-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for constructors and axioms to the
grind
E-matchi…
…ng module (#6839) This PR ensures `grind` can use constructors and axioms for heuristic instantiation based on E-matching. It also allows patterns without pattern variables for theorems such as `theorem evenz : Even 0`.
- Loading branch information
1 parent
e051311
commit 08ec254
Showing
6 changed files
with
145 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
inductive Even : Nat → Prop | ||
| zero : Even 0 | ||
| plus_two {n} : Even n → Even (n + 2) | ||
|
||
example : Even 2 := by | ||
grind [Even.plus_two, Even.zero] | ||
|
||
attribute [grind] Even.zero | ||
attribute [grind] Even.plus_two | ||
|
||
example : Even 2 := by | ||
grind | ||
|
||
example : Even 4 := by | ||
grind | ||
|
||
/-- | ||
error: `grind` failed | ||
case grind | ||
x✝ : ¬Even 16 | ||
⊢ False | ||
[grind] Diagnostics | ||
[facts] Asserted facts | ||
[prop] ¬Even 16 | ||
[prop] Even 14 → Even 16 | ||
[prop] Even 12 → Even 14 | ||
[prop] Even 10 → Even 12 | ||
[prop] Even 8 → Even 10 | ||
[prop] Even 6 → Even 8 | ||
[eqc] True propositions | ||
[prop] Even 14 → Even 16 | ||
[prop] Even 12 → Even 14 | ||
[prop] Even 10 → Even 12 | ||
[prop] Even 8 → Even 10 | ||
[prop] Even 6 → Even 8 | ||
[eqc] False propositions | ||
[prop] Even 16 | ||
[ematch] E-matching patterns | ||
[thm] Even.plus_two: [Even (Lean.Grind.offset #1 (2))] | ||
[thm] Even.zero: [Even `[0]] | ||
[limits] Thresholds reached | ||
[limit] maximum number of E-matching rounds has been reached, threshold: `(ematch := 5)` | ||
[limit] maximum term generation has been reached, threshold: `(gen := 5)` | ||
[grind] Counters | ||
[thm] E-Matching instances | ||
[thm] Even.plus_two ↦ 5 | ||
-/ | ||
#guard_msgs (error) in | ||
example : Even 16 := by | ||
grind | ||
|
||
example : Even 16 := by | ||
grind (gen := 9) (ematch := 9) | ||
|
||
opaque f : Nat → Nat | ||
|
||
axiom fax (x : Nat) : f (f x) = f x | ||
|
||
example : f (f (f x)) = f x := by | ||
grind [fax] | ||
|
||
attribute [grind] fax | ||
|
||
example : f (f (f x)) = f x := by | ||
grind | ||
|
||
/-- error: invalid E-matching theorem `Nat.succ`, type is not a proposition -/ | ||
#guard_msgs in | ||
attribute [grind] Nat.succ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters