Products (respectively, sums) over a finset or a multiset. #
The regular Finset.prod
and Multiset.prod
require [CommMonoid α]
.
Often, there are collections s : Finset α
where [Monoid α]
and we know,
in a dependent fashion, that for all the terms ∀ (x ∈ s) (y ∈ s), Commute x y
.
This allows to still have a well-defined product over s
.
Main definitions #
Finset.noncommProd
, requiring a proof of commutativity of held termsMultiset.noncommProd
, requiring a proof of commutativity of held terms
Implementation details #
While List.prod
is defined via List.foldl
, noncommProd
is defined via
Multiset.foldr
for neater proofs and definitions. By the commutativity assumption,
the two must be equal.
TODO: Tidy up this file by using the fact that the submonoid generated by commuting
elements is commutative and using the Finset.prod
versions of lemmas to prove the noncommProd
version.
Fold of a s : Multiset α
with f : α → β → β
, given a proof that LeftCommutative f
on all elements x ∈ s
.
Equations
- Multiset.noncommFoldr f s comm b = Multiset.foldr (f ∘ Subtype.val) ⋯ b s.attach
Instances For
Fold of a s : Multiset α
with an associative op : α → α → α
, given a proofs that op
is commutative on all elements x ∈ s
.
Equations
- Multiset.noncommFold op s comm = Multiset.noncommFoldr op s ⋯
Instances For
Sum of a s : Multiset α
with [AddMonoid α]
, given a proof that +
commutes
on all elements x ∈ s
.
Equations
- s.noncommSum comm = Multiset.noncommFold (fun (x x_1 : α) => x + x_1) s comm 0
Instances For
Product of a s : Multiset α
with [Monoid α]
, given a proof that *
commutes
on all elements x ∈ s
.
Equations
- s.noncommProd comm = Multiset.noncommFold (fun (x x_1 : α) => x * x_1) s comm 1
Instances For
Proof used in definition of Finset.noncommProd
Sum of a s : Finset α
mapped with f : α → β
with [AddMonoid β]
,
given a proof that +
commutes on all elements f x
for x ∈ s
.
Equations
- s.noncommSum f comm = (Multiset.map f s.val).noncommSum ⋯
Instances For
Product of a s : Finset α
mapped with f : α → β
with [Monoid β]
,
given a proof that *
commutes on all elements f x
for x ∈ s
.
Equations
- s.noncommProd f comm = (Multiset.map f s.val).noncommProd ⋯
Instances For
The non-commutative version of Finset.sum_union
The non-commutative version of Finset.prod_union
The non-commutative version of Finset.sum_add_distrib
The non-commutative version of Finset.prod_mul_distrib