The areas / V03. Sets, finite structures and big operators
Mathlib.Data.Multiset.Fintype
58 declarations and 1 deprecated aliases. Mathlib docs · Source
theorem Multiset.ToType.congr_simp E1 #
∀ {α : Type u_1} {inst : DecidableEq α} [inst_1 : DecidableEq α] (m m_1 : Multiset α), m = m_1 → m.ToType = m_1.ToType
theorem Multiset.cast.congr_simp E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α} (h : s = t), Multiset.cast h = Multiset.cast h
def Multiset.ToType E1 #
{α : Type u_1} → [DecidableEq α] → Multiset α → Type u_1
Auxiliary definition for the CoeSort instance. This prevents the CoeOut m α
instance from inadvertently applying to other sigma types.
instance Multiset.instCoeSortType E0 #
{α : Type u_1} → [DecidableEq α] → CoeSort (Multiset α) (Type u_1)
Create a type that has the same number of elements as the multiset.
Terms of this type are triples ⟨x, ⟨i, h⟩⟩ where x : α, i : ℕ, and h : i < m.count x.
This way repeated elements of a multiset appear multiple times from different values of i.
def Multiset.mkToType E1 #
{α : Type u_1} → [inst : DecidableEq α] → (m : Multiset α) → (x : α) → Fin (Multiset.count x m) → m.ToType
Constructor for terms of the coercion of m to a type.
This helps Lean pick up the correct instances.
instance Multiset.instCoeSortMultisetType.instCoeOutToType E0 #
{α : Type u_1} → [inst : DecidableEq α] → {m : Multiset α} → CoeOut m.ToType α
As a convenience, there is a coercion from m : Type* to α by projecting onto the first
component.
theorem Multiset.coe_mk E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α} {x : α} {i : Fin (Multiset.count x m)},
(m.mkToType x i).fst = x
theorem Multiset.coe_mem E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α} {x : m.ToType}, x.fst ∈ m
theorem Multiset.forall_coe E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α} (p : m.ToType → Prop),
(∀ (x : m.ToType), p x) ↔ ∀ (x : α) (i : Fin (Multiset.count x m)), p ⟨x, i⟩
theorem Multiset.exists_coe E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α} (p : m.ToType → Prop), (∃ x, p x) ↔ ∃ x i, p ⟨x, i⟩
instance Multiset.instFintypeElemProdNatOfPredLtSndCountFst E0 #
{α : Type u_1} → [inst : DecidableEq α] → {m : Multiset α} → Fintype ↑{p | p.2 < Multiset.count p.1 m}
def Multiset.toEnumFinset E1 #
{α : Type u_1} → [DecidableEq α] → Multiset α → Finset (α × ℕ)
Construct a finset whose elements enumerate the elements of the multiset m.
The ℕ component is used to differentiate between equal elements: if x appears n times
then (x, 0), ..., and (x, n-1) appear in the Finset.
theorem Multiset.mem_toEnumFinset E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α) (p : α × ℕ), p ∈ m.toEnumFinset ↔ p.2 < Multiset.count p.1 m
theorem Multiset.mem_of_mem_toEnumFinset E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α} {p : α × ℕ}, p ∈ m.toEnumFinset → p.1 ∈ m
theorem Multiset.toEnumFinset_filter_eq E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α) (a : α),
{x ∈ m.toEnumFinset | x.1 = a} = {a} ×ˢ Finset.range (Multiset.count a m)
theorem Multiset.map_toEnumFinset_fst E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α), Multiset.map Prod.fst m.toEnumFinset.val = m
theorem Multiset.sum_map_eq_sum_toEnumFinset E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {M : Type u_3} [inst_1 : AddCommMonoid M] (m : Multiset α) (f : α → M),
(Multiset.map f m).sum = ∑ i ∈ m.toEnumFinset, f i.1
theorem Multiset.prod_map_eq_prod_toEnumFinset E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {M : Type u_3} [inst_1 : CommMonoid M] (m : Multiset α) (f : α → M),
(Multiset.map f m).prod = ∏ i ∈ m.toEnumFinset, f i.1
theorem Multiset.image_toEnumFinset_fst E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α), Finset.image Prod.fst m.toEnumFinset = m.toFinset
theorem Multiset.map_fst_le_of_subset_toEnumFinset E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α} {s : Finset (α × ℕ)},
s ⊆ m.toEnumFinset → Multiset.map Prod.fst s.val ≤ m
theorem Multiset.toEnumFinset_mono E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {m₁ m₂ : Multiset α}, m₁ ≤ m₂ → m₁.toEnumFinset ⊆ m₂.toEnumFinset
theorem Multiset.toEnumFinset_subset_iff E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m₁ m₂ : Multiset α}, m₁.toEnumFinset ⊆ m₂.toEnumFinset ↔ m₁ ≤ m₂
def Multiset.coeEmbedding E1 #
{α : Type u_1} → [inst : DecidableEq α] → (m : Multiset α) → m.ToType ↪ α × ℕ
The embedding from a multiset into α × ℕ where the second coordinate enumerates repeats.
If you are looking for the function m → α, that would be plain (↑).
theorem Multiset.coeEmbedding_apply E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α) (x : m.ToType), m.coeEmbedding x = (x.fst, ↑x.snd)
def Multiset.coeEquiv E1 #
{α : Type u_1} → [inst : DecidableEq α] → (m : Multiset α) → m.ToType ≃ ↥m.toEnumFinset
Another way to coerce a Multiset to a type is to go through m.toEnumFinset and coerce
that Finset to a type.
theorem Multiset.coeEquiv_apply_coe E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α) (x : m.ToType), ↑(m.coeEquiv x) = m.coeEmbedding x
theorem Multiset.coeEquiv_symm_apply_fst E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α) (x : ↥m.toEnumFinset), (m.coeEquiv.symm x).fst = (↑x).1
theorem Multiset.coeEquiv_symm_apply_snd_val E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α) (x : ↥m.toEnumFinset), ↑(m.coeEquiv.symm x).snd = (↑x).2
theorem Multiset.toEmbedding_coeEquiv_trans E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α),
m.coeEquiv.toEmbedding.trans (Function.Embedding.subtype fun x ↦ x ∈ m.toEnumFinset) = m.coeEmbedding
instance Multiset.fintypeCoe E0 #
{α : Type u_1} → [inst : DecidableEq α] → {m : Multiset α} → Fintype m.ToType
theorem Multiset.map_univ_coeEmbedding E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α), Finset.map m.coeEmbedding Finset.univ = m.toEnumFinset
theorem Multiset.map_univ_coe E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α), Multiset.map (fun x ↦ x.fst) Finset.univ.val = m
theorem Multiset.map_univ_comp_coe E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {β : Type u_3} (m : Multiset α) (f : α → β),
Multiset.map (f ∘ fun x ↦ x.fst) Finset.univ.val = Multiset.map f m
theorem Multiset.map_univ E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {β : Type u_3} (m : Multiset α) (f : α → β),
Multiset.map (fun x ↦ f x.fst) Finset.univ.val = Multiset.map f m
theorem Multiset.card_toEnumFinset E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α), m.toEnumFinset.card = m.card
theorem Multiset.card_coe E0 #
∀ {α : Type u_1} [inst : DecidableEq α] (m : Multiset α), Fintype.card m.ToType = m.card
theorem Multiset.prod_eq_prod_coe E0 #
∀ {α : Type u_1} [inst : DecidableEq α] [inst_1 : CommMonoid α] (m : Multiset α), m.prod = ∏ x, x.fst
theorem Multiset.sum_eq_sum_coe E0 #
∀ {α : Type u_1} [inst : DecidableEq α] [inst_1 : AddCommMonoid α] (m : Multiset α), m.sum = ∑ x, x.fst
theorem Multiset.sum_eq_sum_toEnumFinset E1 #
∀ {α : Type u_1} [inst : DecidableEq α] [inst_1 : AddCommMonoid α] (m : Multiset α), m.sum = ∑ x ∈ m.toEnumFinset, x.1
theorem Multiset.prod_eq_prod_toEnumFinset E1 #
∀ {α : Type u_1} [inst : DecidableEq α] [inst_1 : CommMonoid α] (m : Multiset α), m.prod = ∏ x ∈ m.toEnumFinset, x.1
theorem Multiset.sum_toEnumFinset E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {β : Type u_3} [inst_1 : AddCommMonoid β] (m : Multiset α) (f : α → ℕ → β),
∑ x ∈ m.toEnumFinset, f x.1 x.2 = ∑ x, f x.fst ↑x.snd
theorem Multiset.prod_toEnumFinset E1 #
∀ {α : Type u_1} [inst : DecidableEq α] {β : Type u_3} [inst_1 : CommMonoid β] (m : Multiset α) (f : α → ℕ → β),
∏ x ∈ m.toEnumFinset, f x.1 x.2 = ∏ x, f x.fst ↑x.snd
def Multiset.cast E1 #
{α : Type u_1} → [inst : DecidableEq α] → {s t : Multiset α} → s = t → s.ToType ≃ t.ToType
If s = t then there's an equivalence between the appropriate types.
theorem Multiset.cast_symm_apply_fst E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α} (h : s = t) (x : t.ToType),
((Multiset.cast h).symm x).fst = x.fst
theorem Multiset.cast_apply_fst E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α} (h : s = t) (x : s.ToType), ((Multiset.cast h) x).fst = x.fst
theorem Multiset.cast_symm_apply_snd E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α} (h : s = t) (x : t.ToType),
((Multiset.cast h).symm x).snd = Fin.cast ⋯ x.snd
theorem Multiset.cast_apply_snd E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α} (h : s = t) (x : s.ToType),
((Multiset.cast h) x).snd = Fin.cast ⋯ x.snd
instance Multiset.instIsEmptyToTypeOfNat E0 #
∀ {α : Type u_1} [inst : DecidableEq α], IsEmpty (Multiset.ToType 0)
instance Multiset.instIsEmptyToTypeEmptyCollection E0 #
∀ {α : Type u_1} [inst : DecidableEq α], IsEmpty ∅.ToType
def Multiset.consEquiv E1 #
{α : Type u_1} → [inst : DecidableEq α] → {m : Multiset α} → {v : α} → (v ::ₘ m).ToType ≃ Option m.ToType
v ::ₘ m is equivalent to Option m by mapping one v to none and everything else to m.
theorem Multiset.consEquiv_symm_none E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α} {v : α},
Multiset.consEquiv.symm none = ⟨v, ⟨Multiset.count v m, ⋯⟩⟩
theorem Multiset.consEquiv_symm_some E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α} {v : α} {x : m.ToType},
Multiset.consEquiv.symm (some x) = ⟨x.fst, Fin.castLE ⋯ x.snd⟩
theorem Multiset.coe_consEquiv_of_ne E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α} {v : α} (x : (v ::ₘ m).ToType) (hx : x.fst ≠ v),
Multiset.consEquiv x = some ⟨x.fst, Fin.cast ⋯ x.snd⟩
theorem Multiset.coe_consEquiv_of_eq_of_eq E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α} {v : α} (x : (v ::ₘ m).ToType),
x.fst = v → ↑x.snd = Multiset.count v m → Multiset.consEquiv x = none
theorem Multiset.coe_consEquiv_of_eq_of_lt E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {m : Multiset α} {v : α} (x : (v ::ₘ m).ToType) (hx : x.fst = v)
(hx2 : ↑x.snd < Multiset.count v m), Multiset.consEquiv x = some ⟨x.fst, ⟨↑x.snd, ⋯⟩⟩
def Multiset.mapEquivAux E0 #
{α : Type u_1} →
{β : Type u_2} →
[inst : DecidableEq α] →
[inst_1 : DecidableEq β] → (m : Multiset α) → (f : α → β) → Squash { v // ∀ (a : m.ToType), (v a).fst = f a.fst }
There is some equivalence between m and m.map f which respects f.
def Multiset.mapEquiv E1 #
{α : Type u_1} →
{β : Type u_2} →
[inst : DecidableEq α] →
[inst_1 : DecidableEq β] → (s : Multiset α) → (f : α → β) → s.ToType ≃ (Multiset.map f s).ToType
One of the possible equivalences from Multiset.mapEquivAux, selected using choice.
theorem Multiset.mapEquiv_apply E0 #
∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq α] [inst_1 : DecidableEq β] (s : Multiset α) (f : α → β)
(v : s.ToType), ((s.mapEquiv f) v).fst = f v.fst
Deprecated aliases
| Name | New name | Since |
|---|---|---|
Multiset.mapEquiv_aux | Multiset.mapEquivAux | 2026-06-06 |