Documentation

CslibFrontier.Foundations.Data.Finset.OffDiag

Products of sums over the off-diagonal #

The product of two finite sums over the same index set is the sum of the products at equal indices plus the sum of the products over the ordered pairs of distinct indices (Finset.sum_mul_sum_eq_sum_mul_add_sum_offDiag); in particular the square of a finite sum is the sum of the squares plus the sum over the off-diagonal (Finset.sq_sum_eq_sum_sq_add_sum_offDiag). This is how second and fourth moments of sums of pairwise or four-wise independent terms are computed.

Main results #

theorem Finset.sum_mul_sum_eq_sum_mul_add_sum_offDiag {α : Type u_1} {R : Type u_2} [CommSemiring R] (s : Finset α) (f g : α → R) :
(∑ x ∈ s, f x) * ∑ x ∈ s, g x = ∑ x ∈ s, f x * g x + ∑ p ∈ s.offDiag, f p.1 * g p.2

The product of two finite sums over the same index set is the sum of the products at equal indices plus the products over the ordered pairs of distinct indices.

theorem Finset.sq_sum_eq_sum_sq_add_sum_offDiag {α : Type u_1} {R : Type u_2} [CommSemiring R] (s : Finset α) (g : α → R) :
(∑ x ∈ s, g x) ^ 2 = ∑ x ∈ s, g x ^ 2 + ∑ p ∈ s.offDiag, g p.1 * g p.2

The square of a finite sum is the sum of the squares plus the products over the ordered pairs of distinct indices.