Scarpazza - Notes On The Catalan Problem - Slides 2004-03-16
Scarpazza - Notes On The Catalan Problem - Slides 2004-03-16
• they were first described in the 18th century by Leonhard Euler (working
on polygon triangulation);
Balanced: same number of open and close parentheses, and every prefix
of the string has at least as many open parentheses as close parentheses;
n C(n)
0 empty string 1
1 () 1
2 ()() (()) 2
0 a 1
1 a·b 1
2 (a · b) · c a · (b · c) 2
3 ((a · b) · c) · d (a · b) · (c · d) 5
(a · (b · c)) · d a · ((b · c) · d)
a · (b · (c · d))
4 (((a · b) · c) · d) · e ((a · b) · c) · (d · e) 14
((a · b) · (c · d)) · e (a · b) · ((c · d) · e)
(a · b) · (c · (d · e)) ((a · (b · c)) · d) · e
(a · (b · c)) · (d · e) (a · ((b · c) · d)) · e
(a · (b · (c · d))) · e a · (((b · c) · d) · e)
a · ((b · c) · (d · e)) a · ((b · (c · d)) · e)
a · (b · ((c · d) · e)) a · (b · (c · (d · e)))
Daniele Paolo Scarpazza Notes on the Catalan problem [7]
“Determine the number of ways in which a convex polygon with n+2 edges
can be triangulated.”
Daniele Paolo Scarpazza Notes on the Catalan problem [8]
“Determine the number of plane trees with n edges.” A plane tree is such
that it is possible to draw it on a plane with no edges crossing each other.
Daniele Paolo Scarpazza Notes on the Catalan problem [11]
(A)B
C1 = C0C0
C2 = C0C1 + C1C0
C3 = C0C2 + C1C1 + C2C0
C4 = C0C3 + C1C2 + C2C1 + C3C0
... = ...
n−1
X
C0 = 1, C1 = 1, Cn = CiCn−1−i
i=0
Daniele Paolo Scarpazza Notes on the Catalan problem [16]
We will now solve the above recurrences with the use of generating functions.
+∞
X
C(x) = C0 + C1 · x + C2 · x2 + ... = Ci · xi
i=0
still a generating function with Catalan coefficients, shifted one position left:
+∞
X
[C(x)]2 = C1 + C2x + C3x2 = Ci+1xi .
i=0
Daniele Paolo Scarpazza Notes on the Catalan problem [17]
Therefore if we multiply the whole series by x and add C0, the original Catalan
series is obtained:
C(x) = C0 + x[C(x)]2.
A quadratic equation, which could be put into the more familiar form:
xC 2 − C + C0 = 0,
√
1± 1 − 4x
C= .
2x
Daniele Paolo Scarpazza Notes on the Catalan problem [18]
√
1− 1 − 4x
C= . (1)
2x
√ X 1/2
1 − 4x = (1 − 4x)1/2 = (−4x)n,
n
n≥0
Daniele Paolo Scarpazza Notes on the Catalan problem [19]
1/2 (1/2)(−1/2)
(1 − 4x)1/2 = 1 − 4x + (4x)2 +
1 2·1
(1/2)(−1/2)(−3/2)
+ (4x)3 +
3·2·1
(1/2)(−1/2)(−3/2)(−5/2)
+ (4x)4 + ...
4·3·2·1
1 1 3·1 3 5·3·1
(1 − 4x)1/2 = 1 − 2x + 4x2 − 8x + 16x4 + ...
1! 2! 3! 4!
Daniele Paolo Scarpazza Notes on the Catalan problem [20]
22 · 2! = 4 · 2
23 · 3! = 6 · 4 · 2
24 · 4! = 8 · 6 · 4 · 2
... = ...
Yn
2n · n! = 2i
i=1
Daniele Paolo Scarpazza Notes on the Catalan problem [21]
Consequently:
1 2! 1 4! 2 1 6! 2
C(x) = 1 + ( )x + ( )x + ( )x =
2 1!1! 3 2!2! 4 3!3!
+∞
X 1 2i i
= z
i=0
1 + i i
1 2i
Ci = .
1+i i
Daniele Paolo Scarpazza Notes on the Catalan problem [22]
2n 2n 2n n 2n 1 2n
Cn = − = − = .
n n+1 n n+1 n n+1 n
Daniele Paolo Scarpazza Notes on the Catalan problem [25]
A novel interpretation
A novel calculation of the Catalan numbers, inspired by formal language
considerations.
Language of balanced parentheses (Van Dyck language).
G = (Σ, N, S, R)
Σ = {(, )}
N = {S}
R = {r1, r2}
r1 : S→ε
r2 : S → (S)S
Daniele Paolo Scarpazza Notes on the Catalan problem [26]
r1* (n-1,t)
(n,t)
H
HH
H
HH
r 2
HH
j
(n+1,t+2)
Daniele Paolo Scarpazza Notes on the Catalan problem [28]
(n+1,t) HH
Y
HH1r
HH
(n,t)
H
H
(n-1,t-2) r
2
Daniele Paolo Scarpazza Notes on the Catalan problem [29]
• (n, t) forms with n > t do not exist, apart from the axiom (1, 0). (Proof: by
induction. For each form (n, t), be δ = t − n. The axiom has δ = −1, both
rules increment δ.)
Each derivation tree starts with a label corresponding to a string, (0, 2i),
and reaches leaf nodes which are either axioms or invalid nodes.
Daniele Paolo Scarpazza Notes on the Catalan problem [31]
Examples follow; axioms are marked with “!”, invalid nodes with “×”.
(0,2)
(1,2)
(2,2)
(1,0) !
(0,4)
(1,4)
(2,4)
((((`````
((((((((( ```
(
(1,2) (3,4)
XXXXX
XX
(2,2)
b
(2,2)
b
(4,4)
H
bb bb HH
H
The count of axiom nodes in each derivation tree, is the ith Catalan
Daniele Paolo Scarpazza Notes on the Catalan problem [34]
number.
By construction,
Ci = R(0, 2i).
The above relation R was implemented in Tcl function and tested for
correctness.
Daniele Paolo Scarpazza Notes on the Catalan problem [35]
t/n 0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 1 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2 1 1 1 0 0 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4 2 2 2 1 0 0 0 0 0 0 0 0 0 0
5 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6 5 5 5 3 1 0 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8 14 14 14 9 4 1 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10 42 42 42 28 14 5 1 0 0 0 0 0 0 0
11 0 0 0 0 0 0 0 0 0 0 0 0 0 0
12 132 132 132 90 48 20 6 1 0 0 0 0 0 0
13 0 0 0 0 0 0 0 0 0 0 0 0 0 0
14 429 429 429 297 165 75 27 7 1 0 0 0 0 0
15 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16 1430 1430 1430 1001 572 275 110 35 8 1 0 0 0 0
17 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18 4862 4862 4862 3432 2002 1001 429 154 44 9 1 0 0 0
19 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20 16796 16796 16796 11934 7072 3640 1638 637 208 54 10 1 0 0
21 0 0 0 0 0 0 0 0 0 0 0 0 0 0
22 58786 58786 58786 41990 25194 13260 6188 2548 910 273 65 11 1 0
23 0 0 0 0 0 0 0 0 0 0 0 0 0 0
24 208012 208012 208012 149226 90440 48450 23256 9996 3808 1260 350 77 12 1
Daniele Paolo Scarpazza Notes on the Catalan problem [36]
Plot of the surface R(n, t). Points with odd values of t were not plotted.
Daniele Paolo Scarpazza Notes on the Catalan problem [37]
Plot of the surface log R(n, t). Points with odd values of t were not plotted.
Daniele Paolo Scarpazza Notes on the Catalan problem [38]
Future Developments
where · denotes P
string concatenation. w can be extended on languages, by
defining w(L) = α∈L w(α). Therefore
∗
X X
|α|
X X X 1
w(A ) = w(α) = x = 1 xn = n n
m x = .
1 − mx
α∈A∗ α∈A∗ n≥0 |α|=n n≥0
w(D) = 1 + x2w(D)2
Daniele Paolo Scarpazza Notes on the Catalan problem [40]
_
_ _/ \
_ _ / \/ \
/ \/ \/ \_
H = (Σ0, N, B, R0)
Σ0 = {(, ), S}
N = {B}
R = {r1, r2, r3}
r1 : B→ε
r2 : B → SB
r3 : B → (B)B
B → ε | SB | (B)B,
E = {ε} + SE + (E)E.
p
1 − yz − 1 − 2yz + y 2z 2 − 4x2z 2
e= 2 2
.
2x z
Ei,j,k :
e(x, y, z) = E0,0,0 +
+ E1,0,0x + E0,1,0y + E0,0,1z +
+ E2,0,0x2 + E0,2,0y 2 + E0,0,2z 2 + E1,1,0xy + E0,1,1yz + E1,0,1xz +
+ ...
It is now evident that the number of sentential forms with n nonterminals and
t terminals, previously called R(n, t) is given by :
in particular
[xiy j z k ]e(x, y, z) = Ei,j,k .
Furthermore, an expression of e(x, y, 1) can be obtained by restriction:
p
1 − y − 1 − 2y + y 2 − 4x2
e(x, y, 1) = e(x, y, z)|z=1 = .
2x2
Incidentally, the i-th Catalan number, which was equal to R(0, 2i) can be
obtained by setting y = 0, thus:
Daniele Paolo Scarpazza Notes on the Catalan problem [47]
√
1− 1 − 4x2
e(x, 0, 1) = e(x, y, 1)|y=0 = ,
2x2
which is identical to a previous equation and admits the same solutions.
To obtain an expression of R(i, j), we can collect (1 − y) in the numerator
and (1 − y)2 in the denominator, thus obtaining:
q
x2
1 − 1 − 4
p
1−y (1−y) 2 1 1 − 1 − 4q 2
e= 2x2
= x ,
(1 − y)2 2
1 − y 2q 2
q=
(1−y) 1−y
but since
p
1− 1 − 4q 2 X
k
D(q) = = Dk q
2q 2
k≥0
then
1 X xk X xk
e= Dk k
= Dk
1−y (1 − y) (1 − y)k+1
k≥0 k≥0
X X n + k
= Dk xk yn
k
k≥0 n≥0
X n + k
= Dk xk y n
k
n,k≥0
Daniele Paolo Scarpazza Notes on the Catalan problem [49]
Our current efforts are devoted to finding a new correct and unambiguous
grammar for language E, obtaining an appropriate recursive definition of E
and a corresponding equation for w(E), which, solved, would yield a formal
power series for w(E), thus, a closed form for R(n, t) numbers.