-
Notifications
You must be signed in to change notification settings - Fork 350
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
Non-termination at inductive predicate #1616
Labels
Comments
I took a look at this and found that elaborating the inductive type hangs on this line: lean4/src/Lean/Elab/Inductive.lean Line 357 in 0b243f0
I inserted logging into Lines 1503 to 1526 in 0b243f0
and found that go was being executed in an infinite loop:
The fix I came up with filters out previously seen mvars to stop this case, though there may be a more efficient solution. partial def collectUnassignedMVars (type : Expr) (init : Array Expr := #[]) (except : MVarId → Bool := fun _ => false)
: TermElabM (Array Expr) := do
let mvarIds ← getMVars type
if mvarIds.isEmpty then
return init
else
go mvarIds.toList init init
where
go (mvarIds : List MVarId) (result visited : Array Expr) : TermElabM (Array Expr) := do
match mvarIds with
| [] => return result
| mvarId :: mvarIds => do
let visited := visited.push (mkMVar mvarId)
if (← mvarId.isAssigned) then
go mvarIds result visited
else if result.contains (mkMVar mvarId) || except mvarId then
go mvarIds result visited
else
let mvarType := (← getMVarDecl mvarId).type
let mvarIdsNew ← getMVars mvarType
let mvarIdsNew := mvarIdsNew.filter fun mvarId => !visited.contains (mkMVar mvarId)
if mvarIdsNew.isEmpty then
go mvarIds (result.push (mkMVar mvarId)) visited
else
go (mvarIdsNew.toList ++ mvarId :: mvarIds) result visited |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
Reported at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Compiler.20stuck.20computing.20something.2E.2E.2E/near/299193185
The text was updated successfully, but these errors were encountered: