Approaches for enumerating permutations with a prescribed number of occurrences of patterns
aa r X i v : . [ m a t h . C O ] S e p Approaches for enumerating permutations with a prescribednumber of occurrences of patterns
Brian Nakamura ∗ Abstract
In recent work, Zeilberger and the author used a functional equations approach for enu-merating permutations with r occurrences of the pattern 12 . . . k . In particular, the approachyielded a polynomial-time enumeration algorithm for any fixed r ≥
0. We extend that ap-proach to patterns of the form 12 . . . ( k − k )( k −
1) by deriving analogous functional equationsand using them to develop similar algorithms that enumerate permutations with r occurrencesof the pattern. We also generalize those techniques to handle patterns of the form 23 . . . k Let σ = σ . . . σ k be a sequence of k distinct positive integers. We define the reduction red( σ )to be the length k permutation τ = τ . . . τ k that is order-isomorphic to σ (i.e., σ i < σ j if andonly if τ i < τ j for every i and j ). Given a (permutation) pattern τ ∈ S k , we say that a permu-tation π = π . . . π n contains the pattern τ if there exists 1 ≤ i < i < . . . < i k ≤ n such thatred( π i π i . . . π i k ) = τ , in which case we call π i π i . . . π i k an occurrence of τ . We will define N τ ( π )to be the number of occurrences of τ in π . For example, if the pattern τ = 123, the permutation53412 avoids the pattern τ (so N (53412) = 0), whereas the permutation 52134 contains twooccurrences of τ (so N (52134) = 2).For a pattern τ and non-negative integer r ≥
0, we define the set S n ( τ, r ) := { π ∈ S n : π has exactly r occurrences of the pattern τ } and also define s n ( τ, r ) := |S n ( τ, r ) | . The corresponding generating function is defined as F rτ ( x ) := ∞ X n =0 s n ( τ, r ) x n . Observe that the classical pattern avoidance problem corresponds to the case where r = 0 and hasbeen well studied. In this setting, S n ( τ,
0) is known to be enumerated by the Catalan numbers if τ ∈ S [11]. However, much is still unknown even for length 4 patterns. For example, permutationsavoiding the pattern 1324 have been notoriously difficult to enumerate. Precise asymptotics arenot even known, although B´ona recently gave an improved upper bound for the growth rate (in[3]) by modifying the approach used by Claesson, Jel´ınek, and Steingr´ımsson [8]. The survey paper ∗ Mathematics Department, Rutgers University-New Brunswick, Piscataway, NJ, USA. [[email protected]]
1y Kitaev and Mansour [10] provides an extensive overview of work in this area as well as relatedproblems in permutation patterns.While the more general problem (where r ≥
0) has also been studied, the work has usually beenrestricted to small patterns (usually length three) and small r . In [15], Noonan studied permu-tations containing exactly one occurrence of 123 and proved that s n (123 ,
1) = n (cid:0) nn − (cid:1) . Bursteinrecently gave a short combinatorial proof for the result [6]. In [16], Noonan and Zeilberger pre-sented an approach using functional equations to enumerate s n ( τ, r ) for small r and for the patterns123, 312, and 1234. Subsequent work has been done by B´ona [5, 4], Fulmek [9], Mansour and Vain-shtein [13], Callan [7], and many others. Many of these focused on finding F rτ ( x ) for τ ∈ S andfor small r .One difficulty arising from the initial Noonan-Zeilberger functional equation approach in [16]was that the approach became very complicated for even r = 2. In addition, there are manypatterns that this approach does not readily extend to. One such pattern (explicitly mentionedin [16]) was 1432. A modified approach was recently presented in [14] for the case of increasingpatterns. Given a fixed r ≥
0, the resulting enumeration algorithm for computing s n (12 . . . k, r )was polynomial-time (in n ). This, in a sense, tackled the first difficulty from [16] and allowed usto enumerate the sequence s n (12 . . . k, r ) for even larger fixed r .In this paper, we extend the enumeration techniques in [14] to new families of patterns (includ-ing the pattern 1432) as well as multiple patterns. It should be noted that this general approachis different from the enumeration schemes approach pioneered by Zeilberger [21] and extended byVatter [20], Pudwell [17, 2], and Baxter [1, 2]. The enumeration schemes approach is useful forenumerating pattern-avoiding permutations (the r = 0 case) but does not appear to be readilyadaptable to the generalized setting for permutations with r > .Section 5 lists some possible future work as well as some conjectures. The enumeration algorithmsdeveloped in this paper are implemented in the Maple packages FINCR , FINCRT , F231 , F2341 , F123n132 , F1234n1243 , and
FS3 . They are all available from the author’s website. . . . ( k − k )( k − In this section, we adapt the approach in [14] (for increasing patterns) to the patterns 12 . . . ( k − k )( k − Given a (fixed) pattern τ and non-negative integer n , we define the polynomial f n ( t ) := X π ∈S n t N τ ( π ) . (1) This is technically the same as tracking the number of 21 patterns that occur. t r in f n ( t ) is exactly equal to s n ( τ, r ). For a fixed pattern τ andfixed r ≥
0, our goal is to quickly compute s n ( τ, r ). In the remainder of this section, we willassume that τ = 132.In addition to the variable t , we introduce the catalytic variables x , . . . , x n and define theweight of a length n permutation π = π . . . π n to beweight ( π ) := t N ( π ) n Y i =1 x { ( a,b ) : π a >π b = i, ≤ a
1) = f n ( t ). We now get the following: Lemma 1.
Let π = π . . . π n and suppose that π = i . If π ′ := red ( π . . . π n ) , thenweight ( π ) = x x . . . x i − · weight ( π ′ ) | x i → tx i +1 , x i +1 → tx i +2 , ... , x n − → tx n . Proof.
We assume i to be a fixed value and will compute weight( π ) from weight( π ′ ). We re-insert i at the beginning of π ′ by shifting all the terms i, i + 1 , . . . , n − x j → x j +1 for j ≥ i ).The new “ i ” would create new 21 patterns and would require an extra factor of x x . . . x i − forthe weight. Also, observe that N ( π ) is equal to the number of occurrences of 132 in π ′ plus thenumber of occurrences of 21 in π . . . π n , where the term corresponding to the “1” is larger than i .Therefore, our x j shift now becomes x j → tx j +1 for j ≥ i .This directly leads to the functional equation: Theorem 1.
For the pattern τ = 132 , P n ( t ; x , . . . , x n ) = n X i =1 x x . . . x i − · P n − ( t ; x , . . . , x i − , tx i +1 , . . . , tx n ) . (FE132)Once P n ( t ; x , . . . , x n ) is computed, the catalytic variables x , . . . , x n can all be set to 1 to get f n ( t ) = P n ( t ; 1 , . . . , P n ( t ; x , . . . , x n ) in its entiretyprior to setting the catalytic variables to 1. Observe that by (FE132), we have: P n ( t ; 1 , . . . ,
1) = n X i =1 P n − ( t ; 1 [ i − times ] , t [ n − i times ]) .
3e get terms of the form P a + a ( t ; 1 [ a times ] , t [ a times ]) in the summation, which can againbe plugged into (FE132) to get: P a + a ( t ; 1 [ a times ] , t [ a times ]) = a X i =1 P a + a − (1 [ i − times ] , t [ a − i times ] , t [ a times ])+ a X i =1 t i − P a + a − (1 [ a times ] , t [ i − times ] , t [ a − i times ])Now, we must deal with terms of the form P a + a + a ( t ; 1 [ a times ] , t [ a times ] , t [ a times ]).We can continue this recursive process of plugging new terms into (FE132) to eventually compute f n ( t ) = P n ( t ; 1 [ n times ]). This is much faster than the direct weighted counting of all n ! permu-tations, although it is still unfortunately an exponential-time (and memory) algorithm.This algorithm has been implemented in the procedure F132full(n,t) (in the Maple package
FINCRT ). For example, the Maple call
F132full(8,t); computes f ( t ) and outputs: t + 7 t + 20 t + 37 t + 41 t + 109 t + 162 t + 169 t + 322 t + 397 t + 647 t + 730 t +1048 t + 1152 t + 1417 t + 1576 t + 1770 t + 1853 t + 2321 t + 2088 t + 2620 t +2401 t + 2682 t + 2489 t + 2858 t + 2225 t + 2593 t + 1918 t + 1950 t + 1287 t + 1430Suppose that for a small fixed r ≥
0, we wanted the first 20 terms of the sequence s n (132 , r ).By this functional equation approach, one would compute f n ( t ) and extract the coefficient of t r for each n up to 20. This approach would expend quite a bit of computational effort in gener-ating unnecessary information (namely, all the t k terms where k > r ). This issue can mostly becircumvented, however, by a couple of observations. The first is the following lemma from [14]: Lemma 2.
Let n = a + a + . . . + a s (where a i ≥ for each i ) and suppose s > r + 1 . Then, thecoefficients of t , t , . . . , t r in P n ( t ; 1 [ a times ] , . . . , t s − [ a s − times ] , t s [ a s times ]) − P n ( t ; 1 [ a times ] , . . . , t r [ a r times ] , t r +1 [ a r +1 + a r +2 + . . . + a s times ]) all vanish.Proof. The more general function P n ( t ; x , . . . , x n ) is a multi-variate polynomial.This lemma allows us to collapse all the higher powers of t into the t r +1 coefficient and allows usto consider objects of the form P n ( t ; 1 [ a times] , . . . , t r [ a r times] , t r +1 [ a r +1 times]) regardless ofhow large n is.Let n := a + a + . . . + a r +1 . Also, for any expression R and positive integer k , let R $ k denote R [ k times ]. For example, t $4 is shorthand for t , t , t , t . Now for any polynomial p ( t ) in thevariable t , let p ( r ) ( t ) denote the polynomial of degree (at most) r obtained by discarding all powersof t larger than r . Also, define the operator CHOP r by CHOP r [ p ( t )] := p ( r ) ( t ).An application of (FE132) and CHOP r to P ( r ) n ( t ; 1 [ a times] , . . . , t r [ a r times] , t r +1 [ a r +1 times])becomes: 4 ( r ) n ( t ; 1$ a , . . . , t r $ a r , t r +1 $ a r +1 )= CHOP r " a X i =1 P ( r ) n − ( t ; 1$( i − , t $( a − i ) , t $ a , . . . , t r $ a r − , t r +1 $( a r + a r +1 ))+ a X i =1 t i − P ( r ) n − ( t ; 1$ a , t $( i − , t $( a − i ) , t $ a , . . . , t r $ a r − , t r +1 $( a r + a r +1 ))+ a X i =1 t a +2( i − P ( r ) n − ( t ; 1$ a , t $ a , t $( i − , t $( a − i ) , . . . , t r $ a r − , t r +1 $( a r + a r +1 ))+ . . . . . . + a r +1 X i =1 t a +2 a + ... + ra r +( r +1)( i − P ( r ) n − ( t ; 1$ a , t $ a , . . . , t r $ a r , t r +1 $( a r +1 − . Due to the CHOP r operator, many terms automatically disappear because of the power of t in front. From a computational perspective, this observation eliminates many unnecessary termsand hence circumvents a lot of unnecessary computation. This has been automated in the Maplepackage FINCRT so that a computer can derive a “scheme” for any fixed r (completely on its own)and use it to enumerate s n (132 , r ) for as many terms as the user wants. For example, the Maple call
F132rN(5,15); for the first 15 terms of s n (132 ,
5) produces thesequence:0 , , , , , , , , , , , , , , First, we outline how to extend the previous approach to the pattern 1243. In addition to thevariable t , we now introduce 2 n catalytic variables x , . . . , x n and y , . . . , y n . The weight of alength n permutation π = π . . . π n will now beweight( π ) := t N ( π ) n Y i =1 x { ( a,b ) : π a >π b = i, ≤ a
Lemma 3.
Let π = π . . . π n and suppose that π = i . If π ′ := red ( π . . . π n ) , thenweight ( π ) = x x . . . x i − · weight ( π ′ ) | A , The “scheme” mentioned here is a liberal application of the word and differs from enumeration schemes . here A is the set of substitutions given by A := ( x b → y i x b +1 i ≤ b ≤ n − y b → ty b +1 i ≤ b ≤ n − . Proof.
We assume i to be a fixed value and will again compute weight( π ) from weight( π ′ ). First, were-insert i at the beginning of π ′ by shifting all the terms i, i + 1 , . . . , n − x j → x j +1 and y j → y j +1 for j ≥ i ). The new “ i ” would create new 21 patterns and would require an extrafactor of x x . . . x i − for the weight. Also, the re-insertion of i would create new 132 patterns.The number of such new patterns is exactly the number of 21 patterns in the shifted π ′ , where the“1” is greater than i . Therefore, our x j shift now becomes x j → y i x j +1 for j ≥ i . Also, observethat N ( π ) is equal to the number of occurrences of 1243 in π ′ plus the number of occurrencesof 132 in π . . . π n , where the term corresponding to the “1” is larger than i . Therefore, our y j shift now becomes y j → ty j +1 for j ≥ i .This directly leads to the new functional equation: Theorem 2.
For the pattern τ = 1243 , P n ( t ; x , . . . , x n ; y , . . . , y n ) = n X i =1 x x . . . x i − · P n − ( t ; x , . . . , x i − , y i x i +1 , . . . , y i x n ; y , . . . , y i − , ty i +1 , . . . , ty n ) . (FE1243)Again, our goal is to compute f n ( t ) = P n ( t ; 1 [2 n times]). We can apply the same computationalmethods as before. For example, we can apply (FE1243) directly to P n ( t ; 1 [2 n times]) (and moregenerally, to objects of the form P n ( t ; 1 [ a times] , . . . , t s [ a s times] , b times] , . . . , t s [ b s times]))to compute f n ( t ). This again gives us an algorithm that is faster than the direct weighted countingof n ! permutations but is still exponential-time (and memory).This algorithm has been implemented in the procedure F1243full(n,t) (in Maple package
FINCRT ). For example, the Maple call
F1243full(8,t); computes f ( t ) and outputs: t + t + 10 t + 3 t + 13 t + 9 t + 8 t + 37 t + 16 t + 16 t + 49 t + 60 t +41 t + 130 t + 81 t + 157 t + 266 t + 184 t + 233 t + 542 t + 356 t + 771 t +877 t + 975 t + 972 t + 2180 t + 1710 t + 2658 t + 3119 t + 4600 t + 4478 t + 15767Additionally, both the obvious analog of Lemma 2 as well as the computational reduction usingthe CHOP r operator still apply in this setting. This has also been automated in the Maple package FINCRT .For example, the Maple call
F1243rN(1,15); for the first 15 terms of s n (1243 ,
1) produces thesequence:0 , , , , , , , , , , , , , , F1243rN(2,15); for the first 15 terms of s n (1243 ,
2) produces the sequence:0 , , , , , , , , , , , , , , .3 Extending to longer patterns The approach for the patterns 132 and 1243 can be extended analogously to longer patterns ofthe form 12 . . . ( k − k )( k − τ = 12354, we consider the variable t and 3 n catalytic variables: x , . . . , x n and y , . . . , y n and z , . . . , z n . The weight of a length n permutation π = π . . . π n will now beweight( π ) = t N ( π ) n Y i =1 x { ( a,b ) : π a >π b = i } i · y { ( a,b,c ) : π a = i<π c <π b } i · z { ( a,b,c,d ) : π a = i<π b <π d <π c } i where it is always assumed that a < b < c < d .An analogous functional equation is derived for the corresponding polynomial P n ( t ; x , . . . , x n ; y , . . . , y n ; z , . . . , z n ) := X π ∈S n weight( π )and all the analogous computational methods work in this setting as well. The 12354 case has alsobeen automated in the Maple package FINCRT .For example, the Maple call
F12354rN(0,14); for the first 14 terms of s n (12354 ,
0) producesthe sequence:1 , , , , , , , , , , , , , F12354rN(1,15); for the first 15 terms of s n (12354 ,
1) produces the sequence:0 , , , , , , , , , , , , , , . . . k In this section, we extend the previous techniques to handle patterns of the form 23 . . . k
1. Although s n (231 , r ) = s n (132 , r ) for every r and n (by reversal), we will develop an approach for handling231 directly and then show how this can be extended to longer patterns of the form 23 . . . k
1. Thisnew approach for handling 231 will also be necessary in the next section for considering multiplepatterns simultaneously.
In this section, we will assume that our (fixed) pattern τ = 231. We define the analogous polyno-mial f n ( t ) := X π ∈S n t N ( π ) . Recall that the coefficient of t r in f n ( t ) will be exactly s n (231 , r ).In addition to the variable t , we introduce n ( n + 1) / x i,j with 1 ≤ j ≤ i ≤ n and define the weight of a permutation π = π . . . π n to beweight( π ) := t N ( π ) Y ≤ j ≤ i ≤ n x { ( a,b ) : π a >π b , π a = i, π b
Let π = π . . . π n and suppose that π = i . If π ′ := red ( π . . . π n ) , thenweight ( π ) = x i, x i, . . . x i − i,i · weight ( π ′ ) | A , where A is the set of substitutions given by A := x b,c → x b +1 ,c b ≥ i, c < ix b,c → x b +1 ,c +1 b ≥ i, c > ix b,c → tx b +1 ,c · x b +1 ,c +1 b ≥ i, c = i . Proof.
We assume i to be a fixed value. Observe that N ( π ) is equal to the number of occurrencesof 231 in π . . . π n plus the number of occurrences of 21 in π . . . π n , where the term correspondingto the “2” is greater than i and the term corresponding to the “1” is less than i . We make thefollowing two observations. First, in weight( π ), the exponents of x k,i and x k,i +1 are equal for each k (since π = i ). Second, the number of 231 patterns that include the first term π = i is the sumof the exponents of x j,i for i + 1 ≤ j ≤ n .If we re-insert i at the beginning of π ′ , we would shift all the terms i, i + 1 , . . . , n − A .Note that there is no case for b < i, c ≥ i since the x b,c variables are only defined for b ≥ c . Finally,the new “ i ” would create new 21 patterns and would require an extra factor of x i, x i, . . . x i − i,i forthe weight. 8ow, define the operator R on an n × n square matrix X n and i < n to be: R ( X n , i ) := x , · · · x ,i − tx ,i x ,i +1 x ,i +2 · · · x ,n ... . . . ... ... x i − , x i − ,i − · · · x i − ,n x i +1 , · · · x i +1 ,i − tx i +1 ,i x i +1 ,i +1 x i +1 ,i +2 · · · x i +1 ,n ... ... ... . . . ...... ... ... . . . ... x n, · · · x n,i − tx n,i x n,i +1 x n,i +2 · · · x n,n . (3)In essence, the R operator deletes the i -th row, merges the i -th and ( i + 1)-th columns via term-by-term multiplication, and multiplies this new column by a factor of t . If i = n , then R ( X n , i )is defined to be the ( n − × ( n −
1) matrix obtained by deleting the n -th row and n -th columnfrom X n . It is important to note that while this operator is defined on any n × n matrix, it willonly be applied to our “matrix of variables” X n to get a smaller ( n − × ( n −
1) matrix.The previous lemma now leads directly to the following:
Theorem 3.
For the pattern τ = 231 , P n ( t ; X n ) = n X i =1 x i, x i, . . . x i − i,i · P n − ( t ; R ( X n , i )) . (FE231)Note that while all entries in the matrix are changed for consistency, we will continue to disregardthe entries above the diagonal.Again, our goal is to compute P n ( t ; ), and the analogous computational techniques fromprevious sections will also apply in this setting. For example, we can apply (FE231) directly to P n ( t ; ) as opposed to computing P n ( t ; X n ) symbolically and substituting x i,j = 1 at the end. Thefollowing result, which is obvious from the definition of the operator R , provides a substantialsimplification: Lemma 5.
Let A be a square matrix where every row is identical (i.e., the i -th row and the j -throw are equal for every i, j ). Then, R ( A, i ) will also be a square matrix with identical rows. By Lemma 5, repeated applications of R to the all ones matrix will still result in a matrixwith identical rows. Therefore, it is sufficient to keep track of only one row as opposed to theentire matrix. Also observe that repeated applications of R to the matrix will always result in amatrix whose entries are powers of t . Let Q n ( t ; c , . . . , c n ) denote the polynomial P n ( t ; C ), where C is the n × n matrix where every row is [ c , . . . , c n ] and every c i is a power of t . This leads to afunctional equation analogous to (FE231): Q n ( t ; c , . . . , c n ) = n X i =1 c c . . . c i − i · Q n − ( t ; c , . . . , c i − , tc i c i +1 , c i +2 , . . . , c n ) . (FE231c)Note that Q n ( t ; 1 [ n times]) is exactly our desired polynomial P n ( t ; ) = f n ( t ). However, this in-terpretation only forces us to deal with n catalytic variables (the c i ’s) as opposed to n ( n + 1) / x i,j ’s). Just as in prior sections, we can repeatedly apply our functionalequation (FE231c) to compute Q n ( t ; 1 [ n times]).9hen the sequence s n (231 , r ) is desired for a fixed r , the obvious analog of Lemma 2 and thecomputational reduction using the CHOP r operator can again be used. This has been implementedin the Maple package F231 . In this section, we outline how to extend the approach for 231 to an analogous (but more com-plicated) approach for 2341. In addition to the variable t , we now introduce n ( n + 1) / x i,j with 1 ≤ j ≤ i ≤ n and n ( n + 1) / y i,j with 1 ≤ j ≤ i ≤ n (a total of n ( n + 1) catalytic variables). Define the weight of a permutation π = π . . . π n to beweight( π ) := t N ( π ) Y ≤ j ≤ i ≤ n x { ( a,b ) : π a >π b , π a = i, π b Let π = π . . . π n and suppose that π = i . If π ′ := red ( π . . . π n ) , thenweight ( π ) = x i, x i, . . . x i − i,i · weight ( π ′ ) | A ′ , where A ′ is the set of substitutions given by A ′ := x b,c → y i,c · x b +1 ,c b ≥ i, c < ix b,c → x b +1 ,c +1 b ≥ i, c > ix b,c → y i,i · x b +1 ,c · x b +1 ,c +1 b ≥ i, c = iy b,c → y b +1 ,c b ≥ i, c < iy b,c → y b +1 ,c +1 b ≥ i, c > iy b,c → ty b +1 ,c · y b +1 ,c +1 b ≥ i, c = i . Although all output would be equivalent to the 132 case, the approach here will be necessary when consideringmultiple patterns. roof. We assume i to be a fixed value. Observe that N ( π ) is equal to the number of occurrencesof 2341 in π . . . π n plus the number of occurrences of 231 in π . . . π n , where the term correspondingto the “2” is greater than i and the term corresponding to the “1” is less than i . We make thefollowing few observations. First, in weight( π ), the exponents of x k,i and x k,i +1 are equal andthe exponents of y k,i and y k,i +1 are equal for each k (since π = i ). Second, the number of 2341patterns that include the first term π = i is the sum of the exponents of y j,i for i + 1 ≤ j ≤ n .Third, the number of 231 patterns that include the first term π = i (i.e., the “2” is equal to i )and whose “1” term is less than k is equal to the sum of the exponents of x j,k for i + 1 ≤ j ≤ n .If we re-insert i at the beginning of π ′ , we would shift all the terms i, i + 1 , . . . , n − A ′ .Note that there is no case for b < i, c ≥ i since the x b,c variables are only defined for b ≥ c . Finally,the new “ i ” would create new 21 patterns and would require an extra factor of x i, x i, . . . x i − i,i forthe weight.In addition to the previous R operator defined in Eq. 3, we define another operator R on twosquare matrices X n and Y n (of equal dimension) and i < n to be: R ( X n , Y n , i ) := x , · · · x ,i − y i,i x ,i x ,i +1 x ,i +2 · · · x ,n ... . . . ... ... x i − , x i − ,i − · · · x i − ,n y i, x i +1 , · · · y i,i − x i +1 ,i − y i,i x i +1 ,i x i +1 ,i +1 x i +1 ,i +2 · · · x i +1 ,n ... ... ... . . . ...... ... ... . . . ... y i, x n, · · · y i,i − x n,i − y i,i x n,i x n,i +1 x n,i +2 · · · x n,n . (5)In essence, the R operator deletes the i -th row, merges the i -th and ( i + 1)-th columns via term-by-term multiplication (and multiplies this new column by a factor of y i,i ), and scales all x b,c with b > i and c < i by terms from Y n . If i = n , then R ( X n , Y n , i ) is defined to be the ( n − × ( n − n -th row and n -th column from X n .The previous lemma now leads to the following: Theorem 4. For the pattern τ = 2341 , P n ( t ; X n , Y n ) = n X i =1 x i, x i, . . . x i − i,i · P n − ( t ; R ( X n , Y n , i ) , R ( Y n , i )) . (FE2341)As in prior sections, we recursively apply the functional equation directly to P n ( t ; , ) (andsubsequent instances of P k ). Observe that in this scenario, Lemma 5 still applies for the R operator and more specifically the “ Y n ” matrix in P n . While the lemma does not apply to the R operator, this still allows us to reduce the number of catalytic variables. Let Q n ( t ; C ; d , . . . , d n )denote the polynomial P n ( t ; C, D ) where every entry of the n × n matrices C and D are powers of t and every row in D is [ d , . . . , d n ]. We derive an analogous functional equation: Q n ( t ; C ; d , . . . , d n ) = n X i =1 c i, c i, . . . c i − i,i · Q n − ( t ; R ( C, D, i ); d , . . . , d i − , td i d i +1 , d i +2 , . . . , d n ) . (FE2341c)Using this recurrence to compute Q n ( t ; ; 1 [ n times]) will yield the desired polynomial f n ( t ). Thisapproach allows us to deal with n ( n + 1) / n catalytic variables (as opposed to n ( n + 1) such11ariables).Additionally, for a fixed r , the sequence s n (2341 , r ) can be computed by applying Lemma 2 andthe CHOP r operator as necessary. This has been implemented in the procedure F2341rN(r,N) (inthe Maple package F2341 ).For example, the Maple call F2341rN(1,15); for the first 15 terms of s n (2341 , 1) produces thesequence:0 , , , , , , , , , , , , , , F2341rN(2,15); for the first 15 terms of s n (2341 , 2) produces the sequence:0 , , , , , , , , , , , , , , . . . k 1. Analogous functional equations can be derived and used for enu-meration. One of the most commonly studied permutation statistic is the inversion number. The inversionnumber of a permutation π = π . . . π n , denoted by inv( π ), is the number of pairs ( i, j ) such that1 ≤ i < j ≤ n and π i > π j . Equivalently, it is the number of occurrences of the pattern 21 in π .For a (fixed) pattern τ , define the polynomial g n ( t, q ) := X π ∈S n q inv( π ) t N τ ( π ) . (6)Observe that g n ( t, 1) is exactly f n ( t ) from before.Given a permutation π = π . . . π n , suppose that π = i . Then, inv( π ) is equal to the numberof inversions in π . . . π n plus the number of elements in π , . . . , π n that are less than i . For anypreviously defined functional equation, it is enough to insert a q i − factor in the summation.For example, if the fixed pattern is τ = 132, the polynomial P n can be analogously defined as P n ( t, q ; x , . . . , x n ) := X π ∈S n q inv( π ) · weight ( π )and the analog to functional equation (FE132) would be P n ( t, q ; x , . . . , x n ) = n X i =1 q i − x x . . . x i − · P n − ( t, q ; x , . . . , x i − , tx i +1 , . . . , tx n ) . Similarly, the analogous functional equation to (FE231c) would be Q n ( t, q ; c , . . . , c n ) = n X i =1 q i − c c . . . c i − i · Q n − ( t, q ; c , . . . , c i − , tc i c i +1 , c i +2 , . . . , c n ) . qF123r(n,r,t,q) and qF1234r(n,r,t,q) (inMaple package FINCR ), qF132r(n,r,t,q) and qF1243r(n,r,t,q) (in Maple package FINCRT ), qF231r(n,r,t,q) (in Maple package F231 ), and qF2341r(n,r,t,q) (in Maple package F2341 ). In the preceding sections, various functional equations were derived by considering the first termof a typical permutation and deriving a recurrence. Given any collection of patterns where suchrecurrences can be derived, we can also consider those patterns simultaneously.As an example, consider the patterns σ = 123 and τ = 132. The case of only the pattern 123was done in [14]. In this setting, the weight of a permutation π = π . . . π n is defined byweight ( π ) := t N ( π ) n Y i =1 x { ( a,b ) : π a = i<π b , ≤ a
Noonan-Zeilberger Functional Equation )is P n ( t ; x , . . . , x n ) = n X i =1 x n − ii P n − ( t ; x , . . . , x i − , tx i +1 , . . . , tx n ) . (NZFE)This can be merged with the analogous quantities for 132 as follows. Let s and t be the variablescorresponding to 123 and 132, respectively. Let x , . . . , x n and y , . . . , y n be two sets of catalyticvariables, and define the weight of a permutation π = π . . . π n byweight( π ) := s N ( π ) t N ( π ) n Y i =1 x { ( a,b ) : π a = i<π b , ≤ aπ b = i, ≤ a
F123n132 . For example, the Maple call F123r132sN(2,2,15); gives the first 15 terms of the sequence enumerating permutations with 2occurrences of 123 and 2 occurrences of 132:0 , , , , , , , , , , , , , , F123r132sN(4,2,15); gives the first 15 terms of the sequence enumeratingpermutations with 4 occurrences of 123 and 2 occurrences of 132:0 , , , , , , , , , , , , , , F1234n1243 .Finally, it is possible to consider all length 3 patterns simultaneously. Only the patterns 123,132, and 231 were done directly, but analogous functional equations can be derived for 321, 312,and 213. These six functional equations can be combined to count occurrences of all the length3 patterns. This has been implemented in the Maple package FS3 . For example, the Maple call FS3full(7,[t[1],t[2],t[3],t[4],t[5],t[6]]); would produce the polynomial X π ∈S t N ( π )1 t N ( π )2 t N ( π )3 t N ( π )4 t N ( π )5 t N ( π )6 in its computed and expanded form. In this work, we extended and generalized the techniques of [14] to the pattern families 12 . . . ( k − k )( k − 1) and 23 . . . k 1. In addition, we showed how this approach could be further extended tohandle inversions and more generally, multiple patterns simultaneously. It would be interesting tosee what additional patterns this approach can be applied to. Also, while the main results of thispaper are enumeration algorithms, they are based off of rigorously derived functional equations.It would be interesting to find out if any additional information can be extracted from these func-tional equations.Finally, the techniques of this paper allow us to compute many sequences that lead to new con-jectures. Let c r,s ( n ) be the number of length n permutations with exactly r occurrences of 1234and exactly s occurrences of 1243. We will denote this as c ( n ) when r and s is clear from context.When r = s = 0, it is known that c ( n ) is exactly the Schr¨oder numbers. For fixed r, s ≤ 1, we arealmost certain that c ( n ) is P-recursive (the algorithm can compute enough terms to guess a recur-rence). On the other hand, for the single pattern case, it is not clear if s n (1234 , 1) is P-recursive [14].Based off of empirical evidence, we also believe the following to be true: Conjecture 1. Given fixed r ≥ and s ≥ , let a ( n ) be the number of length n permutationswith exactly r occurrences of and s occurrences of . Then, there exists a polynomial p ( n ) of degree r + s such that a ( n ) = p ( n )2 n for all n ≥ r + s + 1 . This conjecture has been empirically checked for all r + s ≤ 10. There are some results con-sidering this type of problem, but most such results limit themselves to s = 0 , 1. For example,Robertson [18] derives closed form expressions for a ( n ) when r = 0 , s = 0 , 1, and otherauthors [19, 12] derive more general generating functions for a ( n ) when s = 0. If this general formwere shown to hold for arbitrary r and s , the F123n132 package could quickly compute enoughterms to find explicit formulas and generating functions. The actual output from Maple is too large to include here. We were able to compute up to FS3full(11,[t[1],t[2],t[3],t[4],t[5],t[6]]); , which is a 450 megabyte text file. This is a special case of the Noonan-Zeilberger Conjecture from [16]. cknowledgments : The author owes many thanks to Doron Zeilberger for the helpful discussionson this topic. The author also needs to thank the anonymous referees for their corrections andcomments toward improving this article. References [1] Andrew Baxter. Refining enumeration schemes to count according to the inversion number. Pure Math. Appl. (PU.M.A.) , 21(2):137–160, 2010.[2] Andrew Baxter and Lara Pudwell. Enumeration schemes for vincular patterns. DiscreteMath. , 312(10):1699–1712, 2012.[3] Mikl´os B´ona. A new upper bound for 1324-avoiding permutations. arxiv:1207.2379 [math.co],2012.[4] Mikl´os B´ona. The number of permutations with exactly r P -recursive inthe size! Adv. in Appl. Math. , 18(4):510–522, 1997.[5] Mikl´os B´ona. Permutations with one or two 132-subsequences. Discrete Math. , 181(1-3):267–274, 1998.[6] Alexander Burstein. A short proof for the number of permutations containing pattern 321exactly once. Electron. J. Combin. , 18(2):Paper 21, 3, 2011.[7] David Callan. A recursive bijective approach to counting permutations containing 3-letterpatterns. arxiv:math/0211380 [math.co], 2002.[8] Anders Claesson, V´ıt Jel´ınek, and Einar Steingr´ımsson. Upper bounds for the Stanley-Wilflimit of 1324 and other layered patterns. J. Combin. Theory Ser. A , 119(8):1680–1691, 2012.[9] Markus Fulmek. Enumeration of permutations containing a prescribed number of occurrencesof a pattern of length three. Adv. in Appl. Math. , 30(4):607–632, 2003.[10] Sergey Kitaev and Toufik Mansour. A survey on certain pattern problems. University ofKentucky research report 2003-09 , 2003.[11] Donald E. Knuth. The art of computer programming . Vol. 1: Fundamental algorithms.Addison Wesley, Reading, Massachusetts, 1973.[12] Toufik Mansour and Alek Vainshtein. Restricted permutations, continued fractions, andChebyshev polynomials. Electron. J. Combin. , 7:Research Paper 17, 9 pp. (electronic), 2000.[13] Toufik Mansour and Alek Vainshtein. Counting occurrences of 132 in a permutation. Adv. inAppl. Math. , 28(2):185–195, 2002.[14] Brian Nakamura and Doron Zeilberger. Using Noonan-Zeilberger functional equations toenumerate (in polynomial time!) generalized Wilf classes. Adv. in Appl. Math. , 50(3):356–366, 2013.[15] John Noonan. The number of permutations containing exactly one increasing subsequence oflength three. Discrete Math. , 152(1-3):307–313, 1996.[16] John Noonan and Doron Zeilberger. The enumeration of permutations with a prescribednumber of “forbidden” patterns. Adv. in Appl. Math. , 17(4):381–407, 1996.1517] Lara Pudwell. Enumeration schemes for permutations avoiding barred patterns. Electron. J.Combin. , 17(1):Research Paper 29, 27, 2010.[18] Aaron Robertson. Permutations containing and avoiding 123 and 132 patterns. Discrete Math.Theor. Comput. Sci. , 3(4):151–154 (electronic), 1999.[19] Aaron Robertson, Herbert S. Wilf, and Doron Zeilberger. Permutation patterns and continuedfractions. Electron. J. Combin. , 6:Research Paper 38, 6 pp. (electronic), 1999.[20] Vince Vatter. Enumeration schemes for restricted permutations. Combin. Probab. Comput. ,17(1):137–159, 2008.[21] Doron Zeilberger. Enumeration schemes and, more importantly, their automatic generation.