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
@[simp]
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.nsmul_replicate
{α : Type u_1}
{a : α}
(n m : ℕ)
:
n • Multiset.replicate m a = Multiset.replicate (n * m) 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 α)
:
(Multiset.mapAddMonoidHom f) s = Multiset.map f s
@[simp]
theorem
Multiset.map_nsmul
{α : Type u_1}
{β : Type u_2}
(f : α → β)
(n : ℕ)
(s : Multiset α)
:
Multiset.map f (n • s) = n • Multiset.map f s
Subtraction #
theorem
Multiset.filter_nsmul
{α : Type u_1}
(p : α → Prop)
[DecidablePred p]
(s : Multiset α)
(n : ℕ)
:
Multiset.filter p (n • s) = n • Multiset.filter p s
countP #
@[simp]
theorem
Multiset.countP_nsmul
{α : Type u_1}
(p : α → Prop)
[DecidablePred p]
(s : Multiset α)
(n : ℕ)
:
Multiset.countP p (n • s) = n * Multiset.countP p s
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]
@[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]
@[simp]
theorem
Multiset.count_nsmul
{α : Type u_1}
[DecidableEq α]
(a : α)
(n : ℕ)
(s : Multiset α)
:
Multiset.count a (n • s) = n * Multiset.count a s
theorem
Multiset.addHom_ext
{α : Type u_1}
{β : Type u_2}
[AddZeroClass β]
⦃f g : Multiset α →+ β⦄
(h : ∀ (x : α), f {x} = g {x})
:
f = g