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

31 lines
1.2 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
theorem sq_inj (x y : Nat) (h : x ^ 2 = y ^ 2) : x = y := by
-- Puzzle for anyone bored: a quick Mathlib-free proof?
sorry
example (a b c d e : Nat) (_ : a = b) (_ : b = c) (_ : c ^ 2 = d ^ 2) (_ : d = e) : a = e := by
grind =>
-- We can verify that `grind` can see certain facts:
have : a = c
-- We can ask for all the known equivalence classes,
-- or classes involving certain terms:
show_eqcs a
-- We can add additional facts, giving proofs inline.
have : c = d := by grind? +suggestions
-- These facts are automatically used to extend equivalence classes,
-- so in this case the `have` statement itself closes the goal.
example (a b c d e : Nat) (_ : a = b) (_ : b = c) (_ : c ^ 2 = d ^ 2) (_ : d = e) : a = e := by
grind [sq_inj]
example (x y : Rat) (_ : x^2 = 1) (_ : x + y = 1) : y 2 := by
fail_if_success grind
grind =>
-- We can also use `have` statements as clues to guide `grind`.
have : x = 1 x = -1
-- Here `grind` can both prove the `have` statement (via a Grobner argument)
-- and finish off afterwards (using linear arithmetic),
-- even though it can't close the original goal by itself.
finish