Combinatorial specifications for juxtapositions of permutation classes

We show that, given a suitable combinatorial specification for a permutation class $\mathcal{C}$, one can obtain a specification for the juxtaposition (on either side) of $\mathcal{C}$ with Av(21) or Av(12), and that if the enumeration for $\mathcal{C}$ is given by a rational or algebraic generating function, so is the enumeration for the juxtaposition. Furthermore this process can be iterated, thereby providing an effective method to enumerate any 'skinny' $k\times 1$ grid class in which at most one cell is non-monotone, with a guarantee on the nature of the enumeration given the nature of the enumeration of the non-monotone cell.


Introduction
A phenomenon observed both in the practical enumeration of specific permutation classes and in the study of growth rates is that in many classes, the entries of any permutation in the class can be partitioned in such a way as the pattern formed by the entries in each part lies in some specified proper subclass.
As well as very general compositions such as the merge of two classes (exemplified by the class Av(321), being the merge of two increasing sequences), one more restrictive (but nonetheless ubiquitous) instance of this phenomenon is the juxtaposition of two classes, first considered by Atkinson [4].
In this paper, we consider the effect on combinatorial specifications of juxtapositions.The juxtaposition of two permutations can be thought of as a special kind of merge, in which only the values of the two permutations can be interleaved arbitrarily, and not the positions.However, our primary motivation in studying juxtapositions is towards a generalisation in another direction, namely the broader study of grid classes.
Our main result is as follows.Definitions are given in Section 2, but we note here that context-free specifications give rise to algebraic generating functions, while regular ones give rational generating functions.
(i) If S tracks the rightmost entry, then there exists a combinatorial specification for C|M that tracks the rightmost entry.
(ii) Similarly, if S tracks the leftmost entry, then there exists one for M|C that tracks the leftmost entry.
(iii) If S tracks both the leftmost and the rightmost entries, then there exists specifications for C|M and M|C that do.
(iv) If S is context-free (resp.regular), then the specifications for C|M and M|C are context-free (regular).
Since the resulting specifications satisfy the same conditions as the theorem requires of C, the process can be iterated, thereby allowing us to generate combinatorial specifications for classes of the form given in Figure 1.Corollary 1.2.If a permutation class C possesses a specification S that tracks the rightmost and leftmost entries, then so does any k × 1 grid class of the form given in Figure 1.In particular, if C possesses an algebraic or rational generating function, then so too does the k × 1 grid class.
Permutation classes to which our method applies include any class C that contains only finitely many simple permutations, but it is not limited to this (for example, in Section 4 we present a suitable specification for Av(321)).By its nature, there is a parallel between our bottom-to-top specifications and the insertion encoding of Albert, Linton and Ruškuc [3], and we explore this further in Section 4.
Prior to this paper, the most general result for k × 1 grids concerns the case where the class C above is itself also monotone.Such grid classes were called 'skinny' grid classes by Bevan [7,Chapter 3], where he demonstrates an iterative technique for enumerating any k × 1 grid in which all the cells are monotone.Indeed, the enumeration of such classes was also studied under the term 'monotone segment sets' by Albert, Atkinson and Ruškuc [2], where it was shown that all such classes can be encoded in a regular language, and hence possess rational generating functions.Meanwhile, the process of juxtaposing some permutation class C with a monotone one plays a key role in the classification of possible growth rates, since each such juxtaposition has a growth rate that is precisely one more than that of C, see Vatter [15] and Bevan [8].
More recently, in [12] the current authors enumerated all juxtapositions of the form C|M where C is a 'Catalan' class (i.e. one of the classes avoiding a single length 3 permutation, all of which are enumerated by the Catalan numbers), and M is monotone.Our approach in this article is different from the technique employed in that earlier paper, and is considerably more general.
Our method is fully constructive, and relies on operators that act on the equations of the combinatorial specification.Thus, it could be used for practical enumeration tasks, although each application typically results in a sixfold-increase in the number of equations of the specification.Perhaps a more significant consequence of our approach is the general theory, offering a guarantee of the nature of combinatorial specifications and their related enumerations, which could be used to inform future development of algorithms such as TileScope and its underpinning CombSpecSearcher, see Bean's PhD thesis [6].
The rest of this paper is organised as follows.Following some preliminary definitions and results in Section 2, the proof of Theorem 1.1 is given in Section 3. In Sections 4 and 5, we present a number of classes to which this method applies, and demonstrate the process by computing the specifications and enumerations of three specific juxtaposition classes.Some concluding remarks are given in Section 6.

Combinatorial specifications and permutation classes
We will begin by covering a few of the most pertinent basic definitions relating to the study of permutations, but refer the reader to Bevan's introduction [10] for others.We say that a permutation σ is contained in another π, and write σ ≤ π if there is a subsequence of π that is order-isomorphic to σ, i.e. a subsequence of the entries of π possesses the same relative ordering as the entries of σ.A permutation class is a set of permutations that is closed under the permutation containment ordering, that is, if C is a permutation class, π ∈ C and σ ≤ π, then we must have σ ∈ C.
If there is no subsequence of π order-isomorphic to σ, then we say that π avoids σ.A permutation class can be defined by its unique minimal avoidance set, which we call the basis.We write C = Av(B) to mean that C is the permutation class comprising all permutations that avoid every permutation in B, C = Av(B) = {π : π ∈ β for all β ∈ B}.
We will also typically drop the set braces in this notation, thus writing, e.g., Av(321) instead of Av({321}).

Combinatorial classes and specifications
where C is a countable set of combinatorial objects, e.g.permutations, and | • | : C → Z + is a size function such that the number of objects of size n in C is finite.In this paper, we will primarily be concerned with combinatorial classes which are sets of permutations. 1 However, we will periodically need to consider related objects which will be in bijection with some set of permutations.Formally, we say that two combinatorial classes are combinatorially isomorphic if their counting sequences are identical.This is equivalent to the existence of a size-preserving bijection between the two classes.Following Flajolet and Sedgewick [14], given a combinatorial class C, a combinatorial specification for C is a system of equations where each f i is a constructor that only involves admissible operations acting on the classes S 1 , . . ., S r , the atom Z and the empty class E. The only admissible operations we will consider are the combinatorial sum +, Cartesian product ×, and the sequence construction Seq(•).Crucially, note that these admissible operations are not necessarily commutative, and indeed we will assume throughout that the Cartesian product is noncommutative.
For convenience, throughout this paper we will write equations such as those in the above specification as S i = f i (V ), where V = {S 1 , . . ., S r } is the set of classes.Note that we have omitted the empty class E and any atoms: the function f i may depend on these implicitly.
We are particularly interested in certain types of combinatorial specifications, in which the constructors f i satisfy certain additional conditions.We highlight two in particular here: Regular A combinatorial specification for C is regular if the constructors involve only atoms and the three admissible operations +, × and Seq(•).
Context-free A combinatorial specification for C is context-free if the constructors use only the admissible operations + and ×.
It is possible to see the family of context-free specifications as more general than regular specifications by observing that the equation S Z = E + S Z × Z is combinatorially isomorphic to S Z = Seq(Z ), i.e. the sequence construction.Indeed, in what follows we will periodically use the class S Z , together with its context-free combinatorial specification, to correspond to Seq(Z ).
The attraction of regular and context-free specifications is due to the following two results: Proposition 2.1 (See, e.g.Proposition I.2 [14]).A combinatorial class that has a regular specification admits a rational (ordinary) generating function.
Theorem 2.2 (Chomsky-Schutzenberger [13]).A combinatorial class C that has a context-free specification admits an algebraic (ordinary) generating function C(z).In other words, there exists a (non-null) bivariate polynomial P(z, y) ∈ C[z, y] such that P(z, C(z)) = 0. Bottom-to-top specifications We say that a combinatorial specification of a permutation class C is bottom-to-top if in the specification, the left-to-right reading order of the atoms and classes in a term corresponds to the order of the entries of the permutations in the class, reading from bottom to top.
(Recall that the Cartesian product is noncommutative.)For example, the term 'Z CCD' in a bottomto-top specification refers to permutations which, from bottom to top, can be seen as an atom Z, followed by two instances of elements from C, followed by an element from D. A typical example of how this might arise is illustrated in Figure 2.

Greedy griddings and atoms
We will be working with operators that act on bottom-to-top combinatorial specifications of a class C, and produce new combinatorial specifications for the class C|M or M|C (i.e. for C juxtaposed by a monotone class M to its right or left).A challenge in this process is to ensure that each permutation in such a juxtaposition has a unique representation in the resulting combinatorial specification.Our solution will be to greedily add as many entries as possible into the monotone class M. For this to work, the operators need to know whether the bottom-to-top reading of the specification has encountered the rightmost (for C|M) or leftmost (for M|C) entry of C. See Figure 3 for an illustration.
To this end, we will use four different atoms: In addition to the standard atom Z to represent generic entries of a permutation, we may use Z L to identify the left-most entry and Z R the right-most entry.The fourth atom, Z LR , represents an entry that is simultaneously both leftmost and rightmost, and thus can only occur to represent the singleton permutation.
Clearly, each term in a combinatorial specification can have at most one leftmost atom and one rightmost atom, and it will be helpful to decorate the classes in the specification with L, R or LR to indicate when these atoms are present or not present.For example, C L represents a class in which the leftmost atom Z L is used exactly once in each permutation (but Z R is not used).
We say that a class C admits a combinatorial specification that tracks the rightmost entry if there exists a bottom-to-top specification for C R .Note that in moving from combinatorial specifications to generating functions, the four atoms all make the same contribution z.Thus Proposition 2.1 and Theorem 2.2 remain valid, and we can still use the terms 'regular' and 'context-free' to refer to specifications involving all the different atoms.

Operators and the proof of Theorem 1.1
To describe the process by which we transform a combinatorial specification for C into one for a juxtaposition of C with a monotone class M, we begin by considering only the juxtaposition C| Av(21).We will later describe symmetry operators that allow us to obtain the other possible juxtapositions.
We can think of the juxtaposition of C with Av(21) as the entries of C, with sequences of monotone entries inserted vertically in-between (but horizontally to the right).Let x be any entry of a permutation π ∈ C. The gap associated with x is the vertical space immediately below x and above the entry immediately below (if it exists) -see Figure 4.In addition, the top gap is the vertical space above the highest point of C.
x Figure 4: The shaded region on the RHS corresponds to the gap associated with x.
Lemma 3.1.Let C be a permutation class with a combinatorial specification that tracks the rightmost entry.
Then the juxtaposition C| Av( 21) is combinatorially isomorphic to the class C with (possibly empty) sequences of atoms inserted in the gaps, such that there is at least one nonempty gap no higher than the atom Z R of C.
Proof.First, by the comments made before the statement of the lemma it is clear that the juxtaposition C| Av(21) can be thought of as sequences of monotone entries inserted into the gaps (including the top gap) of a (possibly empty) permutation from C.
It remains to ensure that we consider each permutation in C| Av(21) at most once, and for this we use the greedy gridding described in the previous section to include as many entries in the monotone part as possible.Let π ∈ C| Av(21), and write π = στ such that σ ∈ C, and τ is as large as possible subject to τ ∈ Av(21).First, if σ is empty, then π = τ ∈ Av(21) is either empty or an increasing permutation, which can be thought of as the insertion of a sequence into the top gap of the empty permutation ǫ.
Otherwise, both σ and τ are nonempty, and thus the rightmost entry of σ must be above at least one entry of τ.Since Z R tracks the rightmost entry of σ in a bottom-to-top specification, the greedy gridding condition translates to the requirement that there is at least one entry of τ in some gap below Z R , as required.
To produce the combinatorial specification representing this insertion of sequences of entries into the gaps of permutations from C, we will define operators that are sensitive to the atom Z R to ensure the conditions of Lemma 3.1 are satisfied.Specifically, we will distinguish between an operator which inserts the lowest entry in Av(21), and operators that insert (possibly empty) sequences of entries above this.
Furthermore, the claim made in Theorem 1.1 requires us to output a combinatorial specification for C| Av(21) that tracks the rightmost point.By our choice of greedy gridding this rightmost point must lie in Av(21), and is therefore created by the process of applying operators.Thus, we will also distinguish between an operator which inserts the rightmost ( = highest) entry Z R in some gap, and an operator that acts on gaps below this.
To this end, we define the following linear operators.
Ω ǫ the null operator: inserts no entries, but replaces Z R with Z in its operand (if it appears).
Ω • inserts a single point (lowest and highest entry) in some gap of its operand below Z R .
Ω •• inserts (possibly empty) increasing sequences of entries in the gaps of its operand.
Ω •• inserts the lowest entry in some gap of its operand (below the operand atom Z R ), followed by (possibly empty) increasing sequences of entries in the subsequent gaps.
Ω •• inserts (possibly empty) increasing sequences of entries in the gaps of its operand, finishing with the insertion of a new rightmost atom Z R in some (non-topmost) gap.
Ω •• inserts the lowest entry in some gap of its operand (below the operand atom Z R ), followed by (possibly empty) increasing sequences of entries in the subsequent gaps, and finishing with the insertion of a new rightmost atom Z R .
For convenience later, let We will defer the description of the action of the operators in O until later, except to define their action on the neutral atom E. The two operators that add potentially empty sequences of points, namely Ω ǫ and Ω •• , act as the identity on E, whereas the other four annihilate the term entirely; this convention is simply to ensure that later expressions involving combinatorial sums and Cartesian products are consistent.
Let C be a class given by a combinatorial specification which tracks the rightmost entry, and let M = Av(21).Then the class C|M is given by Furthermore, if C = C L also tracks the leftmost entry, then the class C L |M is given by Proof.Let π ∈ C|M be nonempty, and take the leftmost gridding π = π C π M .If π C is empty, then π is a monotone increasing sequence of points, and this is captured by the term S Z × Z R , so we now assume that π C is non-empty.Observe that, by the greedy gridding, there is at least one entry in π M .
If there is precisely one, then there must be at least one entry of π C above it, and this is captured by the term Ω • (C).
We may now suppose that there are at least two entries in π M .If all the entries in M lie in gaps associated with entries from π C , then π lies in Ω •• (C).
On the other hand, if one or more entries lie in the top gap, then Z R lies in this gap and is the topmost entry, preceded by a (possibly empty) sequence of atoms.Below the top gap, we must insert the lowest entry of π M (which must be below the rightmost entry of π C ), followed by a (possibly empty) sequence, interleaved with the entries of π C .This accounts for the final term.
The case where C = C L also tracks the leftmost entry follows similarly; indeed, the only difference is in handling the case where the portion π C of π is empty.
Thus in order to describe the class C| Av(21), we need to understand terms such as To do this, we can use the given combinatorial specification for the class C. In other words, we will be applying our operators to equations, each of which is built from a combination of +, × and Seq(•) of other combinatorial classes (which have their own specifications) and atoms.
We need to document precisely the effect these six operators have on their operands; this is carried out in the next three subsections.As the operators act linearly, and having described the effect on the neutral atom E earlier, we have three main tasks: to describe (1) the action on the four atoms, (2) the action over Cartesian products, and (3) the action over the sequence constructor.

The action on the four atoms
The complete list of actions is given below, followed by a short narrative to explain the terms.Recall that S Z = E + S Z Z = Seq(Z ) represents sequences of the atom Z. Operand For an operand that is one of the four atoms, the operators Finally, we have also listed explicitly the action on the operands Z L and Z LR , although these are broadly analogous to Z and Z R .Such atoms will still be leftmost after the effect of the operator, but they will cease to be rightmost (even in the case of Ω ǫ ).

The action on Cartesian products
Whereas the operators all act linearly over combinatorial sums (+), their action on the Cartesian product of two (or more) classes is dependent upon whether they insert the lowest entry of the new cell or not.We will call those that do not insert the lowest entry (Ω ǫ , Ω •• and Ω •• ), Z R -invariant while the others are Z R -sensitive.We will describe the action of these two groups separately.
Note also that we have not mentioned explicitly the leftmost atom Z L (or the class containing it) of the operand.This is because the action on the Cartesian product of two or more classes is the same whether Z L is present or not.
Z R -invariant operators Operators which do not insert the lowest entry in the new cell act in the same way irrespective of whether the operand contains Z R or not.There are three such operators, namely Ω ǫ , Ω •• and Ω •• .Their action over Cartesian products is therefore defined by: for all classes A and B.2 Z R -sensitive operators The remaining three operators all insert the lowest entry of the cell, and are therefore sensitive to the position of the atom Z R .For the action on the product of two operators, we distinguish two cases: A × B where no term of A contains Z R , and A R × B where every term of A R contains exactly one Z R (or another class D R of the same form).
Note, in each case, that the only difference between the action on AB and the action on A R B is to lose the final term (involving Ω ǫ (A)).Such a term would correspond to inserting the lowest entry above the atom Z R , which is of course disallowed by the greedy gridding.

The action on sequences
In the case that we are given a regular specification, then we need to understand how the operators in O act on the sequence constructor, Seq.Note first that the atoms Z L , Z R and Z LR can never appear inside a Seq operator, since there can only ever be at most one copy of each of these types of atom in a term.Thus, in describing these actions we do not need to consider the Z R -sensitive operators separately. 3et A be an atom, class, or an expression involving combinatorial sums, Cartesian products and sequences of the atom Z and other classes not involving Z L , Z R or Z LR .It is routine to verify that the following expressions correctly describe the action of operators on the sequence construction.

Expansions
Let V be a collection of combinatorial classes, and let Ω ∈ O be an operator.Define V Ω = {Ω(S) : S ∈ V } to be the collection of combinatorial classes under the action of Ω, and Given an equation C = f (V ) from some combinatorial specification, we have (trivially), Ω(C) = Ω( f (V )).The expansion of Ω(C) is then the equation obtained by using the linearity of the operators and the expressions for atoms and Cartesian products given above, i.e. the equation of the form for some function g.See Figure 5 for an example.The properties of g are given in the next lemma.
Lemma 3.3.Let C = f (V ) be an equation from a combinatorial specification using only the combinatorial sum, Cartesian product and sequence constructors.Then, for every operator Ω ∈ O, the expansion of Ω(C) is an equation involving only the combinatorial sum, Cartesian product and sequence constructors, acting only on atoms and classes from V O ∪ {S Z }.
Furthermore, if C = f (V ) does not use the sequence constructor, then neither does the expansion of Ω(C).
Proof.First, any operator Ω ∈ O acts linearly on combinatorial sums so it suffices to consider the action of Ω on individual terms of f (V ).Such terms, however, are themselves composed of Cartesian products of classes in V or sequences of classes in V, and the rules for any operator in O described earlier in this subsection demonstrate that these can be rewritten as expressions involving combinatorial sums, Cartesian products and sequences of classes in V O .Note that the action of an operator Ω ∈ O on an atom is described in Subsection 3.1, and can be expressed as the Cartesian product of atoms and the class S Z .This completes the proof.
Finally, if there are no sequence constructors in the original equation, then the rules given earlier for operators in O guarantee that no sequence constructor will be introduced in the expansion of Ω(C).
With this result in place, we can now conclude the first piece of our main result.

D C R B
A Furthermore, if S is context-free, and/or tracks the leftmost entry, then so is S ′ .
Proof.First, let V denote the set of classes that appear on the left hand side of any equation in the specification S .Thus, any equation in S is of the form S = f (V ).
By Lemma 3.2, the class C| Av(21) is given by the equation We therefore need to establish a system of equations to describe the classes Ω • (C), Ω •• (C) and Ω •• (C), which taken together with the equation S Z = E + S Z Z, forms a complete combinatorial specification.We claim that it suffices to define the system of equations S ′ to comprise the following: Every class in V O is of the form Ω(S) for some Ω ∈ O and S ∈ V. Writing S = f (V ) (an equation taken from S ), by Lemma 3.3 the expansion of Ω(S) is an equation involving only combinatorial sums and Cartesian products of classes from V O ∪ {S Z }.Thus the system S ′ above is indeed a context-free combinatorial specification, providing S is.Furthermore, each term in the equation for C|M acts from bottom-to-top, and specifies the position of the rightmost entry Z R .
If the atom Z L and/or Z LR is present in the specification for C(= C L ), then, by definition, the operators in O ensure that Z L and/or Z LR are correctly tracked for C L |M.However, in this case we need to use the following expression for the class C L |M, given in Lemma 3.2: Analogously, we have the following result that guarantees a regular specification is obtained if the initial specification is regular.
Proposition 3.5.Let C be a permutation class, and S a regular combinatorial specification for C that tracks the rightmost entry.Then there exists a regular combinatorial specification S ′ that tracks the rightmost entry for C| Av(21).
Furthermore, if S tracks the leftmost entry, then so does S ′ .
Proof.We construct the specification S ′ from S following the proof of Proposition 3.4.We will omit the details as they are similar, the only exception being that we now need to use the defined actions of operators in O on sequences in the expansions.Note that S ′ will track the rightmost entry, and if S tracks the leftmost entry, then so does S ′ .
It remains to verify that S ′ is regular.Note that the right hand side of any equation in S involves only atoms, combined using the sum, Cartesian product and sequence operations.As such, by considering the effect of the operators in O, the expansion of an equation in S under some operator in O will yield an equation in S ′ also involving only sums, products and sequences of atoms, except for the appearance of the class S Z .This however, can be replaced by Seq(Z ) wherever it appears, whence the equation in S ′ satisfies the conditions to be regular.

Symmetry operators
Having established how to find a combinatorial specification for C| Av(21) given one for C, we now need to describe how to find specifications for C| Av (12), Av(21)|C and Av(12)|C.
Let π be a permutation of length n.The reverse of π, denoted π r , is the permutation obtained by reading the entries of π in reverse order, i.e. π r (i Combining these two operations, we obtain the reverse-complement, π rc , which is formally defined by By extension, we may consider the reverse, complement, and reverse-complement of a class C of permutations, for example C r = {π r : π ∈ C}.Given a bottom-to-top combinatorial specification for C, we can obtain a bottom-to-top specification for C c simply by reversing the order in which terms in a Cartesian product are taken.This is characterised by the complement operator, Θ, which acts linearly on combinatorial sums, as the identity on atoms (i.e.
and is then defined recursively on Cartesian products as follows: for classes A and B. The action on the sequence operator is given by Similarly, given a specification for C that tracks both the leftmost and rightmost entries, we can find one for C r by preserving the order in the Cartesian product, but switching the atoms Z R and Z L .This is characterised by the reverse operator, Φ, which acts linearly on combinatorial sums, distributively on Cartesian products (Φ(A × B) = Φ(A) × Φ(B)) and sequences (Φ(Seq(A)) = Seq(Φ(A))), and satisfies Note that if a class C tracks only the leftmost entry, then Φ(C) tracks only the rightmost entry and vice versa, and if C tracks both, then so does Φ(C).
Given some equation C = f (V ) from a combinatorial specification, the expansion of Θ(C) is the equation obtained by using the linearity of Θ, together with the defined action on Cartesian products, to obtain an equation of the form for some g.Similarly, the expansion of Φ(C) is the equation obtained following the definition of Φ above, Φ(C) = h(V Φ ) for some h.
We now have the following observation, mirroring Lemma 3.3.We omit its proof.
Lemma 3.7.Let C = f (V ) be an equation from a combinatorial specification using only the combinatorial sum, Cartesian product, and sequence constructors.Then the expansion of Θ(C) and Φ(C) are equations involving only the combinatorial sum, Cartesian product and sequence operators, acting only on classes from V Θ and V Φ , respectively.
Furthermore, if C = f (V ) does not contain any instance of a sequence operator, then neither does the expansion of Θ(C).
Similarly, we may combine these expansions to obtain combinatorial specifications for C c , C r and C rc .As its proof resembles (but is simpler than) the proof of Proposition 3.4, we will omit it.
Proposition 3.8.Let S be a combinatorial specification for a class C. Then there exist combinatorial specifications S Θ , S Φ and S Θ•Φ for the classes C c , C r and C rc , respectively.
Furthermore, if S tracks the rightmost (resp.leftmost) entry, then so does S Θ , while the specifications S Θ•Φ and S Φ track the leftmost (resp.rightmost) entry.
Equipped with Observation 3.6 and combinatorial specifications for C|M, C c , C r and C rc , we can now complete the proof of Theorem 1.1.
Proof of Theorem 1.1.By Proposition 3.4, if the combinatorial specification S for C tracks the rightmost entry, then there exists a specification for C| Av(21) that does.To complete the proof of part (i), therefore, we need to consider C| Av (12).
By Observation 3.6, we have C| Av(12) = (C c | Av(21)) c .By Proposition 3.8, there exists a combinatorial specification S Θ for C c .To this we apply Proposition 3.4 to obtain a combinatorial speci- fication for C c | Av(21).Finally, an application of Θ to this specification gives us a specification for (C c | Av(21)) c , which is combinatorially isomorphic to C| Av (12).Furthermore, all these specifications track the rightmost entry by Propositions 3.4 and 3.8.
Similar arguments can now be made to establish part (ii) of the theorem: Observation 3.6 gives us equations for Av(21)|C and Av(12)|C, and combinatorial specifications for these can then be computed using applications of Φ, Θ, and the operators in O.Note that if S tracks the leftmost entry, then by Proposition 3.8 S Φ and S Θ•Φ (being specifications C r and C rc ) track the rightmost entry (as required for the operators in O to append Av(21) to the right).After appending Av(21), a further application of Φ replaces the rightmost entry with the leftmost, while any application of Θ keeps the rightmost and leftmost atoms intact.
For part (iii), note that the operators Θ and those in O preserve the atom Z L , while Φ interchanges the atoms Z L and Z R , and both Θ and Φ preserve Z LR .Combined with Proposition 3.4, We conclude that the resulting combinatorial specifications for all of C| Av(21), C| Av(12), Av(21)|C and Av(12)|C also track both the leftmost and rightmost entries.
Finally, for part (iv), if S is context-free or rational, then it is clear that the operators Θ and Φ preserve this.We know that the operators in O preserve context-freeness by Proposition 3.4, and preserve rationality by Proposition 3.5.This completes the proof.

Applicable classes
In this section, we demonstrate classes which possess combinatorial specifications that track the rightmost and leftmost entries.
Classes containing finitely many simple permutations It has been known since Albert and Atkinson [1] that classes which possess only finitely many simple permutations admit an algebraic generating function.Subsequently, Brignall, Huczynska and Vatter [11] described a framework, called 'query-completeness' which concluded that many other subsets of permutations in a class with only finitely many simple permutations also have algebraic generating functions: in the language of this current article, this is done by constructing context-free specifications.
More recently, a fully algorithmic method to derive combinatorial specifications for permutation classes with only finitely many simple permutations was given by Bassino, Bouvel, Pierrot, Pivoteau, and Rossin [5], and we refer to that article for fuller details.
In terms of specifications, if π i ∈ C i , then the bottom-to-top inflation σ[π 1 , . . ., π |σ| ] T belongs to the product of classes C 1 × • • • × C |σ| .By virtue of the bottom-to-top inflation, this is compatible with bottom-to-top specifications.Furthermore, in order to track the rightmost entry of such an inflation, it is the rightmost entry of the permutation inflating the rightmost entry of σ, namely π σ(|σ|) .Similarly, the leftmost entry of this inflation is the leftmost entry of π σ (1) .
Proposition 4.1.Every class containing only finitely many simple permutations admits a combinatorial specification that track the leftmost and rightmost entries.
Proof.Let Si(C) denote the (finite) set of simple permutations in C, which for convenience we will assume includes the permutations 12 and 21.Consider some combinatorial specification S for C, as produced e.g. by the algorithm of Bassino et al [5].
Let V denote the set of classes and atoms arising in S , and consider any D ∈ V, specified by some equation D = f (V ).The function f comprises a combinatorial sum of finitely many terms, each of which arises from the inflation of a permutation in Si(C) by other classes from V (or is simply equal to an atom Z).For each such term, we replace the expression with the corresponding expression from the bottom-to-top inflation.Note that this amounts simply to reordering the classes in the term.By modifying the ordering of all terms in this way, we obtain a bottom-to-top specification S ′ for C. Now, in order to track the rightmost entry, we define V R = {D R : D ∈ V } to be the collection of classes that track the rightmost entry.For each D R ∈ V R , we copy the corresponding equation for D in S ′ , except that in each term (corresponding to the inflation of a simple permutation) we identify the rightmost class F , say, and replace it with F R .
A similar process can be carried out to track the leftmost entry as required, as well as tracking both the leftmost and rightmost entries.Combining all the equations thus described for V, V R , V L and V LR as required, we obtain a specification for C R (or C L , C LR ) satisfying the requirements of the proposition.
The class Av(321) Permutations of length n in Av(321) are in bijection with Dyck paths below the diagonal, starting at (0, 0) and ending at (n, n) via up (U) and right (R) steps.This bijection is well-known, and rather than present a formal definition we merely illustrate the process in Figure 6.In this bijection, the rightmost entry of a 321-avoider is the first right-to-left minimum, which occurs in the final 'corner', i.e. the first U step after the last R step. 4 Thus, the class of Dyck paths D satisfies the following combinatorial specification (taking the atoms to be R, U, and (to mark the 'rightmost corner Translating this to the permutation case (by mapping U to Z, U R to Z R , and ignoring R) yields the following specification: Insertion encodings Introduced by Albert, Linton and Ruškuc [3], the insertion encoding of a class is a method of constructing permutations in the class by repeatedly adding a new maximal element into a number of permitted active sites called slots.The addition of a new maximal element can be performed in one of four ways: fill the slot (F), insert to the right of a slot (R, leaving a slot to the left of the newly-inserted entry), insert to the left of a slot (L), or insert in the middle of a slot (M, leaving a slot on both sides of the newly-inserted entry).To these four basic letters, one typically uses indices to denote which slot (reading, e.g., from left to right) the action is performed on.For example, the permutation 3164752 is encoded by By their nature, insertion encodings for permutation classes are bottom-to-top processes.Thus, in order to include classes which possess specifications given by insertion encodings amongst those to whom our method can be applied, 5 it suffices to capture how to track the rightmost (and/or the leftmost) entry.
We make the following observation.
Lemma 4.2.In any insertion encoding of a permutation class, the rightmost entries of permutations in the class correspond to an F or R insertion into the rightmost gap.
For example, the following grammar (given in Albert,Linton, Ruškuc [3]) defines the insertion encoding of Av(312).(Note that, as there is only one active slot, we have omitted all indices.) To adapt this encoding to track the rightmost entry, we introduce two new symbols, F R and R R , corresponding to the insertion of the rightmost entry: thus, any word in this encoding has exactly one of these two symbols, occurring exactly once.The grammar becomes: where s R denotes the encoding for the class with the rightmost entry encoded separately.Converting to combinatorial specifications for the class Av(312), we obtain This specification can be simplified slightly by admitting the empty permutation into C: Similar modifications can be made to track the leftmost entry; we omit the details.

Examples
In this section, we give three examples of the application of our operators to derive combinatorial specifications (and hence enumerations) for juxtapositions.

Av(321) | Av(21)
Juxtaposing the 321-avoiding permutations with a monotone increasing sequence was first carried out by the current authors [12].We repeat that enumeration here using the rightmost-entry-tracking specification obtained in the previous section: From the specification above, together with the master equation, presentation.Similarly, we will also use the superscript + to denote non-empty sequences, thus we have, for example, S + Z = S Z Z = ZS Z and Seq + (A) = Seq(A)A.
Thus C| Av(21) = E + Z L S Z + S + Z Z L + Z L S + Z S + Z Seq(S + Z )S Z .
Momentarily evaluating this as a generating function, we have as expected.
We now turn to appending Av(21) to the left of C| Av(21).First, we need to apply the operators Φ and Θ to the specification above, yielding the following specification for Av This agrees with the expression given in Bevan's thesis [7, page 34].

Separable permutations
The following is an illustrated bottom-to-top specification for the class of non-empty separable permutations, Av(2413, 3142): where C ⊖ and C ⊕ denote the skew-indecomposable and sum-indecomposable permutations in C, respectively.The following specification then tracks the rightmost entry: Note that there are other specifications that carry out the same process, but this one has been chosen to minimise the number of combinatorial classes required in the final specification for the juxtaposition we will compute below, namely the juxtaposition of the separable permutations with the class Av(21).
To describe the complete specification for C R | Av(21) that tracks the rightmost entry requires 26 separate equations.Instead, here we will again drop the rightmost tracking in order to compute the generating function for C R | Av(21) using the simplified equation ( 1).This requires the following 11 equations (together with the equation for S Z , and the equation for the class itself).

Figure 1 :
Figure 1: The k × 1 grid classes in Corollary 1.2, in which C possesses a rightmost-and leftmost-entry tracking specification, and M i ∈ {Av(21), Av(12)} for all i = j.

Figure 2 :
Figure 2: An example of a class which would correspond to the term Z CCD in a bottom-to-top combinatorial specification.

Figure 3 :
Figure 3: The role of the rightmost point of the class C in fixing a greedy gridding for C|M.A gridline any further left would produce a basis element of M involving this entry.
add a (possibly empty) sequence of entries in the gap corresponding to the atom -this is represented by S Z .Operators that insert a new rightmost entry (namely Ω • , Ω •• and Ω •• ) insert the atom Z R immediately before the final atom Z (which corresponds to the same entry as the original operand).

Figure 5 :Proposition 3 . 4 .
Figure 5: The expansion of Ω •• (C) given the equation C = ABC R D is given by the combinatorial sum of the 9 terms above.

Figure 6 :
Figure 6: Moving from a Dyck path to its corresponding 321-avoider.