File: Mathlib/Data/Multiset/Fintype.lean

full_name: Multiset.ToType
code: /-- Auxiliary definition for the `CoeSort` instance. This prevents the `CoeOut m α`
instance from inadvertently applying to other sigma types. -/
def Multiset.ToType (m : Multiset α) : Type _ 
goal: Type u_1

full_name: instCoeSortMultisetType
code: /-- 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`. -/
instance : CoeSort (Multiset α) (Type _) 
goal: CoeSort (Multiset α) (Type u_1)

full_name: Multiset.mkToType
code: /-- Constructor for terms of the coercion of `m` to a type.
This helps Lean pick up the correct instances. -/
@[reducible, match_pattern]
def Multiset.mkToType (m : Multiset α) (x : α) (i : Fin (m.count x)) : m 
goal: m.ToType

full_name: instCoeSortMultisetType.instCoeOutToType
code: /-- As a convenience, there is a coercion from `m : Type*` to `α` by projecting onto the first
component. -/
instance instCoeSortMultisetType.instCoeOutToType : CoeOut m α 
goal: CoeOut m.ToType α

full_name: Multiset.coe_mk
code: theorem Multiset.coe_mk {x : α} {i : Fin (m.count x)} : ↑(m.mkToType x i) = x 
goal: (m.mkToType x i).fst = x

full_name: Multiset.coe_mem
code: @[simp] lemma Multiset.coe_mem {x : m} : ↑x ∈ m 
goal: x.fst ∈ m

full_name: Multiset.forall_coe
code: @[simp]
protected theorem Multiset.forall_coe (p : m → Prop) :
    (∀ x : m, p x) ↔ ∀ (x : α) (i : Fin (m.count x)), p ⟨x, i⟩ 
goal: (∀ (x : m.ToType), p x) ↔ ∀ (x : α) (i : Fin (Multiset.count x m)), p ⟨x, i⟩

full_name: Multiset.exists_coe
code: @[simp]
protected theorem Multiset.exists_coe (p : m → Prop) :
    (∃ x : m, p x) ↔ ∃ (x : α) (i : Fin (m.count x)), p ⟨x, i⟩ 
goal: (∃ x, p x) ↔ ∃ x i, p ⟨x, i⟩

full_name: instFintypeElemProdNatSetOfLtSndCountFst
code: instance : Fintype { p : α × ℕ | p.2 < m.count p.1 } 
goal: Fintype ↑{p | p.2 < Multiset.count p.1 m}

full_name: Multiset.toEnumFinset
code: /-- 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`. -/
def Multiset.toEnumFinset (m : Multiset α) : Finset (α × ℕ) 
goal: Finset (α × ℕ)

full_name: Multiset.mem_toEnumFinset
code: @[simp]
theorem Multiset.mem_toEnumFinset (m : Multiset α) (p : α × ℕ) :
    p ∈ m.toEnumFinset ↔ p.2 < m.count p.1 
goal: p ∈ m.toEnumFinset ↔ p.2 < Multiset.count p.1 m

full_name: Multiset.mem_of_mem_toEnumFinset
code: theorem Multiset.mem_of_mem_toEnumFinset {p : α × ℕ} (h : p ∈ m.toEnumFinset) : p.1 ∈ m 
goal: p.1 ∈ m

full_name: Multiset.toEnumFinset_filter_eq
code: @[simp] lemma toEnumFinset_filter_eq (m : Multiset α) (a : α) :
    m.toEnumFinset.filter (·.1 = a) = {a} ×ˢ Finset.range (m.count a) 
goal: Finset.filter (fun x => x.1 = a) m.toEnumFinset = {a} ×ˢ Finset.range (Multiset.count a m)

full_name: Multiset.map_toEnumFinset_fst
code: @[simp] lemma map_toEnumFinset_fst (m : Multiset α) : m.toEnumFinset.val.map Prod.fst = m 
goal: Multiset.map Prod.fst m.toEnumFinset.val = m

full_name: Multiset.image_toEnumFinset_fst
code: @[simp] lemma image_toEnumFinset_fst (m : Multiset α) :
    m.toEnumFinset.image Prod.fst = m.toFinset 
goal: Finset.image Prod.fst m.toEnumFinset = m.toFinset

full_name: Multiset.map_fst_le_of_subset_toEnumFinset
code: @[simp] lemma map_fst_le_of_subset_toEnumFinset {s : Finset (α × ℕ)} (hsm : s ⊆ m.toEnumFinset) :
    s.1.map Prod.fst ≤ m 
goal: Multiset.map Prod.fst s.val ≤ m

full_name: Multiset.toEnumFinset_mono
code: @[mono]
theorem Multiset.toEnumFinset_mono {m₁ m₂ : Multiset α} (h : m₁ ≤ m₂) :
    m₁.toEnumFinset ⊆ m₂.toEnumFinset 
goal: m₁.toEnumFinset ⊆ m₂.toEnumFinset

full_name: Multiset.toEnumFinset_subset_iff
code: @[simp]
theorem Multiset.toEnumFinset_subset_iff {m₁ m₂ : Multiset α} :
    m₁.toEnumFinset ⊆ m₂.toEnumFinset ↔ m₁ ≤ m₂ 
goal: m₁.toEnumFinset ⊆ m₂.toEnumFinset ↔ m₁ ≤ m₂

full_name: Multiset.coeEmbedding
code: /-- The embedding from a multiset into `α × ℕ` where the second coordinate enumerates repeats.
If you are looking for the function `m → α`, that would be plain `(↑)`. -/
@[simps]
def Multiset.coeEmbedding (m : Multiset α) : m ↪ α × ℕ 
goal: m.ToType ↪ α × ℕ

full_name: Multiset.coeEmbedding_apply
code: /-- The embedding from a multiset into `α × ℕ` where the second coordinate enumerates repeats.
If you are looking for the function `m → α`, that would be plain `(↑)`. -/
@[simps]
def Multiset.coeEmbedding (m : Multiset α) : m ↪ α × ℕ 
goal: m.coeEmbedding x = (x.fst, ↑x.snd)

full_name: Multiset.coeEquiv_symm_apply_snd_val
code: /-- Another way to coerce a `Multiset` to a type is to go through `m.toEnumFinset` and coerce
that `Finset` to a type. -/
@[simps]
def Multiset.coeEquiv (m : Multiset α) : m ≃ m.toEnumFinset 
goal: ↑(m.coeEquiv.symm x).snd = (↑x).2

full_name: Multiset.coeEquiv_apply_coe
code: /-- Another way to coerce a `Multiset` to a type is to go through `m.toEnumFinset` and coerce
that `Finset` to a type. -/
@[simps]
def Multiset.coeEquiv (m : Multiset α) : m ≃ m.toEnumFinset 
goal: ↑(m.coeEquiv x) = m.coeEmbedding x

full_name: Multiset.coeEquiv
code: /-- Another way to coerce a `Multiset` to a type is to go through `m.toEnumFinset` and coerce
that `Finset` to a type. -/
@[simps]
def Multiset.coeEquiv (m : Multiset α) : m ≃ m.toEnumFinset 
goal: m.ToType ≃ { x // x ∈ m.toEnumFinset }

full_name: Multiset.coeEquiv_symm_apply_fst
code: /-- Another way to coerce a `Multiset` to a type is to go through `m.toEnumFinset` and coerce
that `Finset` to a type. -/
@[simps]
def Multiset.coeEquiv (m : Multiset α) : m ≃ m.toEnumFinset 
goal: (m.coeEquiv.symm x).fst = (↑x).1

full_name: Multiset.toEmbedding_coeEquiv_trans
code: @[simp]
theorem Multiset.toEmbedding_coeEquiv_trans (m : Multiset α) :
    m.coeEquiv.toEmbedding.trans (Function.Embedding.subtype _) = m.coeEmbedding 
goal: m.coeEquiv.toEmbedding.trans (Function.Embedding.subtype fun x => x ∈ m.toEnumFinset) = m.coeEmbedding

full_name: Multiset.fintypeCoe
code: @[irreducible]
instance Multiset.fintypeCoe : Fintype m 
goal: Fintype m.ToType

full_name: Multiset.map_univ_coeEmbedding
code: theorem Multiset.map_univ_coeEmbedding (m : Multiset α) :
    (Finset.univ : Finset m).map m.coeEmbedding = m.toEnumFinset 
goal: Finset.map m.coeEmbedding Finset.univ = m.toEnumFinset

full_name: Multiset.map_univ_coe
code: @[simp]
theorem Multiset.map_univ_coe (m : Multiset α) :
    (Finset.univ : Finset m).val.map (fun x : m ↦ (x : α)) = m 
goal: Multiset.map (fun x => x.fst) Finset.univ.val = m

full_name: Multiset.map_univ
code: @[simp]
theorem Multiset.map_univ {β : Type*} (m : Multiset α) (f : α → β) :
    ((Finset.univ : Finset m).val.map fun (x : m) ↦ f (x : α)) = m.map f 
goal: Multiset.map (fun x => f x.fst) Finset.univ.val = Multiset.map f m

full_name: Multiset.card_toEnumFinset
code: @[simp]
theorem Multiset.card_toEnumFinset (m : Multiset α) : m.toEnumFinset.card = Multiset.card m 
goal: m.toEnumFinset.card = Multiset.card m

full_name: Multiset.card_coe
code: @[simp]
theorem Multiset.card_coe (m : Multiset α) : Fintype.card m = Multiset.card m 
goal: Fintype.card m.ToType = Multiset.card m

full_name: Multiset.prod_eq_prod_coe
code: @[to_additive]
theorem Multiset.prod_eq_prod_coe [CommMonoid α] (m : Multiset α) : m.prod = ∏ x : m, (x : α) 
goal: m.prod = ∏ x : m.ToType, x.fst

full_name: Multiset.sum_eq_sum_coe
code: @[to_additive]
theorem Multiset.prod_eq_prod_coe [CommMonoid α] (m : Multiset α) : m.prod = ∏ x : m, (x : α) 
goal: m.sum = ∑ x : m.ToType, x.fst

full_name: Multiset.sum_eq_sum_toEnumFinset
code: @[to_additive]
theorem Multiset.prod_eq_prod_toEnumFinset [CommMonoid α] (m : Multiset α) :
    m.prod = ∏ x ∈ m.toEnumFinset, x.1 
goal: m.sum = ∑ x ∈ m.toEnumFinset, x.1

full_name: Multiset.prod_eq_prod_toEnumFinset
code: @[to_additive]
theorem Multiset.prod_eq_prod_toEnumFinset [CommMonoid α] (m : Multiset α) :
    m.prod = ∏ x ∈ m.toEnumFinset, x.1 
goal: m.prod = ∏ x ∈ m.toEnumFinset, x.1

full_name: Multiset.prod_toEnumFinset
code: @[to_additive]
theorem Multiset.prod_toEnumFinset {β : Type*} [CommMonoid β] (m : Multiset α) (f : α → ℕ → β) :
    ∏ x ∈ m.toEnumFinset, f x.1 x.2 = ∏ x : m, f x x.2 
goal: ∏ x ∈ m.toEnumFinset, f x.1 x.2 = ∏ x : m.ToType, f x.fst ↑x.snd

full_name: Multiset.sum_toEnumFinset
code: @[to_additive]
theorem Multiset.prod_toEnumFinset {β : Type*} [CommMonoid β] (m : Multiset α) (f : α → ℕ → β) :
    ∏ x ∈ m.toEnumFinset, f x.1 x.2 = ∏ x : m, f x x.2 
goal: ∑ x ∈ m.toEnumFinset, f x.1 x.2 = ∑ x : m.ToType, f x.fst ↑x.snd