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 #
@[implicit_reducible]
theorem
Multiset.mem_of_mem_nsmul
{α : Type u_1}
{a : α}
{s : Multiset α}
{n : ℕ}
(h : a ∈ n • s)
:
a ∈ s
@[simp]
theorem
Multiset.mem_nsmul
{α : Type u_1}
{a : α}
{s : Multiset α}
{n : ℕ}
:
a ∈ n • s ↔ n ≠ 0 ∧ a ∈ s
theorem
Multiset.mem_nsmul_of_ne_zero
{α : Type u_1}
{a : α}
{s : Multiset α}
{n : ℕ}
(h0 : n ≠ 0)
:
a ∈ n • s ↔ a ∈ s
theorem
Multiset.nsmul_cons
{α : Type u_1}
{s : Multiset α}
(n : ℕ)
(a : α)
:
n • (a ::ₘ s) = n • {a} + n • s
Cardinality #
Multiset.card bundled as a group hom.
Instances For
@[simp]
@[simp]
Multiset.replicate as an AddMonoidHom.
Instances For
@[simp]
theorem
Multiset.replicateAddMonoidHom_apply
{α : Type u_1}
(a : α)
(n : ℕ)
:
(replicateAddMonoidHom a) n = replicate n a
Multiset.map as an AddMonoidHom.
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 #
@[simp]
countP p, the number of elements of a multiset satisfying p, promoted to an
AddMonoidHom.
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.
Instances For
@[simp]
theorem
Multiset.coe_countAddMonoidHom
{α : Type u_1}
[DecidableEq α]
(a : α)
:
⇑(countAddMonoidHom a) = count a
@[simp]
theorem
Multiset.addHom_ext
{α : Type u_1}
{β : Type u_2}
[AddZeroClass β]
⦃f g : Multiset α →+ β⦄
(h : ∀ (x : α), f {x} = g {x})
:
f = g
theorem
Multiset.addHom_ext_iff
{α : Type u_1}
{β : Type u_2}
[AddZeroClass β]
{f g : Multiset α →+ β}
:
f = g ↔ ∀ (x : α), f {x} = g {x}