lean4 icon indicating copy to clipboard operation
lean4 copied to clipboard

fix: handle delayed-assigned mvars in `isDefEq` safely

Open thorimur opened this issue 1 year ago • 3 comments

Currently, unknown fvars can be introduced during isDefEq when synthetic opaque metavariables are assignable and appear in a delayed assignment. Specifically, if ?m.23 is delayed-assigned to ?a, we currently replace ?m.23 as bs with ?a bs. However, if the type of ?a depends on the new fvars in its context, we've now introduced unknown fvars to isDefEq. Notably, this happens when elaborating expressions like fun x => ?a which leave the type of ?a unspecified (and therefore dependent on x via another delayed-assigned mvar).

This PR checks that either the context of ?a is compatible with the local context, or attempts to clear the new fvars from ?a's context if ?a's context is strictly larger than the current one. Otherwise, isDefEq now fails.


Closes #3393

thorimur avatar Mar 08 '24 19:03 thorimur

Mathlib CI status (docs):

It looks like the Mathlib failure is genuinely caused by this PR, right?

kim-em avatar Mar 22 '24 00:03 kim-em

Yes, I believe this one's for real. :) It introduces the possibility of isDefEq failing where it otherwise wouldn't. Contrast with #3473 (an alternate more experimental approach to the same problem) which built mathlib around the same time.

thorimur avatar Mar 22 '24 00:03 thorimur