Multinomial #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file defines the multinomial coefficient and several small lemma's for manipulating it.
Main declarations #
nat.multinomial
: the multinomial coefficient
Main results #
finest.sum_pow
: The expansion of(s.sum x) ^ n
using multinomial coefficients
The multinomial coefficient. Gives the number of strings consisting of symbols
from s
, where c ∈ s
appears with multiplicity f c
.
Defined as (∑ i in s, f i)! / ∏ i in s, (f i)!
.
@[simp]
@[simp]
theorem
nat.multinomial_insert_one
{α : Type u_1}
(s : finset α)
(f : α → ℕ)
{a : α}
[decidable_eq α]
(h : a ∉ s)
(h₁ : f a = 1) :
nat.multinomial (has_insert.insert a s) f = (s.sum f).succ * nat.multinomial s f
theorem
nat.multinomial_insert
{α : Type u_1}
(s : finset α)
(f : α → ℕ)
{a : α}
[decidable_eq α]
(h : a ∉ s) :
nat.multinomial (has_insert.insert a s) f = (f a + s.sum f).choose (f a) * nat.multinomial s f
theorem
nat.multinomial_congr
{α : Type u_1}
(s : finset α)
{f g : α → ℕ}
(h : ∀ (a : α), a ∈ s → f a = g a) :
nat.multinomial s f = nat.multinomial s g
Connection to binomial coefficients #
When nat.multinomial
is applied to a finset
of two elements {a, b}
, the
result a binomial coefficient. We use binomial
in the names of lemmas that
involves nat.multinomial {a, b}
.
theorem
nat.binomial_eq_choose
{α : Type u_1}
(f : α → ℕ)
{a b : α}
[decidable_eq α]
(h : a ≠ b) :
nat.multinomial {a, b} f = (f a + f b).choose (f a)
@[simp]
theorem
nat.binomial_one
{α : Type u_1}
(f : α → ℕ)
{a b : α}
[decidable_eq α]
(h : a ≠ b)
(h₁ : f a = 1) :
nat.multinomial {a, b} f = (f b).succ
theorem
nat.binomial_succ_succ
{α : Type u_1}
(f : α → ℕ)
{a b : α}
[decidable_eq α]
(h : a ≠ b) :
nat.multinomial {a, b} (function.update (function.update f a (f a).succ) b (f b).succ) = nat.multinomial {a, b} (function.update f a (f a).succ) + nat.multinomial {a, b} (function.update f b (f b).succ)
theorem
nat.succ_mul_binomial
{α : Type u_1}
(f : α → ℕ)
{a b : α}
[decidable_eq α]
(h : a ≠ b) :
(f a + f b).succ * nat.multinomial {a, b} f = (f a).succ * nat.multinomial {a, b} (function.update f a (f a).succ)
Simple cases #
theorem
nat.multinomial_univ_two
(a b : ℕ) :
nat.multinomial finset.univ ![a, b] = (a + b).factorial / (a.factorial * b.factorial)
Alternative definitions #
theorem
finsupp.multinomial_eq
{α : Type u_1}
(f : α →₀ ℕ) :
f.multinomial = nat.multinomial f.support ⇑f
theorem
finsupp.multinomial_update
{α : Type u_1}
(a : α)
(f : α →₀ ℕ) :
f.multinomial = (f.sum (λ (_x : α), id)).choose (⇑f a) * (f.update a 0).multinomial
Alternative definition of multinomial based on multiset
delegating to the
finsupp definition
Equations
theorem
multiset.multinomial_filter_ne
{α : Type u_1}
[decidable_eq α]
(a : α)
(m : multiset α) :
m.multinomial = (⇑multiset.card m).choose (multiset.count a m) * (multiset.filter (ne a) m).multinomial
Multinomial theorem #
theorem
finset.sum_pow_of_commute
{α : Type u_1}
[decidable_eq α]
(s : finset α)
{R : Type u_2}
[semiring R]
(x : α → R)
(hc : ↑s.pairwise (λ (i j : α), commute (x i) (x j)))
(n : ℕ) :
s.sum x ^ n = finset.univ.sum (λ (k : ↥(s.sym n)), ↑(k.val.val.multinomial) * (multiset.map x k.val.val).noncomm_prod _)
The multinomial theorem
Proof is by induction on the number of summands.
theorem
finset.sum_pow
{α : Type u_1}
[decidable_eq α]
(s : finset α)
{R : Type u_2}
[comm_semiring R]
(x : α → R)
(n : ℕ) :