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 #
catalan n
: then
th Catalan number, defined recursively ascatalan (n + 1) = ∑ i : Fin n.succ, catalan i * catalan (n - i)
.
Main results #
-
catalan_eq_centralBinom_div
: The explicit formula for the Catalan number using the central binomial coefficient,catalan n = Nat.centralBinom n / (n + 1)
. -
treesOfNodesEq_card_eq_catalan
: The number of binary trees withn
internal nodes iscatalan n
Implementation details #
The proof of catalan_eq_centralBinom_div
follows https://math.stackexchange.com/questions/3304415
TODO #
- Prove that the Catalan numbers enumerate many interesting objects.
- Provide the many variants of Catalan numbers, e.g. associated to complex reflection groups, Fuss-Catalan, etc.
@[reducible]
Given two finsets, find all trees that can be formed with
left child in a
and right child in b
Equations
- Tree.pairwiseNode a b = Finset.map { toFun := fun (x : Tree Unit × Tree Unit) => Tree.node () x.1 x.2, inj' := Tree.pairwiseNode.proof_1 } (a ×ˢ b)
Instances For
A Finset of all trees with n
nodes. See mem_treesOfNodesEq
Equations
- One or more equations did not get rendered due to their size.
- Tree.treesOfNumNodesEq 0 = {Tree.nil}
Instances For
theorem
Tree.treesOfNumNodesEq_succ
(n : ℕ)
:
Tree.treesOfNumNodesEq (n + 1) = Finset.biUnion (Finset.antidiagonal n) fun (ij : ℕ × ℕ) =>
Tree.pairwiseNode (Tree.treesOfNumNodesEq ij.1) (Tree.treesOfNumNodesEq ij.2)
@[simp]
theorem
Tree.mem_treesOfNumNodesEq
{x : Tree Unit}
{n : ℕ}
:
x ∈ Tree.treesOfNumNodesEq n ↔ Tree.numNodes x = n
@[simp]
theorem
Tree.coe_treesOfNumNodesEq
(n : ℕ)
:
↑(Tree.treesOfNumNodesEq n) = {x : Tree Unit | Tree.numNodes x = n}