The (Ordinary) Generating Functions Enumerating 123-Avoiding Words with r occurrences of each of 1,2, ..., n are Always Algebraic
aa r X i v : . [ m a t h . C O ] N ov The (Ordinary) Generating Functions Enumerating 123-Avoiding Words with r occurrencesof each of 1,2, ..., n are Always Algebraic
Nathaniel SHAR and Doron ZEILBERGER
Abstract : The set of 123-avoiding permutations (alias words in { , ..., n } with exactly 1 occur-rence of each letter) is famously enumerated by the ubiquitous Catalan numbers, whose generatingfunction C ( x ) famously satisfies the algebraic equation C ( x ) = 1 + xC ( x ) . Recently, Bill Chen,Alvin Dai, and Robin Zhou found (and very elegantly proved) an algebraic equation satisfied by thegenerating function enumerating 123-avoiding words with two occurrences of each of { , . . . , n } . In-spired by the Chen-Dai-Zhou result, we present an algorithm for finding such an algebraic equationfor the ordinary generating function enumerating 123-avoiding words with exactly r occurrencesof each of { , . . . , n } for any positive integer r , thereby proving that they are algebraic , and notmerely D -finite (a fact that is promised by WZ theory). Our algorithm consists of presenting an algebraic enumeration scheme , combined with the Buchberger algorithm. Introduction
Recall that a word w = w . . . w n in an ordered alphabet contains a pattern σ (a certain permutationof { , ..., k } ) if there exist 1 ≤ i < i < . . . < i k ≤ n such that the subword w i . . . w i k is order isomorphic to σ ; in other words w i , . . . , w i k are distinct,and if you replace the smallest entry by 1, the second smallest entry by 2, etc., you would get σ .For example, the word mathisfun contains the pattern 132, since (inter alia) the subword hsn isorder-isomorphic to 132 (under the usual lexicographic order).A word w avoids the pattern σ if it does not contain it. One is interested in enumerating words, ofa given length and given alphabet-size, avoiding one or more patterns.In a remarkable PhD thesis, under the guidance of guru Herbert S. Wilf, Alexander Burstein ([Bu])initiated the study of forbidden patterns (alias Wilf classes ) in words , extending the very active andfruitful research on forbidden patterns in permutations initiated by Donald Knuth, Rodica Simion,Richard Stanley, Herbert Wilf, and others. For the current state of the art of the latter, see [Wiki].Burstein’s pioneering thesis was extended by quite a few people, and the current knowledge isdescribed in the lucid and insightful research monographs [HM] and [Ki]. A systematic approachfor computer-assisted enumeration of words avoiding a given set of patterns, extending the work ofZeilberger and Vatter for permutations (see [Z4] and its references), was initiated by Lara Pudwell([P]). Some of the recent work (e.g. [GGHP]) is phrased in the equivalent language of ordered setpartitions . This equivalence is cleverly used in Anisse Kasraoui’s ([Ka]) recent article.Most of this work concerns the set of all words avoiding a pattern. In a very interesting recentpaper [GGHP], the authors consider (in the equivalent language of ordered set partitions), amongother problems, the problem of enumerating 123-avoiding words of length 2 n where each of the n { , , . . . , n } occurs exactly twice, and conjectured a certain second-order linear recurrenceequation with polynomial coefficients. They apparently did not realize that, in their case, it waspossible to justify it by a (fully rigorous, or at least rigorizable) hand-waving argument. By general‘holonomic nonsense’ ([Z1]) it is known beforehand that there is some such linear recurrence, andit is possible to bound the order, thereby justifying, a posteriori , the guessed recurrence, providedthat it is checked for sufficiently many initial values. A more direct proof was given by Chen, Dai,and Zhou ([CDZ]), who proved the stronger statement that the generating function is algebraic ,and even found the defining equation explicitly: 1 − (2 x + 1) F + x ( x + 4) F = 0 .Using Comtet’s algorithm ([Co], see also [S]) for deducing, out of the algebraic equation, a lineardifferential equation for the generating function, and hence a linear recurrence for the sequenceitself, Chen, Dai and Zhou proved the [GGHP] conjecture directly.In the present article we will generalize this and prove that, for every positive integer r , theordinary generating function enumerating 123-avoiding words of length rn where each of the n letters of { , , . . . , n } occurs exactly r times, is algebraic, and present an algorithm for findingthe defining equation. Alas, since at the end it uses the memory-heavy, and exponential time,Buchberger’s algorithm for finding Gr¨obner bases, our computer (running Maple) only agreed toexplicitly find the next-in-line, the analogous equation for r = 3:(4 x + 1) + (cid:0) x + 48 x − (cid:1) F − x (cid:0) x + 108 x + 27 (cid:1) F − x (32 x + 27) F + x (32 x + 27) F = 0 . This took less than a second, but the case r = 4 took about an hour. Here is the minimal algebraicequation satisfied by the generating function, let’s call it F , whose coefficient of x n is the numberof 123-avoiding words with 4 n letters with 4 occurrences of each i (1 ≤ i ≤ n ): x (5 x − (4 x + 1) F +4 x (85 x + 58) (5 x − (4 x + 1) F +2 x (cid:0) x + 11845 x + 8658 x + 6503 x + 256 (cid:1) (5 x − (4 x + 1) F +4 x (5 x − x + 1) (cid:0) x − x + 15739435 x + 9911721 x + 2082455 x + 138496 (cid:1) F + x (60000 x + 2772000 x − x + 11351360680 x + 15348867846 x +7091445146 x + 1387805641 x + 96468480 x − F +4 x (cid:0) x − x + 28100475 x + 187145995 x + 58215739 x − x − x − (cid:1) F +(10000 x + 628250 x − x + 1098116930 x + 827342646 x +223797652 x + 24970546 x + 842512 x + 1024) F + (cid:0) x − x − x − x − x + 461716 x + 49271 x − (cid:1) F + x ( x + 1) (cid:0) x + 65 x + 11 (cid:1) = 0 . We didn’t even try the case r = 5. 2owever, since we know, once again (now even without using Zeilberger’s holonomic theory) thatthe generating function is D -finite, since it has the stronger property of being algebraic, it justifies rigorously guessing a linear recurrence equation with polynomial coefficients, which enables one tocompute, in linear time , any term of the enumerating sequence. We succeeded, using our algorithm,to be described below (which in particular enables a very fast enumeration of many terms of theenumerating sequences), in discovering such recurrences for 1 ≤ r ≤
5, and using [Z2] we (or ratherour beloved servant, Shalosh B. Ekhad, running Maple) found precise asymptotics for these cases.This enables us to formulate the following intriguing conjecture, and the second-named author (DZ)is pledging a $100 donation to the OEIS foundation, in honor of the first prover.
Conjecture : Let w r ( n ) be the number of 123-avoiding words of length rn with r occurrences ofeach of { , . . . , n } . Then lim n →∞ w r ( n ) w r ( n −
1) = ( r + 1) 2 r . More strongly, w r ( n ) is asymptotically C r · (( r + 1)2 r ) n · n − / , where C r is a ‘nice’ constant(probably √ π times the square-root of a rational number that depends ‘nicely’ on r ).Using the Maple package Words123 accompanying this article, we proved it for r ≤ C r in terms of r from the five data points).Speaking of the OEIS, currently only the cases r = 1 (of course!) and r = 2 ([OEIS], sequenceA220097) are there. We hope to remedy this soon, and enter, at least, w r ( n ) for 3 ≤ r ≤ r = 3, although it they are not in OEIS, the first ten terms are already in cyberspace (moreprecisely, in Lara Pudwell’s website). Some Crucial Background and Zeilberger’s Beautiful Snappy Proof that 123-AvoidingWords are Equinumerous with 132-Avoiding Words
Burstein [B] proved that the number of all words in a given (ordered) alphabet of a given length n avoiding 123 is the same as the number of words avoiding 132, and hence, via trivial symmetry, allpatterns of length 3 have the same enumeration. The stronger result that this is still true if onespecifies the number of occurrences of each letter was first proved in [AAAHH], but the proof fromthe book appeared in the half-page gem , [Z3]. Since this lovely proof deserves to be better known,we reproduce it here. Define a mapping F on a word w in the alphabet { , , . . . , n } recursively as follows. If w is empty,then F ( w ) := w . Otherwise, i := w , and let W be the word obtained from w by first beheading it,and then replacing all letters larger than i + 1 by i + 1 , and let s be the sub-sequence of w obtainedby deleting the letters ≤ i . Let ¯ s be the reverse of s . Let V := F ( W ) , and let U be the wordobtained from V by replacing (in order) the letters that are i + 1 by the members of ¯ s . Finally let F ( w ) := iU . F is an involution that sends 123-avoiding words to 132-avoiding ones, and vice versa. This followsfrom the fact that s above is non-increasing and non-decreasing respectively. Hence, for any vector f non-negative integers ( a , . . . , a n ) amongst the ( a + . . . + a n )! / ( a ! · · · a n !) words with a ’s, . . . , a n n ’s, the number of those that avoid the pattern equals the number of those that avoid ,It also follows that we have a quick recurrence that enables us to compute the number of such words,which we will call A ( a , . . . , a n ) : A ( a , . . . , a n ) = n X i =1 A ( a , . . . , a i − , a i − , a i +1 + . . . + a n ) . Another important consequence (which also follows from the Robinson-Schenstead-Knuth algo-rithm) is that A ( a , . . . , a n ) is symmetric in its arguments.Because of the equinumeracy of all patterns of length 3, we can consider 231-avoiding words. Important Definitions
Let W r ( n ) be the set of 231-avoiding words in the alphabet { , . . . , n } with exactly r occurrencesof each letter.Also, let w r ( n ) be the number of elements of W r ( n ).Define the ‘global set’ W r := ∞ [ n =0 W r ( n ) . Let g r ( x ) be its weight enumerator with respect to the weight w → x length ( w ) . Note that g r ( x ) = f r ( x r ), where f r ( x ) is the generating function of the sequence w r ( n ), f r ( x ) := ∞ X n =0 w r ( n ) x n . We will soon show how, for any specific , given, positive integer r , to obtain an algebraic equation(i.e. a polynomial P r ( x, F ) with integer coefficients such that P r ( x, f r ( x )) = 0), but let’s srart withsome warm-ups . First Warm-Up: r=1 W is the set of all permutations (of any length!) that avoid the pattern 231. Let the weight of apermutation π be x length ( π ) . Consider any member π of that set. It may happen to be the emptypermutation, of course (weight 1), or else it has a largest element; let’s call that element n . Allthe entries to the left of n must be smaller than all the elements to the right of n (or else a 231pattern would emerge), and each portion must be 231-avoiding in its own right. If the location of n is at the i -th place, then the portion to the left of n is a 231-avoiding permutation of { , . . . , i − } { i, . . . , n − } . Conversely, if π and π are 231-avoiding permutations of { , . . . , i − } and { i, . . . , n − } respectively, then π nπ is a231-avoiding permutation of length n , since no trouble can arise by joining them. Hence, f ( x ) = 1 + xf ( x ) , giving the good-old Catalan numbers. Second Warm-Up: r=2
The following argument is inspired by the beautiful proof in [CDZ], but is phrased in such a waythat will make it transparent how to generalize it for general r .Let g ( x ) be the weight-enumerator of W . Recall that W is the set of all 231-avoiding wordswhose letters consist of { , , . . . , n, n } for some n ≥
0, and the weight is x length ( w ) = x n ).(Note that g ( x ) = f ( x )), so once we have g ( x ) we will have f ( x ) immediately.)Consider a typical member of W , and let n be its largest element (i.e. it is of length 2 n ). Let i be the location of the leftmost occurrence of n . Notice, just as before, that the entries to the leftof that first n must be ≤ the entries to the right of that n , and each portion is 231-avoiding in itsown right, and conversely, if you place such 231-avoiding words with these entries to the left andright of that leftmost n , you will not cause any trouble, and get a 231-avoiding word whose entriesare { , , , , . . . , n, n } . Case I : i is odd, i.e. i = 2 j + 1.Then the entries to the left of that first n are { , , . . . , j, j } and the entries to the right are { j + 1 , j + 1 , . . . , n − , n − , n } . The generating function of the left part is our g ( x ), but the entriesto the right are a new combinatorial creature: a 231-avoiding word with all the letters occurringtwice, except for one of them (which by symmetry can be taken to be ‘1’) that only occurs once. Solet’s give the set W the new name W (0 , , and let W (1 , be the union of the sets of 231-avoidingwords on { , , , , , . . . , n, n } , for all n ≥
0. Let g (1 , ( x ) be its weight-enumerator. Hence thetotal weight-enumerator of Case I is x g (0 , ( x ) g (1 , ( x ) . (The x in front corresponds to the first n separating the two parts).We will deal with g (1 , ( x ) in due course, but now let’s proceed to Case II. Case II : i is even, i.e. i = 2 j .Once again let its length be 2 n (so the largest entry is n ). The entries to the left of that first n are { , , . . . , j − , j − , j } , and the entries to the right are { j, j + 1 , j + 1 , . . . , n } . The generating5unction of the left part is the already familiar g (1 , ( x ), but the right part is a new combinatorialcreature; namely, a 231-avoiding word with all the letters occurring twice, except for two of them(that by symmetry may be taken to be the smallest and the largest) that only occur once . Let’scall this set W (1 , , and its weight-enumerator g (1 , ( x ). Hence the total weight of Case II is x g (1 , ( x ) g (1 , ( x ).Combining the two cases, plus the empty permutation, leads to the following equation g (0 , ( x ) = 1 + x g (0 , ( x ) g (1 , ( x ) + xg (1 , ( x ) g (1 , ( x ) . ( Eq uninvited guests , g (1 , ( x ) and g (1 , ( x ). Using the same reasoning as above, thereaders are welcome to convince themselves that g (1 , ( x ) = xg (0 , ( x ) + xg (1 , ( x ) , ( Eq g (1 , ( x ) = x g (0 , ( x ) g (1 , ( x ) + x g (1 , ( x ) (1 + g (1 , ( x )) . ( Eq algebraic scheme , a system of three algebraic equations { Eq , Eq , Eq } in thethree ‘ unknowns ’ { g (0 , ( x ) , g (1 , ( x ) , g (1 , ( x ) } , using Gr¨obner bases (or, in this simple case itcould be easily done by hand) gives an algebraic equation satisfied by g (0 , ( x ), and hence, afterreplacing x by x , the [CDZ] equation for f ( x ) mentioned above:1 − (2 x + 1) f ( x ) + x ( x + 4) f ( x ) = 0 . The General Case
For 0 ≤ i ≤ j ≤ r − n ≥
0, let W ( i,j ) r ( n ) be the set of 231-avoiding words of length rn + i + j ,in the alphabet { , , . . . , n, n + 1 , n + 2 } , with i occurrences of the letter ‘1’, j occurrences of ‘ n + 2’,and exactly r occurrences of the other n letters (i.e. 2 , , . . . , n + 1), and let W ( i,j ) r be the union of W ( i,j ) r ( n ) over all n ≥ any two letters have i and j occurrencesrespectively, and the remaining letters each occur exactly r times.Using the same logic as above, we have the following (cid:0) r +12 (cid:1) equations, for 0 ≤ i ≤ j ≤ r −
1, wherebelow we make the convention that if r > s then g ( r,s ) = g ( s,r ) . g ( i,j ) ( x ) = δ i, δ j, + x r − X t =0 g ( i,t ) ( x ) g (( r − t ) mod r , ( j − mod r ) ( x ) + i − X m =0 x m +1 g ( i − m , j − ( x ) . By eliminating g (0 , ( x ), and replacing x r by x , we get the equation of our object of desire f r ( x ).In fact, this equation would have several solutions, and the right one is picked by plugging in thefirst few terms. 6 uessing Linear Recurrences for our sequences Now that we know, even without WZ-theory, that for every positive integer r , the generatingfunction f r ( x ) is D -finite, since it has the much stronger property of being algebraic, we immediatelyknow that the sequence itself, { w r ( n ) } , is P -recursive in the sense of Stanley[S]; in other words, itsatisfies some homogeneous linear recurrence equation with polynomial coefficients.With a very large computer, one should be able to get the algebraic equation for quite a few r ,and then use Comtet’s algorithm (built-in in the Maple package gfun , procedure algeqtodiffeq followed by procedure diffeqtorec ), to get a rigorously derived recurrence. Alas, because oursystem has ( r + 1) r/ r = 3 and r = 4, mentioned above. But now that weknow for sure that such recurrences exist, and it is easy to find a priori bounds for the order, it iseasy to justify these empirically-derived recurrences, a posteriori.But in order to guess complicated linear recurrences, one needs lots of data. Our algebraic schemeimplies very fast nonlinear recurrences for the coefficients of g ( i,j ) ( x ), and in particular for g (0 , ( x ),our primary interest. These turn out to be much faster than the ‘vanilla’ linear recurrence for A ( a , . . . , a n ) mentioned above. The Maple package Words123
Everything (and more!) is implemented in the Maple package
Words123 , available directly from ,or via the front of this article ,that also contains some sample input and output files.
The recurrences for ≤ r ≤ r = 1 we get the good-old Catalan numbers − n ) w ( n ) n + 2 + w ( n + 1) = 0 . For r = 2 we get a new proof of the [GGHP] conjecture (first proved in [CDZ]) − n + 12) (1 + 2 n ) (1 + n ) w ( n )(2 n + 5) (7 n + 5) ( n + 2) − (cid:0)
528 + 1426 n + 1215 n + 329 n (cid:1) w ( n + 1)2 (2 n + 5) (7 n + 5) ( n + 2) + w ( n + 2) = 0 . r = 3 we get −
643 (4 n + 1) (2 n + 3) (4 n + 3) (14 n + 25) ( n + 1) w ( n )(3 n + 5) (1 + 2 n ) (3 n + 7) (14 n + 11) ( n + 2) − · (cid:0) n + 39676 n + 37144 n + 16736 n + 2912 n (cid:1) w ( n + 1)(3 n + 5) (1 + 2 n ) (3 n + 7) (14 n + 11) ( n + 2) + w ( n + 2) = 0 . See the output file for the recurrences for w ( n ) and w ( n ). The Asymptotics for ≤ r ≤ w ( n ) = 1 √ π · n · n − (cid:18) − n − + 145128 n − − n − + O ( n − ) (cid:19) ,w ( n ) = 1 √ π · √ √ · n · n − (cid:18) − n − + 1325543904 n − − n − + O ( n − ) (cid:19) ,w ( n ) = 1 √ π · · n · n − (cid:18) − n − + 11058192 n − − n − + O ( n − (cid:19) ,w ( n ) = 1 √ π · √ · n · n − (cid:18) − n − + 162123040 n − − n − + O ( n − ) (cid:19) ,w ( n ) = 1 √ π · √ · n · n − (cid:18) − n − + 38914110000000 n − − n − + O ( n − ) (cid:19) . Warning: the above asymptotic expressions are fully rigorous except for the constants in front, which are onlyconjectured . References [AAAHH] M. H. Albert, M. Aldred, M. D. Atkinson, C. C. Handley and D. A. Holton,
Permutationsof a multiset avoiding permutations of length
3, Europ. J. Comb. (2001), 1021-1031. http://reflect.otago.ac.nz/staffpriv/mike/Papers/Multiperms/Multiperms.pdf .[B] A. Burstein, “Enumeration of words with forbidden patterns” , PhD Thesis, University of Penn-sylvania, 1998.[CDZ] W. Y. C. Chen, A. Y. L. Dai and R. D. P. Zhou, Ordered Partitions Avoiding a Permutationof Length 3 , to appear in European J. of Combinatorics. http://arxiv.org/abs/1304.3187 . 8Co] L. Comtet,
Calcul pratique des coefficients de Taylor d’une fonction alg´ebrique , EnseignementMathematique (1964), 267-270.[GGHP] A. Godbole, A.Goyt, J. Herdan, and L. Pudwell, Pattern Avoidance in Ordered Set Par-titions , Ann. Comb. (2014), 429-445. http://arxiv.org/abs/1212.2530 .[HM] S. Heubach and T. Mansour, “ Combinatorics of compositions and words ”, Discrete Mathe-matics and its Applications (Boca Raton), CRC Press, Boca Raton, FL, 2010 .[Ka] Anisse Kasraoui,
Pattern avoidance in ordered set partitions and words , Advances in AppliedMathematics Oct. 2014. http://arxiv.org/abs/1307.0495 .[Ki] S. Kitaev, “
Patterns in permutations and words ”, Springer Verlag (EATCS monographs inTheoretical Computer Science book series), 2011.[OEIS] The OEIS Foundation, Sequence A220997, https://oeis.org/A220097 .[P] L. Pudwell,
Enumeration schemes for words avoiding permutations . In “Permutation Patterns”( ), S. Linton, N. Ruskuc, and V. Vatter, Eds., vol. of London Mathematical SocietyLecture Note Series, Cambridge University Press, pp. 193-211. Cambridge: Cambridge UniversityPress.[S] R. Stanley,
Differentiably finite power series , European J. Combinatorics (1980), 175-188. .[Wiki] Wikipedia contributors (most notably Vince Vatter), “ Permutation pattern” , Wikipedia,The Free Encyclopedia, 19 Sep. 2014. Web. 7 Nov. 2014. https://en.wikipedia.org/wiki/Permutation pattern .[Z1] D. Zeilberger, A Holonomic Systems Approach To Special Functions , J. Computational andApplied Math (1990), 321-368.preprint version: [Z2] D. Zeilberger, AsyRec: A Maple package for Computing the Asymptotics of Solutionsof Linear Recurrence Equations with Polynomial Coefficients , Personal Journal of ShaloshB. Ekhad and Doron Zeilberger, April 4, 2008. [Z3] D. Zeilberger,
A Snappy Proof That 123-Avoiding Words are Equinumerous With 132-AvoidingWords , Personal Journal of Shalosh B. Ekhad and Doron Zeilberger, April 11, 2005. .9Z4] D. Zeilberger,
On Vince Vatter’s Brilliant Extension of Doron Zeilberger’s Enumeration Schemesfor Counting Herb Wilf ’s Classes , Personal Journal of Shalosh B. Ekhad and Doron Zeilberger, Dec.29, 2006. .Nathaniel Shar, Department of Mathematics, Rutgers University (New Brunswick), Hill Center-Busch Campus, 110 Frelinghuysen Rd., Piscataway, NJ 08854-8019, USA.Email: nshar at math dot rutgers dot edu .Doron Zeilberger, Department of Mathematics, Rutgers University (New Brunswick), Hill Center-Busch Campus, 110 Frelinghuysen Rd., Piscataway, NJ 08854-8019, USA.Email: zeilberg at math dot rutgers dot eduzeilberg at math dot rutgers dot edu