Documentation

Mathlib.Combinatorics.Enumerative.Catalan

Catalan numbers #

The Catalan numbers (http://oeis.org/A000108) are probably the most ubiquitous sequence of integers in mathematics. They enumerate several important objects like binary trees, Dyck paths, and triangulations of convex polygons.

Main definitions #

Main results #

Implementation details #

The proof of catalan_eq_centralBinom_div follows https://math.stackexchange.com/questions/3304415

TODO #

@[irreducible]
def catalan :

The recursive definition of the sequence of Catalan numbers: catalan (n + 1) = ∑ i : Fin n.succ, catalan i * catalan (n - i)

Equations
Instances For
    @[simp]
    theorem catalan_zero :
    theorem catalan_succ (n : ) :
    catalan (n + 1) = i : Fin n.succ, catalan i * catalan (n - i)
    theorem catalan_succ' (n : ) :
    catalan (n + 1) = ijFinset.antidiagonal n, catalan ij.1 * catalan ij.2
    @[simp]
    theorem catalan_one :
    theorem catalan_eq_centralBinom_div (n : ) :
    catalan n = n.centralBinom / (n + 1)
    theorem succ_mul_catalan_eq_centralBinom (n : ) :
    (n + 1) * catalan n = n.centralBinom
    @[reducible, inline]

    Given two finsets, find all trees that can be formed with left child in a and right child in b

    Equations
    Instances For
      @[irreducible]

      A Finset of all trees with n nodes. See mem_treesOfNodesEq

      Equations
      Instances For
        @[simp]
        theorem Tree.mem_treesOfNumNodesEq {x : Tree Unit} {n : } :
        x Tree.treesOfNumNodesEq n x.numNodes = n
        @[simp]
        theorem Tree.coe_treesOfNumNodesEq (n : ) :
        (Tree.treesOfNumNodesEq n) = {x : Tree Unit | x.numNodes = n}