The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V30. Combinatorics

Mathlib.Combinatorics.Enumerative.Bell

23 declarations. Mathlib docs · Source

Bell numbers for multisets

For n : ℕ, the nth Bell number is the number of partitions of a set of cardinality n. Here, we define a refinement of these numbers, that count, for any m : Multiset ℕ, the number of partitions of a set of cardinality m.sum whose parts have cardinalities given by m.

The definition presents it as a natural number.

  • Multiset.bell: number of partitions of a set whose parts have cardinalities a given multiset

  • Nat.uniformBell m n : short name for Multiset.bell (replicate m n)

  • Multiset.bell_mul_eq shows that m.bell * (m.map (fun j ↦ j !)).prod * Π j ∈ (m.toFinset.erase 0), (m.count j)! = m.sum !

  • Nat.uniformBell_mul_eq shows that uniformBell m n * n ! ^ m * m ! = (m * n) !

  • Nat.uniformBell_succ_left computes Nat.uniformBell (m + 1) n from Nat.uniformBell m n

  • Nat.bell n: the nth standard Bell number, which counts the number of partitions of a set of cardinality n

  • Nat.bell_succ n shows that Nat.bell (n + 1) = ∑ k ∈ Finset.range (n + 1), Nat.choose n k * Nat.bell (n - k)

TODO

Prove that it actually counts the number of partitions as indicated. (When m contains 0, the result requires to admit repetitions of the empty set as a part.)

theorem Nat.bell.match_1.congr_eq_1 E1 #

∀ (motive : ℕ → Sort u_1) (x : ℕ) (h_1 : Unit → motive 0) (h_2 : (n : ℕ) → motive n.succ),
  x = 0 →
    (match x with
      | 0 => h_1 ()
      | n.succ => h_2 n) ≍
      h_1 ()

theorem Nat.bell.match_1.congr_eq_2 E1 #

∀ (motive : ℕ → Sort u_1) (x : ℕ) (h_1 : Unit → motive 0) (h_2 : (n : ℕ) → motive n.succ) (n : ℕ),
  x = n.succ →
    (match x with
      | 0 => h_1 ()
      | n.succ => h_2 n) ≍
      h_2 n

def Multiset.bell E3 #

Multiset ℕ → ℕ

Number of partitions of a set of cardinality m.sum whose parts have cardinalities given by m

theorem Multiset.bell_zero E0 #

Multiset.bell 0 = 1

theorem Multiset.bell_mul_eq E0 #

∀ (m : Multiset ℕ),
  m.bell * (Multiset.map (fun j ↦ j.factorial) m).prod * ∏ j ∈ m.toFinset.erase 0, (Multiset.count j m).factorial =
    m.sum.factorial

theorem Multiset.bell_eq E0 #

∀ (m : Multiset ℕ),
  m.bell =
    m.sum.factorial /
      ((Multiset.map (fun j ↦ j.factorial) m).prod * ∏ j ∈ m.toFinset.erase 0, (Multiset.count j m).factorial)

def Nat.uniformBell E1 #

ℕ → ℕ → ℕ

Number of possibilities of dividing a set with m * n elements into m groups of n-element subsets.

theorem Nat.uniformBell_eq E0 #

∀ (m n : ℕ), m.uniformBell n = ∏ p ∈ Finset.range m, (p * n + n - 1).choose (n - 1)

theorem Nat.uniformBell_zero_left E1 #

∀ (n : ℕ), Nat.uniformBell 0 n = 1

theorem Nat.uniformBell_zero_right E1 #

∀ (m : ℕ), m.uniformBell 0 = 1

theorem Nat.uniformBell_succ_left E1 #

∀ (m n : ℕ), (m + 1).uniformBell n = (m * n + n - 1).choose (n - 1) * m.uniformBell n

theorem Nat.uniformBell_one_left E1 #

∀ (n : ℕ), Nat.uniformBell 1 n = 1

theorem Nat.uniformBell_one_right E1 #

∀ (m : ℕ), m.uniformBell 1 = 1

theorem Nat.uniformBell_mul_eq E0 #

∀ (m : ℕ) {n : ℕ}, n ≠ 0 → m.uniformBell n * n.factorial ^ m * m.factorial = (m * n).factorial

theorem Nat.uniformBell_eq_div E1 #

∀ (m : ℕ) {n : ℕ}, n ≠ 0 → m.uniformBell n = (m * n).factorial / (n.factorial ^ m * m.factorial)

def Nat.bell E1 #

ℕ → ℕ

The nth standard Bell number, which counts the number of partitions of a set of cardinality n.

theorem Nat.bell_succ E1 #

∀ (n : ℕ), (n + 1).bell = ∑ i ≤ n, n.choose i * (n - i).bell

theorem Nat.bell_succ' E1 #

∀ (n : ℕ), (n + 1).bell = ∑ ij ∈ Finset.HasAntidiagonal.antidiagonal n, n.choose ij.1 * ij.2.bell

theorem Nat.bell_zero E0 #

Nat.bell 0 = 1

theorem Nat.bell_one E0 #

Nat.bell 1 = 1

theorem Nat.bell_two E0 #

Nat.bell 2 = 2

theorem Nat.bell_eq_sum_erase E1 #

∀ {n : ℕ} (p : (n + 1).Partition), p.parts.bell = ∑ a ∈ p.parts.toFinset, n.choose (a - 1) * (p.parts.erase a).bell

theorem Nat.bell_eq_sum_partition E1 #

∀ (n : ℕ), n.bell = ∑ p, p.parts.bell

Nat.bell n is equal to the sum of Multiset.bell m over all multisets m : Multiset ℕ such that m.sum = n.