Coutig Well-Formed Parethesizatios Easily Pekka Kilpeläie Uiversity of Easter Filad School of Computig, Kuopio August 20, 2014 Abstract It is well kow that there is a oe-to-oe correspodece betwee ordered trees of + 1 odes, forests of odes, biary trees of odes, ad well-formed parethesizatios with opeig ad closig paretheses, which leads to the classic result that the umber of objects i each of these collectios is give by the th Catala umber C. The closed form of C is typically derived as a applicatio of geeratig fuctios. This ote presets a simple combiatorial argumet for the fact that the umber of well-formed parethesizatios of opeig ad 1 closig paretheses is 2 +1(. 1 Key words: Well-formed parethesizatio, Dyck word, Catala umber, coutig, Raey s lemma 1 Itroductio It is well kow that the th Catala umber C gives the umber of differet ordered trees of + 1 odes, forests of odes, biary trees of odes, ad well-formed parethesizatios with opeig ad closig paretheses. Catala umbers have surprisigly may additioal combiatorial iterpretatios. Staley metios about 70 of them i his book (1999. Together with a addedum published o his web site 2 the umber of combiatorial iterpretatios of C is 207. Koshy (2009, Chap. 5 provides a historical itroductio to Catala umbers. The closed form +1( 1 2 of the th Catala umber C is typically derived as follows (See, e.g., (Kuth, 1973, pp. 388-389 or (Graham et al., 1 The overall idea of this proof was give by late Derick Wood i persoal commuicatio at the Uiversity of Waterloo, Otario, i 1994. 2 www-math.mit.edu/ rsta/ec/ 1
1990, pp. 343-344: First a recurrece is derived for C, with C 0 = 1 1 C = C i C 1 i for 1. i=0 The a quadratic equatio is derived for a geeratig fuctio C(z whose coefficiets are C, ad solved as C(z = 1 1 4z 2z Usig the biomial theorem ad properties of biomial coefficiets the closed form of C(z ca be trasformed back to a power series, whose coefficiets fially give the result C = +1( 1 2. Geeratig fuctios are a powerful tool to solve combiatorial eumeratio problems; see (Graham et al., 1990, Chap. 7. Their drawback is that by maipulatig formal power series oe easily looses combiatorial ituitio of the objects that are beig studied. For this reaso we preset a simple combiatorial proof for the value of C. The argumet is based o placig well-formed parethesizatios i correspodece with strigs of paretheses which are straight-forward to cout. A strig of opeig paretheses ( ad closig paretheses is a well-formed parethesizatio (wfp if each of its opeig paretheses is matched by a uique closig parethesis that follows it, ad vice versa. The followig are the five well-formed parethesizatios with three opeig ad three closig paretheses: (((, (((, (((, (((, ad ((( Well-formed parethesizatios cosist of equally may opeig ad closig paretheses, but ot all such strigs are well-formed. I geeral, a strig of opeig ad closig paretheses ca be formed by choosig which out of the 2 available positios are occupied by a opeig parethesis, ad placig a closig parethesis at each of the remaiig positios (or vice versa. Thus the total umber of such strigs is ( 2. For example, there are ( 6 3 = 20 differet strigs that cosist of three opeig ad three closig paretheses. I additio to the above five of them which are well-formed parethesizatios, below are the remaiig 15 which are ot well-formed: (((, (((, (((, (((, (((, (((, (((, (((, (((, (((, (((, (((, (((, (((, (((. 2
Table 1: Correspodece btw Dyck-1 words of legth 7 ad strigs of 4 opeig ad 3 closig paretheses Dyck-1 Rotatios, or strigs with four ( ad three (((( ((((, ((((, ((((, ((((, ((((, ((((, (((( (((( ((((, ((((, ((((, ((((, ((((, ((((, (((( (((( ((((, ((((, ((((, ((((, ((((, ((((, (((( (((( ((((, ((((, ((((, ((((, ((((, ((((, (((( (((( ((((, ((((, ((((, ((((, ((((, ((((, (((( Our proof for the umber of well-formed parethesizatios is based o a correspodece betwee wfp s ad their rotatios. For a strig w which starts by a prefix α that is followed by the suffix β, the strigs w = αβ ad βα are rotatios (aka cyclic shifts of each other. Whe both α ad β are o-empty strigs, the strigs αβ ad βα are proper rotatios of each other. Oe complicatio for coutig wfp s i terms of their rotatios is that some wfp s have rotatios which are idetical. For example, ((( has oly two differet rotatios, which are ((( ad (((. Aother complicatio is that the rotatios of some wfp s coicide. For example, the wfp s ((( ad ((( have the followig commo set of rotatios: {(((, (((, (((, (((, (((, (((} Surprisigly these complicatios disappear whe we prefix the wfp s by a extra opeig parethesis. We call the resultig strigs Dyck-1 words. Let C be the umber of well-formed parethesizatios of legth 2. Clearly the umber of Dyck-1 words of legth 2+1 is also C. Let A be the set of strigs of + 1 opeig ad closig paretheses. The size of A is easily see to be ( 2+1. As we ll prove formally, the rotatios of Dyck-1 words partitio the set A i C equivalece classes each with 2 + 1 members. This yields for the th Catala umber its closed form ( 2 ( 2+1 C = 2 + 1 = + 1. For example, Table 1 gives the correspodece betwee the five Dyck-1 words of legth 7 ad the ( 7 3 = 35 strigs with four opeig ad three closig paretheses, which yields the umber 35/7 = 5 of wfp s of legth 6. 2 Proof Next we justify the details of the above claim. 3
All strigs that we cosider i this ote are over the alphabet {(, }. For a strig w we use d(w to deote the depth of strig w, which we defie as the differece betwee the umber of opeig paretheses ad the umber of closig paretheses that occur i w. For example, d(ε = d( ( = d( (( = 0, d( ( = 2, ad d( (( = 1. Notice that the depth of a strig is the sum of the depths of its subwords, that is, if w = uv the d(w = d(u + d(v. Well-formed parethesizatios ca be characterized as those strigs w which satisfy the coditios that d(w = 0 ad d(α 0 for each prefix α of w. They are also kow as Dyck words. Let us call well-formed parethesizatios which are prefixed by a extra opeig parethesis Dyck-1 words (or Dyck words of depth 1. That is, a strig w is a Dyck-1 word, or simply Dyck-1, iff d(w = 1 ad d(α 1 for every o-empty prefix α of w. We first prove two remarkable properties of rotatios of Dyck-1 words: Lemma 2.1 There are o Dyck-1 words amog the proper rotatios of a Dyck-1 word. Proof. Let w = αβ be a Dyck-1 word ad u = βα its proper rotatio. Sice w is Dyck-1, we have d(w = 1 ad d(α 1. Sice d(u = d(β + d(α = d(w, we have that d(β 0. This meas that u caot be Dyck-1. A cosequece of Lemma 2.1 is that a Dyck-1 word of legth 2 + 1 has 2 + 1 differet rotatios: Lemma 2.2 All rotatios of a Dyck-1 word are differet. Proof. Let w = a 1 a 2 a m be a Dyck-1 word of symbols a 1, a 2,..., a m {(, }. Let r i deote its ith rotatio a i a i+1 a m a 1 a 2 a i 1, where 1 i m. Assume for the cotrary that w has two rotatios r i ad r j with 1 i < j m which are idetical. The also a 1 a i 1 = a j i+1 a j 1. This meas that w equals its proper rotatio r j i+1, which is accordig to Lemma 2.1 ot possible. The two lemmas above imply the ext result, which says that rotatios partitio the set A i C equivalece classes of equal cardiality: Lemma 2.3 Every strig of A has 2 + 1 differet rotatios, out of which exactly oe is a Dyck-1 word. Proof. Let w A. It suffices to show that w has a rotatio w which is a Dyck-1 word. Because rotatios of this w are also rotatios of w, Lemma 2.1 gives that o other of them is Dyck-1, ad Lemma 2.2 gives that all 2 + 1 of them are differet. If w is a Dyck-1 word, there is othig further to prove. Otherwise let u be a o-empty prefix of w such that d(u is miimal; if there are 4
several such prefixes, we take u to be the logest of them. Let v be the correspodig suffix of w, that is, w = uv. Sice d(w = 1, strig w must fail the Dyck-1 coditio by d(u < 1. Now w = vu is a rotatio of w with d(w = 1, which satisfies also the other Dyck-1 coditio that each of its o-empty prefixes has a positive depth: First, let α be a o-empty prefix of w which is also a prefix of v. Sice u was chose to be the logest of the miimal-depth prefixes of w ad uα is a loger prefix of w, we have that d(uα = d(u + d(α d(u + 1, which gives that d(α 1. Secod, let α be a prefix of w which cotais also some characters of u, that is, α = vu for some o-empty prefix u of u. Sice u is a miimal-depth prefix of w, we have d(u d(u ad thus d(α = d(vu = d(v + d(u d(v + d(u = 1. Sice there are C differet Dyck-1 words of legth 2 + 1, we have the followig corollary: Corollary 2.4 The set A cosists of C equivalece classes uder rotatio, ad each of them has 2 + 1 members. Accordig to the Corollary A = (2 + 1C, ad thus C = A 2 + 1 ( 2+1 3 Cocludig remarks = 2 + 1 (2 + 12 ( + 2 = (2 + 1! 2(2 1 ( + 1 =!( + 1 = 1 ( 2 + 1 Our argumet is closely related to a lemma which states that a sequece of itegers which add up to +1 has exactly oe rotatio such that all of its partial sums of are positive. Graham, Kuth ad Patashik (1990, p. 345 attribute this result to Raey (1960. Ideed, this Raey s Lemma ca be proved by the same argumet as Lemmas 2.3 ad 2.1, simply by iterpretig d(w as sum of a subsequece istead of depth of a sub-word. Graham, Kuth ad Patashik (1990, p. 346 give for Raey s Lemma a geometric proof, which is debatably more ivolved tha our simple combiatorial argumet. 5
Refereces Graham, R. L., Kuth, D. E., ad Patashik, O. (1990. Cocrete Mathematics. Addiso-Wesley. Kuth, D. E. (1973. The Art of Computer Programmig, Volume 1: Fudametal Algorithms. Addiso-Wesley, 2d editio. Koshy, T. (2009. Catala Numbers with Applicatios. Oxford Uiversity Press. Raey, G. N. (1960. Fuctioal compositio patters ad power series reversio. Trasactios of the AMS, 94:441 451. Staley, R. P. (1999. Eumerative Combiatorics, Volume 2. Cambridge Uiversity Press. 6