Files
lean4/tests/elab/try_first_par.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

44 lines
1.3 KiB
Lean4
Raw Permalink 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.
import Lean.LibrarySuggestions.Default
/-!
# Test for `first_par` combinator in try?
This tests that `try?` uses `first_par` internally to try multiple grind variants
(`grind? +suggestions`, `grind? +locals`, `grind? +locals +suggestions`) in parallel
and return the first successful result.
The test creates a scenario where:
1. Basic tactics (rfl, assumption, simp) fail
2. Basic grind fails
3. But `grind +locals +suggestions` succeeds by finding a local theorem via library search
-/
structure MyPair (α : Type) where
fst : α
snd : α
def foo (x : MyPair Nat) := x
-- A theorem about MyPair that grind +suggestions can find via library search
theorem myPair_eq (p : MyPair Nat) (h1 : p.fst = 1) (h2 : p.snd = 1) :
p = foo 1, 1 := by
cases p; simp_all [foo]
-- A goal where:
-- - atomic block fails (no simple solution, basic grind can't prove it)
-- - first_par succeeds: grind +locals +suggestions finds myPair_eq
-- The +locals +suggestions flags are filtered out in the suggestion output
/--
info: Try these:
[apply] grind only [myPair_eq, foo]
[apply] grind =>
instantiate only [myPair_eq]
instantiate only [foo]
-/
#guard_msgs in
example (p : MyPair Nat) (h1 : p.fst = 1) (h2 : p.snd = 1) : p = 1, 1 := by
fail_if_success grind
fail_if_success grind +locals
fail_if_success grind +suggestions
try?