Zulip Chat Archive
Stream: lean4
Topic: Understanding trace.Meta.synthInstance
Filippo A. E. Nuccio (Jan 08 2025 at 10:38):
When I look at the output of
set_option trace.Meta.synthInstance true in
example : 0 = 0 := rfl
I see a strange (to my eyes...) behaviour. Lean is trying to infer two OfNat ?m 0
instances, to make sense of the two 0
's, and this makes sense. What I do not understand is
- Why is it trying twice both for the first and for the second
0
? Indeed, on the left, it tries both aOfNat ?m.4 0
and aOfNat ?m.35 0
; and both aOfNat ?m.18 0
and aOfNat? m.35 0
on the right (of course, the values 4, 18, 35 might vary).
My trial Perhaps what launches the instance search is actually the =
sign, and Lean is trying both with HEq
and with Eq
: in the first case it looks for two types to which the two zeros should belong (m.4
and m.18
), in the second for just one type (m.35)
.
Comment I guess my trial is false, if I replace the statement with example : 0 ≤ 0 := sorry
I still get the same behaviour (plus the one for LE
, of course), although HLE
does not exist...
- At any rate, I do not understand why after some trials for the left-hand
0
it gives up, while for the right-hand one it ends up findingOfNat Nat 0
. Not only is not clear to me where this asymmetry comes from, but also how can it be happy having only found the instance on the RHS and having abandoned the LHS to its fate...
Eric Wieser (Jan 08 2025 at 11:52):
(I'll briefly hijack this thread to suggest upvoting lean4#6389, which causes trace.Meta.synthInstance
to be much harder to read than it was supposed to be)
Edward van de Meent (Jan 08 2025 at 11:58):
(the indistinguishability of issue numbers vs pr numbers really doesn't help with reading that sentence)
Last updated: May 02 2025 at 03:31 UTC