Zulip Chat Archive

Stream: mathlib4

Topic: Failing to infer Module instance from Algebra


Kyle Miller (Mar 29 2023 at 19:08):

Is it a known error that you can't get a Module instance if A is a Ring rather than a Semiring?

import Mathlib.Algebra.Algebra.Basic

section
variable [Field k] [Ring A] [Algebra k A]
#check (inferInstance : Semiring A) -- OK
#check (inferInstance : Module k A) -- fails
end

section
variable [Field k] [Semiring A] [Algebra k A]
#check (inferInstance : Semiring A) -- OK
#check (inferInstance : Module k A) -- OK
end

Kyle Miller (Mar 29 2023 at 19:09):

I would expect docs4#Algebra.toModule to apply in both cases.

Matthew Ballard (Mar 29 2023 at 19:13):

Fixed by etaExperiment

Matthew Ballard (Mar 29 2023 at 19:14):

So I guess that answer is yes

Jireh Loreaux (Mar 29 2023 at 20:06):

yes, this was one of the early examples in lean4#2074 (see the second post)

Alex Kontorovich (Mar 31 2023 at 21:35):

What's the status of this bug? I think @Heather Macbeth and I may have encountered it again just now. See mathlib4#3211. It's a case where we have a field but Lean can't seem to infer that it's a ring.

Eric Wieser (Mar 31 2023 at 21:38):

What's the error message you get?

Eric Wieser (Mar 31 2023 at 21:39):

Either way, lean4#2074 is alive and well, and I don't think any imminent fix is incoming

Eric Wieser (Mar 31 2023 at 21:39):

There's a workaround for mathlib4 that's in the works (!4#3171), but it's not ready yet

Eric Wieser (Mar 31 2023 at 21:40):

Oh, I assume you mean these lines

Eric Wieser (Mar 31 2023 at 21:41):

You can use set_option synthInstance.etaExperiment true in ... to test whether the problem is lean4#2074. If it works with that setting and not without, then it's lean4#2074.

Heather Macbeth (Mar 31 2023 at 22:14):

Yup, I just tried it. That's the issue. (cc @Alex Kontorovich)

Heather Macbeth (Mar 31 2023 at 22:15):

So is the current advice to turn that option on in declarations which need it?

Heather Macbeth (Mar 31 2023 at 22:22):

I pushed the change assuming so.


Last updated: Dec 20 2023 at 11:08 UTC