This PR improves the E-matching pattern inference procedure in `grind`.
Consider the following theorem:
```lean
@[grind →]
theorem eq_empty_of_append_eq_empty {xs ys : Array α} (h : xs ++ ys = #[]) : xs = #[] ∧ ys = #[] :=
append_eq_empty_iff.mp h
```
Before this PR, `grind` inferred the following pattern:
```lean
@HAppend.hAppend _ _ _ _ #2 #1
```
Note that this pattern would match any `++` application, even if it had
nothing to do with arrays. With this PR, the inferred pattern becomes:
```lean
@HAppend.hAppend (Array #3) (Array _) (Array _) _ #2 #1
```
With the new pattern, the theorem will not be considered by `grind` for
goals that do not involve `Array`s.
32 lines
1.1 KiB
Text
32 lines
1.1 KiB
Text
reset_grind_attrs%
|
|
|
|
/--
|
|
info: [grind.ematch.pattern] List.append_ne_nil_of_left_ne_nil: [@HAppend.hAppend (List #3) (List _) (List _) _ #2 #0]
|
|
-/
|
|
#guard_msgs (info) in
|
|
set_option trace.grind.ematch.pattern true in
|
|
attribute [grind] List.append_ne_nil_of_left_ne_nil
|
|
|
|
/--
|
|
info: [grind.ematch.pattern] List.append_ne_nil_of_right_ne_nil: [@HAppend.hAppend (List #3) (List _) (List _) _ #1 #2]
|
|
-/
|
|
#guard_msgs (info) in
|
|
set_option trace.grind.ematch.pattern true in
|
|
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 ++ [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
|