File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import lean.extra.attrs.dummy
22import lean.extra.attrs.tag
33import lean.extra.attrs.parametric
4+ import lean.extra.attrs.simp
45/-
56# Attributes
67
@@ -58,6 +59,26 @@ We'll see you at [`./attrs/parametric.lean`](./attrs/dummy.lean).
5859@[myParam 20 important] def h2 (x : Nat) := 2 *x + 1
5960
6061
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+
6182/-
6283## Using `dummy_attr`
6384
Original file line number Diff line number Diff line change @@ -34,8 +34,17 @@ initialize renameExtension : SimplePersistentEnvExtension (Name × Name) RenameM
3434 name := `renameMapExtension
3535 addEntryFn := RenameMap.insertPair
3636 addImportedFn := fun es => mkStateFromImportedEntries (RenameMap.insertPair) {} es
37+ initial := sorry
3738 }
3839
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+
3948def findRename? (env : Environment) : Name → Option Name :=
4049 (renameExtension.getState env).find?
4150
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