Documentation

Mathlib.Algebra.BigOperators.Ring.Finset

Results about big operators with values in a (semi)ring #

We prove results about big operators that involve some interaction between multiplicative and additive structures on the values being combined.

theorem Finset.prod_neg {ฮน : Type u_1} {M : Type u_3} {s : Finset ฮน} [CommMonoid M] [HasDistribNeg M] (f : ฮน โ†’ M) :
โˆ x โˆˆ s, -f x = (-1) ^ s.card * โˆ x โˆˆ s, f x
theorem Finset.natCast_card_filter {ฮน : Type u_1} {R : Type u_4} [AddCommMonoidWithOne R] (p : ฮน โ†’ Prop) [DecidablePred p] (s : Finset ฮน) :
โ†‘{x โˆˆ s | p x}.card = โˆ‘ a โˆˆ s, if p a then 1 else 0
@[simp]
theorem Finset.sum_boole {ฮน : Type u_1} {R : Type u_4} [AddCommMonoidWithOne R] (p : ฮน โ†’ Prop) [DecidablePred p] (s : Finset ฮน) :
(โˆ‘ x โˆˆ s, if p x then 1 else 0) = โ†‘{x โˆˆ s | p x}.card
theorem Finset.sum_mul {ฮน : Type u_1} {R : Type u_4} [NonUnitalNonAssocSemiring R] (s : Finset ฮน) (f : ฮน โ†’ R) (a : R) :
(โˆ‘ i โˆˆ s, f i) * a = โˆ‘ i โˆˆ s, f i * a
theorem Finset.mul_sum {ฮน : Type u_1} {R : Type u_4} [NonUnitalNonAssocSemiring R] (s : Finset ฮน) (f : ฮน โ†’ R) (a : R) :
a * โˆ‘ i โˆˆ s, f i = โˆ‘ i โˆˆ s, a * f i
theorem Finset.sum_mul_sum {ฮน : Type u_1} {ฮบ : Type u_2} {R : Type u_4} [NonUnitalNonAssocSemiring R] (s : Finset ฮน) (t : Finset ฮบ) (f : ฮน โ†’ R) (g : ฮบ โ†’ R) :
(โˆ‘ i โˆˆ s, f i) * โˆ‘ j โˆˆ t, g j = โˆ‘ i โˆˆ s, โˆ‘ j โˆˆ t, f i * g j
theorem Fintype.sum_mul_sum {ฮน : Type u_1} {ฮบ : Type u_2} {R : Type u_4} [NonUnitalNonAssocSemiring R] [Fintype ฮน] [Fintype ฮบ] (f : ฮน โ†’ R) (g : ฮบ โ†’ R) :
(โˆ‘ i : ฮน, f i) * โˆ‘ j : ฮบ, g j = โˆ‘ i : ฮน, โˆ‘ j : ฮบ, f i * g j
theorem Commute.sum_right {ฮน : Type u_1} {R : Type u_4} [NonUnitalNonAssocSemiring R] (s : Finset ฮน) (f : ฮน โ†’ R) (b : R) (h : โˆ€ i โˆˆ s, Commute b (f i)) :
Commute b (โˆ‘ i โˆˆ s, f i)
theorem Commute.sum_left {ฮน : Type u_1} {R : Type u_4} [NonUnitalNonAssocSemiring R] (s : Finset ฮน) (f : ฮน โ†’ R) (b : R) (h : โˆ€ i โˆˆ s, Commute (f i) b) :
Commute (โˆ‘ i โˆˆ s, f i) b
theorem Finset.sum_range_succ_mul_sum_range_succ {R : Type u_4} [NonUnitalNonAssocSemiring R] (m n : โ„•) (f g : โ„• โ†’ R) :
(โˆ‘ i โˆˆ range (m + 1), f i) * โˆ‘ i โˆˆ range (n + 1), g i = (โˆ‘ i โˆˆ range m, f i) * โˆ‘ i โˆˆ range n, g i + f m * โˆ‘ i โˆˆ range n, g i + (โˆ‘ i โˆˆ range m, f i) * g n + f m * g n
theorem Finset.dvd_sum {ฮน : Type u_1} {R : Type u_4} {s : Finset ฮน} [NonUnitalSemiring R] {f : ฮน โ†’ R} {a : R} (h : โˆ€ i โˆˆ s, a โˆฃ f i) :
a โˆฃ โˆ‘ i โˆˆ s, f i
theorem Finset.sum_mul_boole {ฮน : Type u_1} {R : Type u_4} [NonAssocSemiring R] [DecidableEq ฮน] (s : Finset ฮน) (f : ฮน โ†’ R) (i : ฮน) :
(โˆ‘ j โˆˆ s, f j * if i = j then 1 else 0) = if i โˆˆ s then f i else 0
theorem Finset.sum_boole_mul {ฮน : Type u_1} {R : Type u_4} [NonAssocSemiring R] [DecidableEq ฮน] (s : Finset ฮน) (f : ฮน โ†’ R) (i : ฮน) :
โˆ‘ j โˆˆ s, (if i = j then 1 else 0) * f j = if i โˆˆ s then f i else 0
theorem Finset.prod_add_prod_eq {ฮน : Type u_1} {R : Type u_4} [CommSemiring R] {s : Finset ฮน} {i : ฮน} {f g h : ฮน โ†’ R} (hi : i โˆˆ s) (h1 : g i + h i = f i) (h2 : โˆ€ j โˆˆ s, j โ‰  i โ†’ g j = f j) (h3 : โˆ€ j โˆˆ s, j โ‰  i โ†’ h j = f j) :
โˆ i โˆˆ s, g i + โˆ i โˆˆ s, h i = โˆ i โˆˆ s, f i

If f = g = h everywhere but at i, where f i = g i + h i, then the product of f over s is the sum of the products of g and h.

theorem Finset.prod_sum {ฮน : Type u_1} {R : Type u_4} [CommSemiring R] [DecidableEq ฮน] {ฮบ : ฮน โ†’ Type u_5} (s : Finset ฮน) (t : (i : ฮน) โ†’ Finset (ฮบ i)) (f : (i : ฮน) โ†’ ฮบ i โ†’ R) :
โˆ a โˆˆ s, โˆ‘ b โˆˆ t a, f a b = โˆ‘ p โˆˆ s.pi t, โˆ x โˆˆ s.attach, f (โ†‘x) (p โ†‘x โ‹ฏ)

The product over a sum can be written as a sum over the product of sets, Finset.Pi. Finset.prod_univ_sum is an alternative statement when the product is over univ.

theorem Finset.prod_univ_sum {ฮน : Type u_1} {R : Type u_4} [CommSemiring R] [DecidableEq ฮน] {ฮบ : ฮน โ†’ Type u_5} [Fintype ฮน] (t : (i : ฮน) โ†’ Finset (ฮบ i)) (f : (i : ฮน) โ†’ ฮบ i โ†’ R) :
โˆ i : ฮน, โˆ‘ j โˆˆ t i, f i j = โˆ‘ x โˆˆ Fintype.piFinset t, โˆ i : ฮน, f i (x i)

The product over univ of a sum can be written as a sum over the product of sets, Fintype.piFinset. Finset.prod_sum is an alternative statement when the product is not over univ.

theorem Finset.sum_prod_piFinset {ฮน : Type u_1} {ฮบ : Type u_2} {R : Type u_4} [CommSemiring R] [DecidableEq ฮน] [Fintype ฮน] (s : Finset ฮบ) (g : ฮน โ†’ ฮบ โ†’ R) :
โˆ‘ f โˆˆ Fintype.piFinset fun (x : ฮน) => s, โˆ i : ฮน, g i (f i) = โˆ i : ฮน, โˆ‘ j โˆˆ s, g i j
theorem Finset.sum_pow' {ฮบ : Type u_2} {R : Type u_4} [CommSemiring R] (s : Finset ฮบ) (f : ฮบ โ†’ R) (n : โ„•) :
(โˆ‘ a โˆˆ s, f a) ^ n = โˆ‘ p โˆˆ Fintype.piFinset fun (_i : Fin n) => s, โˆ i : Fin n, f (p i)
theorem Finset.prod_add {ฮน : Type u_1} {R : Type u_4} [CommSemiring R] [DecidableEq ฮน] (f g : ฮน โ†’ R) (s : Finset ฮน) :
โˆ i โˆˆ s, (f i + g i) = โˆ‘ t โˆˆ s.powerset, (โˆ i โˆˆ t, f i) * โˆ i โˆˆ s \ t, g i

The product of f a + g a over all of s is the sum over the powerset of s of the product of f over a subset t times the product of g over the complement of t

theorem Finset.prod_one_add {ฮน : Type u_1} {R : Type u_4} [CommSemiring R] {f : ฮน โ†’ R} (s : Finset ฮน) :
โˆ i โˆˆ s, (1 + f i) = โˆ‘ t โˆˆ s.powerset, โˆ i โˆˆ t, f i
theorem Finset.prod_add_one {ฮน : Type u_1} {R : Type u_4} [CommSemiring R] {f : ฮน โ†’ R} (s : Finset ฮน) :
โˆ i โˆˆ s, (f i + 1) = โˆ‘ t โˆˆ s.powerset, โˆ i โˆˆ t, f i
theorem Finset.prod_add_ordered {ฮน : Type u_1} {R : Type u_4} [CommSemiring R] [LinearOrder ฮน] (s : Finset ฮน) (f g : ฮน โ†’ R) :
โˆ i โˆˆ s, (f i + g i) = โˆ i โˆˆ s, f i + โˆ‘ i โˆˆ s, (g i * โˆ j โˆˆ s with j < i, (f j + g j)) * โˆ j โˆˆ s with i < j, f j

โˆ i, (f i + g i) = (โˆ i, f i) + โˆ‘ i, g i * (โˆ j < i, f j + g j) * (โˆ j > i, f j).

theorem Finset.prod_one_add_ordered {ฮน : Type u_1} {R : Type u_4} [CommSemiring R] [LinearOrder ฮน] (s : Finset ฮน) (f : ฮน โ†’ R) :
โˆ i โˆˆ s, (1 + f i) = 1 + โˆ‘ i โˆˆ s, f i * โˆ j โˆˆ s with j < i, (1 + f j)
theorem Finset.sum_pow_mul_eq_add_pow {ฮน : Type u_1} {R : Type u_4} [CommSemiring R] (a b : R) (s : Finset ฮน) :
โˆ‘ t โˆˆ s.powerset, a ^ t.card * b ^ (s.card - t.card) = (a + b) ^ s.card

Summing a ^ #t * b ^ (n - #t) over all finite subsets t of a finset s gives (a + b) ^ #s.

theorem Fintype.sum_pow_mul_eq_add_pow {R : Type u_4} [CommSemiring R] (ฮน : Type u_5) [Fintype ฮน] (a b : R) :
โˆ‘ s : Finset ฮน, a ^ s.card * b ^ (card ฮน - s.card) = (a + b) ^ card ฮน

Summing a^#s * b^(n-#s) over all finite subsets s of a fintype of cardinality n gives (a + b)^n. The "good" proof involves expanding along all coordinates using the fact that x^n is multilinear, but multilinear maps are only available now over rings, so we give instead a proof reducing to the usual binomial theorem to have a result over semirings.

theorem Finset.prod_natCast {ฮน : Type u_1} {R : Type u_4} [CommSemiring R] (s : Finset ฮน) (f : ฮน โ†’ โ„•) :
โ†‘(โˆ i โˆˆ s, f i) = โˆ i โˆˆ s, โ†‘(f i)
theorem Finset.prod_sub {ฮน : Type u_1} {R : Type u_4} [CommRing R] [DecidableEq ฮน] (f g : ฮน โ†’ R) (s : Finset ฮน) :
โˆ i โˆˆ s, (f i - g i) = โˆ‘ t โˆˆ s.powerset, ((-1) ^ t.card * โˆ i โˆˆ s \ t, f i) * โˆ i โˆˆ t, g i

The product of f i - g i over all of s is the sum over the powerset of s of the product of g over a subset t times the product of f over the complement of t times (-1) ^ #t.

theorem Finset.prod_sub_ordered {ฮน : Type u_1} {R : Type u_4} [CommRing R] [LinearOrder ฮน] (s : Finset ฮน) (f g : ฮน โ†’ R) :
โˆ i โˆˆ s, (f i - g i) = โˆ i โˆˆ s, f i - โˆ‘ i โˆˆ s, (g i * โˆ j โˆˆ s with j < i, (f j - g j)) * โˆ j โˆˆ s with i < j, f j

โˆ i, (f i - g i) = (โˆ i, f i) - โˆ‘ i, g i * (โˆ j < i, f j - g j) * (โˆ j > i, f j).

theorem Finset.prod_one_sub_ordered {ฮน : Type u_1} {R : Type u_4} [CommRing R] [LinearOrder ฮน] (s : Finset ฮน) (f : ฮน โ†’ R) :
โˆ i โˆˆ s, (1 - f i) = 1 - โˆ‘ i โˆˆ s, f i * โˆ j โˆˆ s with j < i, (1 - f j)

โˆ i, (1 - f i) = 1 - โˆ‘ i, f i * (โˆ j < i, 1 - f j). This formula is useful in construction of a partition of unity from a collection of โ€œbumpโ€ functions.

theorem Finset.prod_range_natCast_sub {R : Type u_4} [CommRing R] (n k : โ„•) :
โˆ i โˆˆ range k, (โ†‘n - โ†‘i) = โ†‘(โˆ i โˆˆ range k, (n - i))
theorem Fintype.sum_pow {ฮน : Type u_5} {R : Type u_7} [Fintype ฮน] [CommSemiring R] (f : ฮน โ†’ R) (n : โ„•) :
(โˆ‘ a : ฮน, f a) ^ n = โˆ‘ p : Fin n โ†’ ฮน, โˆ i : Fin n, f (p i)
theorem Fintype.prod_sum {ฮน : Type u_5} {R : Type u_7} [Fintype ฮน] [CommSemiring R] [DecidableEq ฮน] {ฮบ : ฮน โ†’ Type u_8} [(i : ฮน) โ†’ Fintype (ฮบ i)] (f : (i : ฮน) โ†’ ฮบ i โ†’ R) :
โˆ i : ฮน, โˆ‘ j : ฮบ i, f i j = โˆ‘ x : (i : ฮน) โ†’ ฮบ i, โˆ i : ฮน, f i (x i)

A product of sums can be written as a sum of products.

theorem Fintype.prod_add {ฮน : Type u_5} {R : Type u_7} [Fintype ฮน] [CommSemiring R] [DecidableEq ฮน] (f g : ฮน โ†’ R) :
โˆ a : ฮน, (f a + g a) = โˆ‘ t : Finset ฮน, (โˆ a โˆˆ t, f a) * โˆ a โˆˆ tแถœ, g a
theorem Nat.sum_div {ฮน : Type u_5} {s : Finset ฮน} {f : ฮน โ†’ โ„•} {n : โ„•} (hf : โˆ€ i โˆˆ s, n โˆฃ f i) :
(โˆ‘ i โˆˆ s, f i) / n = โˆ‘ i โˆˆ s, f i / n
@[simp]
theorem Nat.cast_list_prod {R : Type u_4} [Semiring R] (s : List โ„•) :
โ†‘s.prod = (List.map Nat.cast s).prod
@[simp]
theorem Nat.cast_sum {R : Type u_4} {ฮน : Type u_5} [AddCommMonoidWithOne R] (s : Finset ฮน) (f : ฮน โ†’ โ„•) :
โ†‘(โˆ‘ x โˆˆ s, f x) = โˆ‘ x โˆˆ s, โ†‘(f x)
@[simp]
theorem Nat.cast_prod {R : Type u_4} {ฮน : Type u_5} [CommSemiring R] (f : ฮน โ†’ โ„•) (s : Finset ฮน) :
โ†‘(โˆ i โˆˆ s, f i) = โˆ i โˆˆ s, โ†‘(f i)
theorem Int.sum_div {ฮน : Type u_5} {s : Finset ฮน} {f : ฮน โ†’ โ„ค} {n : โ„ค} (hf : โˆ€ i โˆˆ s, n โˆฃ f i) :
(โˆ‘ i โˆˆ s, f i) / n = โˆ‘ i โˆˆ s, f i / n
@[simp]
theorem Int.cast_list_prod {R : Type u_4} [Ring R] (s : List โ„ค) :
โ†‘s.prod = (List.map Int.cast s).prod
@[simp]
theorem Int.cast_sum {R : Type u_4} {ฮน : Type u_5} [AddCommGroupWithOne R] (s : Finset ฮน) (f : ฮน โ†’ โ„ค) :
โ†‘(โˆ‘ x โˆˆ s, f x) = โˆ‘ x โˆˆ s, โ†‘(f x)
@[simp]
theorem Int.cast_prod {ฮน : Type u_5} {R : Type u_6} [CommRing R] (f : ฮน โ†’ โ„ค) (s : Finset ฮน) :
โ†‘(โˆ i โˆˆ s, f i) = โˆ i โˆˆ s, โ†‘(f i)