Discrete Mathematics and Theoretical Computer Science 3, 1999, 151–154 Permutations Containing and Avoiding and Patterns Aaron Robertson Department of Mathematics, Colgate University, Hamilton, NY 13346 received April 5, 1999, revised May 12, 1999, accepted May 19, 1999. We prove that the number of permutations which avoid -patterns and have exactly one -pattern, equals , for . We then give a bijection onto the set of permutations which avoid -patterns and have exactly one -pattern. Finally, we show that the number of permutations which contain exactly one -pattern and exactly one -pattern is , for . ! " $# %& Keywords: Patterns, Words 1 Introduction ' ( (*,+-(/.01(32044401(3576 < In 1990, Herb Wilf asked the following: How many permutations of length avoid a given pattern, ? By pattern-avoiding we mean the following: Let be a permutation of length and let be a permutation of length (we will call this a pattern of length ). Let be a set of integers, and let . Define to be if is the smallest element in , if it is the second smallest, ..., and if it is the largest. The permutation avoids the pattern if and only if there does not exist a set of indices , such that . In two beautiful papers ([B1] and [N]), the number of subsequences containing exactly one -pattern and exactly one -pattern are enumerated. Noonan shows in [N] that the number of permutations containing exactly one -pattern is the simple formula . Bóna proves that the even simpler formula enumerates the number of permutations containing exactly one -pattern. Bóna’s result proved a conjecture first made by Noonan and Zeilberger in [NZ]. Noonan and Zeilberger considered in [NZ] the number of permutations of length which contain exactly p-patterns, for . Bóna, in [B2], made further progress concerning the number of permutations with exactly -patterns. In this article we work towards the following generalization: How many per, and contain -patterns, for , ? We will mutations of length avoid patterns , for first consider the permutations of length which avoid -patterns, but contain exactly one -pattern. We then define a natural bijection between these permutations and the permutations of length which avoid -patterns, but contain exactly one -pattern. Finally, we will calculate the number of permutations which contain one -pattern and one -pattern. These results address questions first raised in [NZ]. 8%9:' =>?; (A@1BDCED+F=70;G6 < JK*L+NMO.0PMQ2704440PM576 HI7Y HIY ] 2 \D\Da a [b[ ` < <dHYUI HIY < c?H ' ) 8 ; H = ; I ) ( (%*R+S(A@TBUCEU+1)V+NMO.60PJD6 0T(A@1BDCED+1)V+NM26 0!JU604440T(A@TBUCEU+1)V+NMW5X6 0!JU6P6 HYZI \^[ ] \72 _ \ [!` HYZI ' (Ae ' HIY o p ' Mfchg HYZI HYZI <ij($i =kclH <imcnH HIY HYZI email: arobertson@mail.colgate.edu 1365–8050 c 1999 Maison de l’Informatique et des Mathématiques Discrètes (MIMD), Paris, France ' 152 Aaron Robertson 2 Known Results For completeness, two results which are already known are given below. Lemma 1: The number of permutations of length with one -pattern is . Proof: Induct on . The base case is trivial. A permutation, , of length with one -pattern must have or . If , by induction we get permutation. If , then we must have (or we would have more than one -pattern). The rest of the entries of must be decreasing. Hence we get more permutation from this second case, for a total of . Lemma 2: The number of permutations which avoid both the pattern and is . Proof: Let denote the number of permutations we are interested in. Then with . To see this, let be a permutation of length . Insert the element into the position of . Let be this new permutation of length . To assure that avoids the -pattern, we must have all entries preceding in be larger than the entries following . To assure that avoids the -pattern, the entries preceding must be in decreasing order. This argument gives the sum in the recursion. The recursion holds by noting that if , there is one permutation which avoids both patterns. To complete the proof note that . ' ' 's*trj+WH6 '*urv+wI76 'sq?H*yrj+WH6 z~K*yH '*urj+OH6 HI z\ H ) ' ' 'qH ' ) HI r ' qI x ' 'q:H ' HI '*urj+TIZ6 r 'q:\DH a . HI7Y HYUI I \ z \ *|{ eF}v. z \Da e ' MQ1 HYZI ) HIY ) '*RH z \ * I \Da . 3 One 123-pattern, but no 132-pattern ' +1'xqIZ6OI \a [ HI7Y Theorem 1: The number of permutations of length which have exactly one -pattern, and avoid the -pattern is . Proof: Call a permutation good if it has exactly one -pattern and avoids the -pattern, and let denote the number of good permutations of length . Let be a permutation of length . Insert the element into the position of . Call this newly constructed permutation of length , . To assure that avoids the pattern, we must have all elements preceding in be larger than the elements following in . For to be a good permutation, we must consider two disjoint cases. Case I: The pattern appears in the elements following in . This forces the elements preceding to be in decreasing order. Summing over , this case accounts for permutations. Case II: The pattern appears in the elements preceding and including in . This forces the in the pattern to be . Hence the elements preceding must contain exactly one -pattern. (Further there must be at least elements. Hence must be at least ). From Lemma 1, this number is . We are also forced to avoid both patterns in the elements following . Lemma 2 implies that there are such permutations. Summing over , this case accounts for permutations. We have established that the recurrence relation HYZI ) ' ' Mw1 HYUI ) I ' HI7Y ' ' ) H I7Y HIY ' M M M HYZI ' Y ) ) \ { eF}v. \Da e \ 'qH ' ) ' ' HI ) ' { \De} a [ . +1MvqI76PI \Da e a . 'qI Y MqI D\ a e a . I \ \ a . \ * \Da e +1MGqI76PI \Da e a . 'qI$0 e}j. eF} [ which holds for 'ctY ( ~ *,g$0WU.*Lg0W72K*,g ), enumerates the permutations of length ' which avoid the pattern HYZI and contain exactly one HIY -pattern. One easy way to proceed would be to find the generating function of \ . However, in this article we would like to employ a different, and in many circumstances more powerful, tool. We will use the Maple procedure findrec in Doron Zeilberger’s Maple package EKHAD . (The Maple shareware Available for download at www.math.temple.edu/˜zeilberg/ Permutations Containing and Avoiding HI7Y and HYZI Patterns 153 package gfun could have also been used.) Instructions for its use are available online. To use find) . We rec we compute the first few terms of . These are (for type findrec([4,12,32,80,192,448,1024],0,2,n,N) and are given the recurrence for . Define and , and it is routine to verify that for . Another routine calculation shows us that for , thereby proving the statement of the theorem. \ 'c A0HI$0PYUI0PZg$0HZI$0OZ7$0HgZI \ * ~ *ug$03.*tg0!A2*Rg$0 [ *yH \ *+N'sqhI76PI \Da [ '?c,Y A+T D\ a .q D\ a 26 'c \ *y \ n ' c,g 4 One 132-pattern, but no 123-pattern ' +1'xqIZ6OI \a [ HYUI Theorem 2: The number of permutations of length which have exactly one -pattern, and avoid the -pattern is . Proof: We prove this by exhibiting a (natural) bijection from the permutations counted in Theorem 1 to the permutations counted in this theorem. Define avoids -pattern and contains one -pattern and avoids -pattern and contains one -pattern . We will show that , by using the following bijection: Let . Let , and let be the -pattern in . Then acts on the elements of as follows: if , , and . In other words, all elements keep their positions except and switch places. An easy examination of several cases shows that this is a bijection, thereby proving the theorem. HIY -*) ) H¦ IY ¦ ¦ ¦ ¡ ¢£-*¤)y¥) HI7Y * ¢ rA q/§¢ ¨k> BD©C HI7Y ¨ rv+1ª36«*¬ª ª®>¯­ X©0PC¡ rv+w©6¥* C rj+1C6¥*?© © C HYZI HYZI ¡ r ¨ 5 One 132-pattern and one 123-pattern +N'qYZ6+1'xqsD6OI \a3° HIY ' ' HYUI ' HYZI HIY Theorem 3: The number of permutations of length which have exactly one -pattern and one pattern is . Proof: We use the same insertion technique as in the proof of Theorem 1. Call a permutation good if it has exactly one -pattern and exactly one -pattern and let denote the number of good permutations of length . Let be a permutation of length . Insert the element into the position of . Let be -pattern cannot consist of elements this newly constructed permutation of length . We note that the only preceding . If this were the case, we would have two -patterns ending with . For to be a good permutation, we must consider the following disjoint cases. Case I: The -pattern consists of elements following . In this case all elements preceding must be larger than the elements following . HI7Y HYZI \ '%qhH ' HIY ' HYZI MQ1 ) ' ' M -pattern consists of elements following . Summing over we get Subcase A: The permutations in this subcase. ' ) ' ' ' { \eF}v. \a e HI HIY H\IaY ' { eF} [ [ +1MjqhI76+1'q®M±q®YZ6PI \Da e a 2 ' ' ' 'qlH70P'q¬I$04440O'qlH I 0O'q¬M good Subcase B: The elements preceding have exactly one -pattern. This gives a -pattern where the 3 in the pattern is . We must also avoid the -pattern in the elements following . Summing over and using Lemma 1 and Theorem 1, we get good permutations in this subcase. Case II: The -pattern has the first element preceding , the last element following , and as the middle element. The elements preceding must be , where immediately precedes in . See [B1] for a more detailed argument as to why this must be true. ' HYUI ' ) ' Subcase A: The elements preceding have exactly one element of the pattern is . We must also avoid both the ' ' M 'q:M HI -pattern. This gives a HIY -pattern where the last HIY and the HYUI pattern in the elements following 154 Aaron Robertson ' . Summing over M and using Lemma 1 and Lemma 2 we have { \DeF}ba ² . N+ M±qYZ6PI \Da e a . good permutations in this subcase. Subcase B: The HIY -pattern consists of elements following ' . We must have the elements preceding ' in ) be decreasing to avoid another HI7Y -pattern. Further, the elements following ' must not contain a HYZI -pattern. Using Theorem 1 and summing over M , we get a total of { \DeF}³a 2 [ +N'qhMfqI76PI \Da e a [ good permutations in this subcase. In total, we find that the following recurrence enumerates the permutations of length ' which contain exactly one HIY -pattern and one HYZI -pattern. \ \ a ² \ * \Da e +wIXM +N'qMGqU6 'qYZ6PI \Da e a ² e}j. eF}v. for 'sc¬´ and . *¬ 2 * *¬ ² * g . [ Using findrec again by typing findrec([2,12,48,160,480,1344,3584],1,1,n,N) 2µ \7\ _ 2P¶ z \ , (where the list is the first few terms of our recurrence for 'sc´ ) we get the recurrence z \_ . * with z7. *?I . After reindexing, another routine calculation shows that z \ *¬ \ . Solving z \ for an explicit \a3° . answer, we find that \ *L+N'qYZ6+1'xqsD6OI We conjecture that the generating function for the number of permutations with exactly zero or exactly _ one HYUI -pattern and exactly <KHI7Y -patterns is ·k+1¸D6P¹$+WH q®I¸D6Wº . , where ·k+1¸D6 is a polynomial. For more evidence, and further extensions see [RWZ]. Acknowledgements The author would like to thank Robin Chapman for his useful comments. References HYZI [B1] M. Bóna, Permutations with one or two -subsequences., Discrete Mathematics, 181, 1998, 267274. -subsequences is -recursive in the Size!., [B2] M. Bóna, The Number of Permutations with Exactly Advances in Applied Mathematics, 18, 1997, 510-522. [N] J. Noonan, The Number of Permutations Containing Exactly One Increasing Subsequence of Length , Discrete Mathematics, 152, 1996, 307-313. [NZ] J. Noonan and D. Zeilberger, The Enumeration of Permutations with a Prescribed Number of “Forbidden” Patterns, Advances in Applied Mathematics, 17, 1996, 381-407. [RWZ] A. Robertson, H. Wilf, and D. Zeilberger, Patterns and Fractions, submitted. See www.math.temple.edu/˜[aaron,zeilberg]/ for preprint. Y <HYZI ·