Products (respectively, sums) over a finset or a multiset. #
The regular finset.prod and multiset.prod require [comm_monoid α].
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.noncomm_prod, requiring a proof of commutativity of held termsmultiset.noncomm_prod, requiring a proof of commutativity of held terms
Implementation details #
While list.prod is defined via list.foldl, noncomm_prod is defined via
multiset.foldr for neater proofs and definitions. By the commutativity assumption,
the two must be equal.
Fold of a s : multiset α with f : α → β → β, given a proof that left_commutative f
on all elements x ∈ s.
Equations
- multiset.noncomm_foldr f s comm b = multiset.foldr (f ∘ subtype.val) _ b s.attach
Fold of a s : multiset α with an associative op : α → α → α, given a proofs that op
is commutative on all elements x ∈ s.
Equations
- multiset.noncomm_fold op s comm a = multiset.noncomm_foldr op s _ a
Sum of a s : multiset α with [add_monoid α], given a proof that + commutes
on all elements x ∈ s.
Equations
- s.noncomm_sum comm = multiset.noncomm_fold has_add.add s comm 0
Product of a s : multiset α with [monoid α], given a proof that * commutes
on all elements x ∈ s.
Equations
- s.noncomm_prod comm = multiset.noncomm_fold has_mul.mul s comm 1
Sum of a s : finset α mapped with f : α → β with [add_monoid β],
given a proof that + commutes on all elements f x for x ∈ s.
Equations
- s.noncomm_sum f comm = (multiset.map f s.val).noncomm_sum _
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.noncomm_prod f comm = (multiset.map f s.val).noncomm_prod _
The non-commutative version of finset.sum_union
The non-commutative version of finset.sum_add_distrib
The non-commutative version of finset.prod_mul_distrib