-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
grind
parameter issues and configuration (#6686)
This PR fixes parameter processing, initialization, and attribute handling issues in the `grind` tactic.
- Loading branch information
1 parent
4d4c094
commit d4070d4
Showing
6 changed files
with
105 additions
and
17 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
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,48 @@ | ||
def replicate : (n : Nat) → (a : α) → List α | ||
| 0, _ => [] | ||
| n+1, a => a :: replicate n a | ||
|
||
/-- | ||
info: [grind.ematch.pattern] replicate.eq_1: [@replicate #1 `[0] #0] | ||
[grind.ematch.pattern] replicate.eq_2: [@replicate #2 (Lean.Grind.offset #0 (1)) #1] | ||
-/ | ||
#guard_msgs (info) 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] |