Commit 881c910 1 parent 5285bc7 commit 881c910 Copy full SHA for 881c910
File tree 5 files changed +31
-5
lines changed
5 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,13 @@ Authors: Leonardo de Moura
6
6
prelude
7
7
import Init.Tactics
8
8
9
- namespace Lean.Parser.Attr
9
+ namespace Lean.Parser
10
+ /--
11
+ Reset all `grind` attributes. This command is intended for testing purposes only and should not be used in applications.
12
+ -/
13
+ syntax (name := resetGrindAttrs) "%reset_grind_attrs" : command
10
14
15
+ namespace Attr
11
16
syntax grindEq := "= "
12
17
syntax grindEqBoth := atomic("_" "=" "_ " )
13
18
syntax grindEqRhs := atomic("=" "_ " )
@@ -17,12 +22,10 @@ syntax grindFwd := "→ "
17
22
syntax grindUsr := &"usr "
18
23
syntax grindCases := &"cases "
19
24
syntax grindCasesEager := atomic(&"cases" &"eager " )
20
-
21
25
syntax grindMod := grindEqBoth <|> grindEqRhs <|> grindEq <|> grindEqBwd <|> grindBwd <|> grindFwd <|> grindUsr <|> grindCasesEager <|> grindCases
22
-
23
26
syntax (name := grind) "grind" (grindMod)? : attr
24
-
25
- end Lean.Parser.Attr
27
+ end Attr
28
+ end Lean.Parser
26
29
27
30
namespace Lean.Grind
28
31
/--
Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ def elabGrindPattern : CommandElab := fun stx => do
35
35
Grind.addEMatchTheorem declName xs.size patterns.toList .user
36
36
| _ => throwUnsupportedSyntax
37
37
38
+ open Command in
39
+ @[builtin_command_elab Lean.Parser.resetGrindAttrs]
40
+ def elabResetGrindAttrs : CommandElab := fun _ => liftTermElabM do
41
+ Grind.resetCasesExt
42
+ Grind.resetEMatchTheoremsExt
43
+
38
44
open Command Term in
39
45
@[builtin_command_elab Lean.Parser.Command.initGrindNorm]
40
46
def elabInitGrindNorm : CommandElab := fun stx =>
Original file line number Diff line number Diff line change @@ -60,6 +60,9 @@ builtin_initialize casesExt : SimpleScopedEnvExtension CasesEntry CasesTypes ←
60
60
addEntry := fun s {declName, eager} => s.insert declName eager
61
61
}
62
62
63
+ def resetCasesExt : CoreM Unit := do
64
+ modifyEnv fun env => casesExt.modifyState env fun _ => {}
65
+
63
66
def getCasesTypes : CoreM CasesTypes :=
64
67
return casesExt.getState (← getEnv)
65
68
Original file line number Diff line number Diff line change @@ -224,6 +224,9 @@ private builtin_initialize ematchTheoremsExt : SimpleScopedEnvExtension EMatchTh
224
224
initial := {}
225
225
}
226
226
227
+ def resetEMatchTheoremsExt : CoreM Unit := do
228
+ modifyEnv fun env => ematchTheoremsExt.modifyState env fun _ => {}
229
+
227
230
/--
228
231
Symbols with built-in support in `grind` are unsuitable as pattern candidates for E-matching.
229
232
This is because `grind` performs normalization operations and uses specialized data structures
Original file line number Diff line number Diff line change
1
+ %reset_grind_attrs
2
+
1
3
attribute [grind =] List.length_cons
2
4
attribute [grind →] List.getElem?_eq_getElem
3
5
attribute [grind =] List.length_replicate
@@ -92,3 +94,12 @@ error: `And` is marked as a built-in case-split for `grind` and cannot be erased
92
94
#guard_msgs (error) in
93
95
example : p ∧ q → p := by
94
96
grind [-And]
97
+
98
+ example : (List.replicate n a)[m]? = if m < n then some a else none := by
99
+ grind?
100
+
101
+ %reset_grind_attrs
102
+
103
+ example : (List.replicate n a)[m]? = if m < n then some a else none := by
104
+ fail_if_success grind?
105
+ sorry
You can’t perform that action at this time.
0 commit comments