The fold operation for a commutative associative operation over a multiset. #
fold #
def
Multiset.fold
{α : 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.
Instances For
theorem
Multiset.fold_eq_foldr
{α : Type u_1}
(op : α → α → α)
[hc : Std.Commutative op]
[ha : Std.Associative op]
(b : α)
(s : Multiset α)
:
@[simp]
theorem
Multiset.coe_fold_r
{α : Type u_1}
(op : α → α → α)
[hc : Std.Commutative op]
[ha : Std.Associative op]
(b : α)
(l : List α)
:
fold op b ↑l = List.foldr op b l
theorem
Multiset.coe_fold_l
{α : Type u_1}
(op : α → α → α)
[hc : Std.Commutative op]
[ha : Std.Associative op]
(b : α)
(l : List α)
:
fold op b ↑l = List.foldl op b l
theorem
Multiset.fold_eq_foldl
{α : Type u_1}
(op : α → α → α)
[hc : Std.Commutative op]
[ha : Std.Associative op]
(b : α)
(s : Multiset α)
:
@[simp]
theorem
Multiset.fold_zero
{α : Type u_1}
(op : α → α → α)
[hc : Std.Commutative op]
[ha : Std.Associative op]
(b : α)
:
fold op b 0 = b
@[simp]
theorem
Multiset.fold_singleton
{α : Type u_1}
(op : α → α → α)
[hc : Std.Commutative op]
[ha : Std.Associative op]
(b a : α)
:
fold op b {a} = op a b
theorem
Multiset.fold_hom
{α : Type u_1}
{β : Type u_2}
(op : α → α → α)
[hc : Std.Commutative op]
[ha : Std.Associative op]
{op' : β → β → β}
[Std.Commutative op']
[Std.Associative op']
{m : α → β}
(hm : ∀ (x y : α), m (op x y) = op' (m x) (m y))
(b : α)
(s : Multiset α)
:
@[simp]