list.count
as a bundled homomorphism #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
In this file we define free_monoid.countp
, free_monoid.count
, free_add_monoid.countp
, and
free_add_monoid.count
. These are list.countp
and list.count
bundled as multiplicative and
additive homomorphisms from free_monoid
and free_add_monoid
.
We do not use to_additive
because it can't map multiplicative ℕ
to ℕ
.
list.countp
as a bundled additive monoid homomorphism.
Equations
- free_add_monoid.countp p = {to_fun := list.countp p (λ (a : α), _inst_2 a), map_zero' := _, map_add' := _}
theorem
free_add_monoid.countp_of
{α : Type u_1}
(p : α → Prop)
[decidable_pred p]
(x : α) :
⇑(free_add_monoid.countp p) (free_add_monoid.of x) = ite (p x) 1 0
theorem
free_add_monoid.countp_apply
{α : Type u_1}
(p : α → Prop)
[decidable_pred p]
(l : free_add_monoid α) :
⇑(free_add_monoid.countp p) l = list.countp p l
list.count
as a bundled additive monoid homomorphism.
Equations
theorem
free_add_monoid.count_of
{α : Type u_1}
[decidable_eq α]
(x y : α) :
⇑(free_add_monoid.count x) (free_add_monoid.of y) = pi.single x 1 y
theorem
free_add_monoid.count_apply
{α : Type u_1}
[decidable_eq α]
(x : α)
(l : free_add_monoid α) :
⇑(free_add_monoid.count x) l = list.count x l
list.countp
as a bundled multiplicative monoid homomorphism.
Equations
theorem
free_monoid.countp_of'
{α : Type u_1}
(p : α → Prop)
[decidable_pred p]
(x : α) :
⇑(free_monoid.countp p) (free_monoid.of x) = ite (p x) (⇑multiplicative.of_add 1) (⇑multiplicative.of_add 0)
theorem
free_monoid.countp_of
{α : Type u_1}
(p : α → Prop)
[decidable_pred p]
(x : α) :
⇑(free_monoid.countp p) (free_monoid.of x) = ite (p x) (⇑multiplicative.of_add 1) 1
theorem
free_monoid.countp_apply
{α : Type u_1}
(p : α → Prop)
[decidable_pred p]
(l : free_add_monoid α) :
⇑(free_monoid.countp p) l = ⇑multiplicative.of_add (list.countp p l)
list.count
as a bundled additive monoid homomorphism.
Equations
theorem
free_monoid.count_apply
{α : Type u_1}
[decidable_eq α]
(x : α)
(l : free_add_monoid α) :
⇑(free_monoid.count x) l = ⇑multiplicative.of_add (list.count x l)
theorem
free_monoid.count_of
{α : Type u_1}
[decidable_eq α]
(x y : α) :
⇑(free_monoid.count x) (free_monoid.of y) = pi.mul_single x (⇑multiplicative.of_add 1) y