File tree 3 files changed +33
-0
lines changed
3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1
1
import lean.extra.attrs.dummy
2
2
import lean.extra.attrs.tag
3
3
import lean.extra.attrs.parametric
4
+ import lean.extra.attrs.simp
4
5
/-
5
6
# Attributes
6
7
@@ -58,6 +59,26 @@ We'll see you at [`./attrs/parametric.lean`](./attrs/dummy.lean).
58
59
@[myParam 20 important] def h2 (x : Nat) := 2 *x + 1
59
60
60
61
62
+ /-
63
+ ## Using `simpAttr`
64
+ -/
65
+
66
+ @[my_simp] theorem f_eq : f x = x + 2 := rfl
67
+ @[my_simp] theorem g_eq : g x = x + 1 := rfl
68
+
69
+ example : f x + g x = 2 *x + 3 := by
70
+ simp_arith -- does not appy f_eq and g_eq
71
+ simp_arith [f, g]
72
+
73
+ example : f x + g x = 2 *x + 3 := by
74
+ simp_arith [my_simp]
75
+
76
+ example : f x = id (x + 2 ) := by
77
+ simp
78
+ simp [my_simp]
79
+
80
+
81
+
61
82
/-
62
83
## Using `dummy_attr`
63
84
Original file line number Diff line number Diff line change @@ -34,8 +34,17 @@ initialize renameExtension : SimplePersistentEnvExtension (Name × Name) RenameM
34
34
name := `renameMapExtension
35
35
addEntryFn := RenameMap.insertPair
36
36
addImportedFn := fun es => mkStateFromImportedEntries (RenameMap.insertPair) {} es
37
+ initial := sorry
37
38
}
38
39
40
+ /-
41
+ The key is Name × Name, and the value is RenameMap.
42
+ The entires are written into the `olean` files.
43
+ The functions `addEntryFn` tells us how to compute the values from the keys.
44
+ So the values are "just" a caching mechanism for the keys, where the keys tell us
45
+ what data is to be stored.
46
+ -/
47
+
39
48
def findRename? (env : Environment) : Name → Option Name :=
40
49
(renameExtension.getState env).find?
41
50
Original file line number Diff line number Diff line change
1
+ register_simp_attr fooSimp " my own foo simp attribute"
2
+
3
+
You can’t perform that action at this time.
0 commit comments