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

52 lines
1.4 KiB
Lean4

/-!
# Test for `grind +locals` flag
This tests that `grind +locals` adds local definitions from the current file.
-/
-- A simple definition that provides an equation grind can use
def foo (n : Nat) : Nat := n + 1
-- Without +locals, grind shouldn't know about foo
-- (This test verifies +locals is actually doing something)
/--
error: `grind` failed
case grind
n : Nat
h : ¬foo n = n + 1
⊢ False
[grind] Goal diagnostics
[facts] Asserted facts
[prop] ¬foo n = n + 1
[eqc] False propositions
[prop] foo n = n + 1
[cutsat] Assignment satisfying linear constraints
[assign] n := 0
[assign] foo n := 2
-/
#guard_msgs in
example (n : Nat) : foo n = n + 1 := by grind
-- Test that grind +locals can use the equation `foo n = n + 1`
example (n : Nat) : foo n = n + 1 := by grind +locals
-- An irrelevant definition that should NOT appear in grind? suggestions
def bar (n : Nat) : Nat := n * 2
-- Test that grind? +locals suggests only the relevant definition (foo), not bar
/--
info: Try these:
[apply] grind only [foo]
[apply] grind => instantiate only [foo]
-/
#guard_msgs in
example (n : Nat) : foo n = n + 1 := by grind? +locals
-- Test with a definition that has multiple equations via pattern matching
def isZero : Nat Bool
| 0 => true
| _ + 1 => false
example : isZero 0 = true := by grind +locals
example (n : Nat) : isZero (n + 1) = false := by grind +locals