The fold operation for a commutative associative operation over a finset. #
fold #
@[simp]
theorem
Finset.fold_empty
{α : Type u_1}
{β : Type u_2}
{op : β → β → β}
[hc : Std.Commutative op]
[ha : Std.Associative op]
{f : α → β}
{b : β}
:
fold op b f ∅ = b
@[simp]
@[simp]
@[simp]
theorem
Finset.fold_singleton
{α : Type u_1}
{β : Type u_2}
{op : β → β → β}
[hc : Std.Commutative op]
[ha : Std.Associative op]
{f : α → β}
{b : β}
{a : α}
:
fold op b f {a} = op (f a) b
theorem
Finset.fold_const
{α : Type u_1}
{β : Type u_2}
{op : β → β → β}
[hc : Std.Commutative op]
[ha : Std.Associative op]
{b : β}
{s : Finset α}
[hd : Decidable (s = ∅)]
(c : β)
(h : op c (op b c) = op b c)
:
fold op b (fun (x : α) => c) s = if s = ∅ then b else op b c
theorem
Finset.fold_hom
{α : Type u_1}
{β : Type u_2}
{γ : Type u_3}
{op : β → β → β}
[hc : Std.Commutative op]
[ha : Std.Associative op]
{f : α → β}
{b : β}
{s : Finset α}
{op' : γ → γ → γ}
[Std.Commutative op']
[Std.Associative op']
{m : β → γ}
(hm : ∀ (x y : β), m (op x y) = op' (m x) (m y))
:
@[simp]
theorem
Finset.fold_ite'
{α : Type u_1}
{β : Type u_2}
{op : β → β → β}
[hc : Std.Commutative op]
[ha : Std.Associative op]
{f : α → β}
{b : β}
{s : Finset α}
{g : α → β}
(hb : op b b = b)
(p : α → Prop)
[DecidablePred p]
:
A stronger version of Finset.fold_ite, but relies on
an explicit proof of idempotency on the seed element, rather
than relying on typeclass idempotency over the whole type.
theorem
Finset.fold_ite
{α : Type u_1}
{β : Type u_2}
{op : β → β → β}
[hc : Std.Commutative op]
[ha : Std.Associative op]
{f : α → β}
{b : β}
{s : Finset α}
[Std.IdempotentOp op]
{g : α → β}
(p : α → Prop)
[DecidablePred p]
:
A weaker version of Finset.fold_ite',
relying on typeclass idempotency over the whole type,
instead of solely on the seed element.
However, this is easier to use because it does not generate side goals.
@[simp]
theorem
Finset.le_fold_min
{α : Type u_1}
{β : Type u_2}
{f : α → β}
{b : β}
{s : Finset α}
[LinearOrder β]
(c : β)
:
theorem
Finset.fold_min_le
{α : Type u_1}
{β : Type u_2}
{f : α → β}
{b : β}
{s : Finset α}
[LinearOrder β]
(c : β)
:
theorem
Finset.lt_fold_min
{α : Type u_1}
{β : Type u_2}
{f : α → β}
{b : β}
{s : Finset α}
[LinearOrder β]
(c : β)
:
theorem
Finset.fold_min_lt
{α : Type u_1}
{β : Type u_2}
{f : α → β}
{b : β}
{s : Finset α}
[LinearOrder β]
(c : β)
:
theorem
Finset.fold_max_le
{α : Type u_1}
{β : Type u_2}
{f : α → β}
{b : β}
{s : Finset α}
[LinearOrder β]
(c : β)
:
theorem
Finset.le_fold_max
{α : Type u_1}
{β : Type u_2}
{f : α → β}
{b : β}
{s : Finset α}
[LinearOrder β]
(c : β)
:
theorem
Finset.fold_max_lt
{α : Type u_1}
{β : Type u_2}
{f : α → β}
{b : β}
{s : Finset α}
[LinearOrder β]
(c : β)
:
theorem
Finset.lt_fold_max
{α : Type u_1}
{β : Type u_2}
{f : α → β}
{b : β}
{s : Finset α}
[LinearOrder β]
(c : β)
: