Skip to content

Commit ea957a2

Browse files
committed
chore:
1 parent df53f6f commit ea957a2

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,23 @@ import Lean.Elab.Tactic.Grind.Filter
2727
import Lean.Elab.Tactic.Grind.ShowState
2828
namespace Lean.Elab.Tactic.Grind
2929

30+
def showStateAt (ref : Syntax) (filter : Filter) : GrindTacticM Unit := do
31+
if let goalBefore :: _ := (← getGoals) then
32+
withRef ref <| goalBefore.withContext <| showState filter (isSilent := true)
33+
else
34+
logAt ref (severity := .information) (isSilent := true) "no grind state"
35+
3036
def evalSepTactics (stx : Syntax) : GrindTacticM Unit := do
3137
for arg in stx.getArgs, i in *...stx.getArgs.size do
3238
if i % 2 == 0 then
33-
let `(Parser.Tactic.Grind.grindStep| $tac:grind $[| $[$filter??]?]?) := arg | throwUnsupportedSyntax
34-
evalGrindTactic tac
35-
if let some filter? := filter?? then
36-
if let goal :: _ ← getGoals then
37-
withRef stx <| goal.withContext <| showState filter? (silent := true)
39+
match arg with
40+
| `(Parser.Tactic.Grind.grindStep| $tac:grind) => evalGrindTactic tac
41+
| `(Parser.Tactic.Grind.grindStep| $tac:grind | $[$filter?]?) =>
42+
let filter ← elabFilter filter?
43+
showStateAt arg filter
44+
evalGrindTactic tac
45+
showStateAt arg[1] filter
46+
| _ => throwUnsupportedSyntax
3847
else
3948
saveTacticInfoForToken arg
4049

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Authors: Leonardo de Moura
66
module
77
prelude
88
public import Lean.Elab.Tactic.Grind.Basic
9-
import Lean.Elab.Tactic.Grind.Filter
9+
public import Lean.Elab.Tactic.Grind.Filter
1010
import Lean.Meta.Tactic.Grind.PP
1111
import Lean.Meta.Tactic.Grind.Anchor
1212
import Lean.Meta.Tactic.Grind.Split
@@ -92,18 +92,18 @@ def ppEqcs? (filter : Filter) (collapsed := false) : GrindTacticM (Option Messag
9292
def pushIfSome (msgs : Array MessageData) (msg? : Option MessageData) : Array MessageData :=
9393
if let some msg := msg? then msgs.push msg else msgs
9494

95-
public def showState (filter? : Option (TSyntax `grind_filter)) (silent := false) : GrindTacticM Unit := do
96-
let filter ← elabFilter filter?
95+
public def showState (filter : Filter) (isSilent := false) : GrindTacticM Unit := do
9796
let msgs := #[]
9897
let msgs := pushIfSome msgs (← ppAsserted? filter (collapsed := true))
9998
let msgs := pushIfSome msgs (← ppProps? filter true (collapsed := false))
10099
let msgs := pushIfSome msgs (← ppProps? filter false (collapsed := false))
101100
let msgs := pushIfSome msgs (← ppEqcs? filter (collapsed := false))
102-
logAt (← getRef) (severity := .information) (isSilent := silent) <| MessageData.trace { cls := `grind, collapsed := false } "Grind state" msgs
101+
logAt (← getRef) (severity := .information) (isSilent := isSilent) <| MessageData.trace { cls := `grind, collapsed := false } "Grind state" msgs
103102

104103
@[builtin_grind_tactic Parser.Tactic.Grind.showState] def evalShowState : GrindTactic := fun stx => withMainContext do
105104
let `(grind| show_state $[$filter?]?) := stx | throwUnsupportedSyntax
106-
showState filter?
105+
let filter ← elabFilter filter?
106+
showState filter
107107

108108
@[builtin_grind_tactic showCases] def evalShowCases : GrindTactic := fun stx => withMainContext do
109109
let `(grind| show_cases $[$filter?]?) := stx | throwUnsupportedSyntax

tests/lean/run/grind_interactive.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ example (as bs cs : Array α) (v₁ v₂ : α)
401401
(h₆ : j < as.size)
402402
: cs[j] = as[j] := by
403403
grind =>
404-
instantiate Array.getElem_set
404+
instantiate Array.getElem_set | gen > 0
405405
instantiate Array.getElem_set
406406

407407
example (as bs cs : Array α) (v₁ v₂ : α)

0 commit comments

Comments
 (0)