Binomial coefficients #
This file defines binomial coefficients and proves simple lemmas (i.e. those not requiring more imports).
Main definition and results #
Nat.choose
: binomial coefficients, defined inductivelyNat.choose_eq_factorial_div_factorial
: a proof thatchoose n k = n! / (k! * (n - k)!)
Nat.choose_symm
: symmetry of binomial coefficientsNat.choose_le_succ_of_lt_half_left
:choose n k
is increasing for small values ofk
Nat.choose_le_middle
:choose n r
is maximised whenr
isn/2
Nat.descFactorial_eq_factorial_mul_choose
: Relates binomial coefficients to the descending factorial. This is used to proveNat.choose_le_pow
and variants. We provide similar statements for the ascending factorial.Nat.multichoose
: whereaschoose
counts combinations,multichoose
counts multicombinations. The fact that this is indeed the correct counting function for multisets is proved inSym.card_sym_eq_multichoose
inData.Sym.Card
.Nat.multichoose_eq
: a proof thatmultichoose n k = (n + k - 1).choose k
. This is central to the "stars and bars" technique in informal mathematics, where we switch between counting multisets of sizek
over an alphabet of sizen
to counting strings ofk
elements ("stars") separated byn-1
dividers ("bars"). SeeData.Sym.Card
for more detail.
Tags #
binomial coefficient, combination, multicombination, stars and bars
choose n k
is the number of k
-element subsets in an n
-element set. Also known as binomial
coefficients.
Equations
- Nat.choose x 0 = 1
- Nat.choose 0 (Nat.succ n) = 0
- Nat.choose (Nat.succ n) (Nat.succ k) = Nat.choose n k + Nat.choose n (k + 1)
Instances For
choose n 2
is the n
-th triangle number.
A faster implementation of choose
, to be used during bytecode evaluation
and in compiled code.
Equations
- Nat.fast_choose n k = Nat.descFactorial n k / Nat.factorial k
Instances For
Inequalities #
Show that Nat.choose
is increasing for small values of the right argument.
choose n r
is maximised when r
is n/2
.
Inequalities about increasing the first argument #
Multichoose #
Whereas choose n k
is the number of subsets of cardinality k
from a type of cardinality n
,
multichoose n k
is the number of multisets of cardinality k
from a type of cardinality n
.
Alternatively, whereas choose n k
counts the number of combinations,
i.e. ways to select k
items (up to permutation) from n
items without replacement,
multichoose n k
counts the number of multicombinations,
i.e. ways to select k
items (up to permutation) from n
items with replacement.
Note that multichoose
is not the multinomial coefficient, although it can be computed
in terms of multinomial coefficients. For details see https://mathworld.wolfram.com/Multichoose.html
TODO: Prove that choose (-n) k = (-1)^k * multichoose n k
,
where choose
is the generalized binomial coefficient.
multichoose n k
is the number of multisets of cardinality k
from a type of cardinality n
.
Equations
- Nat.multichoose x 0 = 1
- Nat.multichoose 0 (Nat.succ n) = 0
- Nat.multichoose (Nat.succ n) (Nat.succ k) = Nat.multichoose n (k + 1) + Nat.multichoose (n + 1) k