Zulip Chat Archive

Stream: lean4

Topic: Odd `failed to compile definition` error


Geoffrey Irving (Jan 18 2024 at 21:57):

I'm not sure what's going on here:

import Mathlib.Data.Complex.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.Real  -- Removing this import fixes things

class Approx (A : Type) (R : outParam Type) where

class ApproxAddGroup (A : Type) (R : outParam Type) [AddGroup R] extends
  Neg A, Approx A R where

structure Box where

instance : Approx Box  where
instance : Neg Box where neg x := sorry

/-- Bails with `consider marking it as noncomputable` if we do the `...Pow.Real` import -/
instance : ApproxAddGroup Box  where

What's noncomputable about ApproxAddGroup, given that it declares no code? It also seems odd that removing the Mathlib.Analysis.SpecialFunctions.Pow.Real import fixes things.

Geoffrey Irving (Jan 18 2024 at 22:01):

This isn't blocking me because I can in fact just mark the instances noncomputable, but it was surprising.

Alex J. Best (Jan 19 2024 at 13:46):

Yeah I agree this is surprising / annoying, but it does make sense, docs#Complex.instNormedAddCommGroupComplex is noncomputable and that is on the instance path that is used to infer [AddGroup Complex] as long as Mathlib.Analysis.Complex.Basic is imported (transitively). So even though the structure is projected to a bunch of things that are computable the viral noncomputable marker tricks lean. Maybe we need a computable! keyword or something for such cases. docs#Complex.Complex.addGroupWithOne is what is used without the import

Geoffrey Irving (Jan 19 2024 at 14:27):

Ah, that makes sense.


Last updated: May 02 2025 at 03:31 UTC