Revstack sort, zigzag patterns, descent polynomials of $t$-revstack sortable permutations, and Steingr\'imsson's sorting conjecture

In this paper we examine the sorting operator $T(LnR)=T(R)T(L)n$. Applying this operator to a permutation is equivalent to passing the permutation reversed through a stack. We prove theorems that characterise $t$-revstack sortability in terms of patterns in a permutation that we call $zigzag$ patterns. Using these theorems we characterise those permutations of length $n$ which are sorted by $t$ applications of $T$ for $t=0,1,2,n-3,n-2,n-1$. We derive expressions for the descent polynomials of these six classes of permutations and use this information to prove Steingr\'imsson's sorting conjecture for those six values of $t$. Symmetry and unimodality of the descent polynomials for general $t$-revstack sortable permutations is also proven and three conjectures are given.


Introduction
Let S n be the group of all permutations of {1, . . . , n}. The classical stack sort operator S on permutations [8] may be defined in two equivalent ways. One way is to define it as an operator on words representing permutations: S( ) = where is the empty permutation, S(x) = x where x is a word of length 1, and

S(LnR) = S(L)S(R)n
where n is the unique largest entry in the word LnR. Another way to define S is as the output of pushing π = π 1 · · · π n ∈ S n (from left to right) through a stack. The stack has the rule that an element may be above another element in the stack only if it is less than it. If the element at the top of the stack is not less than the next (leftmost) element of π which is to next enter the stack, then elements of the stack must be popped from the stack (to the left) until this is the case. This is illustrated in Figure 1 for the permutation π = 42513. Moving the permutation π = 42513 through the stack once to get S(π) = 24135. First, 4 is pushed onto the stack, followed by 2. Since 5 is larger than both 2 and 4, both are popped from the stack before 5 can be pushed onto it. 1 is then pushed onto the stack. As 3 is not less than 1, but is less than 5, 1 is popped from the stack, 3 is pushed onto the stack, and then all stack elements are popped from the stack.
It is clear that repeatedly applying S to a permutation will yield the identity permutation, and the operator S is therefore a sorting operator. The set of permutations which are sorted by at most one application of S is known to be the set of 231-avoiding permutations, and this result is often described as the first result in the combinatorics of permutation patterns. We will assume the reader is familiar with the basic terminology of permutation patterns [3]. Variants of this operation and their analysis have also thrown up interesting connections to other areas of discrete mathematics. Recently, the author in collaboration with others showed how the sorting operation B(LnR) = B(L)Rn describes one pass of the bubble-sort operator. Further to this, it was shown that permutations in S n which require at most t passes of B are in bijection with the set of ground state juggling sequences of period n with t balls [5].
In this paper, we will consider another variant of the stack sort operator. We will call this variant revstack sort and denote it by T = S •rev, where rev is the operation that reverses the list that it acts upon. We may write a recursion for T as we did for S above: Given π = LnR ∈ S n , T satisfies T (LnR) = T (R)T (L)n, T ( ) = , and T (x) = x where x is a word of length 1. For example, T (42513) = T (13)T (42)5 = T (1)3T (2)45 = 13245. An equivalent way to describe this operation is that it is what results when a permutation is fed backwards into a stack. For π = 42513, this is illustrated in Figure 2. This new sorting operation is interesting because it appears to be faster than stack sort in the following sense: Conjecture 1.1 (Steingrímsson's sorting conjecture [10]). For all 0 ≤ t ≤ n, |{π ∈ S n : S t (π) = id}| ≤ {π ∈ S n : T t (π) = id}|, where id is the identity permutation. Furthermore, this inequality is strict for all pairs (n, t) that satisfy 2 < t < n − 1.
In Section 2 we will define a t-zigzag of a permutation. We present theorems which tell us when permutations are and are not t-revstack sortable based on whether or not the permutation contains (certain types of) zigzags of certain degrees. In Section 3 we use the theorems of Section 2 to classify permutations of length n that are 1-revstack, 2-revstack, (n−3)-revstack and (n−2)revstack sortable. These classifications are then used to derive the descent polynomials which are the generating functions of the descent statistic on classes of t-revstack sortable permutations for t = 0, 1, 2, n − 3, n − 2 and n − 1.
These generating functions are then used in Section 4 to prove Steingrímsson's conjecture those six particular values of t. In Section 5 we prove symmetry and unimodality of the descent polynomials for the class of t-revstack sortable permutations, and conjecture log-concavity and real-rooted-ness of coefficients of our polynomials based on the evidence given in the Appendix.

Classification theorems and zigzag patterns
In this section we will present classification theorems which assist us in deciding whether or not a permutation is t-revstack sortable. These classifications are in terms of zigzags which are subsequences of values in the permutation. These will be used to classify particular classes of t-revstack sortable permutations.
Lemma 2.1. If π ∈ S n , 1 ≤ a < b ≤ n, and b precedes a in π, then a precedes b in T (π) Proof. Since b precedes a in π, a enters the stack before b. Since a < b, element a must have been popped from the stack before element b enters. Thus a precedes b in T (π). Lemma 2.2. Suppose that π ∈ S n , 1 ≤ a < b ≤ n, and a precedes b in π. Then b precedes a in T (π) if there exists c > b such that a precedes c and c precedes b in π. If no such c exists then a precedes b in T (π).
Proof. If there is an element c > b such that a precedes c and c precedes b in π, then b will be the first of the three elements to enter the stack. Since c > b, element b must be popped from the stack before c enters the stack. It is only after c enters the stack that a may enter the stack and be popped. Thus b precedes a in T (π).
If no such c exists then all elements that appear between a and b in π are less than b. Element b will enter the stack and remain in the stack while a enters. Element a must be popped before element b, therefore a precedes b in T (π).
Proof. Lemma 2.1 tells us that an inversion (b, a) in π becomes a non-inversion (a, b) in T (π). Lemma 2.2 tells us that a non-inversion (a, b) in π becomes an inversion (b, a) in T (π) iff an element c larger than both exists between the two in π. Thus if (b, a) is an inversion in T (π) then there exists c such that (a, c, b) is an occurrence of the pattern 132 in π. If (a, c, b) is a 132 pattern in π, then applying T one finds that b precedes a in T (π), thereby forming an inversion (b, a) in T (π).
Proof. A permutation π ∈ S n is in Revstack n,1 iff T (π) = id, which occurs iff T (π) has no inversions. Lemma 2.3 tells us this happens precisely when π is 132 avoiding. Proof. Lemmas 2.1-2.3 provide us with the following information about patterns in σ and T (σ). We will say '(x, y) in σ' to mean x precedes y in the the word representing the permutation σ, and '(x, y, z) in σ' to mean x precedes y and y precedes z in the word representing the permutation σ, etc . Rewriting these observations in terms of how entries appear in T (σ) first: Using these observations, if T (σ) contains (a, c, b) as a 132 pattern then the following hold: Since (a, c) in T (σ), either 2(i) (c, a) in σ, or 2(ii) (a, c) in σ and ∃ e > c such that (a, e, c) in σ. 3. Since (a, b) in T (σ), either 3(i) (b, a) in σ, or 3(ii) (a, b) in σ and ∃ f > b such that (a, f, b) in σ. Let us now check all possible combinations of 2(i), 2(ii), 3(i), and 3(ii). At the very end of the previous argument, we are told that there does not exist e > c such that (b, d, a, e, c) in σ. Since d is greater than c and less than e, this statement implies that there does not exist e > d such that (b, d, a, e, c) in σ. This implies part (ii) of the theorem. Definition 2.6. A k-zigzag pattern in a permutation π is a sequence z = (z 0 , . . . , z k+1 ) such that (a) z 0 > z 1 > z 2 > · · · > z k+1 , and (b) π −1 (z 2i ) < π −1 (z 0 ) < π −1 (z 2i−1 ) for all i ≥ 1.
A 0-zigzag pattern is an occurrence of the permutation pattern 21, and so the only permutation that contains no 0-zigzag pattern is the identity. A 1-zigzag pattern is an occurrence of the permutation pattern 132. A 2-zigzag pattern is either an occurrence of the permutation pattern 2413 or an occurrence of the permutation pattern 2431. A 3-zigzag pattern is illustrated in Figure 3.
Proof. If π contains no 1-zigzag pattern, then π avoids the pattern 132, which by Theorem 2.4 means T (π) = T 1 (π) = id. Therefore the result of the theorem is true for k = 1.
The proof will follow by induction. It will be sufficient to show that given π ∈ S n , π contains no k-zigzag pattern =⇒ T (π) contains no (k − 1)-zigzag pattern.
We will prove the contrapositive to the above statement: T (π) contains a (k − 1)-zigzag pattern =⇒ π contains a k-zigzag pattern.
Definition 2.8. Let z = (z 0 , . . . , z k+1 ) be a k-zigzag pattern in π ∈ S n . We will call z interrupted if there exists c > z 0 such that either (i) z 2a precedes c and c precedes z 2b in π for some a, b ≥ 1, or (ii) z 2a−1 precedes c and c precedes z 2b−1 in π for some a, b ≥ 1. Otherwise we will call z uninterrupted.
Proof. An uninterrupted 1-zigzag in a permutation π ∈ S n is an occurrence of the pattern 132. If π ∈ S n contains an occurrence of the pattern 132 then T (π) = id by Theorem 2.4. The theorem is true for k = 1. Now we claim that if π contains an uninterrupted k-zigzag, then T (π) contains an uninterrupted (k − 1)-zigzag. To see the validity of this claim consider the following. Let z = (z 0 , z 1 , . . . , z k+1 ) be the lexicographically largest k-zigzag in π that begins with z 0 that is uninterrupted. Let z odd = {z 2j−1 : j ≥ 1} and z even = {z 2j : j ≥ 1}.
All elements of z odd enter and leave the stack before z 0 does. There are no elements larger than z 0 among z odd in T (π) as z is uninterrupted (the elements among z odd in T (π) start by some element among z odd in π and end by the maximal element among z odd ). Similarly there are no elements larger than z 0 among z even in T (π).
Since z is the lexicographically largest k-zigzag with the desired properties, we know that there are no elements larger than z 1 among z even . Also z 1 is, by definition, the largest element of z odd that is less than z 0 (otherwise there would exist a lexicographically larger k-zigzag z which starts with z 0 in π). From this we know that z 1 is the rightmost element among z odd in T (π). The sequence (z 1 , . . . , z k+1 ) is therefore an uninterrupted (k − 1)-zigzag in T (π).
Iterating the above claim, we have that if π contains an uninterrupted k-zigzag, then T (π) contains an uninterrupted (k − 1)-zigzag, T 2 (π) contains an uninterrupted (k − 2)-zigzag, and T k (π) contains an uninterrupted 0-zigzag. An uninterrupted 0-zigzag is simply an inversion, so T k (π) contains an inversion and is therefore not the identity permutation.
The following result is the companion to West's result [12] which tells us that the set of 2-stack sortable permutations is S n (2341, 35241). Proof. Suppose that π ∈ S n with T 2 (π) = id. According to Theorem 2.11, π does not contain an uninterrupted 2-zigzag. There are two 2-zigzags: 2431 and 2413. The statement 'π does not contain an uninterrupted 2-zigzag' is equivalent to 'π does not contain a 2-zigzag, or if it does then it is interrupted', and this happens iff π ∈ S n (24351) ∩ S n (24153).

Descent polynomials
In this section we will determine the descent polynomial over Revstack n,k for several values of k relative to n. Given A ⊆ S n define It is straightforward to see that Revstack n,n−1 = S n and W (Revstack n,n−1 ; x) is therefore A n (x), the nth Eulerian polynomial. Proof. Recall that Stack n,1 = S n (231). Simion [9] showed that where N (n, k) = 1 n n k n k+1 are the well-known Narayana numbers. Theorem 2.4 showed that Revstack n,1 = S n (132). Since S n (132) is easily formed from S n (231) by reversing the elements, and by using the symmetry of the Narayana numbers N (n, k) = N (n, n − k − 1), we have x 1+des(rev(π)) = π∈Sn (231) x n−des(π) = W (Stack n,1 ; x).
Proof. By definition, Bouvel and Guibert [4, Thm. 1.3] recently showed that the descent statistic is equi-distributed on the sets {π ∈ S n : S • S(π) = id} and {π ∈ S n : S • rev • S(π) = id}. This means the final equality stemming from the fact that W (Stack n,2 ; x) is symmetric in the sense that [x k ]W (Stack n,2 ; x) = [x n+1−k ]W (Stack n,2 ; x) for all 1 ≤ k ≤ n. This symmetry is easily checked from the expression for W (Stack n,2 ; x) given in Dulucq et al. [7,Cor. 9].
Throughout the remainder of this section we will employ some new terminology. Given a set Many of our cases will involve [m] ↓2 for certain values m.
An (n − 3)-zigzag in a permutation π is a strictly decreasing sequence z = (z 0 , . . . , z n−2 ). Let us suppose that z is maximal in the sense that it is the lexicographically largest (n − 3)-zigzag in π. Because z contains n − 1 elements out of a possible n elements, and because it is strictly decreasing, it must be the sequence (n, n − 1, . . . , 1) with one element removed. We indicate this using a hat above the element that is removed: z = (n, n − 1, . . . ,î, . . . , 1).
To perform this classification, we must split the analysis into four distinct cases: (a) i = n (b) i = n − 1 (c) i = n − 2 and (d) 1 ≤ i ≤ n − 3. Case (a) i = n: In this case the (n − 3)-zigzag is (n − 1, n − 2, . . . , 1). Let π be π with n removed. Then π must be of the form L(n − 1)R where L ∈ Perm [n − 3] ↓2 and R ∈ Perm [n − 2] ↓2 . All that remains is to carefully check how the position of n in π changes the degree of π with respect to T . We must be careful that by inserting n in different places, the resulting permutation does not contain an (n − 2)-zigzag (as these were taken care of previously in Theorem 3.3).
Case (b) i = n − 1: In this case the maximal (n − 3)-zigzag is (n, n − 2, n − 3, . . . , 1). We will consider how the position of (n − 1) in π affects the degree of the resulting permutation. The permutation π must have the form (otherwise there will be a lexicographically larger (n − 3)-zigzag starting with (n, n − 1, . . .) which is forbidden).
Combining both sub-cases yields the following classification of permutations for this case: This case is in many ways similar to Case (c) so we only will highlight the main difference. It turns out that in order to obtain z maximal among (n − 3)-zigzags, the restriction in this case is that two consecutive elements of The class of these permutations given by this classification and for which deg T (π) = n − 2 is for all appropriate i ∈ [1, n/2] when n − i is odd, and for all appropriate i ∈ [1, n/2] when n − i is even.
The permutations in Equations 3.1-3.6 are all of the permutations π ∈ S n for which deg T (π) = n − 2. We will use these to calculate the descent polynomial (3.7) In some of the classifications of permutations, we see that the sum is over all permutations in a set except that the largest value must always be to the left or right of the second largest value. (See for example Equations 3.1 and 3.2.) To accommodate descent polynomials over these restricted sets we define: x 1+des(π) and L n (x) = π∈Sn π −1 (n)<π −1 (n−1) x 1+des(π) .
Clearly D n (x)+L n (x) = A n (x). In order to give an expression for D n (x) in terms of polynomials that we know, we do as follows. The polynomial D n (x) is the Eulerian distribution on length n permutations for which n is to the right of n − 1 in the permutation.
Split the sum over those permutations π ∈ S n for which (i) π n = n and (ii) π j = n for some 1 ≤ j ≤ n − 1. In the second case, there are n−2 j−2 ways of choosing the elements which precede n in π, because n − 1 must be one of them. Let us write π = π nπ . So we have where π = π nπ and Perms(X) is the set of all permutations of the elements in X. Clearly the first sum is A n−1 (x). Since des(π) = des(π ) + 1 + d(π ) for all 2 ≤ j ≤ n − 1, we have x 1+des(π) = x 1+des(π ) x 1+des(π ) . Replacing this in the second summation, we find Figure 5. Contributions to the descent polynomial from different cases.
The sums over all permutations in each of Equations 3.1-3.6 are given in the table in Figure 5, and their total noted in the final row. We thus have The statement of the theorem follows by substituting L n 2 (x) = A n 2 (x) − D n 2 (x).

Steingrímsson's conjecture
In this section we will use the results of Section 3 to prove Steingrímsson's conjecture (Conjecture 1.1) in some special cases.
First let us consider k = n − 2. West [12] enumerated the set Stack n,n−2 : |Stack n,n−2 | = n! − (n − 2)! If we set x = 1 in Theorem 3.3 then we find that The condition |Stack n,n−2 | ≤ |Revstack n,n−2 | is equivalent to • If n = 2m + 1 then this translates to m!m! ≤ (2m − 1)!, which is equivalent to 2m 1 ≤ 2m m , and this is true for all m ≥ 1. This is a strict inequality for m ≥ 2. • If n = 2m + 2 then this translates to m!(m + 1)! ≤ (2m)!, which is equivalent to , and this is true for all m ≥ 0. This is a strict inequality for m ≥ 2. The inequality 4.1 therefore holds true for all n ≥ 2 and so the conjecture is true for k = n − 2. Furthermore, the inequality is strict when n ≥ 5.

The descent polynomial of t-revstack sortable permutations
Let V t (n, i) and W t (n, i) be the sets of permutations in S n having i descents which are t-revstack sortable and t-stack sortable, respectively. Let us write v t (n, i) = |V t (n, i)| and w t (n, i) = |W t (n, i)| so that Bóna [1,2] proved symmetry and unimodality of the numbers w t (n, i) with respect to the descent parameter, i.e. w t (n, i) = w t (n, n − 1 − i) for all 0 ≤ i ≤ n − 1, and w t (n, 0) ≤ w t (n, 1) ≤ . . . ≤ w t (n, (n − 1)/2 ) ≥ . . . ≥ w t (n, n − 1).
In this section we will do the same for the numbers v t (n, i). Symmetry is proven by showing that the reflection operation on permutations commutes with Bóna's [1] duality map. Unimodality is proven by using the same argument of Bóna [1,2] and showing that his function z : W t (n, i) → W t (n, i + 1) is injective for all 0 ≤ i ≤ n−3 2 and preserves t-revstack sortability.
Proof. Bóna's duality map [1, Section 2] f : S n → S n is defined in the following recursive way. Note that permutations are written as words, and the definition is necessarily a definition on words. The value n stands for the unique largest value in a word. • • f (nR) = f (R)n. Let us recall Bóna's method of proof of symmetry. He showed [1,Lemma 2.6] that f preserves the t-stack sortable property: from which he concludes that π is t-stack sortable iff f (π) is t-stack sortable. He also showed [1, Proposition 2.5] that des(π) + des(f (π)) = n − 1 (5.2) for all π ∈ S n . Combining these two observations: applying f to permutations in S n that are t-stack sortable gives another permutation that is t-stack sortable, but which has n − 1 − des(π) descents, i.e. there is symmetry in the descent statistic. The reverse operation rev : S n → S n is defined recursively via • rev( ) = • rev(LnR) = rev(R)nrev(L) where n is the largest value in the word LnR. It is easy (by induction on the length of the word) to see that f • rev = rev • f = g where g is defined as follows: . The operator f preserves the t-revstack sortable property since T (π) = S(rev(π)) = S(f (rev(π))) by applying Bóna's equation 5.1 above, = S(rev(f (π))) since f commutes with rev, = T (f (π)).
This fact, in conjunction with equation 5.2, gives the stated result.
Proof. This proof is a slight modification of Bóna's unimodality proof of the number sequence (w t (n, i)) n−1 i=0 (see [1,Section 3] and [2]). Let S des=i n be the set of permutations in S n that have i descents. Let T (n, i) be the set of decreasing binary trees on n vertices whose label set is {1, . . . , n} and which have i right edges.
The sets S des=i n and T (n, i) are in one-to-one correspondence, and we write Tree(π) for the tree in T (n, i) that corresponds to π ∈ S des=i n using the following rule: x is a left (resp. right) child of y in Tree(π) iff x is the largest value to the left (resp. right) of y in π and which is less than it. (One easily recovers the permutation π from Tree(π) by reading its labels using in-order traversal, and des(π) equals the number of right edges in Tree(π).) Bóna proved unimodality by exhibiting an function h : T (n, i) → T (n, i + 1) that is injective for all i ≤ n−3 2 and preserves the t-stack sortable property. Due to the bijective correspondence between S des=i n and T (n, i) (outlined in the previous paragraph), the injective function h is equivalent to a function h : W t (n, i) → W t (n, i + 1) that is injective for all 0 ≤ i ≤ n−3 2 and for all t.
Index the vertices of the tree from bottom to top, and within every level from left to right. This starts by labeling the bottom-most vertex on the left hand side v 1 . If there is a vertex on the same level and to its right then label it vertex v 2 , but otherwise go up one level and label the leftmost vertex v 2 , and so forth. The labeling of Tree(π) in Figure 6 is given in Figure 7.  Determine the minimum value of i such that the number of left edges in T i is precisely one more than the number of right edges in T i . (Bóna proved the existence of such an i using a continuity argument [2].) In our example this minimum value is i = 9.
Next we look at the vertices in Tree(π) that are both part of T i and have only either a left or a right child (but not both). If such a vertex has a left child, then move it to be a right child instead. If such a vertex has a right child, then move it to be a left child instead. Let the resulting tree be h (Tree(π)).
For example, the nodes in Tree(π) that are part of T 9 and which have only left or right children (but not both) are v 5 , v 7 and v 9 . Consequently h (Tree(π)) is illustrated in Figure 9.
To summarise: the function h : S des=i Bóna then showed that h preserves the t-stack sortable property: S(π) = S(h(π)). This was done by noting that S(π) is given by reading the tree Tree(π) using post-order traversal. The post-order reading of the tree is the same even after the application of the operator h on Tree(π) because h only changes the direction of subtrees that are the only-children of nodes, and therefore preserves the post-order reading.
The same argument holds in our case, and all we need to show in order to prove the theorem is that h preserves the t-revstack sortable property: T (π) = T (h(π)). To do this, let us define the rpostorder traversal of a tree as the list one obtains by first listing the rpostorder of its right subtree, then the rpostorder of the left subtree, and then finally listing the label of the root node. The rpostorder of the tree Tree(π) is then T (π). Since h only changes the orientation of subtrees that are only-children of nodes, the rpostorder reading of h (Tree(π)) is the same as the rpostorder reading of Tree(π).
The coefficients of the two smallest and two largest powers of x in W (Revstack n,t ; x) and W (Stack n,t ; x) are always the same. This follows from symmetry and using the following results. Note that the coefficient of x in both is always unity because Revstack n,0 = Stack n,0 = {id} which means v t (n, 0) = w t (n, 0) = 1.
Proving real-rootedness and log-concavity of the coefficient sequences of the descent polynomials for t-stack sortable permutations remains an unsolved problem. We present companion conjectures for revstack sort that have been verified for all 0 ≤ t < n ≤ 10. All such polynomials, along with their roots, are listed in the appendix.
Conjecture 5.4. For all n ≥ 1, the polynomial W (Revstack n,t ; x) has only real non-positive roots.
Conjecture 5.5. For all n ≥ 1, the sequence of coefficients of the polynomial W (Revstack n,t ; x) is log-concave.
Note that a proof of Conjecture 5.4 would imply Conjecture 5.5.

Concluding Remarks
(1)Úlfarsson [11] recently classified 3-stack sortable permutations in terms of a new type of permutation pattern that he called decorated patterns. Can a similar analysis be performed for the case of 3-revstack sortable permutations? The stack sort operator preserves a certain left-to-rightness, whereas this is not the case for revstack. (2) In the paper [6] the author (in collaboration with two others) classified and enumerated (n − 4)-stack sortable permutations. It was proven that |Stack n,n−4 | = (n − 4)!(3n 4 − 18n 3 − 4n 2 + 158n − 192)/3. Determining those permutations that are (n − 4)-revstack sortable would appear to be tractable but most likely hard. Enumerating this class would allow for Steingrímsson's conjecture to be proven for t = n − 4. (3) How many permutations π ∈ S n contain no t-zigzag? How many permutations π ∈ S n contain no uninterrupted t-zigzag? Answers to these questions will provide bounds on the number of t-revstack sortable permutations.