HepLean 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 = mFinset.range (n + 1), x ^ m * y ^ (n - m) * (n.choose 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 = mFinset.antidiagonal n, n.choose 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 = mFinset.range (n + 1), x ^ m * y ^ (n - m) * (n.choose m)

The binomial theorem

theorem sub_pow {R : Type u_1} [CommRing R] (x : R) (y : R) (n : ) :
(x - y) ^ n = mFinset.range (n + 1), (-1) ^ (m + n) * x ^ m * y ^ (n - m) * (n.choose m)

A special case of the binomial theorem

theorem Nat.sum_range_choose (n : ) :
mFinset.range (n + 1), n.choose m = 2 ^ n

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

theorem Nat.sum_range_choose_halfway (m : ) :
iFinset.range (m + 1), (2 * m + 1).choose i = 4 ^ m
theorem Nat.choose_middle_le_pow (n : ) :
(2 * n + 1).choose n 4 ^ n
theorem Nat.four_pow_le_two_mul_add_one_mul_central_binom (n : ) :
4 ^ n (2 * n + 1) * (2 * n).choose n
theorem Nat.sum_Icc_choose (n : ) (k : ) :
mFinset.Icc k n, m.choose k = (n + 1).choose (k + 1)

Zhu Shijie's identity aka hockey-stick identity, version with Icc.

theorem Nat.sum_range_add_choose (n : ) (k : ) :
iFinset.range (n + 1), (i + k).choose k = (n + k + 1).choose (k + 1)

Zhu Shijie's identity aka hockey-stick identity, version with range. Summing (i + k).choose k for i ∈ [0, n] gives (n + k + 1).choose (k + 1).

Combinatorial interpretation: (i + k).choose k is the number of decompositions of [0, i) in k + 1 (possibly empty) intervals (this follows from a stars and bars description). In particular, (n + k + 1).choose (k + 1) corresponds to decomposing [0, n) into k + 2 intervals. By putting away the last interval (of some length n - i), we have to decompose the remaining interval [0, i) into k + 1 intervals, hence the sum.

theorem Int.alternating_sum_range_choose {n : } :
mFinset.range (n + 1), (-1) ^ m * (n.choose m) = if n = 0 then 1 else 0
theorem Int.alternating_sum_range_choose_of_ne {n : } (h0 : n 0) :
mFinset.range (n + 1), (-1) ^ m * (n.choose m) = 0
theorem Finset.sum_powerset_apply_card {α : Type u_2} {β : Type u_3} [AddCommMonoid α] (f : α) {x : Finset β} :
mx.powerset, f m.card = mFinset.range (x.card + 1), x.card.choose m f m
theorem Finset.sum_powerset_neg_one_pow_card {α : Type u_2} [DecidableEq α] {x : Finset α} :
mx.powerset, (-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) :
mx.powerset, (-1) ^ m.card = 0
theorem Finset.sum_choose_succ_nsmul {M : Type u_2} [AddCommMonoid M] (f : M) (n : ) :
iFinset.range (n + 2), (n + 1).choose i f i (n + 1 - i) = iFinset.range (n + 1), n.choose i f i (n + 1 - i) + iFinset.range (n + 1), n.choose i f (i + 1) (n - i)
theorem Finset.prod_pow_choose_succ {M : Type u_2} [CommMonoid M] (f : M) (n : ) :
iFinset.range (n + 2), f i (n + 1 - i) ^ (n + 1).choose i = (∏ iFinset.range (n + 1), f i (n + 1 - i) ^ n.choose i) * iFinset.range (n + 1), f (i + 1) (n - i) ^ n.choose i
theorem Finset.sum_antidiagonal_choose_succ_nsmul {M : Type u_2} [AddCommMonoid M] (f : M) (n : ) :
ijFinset.antidiagonal (n + 1), (n + 1).choose ij.1 f ij.1 ij.2 = ijFinset.antidiagonal n, n.choose ij.1 f ij.1 (ij.2 + 1) + ijFinset.antidiagonal n, n.choose ij.2 f (ij.1 + 1) ij.2
theorem Finset.prod_antidiagonal_pow_choose_succ {M : Type u_2} [CommMonoid M] (f : M) (n : ) :
ijFinset.antidiagonal (n + 1), f ij.1 ij.2 ^ (n + 1).choose ij.1 = (∏ ijFinset.antidiagonal n, f ij.1 (ij.2 + 1) ^ n.choose ij.1) * ijFinset.antidiagonal n, f (ij.1 + 1) ij.2 ^ n.choose ij.2
theorem Finset.sum_choose_succ_mul {R : Type u_1} [NonAssocSemiring R] (f : R) (n : ) :
iFinset.range (n + 2), ((n + 1).choose i) * f i (n + 1 - i) = iFinset.range (n + 1), (n.choose i) * f i (n + 1 - i) + iFinset.range (n + 1), (n.choose 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_1} [NonAssocSemiring R] (f : R) (n : ) :
ijFinset.antidiagonal (n + 1), ((n + 1).choose ij.1) * f ij.1 ij.2 = ijFinset.antidiagonal n, (n.choose ij.1) * f ij.1 (ij.2 + 1) + ijFinset.antidiagonal n, (n.choose 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.

theorem Finset.sum_antidiagonal_choose_add (d : ) (n : ) :
ijFinset.antidiagonal n, (d + ij.2).choose d = (d + n).choose d + (d + n).choose (d + 1)