Binomial coefficients #
This file defines binomial coefficients and proves simple lemmas (i.e. those not
requiring more imports).
For the lemma that n.choose k counts the k-element-subsets of an n-element set,
see Fintype.card_powersetCard in Mathlib/Data/Finset/Powerset.lean.
Main definition and results #
- Nat.choose: binomial coefficients, defined inductively
- Nat.choose_eq_factorial_div_factorial: a proof that- choose n k = n! / (k! * (n - k)!)
- Nat.choose_symm: symmetry of binomial coefficients
- Nat.choose_le_succ_of_lt_half_left:- choose n kis increasing for small values of- k
- Nat.choose_le_middle:- choose n ris maximised when- ris- n/2
- Nat.descFactorial_eq_factorial_mul_choose: Relates binomial coefficients to the descending factorial. This is used to prove- Nat.choose_le_powand variants. We provide similar statements for the ascending factorial.
- Nat.multichoose: whereas- choosecounts combinations,- multichoosecounts multicombinations. The fact that this is indeed the correct counting function for multisets is proved in- Sym.card_sym_eq_multichoosein- Data.Sym.Card.
- Nat.multichoose_eq: a proof that- multichoose 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 size- kover an alphabet of size- nto counting strings of- kelements ("stars") separated by- n-1dividers ("bars"). See- Data.Sym.Cardfor 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. For the fact that this is the number of k-element-subsets of an n-element
set, see Fintype.card_powersetCard.
Instances For
A faster implementation of choose, to be used during bytecode evaluation
and in compiled code.
Equations
- n.fast_choose k = n.descFactorial k / k.factorial
Instances For
Inequalities #
Show that Nat.choose is increasing for small values of the right argument.
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.
https://github.com/leanprover-community/mathlib/pull/15072#issuecomment-1171415738
multichoose n k is the number of multisets of cardinality k from a type of cardinality n.
Equations
- x✝.multichoose 0 = 1
- Nat.multichoose 0 n.succ = 0
- n.succ.multichoose k.succ = n.multichoose (k + 1) + (n + 1).multichoose k