@@ -14,6 +14,15 @@ In this file we define `FreeMonoid.countP`, `FreeMonoid.count`, `FreeAddMonoid.c
14
14
additive homomorphisms from `FreeMonoid` and `FreeAddMonoid`.
15
15
16
16
We do not use `to_additive` because it can't map `Multiplicative ℕ` to `ℕ`.
17
+
18
+ ## TODO
19
+
20
+ There is lots of defeq abuse here of `FreeAddMonoid α = List α`, e.g. in statements like
21
+ ```
22
+ theorem countP_apply (l : FreeAddMonoid α) : countP p l = List.countP p l := rfl
23
+ ```
24
+ This needs cleaning up.
25
+
17
26
-/
18
27
19
28
variable {α : Type *} (p : α → Prop ) [DecidablePred p]
@@ -27,7 +36,8 @@ def countP : FreeAddMonoid α →+ ℕ where
27
36
map_add' := List.countP_append _
28
37
29
38
theorem countP_of (x : α) : countP p (of x) = if p x = true then 1 else 0 := by
30
- simp [countP, List.countP, List.countP.go]
39
+ change List.countP p [x] = _
40
+ simp [List.countP_cons]
31
41
32
42
theorem countP_apply (l : FreeAddMonoid α) : countP p l = List.countP p l := rfl
33
43
@@ -36,8 +46,8 @@ theorem countP_apply (l : FreeAddMonoid α) : countP p l = List.countP p l := rf
36
46
def count [DecidableEq α] (x : α) : FreeAddMonoid α →+ ℕ := countP (· = x)
37
47
38
48
theorem count_of [DecidableEq α] (x y : α) : count x (of y) = (Pi.single x 1 : α → ℕ) y := by
39
- simp [Pi.single, Function.update, count, countP, List.countP, List.countP.go,
40
- Bool.beq_eq_decide_eq ]
49
+ change List. count x [y] = _
50
+ simp [Pi.single, Function.update, List.count_cons ]
41
51
42
52
theorem count_apply [DecidableEq α] (x : α) (l : FreeAddMonoid α) : count x l = List.count x l :=
43
53
rfl
0 commit comments