Open gebner opened 1 year ago
I think we might have had this problem in lean 3 too, it was not uncommon to have to add a type annotation to make dot notation work.
I've clarified the title of the issue. This is a different issue, and it's new in Lean 4 because we didn't have the stuck exception handling in Lean 3. This issue also appears without dot-notation:
#check Iff.mp foo -- fails
#check Iff.mp foo h -- fails
The last five commands should all succeed. Mathlib has a lot of lemmas like
foo
(usually due toCovariantClass
, so e.g.le_neg
,abs_pos
, etc.). (It's important that the instance[CommMonoid α] → Monoid α
is not a subobject projection here, but this is super common in the algebraic hierarchy.)What's happening here is that we ignore the stuck exception in nested TC problems. So Lean thinks that the only
IsCommutative
instance does not apply because it cannot unifyMonoid.toLeftUnit =?= CommMonoid.toLeftUnit
while the type is still a metavariable. And since we ignore the stuck exception, we never try again. cc @KhaA workaround is to specify the type manually (surprising syntax btw):
For comparison, all is well without the
IsCommutative
argument: