lean4-htt/tests/elab/library_search_grind.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

94 lines
2.3 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.

/-!
# Tests for `exact? +grind` and `apply? +grind`
These tests verify that the `+grind` option is accepted syntactically and
enables `grind` as a fallback discharger for subgoals.
-/
/--
info: Try this:
[apply] exact List.ne_nil_of_length_pos h
-/
#guard_msgs in
example (l : List Nat) (h : 0 < l.length) : l ≠ [] := by exact?
/--
info: Try this:
[apply] exact List.ne_nil_of_length_pos (h trivial)
-/
#guard_msgs in
example (l : List Nat) (h : True → 0 < l.length) : l ≠ [] := by exact?
example (l : List Nat) (h : 1 < l.length) : l ≠ [] := by exact List.ne_nil_of_length_pos (by grind)
/--
info: Try this:
[apply] exact List.ne_nil_of_length_pos (by grind)
-/
#guard_msgs in
example (l : List Nat) (h : 1 < l.length) : l ≠ [] := by
exact? +grind
/--
info: Try this:
[apply] exact List.ne_nil_of_length_pos (by grind)
-/
#guard_msgs in
example {P : Prop} (l : List Nat) (p : P) (h : P → 1 < l.length) : l ≠ [] := by
exact? +grind
axiom foo (x : Nat) : x < 37 → 5 < x → x.log2 < 6
/--
info: Try this:
[apply] exact foo x (by grind) (by grind)
-/
#guard_msgs in
example (x : Nat) (h₁ : x < 30) (h₂ : 8 < x) : x.log2 < 6 := by
exact? +grind
inductive MyList (α : Type _) where
| nil : MyList α
| cons : α → MyList α → MyList α
axiom MyListProp : MyList α → Prop
axiom MyListProp2 : MyList α → Prop
@[grind .] axiom mylist_nil : MyListProp (MyList.nil : MyList α)
@[grind .] axiom mylist_cons : ∀ (x : α) (xs : MyList α), MyListProp xs → MyListProp (MyList.cons x xs)
/--
info: Try these:
[apply] (induction xs) <;> grind
[apply] (induction xs) <;> grind only [mylist_nil, mylist_cons]
[apply] ·
induction xs
· grind => instantiate only [mylist_nil]
· grind => instantiate only [mylist_cons]
-/
#guard_msgs in
example (xs : MyList α) : MyListProp xs := by
try?
axiom qux (xs : MyList α) (p : MyListProp xs) : MyListProp2 xs
/--
info: Try these:
[apply] (induction xs) <;> grind
[apply] (induction xs) <;> grind only [mylist_nil, mylist_cons]
[apply] ·
induction xs
· grind => instantiate only [mylist_nil]
· grind => instantiate only [mylist_cons]
-/
#guard_msgs in
example (xs : MyList α) : MyListProp2 xs := by
exact qux xs (by try?)
/--
info: Try this:
[apply] exact qux xs (by try?)
-/
example (xs : MyList α) : MyListProp2 xs := by
exact? +try?