You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When simp? [name] gets replaced with simp only [name'], it can still sometimes alias the current theorem name due to incorrect manipulation of namespaces.
Context
This has been previously filed and resolved in #4591, but the issue still persists.
Steps to Reproduce
defP := True
theoremN.A.B : P := by constructor
theoremN.X.A.B : P := by simp? [N.A.B]
-- Try this: simp only [A.B]
Expected behavior: Lean offers to replace with simp only [N.A.B].
Actual behavior: Lean offers to replace with simp only [A.B], which in this context is a different name from N.A.B, making the theorem recursive.
It did happen in the wild: I have a function NFA.kleene.ε whose behavior on a certain subset of the inputs is characterized by
@[simp]theoremNFA.kleene.ε.some_none
: ReflTransGen (ε E I F) (some q) none ↔ ∃ f ∈ F, ReflTransGen E q f
Then I have a construction on top of it, with a function NFA.Triple.kleene.ε, and a theorem that characterizes the new construction in terms of the previous:
theoremNFA.Triple.kleene.ε.gen
: ReflTransGen (ε E I F) (p, q, s) (p', q', s')
↔ p = p' ∧ s = s'
∧ ReflTransGen (NFA.kleene.ε E (Rel.image I p) (Rel.preimage F s)) q q'
So a similar proof about NFA.Triple.kleene.ε on a subset of inputs proceeds by simply invoking the two aforementioned theorems:
@[simp]theoremNFA.Triple.kleene.ε.some_none
: ReflTransGen (ε E I F) (p, some q, s) (p', none, s')
↔ p = p' ∧ s = s' ∧ (∃ f ∈ Rel.preimage F s, ReflTransGen E q f)
:= by simp only [gen, NFA.kleene.ε.some_none]
Which is where Lean purports to instead use simp only [gen, kleene.ε.none_some] and thus make a cyclic proof.
@nomeata This is a bug in unresolveNameGlobalAvoidingLocals. It is not taking the auxiliary declarations in the local context into account. Here is a repro without simp?
import Lean
defN.A.B := 10theoremN.X.A.B : True := byopen Lean Meta Elab Tactic in
run_tac do
for decl in (← getLCtx) doif decl.isAuxDecl then
IO.println s!"current namespace: {← getCurrNamespace}\nauxiliary declaration: {decl.userName}"
IO.println s!"{``N.A.B} ===> {← unresolveNameGlobalAvoidingLocals ``N.A.B}"sorry/-current namespace: N.X.Aauxiliary declaration: BN.A.B ===> A.B-/
Description
When
simp? [name]
gets replaced withsimp only [name']
, it can still sometimes alias the current theorem name due to incorrect manipulation of namespaces.Context
This has been previously filed and resolved in #4591, but the issue still persists.
Steps to Reproduce
Expected behavior: Lean offers to replace with
simp only [N.A.B]
.Actual behavior: Lean offers to replace with
simp only [A.B]
, which in this context is a different name fromN.A.B
, making the theorem recursive.Versions
4.13.0, 4.16.0-rc2
Impact
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: