File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77prelude
88public import Lean.Elab.Tactic.Grind.Basic
99import Lean.Meta.Tactic.Grind.Intro
10- import Lean.Meta.Tactic.Grind.RevertAll
10+ import Lean.Meta.Tactic.Grind.MarkAccessible
1111import Lean.Elab.SyntheticMVars
1212import Lean.Meta.Tactic.Grind.Solve
1313namespace Lean.Elab.Tactic.Grind
Original file line number Diff line number Diff line change @@ -32,10 +32,7 @@ private def mkImpossibleNegType (mainGoal : MVarId) (goalType : Expr)
3232 (cfg : Parser.Tactic.ImpossibleConfig) :
3333 MetaM (Expr × Array Name) := mainGoal.withContext do
3434 let dummy ← mkFreshExprSyntheticOpaqueMVar goalType
35- let cleaned ← dummy.mvarId!.cleanup
36- let (_, reverted) ← cleaned.revert
37- (clearAuxDeclsInsteadOfRevert := true )
38- (← cleaned.getDecl).lctx.getFVarIds
35+ let reverted ← dummy.mvarId!.revertAll
3936 let revertedType ← reverted.getType
4037 let r ← Closure.mkValueTypeClosure revertedType (mkConst ``True)
4138 (zetaDelta := false )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ Authors: Leonardo de Moura
66module
77prelude
88public import Lean.Meta.Tactic.Grind.Attr
9- public import Lean.Meta.Tactic.Grind.RevertAll
9+ public import Lean.Meta.Tactic.Grind.MarkAccessible
1010public import Lean.Meta.Tactic.Grind.Types
1111public import Lean.Meta.Tactic.Grind.Util
1212public import Lean.Meta.Tactic.Grind.Cases
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import Lean.Meta.Tactic.Grind.Util
1212import Lean.Meta.Tactic.Grind.CasesMatch
1313import Lean.Meta.Tactic.Grind.Injection
1414import Lean.Meta.Tactic.Grind.Core
15- import Lean.Meta.Tactic.Grind.RevertAll
15+ import Lean.Meta.Tactic.Grind.MarkAccessible
1616import Init.Grind.Util
1717public section
1818namespace Lean.Meta.Grind
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import Lean.PrettyPrinter
1212import Lean.Meta.Tactic.ExposeNames
1313import Lean.Meta.Tactic.Simp.Diagnostics
1414import Lean.Meta.Tactic.Simp.Rewrite
15- import Lean.Meta.Tactic.Grind.RevertAll
15+ import Lean.Meta.Tactic.Grind.MarkAccessible
1616import Lean.Meta.Tactic.Grind.Proj
1717import Lean.Meta.Tactic.Grind.ForallProp
1818import Lean.Meta.Tactic.Grind.CtorIdx
Original file line number Diff line number Diff line change @@ -51,21 +51,4 @@ def _root_.Lean.MVarId.markAccessible (mvarId : MVarId) : MetaM MVarId := mvarId
5151 mvarId.assign mvarNew
5252 return mvarNew.mvarId!
5353
54- /--
55- Reverts all free variables in the goal `mvarId`.
56- **Remark** : Auxiliary local declarations are cleared.
57- The `grind` tactic also clears them, but this tactic can be used independently by users.
58- -/
59- def _root_.Lean.MVarId.revertAll (mvarId : MVarId) : MetaM MVarId := mvarId.withContext do
60- mvarId.checkNotAssigned `revertAll
61- let mut toRevert := #[]
62- for fvarId in (← getLCtx).getFVarIds do
63- unless (← fvarId.getDecl).isAuxDecl do
64- toRevert := toRevert.push fvarId
65- mvarId.setKind .natural
66- let (_, mvarId) ← mvarId.revert toRevert
67- (preserveOrder := true )
68- (clearAuxDeclsInsteadOfRevert := true )
69- return mvarId
70-
7154end Lean.Meta.Grind
Original file line number Diff line number Diff line change @@ -66,4 +66,19 @@ def _root_.Lean.MVarId.revertFrom (mvarId : MVarId) (fvarId : FVarId) : MetaM (A
6666 let fvarIds := (← getLCtx).foldl (init := #[]) (start := localDecl.index) fun fvarIds decl => fvarIds.push decl.fvarId
6767 mvarId.revert fvarIds (preserveOrder := true ) (clearAuxDeclsInsteadOfRevert := true )
6868
69+ /--
70+ Reverts all free variables in the goal `mvarId`.
71+ **Remark** : Auxiliary local declarations are cleared.
72+ -/
73+ def _root_.Lean.MVarId.revertAll (mvarId : MVarId) : MetaM MVarId := mvarId.withContext do
74+ mvarId.checkNotAssigned `revertAll
75+ let mut toRevert := #[]
76+ for fvarId in (← getLCtx).getFVarIds do
77+ unless (← fvarId.getDecl).isAuxDecl do
78+ toRevert := toRevert.push fvarId
79+ let (_, mvarId) ← mvarId.revert toRevert
80+ (preserveOrder := true )
81+ (clearAuxDeclsInsteadOfRevert := true )
82+ return mvarId
83+
6984end Lean.Meta
Original file line number Diff line number Diff line change 11import Lean
2+
3+ set_option linter.unusedVariables false
4+
25/-! # Tests for the `impossible` tactic combinator -/
36
47-- Closed goal: the negation has no binders, so the user proves it directly.
@@ -250,3 +253,16 @@ example : 0 = 1 ∧ True := by
250253 constructor
251254 impossible by decide
252255 trivial
256+
257+ -- Test that we don’t run `cleanup` in `impossible`.
258+
259+ /--
260+ error: unsolved goals
261+ ⊢ False
262+ ---
263+ trace: ⊢ ¬∀ {α : Type u_1} (xs : List α), xs.length > 0 → xs = [] → False
264+ -/
265+ #guard_msgs in
266+ example (xs : List α) (h : xs.length > 0 ) : xs ≠ [] := by
267+ intro h_empty
268+ impossible by trace_state; simp
You can’t perform that action at this time.
0 commit comments