lean4-htt/tests/lean/run/grind_trace.lean
Leonardo de Moura 20c616503a
feat: add grind? (#6810)
This PR implements a basic `grind?` tactic companion for `grind`. We
will add more bells and whistles later.
2025-01-28 04:17:25 +00:00

81 lines
2.1 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

attribute [grind =] List.length_cons
attribute [grind →] List.getElem?_eq_getElem
attribute [grind =] List.length_replicate
attribute [grind =] List.getElem_replicate
attribute [grind =] List.getElem?_eq_none
attribute [grind =] List.getElem?_eq_some_iff
attribute [grind =] getElem!_pos
attribute [grind =] Option.map_some' Option.map_none'
attribute [grind =] List.getElem?_map
attribute [grind =] List.getElem?_replicate
attribute [grind =] List.getLast?_eq_some_iff
attribute [grind] List.mem_concat_self
attribute [grind =] List.getElem_cons_zero in
attribute [grind =] List.getElem?_cons_zero in
/--
info: Try this: grind only [= List.getElem?_replicate, = List.getElem?_eq_none]
-/
#guard_msgs (info) in
theorem getElem?_replicate' : (List.replicate n a)[m]? = if m < n then some a else none := by
grind?
/--
info: Try this: grind only [= List.length_cons]
-/
#guard_msgs (info) in
example : 0 < (x :: t).length := by
grind?
/--
info: Try this: grind only [= List.getElem?_replicate, = List.getElem?_eq_some_iff, = List.getElem?_map, =
List.getElem_replicate, = List.getElem?_eq_none, = Option.map_some', = Option.map_none', = List.length_replicate, →
List.getElem?_eq_getElem, cases And, cases Or, cases Exists]
-/
#guard_msgs (info) in
theorem map_replicate' : (List.replicate n a).map f = List.replicate n (f a) := by
grind?
/--
info: Try this: grind only [= List.getLast?_eq_some_iff, List.mem_concat_self, cases Exists]
-/
#guard_msgs (info) in
theorem mem_of_getLast?_eq_some' {xs : List α} {a : α} (h : xs.getLast? = some a) : a ∈ xs := by
grind?
def f : Nat → Nat
| 0 => 1
| _ => 2
/--
info: Try this: grind only
-/
#guard_msgs (info) in
example : x = 0 → f x = 1 := by
unfold f
grind? -- should not include match equations
attribute [grind] f
/--
info: Try this: grind only [f]
-/
#guard_msgs (info) in
example : x = 0 → f x = 1 := by
grind? [f]
opaque g : Nat → Nat
theorem gthm : g (g x) = g x := sorry
grind_pattern gthm => g (g x)
/--
info: Try this: grind only [usr gthm]
-/
#guard_msgs (info) in
example : g (g (g x)) = g x := by
grind?