Skip to content

Commit bdd5db4

Browse files
committed
feat: add expose_names
1 parent d6657d5 commit bdd5db4

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/Init/Grind/Interactive.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,13 @@ macro_rules
172172
/-- `rename_i x_1 ... x_n` renames the last `n` inaccessible names using the given names. -/
173173
syntax (name := renameI) "rename_i" (ppSpace colGt binderIdent)+ : grind
174174

175+
/--
176+
`expose_names` renames all inaccessible variables with accessible names, making them available
177+
for reference in generated tactics. However, this renaming introduces machine-generated names
178+
that are not fully under user control. `expose_names` is primarily intended as a preamble for
179+
generated `grind` tactic scripts.
180+
-/
181+
syntax (name := exposeNames) "expose_names" : grind
182+
175183
end Grind
176184
end Lean.Parser.Tactic

src/Lean/Elab/Tactic/Grind/BuiltinTactic.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Lean.Meta.Tactic.Grind.Anchor
2020
import Lean.Meta.Tactic.Grind.Arith.CommRing.PP
2121
import Lean.Meta.Tactic.Grind.Arith.Linear.PP
2222
import Lean.Meta.Tactic.Grind.AC.PP
23+
import Lean.Meta.Tactic.ExposeNames
2324
import Lean.Elab.Tactic.Basic
2425
import Lean.Elab.Tactic.RenameInaccessibles
2526
namespace Lean.Elab.Tactic.Grind
@@ -354,4 +355,10 @@ where
354355
replaceMainGoal [{ goal with mvarId }]
355356
| _ => throwUnsupportedSyntax
356357

358+
@[builtin_grind_tactic exposeNames] def evalExposeNames : GrindTactic := fun _ => do
359+
let goal ← getMainGoal
360+
let mvarId ← goal.mvarId.exposeNames
361+
liftGrindM <| resetAnchors
362+
replaceMainGoal [{ goal with mvarId }]
363+
357364
end Lean.Elab.Tactic.Grind

tests/lean/run/grind_interactive.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,4 +473,10 @@ example : (a : Point Nat) → p a → x ≠ y → False := by
473473
cases #e2a6
474474
all_goals sorry
475475

476+
example : (a : Point Nat) → p a → x ≠ y → False := by
477+
grind =>
478+
expose_names
479+
cases #6ccb
480+
sorry
481+
476482
end Ex1

0 commit comments

Comments
 (0)