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.Fold

17 declarations. Mathlib docs · Source

The fold operation for a commutative associative operation over a multiset.

fold

theorem Multiset.fold.congr_simp E1 #

∀ {α : Type u_1} (op op_1 : α → α → α) (e_op : op = op_1) [hc : Std.Commutative op] [ha : Std.Associative op]
  (a a_1 : α), a = a_1 → ∀ (a_2 a_3 : Multiset α), a_2 = a_3 → Multiset.fold op a a_2 = Multiset.fold op_1 a_1 a_3

def Multiset.fold E1 #

{α : Type u_1} → (op : α → α → α) → [hc : Std.Commutative op] → [ha : Std.Associative op] → α → Multiset α → α

fold op b s folds a commutative associative operation op over the multiset s.

theorem Multiset.fold_eq_foldr E1 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] (b : α) (s : Multiset α),
  Multiset.fold op b s = Multiset.foldr op b s

theorem Multiset.coe_fold_r E0 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] (b : α) (l : List α),
  Multiset.fold op b ↑l = List.foldr op b l

theorem Multiset.coe_fold_l E0 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] (b : α) (l : List α),
  Multiset.fold op b ↑l = List.foldl op b l

theorem Multiset.fold_eq_foldl E1 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] (b : α) (s : Multiset α),
  Multiset.fold op b s = Multiset.foldl op b s

theorem Multiset.fold_zero E0 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] (b : α), Multiset.fold op b 0 = b

theorem Multiset.fold_cons_left E0 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] (b a : α) (s : Multiset α),
  Multiset.fold op b (a ::ₘ s) = op a (Multiset.fold op b s)

theorem Multiset.fold_cons_right E1 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] (b a : α) (s : Multiset α),
  Multiset.fold op b (a ::ₘ s) = op (Multiset.fold op b s) a

theorem Multiset.fold_cons'_right E1 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] (b a : α) (s : Multiset α),
  Multiset.fold op b (a ::ₘ s) = Multiset.fold op (op b a) s

theorem Multiset.fold_cons'_left E1 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] (b a : α) (s : Multiset α),
  Multiset.fold op b (a ::ₘ s) = Multiset.fold op (op a b) s

theorem Multiset.fold_add E1 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] (b₁ b₂ : α) (s₁ s₂ : Multiset α),
  Multiset.fold op (op b₁ b₂) (s₁ + s₂) = op (Multiset.fold op b₁ s₁) (Multiset.fold op b₂ s₂)

theorem Multiset.fold_singleton E1 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] (b a : α),
  Multiset.fold op b {a} = op a b

theorem Multiset.fold_distrib E1 #

∀ {α : Type u_1} {β : Type u_2} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] {f g : β → α}
  (u₁ u₂ : α) (s : Multiset β),
  Multiset.fold op (op u₁ u₂) (Multiset.map (fun x ↦ op (f x) (g x)) s) =
    op (Multiset.fold op u₁ (Multiset.map f s)) (Multiset.fold op u₂ (Multiset.map g s))

theorem Multiset.fold_hom E1 #

∀ {α : Type u_1} {β : Type u_2} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] {op' : β → β → β}
  [inst : Std.Commutative op'] [inst_1 : Std.Associative op'] {m : α → β},
  (∀ (x y : α), m (op x y) = op' (m x) (m y)) →
    ∀ (b : α) (s : Multiset α), Multiset.fold op' (m b) (Multiset.map m s) = m (Multiset.fold op b s)

theorem Multiset.fold_union_inter E1 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] [inst : DecidableEq α]
  (s₁ s₂ : Multiset α) (b₁ b₂ : α),
  op (Multiset.fold op b₁ (s₁ ∪ s₂)) (Multiset.fold op b₂ (s₁ ∩ s₂)) =
    op (Multiset.fold op b₁ s₁) (Multiset.fold op b₂ s₂)

theorem Multiset.fold_dedup_idem E0 #

∀ {α : Type u_1} (op : α → α → α) [hc : Std.Commutative op] [ha : Std.Associative op] [inst : DecidableEq α]
  [hi : Std.IdempotentOp op] (s : Multiset α) (b : α), Multiset.fold op b s.dedup = Multiset.fold op b s