Documentation

Mathlib.Data.Nat.Choose.Sum

Sums of binomial coefficients #

This file includes variants of the binomial theorem and other results on sums of binomial coefficients. Theorems whose proofs depend on such sums may also go in this file for import reasons.

theorem Commute.add_pow {R : Type u_1} [Semiring R] {x : R} {y : R} (h : Commute x y) (n : ) :
(x + y) ^ n = Finset.sum (Finset.range (n + 1)) fun (m : ) => x ^ m * y ^ (n - m) * (Nat.choose n m)

A version of the binomial theorem for commuting elements in noncommutative semirings.

theorem Commute.add_pow' {R : Type u_1} [Semiring R] {x : R} {y : R} (h : Commute x y) (n : ) :
(x + y) ^ n = Finset.sum (Finset.antidiagonal n) fun (m : × ) => Nat.choose n m.1 (x ^ m.1 * y ^ m.2)

A version of Commute.add_pow that avoids ℕ-subtraction by summing over the antidiagonal and also with the binomial coefficient applied via scalar action of ℕ.

theorem add_pow {R : Type u_1} [CommSemiring R] (x : R) (y : R) (n : ) :
(x + y) ^ n = Finset.sum (Finset.range (n + 1)) fun (m : ) => x ^ m * y ^ (n - m) * (Nat.choose n m)

The binomial theorem

theorem Nat.sum_range_choose (n : ) :
(Finset.sum (Finset.range (n + 1)) fun (m : ) => Nat.choose n m) = 2 ^ n

The sum of entries in a row of Pascal's triangle

theorem Nat.sum_range_choose_halfway (m : ) :
(Finset.sum (Finset.range (m + 1)) fun (i : ) => Nat.choose (2 * m + 1) i) = 4 ^ m
theorem Nat.choose_middle_le_pow (n : ) :
Nat.choose (2 * n + 1) n 4 ^ n
theorem Nat.sum_Icc_choose (n : ) (k : ) :
(Finset.sum (Finset.Icc k n) fun (m : ) => Nat.choose m k) = Nat.choose (n + 1) (k + 1)

Zhu Shijie's identity aka hockey-stick identity.

theorem Int.alternating_sum_range_choose {n : } :
(Finset.sum (Finset.range (n + 1)) fun (m : ) => (-1) ^ m * (Nat.choose n m)) = if n = 0 then 1 else 0
theorem Int.alternating_sum_range_choose_of_ne {n : } (h0 : n 0) :
(Finset.sum (Finset.range (n + 1)) fun (m : ) => (-1) ^ m * (Nat.choose n m)) = 0
theorem Finset.sum_powerset_apply_card {α : Type u_2} {β : Type u_3} [AddCommMonoid α] (f : α) {x : Finset β} :
(Finset.sum (Finset.powerset x) fun (m : Finset β) => f m.card) = Finset.sum (Finset.range (x.card + 1)) fun (m : ) => Nat.choose x.card m f m
theorem Finset.sum_powerset_neg_one_pow_card {α : Type u_2} [DecidableEq α] {x : Finset α} :
(Finset.sum (Finset.powerset x) fun (m : Finset α) => (-1) ^ m.card) = if x = then 1 else 0
theorem Finset.sum_powerset_neg_one_pow_card_of_nonempty {α : Type u_2} {x : Finset α} (h0 : x.Nonempty) :
(Finset.sum (Finset.powerset x) fun (m : Finset α) => (-1) ^ m.card) = 0
theorem Finset.sum_choose_succ_nsmul {M : Type u_4} [AddCommMonoid M] (f : M) (n : ) :
(Finset.sum (Finset.range (n + 2)) fun (i : ) => Nat.choose (n + 1) i f i (n + 1 - i)) = (Finset.sum (Finset.range (n + 1)) fun (i : ) => Nat.choose n i f i (n + 1 - i)) + Finset.sum (Finset.range (n + 1)) fun (i : ) => Nat.choose n i f (i + 1) (n - i)
theorem Finset.prod_pow_choose_succ {M : Type u_4} [CommMonoid M] (f : M) (n : ) :
(Finset.prod (Finset.range (n + 2)) fun (i : ) => f i (n + 1 - i) ^ Nat.choose (n + 1) i) = (Finset.prod (Finset.range (n + 1)) fun (i : ) => f i (n + 1 - i) ^ Nat.choose n i) * Finset.prod (Finset.range (n + 1)) fun (i : ) => f (i + 1) (n - i) ^ Nat.choose n i
theorem Finset.sum_antidiagonal_choose_succ_nsmul {M : Type u_4} [AddCommMonoid M] (f : M) (n : ) :
(Finset.sum (Finset.antidiagonal (n + 1)) fun (ij : × ) => Nat.choose (n + 1) ij.1 f ij.1 ij.2) = (Finset.sum (Finset.antidiagonal n) fun (ij : × ) => Nat.choose n ij.1 f ij.1 (ij.2 + 1)) + Finset.sum (Finset.antidiagonal n) fun (ij : × ) => Nat.choose n ij.2 f (ij.1 + 1) ij.2
theorem Finset.prod_antidiagonal_pow_choose_succ {M : Type u_4} [CommMonoid M] (f : M) (n : ) :
(Finset.prod (Finset.antidiagonal (n + 1)) fun (ij : × ) => f ij.1 ij.2 ^ Nat.choose (n + 1) ij.1) = (Finset.prod (Finset.antidiagonal n) fun (ij : × ) => f ij.1 (ij.2 + 1) ^ Nat.choose n ij.1) * Finset.prod (Finset.antidiagonal n) fun (ij : × ) => f (ij.1 + 1) ij.2 ^ Nat.choose n ij.2
theorem Finset.sum_choose_succ_mul {R : Type u_3} [NonAssocSemiring R] (f : R) (n : ) :
(Finset.sum (Finset.range (n + 2)) fun (i : ) => (Nat.choose (n + 1) i) * f i (n + 1 - i)) = (Finset.sum (Finset.range (n + 1)) fun (i : ) => (Nat.choose n i) * f i (n + 1 - i)) + Finset.sum (Finset.range (n + 1)) fun (i : ) => (Nat.choose n i) * f (i + 1) (n - i)

The sum of (n+1).choose i * f i (n+1-i) can be split into two sums at rank n, respectively of n.choose i * f i (n+1-i) and n.choose i * f (i+1) (n-i).

theorem Finset.sum_antidiagonal_choose_succ_mul {R : Type u_3} [NonAssocSemiring R] (f : R) (n : ) :
(Finset.sum (Finset.antidiagonal (n + 1)) fun (ij : × ) => (Nat.choose (n + 1) ij.1) * f ij.1 ij.2) = (Finset.sum (Finset.antidiagonal n) fun (ij : × ) => (Nat.choose n ij.1) * f ij.1 (ij.2 + 1)) + Finset.sum (Finset.antidiagonal n) fun (ij : × ) => (Nat.choose n ij.2) * f (ij.1 + 1) ij.2

The sum along the antidiagonal of (n+1).choose i * f i j can be split into two sums along the antidiagonal at rank n, respectively of n.choose i * f i (j+1) and n.choose j * f (i+1) j.