mathlib documentation

algebra.big_operators.multiset

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 #

def multiset.sum {α : Type u_2} [add_comm_monoid α] :
multiset α → α

Sum of a multiset given a commutative additive monoid structure on α. sum {a, b, c} = a + b + c

Equations
def multiset.prod {α : Type u_2} [comm_monoid α] :
multiset α → α

Product of a multiset given a commutative monoid structure on α. prod {a, b, c} = a * b * c

Equations
theorem multiset.sum_eq_foldr {α : Type u_2} [add_comm_monoid α] (s : multiset α) :
theorem multiset.prod_eq_foldr {α : Type u_2} [comm_monoid α] (s : multiset α) :
theorem multiset.prod_eq_foldl {α : Type u_2} [comm_monoid α] (s : multiset α) :
theorem multiset.sum_eq_foldl {α : Type u_2} [add_comm_monoid α] (s : multiset α) :
@[simp, norm_cast]
theorem multiset.coe_sum {α : Type u_2} [add_comm_monoid α] (l : list α) :
@[simp, norm_cast]
theorem multiset.coe_prod {α : Type u_2} [comm_monoid α] (l : list α) :
@[simp]
theorem multiset.sum_to_list {α : Type u_2} [add_comm_monoid α] (s : multiset α) :
@[simp]
theorem multiset.prod_to_list {α : Type u_2} [comm_monoid α] (s : multiset α) :
@[simp]
theorem multiset.prod_zero {α : Type u_2} [comm_monoid α] :
0.prod = 1
@[simp]
theorem multiset.sum_zero {α : Type u_2} [add_comm_monoid α] :
0.sum = 0
@[simp]
theorem multiset.prod_cons {α : Type u_2} [comm_monoid α] (a : α) (s : multiset α) :
(a ::ₘ s).prod = a * s.prod
@[simp]
theorem multiset.sum_cons {α : Type u_2} [add_comm_monoid α] (a : α) (s : multiset α) :
(a ::ₘ s).sum = a + s.sum
@[simp]
theorem multiset.prod_erase {α : Type u_2} [comm_monoid α] {s : multiset α} {a : α} [decidable_eq α] (h : a s) :
a * (s.erase a).prod = s.prod
@[simp]
theorem multiset.sum_erase {α : Type u_2} [add_comm_monoid α] {s : multiset α} {a : α} [decidable_eq α] (h : a s) :
a + (s.erase a).sum = s.sum
@[simp]
theorem multiset.sum_map_erase {ι : Type u_1} {α : Type u_2} [add_comm_monoid α] {m : multiset ι} {f : ι → α} [decidable_eq ι] {a : ι} (h : a m) :
f a + (multiset.map f (m.erase a)).sum = (multiset.map f m).sum
@[simp]
theorem multiset.prod_map_erase {ι : Type u_1} {α : Type u_2} [comm_monoid α] {m : multiset ι} {f : ι → α} [decidable_eq ι] {a : ι} (h : a m) :
f a * (multiset.map f (m.erase a)).prod = (multiset.map f m).prod
@[simp]
theorem multiset.prod_singleton {α : Type u_2} [comm_monoid α] (a : α) :
{a}.prod = a
@[simp]
theorem multiset.sum_singleton {α : Type u_2} [add_comm_monoid α] (a : α) :
{a}.sum = a
theorem multiset.prod_pair {α : Type u_2} [comm_monoid α] (a b : α) :
{a, b}.prod = a * b
theorem multiset.sum_pair {α : Type u_2} [add_comm_monoid α] (a b : α) :
{a, b}.sum = a + b
@[simp]
theorem multiset.prod_add {α : Type u_2} [comm_monoid α] (s t : multiset α) :
(s + t).prod = s.prod * t.prod
@[simp]
theorem multiset.sum_add {α : Type u_2} [add_comm_monoid α] (s t : multiset α) :
(s + t).sum = s.sum + t.sum
theorem multiset.prod_nsmul {α : Type u_2} [comm_monoid α] (m : multiset α) (n : ) :
(n m).prod = m.prod ^ n
@[simp]
theorem multiset.prod_repeat {α : Type u_2} [comm_monoid α] (a : α) (n : ) :
@[simp]
theorem multiset.sum_repeat {α : Type u_2} [add_comm_monoid α] (a : α) (n : ) :
theorem multiset.prod_map_eq_pow_single {ι : Type u_1} {α : Type u_2} [comm_monoid α] {m : multiset ι} {f : ι → α} [decidable_eq ι] (i : ι) (hf : ∀ (i' : ι), i' ii' mf i' = 1) :
theorem multiset.sum_map_eq_nsmul_single {ι : Type u_1} {α : Type u_2} [add_comm_monoid α] {m : multiset ι} {f : ι → α} [decidable_eq ι] (i : ι) (hf : ∀ (i' : ι), i' ii' mf i' = 0) :
theorem multiset.sum_eq_nsmul_single {α : Type u_2} [add_comm_monoid α] {s : multiset α} [decidable_eq α] (a : α) (h : ∀ (a' : α), a' aa' sa' = 0) :
theorem multiset.prod_eq_pow_single {α : Type u_2} [comm_monoid α] {s : multiset α} [decidable_eq α] (a : α) (h : ∀ (a' : α), a' aa' sa' = 1) :
theorem multiset.pow_count {α : Type u_2} [comm_monoid α] {s : multiset α} [decidable_eq α] (a : α) :
theorem multiset.nsmul_count {α : Type u_2} [add_comm_monoid α] {s : multiset α} [decidable_eq α] (a : α) :
theorem multiset.sum_hom {α : Type u_2} {β : Type u_3} [add_comm_monoid α] [add_comm_monoid β] (s : multiset α) {F : Type u_1} [add_monoid_hom_class F α β] (f : F) :
theorem multiset.prod_hom {α : Type u_2} {β : Type u_3} [comm_monoid α] [comm_monoid β] (s : multiset α) {F : Type u_1} [monoid_hom_class F α β] (f : F) :
theorem multiset.sum_hom' {ι : Type u_1} {α : Type u_2} {β : Type u_3} [add_comm_monoid α] [add_comm_monoid β] (s : multiset ι) {F : Type u_4} [add_monoid_hom_class F α β] (f : F) (g : ι → α) :
(multiset.map (λ (i : ι), f (g i)) s).sum = f (multiset.map g s).sum
theorem multiset.prod_hom' {ι : Type u_1} {α : Type u_2} {β : Type u_3} [comm_monoid α] [comm_monoid β] (s : multiset ι) {F : Type u_4} [monoid_hom_class F α β] (f : F) (g : ι → α) :
(multiset.map (λ (i : ι), f (g i)) s).prod = f (multiset.map g s).prod
theorem multiset.prod_hom₂ {ι : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [comm_monoid α] [comm_monoid β] [comm_monoid γ] (s : multiset ι) (f : α → β → γ) (hf : ∀ (a b : α) (c d : β), f (a * b) (c * d) = f a c * f b d) (hf' : f 1 1 = 1) (f₁ : ι → α) (f₂ : ι → β) :
(multiset.map (λ (i : ι), f (f₁ i) (f₂ i)) s).prod = f (multiset.map f₁ s).prod (multiset.map f₂ s).prod
theorem multiset.sum_hom₂ {ι : Type u_1} {α : Type u_2} {β : Type u_3} {γ : Type u_4} [add_comm_monoid α] [add_comm_monoid β] [add_comm_monoid γ] (s : multiset ι) (f : α → β → γ) (hf : ∀ (a b : α) (c d : β), f (a + b) (c + d) = f a c + f b d) (hf' : f 0 0 = 0) (f₁ : ι → α) (f₂ : ι → β) :
(multiset.map (λ (i : ι), f (f₁ i) (f₂ i)) s).sum = f (multiset.map f₁ s).sum (multiset.map f₂ s).sum
theorem multiset.sum_hom_rel {ι : Type u_1} {α : Type u_2} {β : Type u_3} [add_comm_monoid α] [add_comm_monoid β] (s : multiset ι) {r : α → β → Prop} {f : ι → α} {g : ι → β} (h₁ : r 0 0) (h₂ : ∀ ⦃a : ι⦄ ⦃b : α⦄ ⦃c : β⦄, r b cr (f a + b) (g a + c)) :
theorem multiset.prod_hom_rel {ι : Type u_1} {α : Type u_2} {β : Type u_3} [comm_monoid α] [comm_monoid β] (s : multiset ι) {r : α → β → Prop} {f : ι → α} {g : ι → β} (h₁ : r 1 1) (h₂ : ∀ ⦃a : ι⦄ ⦃b : α⦄ ⦃c : β⦄, r b cr (f a * b) (g a * c)) :
theorem multiset.sum_map_zero {ι : Type u_1} {α : Type u_2} [add_comm_monoid α] {m : multiset ι} :
(multiset.map (λ (i : ι), 0) m).sum = 0
theorem multiset.prod_map_one {ι : Type u_1} {α : Type u_2} [comm_monoid α] {m : multiset ι} :
(multiset.map (λ (i : ι), 1) m).prod = 1
@[simp]
theorem multiset.sum_map_add {ι : Type u_1} {α : Type u_2} [add_comm_monoid α] {m : multiset ι} {f g : ι → α} :
(multiset.map (λ (i : ι), f i + g i) m).sum = (multiset.map f m).sum + (multiset.map g m).sum
@[simp]
theorem multiset.prod_map_mul {ι : Type u_1} {α : Type u_2} [comm_monoid α] {m : multiset ι} {f g : ι → α} :
(multiset.map (λ (i : ι), f i * g i) m).prod = (multiset.map f m).prod * (multiset.map g m).prod
@[simp]
theorem multiset.prod_map_neg {α : Type u_2} [comm_monoid α] [has_distrib_neg α] (s : multiset α) :
theorem multiset.prod_map_pow {ι : Type u_1} {α : Type u_2} [comm_monoid α] {m : multiset ι} {f : ι → α} {n : } :
(multiset.map (λ (i : ι), f i ^ n) m).prod = (multiset.map f m).prod ^ n
theorem multiset.sum_map_nsmul {ι : Type u_1} {α : Type u_2} [add_comm_monoid α] {m : multiset ι} {f : ι → α} {n : } :
(multiset.map (λ (i : ι), n f i) m).sum = n (multiset.map f m).sum
theorem multiset.prod_map_prod_map {α : Type u_2} {β : Type u_3} {γ : Type u_4} [comm_monoid α] (m : multiset β) (n : multiset γ) {f : β → γ → α} :
(multiset.map (λ (a : β), (multiset.map (λ (b : γ), f a b) n).prod) m).prod = (multiset.map (λ (b : γ), (multiset.map (λ (a : β), f a b) m).prod) n).prod
theorem multiset.sum_map_sum_map {α : Type u_2} {β : Type u_3} {γ : Type u_4} [add_comm_monoid α] (m : multiset β) (n : multiset γ) {f : β → γ → α} :
(multiset.map (λ (a : β), (multiset.map (λ (b : γ), f a b) n).sum) m).sum = (multiset.map (λ (b : γ), (multiset.map (λ (a : β), f a b) m).sum) n).sum
theorem multiset.prod_induction {α : Type u_2} [comm_monoid α] (p : α → Prop) (s : multiset α) (p_mul : ∀ (a b : α), p ap bp (a * b)) (p_one : p 1) (p_s : ∀ (a : α), a sp a) :
p s.prod
theorem multiset.sum_induction {α : Type u_2} [add_comm_monoid α] (p : α → Prop) (s : multiset α) (p_mul : ∀ (a b : α), p ap bp (a + b)) (p_one : p 0) (p_s : ∀ (a : α), a sp a) :
p s.sum
theorem multiset.sum_induction_nonempty {α : Type u_2} [add_comm_monoid α] {s : multiset α} (p : α → Prop) (p_mul : ∀ (a b : α), p ap bp (a + b)) (hs : s ) (p_s : ∀ (a : α), a sp a) :
p s.sum
theorem multiset.prod_induction_nonempty {α : Type u_2} [comm_monoid α] {s : multiset α} (p : α → Prop) (p_mul : ∀ (a b : α), p ap bp (a * b)) (hs : s ) (p_s : ∀ (a : α), a sp a) :
p s.prod
theorem multiset.dvd_prod {α : Type u_2} [comm_monoid α] {s : multiset α} {a : α} :
a sa s.prod
theorem multiset.prod_dvd_prod_of_le {α : Type u_2} [comm_monoid α] {s t : multiset α} (h : s t) :
theorem multiset.prod_dvd_prod_of_dvd {α : Type u_2} {β : Type u_3} [comm_monoid β] {S : multiset α} (g1 g2 : α → β) (h : ∀ (a : α), a Sg1 a g2 a) :
def multiset.sum_add_monoid_hom {α : Type u_2} [add_comm_monoid α] :

multiset.sum, the sum of the elements of a multiset, promoted to a morphism of add_comm_monoids.

Equations
theorem multiset.prod_eq_zero {α : Type u_2} [comm_monoid_with_zero α] {s : multiset α} (h : 0 s) :
s.prod = 0
theorem multiset.prod_eq_zero_iff {α : Type u_2} [comm_monoid_with_zero α] [no_zero_divisors α] [nontrivial α] {s : multiset α} :
s.prod = 0 0 s
theorem multiset.prod_ne_zero {α : Type u_2} [comm_monoid_with_zero α] [no_zero_divisors α] [nontrivial α] {s : multiset α} (h : 0 s) :
s.prod 0
@[simp]
theorem multiset.sum_map_neg {ι : Type u_1} {α : Type u_2} [subtraction_comm_monoid α] {m : multiset ι} {f : ι → α} :
(multiset.map (λ (i : ι), -f i) m).sum = -(multiset.map f m).sum
@[simp]
theorem multiset.prod_map_inv {ι : Type u_1} {α : Type u_2} [division_comm_monoid α] {m : multiset ι} {f : ι → α} :
(multiset.map (λ (i : ι), (f i)⁻¹) m).prod = ((multiset.map f m).prod)⁻¹
@[simp]
theorem multiset.sum_map_sub {ι : Type u_1} {α : Type u_2} [subtraction_comm_monoid α] {m : multiset ι} {f g : ι → α} :
(multiset.map (λ (i : ι), f i - g i) m).sum = (multiset.map f m).sum - (multiset.map g m).sum
@[simp]
theorem multiset.prod_map_div {ι : Type u_1} {α : Type u_2} [division_comm_monoid α] {m : multiset ι} {f g : ι → α} :
(multiset.map (λ (i : ι), f i / g i) m).prod = (multiset.map f m).prod / (multiset.map g m).prod
theorem multiset.prod_map_zpow {ι : Type u_1} {α : Type u_2} [division_comm_monoid α] {m : multiset ι} {f : ι → α} {n : } :
(multiset.map (λ (i : ι), f i ^ n) m).prod = (multiset.map f m).prod ^ n
theorem multiset.sum_map_zsmul {ι : Type u_1} {α : Type u_2} [subtraction_comm_monoid α] {m : multiset ι} {f : ι → α} {n : } :
(multiset.map (λ (i : ι), n f i) m).sum = n (multiset.map f m).sum
theorem commute.multiset_sum_right {α : Type u_2} [non_unital_non_assoc_semiring α] (s : multiset α) (a : α) (h : ∀ (b : α), b scommute a b) :
theorem commute.multiset_sum_left {α : Type u_2} [non_unital_non_assoc_semiring α] (s : multiset α) (b : α) (h : ∀ (a : α), a scommute a b) :
theorem multiset.sum_map_mul_left {ι : Type u_1} {α : Type u_2} [non_unital_non_assoc_semiring α] {a : α} {s : multiset ι} {f : ι → α} :
(multiset.map (λ (i : ι), a * f i) s).sum = a * (multiset.map f s).sum
theorem multiset.sum_map_mul_right {ι : Type u_1} {α : Type u_2} [non_unital_non_assoc_semiring α] {a : α} {s : multiset ι} {f : ι → α} :
(multiset.map (λ (i : ι), f i * a) s).sum = (multiset.map f s).sum * a
theorem multiset.dvd_sum {α : Type u_2} [semiring α] {a : α} {s : multiset α} :
(∀ (x : α), x sa x)a s.sum

Order #

theorem multiset.sum_nonneg {α : Type u_2} [ordered_add_comm_monoid α] {s : multiset α} :
(∀ (x : α), x s0 x)0 s.sum
theorem multiset.one_le_prod_of_one_le {α : Type u_2} [ordered_comm_monoid α] {s : multiset α} :
(∀ (x : α), x s1 x)1 s.prod
theorem multiset.single_le_prod {α : Type u_2} [ordered_comm_monoid α] {s : multiset α} :
(∀ (x : α), x s1 x)∀ (x : α), x sx s.prod
theorem multiset.single_le_sum {α : Type u_2} [ordered_add_comm_monoid α] {s : multiset α} :
(∀ (x : α), x s0 x)∀ (x : α), x sx s.sum
theorem multiset.prod_le_pow_card {α : Type u_2} [ordered_comm_monoid α] (s : multiset α) (n : α) (h : ∀ (x : α), x sx n) :
theorem multiset.sum_le_card_nsmul {α : Type u_2} [ordered_add_comm_monoid α] (s : multiset α) (n : α) (h : ∀ (x : α), x sx n) :
theorem multiset.all_one_of_le_one_le_of_prod_eq_one {α : Type u_2} [ordered_comm_monoid α] {s : multiset α} :
(∀ (x : α), x s1 x)s.prod = 1∀ (x : α), x sx = 1
theorem multiset.all_zero_of_le_zero_le_of_sum_eq_zero {α : Type u_2} [ordered_add_comm_monoid α] {s : multiset α} :
(∀ (x : α), x s0 x)s.sum = 0∀ (x : α), x sx = 0
theorem multiset.sum_le_sum_of_rel_le {α : Type u_2} [ordered_add_comm_monoid α] {s t : multiset α} (h : multiset.rel has_le.le s t) :
s.sum t.sum
theorem multiset.prod_le_prod_of_rel_le {α : Type u_2} [ordered_comm_monoid α] {s t : multiset α} (h : multiset.rel has_le.le s t) :
theorem multiset.prod_map_le_prod {α : Type u_2} [ordered_comm_monoid α] {s : multiset α} (f : α → α) (h : ∀ (x : α), x sf x x) :
theorem multiset.sum_map_le_sum {α : Type u_2} [ordered_add_comm_monoid α] {s : multiset α} (f : α → α) (h : ∀ (x : α), x sf x x) :
theorem multiset.sum_le_sum_sum {α : Type u_2} [ordered_add_comm_monoid α] {s : multiset α} (f : α → α) (h : ∀ (x : α), x sx f x) :
theorem multiset.prod_le_sum_prod {α : Type u_2} [ordered_comm_monoid α] {s : multiset α} (f : α → α) (h : ∀ (x : α), x sx f x) :
theorem multiset.card_nsmul_le_sum {α : Type u_2} [ordered_add_comm_monoid α] {s : multiset α} {a : α} (h : ∀ (x : α), x sa x) :
theorem multiset.pow_card_le_prod {α : Type u_2} [ordered_comm_monoid α] {s : multiset α} {a : α} (h : ∀ (x : α), x sa x) :
theorem multiset.prod_nonneg {α : Type u_2} [ordered_comm_semiring α] {m : multiset α} (h : ∀ (a : α), a m0 a) :
0 m.prod
theorem multiset.sum_eq_zero_iff {α : Type u_2} [canonically_ordered_add_monoid α] {m : multiset α} :
m.sum = 0 ∀ (x : α), x mx = 0
theorem multiset.prod_eq_one_iff {α : Type u_2} [canonically_ordered_monoid α] {m : multiset α} :
m.prod = 1 ∀ (x : α), x mx = 1
theorem multiset.prod_eq_one {α : Type u_2} [comm_monoid α] {m : multiset α} (h : ∀ (x : α), x mx = 1) :
m.prod = 1

Slightly more general version of multiset.prod_eq_one_iff for a non-ordered monoid

theorem multiset.sum_eq_zero {α : Type u_2} [add_comm_monoid α] {m : multiset α} (h : ∀ (x : α), x mx = 0) :
m.sum = 0

Slightly more general version of multiset.sum_eq_zero_iff for a non-ordered add_monoid

theorem multiset.le_sum_of_mem {α : Type u_2} [canonically_ordered_add_monoid α] {m : multiset α} {a : α} (h : a m) :
a m.sum
theorem multiset.le_prod_of_mem {α : Type u_2} [canonically_ordered_monoid α] {m : multiset α} {a : α} (h : a m) :
a m.prod
theorem multiset.le_sum_of_subadditive_on_pred {α : Type u_2} {β : Type u_3} [add_comm_monoid α] [ordered_add_comm_monoid β] (f : α → β) (p : α → Prop) (h_one : f 0 = 0) (hp_one : p 0) (h_mul : ∀ (a b : α), p ap bf (a + b) f a + f b) (hp_mul : ∀ (a b : α), p ap bp (a + b)) (s : multiset α) (hps : ∀ (a : α), a sp a) :
theorem multiset.le_prod_of_submultiplicative_on_pred {α : Type u_2} {β : Type u_3} [comm_monoid α] [ordered_comm_monoid β] (f : α → β) (p : α → Prop) (h_one : f 1 = 1) (hp_one : p 1) (h_mul : ∀ (a b : α), p ap bf (a * b) f a * f b) (hp_mul : ∀ (a b : α), p ap bp (a * b)) (s : multiset α) (hps : ∀ (a : α), a sp a) :
theorem multiset.le_prod_of_submultiplicative {α : Type u_2} {β : Type u_3} [comm_monoid α] [ordered_comm_monoid β] (f : α → β) (h_one : f 1 = 1) (h_mul : ∀ (a b : α), f (a * b) f a * f b) (s : multiset α) :
theorem multiset.le_sum_of_subadditive {α : Type u_2} {β : Type u_3} [add_comm_monoid α] [ordered_add_comm_monoid β] (f : α → β) (h_one : f 0 = 0) (h_mul : ∀ (a b : α), f (a + b) f a + f b) (s : multiset α) :
theorem multiset.le_prod_nonempty_of_submultiplicative_on_pred {α : Type u_2} {β : Type u_3} [comm_monoid α] [ordered_comm_monoid β] (f : α → β) (p : α → Prop) (h_mul : ∀ (a b : α), p ap bf (a * b) f a * f b) (hp_mul : ∀ (a b : α), p ap bp (a * b)) (s : multiset α) (hs_nonempty : s ) (hs : ∀ (a : α), a sp a) :
theorem multiset.le_sum_nonempty_of_subadditive_on_pred {α : Type u_2} {β : Type u_3} [add_comm_monoid α] [ordered_add_comm_monoid β] (f : α → β) (p : α → Prop) (h_mul : ∀ (a b : α), p ap bf (a + b) f a + f b) (hp_mul : ∀ (a b : α), p ap bp (a + b)) (s : multiset α) (hs_nonempty : s ) (hs : ∀ (a : α), a sp a) :
theorem multiset.le_sum_nonempty_of_subadditive {α : Type u_2} {β : Type u_3} [add_comm_monoid α] [ordered_add_comm_monoid β] (f : α → β) (h_mul : ∀ (a b : α), f (a + b) f a + f b) (s : multiset α) (hs_nonempty : s ) :
theorem multiset.le_prod_nonempty_of_submultiplicative {α : Type u_2} {β : Type u_3} [comm_monoid α] [ordered_comm_monoid β] (f : α → β) (h_mul : ∀ (a b : α), f (a * b) f a * f b) (s : multiset α) (hs_nonempty : s ) :
@[simp]
theorem multiset.sum_map_singleton {α : Type u_2} (s : multiset α) :
(multiset.map (λ (a : α), {a}) s).sum = s
theorem map_multiset_prod {α : Type u_2} {β : Type u_3} [comm_monoid α] [comm_monoid β] {F : Type u_1} [monoid_hom_class F α β] (f : F) (s : multiset α) :
theorem map_multiset_sum {α : Type u_2} {β : Type u_3} [add_comm_monoid α] [add_comm_monoid β] {F : Type u_1} [add_monoid_hom_class F α β] (f : F) (s : multiset α) :
@[protected]
theorem monoid_hom.map_multiset_prod {α : Type u_2} {β : Type u_3} [comm_monoid α] [comm_monoid β] (f : α →* β) (s : multiset α) :
@[protected]
theorem add_monoid_hom.map_multiset_sum {α : Type u_2} {β : Type u_3} [add_comm_monoid α] [add_comm_monoid β] (f : α →+ β) (s : multiset α) :