The areas / V03. Sets, finite structures and big operators
Mathlib.Data.Multiset.Basic
24 declarations. Mathlib docs · Source
Basic results on multisets
Multiset.toList
Induction principles
def Multiset.toList E1 #
{α : Type u_1} → Multiset α → List α
Produces a list of the elements in the multiset using choice.
theorem Multiset.coe_toList E0 #
∀ {α : Type u_1} (s : Multiset α), ↑s.toList = s
theorem Multiset.toList_eq_nil E0 #
∀ {α : Type u_1} {s : Multiset α}, s.toList = [] ↔ s = 0
theorem Multiset.empty_toList E1 #
∀ {α : Type u_1} {s : Multiset α}, s.toList.isEmpty = true ↔ s = 0
theorem Multiset.toList_zero E0 #
∀ {α : Type u_1}, Multiset.toList 0 = []
theorem Multiset.mem_toList E0 #
∀ {α : Type u_1} {a : α} {s : Multiset α}, a ∈ s.toList ↔ a ∈ s
theorem Multiset.toList_eq_singleton_iff E0 #
∀ {α : Type u_1} {a : α} {m : Multiset α}, m.toList = [a] ↔ m = {a}
theorem Multiset.toList_singleton E0 #
∀ {α : Type u_1} (a : α), {a}.toList = [a]
theorem Multiset.length_toList E0 #
∀ {α : Type u_1} (s : Multiset α), s.toList.length = s.card
def Multiset.strongInductionOn E1 #
{α : Type u_1} →
{p : Multiset α → Sort u_2} → (s : Multiset α) → ((s : Multiset α) → ((t : Multiset α) → t < s → p t) → p s) → p s
The strong induction principle for multisets.
theorem Multiset.strongInductionOn_eq E0 #
∀ {α : Type u_1} {p : Multiset α → Sort u_2} (s : Multiset α)
(H : (s : Multiset α) → ((t : Multiset α) → t < s → p t) → p s),
s.strongInductionOn H = H s fun t _h ↦ t.strongInductionOn H
theorem Multiset.case_strongInductionOn E1 #
∀ {α : Type u_1} {p : Multiset α → Prop} (s : Multiset α),
p 0 → (∀ (a : α) (s : Multiset α), (∀ t ≤ s, p t) → p (a ::ₘ s)) → p s
def Multiset.strongDownwardInduction E1 #
{α : Type u_1} →
{p : Multiset α → Sort u_2} →
{n : ℕ} →
((t₁ : Multiset α) → ({t₂ : Multiset α} → t₂.card ≤ n → t₁ < t₂ → p t₂) → t₁.card ≤ n → p t₁) →
(s : Multiset α) → s.card ≤ n → p s
Suppose that, given that p t can be defined on all supersets of s of cardinality less than
n, one knows how to define p s. Then one can inductively define p s for all multisets s of
cardinality less than n, starting from multisets of card n and iterating. This
can be used either to define data, or to prove properties.
theorem Multiset.strongDownwardInduction_eq E0 #
∀ {α : Type u_1} {p : Multiset α → Sort u_2} {n : ℕ}
(H : (t₁ : Multiset α) → ({t₂ : Multiset α} → t₂.card ≤ n → t₁ < t₂ → p t₂) → t₁.card ≤ n → p t₁) (s : Multiset α),
Multiset.strongDownwardInduction H s = H s fun {t₂} ht _hst ↦ Multiset.strongDownwardInduction H t₂ ht
def Multiset.strongDownwardInductionOn E1 #
{α : Type u_1} →
{p : Multiset α → Sort u_2} →
{n : ℕ} →
(s : Multiset α) →
((t₁ : Multiset α) → ({t₂ : Multiset α} → t₂.card ≤ n → t₁ < t₂ → p t₂) → t₁.card ≤ n → p t₁) → s.card ≤ n → p s
Analogue of strongDownwardInduction with order of arguments swapped.
theorem Multiset.strongDownwardInductionOn_eq E0 #
∀ {α : Type u_1} {p : Multiset α → Sort u_2} (s : Multiset α) {n : ℕ}
(H : (t₁ : Multiset α) → ({t₂ : Multiset α} → t₂.card ≤ n → t₁ < t₂ → p t₂) → t₁.card ≤ n → p t₁),
(fun a ↦ s.strongDownwardInductionOn H a) = H s fun {t} ht _h ↦ t.strongDownwardInductionOn H ht
def Multiset.chooseX E1 #
{α : Type u_1} → (p : α → Prop) → [DecidablePred p] → (l : Multiset α) → (∃! a, a ∈ l ∧ p a) → { a // a ∈ l ∧ p a }
Given a proof hp that there exists a unique a ∈ l such that p a, chooseX p l hp returns
that a together with proofs of a ∈ l and p a.
def Multiset.choose E1 #
{α : Type u_1} → (p : α → Prop) → [DecidablePred p] → (l : Multiset α) → (∃! a, a ∈ l ∧ p a) → α
Given a proof hp that there exists a unique a ∈ l such that p a, choose p l hp returns
that a.
theorem Multiset.choose_spec E1 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (l : Multiset α) (hp : ∃! a, a ∈ l ∧ p a),
Multiset.choose p l hp ∈ l ∧ p (Multiset.choose p l hp)
theorem Multiset.choose_mem E1 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (l : Multiset α) (hp : ∃! a, a ∈ l ∧ p a),
Multiset.choose p l hp ∈ l
theorem Multiset.choose_property E1 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (l : Multiset α) (hp : ∃! a, a ∈ l ∧ p a),
p (Multiset.choose p l hp)
theorem Multiset.choose_eq_iff E0 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (l : Multiset α) (hp : ∃! a, a ∈ l ∧ p a) {a : α},
Multiset.choose p l hp = a ↔ a ∈ l ∧ p a
def Multiset.subsingletonEquiv E1 #
(α : Type u_1) → [Subsingleton α] → List α ≃ Multiset α
The equivalence between lists and multisets of a subsingleton type.
theorem Multiset.coe_subsingletonEquiv E0 #
∀ {α : Type u_1} [inst : Subsingleton α], ⇑(Multiset.subsingletonEquiv α) = Multiset.ofList