Sums and products over multisets #
In this file we define products and sums indexed by multisets. This is later used to define products and sums indexed by finite sets.
Main declarations #
Multiset.prod
:s.prod f
is the product off i
over alli ∈ s
. Not to be mistaken with the cartesian productMultiset.product
.Multiset.sum
:s.sum f
is the sum off i
over alli ∈ s
.
Product of a multiset given a commutative monoid structure on M
.
prod {a, b, c} = a * b * c
Equations
- Multiset.prod = Multiset.foldr (fun (x1 x2 : M) => x1 * x2) 1
Instances For
Sum of a multiset given a commutative additive monoid structure on M
.
sum {a, b, c} = a + b + c
Equations
- Multiset.sum = Multiset.foldr (fun (x1 x2 : M) => x1 + x2) 0
Instances For
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
theorem
Multiset.nsmul_count
{M : Type u_3}
[AddCommMonoid M]
{s : Multiset M}
[DecidableEq M]
(a : M)
:
theorem
Multiset.prod_hom_rel
{ι : Type u_2}
{M : Type u_3}
{N : Type u_4}
[CommMonoid M]
[CommMonoid N]
(s : Multiset ι)
{r : M → N → Prop}
{f : ι → M}
{g : ι → N}
(h₁ : r 1 1)
(h₂ : ∀ ⦃a : ι⦄ ⦃b : M⦄ ⦃c : N⦄, r b c → r (f a * b) (g a * c))
:
theorem
Multiset.sum_hom_rel
{ι : Type u_2}
{M : Type u_3}
{N : Type u_4}
[AddCommMonoid M]
[AddCommMonoid N]
(s : Multiset ι)
{r : M → N → Prop}
{f : ι → M}
{g : ι → N}
(h₁ : r 0 0)
(h₂ : ∀ ⦃a : ι⦄ ⦃b : M⦄ ⦃c : N⦄, r b c → r (f a + b) (g a + c))
:
theorem
Multiset.prod_induction
{M : Type u_3}
[CommMonoid M]
(p : M → Prop)
(s : Multiset M)
(p_mul : ∀ (a b : M), p a → p b → p (a * b))
(p_one : p 1)
(p_s : ∀ a ∈ s, p a)
:
p s.prod
theorem
Multiset.sum_induction
{M : Type u_3}
[AddCommMonoid M]
(p : M → Prop)
(s : Multiset M)
(p_mul : ∀ (a b : M), p a → p b → p (a + b))
(p_one : p 0)
(p_s : ∀ a ∈ s, p a)
:
p s.sum
theorem
Multiset.prod_induction_nonempty
{M : Type u_3}
[CommMonoid M]
{s : Multiset M}
(p : M → Prop)
(p_mul : ∀ (a b : M), p a → p b → p (a * b))
(hs : s ≠ ∅)
(p_s : ∀ a ∈ s, p a)
:
p s.prod
theorem
Multiset.sum_induction_nonempty
{M : Type u_3}
[AddCommMonoid M]
{s : Multiset M}
(p : M → Prop)
(p_mul : ∀ (a b : M), p a → p b → p (a + b))
(hs : s ≠ ∅)
(p_s : ∀ a ∈ s, p a)
:
p s.sum