lean4-htt/tests/elab/issue13691.lean
Sebastian Graf ed790e99b0
fix: strip hypothesis-naming metadata from proof-mode targets (#13812)
This PR fixes `mconstructor`, `mleft`, and `mright` failing inside
`mhave` blocks (#13691), and `mspecialize` failing after a `mrevert;
mintro` round trip. Both cases stem from hypothesis-naming `Expr.mdata`
leaking from hypothesis-conjunction leaves into non-leaf positions (an
inner target, or the antecedent of an `SPred.imp` target), where
downstream pattern matches did not see through it.

Fixed by stripping the mdata at the offending non-leaf positions in
`elabMHave`, `elabMReplace`, and `mRevert`.
2026-05-21 16:18:17 +00:00

41 lines
927 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Std.Do
import Std.Tactic.Do
/-!
Regression test for #13691: tactics that pattern-match on `MGoal.target`
(`mconstructor`, `mleft`, `mright`) failed inside `mhave` because the inner
goal's target carried hypothesis-naming metadata. The related round trip
`mrevert h; mintro h; mspecialize h` failed for the symmetric reason inside
`Revert`.
-/
open Std.Do
example (P : SPred [Int]) : P ⊢ₛ P ∧ P := by
mintro hp
mhave h : spred(P ∧ P) := by
mconstructor
· mexact hp
· mexact hp
mexact h
example (P : SPred [Int]) : P ⊢ₛ P P := by
mintro hp
mhave h : spred(P P) := by
mleft
mexact hp
mexact h
example (P : SPred [Int]) : P ⊢ₛ P P := by
mintro hp
mhave h : spred(P P) := by
mright
mexact hp
mexact h
example (P Q : SPred [Int]) : P ⊢ₛ (P → Q) → Q := by
mintro HP HPQ
mrevert HPQ
mintro HPQ
mspecialize HPQ HP
mexact HPQ