Counting multiplicity in a multiset #
countP #
countP p s counts the number of elements of s (with multiplicity) that
satisfy p.
Instances For
@[simp]
theorem
Multiset.coe_countP
{α : Type u_1}
(p : α → Prop)
[DecidablePred p]
(l : List α)
:
countP p ↑l = List.countP (fun (b : α) => decide (p b)) l
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
theorem
Multiset.countP_eq_zero
{α : Type u_1}
{p : α → Prop}
[DecidablePred p]
{s : Multiset α}
:
countP p s = 0 ↔ ∀ a ∈ s, ¬p a
Multiplicity of an element #
count a s is the multiplicity of a in s.
Instances For
@[simp]
theorem
Multiset.coe_count
{α : Type u_1}
[DecidableEq α]
(a : α)
(l : List α)
:
count a ↑l = List.count a l
@[simp]
@[simp]
@[simp]
theorem
Multiset.count_singleton
{α : Type u_1}
[DecidableEq α]
(a b : α)
:
count a {b} = if a = b then 1 else 0
@[simp]
@[simp]
theorem
Multiset.count_eq_zero_of_notMem
{α : Type u_1}
[DecidableEq α]
{a : α}
{s : Multiset α}
(h : a ∉ s)
:
count a s = 0
theorem
Multiset.count_ne_zero
{α : Type u_1}
[DecidableEq α]
{s : Multiset α}
{a : α}
:
count a s ≠ 0 ↔ a ∈ s
@[simp]
theorem
Multiset.count_eq_zero
{α : Type u_1}
[DecidableEq α]
{s : Multiset α}
{a : α}
:
count a s = 0 ↔ a ∉ s
@[simp]
theorem
Multiset.count_eq_one_of_mem
{α : Type u_1}
[DecidableEq α]
{a : α}
{s : Multiset α}
(d : s.Nodup)
(h : a ∈ s)
:
count a s = 1
theorem
Multiset.count_eq_of_nodup
{α : Type u_1}
[DecidableEq α]
{a : α}
{s : Multiset α}
(d : s.Nodup)
:
count a s = if a ∈ s then 1 else 0