-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: kernel exception from fvars left from ?m a b
instantiation
#4410
Conversation
aaaee8c
to
dcfd93b
Compare
mkLambdaFVarsWithLetDeps
handles let
s before lambdasmkLambdaFVarsWithLetDeps
, handle let
s before lambdas
Hello @llllvvuu and thanks for your first contribution to lean! The Good issue reports, including good minimized test cases, and contributions to less central components (error messages, leaf tactics, etc.) are a good way to build expertise, reputation and trust, before high-risk areas of the code. |
3f03a5b
to
f07661f
Compare
No worries, it's not a big deal to me whether this particular patch + test case is what gets merged. I'm glad if it's of some use. |
Mathlib CI status (docs):
|
mkLambdaFVarsWithLetDeps
, handle let
s before lambdas?m a b c
; add (useZeta := true)
?m a b c
; add (useZeta := true)
?m a b c
; add (useZeta := true)
8d77259
to
f73d07e
Compare
f73d07e
to
80affa4
Compare
80affa4
to
c365a0e
Compare
?m a b c
; add (useZeta := true)
?m a b
instantiation
I just changed the fix/description, new one is just changing a flag. It still doesn't achieve not touching central modules, but I hope it sheds some more light on the issue (test case further minimized as well). |
The following example raises `error: (kernel) declaration has free variables '_example'`: ```lean example: True → Nat := let a : Nat := Nat.zero fun (_ : True) => let b : Nat := Nat.zero (fun (_ : a = b) => 0) (Eq.refl a) ``` During elaboration of `0`, `elabNumLit` creates a synthetic mvar `?_uniq.16` which gets abstracted by `elabFun` to `?_uniq.16 := ?_uniq.50 _uniq.6 _uniq.12`. The `isDefEq` to `instOfNatNat 0` results in: ``` ?_uniq.50 := fun ([email protected]._hyg.13 : True) => let b : Nat := Nat.zero fun ([email protected]._hyg.23 : Eq.{1} Nat _uniq.4 b) => instOfNatNat 0 ``` This has a free variable `_uniq.4` which was `a`. When the application of `?_uniq.50` to `#[leanprover#2, #0]` is instantiated, the `let b : Nat := Nat.zero` blocks the beta-reduction and `_uniq.4` remains in the expression. fix: add `(useZeta := true)` here: https://github.com/leanprover/lean4/blob/ea46bf2839ad1c98d3a0c3e5caad8a81f812934c/src/Lean/MetavarContext.lean#L567
c365a0e
to
12395b2
Compare
Looks good. We will merge it. Thanks! |
This linter was silently not doing anything until leanprover/lean4#4410 was fixed, and now it is working so a backlog of warnings needed to be addressed. Some were addressed here: #13680. The warnings in this PRs are false positives (leanprover-community/batteries#428?), but a workaround is put in place. Co-authored-by: L Lllvvuu <[email protected]>
This linter was silently not doing anything until leanprover/lean4#4410 was fixed, and now it is working so a backlog of warnings needed to be addressed. Some were addressed here: #13680. The warnings in this PRs are false positives (leanprover-community/batteries#428?), but a workaround is put in place. Co-authored-by: L Lllvvuu <[email protected]>
Closes #4375
The following example raises
error: (kernel) declaration has free variables '_example'
:During elaboration of
0
,elabNumLit
creates a synthetic mvar?_uniq.16
which gets abstracted byelabFun
to?_uniq.16 := ?_uniq.50 _uniq.6 _uniq.12
. TheisDefEq
toinstOfNatNat 0
results in:This has a free variable
_uniq.4
which wasa
.When the application of
?_uniq.50
to#[#2, #0]
is instantiated, thelet b : Nat := Nat.zero
blocks the beta-reduction and_uniq.4
remains in the expression.fix: add
(useZeta := true)
here:lean4/src/Lean/MetavarContext.lean
Line 567 in ea46bf2