lean4-htt/tests/lean/run/grind_eq_pattern.lean
Leonardo de Moura 349da6cae2
feat: improve [grind =] attribute (#6614)
This PR improves the usability of the `[grind =]` attribute by
automatically handling
forbidden pattern symbols. For example, consider the following theorem
tagged with this attribute:
```
getLast?_eq_some_iff {xs : List α} {a : α} : xs.getLast? = some a ↔ ∃ ys, xs = ys ++ [a]
```
Here, the selected pattern is `xs.getLast? = some a`, but `Eq` is a
forbidden pattern symbol.
Instead of producing an error, this function converts the pattern into a
multi-pattern,
allowing the attribute to be used conveniently.
2025-01-12 16:51:09 +00:00

22 lines
734 B
Text

attribute [grind] List.append_ne_nil_of_left_ne_nil
attribute [grind] List.append_ne_nil_of_right_ne_nil
/--
info: [grind.ematch.pattern] List.getLast?_eq_some_iff: [@List.getLast? #2 #1, @some ? #0]
-/
#guard_msgs (info) in
set_option trace.grind.ematch.pattern true in
attribute [grind =] List.getLast?_eq_some_iff
/--
info: [grind.assert] xs.getLast? = b?
[grind.assert] b? = some 10
[grind.assert] xs = []
[grind.assert] (xs.getLast? = some 10) = ∃ ys, xs = ys ++ [10]
[grind.assert] xs = w ++ [10]
[grind.assert] ¬w = [] → ¬w ++ [10] = []
[grind.assert] ¬w ++ [10] = []
-/
#guard_msgs (info) in
set_option trace.grind.assert true in
example (xs : List Nat) : xs.getLast? = b? → b? = some 10 → xs ≠ [] := by
grind