@@ -29,7 +29,7 @@ theorem countP_eq_length_filter' : countP p = length ∘ filter p := by
2929 grind
3030
3131theorem countP_le_length : countP p l ≤ l.length := by
32- grind
32+ induction l with grind
3333
3434theorem countP_append {l₁ l₂ : List α} : countP p (l₁ ++ l₂) = countP p l₁ + countP p l₂ := by
3535 grind
@@ -44,11 +44,11 @@ theorem countP_eq_zero {p} : countP p l = 0 ↔ ∀ a ∈ l, ¬p a := by
4444 induction l with grind
4545
4646theorem countP_eq_length {p} : countP p l = l.length ↔ ∀ a ∈ l, p a := by
47- induction l with grind
47+ induction l with grind [countP_eq_length_filter]
4848
4949theorem countP_replicate {p : α → Bool} {a : α} {n : Nat} :
5050 countP p (replicate n a) = if p a then n else 0 := by
51- grind
51+ induction n with grind
5252
5353theorem boole_getElem_le_countP {p : α → Bool} {l : List α} {i : Nat} (h : i < l.length) :
5454 (if p l[i] then 1 else 0 ) ≤ l.countP p := by
@@ -66,11 +66,9 @@ theorem countP_tail_le (l) : countP p l.tail ≤ countP p l := by grind
6666
6767-- See `Init.Data.List.Nat.Count` for `le_countP_tail : countP p l - 1 ≤ countP p l.tail`.
6868
69- -- TODO Should we have `@[grind]` for `filter_filter`?
70-
7169theorem countP_filter {l : List α} :
7270 countP p (filter q l) = countP (fun a => p a && q a) l := by
73- grind [List.filter_filter]
71+ induction l with grind
7472
7573theorem countP_true : (countP fun (_ : α) => true) = length := by
7674 funext l
@@ -81,23 +79,23 @@ theorem countP_false : (countP fun (_ : α) => false) = Function.const _ 0 := by
8179 induction l with grind
8280
8381theorem countP_map {p : β → Bool} {f : α → β} {l} : countP p (map f l) = countP (p ∘ f) l := by
84- grind
82+ induction l with grind
8583
8684theorem length_filterMap_eq_countP {f : α → Option β} {l : List α} :
8785 (filterMap f l).length = countP (fun a => (f a).isSome) l := by
88- induction l with grind -- TODO
86+ induction l with grind
8987
9088theorem countP_filterMap {p : β → Bool} {f : α → Option β} {l : List α} :
9189 countP p (filterMap f l) = countP (fun a => ((f a).map p).getD false) l := by
92- induction l with grind -- TODO
90+ induction l with grind
9391
9492theorem countP_flatten {l : List (List α)} :
9593 countP p l.flatten = (l.map (countP p)).sum := by
96- grind
94+ induction l with grind
9795
9896theorem countP_flatMap {p : β → Bool} {l : List α} {f : α → List β} :
9997 countP p (l.flatMap f) = sum (map (countP p ∘ f) l) := by
100- grind
98+ induction l with grind
10199
102100theorem countP_reverse {l : List α} : countP p l.reverse = countP p l := by
103101 grind
0 commit comments