-
Notifications
You must be signed in to change notification settings - Fork 437
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
stack overflow during elaboration #6013
Comments
A quick dbg_trace suggests a loop between the mvars for
|
I have found out what causes the problem. It is a subtle violation of the occurs check. Consider
We can see the assignment
and hovering over ?m.29 shows that
So ?m.7 appears in the type of the new assignment. Such a problem would usually be caught by the function |
I don't think this is a problem with the implementation of |
A somewhat easier way to fix this problem is at the place where the let-expression is created, to make it so that the let expression isn't created if the bound variable doesn't appear in the body. (similar to how mkBinding is usually used with lean4/src/Lean/MetavarContext.lean Line 1078 in 9f42368
However, I'm not sure if that fixes the underlying problem. |
This PR fixes bug at `typeOccursCheck` that allowed cycles in the metavariable assignments. closes #6013
This PR fixes bug at `typeOccursCheck` that allowed cycles in the metavariable assignments. closes #6013
This PR does the same fix as #6104, but such that it doesn't break the test/the file in `Plausible`. This is done by not creating unused let binders in metavariable types that are made by `elimMVar`. (This is also a positive thing for users looking at metavariable types, for example in error messages) We get rid of `skipAtMostNumBinders`. This function was originally defined for the purpose of making this test work, but it is a hack because it allows cycles in the metavariable context. It would make sense to split these changes into 2 PRs, but I combined them here to show that the combination of them closes #6013 without breaking anything Closes #6013
Prerequisites
Please put an X between the brackets as you perform the following steps:
https://github.com/leanprover/lean4/issues
Avoid dependencies to Mathlib or Batteries.
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
Elaborating the following code causes a stack overflow:
Context
I found this by accident
Steps to Reproduce
write the above function
Expected behavior:
Elaboration fails. And if we extend the example to
it should complain about
Actual behavior:
A stack overflow happens, crashing the lean server
Versions
The bug is present from 4.9.0 until now, 4.14.0-rc2
It was introduced in lean#3940, commit 97a7d4234bd76bc0f61e43b8c6a78117c1376df
Additional Information
From the stack trace we can see the source of the infinite recursion. It is a mutual block in MetavarContext.lean, and has the following pattern of function calls appearing repeatedly:
(the top of the list corresponds to the top of the stack, so each function calls the one above it)
This infinite loop is reached via a call to
mkLambdaFVars
, which callsmkBinding
. In particular this call inelabFunValues
inMutualDef.lean
. So I think the particular lambda that is trying to be created isImpact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: