List.count as a bundled homomorphism #
In this file we define FreeMonoid.countP, FreeMonoid.count, FreeAddMonoid.countP, and
FreeAddMonoid.count. These are List.countP and List.count bundled as multiplicative and
additive homomorphisms from FreeMonoid and FreeAddMonoid.
We do not use to_additive too much because it can't map Multiplicative ℕ to ℕ.
List.countP lifted to free monoids
Instances For
List.countP lifted to free additive monoids
Instances For
theorem
FreeMonoid.countP'_mul
{α : Type u_1}
(p : α → Prop)
[DecidablePred p]
(l₁ l₂ : FreeMonoid α)
:
theorem
FreeAddMonoid.countP'_add
{α : Type u_1}
(p : α → Prop)
[DecidablePred p]
(l₁ l₂ : FreeAddMonoid α)
:
List.countP as a bundled multiplicative monoid homomorphism.
Instances For
theorem
FreeMonoid.countP_apply
{α : Type u_1}
(p : α → Prop)
[DecidablePred p]
(l : FreeMonoid α)
:
(countP p) l = Multiplicative.ofAdd (List.countP (fun (b : α) => decide (p b)) (toList l))
theorem
FreeMonoid.countP_of
{α : Type u_1}
(p : α → Prop)
[DecidablePred p]
(x : α)
:
(countP p) (of x) = if p x then Multiplicative.ofAdd 1 else Multiplicative.ofAdd 0
List.count as a bundled additive monoid homomorphism.
Instances For
theorem
FreeMonoid.count_apply
{α : Type u_1}
[DecidableEq α]
(x : α)
(l : FreeAddMonoid α)
:
(count x) l = Multiplicative.ofAdd (List.count x (FreeAddMonoid.toList l))
theorem
FreeMonoid.count_of
{α : Type u_1}
[DecidableEq α]
(x y : α)
:
(count x) (of y) = Pi.mulSingle x (Multiplicative.ofAdd 1) y
List.countP as a bundled additive monoid homomorphism.
Instances For
theorem
FreeAddMonoid.countP_apply
{α : Type u_1}
(p : α → Prop)
[DecidablePred p]
(l : FreeAddMonoid α)
:
List.count as a bundled additive monoid homomorphism.