This PR introduces support for user-defined fallback code in the `grind` tactic. The fallback code can be utilized to inspect the state of failing `grind` subgoals and/or invoke user-defined automation. Users can now write `grind on_failure <code>`, where `<code>` should have the type `GoalM Unit`. See the modified tests in this PR for examples.
17 lines
551 B
Text
17 lines
551 B
Text
import Lean.Meta.Tactic.Grind
|
||
|
||
def g {α : Sort u} (a : α) := a
|
||
|
||
open Lean Meta Grind in
|
||
def fallback : Fallback := do
|
||
let nodes ← filterENodes fun e => return e.self.isAppOf ``g
|
||
logInfo (nodes.toList.map (·.self))
|
||
(← get).mvarId.admit
|
||
|
||
-- `grind` final state must contain only two `g`-applications
|
||
/--
|
||
info: [g (a, b), g (g (a, b))]
|
||
-/
|
||
#guard_msgs (info) in
|
||
example {β : Type v} {α : Type u} (a c : α) (b d : β) : g.{max u v + 1} (a, b) = (c, d) → g (g.{max (u+1) (v+1)} (a, b)) = (c, d) → False := by
|
||
grind on_failure fallback
|