Skip to content
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

MVarId.revertAll snags auxiliary declarations, leading to termination issues #6263

Open
3 tasks
eric-wieser opened this issue Nov 29, 2024 · 3 comments
Open
3 tasks
Labels
bug Something isn't working

Comments

@eric-wieser
Copy link
Contributor

eric-wieser commented Nov 29, 2024

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

Lean.MVarId.revertAll fails to ignore auxiliary declarations if variable is used.

Context

[Broader context that the issue occurred in. If there was any prior discussion on the Lean Zulip, link it here as well.]

Steps to Reproduce

import Lean

open Lean.Elab.Tactic

variable (p q : Prop)
theorem foo (h : p ∧ q) : q ∧ p := by
  run_tac liftMetaTactic1 (·.revertAll)
  sorry

Expected behavior: Goal is ⊢ ∀ (p q : Prop), p ∧ q → q ∧ p, no errors

Actual behavior: Goal is ⊢ ∀ (p q : Prop), p ∧ q → (p ∧ q → q ∧ p) → q ∧ p, and the error is

fail to show termination for
  foo
with errors
failed to infer structural recursion:
Not considering parameter p of foo:
  it is unchanged in the recursive calls
Not considering parameter q of foo:
  it is unchanged in the recursive calls
Cannot use parameter h:
  the type p ∧ q does not have a `.brecOn` recursor

Versions

4.14.0-rc3

Additional Information

[Additional information, configuration or data that might be necessary to reproduce the issue]

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@eric-wieser eric-wieser added the bug Something isn't working label Nov 29, 2024
@eric-wieser
Copy link
Contributor Author

Using clearAuxDecls seems to work, but the implementatoin of revertAll suggests it is supposed to handle this for me.

@nomeata
Copy link
Collaborator

nomeata commented Nov 29, 2024

So there is a workaround, you are unblocked and this is just™ a matter of misleading API design/documentation?

@eric-wieser
Copy link
Contributor Author

eric-wieser commented Nov 29, 2024

Yes, I am unblocked, but these lines make me thing this function was intended to operate as I was hoping it would:

let fvars ← fvarIds.filterMapM fun fvarId => do
if (← fvarId.getDecl).isAuxDecl then
return none
else
return some (mkFVar fvarId)

Empirically, the current behavior seems to be "ignore leading auxiliary declarations", so I'd lean towards this being a design issue rather than a documentation issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants