lean4-htt/tests/elab/grind_ematch_patterns.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

49 lines
1.2 KiB
Text
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.

module
def replicate : (n : Nat) → (a : α) → List α
| 0, _ => []
| n+1, a => a :: replicate n a
/--
trace: [grind.ematch.pattern] replicate.eq_1: [@replicate #1 `[0] #0]
[grind.ematch.pattern] replicate.eq_2: [@replicate #2 (#0 + 1) #1]
-/
#guard_msgs (trace) in
set_option trace.grind.ematch.pattern true in
attribute [grind] replicate
example : ys = [] → replicate 0 [] = ys := by
grind only [replicate]
/--
error: invalid `grind` parameter, `replicate` is a definition, the only acceptable (and redundant) modifier is '='
-/
#guard_msgs (error) in
example : ys = [] → replicate 0 [] = ys := by
grind only [←replicate]
example : ys = [] → replicate 0 [] = ys := by
fail_if_success grind only
sorry
example (ys : List α) : n = 0 → replicate n ys = [] := by
grind only [replicate]
example (ys : List α) : n = 0 → List.replicate n ys = [] := by
grind only [List.replicate]
opaque foo : Nat → Nat
opaque bla : Nat → Nat
theorem foo_bla : foo x = bla x := sorry
example : foo x = bla x := by
grind only [_=_ foo_bla]
@[reducible] def inc (_ : Nat) := 1
/--
error: `inc` is a reducible definition, `grind` automatically unfolds them
-/
#guard_msgs (error) in
example : a = 1 → inc x = a := by
grind [inc]