Zulip Chat Archive
Stream: mathlib4
Topic: Bug for quotients?
David Ang (Aug 05 2023 at 09:16):
When making a structure based on quotient groups, sometimes instances are not found? Here is an MWE:
import Mathlib.GroupTheory.QuotientGroup
structure foo := (unfoo : ℕ)
instance fooSetoid : Setoid foo := sorry
def bar := Quotient fooSetoid
instance barNeg : Neg bar := sorry
variable (x : ℕ)
#check (-(⟦⟨x⟩⟧ : bar)) -- no instance of Neg (Quotient fooSetoid)
#check (barNeg.neg (⟦⟨x⟩⟧ : bar)) -- instance found
Not sure if it's a bug in instance resolution or reducibility or something else.
Sebastien Gouezel (Aug 05 2023 at 09:43):
When you are writing
#check (-(⟦⟨x⟩⟧ : bar))
you are not forcing Lean to consider that ⟦⟨x⟩⟧
is of type bar
, you are just helping it to elaborate. Here Lean discards your advice, and considers it as a term of type Quotient fooSetoid
. And it can't find a Neg
instance on this one, which is normal since you haven't declared one (it's exactly what the error message says).
To force Lean to consider ⟦⟨x⟩⟧
of type bar
, you can for instance write id ⟦⟨x⟩⟧ : bar
.
Scott Morrison (Aug 05 2023 at 09:45):
Alternatively an explicit bar.mk
constructor to help guide the type.
Eric Wieser (Aug 05 2023 at 10:08):
Making bar
an abbrev
here would work too I think
David Ang (Aug 05 2023 at 16:33):
I see. Thanks for the suggestions!
Last updated: Dec 20 2023 at 11:08 UTC