This PR implements the basic tactics for the new `grind` interactive
mode. While many additional `grind` tactics will be added later, the
foundational framework is already operational. The following `grind`
tactics are currently implemented: `skip`, `done`, `finish`, `lia`, and
`ring`.
This PR also removes the notion of `grind` fallback procedure since it
is subsumed by the new framework. Examples:
```lean
example (x y : Nat) : x ≥ y + 1 → x > 0 := by
grind => skip; lia; done
open Lean Grind
example [CommRing α] (a b c : α)
: a + b + c = 3 →
a^2 + b^2 + c^2 = 5 →
a^3 + b^3 + c^3 = 7 →
a^4 + b^4 + c^4 = 9 := by
grind => ring
```
45 lines
1.4 KiB
Text
45 lines
1.4 KiB
Text
module
|
||
meta import Lean
|
||
#exit
|
||
|
||
def f (a : Nat) := a + a + a
|
||
def g (a : Nat) := a + a
|
||
|
||
-- Prints the equivalence class containing a `f` application
|
||
open Lean Meta Grind in
|
||
meta def fallback : Fallback := do
|
||
let #[n, _] ← filterENodes fun e => return e.self.isApp && e.self.isAppOf ``f | unreachable!
|
||
let eqc ← getEqc n.self (sort := true)
|
||
trace[Meta.debug] eqc
|
||
(← get).mvarId.admit
|
||
|
||
set_option trace.Meta.debug true
|
||
set_option grind.debug true
|
||
set_option grind.debug.proofs true
|
||
|
||
/-- trace: [Meta.debug] [c, d, f a, f b] -/
|
||
#guard_msgs (trace) in
|
||
example (a b c d : Nat) : a = b → f a = c → f b = d → False := by
|
||
grind on_failure fallback
|
||
|
||
/-- trace: [Meta.debug] [c, d, f a, f b] -/
|
||
#guard_msgs (trace) in
|
||
example (a b c d : Nat) : f a = c → f b = d → a = b → False := by
|
||
grind on_failure fallback
|
||
|
||
/-- trace: [Meta.debug] [c, d, f (g a), f (g b)] -/
|
||
#guard_msgs (trace) in
|
||
example (a b c d e : Nat) : f (g a) = c → f (g b) = d → a = e → b = e → False := by
|
||
grind on_failure fallback
|
||
|
||
/-- trace: [Meta.debug] [c, d, f v, f (g b)] -/
|
||
#guard_msgs (trace) in
|
||
example (a b c d e v : Nat) : f v = c → f (g b) = d → a = e → b = e → v = g a → False := by
|
||
grind on_failure fallback
|
||
|
||
-- arrow congruence test
|
||
example : α = α' → α'' = α' → β' = β → (α → β) = (α'' → β') := by
|
||
grind
|
||
|
||
example (a b c : Nat) (h₁ : a = c) (h₂ : b = c) : (a = b → Nat) = (b = a → Nat) := by
|
||
grind
|