Multisets form an ordered monoid #
This file contains the ordered monoid instance on multisets, and lemmas related to it.
See note [foundational algebra order theory].
Additive monoid #
Cardinality #
Multiset.card
bundled as a group hom.
Equations
- Multiset.cardHom = { toFun := Multiset.card, map_zero' := ⋯, map_add' := ⋯ }
Instances For
Multiset.replicate
as an AddMonoidHom
.
Equations
- Multiset.replicateAddMonoidHom a = { toFun := fun (n : ℕ) => Multiset.replicate n a, map_zero' := ⋯, map_add' := ⋯ }
Instances For
@[simp]
theorem
Multiset.replicateAddMonoidHom_apply
{α : Type u_1}
(a : α)
(n : ℕ)
:
(replicateAddMonoidHom a) n = replicate n a
Multiset.map
as an AddMonoidHom
.
Equations
- Multiset.mapAddMonoidHom f = { toFun := Multiset.map f, map_zero' := ⋯, map_add' := ⋯ }
Instances For
@[simp]
theorem
Multiset.mapAddMonoidHom_apply
{α : Type u_1}
{β : Type u_2}
(f : α → β)
(s : Multiset α)
:
(mapAddMonoidHom f) s = map f s
@[simp]
theorem
Multiset.coe_mapAddMonoidHom
{α : Type u_1}
{β : Type u_2}
(f : α → β)
:
⇑(mapAddMonoidHom f) = map f
Subtraction #
countP #
countP p
, the number of elements of a multiset satisfying p
, promoted to an
AddMonoidHom
.
Equations
- Multiset.countPAddMonoidHom p = { toFun := Multiset.countP p, map_zero' := ⋯, map_add' := ⋯ }
Instances For
@[simp]
theorem
Multiset.coe_countPAddMonoidHom
{α : Type u_1}
(p : α → Prop)
[DecidablePred p]
:
⇑(countPAddMonoidHom p) = countP p
@[simp]
Multiplicity of an element #
count a
, the multiplicity of a
in a multiset, promoted to an AddMonoidHom
.
Equations
- Multiset.countAddMonoidHom a = Multiset.countPAddMonoidHom fun (x : α) => a = x
Instances For
@[simp]
theorem
Multiset.coe_countAddMonoidHom
{α : Type u_1}
[DecidableEq α]
(a : α)
:
⇑(countAddMonoidHom a) = count a
theorem
Multiset.addHom_ext
{α : Type u_1}
{β : Type u_2}
[AddZeroClass β]
⦃f g : Multiset α →+ β⦄
(h : ∀ (x : α), f {x} = g {x})
:
f = g