Counting multiplicity in a multiset #
countP #
countP p s counts the number of elements of s (with multiplicity) that
satisfy p.
Equations
- Multiset.countP p s = Quot.liftOn s (List.countP fun (b : α) => decide (p b)) ⋯
Instances For
@[simp]
@[simp]
theorem Multiset.countP_le_of_le {α : Type u_1} (p : α → Prop) [DecidablePred p] {s t : Multiset α} (h : s ≤ t) :
theorem Multiset.countP_pos_of_mem {α : Type u_1} {p : α → Prop} [DecidablePred p] {s : Multiset α} {a : α} (h : a ∈ s) (pa : p a) :
theorem Multiset.countP_congr {α : Type u_1} {s s' : Multiset α} (hs : s = s') {p p' : α → Prop} [DecidablePred p] [DecidablePred p'] (hp : ∀ (x : α), x ∈ s → p x = p' x) :
Multiplicity of an element #
count a s is the multiplicity of a in s.
Equations
- Multiset.count a = Multiset.countP fun (x : α) => a = x
Instances For
@[simp]
@[simp]
@[simp]
theorem Multiset.count_cons_of_ne {α : Type u_1} [DecidableEq α] {a b : α} (h : a ≠ b) (s : Multiset α) :
@[simp]
theorem Multiset.count_eq_zero_of_notMem {α : Type u_1} [DecidableEq α] {a : α} {s : Multiset α} (h : ¬a ∈ s) :
@[simp]
theorem Multiset.count_injective {α : Type u_1} [DecidableEq α] :
Function.Injective fun (s : Multiset α) (a : α) => count a s
@[simp]
theorem Multiset.count_eq_one_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : Multiset α} (d : s.Nodup) (h : a ∈ s) :