Documentation

Mathlib.Data.Nat.Choose.Multinomial

Multinomial #

This file defines the multinomial coefficient and several small lemma's for manipulating it.

Main declarations #

Main results #

def Nat.multinomial {α : Type u_1} (s : Finset α) (f : α) :

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)!.

Equations
Instances For
    theorem Nat.multinomial_pos {α : Type u_1} (s : Finset α) (f : α) :
    theorem Nat.multinomial_spec {α : Type u_1} (s : Finset α) (f : α) :
    (Finset.prod s fun (i : α) => Nat.factorial (f i)) * Nat.multinomial s f = Nat.factorial (Finset.sum s fun (i : α) => f i)
    @[simp]
    theorem Nat.multinomial_nil {α : Type u_1} (f : α) :
    theorem Nat.multinomial_cons {α : Type u_1} {s : Finset α} {a : α} (ha : as) (f : α) :
    Nat.multinomial (Finset.cons a s ha) f = Nat.choose (f a + Finset.sum s fun (i : α) => f i) (f a) * Nat.multinomial s f
    theorem Nat.multinomial_insert {α : Type u_1} {s : Finset α} {a : α} [DecidableEq α] (ha : as) (f : α) :
    Nat.multinomial (insert a s) f = Nat.choose (f a + Finset.sum s fun (i : α) => f i) (f a) * Nat.multinomial s f
    @[simp]
    theorem Nat.multinomial_singleton {α : Type u_1} (a : α) (f : α) :
    @[simp]
    theorem Nat.multinomial_insert_one {α : Type u_1} {s : Finset α} {f : α} {a : α} [DecidableEq α] (h : as) (h₁ : f a = 1) :
    theorem Nat.multinomial_congr {α : Type u_1} {s : Finset α} {f : α} {g : α} (h : as, f a = g a) :

    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 {α : Type u_1} {f : α} {a : α} {b : α} [DecidableEq α] (h : a b) :
    Nat.multinomial {a, b} f = Nat.factorial (f a + f b) / (Nat.factorial (f a) * Nat.factorial (f b))
    theorem Nat.binomial_eq_choose {α : Type u_1} {f : α} {a : α} {b : α} [DecidableEq α] (h : a b) :
    Nat.multinomial {a, b} f = Nat.choose (f a + f b) (f a)
    theorem Nat.binomial_spec {α : Type u_1} {f : α} {a : α} {b : α} [DecidableEq α] (hab : a b) :
    @[simp]
    theorem Nat.binomial_one {α : Type u_1} {f : α} {a : α} {b : α} [DecidableEq α] (h : a b) (h₁ : f a = 1) :
    Nat.multinomial {a, b} f = Nat.succ (f b)
    theorem Nat.binomial_succ_succ {α : Type u_1} {f : α} {a : α} {b : α} [DecidableEq α] (h : a b) :
    theorem Nat.succ_mul_binomial {α : Type u_1} {f : α} {a : α} {b : α} [DecidableEq α] (h : a b) :
    Nat.succ (f a + f b) * Nat.multinomial {a, b} f = Nat.succ (f a) * Nat.multinomial {a, b} (Function.update f a (Nat.succ (f a)))

    Simple cases #

    theorem Nat.multinomial_univ_two (a : ) (b : ) :
    Nat.multinomial Finset.univ ![a, b] = Nat.factorial (a + b) / (Nat.factorial a * Nat.factorial b)
    theorem Nat.multinomial_univ_three (a : ) (b : ) (c : ) :
    Nat.multinomial Finset.univ ![a, b, c] = Nat.factorial (a + b + c) / (Nat.factorial a * Nat.factorial b * Nat.factorial c)

    Alternative definitions #

    def Finsupp.multinomial {α : Type u_1} (f : α →₀ ) :

    Alternative multinomial definition based on a finsupp, using the support for the big operations

    Equations
    Instances For
      theorem Finsupp.multinomial_eq {α : Type u_1} (f : α →₀ ) :
      theorem Finsupp.multinomial_update {α : Type u_1} (a : α) (f : α →₀ ) :
      def Multiset.multinomial {α : Type u_1} [DecidableEq α] (m : Multiset α) :

      Alternative definition of multinomial based on Multiset delegating to the finsupp definition

      Equations
      Instances For
        theorem Multiset.multinomial_filter_ne {α : Type u_1} [DecidableEq α] (a : α) (m : Multiset α) :
        Multiset.multinomial m = Nat.choose (Multiset.card m) (Multiset.count a m) * Multiset.multinomial (Multiset.filter (fun (x : α) => a x) m)

        Multinomial theorem #

        theorem Finset.sum_pow_of_commute {α : Type u_1} [DecidableEq α] (s : Finset α) {R : Type u_2} [Semiring R] (x : αR) (hc : Set.Pairwise s fun (i j : α) => Commute (x i) (x j)) (n : ) :
        Finset.sum s x ^ n = Finset.sum Finset.univ fun (k : { x : Sym α n // x Finset.sym s n }) => (Multiset.multinomial k) * Multiset.noncommProd (Multiset.map x k) (_ : Set.Pairwise {b : R | b Multiset.map x k} Commute)

        The multinomial theorem

        Proof is by induction on the number of summands.

        theorem Finset.sum_pow {α : Type u_1} [DecidableEq α] (s : Finset α) {R : Type u_2} [CommSemiring R] (x : αR) (n : ) :
        Finset.sum s x ^ n = Finset.sum (Finset.sym s n) fun (k : Sym α n) => (Multiset.multinomial k) * Multiset.prod (Multiset.map x k)