The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V03. Sets, finite structures and big operators

Mathlib.Data.Multiset.UnionInter

77 declarations. Mathlib docs · Source

Distributive lattice structure on multisets

This file defines an instance DistribLattice (Multiset α) using the union and intersection operators:

  • s ∪ t: The multiset for which the number of occurrences of each a is the max of the occurrences of a in s and t.
  • s ∩ t: The multiset for which the number of occurrences of each a is the min of the occurrences of a in s and t.

Union

Intersection

Disjoint multisets

def Multiset.union E1 #

{α : Type u_1} → [DecidableEq α] → Multiset α → Multiset α → Multiset α

s ∪ t is the multiset such that the multiplicity of each a in it is the maximum of the multiplicity of a in s and t. This is the supremum of multisets.

instance Multiset.instUnion E0 #

{α : Type u_1} → [DecidableEq α] → Union (Multiset α)

theorem Multiset.union_def E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Multiset α), s ∪ t = s - t + t

theorem Multiset.le_union_left E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α}, s ≤ s ∪ t

theorem Multiset.le_union_right E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α}, t ≤ s ∪ t

theorem Multiset.union_le_union_right E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α}, s ≤ t → ∀ (u : Multiset α), s ∪ u ≤ t ∪ u

theorem Multiset.union_le E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t u : Multiset α}, s ≤ u → t ≤ u → s ∪ t ≤ u

theorem Multiset.mem_union E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α} {a : α}, a ∈ s ∪ t ↔ a ∈ s ∨ a ∈ t

theorem Multiset.map_union E0 #

∀ {α : Type u_1} {β : Type v} [inst : DecidableEq α] [inst_1 : DecidableEq β] {f : α → β},
  Function.Injective f → ∀ {s t : Multiset α}, Multiset.map f (s ∪ t) = Multiset.map f s ∪ Multiset.map f t

theorem Multiset.zero_union E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {s : Multiset α}, 0 ∪ s = s

theorem Multiset.union_zero E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {s : Multiset α}, s ∪ 0 = s

theorem Multiset.count_union E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (s t : Multiset α),
  Multiset.count a (s ∪ t) = max (Multiset.count a s) (Multiset.count a t)

theorem Multiset.filter_union E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (p : α → Prop) [inst_1 : DecidablePred p] (s t : Multiset α),
  Multiset.filter p (s ∪ t) = Multiset.filter p s ∪ Multiset.filter p t

def Multiset.inter E1 #

{α : Type u_1} → [DecidableEq α] → Multiset α → Multiset α → Multiset α

s ∩ t is the multiset such that the multiplicity of each a in it is the minimum of the multiplicity of a in s and t. This is the infimum of multisets.

instance Multiset.instInter E0 #

{α : Type u_1} → [DecidableEq α] → Inter (Multiset α)

theorem Multiset.inter_zero E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (s : Multiset α), s ∩ 0 = 0

theorem Multiset.zero_inter E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (s : Multiset α), 0 ∩ s = 0

theorem Multiset.cons_inter_of_pos E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {t : Multiset α} {a : α} (s : Multiset α),
  a ∈ t → (a ::ₘ s) ∩ t = a ::ₘ s ∩ t.erase a

theorem Multiset.cons_inter_of_neg E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {t : Multiset α} {a : α} (s : Multiset α), a ∉ t → (a ::ₘ s) ∩ t = s ∩ t

theorem Multiset.inter_le_left E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α}, s ∩ t ≤ s

theorem Multiset.inter_le_right E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α}, s ∩ t ≤ t

theorem Multiset.le_inter E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t u : Multiset α}, s ≤ t → s ≤ u → s ≤ t ∩ u

theorem Multiset.mem_inter E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α} {a : α}, a ∈ s ∩ t ↔ a ∈ s ∧ a ∈ t

instance Multiset.instLattice E0 #

{α : Type u_1} → [DecidableEq α] → Lattice (Multiset α)

theorem Multiset.sup_eq_union E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Multiset α), s ⊔ t = s ∪ t

theorem Multiset.inf_eq_inter E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Multiset α), s ⊓ t = s ∩ t

theorem Multiset.le_inter_iff E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t u : Multiset α}, s ≤ t ∩ u ↔ s ≤ t ∧ s ≤ u

theorem Multiset.union_le_iff E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t u : Multiset α}, s ∪ t ≤ u ↔ s ≤ u ∧ t ≤ u

theorem Multiset.union_comm E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Multiset α), s ∪ t = t ∪ s

theorem Multiset.inter_comm E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Multiset α), s ∩ t = t ∩ s

theorem Multiset.union_le_union_left E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α}, s ≤ t → ∀ (u : Multiset α), u ∪ s ≤ u ∪ t

theorem Multiset.union_le_add E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Multiset α), s ∪ t ≤ s + t

theorem Multiset.union_add_distrib E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t u : Multiset α), s ∪ t + u = s + u ∪ (t + u)

theorem Multiset.add_union_distrib E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t u : Multiset α), s + (t ∪ u) = s + t ∪ (s + u)

theorem Multiset.cons_union_distrib E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (s t : Multiset α), a ::ₘ (s ∪ t) = a ::ₘ s ∪ a ::ₘ t

theorem Multiset.inter_add_distrib E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t u : Multiset α), s ∩ t + u = (s + u) ∩ (t + u)

theorem Multiset.add_inter_distrib E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t u : Multiset α), s + t ∩ u = (s + t) ∩ (s + u)

theorem Multiset.cons_inter_distrib E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (s t : Multiset α), a ::ₘ s ∩ t = (a ::ₘ s) ∩ (a ::ₘ t)

theorem Multiset.union_add_inter E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Multiset α), s ∪ t + s ∩ t = s + t

theorem Multiset.sub_add_inter E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Multiset α), s - t + s ∩ t = s

theorem Multiset.sub_inter E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : Multiset α), s - s ∩ t = s - t

theorem Multiset.count_inter E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (s t : Multiset α),
  Multiset.count a (s ∩ t) = min (Multiset.count a s) (Multiset.count a t)

theorem Multiset.coe_inter E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (s t : List α), ↑s ∩ ↑t = ↑(s.bagInter t)

instance Multiset.instDistribLattice E0 #

{α : Type u_1} → [DecidableEq α] → DistribLattice (Multiset α)

theorem Multiset.filter_inter E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (p : α → Prop) [inst_1 : DecidablePred p] (s t : Multiset α),
  Multiset.filter p (s ∩ t) = Multiset.filter p s ∩ Multiset.filter p t

theorem Multiset.replicate_inter E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (n : ℕ) (x : α) (s : Multiset α),
  Multiset.replicate n x ∩ s = Multiset.replicate (min n (Multiset.count x s)) x

theorem Multiset.inter_replicate E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (s : Multiset α) (n : ℕ) (x : α),
  s ∩ Multiset.replicate n x = Multiset.replicate (min (Multiset.count x s) n) x

theorem Multiset.inter_add_sub_of_add_eq_add E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {M N P Q : Multiset α}, M + N = P + Q → N ∩ Q + (P - M) = N

theorem Multiset.disjoint_left E1 #

∀ {α : Type u_1} {s t : Multiset α}, Disjoint s t ↔ ∀ {a : α}, a ∈ s → a ∉ t

theorem Disjoint.notMem_of_mem_left_multiset E1 #

∀ {α : Type u_1} {s t : Multiset α}, Disjoint s t → ∀ {a : α}, a ∈ s → a ∉ t

Alias of the forward direction of Multiset.disjoint_left.

theorem Multiset.coe_disjoint E0 #

∀ {α : Type u_1} (l₁ l₂ : List α), Disjoint ↑l₁ ↑l₂ ↔ l₁.Disjoint l₂

theorem Multiset.disjoint_right E1 #

∀ {α : Type u_1} {s t : Multiset α}, Disjoint s t ↔ ∀ {a : α}, a ∈ t → a ∉ s

theorem Disjoint.notMem_of_mem_right_multiset E1 #

∀ {α : Type u_1} {s t : Multiset α}, Disjoint s t → ∀ {a : α}, a ∈ t → a ∉ s

Alias of the forward direction of Multiset.disjoint_right.

theorem Multiset.disjoint_iff_ne E1 #

∀ {α : Type u_1} {s t : Multiset α}, Disjoint s t ↔ ∀ a ∈ s, ∀ b ∈ t, a ≠ b

theorem Multiset.disjoint_of_subset_left E1 #

∀ {α : Type u_1} {s t u : Multiset α}, s ⊆ u → Disjoint u t → Disjoint s t

theorem Multiset.disjoint_of_subset_right E1 #

∀ {α : Type u_1} {s t u : Multiset α}, t ⊆ u → Disjoint s u → Disjoint s t

theorem Multiset.zero_disjoint E0 #

∀ {α : Type u_1} (l : Multiset α), Disjoint 0 l

theorem Multiset.singleton_disjoint E0 #

∀ {α : Type u_1} {l : Multiset α} {a : α}, Disjoint {a} l ↔ a ∉ l

theorem Multiset.disjoint_singleton E0 #

∀ {α : Type u_1} {l : Multiset α} {a : α}, Disjoint l {a} ↔ a ∉ l

theorem Multiset.disjoint_add_left E0 #

∀ {α : Type u_1} {s t u : Multiset α}, Disjoint (s + t) u ↔ Disjoint s u ∧ Disjoint t u

theorem Multiset.disjoint_add_right E0 #

∀ {α : Type u_1} {s t u : Multiset α}, Disjoint s (t + u) ↔ Disjoint s t ∧ Disjoint s u

theorem Multiset.disjoint_cons_left E0 #

∀ {α : Type u_1} {a : α} {s t : Multiset α}, Disjoint (a ::ₘ s) t ↔ a ∉ t ∧ Disjoint s t

theorem Multiset.disjoint_cons_right E0 #

∀ {α : Type u_1} {a : α} {s t : Multiset α}, Disjoint s (a ::ₘ t) ↔ a ∉ s ∧ Disjoint s t

theorem Multiset.inter_eq_zero_iff_disjoint E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α}, s ∩ t = 0 ↔ Disjoint s t

theorem Multiset.disjoint_union_left E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t u : Multiset α}, Disjoint (s ∪ t) u ↔ Disjoint s u ∧ Disjoint t u

theorem Multiset.disjoint_union_right E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t u : Multiset α}, Disjoint s (t ∪ u) ↔ Disjoint s t ∧ Disjoint s u

theorem Multiset.add_eq_union_iff_disjoint E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α}, s + t = s ∪ t ↔ Disjoint s t

theorem Multiset.add_eq_union_left_of_le E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t u : Multiset α}, t ≤ s → (u + s = u ∪ t ↔ Disjoint u s ∧ s = t)

theorem Multiset.add_eq_union_right_of_le E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {x y z : Multiset α}, z ≤ y → (x + y = x ∪ z ↔ y = z ∧ Disjoint x y)

theorem Multiset.disjoint_map_map E1 #

∀ {α : Type u_1} {β : Type v} {γ : Type u_2} {f : α → γ} {g : β → γ} {s : Multiset α} {t : Multiset β},
  Disjoint (Multiset.map f s) (Multiset.map g t) ↔ ∀ a ∈ s, ∀ b ∈ t, f a ≠ g b

theorem Multiset.map_set_pairwise E0 #

∀ {α : Type u_1} {β : Type v} {f : α → β} {r : β → β → Prop} {m : Multiset α},
  ({a | a ∈ m}.Pairwise fun a₁ a₂ ↦ r (f a₁) (f a₂)) → {b | b ∈ Multiset.map f m}.Pairwise r

theorem Multiset.nodup_add E1 #

∀ {α : Type u_1} {s t : Multiset α}, (s + t).Nodup ↔ s.Nodup ∧ t.Nodup ∧ Disjoint s t

theorem Multiset.disjoint_of_nodup_add E1 #

∀ {α : Type u_1} {s t : Multiset α}, (s + t).Nodup → Disjoint s t

theorem Multiset.Nodup.add_iff E0 #

∀ {α : Type u_1} {s t : Multiset α}, s.Nodup → t.Nodup → ((s + t).Nodup ↔ Disjoint s t)

theorem Multiset.Nodup.inter_left E1 #

∀ {α : Type u_1} {s : Multiset α} [inst : DecidableEq α] (t : Multiset α), s.Nodup → (s ∩ t).Nodup

theorem Multiset.Nodup.inter_right E1 #

∀ {α : Type u_1} {t : Multiset α} [inst : DecidableEq α] (s : Multiset α), t.Nodup → (s ∩ t).Nodup

theorem Multiset.nodup_union E0 #

∀ {α : Type u_1} [inst : DecidableEq α] {s t : Multiset α}, (s ∪ t).Nodup ↔ s.Nodup ∧ t.Nodup