Documentation

Mathlib.Data.Nat.Choose.Multinomial

Multinomial #

This file defines the multinomial coefficients and several small lemmas for manipulating them.

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 ∈ s, f i)! / ∏ i ∈ 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 : α) :
    (∏ is, (f i).factorial) * multinomial s f = (∑ is, f i).factorial
    @[simp]
    theorem Nat.multinomial_empty {α : Type u_1} (f : α) :
    theorem Nat.multinomial_cons {α : Type u_1} {s : Finset α} {a : α} (ha : as) (f : α) :
    multinomial (Finset.cons a s ha) f = (f a + is, f i).choose (f a) * multinomial s f
    theorem Nat.multinomial_insert {α : Type u_1} {s : Finset α} {a : α} [DecidableEq α] (ha : as) (f : α) :
    multinomial (insert a s) f = (f a + is, f i).choose (f a) * 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) :
    theorem Nat.multinomial_congr_of_eq_on_inter {α : Type u_1} [DecidableEq α] {f g : α} {s t : Finset α} (hf : as \ t, f a = 0) (hg : at \ s, g a = 0) (hfg : as t, f a = g a) :
    theorem Nat.multinomial_congr_of_sdiff {α : Type u_1} [DecidableEq α] {f g : α} {s t : Finset α} (hst : s t) (hg : at \ s, g a = 0) (hfg : as, f a = g a) :
    theorem Nat.multinomial_single {α : Type u_1} (s : Finset α) (a : α) (n : ) [DecidableEq α] :

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

    Simple cases #

    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_update {α : Type u_1} (a : α) (f : α →₀ ) :
      f.multinomial = (f.sum fun (x : α) => id).choose (f a) * (f.update a 0).multinomial
      noncomputable def Multiset.countPerms {α : Type u_1} [DecidableEq α] (m : Multiset α) :

      The number of permutations of a given multiset.

      Equations
      Instances For
        @[deprecated Multiset.countPerms (since := "2025-03-13")]
        def Multiset.multinomial {α : Type u_1} [DecidableEq α] (m : Multiset α) :

        Alias of Multiset.countPerms.


        The number of permutations of a given multiset.

        Equations
        Instances For
          theorem Multiset.countPerms_filter_ne {α : Type u_1} [DecidableEq α] (a : α) (m : Multiset α) :
          m.countPerms = m.card.choose (count a m) * (filter (fun (x : α) => a x) m).countPerms
          @[deprecated Multiset.countPerms_filter_ne (since := "2025-03-13")]
          theorem Multiset.multinomial_filter_ne {α : Type u_1} [DecidableEq α] (a : α) (m : Multiset α) :
          m.countPerms = m.card.choose (count a m) * (filter (fun (x : α) => a x) m).countPerms

          Alias of Multiset.countPerms_filter_ne.

          @[simp]
          @[deprecated Multiset.countPerms_zero (since := "2025-03-13")]

          Alias of Multiset.countPerms_zero.

          Multinomial theorem #

          theorem Finset.sum_pow_eq_sum_piAntidiag_of_commute {α : Type u_1} {R : Type u_2} [DecidableEq α] [Semiring R] (s : Finset α) (f : αR) (hc : (↑s).Pairwise (Function.onFun Commute f)) (n : ) :
          (∑ is, f i) ^ n = ks.piAntidiag n, (Nat.multinomial s k) * s.noncommProd (fun (i : α) => f i ^ k i)

          The multinomial theorem.

          theorem Finset.sum_pow_of_commute {α : Type u_1} {R : Type u_2} [DecidableEq α] [Semiring R] (x : αR) (s : Finset α) (hc : (↑s).Pairwise (Function.onFun Commute x)) (n : ) :
          s.sum x ^ n = k : (s.sym n), (↑k).countPerms * (Multiset.map x k).noncommProd

          The multinomial theorem.

          theorem Finset.sum_pow_eq_sum_piAntidiag {α : Type u_1} {R : Type u_2} [DecidableEq α] [CommSemiring R] (s : Finset α) (f : αR) (n : ) :
          (∑ is, f i) ^ n = ks.piAntidiag n, (Nat.multinomial s k) * is, f i ^ k i
          theorem Finset.sum_pow {α : Type u_1} {R : Type u_2} [DecidableEq α] [CommSemiring R] {s : Finset α} (x : αR) (n : ) :
          s.sum x ^ n = ks.sym n, (↑k).countPerms * (Multiset.map x k).prod
          theorem Nat.multinomial_two_mul_le_mul_multinomial {ι : Type u_1} {s : Finset ι} {f : ι} :
          (multinomial s fun (i : ι) => 2 * f i) ((∑ is, f i) ^ is, f i) * multinomial s f
          theorem Sym.countPerms_coe_fill_of_notMem {n : } {α : Type u_1} [DecidableEq α] {m : Fin (n + 1)} {s : Sym α (n - m)} {x : α} (hx : xs) :
          (↑(fill x m s)).countPerms = n.choose m * (↑s).countPerms
          @[deprecated Sym.countPerms_coe_fill_of_notMem (since := "2025-03-13")]
          theorem Sym.multinomial_coe_fill_of_notMemal_filter_ne {n : } {α : Type u_1} [DecidableEq α] {m : Fin (n + 1)} {s : Sym α (n - m)} {x : α} (hx : xs) :
          (↑(fill x m s)).countPerms = n.choose m * (↑s).countPerms

          Alias of Sym.countPerms_coe_fill_of_notMem.