\section{Introduction}\label{sec-intro}

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 \emph{merge} of two classes (exemplified by the class $\operatorname{Av}(321)$, being the merge of two increasing sequences), one more restrictive (but nonetheless ubiquitous) instance of this phenomenon is the \emph{juxtaposition} of two classes, first considered by Atkinson~\cite{atkinson:restricted-perm:}. For a recent comprehensive survey of the study of permutation patterns, and particularly notions of structure, see Vatter's chapter in the \emph{Handbook of enumerative combinatorics}~\cite{vatter:survey}.

Formally, let $\sigma$ and $\tau$ be (possibly empty) permutations. A permutation $\pi=\pi(1)\cdots\pi(n)$ of length $n$ is a \emph{juxtaposition of $\sigma$ with $\tau$} if there exists an index $i$ such that $\pi(1)\cdots \pi(i)$ is order-isomorphic to $\sigma$, and $\pi(i+1)\cdots\pi(n)$ is order-isomorphic to $\tau$. The \emph{juxtaposition} of two classes or sets of permutations $\mathcal{C}$ and $\mathcal{D}$ is then defined by
\[ \mathcal{C}\mid\mathcal{D} = \{\pi : \pi \text{ is a juxtaposition of }\sigma\in\mathcal{C}\cup\{\epsilon\}\text{ with }\tau\in\mathcal{D}\cup\{\epsilon\}\}.\]
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 \emph{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 \emph{grid classes}.

Our main result is as follows. Definitions are given in Section~\ref{sec-prelim}, but we note here that context-free specifications give rise to algebraic generating functions, while regular ones give rational generating functions.

\begin{theorem}\label{thm:main}
Let $\mathcal{C}$ be a permutation class that admits a bottom-to-top combinatorial specification $\ensuremath{\mathscr{S}}$, and let $\ensuremath{\mathcal{M}} \in\{\operatorname{Av}(21),\operatorname{Av}(12)\}$.
\begin{enumerate}[(i)]
\item\label{item:CM} If $\ensuremath{\mathscr{S}}$ tracks the rightmost entry, then there exists a combinatorial specification for $\mathcal{C}\mid\ensuremath{\mathcal{M}}$ that tracks the rightmost entry.
\item\label{item:MC} Similarly, if $\ensuremath{\mathscr{S}}$ tracks the leftmost entry, then there exists one for $\ensuremath{\mathcal{M}}\mid\mathcal{C}$ that tracks the leftmost entry.
\item\label{item:leftright} If $\ensuremath{\mathscr{S}}$ tracks both the leftmost and the rightmost entries, then there exists specifications for $\mathcal{C}\mid\ensuremath{\mathcal{M}}$ and $\ensuremath{\mathcal{M}}\mid\mathcal{C}$ that do.
\item\label{item:contextfree} If $\ensuremath{\mathscr{S}}$ is context-free (resp. regular), then the specifications for $\mathcal{C}\mid\ensuremath{\mathcal{M}}$ and $\ensuremath{\mathcal{M}}\mid\mathcal{C}$ are context-free (regular).
\end{enumerate}
\end{theorem}

Since the resulting specifications satisfy the same conditions as the theorem requires of $\mathcal{C}$, the process can be iterated, thereby allowing us to generate combinatorial specifications for classes of the form given in Figure~\ref{fig:k-by-one}.
\begin{figure}[h]
\begin{center}
\begin{tikzpicture}
\draw (0,0) grid (1.2,1);
\draw (2.8,0) grid (6.2,1);
\draw (7.8,0) grid (9,1);
\foreach \i in {1,6} {%
  \draw[dashed] (\i,0) -- (\i+2,0);
  \draw[dashed] (\i,1) -- (\i+2,1);
}
\node[empty] at (0.5,0.5) {$\ensuremath{\mathcal{M}}_1$};
\node[empty] at (3.5,0.5) {$\ensuremath{\mathcal{M}}_{j-1}$};
\node[empty] at (4.5,0.5) {$\mathcal{C}$};
\node[empty] at (5.5,0.5) {$\ensuremath{\mathcal{M}}_{j+1}$};
\node[empty] at (8.5,0.5) {$\ensuremath{\mathcal{M}}_k$};
\node[empty] at (2,0.5) {$\cdots$};
\node[empty] at (7,0.5) {$\cdots$};
\end{tikzpicture}
\end{center}
\caption{The $k\times 1$ grid classes in Corollary~\ref{cor:skinny}, in which $\mathcal{C}$ possesses a rightmost- and leftmost-entry tracking specification, and $\ensuremath{\mathcal{M}}_i \in\{\operatorname{Av}(21),\operatorname{Av}(12)\}$ for all $i\neq j$.}
\label{fig:k-by-one}
\end{figure}

\begin{corollary}\label{cor:skinny}
If a permutation class $\mathcal{C}$ possesses a specification $\ensuremath{\mathscr{S}}$ that tracks the rightmost and leftmost entries, then so does any $k\times 1$ grid class of the form given in Figure~\ref{fig:k-by-one}. In particular, if $\mathcal{C}$ possesses an algebraic or rational generating function, then so too does the $k\times 1$ grid class.
\end{corollary}

Permutation classes to which our method applies include any class $\mathcal{C}$ that contains only finitely many simple permutations, but it is not limited to this (for example, in Section~\ref{sec-applicable-classes} we present a suitable specification for $\operatorname{Av}(321)$). By its nature, there is a parallel between our bottom-to-top specifications and the insertion encoding of Albert, Linton and Ru\v{s}kuc~\cite{albert:the-insertion-e:}, and we explore this further in Section~\ref{sec-applicable-classes}.

Prior to this paper, the most general result for $k\times 1$ grids concerns the case where the class $\mathcal{C}$ above is itself also monotone. Such grid classes were called `skinny' grid classes by Bevan~\cite[Chapter 3]{bevan:phd}, where he demonstrates an iterative technique for enumerating any $k\times 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\v{s}kuc~\cite{albert:regular-closed-:}, 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 $\mathcal{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 $\mathcal{C}$, see Vatter~\cite{vatter:every-growth-rate:} and Bevan~\cite{bevan:intervals}.

More recently, in~\cite{bs:juxt-catalan} the current authors enumerated all juxtapositions of the form $\mathcal{C}\mid\ensuremath{\mathcal{M}}$ where $\mathcal{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 $\ensuremath{\mathcal{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 \textsc{TileScope} and its underpinning \textsc{CombSpecSearcher}, see Bean's PhD thesis~\cite{bean:thesis}.

The rest of this paper is organised as follows. Following some preliminary definitions and results in Section~\ref{sec-prelim}, the proof of Theorem~\ref{thm:main} is given in Section~\ref{sec-operators}. In Sections~\ref{sec-applicable-classes} and~\ref{sec-examples}, 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~\ref{sec-conclusion}.

\section{Combinatorial specifications and permutation classes}\label{sec-prelim}

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~\cite{bevan2015defs} for others. We say that a permutation $\sigma$ is \emph{contained} in another $\pi$, and write $\sigma\leq\pi$ if there is a subsequence of $\pi$ that is \emph{order-isomorphic} to $\sigma$, i.e.\ a subsequence of the entries of $\pi$ possesses the same relative ordering as the entries of $\sigma$. A \emph{permutation class} is a set of permutations that is closed under the permutation containment ordering, that is, if $\mathcal{C}$ is a permutation class, $\pi\in\mathcal{C}$ and $\sigma\leq \pi$, then we must have $\sigma\in \mathcal{C}$.

If there is no subsequence of $\pi$ order-isomorphic to $\sigma$, then we say that $\pi$ \emph{avoids} $\sigma$. A permutation class can be defined by its unique minimal avoidance set, which we call the \emph{basis}. We write $\mathcal{C}=\operatorname{Av}(B)$ to mean that $\mathcal{C}$ is the permutation class comprising all permutations that avoid every permutation in $B$,
\[\mathcal{C} = \operatorname{Av}(B) = \{\pi:\pi\not\leq \beta \text{ for all }\beta\in B\}.\]
We will also typically drop the set braces in this notation, thus writing, e.g., $\operatorname{Av}(321)$ instead of $\operatorname{Av}(\{321\})$.

\paragraph{Combinatorial classes and specifications}
A \emph{combinatorial class} is a pair $(\mathcal{C},|\cdot|)$ where $\mathcal{C}$ is a countable set of combinatorial objects, e.g.~permutations, and $|\cdot|:\mathcal{C} \to \mathbb{Z}^{+}$ is a size function such that the number of objects of size $n$ in $\mathcal{C}$ is finite. In this paper, we will primarily be concerned with combinatorial classes which are sets of permutations.\footnote{In an unfortunate clash of notation, note that a `combinatorial class of permutations' need not be a `permutation class' as it need not be downwards-closed.} 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 \emph{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~\cite{flajolet:analytic-combin:}, given a combinatorial class $\mathcal{C}$, a \emph{combinatorial specification} for $\mathcal{C}$ is a system of equations
\[\left\{\begin{array}{r@{}l@{}}
      \mathcal{C} = \S_1 &= f_1(\mathcal{E},\mathcal{Z},\S_1,\ldots,\S_r)\\
      &\vdots\\
      \S_r &= f_r(\mathcal{E},\mathcal{Z},\S_1,\ldots,\S_r)
\end{array}\right.\]
where each $f_i$ is a constructor that only involves \emph{admissible} operations acting on the classes $\S_1,\dots,S_r$, the atom $\mathcal{Z}$ and the empty class $\mathcal{E}$. The only admissible operations we will consider are the combinatorial sum $+$, Cartesian product $\times$, and the sequence construction $\textsc{Seq}(\cdot)$. 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(\ensuremath{\mathcal{V}})$, where $\ensuremath{\mathcal{V}} = \{\S_1,\dots,\S_r\}$ is the set of classes. Note that we have omitted the empty class $\mathcal{E}$ and any atoms: the function $f_i$ may depend on these implicitly.

A priori, the constructors $f_i$ in a combinatorial specification could define recurrences that are (for example) tautological, or impossible to solve. By placing additional conditions on the constructors $f_i$, we can restrict our view to certain types of combinatorial specifications which can always be solved. We highlight two in particular here:
\begin{description}
\item[Regular]
A combinatorial specification for $\mathcal{C}$ is \emph{regular} if the constructors involve only atoms and the three admissible operations $+$, $\times$ and $\textsc{Seq}(\cdot)$.
\item[Context-free]
A combinatorial specification for $\mathcal{C}$ is \emph{context-free} if the constructors use only the admissible operations $+$ and $\times$.
\end{description}

It is possible to see the family of context-free specifications as more general than regular specifications by observing that the equation $\S_{\mathcal{Z}} = \mathcal{E} + \S_{\mathcal{Z}}\times \mathcal{Z}$ is combinatorially isomorphic to $\S_{\mathcal{Z}}=\textsc{Seq}(\mathcal{Z})$, i.e.\ the sequence construction. Indeed, in what follows we will periodically use the class $\S_{\mathcal{Z}}$, together with its context-free combinatorial specification, to correspond to $\textsc{Seq}(\mathcal{Z})$.

The attraction of regular and context-free specifications is due to the following two results:

\begin{proposition}[See, e.g.\ Proposition I.2~\cite{flajolet:analytic-combin:}]\label{prop:regular}
A combinatorial class that has a regular specification admits a rational (ordinary) generating function.
\end{proposition}

\begin{theorem}[Chomsky-Schutzenberger~\cite{chomsky:the-algebraic-t:}]
\label{thm:chomsky}
A combinatorial class $\mathcal{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) \in \mathbb{C}[z,y]$ such that $P(z,C(z)) = 0$.
\end{theorem}

\begin{figure}[t]
  \centering
  \begin{tikzpicture}
    \draw (-0.5,0.5) rectangle (0.5,1.5) node[pos=0.5]{$\ensuremath{\mathcal{D}}$};
    \draw (-3,-0.5) rectangle (-2,0.5) node[pos=0.5]{$\mathcal{C}$};
    \draw (-1.5,-1.5) rectangle (-0.5,-0.5) node[pos=0.5]{$\mathcal{C}$};
    \filldraw[black] (-2,-2) circle (2pt);
    \draw (-1.6,-2.2) node {$\mathcal{Z}$};
  \end{tikzpicture}
  \caption{An example of a class which would correspond to the term $\mathcal{Z}\mathcal{C}\C\mathcal{D}$ in a bottom-to-top combinatorial specification.}
  \label{fig:order}
\end{figure}

\paragraph{Bottom-to-top specifications}
We say that a combinatorial specification of a permutation class $\mathcal{C}$ is \emph{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 `$\mathcal{Z}\mathcal{C}\C\mathcal{D}$' in a bottom-to-top specification refers to permutations which, from bottom to top, can be seen as an atom $\mathcal{Z}$, followed by two instances of elements from $\mathcal{C}$, followed by an element from $\mathcal{D}$. A typical example of how this might arise is illustrated in Figure~\ref{fig:order}.

\subsection{Greedy griddings and atoms}
We will be working with operators that act on bottom-to-top combinatorial specifications of a class $\mathcal{C}$, and produce new combinatorial specifications for the class $\mathcal{C}\mid\ensuremath{\mathcal{M}}$ or $\ensuremath{\mathcal{M}}\mid\mathcal{C}$ (i.e.\ for $\mathcal{C}$ juxtaposed by a monotone class $\ensuremath{\mathcal{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 $\ensuremath{\mathcal{M}}$. For this to work, the operators need to know whether the bottom-to-top reading of the specification has encountered the rightmost (for $\mathcal{C}\mid\ensuremath{\mathcal{M}}$) or leftmost (for $\ensuremath{\mathcal{M}}\mid\mathcal{C}$) entry of $\mathcal{C}$. See Figure~\ref{fig:leftmostgridline} for an illustration.
\begin{figure}
  \centering
  \begin{tikzpicture}[scale=0.2]
\plotperm{9,1,7,2,11,26,16,12,17,23,18,25,24,3,4,5,6,8,10,13,14,15,19,20,21,22}
\node[permpt,fill=black!0] at (24) {};
\draw[black, thick] (13.5,0.5) -- (13.5,26.5);
\end{tikzpicture}
\caption{The role of the rightmost point of the class $\mathcal{C}$ in fixing a greedy gridding for $\mathcal{C}\mid\ensuremath{\mathcal{M}}$. A gridline any further left would produce a basis element of $\ensuremath{\mathcal{M}}$ involving this entry.}
\label{fig:leftmostgridline}
\end{figure}

To this end, we will use four different atoms: In addition to the standard atom $\mathcal{Z}$ to represent generic entries of a permutation, we may use $\Z^{\mathsf{L}}$ to identify the left-most entry and $\Z^{\mathsf{R}}$ the right-most entry. The fourth atom, $\Z^{\mathsf{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 $\mathsf{L}$, $\mathsf{R}$ or $\mathsf{LR}$ to indicate when these atoms are present or not present. For example, $\C^{\mathsf{L}}$ represents a class in which the leftmost atom $\Z^{\mathsf{L}}$ is used exactly once in each permutation (but $\Z^{\mathsf{R}}$ is not used).

We say that a class $\mathcal{C}$ admits a combinatorial specification that \emph{tracks the rightmost entry} if there exists a bottom-to-top specification for $\C^{\mathsf{R}}$. Note that in moving from combinatorial specifications to generating functions, the four atoms all make the same contribution $z$. Thus Proposition~\ref{prop:regular} and Theorem~\ref{thm:chomsky} remain valid, and we can still use the terms `regular' and `context-free' to refer to specifications involving all the different atoms.

\section{Operators and the proof of Theorem~\ref{thm:main}}\label{sec-operators}

To describe the process by which we transform a combinatorial specification for $\mathcal{C}$ into one for a juxtaposition of $\mathcal{C}$ with a monotone class $\ensuremath{\mathcal{M}}$, we begin by considering only the juxtaposition $\mathcal{C}\mid\operatorname{Av}(21)$. We will later describe symmetry operators that allow us to obtain the other possible juxtapositions.

We can think of the juxtaposition of $\mathcal{C}$ with $\operatorname{Av}(21)$ as the entries of $\mathcal{C}$, with sequences of monotone entries inserted vertically in-between (but horizontally to the right). Let $x$ be any entry of a permutation $\pi\in\mathcal{C}$. The \emph{gap} associated with $x$ is the vertical space immediately below $x$ and above the entry immediately below (if it exists) -- see Figure~\ref{fig:xregion}. In addition, the \emph{top gap} is the vertical space above the highest point of $\mathcal{C}$.

\begin{figure}[ht]
  \centering
  \begin{tikzpicture}
  \node[permpt] at (1,2) {};
  \node[permpt] at (2,4) {};
  \node[permpt] at (3,1) {};
  \node[permpt,label=above left:$x$] at (4,3) {};

    \draw[draw=none, thick, pattern=north west lines] (4.5,2) rectangle (6.5,3);

    \draw[black, thick] (4.5,0) -- (4.5,4.5);
    \draw[thin] (2.2,4)--(6.5,4);
    \draw[thin] (4.2,3)--(6.5,3);
    \draw[thin] (1.2,2)--(6.5,2);
    \draw[thin] (3.2,1)--(6.5,1);
  \end{tikzpicture}
  \caption{The shaded region on the RHS corresponds to the gap associated with $x$.}
  \label{fig:xregion}
\end{figure}

\begin{lemma}\label{lem:zr}
Let $\mathcal{C}$ be a permutation class with a combinatorial specification that tracks the rightmost entry. Then the juxtaposition $\mathcal{C}\mid\operatorname{Av}(21)$ is combinatorially isomorphic to the class $\mathcal{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^{\mathsf{R}}$ of $\mathcal{C}$.
\end{lemma}

\begin{proof}
First, by the comments made before the statement of the lemma it is clear that the juxtaposition $\mathcal{C}\mid\operatorname{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 $\mathcal{C}$.

It remains to ensure that we consider each permutation in $\mathcal{C}\mid\operatorname{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 $\pi\in\mathcal{C}\mid\operatorname{Av}(21)$, and write $\pi = \sigma\tau$ such that  $\sigma\in\mathcal{C}$, and $\tau$ is as large as possible subject to $\tau\in\operatorname{Av}(21)$.  First, if $\sigma$ is empty, then $\pi=\tau\in\operatorname{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 $\epsilon$.

Otherwise, both $\sigma$ and $\tau$ are nonempty, and thus the rightmost entry of $\sigma$ must be above at least one entry of $\tau$. Since $\Z^{\mathsf{R}}$ tracks the rightmost entry of $\sigma$ in a bottom-to-top specification, the greedy gridding condition translates to the requirement that there is at least one entry of $\tau$ in some gap below $\Z^{\mathsf{R}}$, as required.
\end{proof}

To produce the combinatorial specification representing this insertion of sequences of entries into the gaps of permutations from $\mathcal{C}$, we will define operators that are sensitive to the atom $\Z^{\mathsf{R}}$ to ensure the conditions of Lemma~\ref{lem:zr} are satisfied. Specifically, we will distinguish between an operator which inserts the lowest entry in $\operatorname{Av}(21)$, and operators that insert (possibly empty) sequences of entries above this.

Furthermore, the claim made in Theorem~\ref{thm:main} requires us to output a combinatorial specification for $\mathcal{C}\mid\operatorname{Av}(21)$ that tracks the rightmost point. By our choice of greedy gridding this rightmost point must lie in $\operatorname{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^{\mathsf{R}}$ in some gap, and an operator that acts on gaps below this.

To this end, we define the following linear operators.
\begin{description}
\item[$\Omega_\o$] the null operator: inserts no entries, but replaces $\Z^{\mathsf{R}}$ with $\mathcal{Z}$ in its operand (if it appears).
\item[$\Omega_\i$] inserts a single point (lowest and highest entry) in some gap of its operand below $\Z^{\mathsf{R}}$.
\item[$\Omega_\oo$] inserts (possibly empty) increasing sequences of entries in the gaps of its operand.
\item[$\Omega_\io$] inserts the lowest entry in some gap of its operand (below the operand atom $\Z^{\mathsf{R}}$), followed by (possibly empty) increasing sequences of entries in the subsequent gaps.
\item[$\Omega_\oi$] inserts (possibly empty) increasing sequences of entries in the gaps of its operand, finishing with the insertion of a new rightmost atom $\Z^{\mathsf{R}}$ in some (non-topmost) gap.
\item[$\Omega_\ii$] inserts the lowest entry in some gap of its operand (below the operand atom $\Z^{\mathsf{R}}$), followed by (possibly empty) increasing sequences of entries in the subsequent gaps, and finishing with the insertion of a new rightmost atom $\Z^{\mathsf{R}}$.
\end{description}
For convenience later, let $\mathcal{O} = \{\Omega_\o,\Omega_\i,\Omega_\oo,\Omega_\io,\Omega_\oi,\Omega_\ii\}$ denote the set of operators.

We will defer the description of the action of the operators in $\mathcal{O}$ until later, except to define their action on the neutral atom $\mathcal{E}$. The two operators that add potentially empty sequences of points, namely $\Omega_\o$ and $\Omega_\oo$, act as the identity on $\mathcal{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.
\begin{align*}
\Omega_\o(\mathcal{E}) &= \Omega_\oo(\mathcal{E}) = \mathcal{E}\\
\Omega_\i(\mathcal{E}) &= \Omega_\io(\mathcal{E}) = \Omega_\oi(\mathcal{E}) = \Omega_\ii(\mathcal{E}) = 0.
\end{align*}

\begin{lemma}\label{lem:CM}
Let $\mathcal{C}$ be a class given by a combinatorial specification which tracks the rightmost entry, and let $\ensuremath{\mathcal{M}}=\operatorname{Av}(21)$. Then the class $\mathcal{C}\mid\ensuremath{\mathcal{M}}$ is given by \[\mathcal{C}\mid\ensuremath{\mathcal{M}}=\mathcal{E}+\S_{\mathcal{Z}}\times\Z^{\mathsf{R}}+\Omega_\i(\mathcal{C})+\Omega_\ii(\mathcal{C})+\Omega_\io(\mathcal{C})\times \S_{\mathcal{Z}}\times\Z^{\mathsf{R}},\]
where $\S_{\mathcal{Z}} = \mathcal{E} + \S_{\mathcal{Z}}\times\mathcal{Z} = \textsc{Seq}(\mathcal{Z})$.

Furthermore, if $\mathcal{C}=\C^{\mathsf{L}}$ also tracks the leftmost entry, then the class $\C^{\mathsf{L}}\mid\ensuremath{\mathcal{M}}$ is given by
\[\C^{\mathsf{L}}\mid\ensuremath{\mathcal{M}}=\mathcal{E}+\Z^{\mathsf{LR}} +\Z^{\mathsf{L}}\times\S_{\mathcal{Z}}\times\Z^{\mathsf{R}}+\Omega_\i(\C^{\mathsf{L}})+\Omega_\ii(\C^{\mathsf{L}})+\Omega_\io(\C^{\mathsf{L}})\times \S_{\mathcal{Z}}\times\Z^{\mathsf{R}}.\]
\end{lemma}

\begin{proof}
Let $\pi\in \mathcal{C}\mid\ensuremath{\mathcal{M}}$ be nonempty, and take the leftmost gridding $\pi=\pi_\mathcal{C}\pi_\ensuremath{\mathcal{M}}$. If $\pi_\mathcal{C}$ is empty, then $\pi$ is a monotone increasing sequence of points, and this is captured by the term $\S_{\mathcal{Z}}\times\Z^{\mathsf{R}}$, so we now assume that $\pi_\mathcal{C}$ is non-empty. Observe that, by the greedy gridding, there is at least one entry in $\pi_\ensuremath{\mathcal{M}}$. If there is precisely one, then there must be at least one entry of $\pi_\mathcal{C}$ above it, and this is captured by the term $\Omega_\i(\mathcal{C})$.

We may now suppose that there are at least two entries in $\pi_\ensuremath{\mathcal{M}}$. If all the entries in $\ensuremath{\mathcal{M}}$ lie in gaps associated with entries from $\pi_\mathcal{C}$, then $\pi$ lies in $\Omega_\ii(\mathcal{C})$.

On the other hand, if one or more entries lie in the top gap, then $\Z^{\mathsf{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 $\pi_\ensuremath{\mathcal{M}}$ (which must be below the rightmost entry of $\pi_\mathcal{C}$), followed by a (possibly empty) sequence, interleaved with the entries of $\pi_\mathcal{C}$. This accounts for the final term.

The case where $\mathcal{C}=\C^{\mathsf{L}}$ also tracks the leftmost entry follows similarly; indeed, the only difference is in handling the case where the portion $\pi_\mathcal{C}$ of $\pi$ is empty.
\end{proof}

Thus in order to describe the class $\mathcal{C}\mid\operatorname{Av}(21)$, we need to understand terms such as $\Omega_\i(\mathcal{C})$, $\Omega_\ii(\mathcal{C})$ and $\Omega_\io(\mathcal{C})$. To do this, we can use the given combinatorial specification for the class $\mathcal{C}$. In other words, we will be applying our operators to equations, each of which is built from a combination of $+$, $\times$ and $\textsc{Seq}(\cdot)$ 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 $\mathcal{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.

\subsection{The action on the four atoms}\label{subsec:atoms}
The complete list of actions is given below, followed by a short narrative to explain the terms. Recall that $\S_{\mathcal{Z}} = \mathcal{E}+\S_{\mathcal{Z}}\mathcal{Z} = \textsc{Seq}(\mathcal{Z})$ represents sequences of the atom $\mathcal{Z}$.
\[
\begin{array}{c|c|c|c|c|c|c}
\text{Operand}&\Omega_\o&\Omega_\i&\Omega_\oo&\Omega_\io&\Omega_\oi&\Omega_\ii\\\hline
\mathcal{Z}&\mathcal{Z}&\Z^{\mathsf{R}}\mathcal{Z}&\S_{\mathcal{Z}}\mathcal{Z}&\mathcal{Z}\S_{\mathcal{Z}}\mathcal{Z}&\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z}&\mathcal{Z}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z}\\
\Z^{\mathsf{R}}&\mathcal{Z}&\Z^{\mathsf{R}}\mathcal{Z}&\S_{\mathcal{Z}}\mathcal{Z}&\mathcal{Z}\S_{\mathcal{Z}}\mathcal{Z}&\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z}&\mathcal{Z}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z}\\\hline
\Z^{\mathsf{L}}&\Z^{\mathsf{L}}&\Z^{\mathsf{R}}\Z^{\mathsf{L}}&\S_{\mathcal{Z}}\Z^{\mathsf{L}}&\mathcal{Z}\S_{\mathcal{Z}}\Z^{\mathsf{L}}&\S_{\mathcal{Z}}\Z^{\mathsf{R}}\Z^{\mathsf{L}}&\mathcal{Z}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\Z^{\mathsf{L}}\\
\Z^{\mathsf{LR}}&\Z^{\mathsf{L}}&\Z^{\mathsf{R}}\Z^{\mathsf{L}}&\S_{\mathcal{Z}}\Z^{\mathsf{L}}&\mathcal{Z}\S_{\mathcal{Z}}\Z^{\mathsf{L}}&\S_{\mathcal{Z}}\Z^{\mathsf{R}}\Z^{\mathsf{L}}&\mathcal{Z}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\Z^{\mathsf{L}}\\
\end{array}
\]

For an operand that is one of the four atoms, the operators $\Omega_\oo$, $\Omega_\io$, $\Omega_\oi$ and $\Omega_\ii$ all add a (possibly empty) sequence of entries in the gap corresponding to the atom -- this is represented by $\S_{\mathcal{Z}}$. Operators that insert a new rightmost entry (namely $\Omega_\i$, $\Omega_\oi$ and $\Omega_\ii$) insert the atom $\Z^{\mathsf{R}}$ immediately before the final atom $\mathcal{Z}$ (which corresponds to the same entry as the original operand).

Finally, we have also listed explicitly the action on the operands $\Z^{\mathsf{L}}$ and $\Z^{\mathsf{LR}}$, although these are broadly analogous to $\mathcal{Z}$ and $\Z^{\mathsf{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 $\Omega_\o$).

\subsection{The action on Cartesian products}\label{subsec:cartesian}

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 ($\Omega_\o$, $\Omega_\oo$ and $\Omega_\oi$),  \emph{$\Z^{\mathsf{R}}$-invariant}  while the others are $\Z^{\mathsf{R}}$-sensitive. We will describe the action of these two groups separately.

Note also that we have not mentioned explicitly the leftmost atom $\Z^{\mathsf{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^{\mathsf{L}}$ is present or not.

\paragraph{$\Z^{\mathsf{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^{\mathsf{R}}$ or not. There are three such operators, namely $\Omega_\o$, $\Omega_\oo$ and $\Omega_\oi$. Their action over Cartesian products is therefore defined by:
\begin{align*}
\Omega_\o(\mathcal{A}\mathcal{B}) &= \Omega_\o(\mathcal{A})\Omega_\o(\mathcal{B})\\
\Omega_\oo(\mathcal{A}\mathcal{B}) &= \Omega_\oo(\mathcal{A})\Omega_\oo(\mathcal{B})\\
\Omega_\oi(\mathcal{A}\mathcal{B}) &= \Omega_\oi(\mathcal{A})\Omega_\o(\mathcal{B})+\Omega_\oo(\mathcal{A})\Omega_\oi(\mathcal{B})
\end{align*}
for all classes $\mathcal{A}$ and $\mathcal{B}$.\footnote{Note that by the convention for the actions of these operators of the empty class $\mathcal{E}$, these and later definitions for the Cartesian product are consistent with the trivial products $\mathcal{A}\times \mathcal{E}$ and $\mathcal{E}\times\mathcal{B}$.}

\paragraph{$\Z^{\mathsf{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^{\mathsf{R}}$. For the action on the product of two operators, we distinguish two cases: $\mathcal{A}\times\mathcal{B}$ where no term of $\mathcal{A}$ contains $\Z^{\mathsf{R}}$, and $\A^{\mathsf{R}}\times\mathcal{B}$ where every term of $\A^{\mathsf{R}}$ contains exactly one $\Z^{\mathsf{R}}$ (or another class $\mathcal{D}^{\mathsf{R}}$ of the same form).
\begin{align*}
\Omega_\i(\mathcal{A}\mathcal{B})	&=\Omega_\i(\mathcal{A})\Omega_\o(\mathcal{B})+\Omega_\o(\mathcal{A})\Omega_\i(\mathcal{B})\\
\Omega_\io(\mathcal{A}\mathcal{B})	&=\Omega_\io(\mathcal{A})\Omega_\oo(\mathcal{B})+\Omega_\o(\mathcal{A})\Omega_\io(\mathcal{B})\\
\Omega_\ii(\mathcal{A}\mathcal{B})	&=\Omega_\ii(\mathcal{A})\Omega_\o(\mathcal{B})+\Omega_\io(\mathcal{A})\Omega_\oi(\mathcal{B})+\Omega_\o(\mathcal{A})\Omega_\ii(\mathcal{B})\\[5pt]
\Omega_\i(\A^{\mathsf{R}}\mathcal{B})	&=\Omega_\i(\A^{\mathsf{R}})\Omega_\o(\mathcal{B})\\
\Omega_\io(\A^{\mathsf{R}}\mathcal{B})&=\Omega_\io(\A^{\mathsf{R}})\Omega_\oo(\mathcal{B})\\
\Omega_\ii(\A^{\mathsf{R}}\mathcal{B})&=\Omega_\ii(\A^{\mathsf{R}})\Omega_\o(\mathcal{B})+\Omega_\io(\A^{\mathsf{R}})\Omega_\oi(\mathcal{B})
\end{align*}
Note, in each case, that the only difference between the action on $\mathcal{A}\mathcal{B}$ and the action on $\A^{\mathsf{R}}\mathcal{B}$ is to lose the final term (involving $\Omega_\o(\mathcal{A})$). Such a term would correspond to inserting the lowest entry above the atom $\Z^{\mathsf{R}}$, which is of course disallowed by the greedy gridding.

\subsection{The action on sequences}
In the case that we are given a regular specification, then we need to understand how the operators in $\mathcal{O}$ act on the sequence constructor, $\textsc{Seq}$. Note first that the atoms $\Z^{\mathsf{L}}$, $\Z^{\mathsf{R}}$ and $\Z^{\mathsf{LR}}$ can \emph{never} appear inside a $\textsc{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^{\mathsf{R}}$-sensitive operators separately.\footnote{Note that it would be perfectly possible to describe the action of operators in $\mathcal{O}$ on sequence constructors that involve, e.g. $\Z^{\mathsf{R}}$.}

Let $\mathcal{A}$ be an atom, class, or an expression involving combinatorial sums, Cartesian products and sequences of the atom $\mathcal{Z}$ and other classes not involving $\Z^{\mathsf{L}}$, $\Z^{\mathsf{R}}$ or $\Z^{\mathsf{LR}}$. It is routine to verify that the following expressions correctly describe the action of operators on the sequence construction.
\begin{align*}
\Omega_\o(\textsc{Seq}(\mathcal{A})) &= \textsc{Seq}(\Omega_\o(\mathcal{A}))\\
\Omega_\oo(\textsc{Seq}(\mathcal{A})) &= \textsc{Seq}(\Omega_\oo(\mathcal{A}))\\
\Omega_\i(\textsc{Seq}(\mathcal{A})) &= \textsc{Seq}(\Omega_\o(\mathcal{A}))\times\Omega_\i(\mathcal{A})\times\textsc{Seq}(\Omega_\o(\mathcal{A}))\\
\Omega_\io(\textsc{Seq}(\mathcal{A})) &= \textsc{Seq}(\Omega_\o(\mathcal{A})) \times \Omega_\io(\mathcal{A}) \times \textsc{Seq}(\Omega_\oo(\mathcal{A}))\\
\Omega_\oi(\textsc{Seq}(\mathcal{A})) &= \textsc{Seq}(\Omega_\oo(\mathcal{A})) \times \Omega_\oi(\mathcal{A}) \times \textsc{Seq}(\Omega_\o(\mathcal{A}))\\
\Omega_\ii(\textsc{Seq}(\mathcal{A})) &= \textsc{Seq}(\Omega_\o(\mathcal{A})) \times \Omega_\io(\mathcal{A}) \times \textsc{Seq}(\Omega_\oo(\mathcal{A})) \times \Omega_\oi(\mathcal{A}) \times \textsc{Seq}(\Omega_\o(\mathcal{A}))\\
&\qquad {}+ \textsc{Seq}(\Omega_\o(\mathcal{A})) \times \Omega_\ii(\mathcal{A}) \times \textsc{Seq}(\Omega_\o(\mathcal{A}))
\end{align*}

\subsection{Expansions}
We have now fully described how the operators act on individual terms, across Cartesian products and on the sequence operator. In this subsection we will apply these descriptions to the equations from the combinatorial specification for a class $\mathcal{C}$, in order to produce new equations for the juxtaposition class $\mathcal{C}\mid\operatorname{Av}(21)$.

Let $\ensuremath{\mathcal{V}}$ be a collection of combinatorial classes, and let $\Omega\in\mathcal{O}$ be an operator. Define $\ensuremath{\mathcal{V}}_{\Omega} = \{ \Omega(\S) : \S\in\ensuremath{\mathcal{V}}\}$ to be the collection of combinatorial classes under the action of $\Omega$, and $\ensuremath{\mathcal{V}}_{\mathcal{O}} = \bigcup_{\Omega\in\mathcal{O}} V_{\Omega}$. Our aim is to produce a combinatorial specification for $\mathcal{C}\mid \operatorname{Av}(21)$, using the symbols in $\ensuremath{\mathcal{V}}_{\mathcal{O}}$ together with the equations in Lemma~\ref{lem:CM}.

Given an equation $\mathcal{C} = f(\ensuremath{\mathcal{V}})$ from some combinatorial specification, we have (trivially), $\Omega(\mathcal{C}) = \Omega(f(\ensuremath{\mathcal{V}}))$. The \emph{expansion} of $\Omega(\mathcal{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
\[\Omega(\mathcal{C}) = g(\ensuremath{\mathcal{V}}_{\mathcal{O}}\cup\{\S_{\mathcal{Z}}\}),\]
for some function $g$. See Figure~\ref{fig:opiiexpansion} for an example. The properties of $g$ that we need are given in the next lemma.

\begin{figure}[!ht]
\newcommand{\drawclasspicture}[2]
    \draw[dashed] (2,4) -- (5,4);
    \draw[dashed] (2,3) -- (5,3);
    \draw[dashed] (1,2) -- (5,2);
    \draw[dashed] (1,1) -- (5,1);
    \draw[dashed] (3,0) -- (5,0);
    \draw[fill=gray!30] (1,3) rectangle ++(1,1) node[pos=0.5]{$\mathcal{D}$};
    \draw[fill=gray!30] (3,2) rectangle ++(1,1) node[pos=0.5]{$\C^{\mathsf{R}}$};
    \draw[fill=gray!30] (0,1) rectangle ++(1,1) node[pos=0.5]{$\mathcal{B}$};
    \draw[fill=gray!30] (2,0) rectangle ++(1,1) node[pos=0.5]{$\mathcal{A}$};
    \draw[-, very thick] (4,-0.5) -- (4,4.5);
    \node[permpt] at (4,2.3) {};
    \node[permpt] (L) at (4.3,#1) {};
    \node[permpt] (T) at (5.0,#2) {};
    \draw[dotted] (L) -- (T);%
    \path[use as bounding box] (-1.05,-1.5) -- (6.05,4.5);
}%
  \centering
\begin{tikzpicture}[scale=0.6]
    \drawclasspicture{0.1}{0.8}
    \draw (2.5,-1.5) node[above]{\footnotesize $\Omega_\ii(\mathcal{A})\Omega_\o(\mathcal{B}\C^{\mathsf{R}}\mathcal{D})$};
  \end{tikzpicture}%
\begin{tikzpicture}[scale=0.6]
    \drawclasspicture{0.1}{1.8}
    \draw (2.5,-1.5) node[above]{\footnotesize $\Omega_\io(\mathcal{A})\Omega_\oi(\mathcal{B})\Omega_\o(\C^{\mathsf{R}}\mathcal{D})$};
\end{tikzpicture}%
\begin{tikzpicture}[scale=0.6]
  \drawclasspicture{0.1}{2.8}
    \draw (2.5,-1.5) node[above]{\footnotesize $\Omega_\io(\mathcal{A})\Omega_\oo(\mathcal{B})\Omega_\oi(\C^{\mathsf{R}})\Omega_\o(\mathcal{D})$};
\end{tikzpicture}%
\begin{tikzpicture}[scale=0.6]
    \drawclasspicture{0.1}{3.8}
    \draw (2.5,-1.5) node[above]{\footnotesize $\Omega_\io(\mathcal{A})\Omega_\oo(\mathcal{B}\C^{\mathsf{R}})\Omega_\oi(\mathcal{D})$};
\end{tikzpicture}%
\\[10pt]
  \begin{tikzpicture}[scale=0.6]
    \drawclasspicture{1.1}{1.8}
    \draw (2.5,-1.5) node[above]{\footnotesize $\Omega_\o(\mathcal{A})\Omega_\ii(\mathcal{B})\Omega_\o(\C^{\mathsf{R}}\mathcal{D})$};
  \end{tikzpicture}
  \begin{tikzpicture}[scale=0.6]
    \drawclasspicture{1.1}{2.8}
    \draw (2.5,-1.5) node[above]{\footnotesize $\Omega_\o(\mathcal{A})\Omega_\io(\mathcal{B})\Omega_\oi(\C^{\mathsf{R}})\Omega_\o(\mathcal{D})$};
  \end{tikzpicture}
   \begin{tikzpicture}[scale=0.6]
    \drawclasspicture{1.1}{3.8}
    \draw (3,-1.5) node[above]{\footnotesize $\Omega_\o(\mathcal{A})\Omega_\io(\mathcal{B})\Omega_\oo(\C^{\mathsf{R}})\Omega_\oi(\mathcal{D})$};
  \end{tikzpicture}
\\[10pt]
  \begin{tikzpicture}[scale=0.6]
    \drawclasspicture{2.1}{2.8}
    \draw (2.5,-1.5) node[above]{\footnotesize $\Omega_\o(\mathcal{A}\mathcal{B})\Omega_\ii(\C^{\mathsf{R}})\Omega_\o(\mathcal{D})$};
  \end{tikzpicture}
   \begin{tikzpicture}[scale=0.6]
    \drawclasspicture{2.1}{3.8}
    \draw (2.5,-1.5) node[above]{\footnotesize $\Omega_\o(\mathcal{A}\mathcal{B})\Omega_\io(\C^{\mathsf{R}})\Omega_\oi(\mathcal{D})$};
  \end{tikzpicture}
\caption{The expansion of $\Omega_\ii(\mathcal{C})$ given the equation $\mathcal{C} =\mathcal{A}\mathcal{B}\C^{\mathsf{R}}\mathcal{D}$ is given by the combinatorial sum of the 9 terms above.}
\label{fig:opiiexpansion}
\end{figure}

\begin{lemma}\label{lem:expansion}
Let $\mathcal{C} = f(\ensuremath{\mathcal{V}})$ be an equation from a combinatorial specification using only the combinatorial sum, Cartesian product and sequence constructors. Then, for every operator $\Omega\in\mathcal{O}$, the expansion of $\Omega(\mathcal{C})$ is an equation involving only the combinatorial sum, Cartesian product and sequence constructors, acting only on atoms and classes from $\ensuremath{\mathcal{V}}_{\mathcal{O}}\cup\{\S_{\mathcal{Z}}\}$.

Furthermore, if $\mathcal{C}=f(\ensuremath{\mathcal{V}})$ does not use the sequence constructor, then neither does the expansion of $\Omega(\mathcal{C})$.
\end{lemma}

\begin{proof}
First, any operator $\Omega\in\mathcal{O}$ acts linearly on combinatorial sums
\[\Omega(\mathcal{A}+\mathcal{B}) = \Omega(\mathcal{A}) + \Omega(\mathcal{B}),\]
so it suffices to consider the action of $\Omega$ on individual terms of $f(\ensuremath{\mathcal{V}})$. Such terms, however, are themselves composed of Cartesian products of classes in $\ensuremath{\mathcal{V}}$ or sequences of classes in $\ensuremath{\mathcal{V}}$, and the rules for any operator in $\mathcal{O}$ described earlier in this subsection demonstrate that these can be rewritten as expressions involving combinatorial sums, Cartesian products and sequences of classes in $\ensuremath{\mathcal{V}}_{\mathcal{O}}$. Note that the action of an operator $\Omega\in\mathcal{O}$ on an atom is described in Subsection~\ref{subsec:atoms}, and can be expressed as the Cartesian product of atoms and the class $\S_{\mathcal{Z}}$. This completes the proof.

Finally, if there are no sequence constructors in the original equation, then the rules given earlier for operators in $\mathcal{O}$ guarantee that no sequence constructor will be introduced in the expansion of $\Omega(\mathcal{C})$.
\end{proof}

The result above tells us that we can create equations for the classes in $\ensuremath{\mathcal{V}}_{\mathcal{O}}$ from the equations in the combinatorial specification for $\mathcal{C}$, and that these equations only use our restricted set of admissible operations. From these equations, we can now describe a combinatorial specification for $\mathcal{C}\mid\operatorname{Av}(21)$, which is the first key piece of our main result.

\begin{proposition}\label{prop:CMcombspec}
Let $\mathcal{C}$ be a permutation class, and $\ensuremath{\mathscr{S}}$ a combinatorial specification for $\mathcal{C}$ that tracks the rightmost entry. Then there exists a combinatorial specification $\ensuremath{\mathscr{S}}'$ for the class $\mathcal{C}\mid\operatorname{Av}(21)$ that tracks the rightmost entry.

Furthermore, if $\ensuremath{\mathscr{S}}$ is context-free, and/or tracks the leftmost entry, then so is $\ensuremath{\mathscr{S}}'$.
\end{proposition}

\begin{proof}
First, let $\ensuremath{\mathcal{V}}$ denote the set of classes that appear on the left hand side of any equation in the specification $\ensuremath{\mathscr{S}}$. Thus, any equation in $\ensuremath{\mathscr{S}}$ is of the form $\S = f(\ensuremath{\mathcal{V}})$.

By Lemma~\ref{lem:CM}, the class $\mathcal{C}\mid\operatorname{Av}(21)$ is given by the equation
\[\mathcal{C}\mid\operatorname{Av}(21)=\mathcal{E}+\S_{\mathcal{Z}}\times\Z^{\mathsf{R}}+\Omega_\i(\mathcal{C})+\Omega_\ii(\mathcal{C})+\Omega_\io(\mathcal{C})\times \S_{\mathcal{Z}}\times\Z^{\mathsf{R}}.\]
We therefore need to establish a system of equations to describe the classes $\Omega_\i(\mathcal{C})$, $\Omega_\ii(\mathcal{C})$ and $\Omega_\io(\mathcal{C})$, which taken together with the equation $\S_{\mathcal{Z}} = \mathcal{E} + \S_{\mathcal{Z}}\mathcal{Z}$, forms a complete combinatorial specification. We claim that it suffices to define the system of equations $\ensuremath{\mathscr{S}}'$ to comprise the following:
\begin{align*}
\mathcal{C}\mid\operatorname{Av}(21) &=\mathcal{E}+\S_{\mathcal{Z}}\times\Z^{\mathsf{R}}+\Omega_\i(\mathcal{C})+\Omega_\ii(\mathcal{C})+\Omega_\io(\mathcal{C})\times \S_{\mathcal{Z}}\times\Z^{\mathsf{R}}\\
\Omega(\S) &= g_{\Omega(\S)}(\ensuremath{\mathcal{V}}_{\mathcal{O}}\cup\{\S_{\mathcal{Z}}\}) &\text{for every }\Omega\in\mathcal{O}, \S\in\ensuremath{\mathcal{V}}\\
\S_{\mathcal{Z}} &= \mathcal{E}+\S_{\mathcal{Z}}\times \mathcal{Z}.
\end{align*}

Every class in $\ensuremath{\mathcal{V}}_{\mathcal{O}}$ is of the form $\Omega(\S)$ for some $\Omega\in\mathcal{O}$ and $\S\in\ensuremath{\mathcal{V}}$. Writing $\S=f(\ensuremath{\mathcal{V}})$ (an equation taken from $\ensuremath{\mathscr{S}}$), by Lemma~\ref{lem:expansion} the expansion of $\Omega(\S)$ is an equation involving only combinatorial sums and Cartesian products of classes from $\ensuremath{\mathcal{V}}_{\mathcal{O}}\cup\{\S_{\mathcal{Z}}\}$. Thus the system $\ensuremath{\mathscr{S}}'$ above is indeed a context-free combinatorial specification, providing $\ensuremath{\mathscr{S}}$ is. Furthermore, each term in the equation for $\mathcal{C}\mid\ensuremath{\mathcal{M}}$ acts from bottom-to-top, and specifies the position of the rightmost entry $\Z^{\mathsf{R}}$.

If the atom $\Z^{\mathsf{L}}$ and/or $\Z^{\mathsf{LR}}$ is present in the specification for $\mathcal{C}(=\C^{\mathsf{L}})$, then, by definition, the operators in $\mathcal{O}$ ensure that $\Z^{\mathsf{L}}$ and/or $\Z^{\mathsf{LR}}$ are correctly tracked for $\C^{\mathsf{L}}\mid\ensuremath{\mathcal{M}}$. However, in this case we need to use the following expression for the class $\C^{\mathsf{L}}\mid\ensuremath{\mathcal{M}}$, given in Lemma~\ref{lem:CM}:
\[\C^{\mathsf{L}}\mid\operatorname{Av}(21)=\mathcal{E}+\Z^{\mathsf{LR}} +\Z^{\mathsf{L}}\times\S_{\mathcal{Z}}\times\Z^{\mathsf{R}}+\Omega_\i(\C^{\mathsf{L}})+\Omega_\ii(\C^{\mathsf{L}})+\Omega_\io(\C^{\mathsf{L}})\times \S_{\mathcal{Z}}\times\Z^{\mathsf{R}}.\]
\end{proof}

Analogously, we have the following result that guarantees a regular specification is obtained if the initial specification is regular.

\begin{proposition}\label{prop:CMratcombspec}
Let $\mathcal{C}$ be a permutation class, and $\ensuremath{\mathscr{S}}$ a regular combinatorial specification for $\mathcal{C}$ that tracks the rightmost entry. Then there exists a regular combinatorial specification $\ensuremath{\mathscr{S}}'$ that tracks the rightmost entry for $\mathcal{C}\mid\operatorname{Av}(21)$.

Furthermore, if $\ensuremath{\mathscr{S}}$ tracks the leftmost entry, then so does $\ensuremath{\mathscr{S}}'$.
\end{proposition}

\begin{proof}
We construct the specification $\ensuremath{\mathscr{S}}'$ from $\ensuremath{\mathscr{S}}$ following the proof of Proposition~\ref{prop:CMcombspec}. 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 $\mathcal{O}$ on sequences in the expansions. Note that $\ensuremath{\mathscr{S}}'$ will track the rightmost entry, and if $\ensuremath{\mathscr{S}}$ tracks the leftmost entry, then so does $\ensuremath{\mathscr{S}}'$.

It remains to verify that $\ensuremath{\mathscr{S}}'$ is regular. Note that the right hand side of any equation in $\ensuremath{\mathscr{S}}$ involves only atoms, combined using the sum, Cartesian product and sequence operations. As such, by considering the effect of the operators in $\mathcal{O}$, the expansion of an equation in $\ensuremath{\mathscr{S}}$ under some operator in $\mathcal{O}$ will yield an equation in $\ensuremath{\mathscr{S}}'$ also involving only sums, products and sequences of atoms, except for the appearance of the class $\S_{\mathcal{Z}}$. This however, can be replaced by $\textsc{Seq}(\mathcal{Z})$ wherever it appears, whence the equation in $\ensuremath{\mathscr{S}}'$ satisfies the conditions to be regular.
\end{proof}

\subsection{Symmetry operators}

Having established how to find a combinatorial specification for $\mathcal{C}\mid\operatorname{Av}(21)$ given one for $\mathcal{C}$, we now need to describe how to find specifications for $\mathcal{C}\mid\operatorname{Av}(12)$, $\operatorname{Av}(21)\mid\mathcal{C}$ and $\operatorname{Av}(12)\mid\mathcal{C}$.

Let $\pi$ be a permutation of length $n$. The \emph{reverse} of $\pi$, denoted $\pi^r$, is the permutation obtained by reading the entries of $\pi$ in reverse order, i.e. $\pi^r(i) =\pi(n+1-i)$. Similarly, the \emph{complement} of $\pi$ is $\pi^c$, defined by $\pi^c(i) = n+1-\pi(i)$. Combining these two operations, we obtain the \emph{reverse-complement}, $\pi^{rc}$, which is formally defined by $\pi^{rc}(i) = n+1 -\pi(n+1-i)$.

By extension, we may consider the reverse, complement, and reverse-complement of a class $\mathcal{C}$ of permutations, for example $\mathcal{C}^r = \{\pi^r : \pi\in\mathcal{C}\}$.

\begin{observation}\label{obs:symmetry}
For any permutation class $\mathcal{C}$, we have the following:
\begin{align*}
\mathcal{C}\mid\operatorname{Av}(12) &= (\mathcal{C}^c\mid\operatorname{Av}(21))^c\\
\operatorname{Av}(12)\mid\mathcal{C} &= (\mathcal{C}^r\mid\operatorname{Av}(21))^r, \text{ and}\\
\operatorname{Av}(21)\mid\mathcal{C} &= (\mathcal{C}^{rc}\mid\operatorname{Av}(21))^{rc}.\end{align*}
\end{observation}

Given a bottom-to-top combinatorial specification for $\mathcal{C}$, we can obtain a bottom-to-top specification for $\mathcal{C}^c$ simply by reversing the order in which terms in a Cartesian product are taken. This is characterised by the \emph{complement} operator, $\Theta$, which acts linearly on combinatorial sums, as the identity on atoms (i.e.\ $\Theta(\mathcal{Z})=\mathcal{Z}$, $\Theta(\Z^{\mathsf{R}})=\Z^{\mathsf{R}}$, $\Theta(\Z^{\mathsf{L}})=\Z^{\mathsf{L}}$, $\Theta(\Z^{\mathsf{LR}})=\Z^{\mathsf{LR}}$), and is then defined recursively on Cartesian products as follows:
\[\Theta( \mathcal{A}\times \mathcal{B}) =  \Theta(\mathcal{B})\times\Theta(\mathcal{A})\]
for classes $\mathcal{A}$ and $\mathcal{B}$. The action on the sequence operator is given by
\[\Theta(\textsc{Seq}(\mathcal{A})) = \textsc{Seq}(\Theta(\mathcal{A})).\]

Similarly, given a specification for $\mathcal{C}$ that tracks both the leftmost and rightmost entries, we can find one for $\mathcal{C}^r$ by preserving the order in the Cartesian product, but switching the atoms $\Z^{\mathsf{R}}$ and $\Z^{\mathsf{L}}$. This is characterised by the \emph{reverse} operator, $\Phi$, which acts linearly on combinatorial sums, distributively on Cartesian products ($\Phi(\mathcal{A}\times\mathcal{B})=\Phi(\mathcal{A})\times\Phi(\mathcal{B})$) and sequences ($\Phi(\textsc{Seq}(\mathcal{A})) = \textsc{Seq}(\Phi(\mathcal{A}))$), and satisfies
\[\Phi(\mathcal{Z})=\mathcal{Z},\quad \Phi(\Z^{\mathsf{R}})=\Z^{\mathsf{L}},\quad \Phi(\Z^{\mathsf{L}})=\Z^{\mathsf{R}},\quad \Phi(\Z^{\mathsf{LR}})=\Z^{\mathsf{LR}}.\]
Note that if a class $\mathcal{C}$ tracks only the leftmost entry, then $\Phi(\mathcal{C})$ tracks only the rightmost entry and vice versa, and if $\mathcal{C}$ tracks both, then so does $\Phi(\mathcal{C})$.

Given some equation $\mathcal{C} = f(\ensuremath{\mathcal{V}})$ from a combinatorial specification, the \emph{expansion} of $\Theta(\mathcal{C})$ is the equation obtained by using the linearity of $\Theta$, together with the defined action on Cartesian products, to obtain an equation of the form
\[\Theta(\mathcal{C}) = g(\ensuremath{\mathcal{V}}_{\Theta})\]
for some $g$. Similarly, the expansion of $\Phi(\mathcal{C})$ is the equation obtained following the definition of $\Phi$ above, $\Phi(\mathcal{C})=h(\ensuremath{\mathcal{V}}_{\Phi})$ for some $h$.

We now have the following observation, mirroring Lemma~\ref{lem:expansion}. We omit its proof.

\begin{lemma}
Let $\mathcal{C} = f(\ensuremath{\mathcal{V}})$ be an equation from a combinatorial specification using only the combinatorial sum, Cartesian product, and sequence constructors. Then the expansion of $\Theta(\mathcal{C})$ and $\Phi(\mathcal{C})$ are equations involving only the combinatorial sum, Cartesian product and sequence operators, acting only on classes from $\ensuremath{\mathcal{V}}_\Theta$ and $\ensuremath{\mathcal{V}}_\Phi$, respectively.

Furthermore, if $\mathcal{C}=f(\ensuremath{\mathcal{V}})$ does not contain any instance of a sequence operator, then neither does the expansion of $\Theta(\mathcal{C})$.
\end{lemma}

Similarly, we may combine these expansions to obtain combinatorial specifications for $\mathcal{C}^c$, $\mathcal{C}^r$ and $\mathcal{C}^{rc}$. As its proof resembles (but is simpler than) the proof of Proposition~\ref{prop:CMcombspec}, we will omit it.

\begin{proposition}\label{prop:TPcombspec}
Let $\ensuremath{\mathscr{S}}$ be a combinatorial specification for a class $\mathcal{C}$. Then there exist combinatorial specifications $\ensuremath{\mathscr{S}}^\Theta$, $\ensuremath{\mathscr{S}}^\Phi$ and $\ensuremath{\mathscr{S}}^{\Theta\cdot\Phi}$  for the classes $\mathcal{C}^c$, $\mathcal{C}^r$ and $\mathcal{C}^{rc}$, respectively.

Furthermore, if $\ensuremath{\mathscr{S}}$ tracks the rightmost (resp. leftmost) entry, then
so does $\ensuremath{\mathscr{S}}^\Theta$, while the specifications $\ensuremath{\mathscr{S}}^{\Theta\cdot\Phi}$ and $\ensuremath{\mathscr{S}}^\Phi$ track the leftmost (resp. rightmost) entry.
\end{proposition}

Equipped with Observation~\ref{obs:symmetry} and combinatorial specifications for $\mathcal{C}\mid\ensuremath{\mathcal{M}}$, $\mathcal{C}^c$, $\mathcal{C}^r$ and $\mathcal{C}^{rc}$, we can now complete the proof of Theorem~\ref{thm:main}.

\begin{proof}[Proof of Theorem~\ref{thm:main}]
By Proposition~\ref{prop:CMcombspec}, if the combinatorial specification $\ensuremath{\mathscr{S}}$ for $\mathcal{C}$ tracks the rightmost entry, then there exists a specification for $\mathcal{C}\mid\operatorname{Av}(21)$ that does. To complete the proof of part~(\ref{item:CM}), therefore, we need to consider $\mathcal{C}\mid\operatorname{Av}(12)$.

By Observation~\ref{obs:symmetry}, we have $\mathcal{C}\mid\operatorname{Av}(12) = (\mathcal{C}^c\mid\operatorname{Av}(21))^c$. By Proposition~\ref{prop:TPcombspec}, there exists a combinatorial specification $\ensuremath{\mathscr{S}}^\Theta$ for $\mathcal{C}^c$. To this we apply Proposition~\ref{prop:CMcombspec} to obtain a combinatorial specification for $\mathcal{C}^c\mid\operatorname{Av}(21)$. Finally, an application of $\Theta$ to this specification gives us a specification for $(\mathcal{C}^c\mid\operatorname{Av}(21))^c$, which is combinatorially isomorphic to $\mathcal{C}\mid\operatorname{Av}(12)$. Furthermore, all these specifications track the rightmost entry by Propositions~\ref{prop:CMcombspec} and~\ref{prop:TPcombspec}.

Similar arguments can now be made to establish part~(\ref{item:MC}) of the theorem: Observation~\ref{obs:symmetry} gives us equations for $\operatorname{Av}(21)\mid\mathcal{C}$ and $\operatorname{Av}(12)\mid\mathcal{C}$, and combinatorial specifications for these can then be computed using applications of $\Phi$, $\Theta$, and the operators in $\mathcal{O}$. Note that if $\ensuremath{\mathscr{S}}$ tracks the leftmost entry, then by Proposition~\ref{prop:TPcombspec} $\ensuremath{\mathscr{S}}^\Phi$ and $\ensuremath{\mathscr{S}}^{\Theta\cdot\Phi}$ (being specifications $\mathcal{C}^r$ and $\mathcal{C}^{rc}$) track the rightmost entry (as required for the operators in $\mathcal{O}$ to append $\operatorname{Av}(21)$ to the right). After appending $\operatorname{Av}(21)$, a further application of $\Phi$ replaces the rightmost entry with the leftmost, while any application of $\Theta$ keeps the rightmost and leftmost atoms intact.

For part~(\ref{item:leftright}), note that the operators $\Theta$ and those in $\mathcal{O}$ preserve the atom $\Z^{\mathsf{L}}$, while $\Phi$ interchanges the atoms $\Z^{\mathsf{L}}$ and $\Z^{\mathsf{R}}$, and both $\Theta$ and $\Phi$ preserve $\Z^{\mathsf{LR}}$. Combined with Proposition~\ref{prop:CMcombspec},  We conclude that the resulting combinatorial specifications for all of $\mathcal{C}\mid\operatorname{Av}(21)$, $\mathcal{C}\mid\operatorname{Av}(12)$, $\operatorname{Av}(21)\mid\mathcal{C}$ and $\operatorname{Av}(12)\mid\mathcal{C}$ also track both the leftmost and rightmost entries.

Finally, for part~(\ref{item:contextfree}), if $\ensuremath{\mathscr{S}}$ is context-free or rational, then it is clear that the operators $\Theta$ and $\Phi$ preserve this. We know that the operators in $\mathcal{O}$ preserve context-freeness by Proposition~\ref{prop:CMcombspec}, and preserve rationality by Proposition~\ref{prop:CMratcombspec}. This completes the proof.
\end{proof}

\section{Applicable classes}\label{sec-applicable-classes}

In this section, we demonstrate classes which possess combinatorial specifications that track the rightmost and leftmost entries.

\paragraph{Classes containing finitely many simple permutations}

It has been known since Albert and Atkinson~\cite{albert:simple-permutat:} that classes which possess only finitely many simple permutations admit an algebraic generating function. Subsequently, Brignall, Huczynska and Vatter~\cite{brignall:simple-permutat:} 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~\cite{bassino:an-algorithm-computing:}, and we refer to that article for fuller details.

To begin, we need to adapt the notation used for inflations slightly, to handle the `bottom-to-top' requirement of our combinatorial specifications. Given a permutation $\sigma$ and permutations $\pi_1,\dots,\pi_{|\sigma|}$, the \emph{bottom-to-top inflation} of $\sigma$ by $\pi_1,\dots,\pi_{|\sigma|}$ is the permutation $\sigma[\pi_1,\dots,\pi_{|\sigma|}]^T$ formed by replacing the $\sigma^{-1}(i)$th entry of $\sigma$ by $\pi_i$. That is, the lowest entry of $\sigma$ is inflated by $\pi_1$, the second-lowest by $\pi_2$, and so on.

In terms of specifications, if $\pi_i\in\mathcal{C}_i$, then the bottom-to-top inflation $\sigma[\pi_1,\dots,\pi_{|\sigma|}]^T$ belongs to the product of classes $\mathcal{C}_1\times \cdots\times \mathcal{C}_{|\sigma|}$. 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 $\sigma$, namely $\pi_{\sigma(|\sigma|)}$. Similarly, the leftmost entry of this inflation is the leftmost entry of $\pi_{\sigma(1)}$.

\begin{proposition}\label{prop:simple-specification}
Every class containing only finitely many simple permutations admits a combinatorial specification that track the leftmost and rightmost entries.
\end{proposition}

\begin{proof}
   Let $\operatorname{Si}(\mathcal{C})$ denote the (finite) set of simple permutations in $\mathcal{C}$, which for convenience we will assume includes the permutations $12$ and $21$. Consider some combinatorial specification $\ensuremath{\mathscr{S}}$ for $\mathcal{C}$, as produced e.g.\ by the algorithm of Bassino et al~\cite{bassino:an-algorithm-computing:}.

   Let $\ensuremath{\mathcal{V}}$ denote the set of classes and atoms arising in $\ensuremath{\mathscr{S}}$, and consider any $\mathcal{D}\in\ensuremath{\mathcal{V}}$, specified by some equation $\mathcal{D} = f(\ensuremath{\mathcal{V}})$. The function $f$ comprises a combinatorial sum of finitely many terms, each of which arises from the inflation of a permutation in $\operatorname{Si}(\mathcal{C})$ by other classes from $\ensuremath{\mathcal{V}}$ (or is simply equal to an atom $\mathcal{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 $\ensuremath{\mathscr{S}}'$ for $\mathcal{C}$.

 Now, in order to track the rightmost entry, we define $\ensuremath{\mathcal{V}}^\mathsf{R} = \{\mathcal{D}^\mathsf{R} :\mathcal{D}\in\ensuremath{\mathcal{V}}\}$ to be the collection of classes that track the rightmost entry.
 For each $\mathcal{D}^\mathsf{R}\in\ensuremath{\mathcal{V}}^\mathsf{R}$, we copy the corresponding equation for $\mathcal{D}$ in $\ensuremath{\mathscr{S}}'$, except that in each term (corresponding to the inflation of a simple permutation) we identify the rightmost class $\mathcal{F}$, say, and replace it with $\mathcal{F}^\mathsf{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 $\ensuremath{\mathcal{V}}$, $\ensuremath{\mathcal{V}}^\mathsf{R}$, $\ensuremath{\mathcal{V}}^\mathsf{L}$ and $\ensuremath{\mathcal{V}}^\mathsf{LR}$ as required, we obtain a specification for $\C^{\mathsf{R}}$ (or $\C^{\mathsf{L}}$, $\C^{\mathsf{LR}}$) satisfying the requirements of the proposition.
\end{proof}

\paragraph{The class $\operatorname{Av}(321)$}
Permutations of length $n$ in $\operatorname{Av}(321)$ are in bijection with Dyck paths below the diagonal, starting at $(0,0)$ and ending at $(n,n)$ via up ($\sf{U}$) and right ($\sf{R}$) steps. This bijection is well-known, and rather than present a formal definition we merely illustrate the process in Figure~\ref{fig:dyck-321}.

\begin{figure}[!ht]
\begin{center}
\begin{tikzpicture}[scale=0.3]
\draw[gray] (0,0) grid (9,9);
\draw[ultra thick, black] (0,0) -- (3,0) -- (3,2) -- (5,2) -- (5,3) -- (7,3) -- (7,4) -- (8,4) -- (8,8) -- (9,8) -- (9,9);
\end{tikzpicture}\quad
\begin{tikzpicture}[scale=0.3]
\draw[gray] (0,0) grid (9,9);
\draw[ultra thick, black] (0,0) -- (3,0) -- (3,2) -- (5,2) -- (5,3) -- (7,3) -- (7,4) -- (8,4) -- (8,8) -- (9,8) -- (9,9);
\filldraw[black] (2.5,0.5) circle (6pt);
\filldraw[black] (4.5,2.5) circle (6pt);
\filldraw[black] (6.5,3.5) circle (6pt);
\filldraw[black] (7.5,4.5) circle (6pt);
\filldraw[black] (8.5,8.5) circle (6pt);
\end{tikzpicture}\quad
\begin{tikzpicture}[scale=0.3]
\draw[gray] (0,0) grid (9,9);
\draw[ultra thick, black] (0,0) -- (3,0) -- (3,2) -- (5,2) -- (5,3) -- (7,3) -- (7,4) -- (8,4) -- (8,8) -- (9,8) -- (9,9);
\filldraw[black] (2.5,0.5) circle (6pt);
\filldraw[black] (4.5,2.5) circle (6pt);
\filldraw[black] (6.5,3.5) circle (6pt);
\filldraw[black] (7.5,4.5) circle (6pt);
\filldraw[black] (8.5,8.5) circle (6pt);
\filldraw[black] (5.5,7.5) circle (6pt);
\filldraw[black] (3.5,6.5) circle (6pt);
\filldraw[black] (1.5,5.5) circle (6pt);
\filldraw[black] (0.5,1.5) circle (6pt);
\end{tikzpicture}\quad
\begin{tikzpicture}[scale=0.3]
\fill[white]  (0,0) rectangle +(9,9);
\draw[gray] (0,0) grid (9,9);
\filldraw[black] (2.5,0.5) circle (6pt);
\filldraw[black] (4.5,2.5) circle (6pt);
\filldraw[black] (6.5,3.5) circle (6pt);
\filldraw[black] (7.5,4.5) circle (6pt);
\filldraw[black] (8.5,8.5) circle (6pt);
\filldraw[black] (5.5,7.5) circle (6pt);
\filldraw[black] (3.5,6.5) circle (6pt);
\filldraw[black] (1.5,5.5) circle (6pt);
\filldraw[black] (0.5,1.5) circle (6pt);
\end{tikzpicture}
\end{center}
\caption{Moving from a Dyck path to its corresponding 321-avoider.}
\label{fig:dyck-321}
\end{figure}

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 $\sf{U}$ step after the last $\sf{R}$ step.\footnote{It is also possible to identify the leftmost entry, though for brevity we have not done this here.} Thus, the class of Dyck paths $\mathcal{D}$ satisfies the following combinatorial specification (taking the atoms to be $\sf{R}$, $\sf{U}$, and (to mark the `rightmost corner') $\sf{U^R}$.
\begin{align*}
\mathcal{D}^{\sf{R}} &= \mathcal{D}\sf{R}\mathcal{D}^{\sf{R}}\sf{U}+\mathcal{D} \sf{RU^R}\\
\mathcal{D} &= \mathcal{E} + \mathcal{D}\sf{R}\mathcal{D}\sf{U}
\end{align*}

Translating this to the permutation case (by mapping $\sf{U}$ to $\mathcal{Z}$, $\sf{U^R}$ to $\Z^{\mathsf{R}}$, and ignoring $\sf{R}$) yields the following specification:
\begin{align*}
\C^{\mathsf{R}} &= \mathcal{C}\C^{\mathsf{R}}\mathcal{Z} + \mathcal{C}\Z^{\mathsf{R}}\\
\mathcal{C} &= \mathcal{E} + \mathcal{C}\C\mathcal{Z}.
\end{align*}

\paragraph{Insertion encodings}

Introduced by Albert, Linton and Ru\v{s}kuc~\cite{albert:the-insertion-e:}, the \emph{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 \emph{slots}. The addition of a new maximal element can be performed in one of four ways: fill the slot ($\mathsf{F}$), insert to the right of a slot ($\mathsf{R}$, leaving a slot to the left of the newly-inserted entry), insert to the left of a slot ($\mathsf{L}$), or insert in the middle of a slot ($\mathsf{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 $\mathsf{M_1R_2F_1M_1R_2F_1F_1}$, illustrated as follows (Reading upwards):
\begin{align*}
3 1 6 &4 7 5 2 \\
3 1 6 &4 \diamond 5 2 \\
3 1 \diamond &4 \diamond 5 2 \\
3 1 \diamond &4 \diamond 2 \\
3 1& \diamond 2 \\
\diamond 1& \diamond 2 \\
\diamond &1 \diamond  \\
&\diamond
\end{align*}
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,\footnote{Note that, for a class $\mathcal{C}$ which possesses a regular or context-free insertion encoding, the use of our method may be overkill: for example, to count $\mathcal{C}\mid\operatorname{Av}(21)$, it may be easier simply to adjust the insertion encoding by permitting an additional slot on the right (subject to ensuring each permutation is represented uniquely, of course).} it suffices to capture how to track the rightmost (and/or the leftmost) entry.

We make the following observation.

\begin{lemma}
In any insertion encoding of a permutation class, the rightmost entries of permutations in the class correspond to an $\mathsf{F}$ or $\mathsf{R}$ insertion into the rightmost gap.
\end{lemma}

For example, the following grammar (given in Albert,Linton, Ru\v{s}kuc~\cite{albert:the-insertion-e:}) defines the insertion encoding of $\operatorname{Av}(312)$. (Note that, as there is only one active slot, we have omitted all indices.)
\[\mathsf{s} \rightarrow \mathsf{F} \mid \mathsf{Ls}\mid \mathsf{Rs}\mid \mathsf{Mss}.\]
To adapt this encoding to track the rightmost entry, we introduce two new symbols, $\mathsf{F^R}$ and $\mathsf{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:
\begin{align*}
\mathsf{s^R} &\rightarrow \mathsf{F^R} \mid \mathsf{Ls}\mid \mathsf{R^Rs}\mid \mathsf{Mss^R}\\
\mathsf{s} &\rightarrow \mathsf{F} \mid \mathsf{Ls}\mid \mathsf{Rs}\mid \mathsf{Mss}
\end{align*}
where $\mathsf{s^R}$ denotes the encoding for the class with the rightmost entry encoded separately. Converting to combinatorial specifications for the class $\operatorname{Av}(312)$, we obtain
\begin{align*}
\C^{\mathsf{R}} &= \Z^{\mathsf{R}}+\mathcal{Z}\C^{\mathsf{R}}+\Z^{\mathsf{R}}\mathcal{C}+\mathcal{Z}\mathcal{C}\C^{\mathsf{R}}\\
\mathcal{C} &= \mathcal{Z} + \mathcal{Z}\mathcal{C}	+\mathcal{Z}\mathcal{C} + \mathcal{Z}\mathcal{C}\C.
\end{align*}
This specification can be simplified slightly by admitting the empty permutation into $\mathcal{C}$:
\begin{align*}
\C^{\mathsf{R}} &= \Z^{\mathsf{R}}\mathcal{C}+\mathcal{Z}\mathcal{C}\C^{\mathsf{R}}\\
\mathcal{C} &= \mathcal{E} + \mathcal{Z}\mathcal{C}\C.
\end{align*}

Similar modifications can be made to track the leftmost entry; we omit the details.
\section{Examples}\label{sec-examples}

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

\subsection{\texorpdfstring{$\operatorname{Av}(321)\mid \operatorname{Av}(21)$}{Av(321)|Av(21)}}

Juxtaposing the 321-avoiding permutations with a monotone increasing sequence was first carried out by the current authors~\cite{bs:juxt-catalan}. We repeat that enumeration here using the rightmost-entry-tracking specification obtained in the previous section:
\begin{align*}
\C^{\mathsf{R}} &= \mathcal{C}\C^{\mathsf{R}}\mathcal{Z} + \mathcal{C}\Z^{\mathsf{R}}\\
\mathcal{C} &= \mathcal{E} + \mathcal{C}\C\mathcal{Z}.
\end{align*}
From the specification above, together with the master equation,
\[\C^{\mathsf{R}}\mid\operatorname{Av}(21)=\mathcal{E}+\S_{\mathcal{Z}}\times\Z^{\mathsf{R}}+\Omega_\i(\C^{\mathsf{R}})+\Omega_\ii(\C^{\mathsf{R}})+\Omega_\io(\C^{\mathsf{R}})\times \S_{\mathcal{Z}}\times\Z^{\mathsf{R}}.\]
we obtain expansions for the classes in $\ensuremath{\mathcal{V}}_\mathcal{O}$, where $\ensuremath{\mathcal{V}}=\{\mathcal{C},\C^{\mathsf{R}}\}$. To aid readability, we use the shorthand $\C^{\mathsf{R}}_\i = \Omega_\i(\C^{\mathsf{R}})$, $\mathcal{C}_{\bullet\bullet}= \Omega_\ii(\mathcal{C})$ and so on.
\begin{align*}
\C^{\mathsf{R}}_\i &= \mathcal{C}_\i\C^{\mathsf{R}}_\o\mathcal{Z} + \mathcal{C}_\o\C^{\mathsf{R}}_\i\mathcal{Z} + \mathcal{C}_\i\mathcal{Z} + \mathcal{C}_\o\Z^{\mathsf{R}}\mathcal{Z}\\
\C^{\mathsf{R}}_{\bullet\bullet} &= \mathcal{C}_{\bullet\bullet}(\C^{\mathsf{R}}_\o\mathcal{Z} + \mathcal{Z}) +\mathcal{C}_{\bullet\circ}(\C^{\mathsf{R}}_{\circ\bullet}\mathcal{Z} +\C^{\mathsf{R}}_{\circ\circ}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z} + \S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z}) +\mathcal{C}_\o(\C^{\mathsf{R}}_{\bullet\bullet}\mathcal{Z} + \C^{\mathsf{R}}_{\bullet\circ}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z}+  \mathcal{Z}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z})\\
\C^{\mathsf{R}}_{\circ\bullet} &= \mathcal{C}_{\circ\bullet}(\C^{\mathsf{R}}_\o\mathcal{Z} + \mathcal{Z})+ \mathcal{C}_{\circ\circ}(\C^{\mathsf{R}}_{\circ\bullet}\mathcal{Z} + \C^{\mathsf{R}}_{\circ\circ}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z} +  \S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z})\\
\C^{\mathsf{R}}_{\bullet\circ} &= \mathcal{C}_{\bullet\circ}(\C^{\mathsf{R}}_{\circ\circ}\S_{\mathcal{Z}}\mathcal{Z} + \S_{\mathcal{Z}}\mathcal{Z}) + \mathcal{C}_\o(\C^{\mathsf{R}}_{\bullet\circ}\S_{\mathcal{Z}}\mathcal{Z} + \mathcal{Z}\S_{\mathcal{Z}}\mathcal{Z})\\
\C^{\mathsf{R}}_{\circ\circ} &= \mathcal{C}_{\circ\circ}(\C^{\mathsf{R}}_{\circ\circ}\S_{\mathcal{Z}}\mathcal{Z} + \S_{\mathcal{Z}}\mathcal{Z})\\
\C^{\mathsf{R}}_\o &= \mathcal{C}_\o(\C^{\mathsf{R}}_\o\mathcal{Z} + \mathcal{Z})\\
\mathcal{C}_\i &= \mathcal{C}_\i\mathcal{C}_\o\mathcal{Z} + \mathcal{C}_\o\mathcal{C}_\i\mathcal{Z} + \mathcal{C}_\o\mathcal{C}_\o\Z^{\mathsf{R}}\mathcal{Z}\\
\mathcal{C}_{\bullet\bullet} &= \mathcal{C}_{\bullet\bullet}\mathcal{C}_\o\mathcal{Z} + \mathcal{C}_{\bullet\circ}(\mathcal{C}_{\circ\bullet}\mathcal{Z} + \mathcal{C}_{\circ\circ}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z}) + \mathcal{C}_\o(\mathcal{C}_{\bullet\bullet}\mathcal{Z} + \mathcal{C}_{\bullet\circ}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z} + \mathcal{C}_\o\mathcal{Z}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z})\\
\mathcal{C}_{\circ\bullet} &= \mathcal{C}_{\circ\bullet}\mathcal{C}_\o\mathcal{Z} + \mathcal{C}_{\circ\circ}(\mathcal{C}_{\circ\bullet}\mathcal{Z} + \mathcal{C}_{\circ\circ}\S_{\mathcal{Z}}\Z^{\mathsf{R}}\mathcal{Z})\\
\mathcal{C}_{\bullet\circ} &= \mathcal{C}_{\bullet\circ}\mathcal{C}_{\circ\circ}\S_{\mathcal{Z}}\mathcal{Z} + \mathcal{C}_\o(\mathcal{C}_{\bullet\circ}\S_{\mathcal{Z}}\mathcal{Z} + \mathcal{C}_\o\mathcal{Z}\S_{\mathcal{Z}}\mathcal{Z})\\
\mathcal{C}_{\circ\circ} &= \mathcal{E} + \mathcal{C}_{\circ\circ}\mathcal{C}_{\circ\circ}\S_{\mathcal{Z}}\mathcal{Z}\\
\mathcal{C}_\o &= \mathcal{E} + \mathcal{C}_\o\mathcal{C}_\o\mathcal{Z}_\o.
\end{align*}

Solving, simplifying and converting into generating functions yields the following,
\newcommand{\sqrt{1-4z}}{\sqrt{1-4z}}
\[ f(z)  = -\frac{1-\sqrt{1-4z} + z(-4+\sqrt{1-4z} + \sqrt{1-5z}/\sqrt{1-z})}{2z^2}.\]
which corresponds to OEIS sequence A278301~\cite{oeis}.

\subsection{\texorpdfstring{$\operatorname{Av}(21)\mid\operatorname{Av}(21)\mid\operatorname{Av}(21)$}{Av(21)|Av(21)|Av(21)}}
In this example, we will demonstrate the use of the operators acting on sequences, together with the use of the $\Phi$ and $\Theta$ operators. For this, our construction of the double juxtaposition $\operatorname{Av}(21)\mid\operatorname{Av}(21)\mid\operatorname{Av}(21)$ will be somewhat contrived, appending one class $\operatorname{Av}(21)$ to the right, then appending the other increasing sequence to the left (via symmetries).

We begin with the following regular specification for $\operatorname{Av}(21)$ that tracks both the leftmost and rightmost entries:
\[\mathcal{C} = \Z^{\mathsf{LR}} + \Z^{\mathsf{L}}\textsc{Seq}(\mathcal{Z})\Z^{\mathsf{R}}.\]
Since we need to keep track of the leftmost entry, we use the following equation for our first juxtaposition.
\[\mathcal{C}\mid\operatorname{Av}(21) =\mathcal{E}+\Z^{\mathsf{LR}} +\Z^{\mathsf{L}}\textsc{Seq}(\mathcal{Z})\Z^{\mathsf{R}}+\Omega_\i(\mathcal{C})+\Omega_\ii(\mathcal{C})+\Omega_\io(\mathcal{C})\textsc{Seq}(\mathcal{Z})\Z^{\mathsf{R}}.\]
However, as we will only be appending to each side once, we do not need to keep track of the rightmost entry in the above expression. We can therefore use the following simplified version:
\begin{equation}\label{eq:simplified}
	\mathcal{C}\mid\operatorname{Av}(21) =\mathcal{E}+\Z^{\mathsf{L}}\textsc{Seq}(\mathcal{Z}) +\Omega_\io(\mathcal{C})\textsc{Seq}(\mathcal{Z}).
\end{equation}
The only term we need to expand in the above is $\Omega_\io(\mathcal{C})$, and we do this first, separately. For ease of viewing, we use $\S_{\mathcal{Z}}$ for $\textsc{Seq}(\mathcal{Z})$, and make use of expressions such as $\mathcal{E} + \S_{\mathcal{Z}}\mathcal{Z} = \S_{\mathcal{Z}}$ to simplify the presentation. Similarly, we will also use the superscript $+$ to denote non-empty sequences, thus we have, for example, $\S_{\mathcal{Z}}^+ = \S_{\mathcal{Z}}\mathcal{Z} = \mathcal{Z}\S_{\mathcal{Z}}$ and $\seq^+(\mathcal{A}) = \textsc{Seq}(\mathcal{A})\mathcal{A}$.
\[
\Omega_\io(\mathcal{C}) = \left(\S_{\mathcal{Z}}^+\Z^{\mathsf{L}}  + \Z^{\mathsf{L}}\S_{\mathcal{Z}}^+\SZp\right) \textsc{Seq}(\S_{\mathcal{Z}}^+).
\]
Thus
\[
\mathcal{C}\mid\operatorname{Av}(21) =\mathcal{E}+\Z^{\mathsf{L}}\S_{\mathcal{Z}} +\left(\S_{\mathcal{Z}}^+\Z^{\mathsf{L}}  + \Z^{\mathsf{L}}\S_{\mathcal{Z}}^+\SZp\right) \textsc{Seq}(\S_{\mathcal{Z}}^+)\S_{\mathcal{Z}}.
\]

Momentarily evaluating this as a generating function, we have
\[f_{\mathcal{C}\mid\operatorname{Av}(21)}(z) = \frac{1}{1-z} + \frac{z^2}{(1-z)^2(1-2z)}\]
as expected.

We now turn to appending $\operatorname{Av}(21)$ to the left of $\mathcal{C}\mid\operatorname{Av}(21)$. First, we need to apply the operators $\Phi$ and $\Theta$ to the specification above, yielding the following specification for $\operatorname{Av}(21)\mid\mathcal{C}^{rc}$:
\begin{align*}
\operatorname{Av}(21)\mid\mathcal{C}^{rc} &=\mathcal{E}+\S_{\mathcal{Z}}\Z^{\mathsf{R}} + \S_{\mathcal{Z}} \textsc{Seq}(\S_{\mathcal{Z}}^+) \left(\Z^{\mathsf{R}}\S_{\mathcal{Z}}^+  + \S_{\mathcal{Z}}^+\SZp \Z^{\mathsf{R}}\right)\\
&=\mathcal{E}+\S_{\mathcal{Z}}\Z^{\mathsf{R}} +  \textsc{Seq}(\S_{\mathcal{Z}}^+)\left(\S_{\mathcal{Z}}\Z^{\mathsf{R}}\S_{\mathcal{Z}}^+  +  \S_{\mathcal{Z}}^+\SZp \S_{\mathcal{Z}}\Z^{\mathsf{R}}\right)
\end{align*}
Again, we will use the simplified equation~(\ref{eq:simplified}) to find the specification for $\operatorname{Av}(21)\mid\mathcal{C}^{rc}\mid\operatorname{Av}(21)$, without keeping track of the rightmost entry. This requires us to compute $\Omega_\io(\operatorname{Av}(21)\mid\mathcal{C}^{rc})$:
\begin{align*}
\Omega_\io(\operatorname{Av}(21)\mid\mathcal{C}^{rc}) &= \S_{\mathcal{Z}}^+\seq^+(\S_{\mathcal{Z}}^+) + \seq^+(\S_{\mathcal{Z}}^+)\seq^+(\S_{\mathcal{Z}}^+)\seq^+(\seq^+(\S_{\mathcal{Z}}^+))\seq^+(\S_{\mathcal{Z}}^+)\textsc{Seq}(\S_{\mathcal{Z}}^+)  \\
&\qquad + \seq^+(\S_{\mathcal{Z}}^+) \left[  \textsc{Seq}(\S_{\mathcal{Z}}^+)\seq^+(\S_{\mathcal{Z}}^+) + \S_{\mathcal{Z}}^+\seq^+(\S_{\mathcal{Z}}^+) + \S_{\mathcal{Z}}^+\SZp  \right]\seq^+(\S_{\mathcal{Z}}^+).
\end{align*}
Inserting this into equation~(\ref{eq:simplified}) yields a specification for $\operatorname{Av}(21)\mid\mathcal{C}^{rc}\mid\operatorname{Av}(21)$. Moving to generating functions, and noting that the classes $\operatorname{Av}(21)\mid\mathcal{C}^{rc}\mid\operatorname{Av}(21)$ and $\operatorname{Av}(21)\mid\mathcal{C}\mid\operatorname{Av}(21)$ are identical (and hence equinumerous), we obtain the following generating function.
\[
f_{\operatorname{Av}(21)\mid\operatorname{Av}(21)\mid\operatorname{Av}(21)} = \frac{1}{1-z} + \frac{z^2}{(1-z)^2(1-2z)} + \frac{z^3(1+z-4z^2)}{(1-z)^3(1-2z)^2(1-3z)}.
\]
This agrees with the expression given in Bevan's thesis~\cite[page~34]{bevan:phd}, and gives sequence A326355 in the OEIS~\cite{oeis}.

\subsection{Separable permutations}

  The following is an illustrated bottom-to-top specification for the class of \emph{non-empty} separable permutations, $\operatorname{Av}(2413,3142)$:
  \begin{align*}
    \mathcal{C} &= \mathcal{Z} + \cplusc{\C^{\oplus}}{\mathcal{C}} + \cminusc{\mathcal{C}}{\C^{\ominus}}\\
    \C^{\ominus} &= \mathcal{Z} + \cplusc{\C^{\oplus}}{\mathcal{C}}\\
    \C^{\oplus} &=\mathcal{Z} + \cminusc{\mathcal{C}}{\C^{\ominus}}
  \end{align*}
  where $\C^{\ominus}$ and $\C^{\oplus}$ denote the skew-indecomposable and sum-indecomposable permutations in $\mathcal{C}$, respectively. The following specification then tracks the rightmost entry:
  \begin{align*}
    \C^{\mathsf{R}} &= \Z^{\mathsf{R}} + \C^{\oplus}\C^{\mathsf{R}} + \C^{\mathsf{R}}\C^{\ominus}\\
    \mathcal{C} &= \mathcal{Z} + \C^{\oplus}\mathcal{C} + \mathcal{C}\C^{\ominus}\\
    \C^{\ominus} &= \mathcal{Z} + \C^{\oplus}\mathcal{C}\\
    \C^{\oplus} &= \mathcal{Z} + \mathcal{C}\C^{\ominus}.
  \end{align*}
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 $\operatorname{Av}(21)$.

First, although we do not need to know the basis of this class for our method, we can compute that $\mathcal{C}\mid\operatorname{Av}(21)$ is equivalent to
\[\operatorname{Av}(25143,35142,35241,41532,42531,241365,251364,314265,315264,415263).\]

To describe the complete specification for $\C^{\mathsf{R}}\mid\operatorname{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^{\mathsf{R}}\mid\operatorname{Av}(21)$ using the simplified equation~(\ref{eq:simplified}). This requires the following 11 equations (together with the equation for $\S_{\mathcal{Z}}$, and the equation for the class itself).
\begin{align*}
\C^{\mathsf{R}}_{\bullet\circ} &= \mathcal{Z}\S_{\mathcal{Z}}\mathcal{Z} + \C^{\oplus}_{\bullet\circ}\C^{\mathsf{R}}_{\circ\circ} + \C^{\oplus}_\o\C^{\mathsf{R}}_{\bullet\circ} + \C^{\mathsf{R}}_{\bullet\circ} \C^{\ominus}_{\circ\circ}\\
\C^{\mathsf{R}}_{\circ\circ} &= \S_{\mathcal{Z}}\mathcal{Z} +\C^{\oplus}_{\circ\circ}\C^{\mathsf{R}}_{\circ\circ} + \C^{\mathsf{R}}_{\circ\circ}\C^{\ominus}_{\circ\circ}\\
\mathcal{C}_{\bullet\circ} &= \mathcal{Z}\S_{\mathcal{Z}}\mathcal{Z} + \C^{\oplus}_{\bullet\circ}\mathcal{C}_{\circ\circ} + \C^{\oplus}_\o\mathcal{C}_{\bullet\circ} + \mathcal{C}_{\bullet\circ}\C^{\ominus}_{\circ\circ} + \mathcal{C}_\o\C^{\ominus}_{\bullet\circ}\\
\mathcal{C}_{\circ\circ} &= \S_{\mathcal{Z}}\mathcal{Z} + \C^{\oplus}_{\circ\circ}\mathcal{C}_{\circ\circ} + \mathcal{C}_{\circ\circ}\C^{\ominus}_{\circ\circ}\\
\mathcal{C}_\o &= \mathcal{Z}+\C^{\oplus}_\o\mathcal{C}_\o + \mathcal{C}_\o\C^{\ominus}_\o\\
\C^{\ominus}_{\bullet\circ} &= \mathcal{Z}\S_{\mathcal{Z}}\mathcal{Z} + \C^{\oplus}_{\bullet\circ}\mathcal{C}_{\circ\circ} + \C^{\oplus}_\o\mathcal{C}_{\bullet\circ}\\
\C^{\ominus}_{\circ\circ} &= \S_{\mathcal{Z}}\mathcal{Z} + \C^{\oplus}_{\circ\circ}\mathcal{C}_{\circ\circ} \\
\C^{\ominus}_\o &= \mathcal{Z}+\C^{\oplus}_\o\mathcal{C}_\o\\
\C^{\oplus}_{\bullet\circ} &= \mathcal{Z}\S_{\mathcal{Z}}\mathcal{Z} + \mathcal{C}_{\bullet\circ}\C^{\ominus}_{\circ\circ} + \mathcal{C}_\o\C^{\ominus}_{\bullet\circ}\\
\C^{\oplus}_{\circ\circ} &=\S_{\mathcal{Z}}\mathcal{Z} + \mathcal{C}_{\circ\circ}\C^{\ominus}_{\circ\circ} \\
\C^{\oplus}_\o &= \mathcal{Z} + \mathcal{C}_\o\C^{\ominus}_\o
\end{align*}
Solving, we obtain the following
\begin{multline*}
	f_{\mathcal{C}\mid\operatorname{Av}(21)}(z) = \frac{(2-4z+z^2)xy}{4(1-z)(-2+7z-7z^2+z^3)} +\\ \frac{(-2+10z-15z^2+7z^3)x + (2-6z+z^2+6z^3-z^4)y -10+54z-99z^2+66z^3-9z^4}{4(1-z)^2(-2+7z-7z^2+z^3)}
\end{multline*}
where
\[ x=\sqrt{1-6z+z^2} \quad\text{and}\quad y=\sqrt{1-8z+8z^2}.\]
The first ten terms of the counting sequence are
\[ 1,1,2,6,24,115,609,3409,19728,116692,701062.\]
This is sequence A326348 in OEIS~\cite{oeis}.
\section{Concluding remarks}\label{sec-conclusion}

\paragraph{Acyclic grids with one non-monotone}
A natural next step beyond the $k\times 1$ grids considered here are families of \emph{acyclic} grids in which at most one cell is non-monotone. This poses a number of challenges beyond the methods described in this article, notably to incorporate the ability to switch from a bottom-to-top specification to a left-to-right one, depending on where a new monotone cell needs to be appended. Another challenge is to identify some canonical way to handle griddings that is consistent in both directions.

\paragraph{Multiple non-monotone}
One can likely replace the monotone classes in our framework with certain other easy-to-describe classes, such as the class $\operatorname{Av}(312,231)$ of layered permutations.  This adds considerably to the number and complexity of the operators required, but the same principles apply.

On the other hand, our approach does not seem to offer insight for juxtapositions involving more complicated classes, for example juxtaposing two classes with algebraic generating functions. A notable example of such a juxtaposition is $\operatorname{Av}(132)\mid\operatorname{Av}(213)$, which is the superclass of the ``domino'' used in recent bounds on the growth rate of $\operatorname{Av}(1324)$~\cite{bbep:1324}.

\bibliographystyle{acm}