1 Introduction

Starting with Knuth’s [1] work on permutations in 1973, the field of pattern avoidance has been well studied in enumerative combinatorics. Simion and Schmidt first considered pattern avoidance in their work on enumerating permutation avoidance classes in 1985 [2]. Pattern avoidance can be defined as follows:

Definition 1.1

Let \(\sigma \in S_{n}\) and \(\pi \in S_{k}\), where \(k \le n\). We say that the permutation \(\sigma \) contains the pattern \(\pi \) if there exists indices \(c_1< \dots < c_k\) such that \(\sigma (c_1) \cdots \sigma (c_k)\) is order-isomorphic to \(\pi \). We say a permutation avoids a pattern if it does not contain it.

Permutations avoiding sets of small patterns have been exhaustively enumerated [1,2,3]. It is well known that permutations avoiding certain patterns are in bijection with other combinatorial objects, such as Dyck paths [4, 5] and maximal chains of lattices [2]. Some of them are further enumerated by the Catalan and Schröder numbers [6]. In their work, Simion and Schmidt [2] completely enumerated permutations avoiding any single pattern, two patterns, or three patterns of size 3, paving the path for more work in the field of pattern avoidance.

More recently, Bonichon and Morel [7] considered a multidimensional generalization of a permutation, called a d-permutation, which resembles the structure of a \((d-1)\)-tuple of permutations. Tuples of permutations have been studied before [8, 9], but d-permutations have not been thoroughly studied yet, mainly appearing in a few papers related to separable permutations [9, 10]. In particular, Asinowski and Mansour [10] presented a generalization of separable permutations that are similar to d-permutations and characterized these generalized permutations with sets of forbidden patterns. The d-permutations studied by Bonichon and Morel coincide with the one introduced by Asinowski and Mansour [10] for the multidimensional case but also coincide with the classical permutation for \(d=2\).

Similar to the enumeration Simion and Schmidt [2] did in 1985 and Mansour [3] in 2020, Bonichon and Morel [7] started the enumeration of d-permutations avoiding small patterns and made many conjectures regarding the enumeration of 3-permutations avoiding sets of two patterns. We present two main classes of results regarding the enumeration of 3-permutation avoiding small patterns. We first completely enumerate 3-permutations avoiding classes of two patterns of size 3 and prove their respective recurrence relations, solving the conjectures presented by Bonichon and Morel [7]. Further, we derive a recurrence relation for 3-permutations avoiding 132 and 213, whose sequence we added to the OEIS database [11], and Bonichon and Morel did not provide any conjecture. We then further initiate and completely enumerate 3-permutations avoiding classes of three patterns of size 3, similar to Simion and Schmidt’s results in 1985 [2].

This paper is organized as follows. In Sect. 2, we introduce preliminary definitions and notation. In Sect. 3, we completely enumerate sequences of 3-permutations avoiding two patterns of size 3 and prove four conjectures of Bonichon and Morel [7]. In addition, we prove a recurrence relation for an avoidance class whose sequence we added to the OEIS database [11], completing our enumeration. In Sect. 4, we extend our enumeration to 3-permutations avoiding three patterns of size 3 and prove recurrence relations for their avoidance classes. We conclude with open problems in Sect. 5.

2 Preliminaries

Let \(S_n\) denote the set of permutations of \([n] = \{ 1,2, \dots , n \}\). Note that we can represent each permutation \(\sigma \in S_n\) as a sequence \(a_1 \cdots a_n\). Further, let \(\textrm{Id}_n\) denote the identity permutation \(12 \cdots n\) of size n and given a permutation \(\sigma = a_1 \cdots a_n \in S_n\), let \({{\,\mathrm{\textrm{rev}}\,}}(\sigma )\) denote the reverse permutation \(a_n \cdots a_1\). We further say that a sequence \(a_1 \cdots a_n\) is consecutively increasing (respectively, decreasing) if for every index i, \(a_{i+1} = a_i+1\) (respectively, \(a_{i+1} = a_i-1\)).

For a sequence \(a = a_1 \cdots a_n\) with distinct real values, the standardization of a is the unique permutation of [n] with the same relative order. Note that once standardized, a consecutively increasing sequence is the identity permutation and a consecutively decreasing sequence is the reverse identity permutation. Moreover, we say that in a permutation \(\sigma = a_1 \cdots a_n\), the elements \(a_i\) and \(a_{i+1}\) are adjacent to each other. More specifically, \(a_i\) is left-adjacent to \(a_{i+1}\) and similarly, the element \(a_{i+1}\) is \(right-adjacent \) to \(a_i\). The following definitions in this section were introduced in [7].

Definition 2.1

A d-permutation \(\varvec{\sigma } := (\sigma _1 , \dots , \sigma _{d-1})\) of size n is a tuple of permutations, each of size n. Let \(S_{n}^{d-1}\) denote the set of d-permutations of size n. We say that d is the dimension of \(\varvec{\sigma }\). Moreover, the diagram of \(\sigma \) is the set of points \((i, \sigma _1(i),\dots , \sigma _{d-1}(i))\) for all \(i \in [n]\).

Note that the identity permutation is implicitly included in the diagram of a d-permutation, which justifies why a d-permutation is a \((d-1)\)-tuple of permutations. For a d-permutation \(\varvec{\sigma } = (\sigma _1,\dots , \sigma _{d-1}),\) let \(\varvec{\bar{\sigma }} = (\textrm{Id}_n, \sigma _1, \dots , \sigma _{d-1}).\) Further, with this definition, it is natural to consider the projections of the diagram of a d-permutation, which is useful in defining the notion of pattern avoidance for d-permutations.

Definition 2.2

Given \(d' \in {\mathbb {N}}\) and \({\varvec{i}} = i_1, \dots , i_{d'} \in [d]^{d'}\), the projection on \({\varvec{i}}\) of some d-permutation \(\varvec{\sigma }\) is the \(d'\)-permutation \(\textrm{proj}_{{\varvec{i}}}(\varvec{\sigma }) = (\varvec{\bar{\sigma }}_{i_2} \circ \varvec{\bar{\sigma }}_{i_1}^{-1}, \dots , \varvec{\bar{\sigma }}_{i_{d'}} \circ \varvec{\bar{\sigma }}_{i_1}^{-1} ).\)

We say that a projection is direct if \(i_1< \dots < i_{d'}\) and indirect otherwise.

Remark 2.3

There are only three direct projections of dimension 2 of a 3-permutation \(\varvec{\sigma } = (\sigma , \sigma ')\). Namely, they are \(\sigma \), \(\sigma '\), and \(\sigma ' \circ \sigma ^{-1}\).

In the remainder of the section, we use the projection of a 3-permutation \(\varvec{\sigma } = (\sigma , \sigma ')\) to refer to the projection \(\sigma ' \circ \sigma ^{-1}\). As such, we will also refer to \(\sigma ' \circ \sigma ^{-1}\) as \({{\,\mathrm{\textrm{proj}}\,}}(\sigma , \sigma ')\) for ease of notation.

In this paper, we will also consider the projection \(\pi ' \circ \pi ^{-1}\) for subpermutations \(\pi , \pi '\). We write \(\rho = \pi ' \circ \pi ^{-1}\) to mean the composition of the standardization of \(\pi \) and \(\pi '\), rewritten to be the elements of \(\pi '\) with the same relative order. For example, if \(\pi = 5467\) and \(\pi ' = 2365\), then \(\pi ' \circ \pi ^{-1}\) is calculated as following. We first standardize \(\pi \) and \(\pi '\) to be 2134 and 1243, respectively. Then the composition of these two permutations is 2143. Finally, we rewrite the permutation to be the elements of \(\pi '\) with the same order as 2143, giving 3265 to be the final projection.

Using direct projections, Bonichon and Morel [7] introduced the following definition of pattern avoidance, which is consistent with the existing concept of pattern avoidance for regular permutations.

Definition 2.4

Let \(\varvec{\sigma } = (\sigma _1 ,\dots , \sigma _{d-1}) \in S_{n}^{d-1}\) and \(\varvec{\pi } = (\pi _1, \dots , \pi _{d'-1}) \in S_{k}^{d'-1}\), where \(k \le n\). We say that the d-permutation \(\varvec{\sigma }\) contains the pattern \(\varvec{\pi }\) if there exists a direct projection \(\varvec{\sigma '}\) of dimension \(d'\) and indices \(c_1< \dots < c_k\) such that \(\varvec{\sigma '}_i(c_1) \cdots \varvec{\sigma '}_i(c_k)\) is order-isomorphic to \(\pi _i\) for all i. We say a d-permutation avoids a pattern if it does not contain it.

For example, the 3-permutation (4231, 2413) avoids the pattern 123 because neither the permutations 4231, 2413, nor the projection \(2413 \circ 4231^{-1} = 3412\) contains an occurrence of 123. Furthermore, note that the 3-permutation (1432, 3124) contains the pattern 231, because despite 1432 and 3124 avoiding an occurrence of 231, the projection \(3124 \circ 1432^{-1} = 3421\) has an occurrence of 231.

Given m patterns \(\varvec{\pi _1}, \dots , \varvec{\pi _m}\), we write \(S_{n}^{d-1}(\varvec{\pi _1}, \dots , \varvec{\pi _m})\) to mean the set of d-permutations of size n that simultaneously avoid \(\varvec{\pi _1}, \dots , \varvec{\pi _m}\).

Bonichon and Morel [7] also noted symmetries on d-permutations that correspond to symmetries on the d-dimensional cube. In particular, these symmetries are counted by signed permutation matrices of dimension d. Such a signed permutation matrix is a square matrix with entries consisting of \(-1, 0\), or 1 such that each row and column contain exactly one nonzero element. We call \(\textit{d-Sym}\) the set of such signed permutation matrices of size d.

This allows us to extend the well-known definitions of Wilf-equivalence and trivial Wilf-equivalence to higher dimensions.

Definition 2.5

We say that two sets of patterns \(\varvec{\pi _1}, \dots , \varvec{\pi _k}\) and \(\varvec{\tau _1}, \dots , \varvec{\tau _\ell }\) are d-Wilf-equivalent if \(|S_{n}^{d-1}(\varvec{\pi _1}, \dots , \varvec{\pi _k})| = |S_n^{d-1}(\varvec{\tau _1}, \dots , \varvec{\tau _\ell })|\). Moreover, these patterns are trivially d-Wilf-equivalent if there exists a symmetry \(s \in \textit{d-Sym}\) that maps \(S_{n}^{d-1}(\varvec{\pi _1}, \dots , \varvec{\pi _k})\) to \(S_n^{d-1}(\varvec{\tau _1}, \dots , \varvec{\tau _\ell })\) bijectively.

In the following sections, we will only work with 3-permutations avoiding 2-permutations.

3 Enumeration of Pattern Avoidance Classes of at Most Size 2

Bonichon and Morel [7] proposed the problem of enumerating sequences of 3-permutations avoiding at most two patterns of size 2 or 3. They provided Table 1, conjecturing the recurrences in the last four rows and leaving the remainder as open problems.

Table 1 Sequences of 3-permutations avoiding at most two patterns of size 2 or 3

In all of the following theorems, we take constructive approaches to prove recurrence relations. Given an element \(\varvec{\sigma }\) in \(S_n^2(\pi _1, \pi _2)\), we attempt to construct elements in \(S_{n+1}^2(\pi _1, \pi _2)\) via inserting the maximal element \(n+1\) into the permutations in \(\varvec{\sigma }\). Note that if a permutation \(\sigma \in S_n\) contains a pattern \(\pi \), then adding the maximal element \(n+1\) anywhere into \(\sigma \) still contains \(\pi \). Similarly, if a permutation \(\sigma \in S_n\) avoids a pattern \(\pi \), then removing the maximal element n from \(\sigma \) will still avoid \(\pi \).

However, it should be noted that it is possible to have a 3-permutation \((\sigma , \sigma ')\) that does not avoid a set of permutations \(\{ \pi _1, \dots , \pi _m \}\) and inserting the maximum element \((n+1)\) into both \(\sigma \) and \(\sigma '\) results in a 3-permutation that avoids these patterns. For example, the 3-permutation (312, 123) contains 231, but (3124, 4123) avoids both 231 and 321. Although in the following proofs we aim to construct elements in \(S_{n+1}^2(\pi _1, \pi _2)\) from \(S_n^2(\pi _1, \pi _2)\), we will prove that for each set of patterns \(\{\pi _1, \pi _2\}\), it is impossible to insert \(n+1\) into \(\sigma \) and \(\sigma '\) of a 3-permutation \((\sigma , \sigma ')\) containing \(\pi _1\) or \(\pi _2\) such that the resulting 3-permutation avoids \(\pi _1\) and \(\pi _2\). It is clear that if \(\sigma \) or \(\sigma '\) contains these patterns, then inserting \(n+1\) anywhere into these permutations will still contain these patterns. Hence, it is enough to show that for a 3-permutation \((\sigma , \sigma ')\) where \(\sigma \) and \(\sigma '\) avoid \(\pi _1\) and \(\pi _2\) but \(\sigma ' \circ \sigma ^{-1}\) contains either pattern, inserting \(n+1\) anywhere will result in a 3-permutation which still contains either pattern. In the following proofs, note that given a 3-permutation \((\sigma , \sigma ')\), if the maximal element \(n+1\) is inserted into the same position in both \(\sigma \) and \(\sigma '\), then \(n+1\) is inserted at the end of the projection \(\sigma ' \circ \sigma ^{-1}\).

Theorem 3.1

Let \(a_n = |S_n^2(132,231)|\). Then \(a_n\) satisfies the recurrence relation \(a_{n+1} = 2a_n + 2^{n}\) with initial term \(a_1 =1\), which corresponds with OEIS sequence A001787.

Proof

Given any \(\varvec{\sigma } = (\sigma , \sigma ') \in S^2_n(132,231)\), we construct an element of \(S^2_{n+1}(132,231)\) by inserting the maximal element \(n+1\) in both \(\sigma \) and \(\sigma '\). To avoid both 132 and 231, the maximal element \(n+1\) must be inserted into either the beginning or end of \(\sigma \) and \(\sigma '\); otherwise if there are elements on both sides of \(n+1\), then there must be either an occurrence of 132 or 231.

Appending the maximal element \(n+1\) onto the left of both \(\sigma \) and \(\sigma '\) or onto the right of both \(\sigma \) and \(\sigma '\) also avoids 132 and 231. In other words, \((\sigma (n+1), \sigma '(n+1))\) and \(((n+1)\sigma , (n+1)\sigma ')\) both still avoid 132 and 231. This contributes \(2a_{n}\) different 3-permutations in \(S_{n+1}^2(132,231)\).

We further make the following claim:

Claim 3.2

The 3-permutation \((\sigma (n+1), (n+1)\sigma ')\) avoids 132 and 231 if and only if \(\sigma \) is \(\textrm{Id}_n\) and \(\sigma ' \in S_n^1(132,231)\).

Proof

For the forwards direction, suppose that \((\sigma (n+1), (n+1)\sigma ')\) avoids 132 and 231. Now writing the projection \({{\,\mathrm{\textrm{proj}}\,}}(\sigma (n+1), (n+1)\sigma ') = (\sigma _L (n+1) \sigma _R)\) for some subpermutations \(\sigma _L\) and \(\sigma _R\), note that \(\sigma _R\) is nonempty, and using the reasoning mentioned above, \(\sigma _L\) is empty. Otherwise, \((\sigma _L (n+1) \sigma _R)\) contains an occurrence of either 132 or 231. Thus, \(\sigma \) begins with the minimal element 1. But since \(\sigma \) is forced to avoid the 132 pattern, \(\sigma \) is forced to be consecutive and becomes the identity permutation.

For the backwards direction, both \({{\,\mathrm{\textrm{Id}}\,}}_{n+1}\) and \(((n+1)\sigma ')\) still avoid 132 and 231. Further, the projection \({{\,\mathrm{\textrm{proj}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_{n+1}, (n+1)\sigma ')\) evaluates to \((n+1)\sigma '\), which also still avoids 132 and 231. \(\square \)

Similarly, we have by symmetry the following claim:

Claim 3.3

The 3-permutation \(((n+1)\sigma , \sigma '(n+1))\) avoids 132 and 231 if and only if \(\sigma \) is \(\textrm{rev}(\textrm{Id}_n)\) and \(\sigma ' \in S_n^1(132,231)\).

Now we show that for \((\sigma , \sigma ') \in S_n^2 {\setminus } S_n^2(132,231)\), we cannot obtain an element in \( S_{n+1}^2(132,231)\) by inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\). We will assume that \(\sigma \) and \(\sigma '\) avoid these patterns but \(\sigma ' \circ \sigma ^{-1}\) does not. Recall that we are forced to insert \(n+1\) onto the left or right of \(\sigma \) and \(\sigma '\). Inserting \(n+1\) onto the left of both \(\sigma \) and \(\sigma '\) or onto the right of both \(\sigma \) and \(\sigma '\) gives a 3-permutation with a projection containing \(\sigma ' \circ \sigma ^{-1}\), which contains either 132 or 231. Now for the 3-permutation \(((n+1)\sigma , \sigma '(n+1))\), our reasoning in Claim 3.3 gives that either the projection contains 132 or 231 or that \(\sigma = {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n)\). In the latter case, \({{\,\mathrm{\textrm{proj}}\,}}(\sigma , \sigma ')\) would become \({{\,\mathrm{\textrm{rev}}\,}}(\sigma ')\), which avoids 132 and 231, a contradiction. Claim 3.2 provides a similar reasoning on how \((\sigma (n+1), (n+1)\sigma ')\) contains 132 or 231. Because inserting \(n+1\) anywhere else in \(\sigma \) and \(\sigma '\) gives an occurrence of 231 or 132, we ensure that elements of \(S_n^2\) not belonging in \(S_n^2(132,231)\) cannot result in elements belonging in \(S_{n+1}^2(132,231)\) when we insert the maximal element \(n+1\) anywhere into \(\sigma \) and \(\sigma '\).

Thus, we have shown that given any 3-permutation \(\varvec{\sigma } = (\sigma , \sigma ') \in S^2_n (132,231)\), we can construct two elements in \(S^2_{n+1}(132,231)\); furthermore, we can construct one additional element in \(S^2_{n+1}(132,231)\) if and only if \(\sigma ' \in S^1_n(132,231)\) and \(\sigma \) is \({{\,\mathrm{\textrm{Id}}\,}}_n\) or \({{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n)\). Simion and Schmidt [2] have shown that \(|S^1_n(132,231)| = 2^{n-1}\). In the cases where \(\sigma \) is \({{\,\mathrm{\textrm{Id}}\,}}_n\) or \({{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n)\), it follows that \(\varvec{\sigma }\) avoids 132 and 231 if and only if \(\sigma '\) avoids these patterns, and hence, it follows that

$$\begin{aligned} a_{n+1} = 2a_n + 2^n.&\end{aligned}$$

\(\square \)

Theorem 3.4

Let \(a_n = |S^2_n(132,321)|\). Then \(a_n\) satisfies the recurrence \(a_{n+1} = a_n +n(n+2)\) with initial term \(a_1 = 1\), which corresponds with the OEIS sequence A047732.

Proof

Let us write \(\varvec{\sigma } = (\sigma , \sigma ') \in S^2_n(132,321)\) of the form \((\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\). We construct an element of \(S^2_{n+1}(132,321)\) by inserting the maximal element \(n+1\) in both \(\sigma \) and \(\sigma '\).

Inserting \(n+1\) onto the end of \(\sigma \) and \(\sigma '\) always constructs a 132-avoiding and 321-avoiding 3-permutation, and this contributes \(a_n\) different 3-permutations to \(S^2_{n+1}(132,321)\).

We also have the following three cases. Figure 1 gives an example on what \(\sigma \) may look like.

  1. (1)

    \(\sigma _R\) and \(\sigma _R'\) are both nonempty and \(\sigma _L n\), \(\sigma _L' n\), \(\sigma _R\), and \(\sigma _R'\) are all consecutively increasing.

  2. (2)

    Exactly one of \(\sigma _R\), \(\sigma _R'\) is empty and the other is of the form \(\sigma _L n \sigma _R\), where \(\sigma _L n\) and \(\sigma _R\) are consecutively increasing.

  3. (3)

    Both \(\sigma _R\), \(\sigma _R'\) are empty.

Fig. 1
figure 1

An example of what \(\sigma _L n \sigma _R\) may look like when avoiding 132 and 321

First we show that when \(\varvec{\sigma }\) does not belong to any of these cases, inserting the maximal element \(n+1\) into \(\varvec{\sigma }\) cannot avoid these patterns. Let \(\varvec{\sigma } = (\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\). If \(\sigma _L n\) is increasing but not consecutively increasing, \(\sigma \) must contain an occurrence of 132. Further, note that \(\sigma _R\) must not contain a 21 pattern, and in the case where \(\sigma _L n\) is consecutively increasing, \(\sigma _R\) is consecutively increasing.

So the only case we need to consider is where there is an occurrence of ab in \(\sigma _L\) for some \(b <a\); the argument for where \(\sigma _L'\) contains the pattern 21 is similar. Note that every element of \(\sigma _L\) and \(\sigma _L'\) still must be greater than every element of \(\sigma _R\) and \(\sigma _R'\), respectively; otherwise, they would contain an occurrence of 132. This implies that \(\sigma _R\) cannot contain elements in the interval (bn). Similarly, if \(\sigma _R\) contains elements in the interval [1, b), then \(\varvec{\sigma }\) would contain an occurrence of 321. Thus, \(\sigma _R\) is empty. Inserting \(n+1\) to the left of a gives an occurrence of 321. And inserting \(n+1\) to the right of a gives an occurrence of 132. Hence, nothing outside these cases avoids 132 and 321.

Now we present each case:

  1. (1)

    We claim that only \((\sigma _L n (n+1) \sigma _R, \sigma _L' n (n+1) \sigma _R')\) avoids 132 and 321.

    Let us write \(\gamma \) as the projection \((\sigma _L' n (n+1) \sigma _R') \circ (\sigma _L n (n+1) \sigma _R)^{-1}\). Since \(\sigma _L\) and \(\sigma _R\) are consecutive and \(\sigma _R\) must start with 1, note that in \(\gamma \), either \(n+1\) is right-adjacent to n, or \(\gamma \) begins with \(n+1\). In the former case, \(\gamma \) is of the form \(\pi _L \pi _R\), where \(\pi _L\) and \(\pi _R\) are consecutively increasing and each element of \(\pi _L\) is greater than each element of \(\pi _R\). Note that \(\pi _R\) may be empty, in which case \(\pi _L\) is the identity permutation. It is clear that \(\pi _L \pi _R\) avoids 132 and 321. In the latter case, \(\gamma \) is of the form \((n+1) \sigma _R' \sigma _L' n\). But \(\sigma _R' \sigma _L' n\) is strictly increasing, and hence, \(\gamma \) also avoids 132 and 321. Therefore, the 3-permutation \((\sigma _L n (n+1) \sigma _R, \sigma _L' n (n+1) \sigma _R')\) avoids these patterns too.

    Now we show that inserting \(n+1\) into \(\varvec{\sigma }\) anywhere else cannot result in an element in \(S_{n+1}^2(132,321)\). In particular, we show that we are forced to insert \(n+1\) at the end of \(\sigma \) and \(\sigma '\) or right-adjacent to n in these two permutations. Otherwise, since \(\sigma _L\), \(\sigma _L'\), \(\sigma _R\), and \(\sigma _R'\) are all consecutively increasing, \(\sigma \) or \(\sigma '\) would contain 132. If we insert \(n+1\) to the left of \(\sigma \) or \(\sigma '\), we would have an occurrence of 321.

    Now it is sufficient to show \((\sigma _L n \sigma _R (n+1), \sigma _L' n (n+1) \sigma _R')\) and \((\sigma _L n (n+1) \sigma _R, \sigma _L' n \sigma _R' (n+1))\) do not avoid 132 and 321.

    To see the former, we take the projection \(\rho \), and depending on the lengths of \(\sigma _L\) and \(\sigma _L'\), we have the following three cases. The projections in each case are illustrated in Fig. 2.

    1. (a)

      \(|\sigma _L| = |\sigma _L'|\). Then the last two elements of \(\rho \) must be nr, where r is an element in \(\sigma _R'\). Note that the maximum element \(n+1\) must appear before this occurrence, and hence, \(\rho \) contains an occurrence of 321.

    2. (b)

      \(|\sigma _L| < |\sigma _L'|\). Then the last two elements of \(\rho \) must be \(\ell r\), where \(\ell \) is an element in \(\sigma _L'\) and r is an element in \(\sigma _R'\). Note that the maximum element \(n+1\) must appear somewhere in \(\rho \) before this occurrence, and thus, \(\rho \) contains an occurrence of 321.

    3. (c)

      \(|\sigma _L| > |\sigma _L'|\). Then \(\rho \) begins with an element a in \(\sigma _R'\) and ends with a larger element b in \(\sigma _R'\). However, the maximum element \(n+1\) must appear in between these elements, and we conclude that \(\rho \) contains an occurrence of 132.

    A similar reasoning shows that \((\sigma _L n (n+1) \sigma _R, \sigma _L' n \sigma _R' (n+1))\) does not avoid 132 and 321.

    There are \((n-1)\) ways to choose \(\sigma _L n \sigma _R\) and \(\sigma _L' n \sigma _R'\). This case contributes \((n-1)^2\) distinct 3-permutations to \(S^2_{n+1}(132,321)\).

  2. (2)

    Let \(\sigma _R\) be empty—the case where \(\sigma _R'\) is empty follows a similar reasoning. Then we claim that only the 3-permutations \(((n+1)\sigma _L n, \sigma _L' n (n+1) \sigma _R')\) and \((\sigma _L n(n+1), \sigma _L' n (n+1) \sigma _R')\) avoid 132 and 321. Checking that both of these 3-permutations avoid 132 and 321 uses a similar argument to the previous case. Now we show that inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) cannot avoid the patterns 132 and 321. In particular, we must insert \(n+1\) into the beginning or end of \(\sigma \) and either right-adjacent to n or at the end in \(\sigma '\). Hence, it is sufficient to show that \(((n+1)\sigma _L n, \sigma _L' n \sigma _R' (n+1))\) does not avoid 132 and 321. Now taking \({{\,\mathrm{\textrm{proj}}\,}}((n+1)\sigma _L n, \sigma _L' n \sigma _R' (n+1))\) gives us a permutation of the form \(\pi (n+1) c\), where c is the first element of \(\sigma _L' n\) and \(\pi \) is some subpermutation. Since \(\sigma _R'\) is nonempty, \(\pi \) contains elements in \(\sigma _R'\), and this composition contains an instance of 132.

    Since there are \(n-1\) ways to choose \(\sigma _L' n \sigma _R'\), this contributes \(2(n-1)\) many 3-permutations to \(S^2_{n+1}(132,321)\). A similar argument holds for when \(\sigma _R'\) is empty and \(\sigma _R\) is nonempty. Hence, this case contributes \(4(n-1)\) many 3-permutations in total to \(S^2_{n+1}(132,321)\).

  3. (3)

    Note that we must insert \(n+1\) into the beginning or end of \(\sigma \) and \(\sigma '\). However, the only 3-permutations that avoid 132 and 321 obtained by inserting \(n+1\) into both \(\sigma \) and \(\sigma '\) are the following: \(({{\,\mathrm{\textrm{Id}}\,}}_n (n+1), (n+1) {{\,\mathrm{\textrm{Id}}\,}}_n)\), \(((n+1){{\,\mathrm{\textrm{Id}}\,}}_n, (n+1) {{\,\mathrm{\textrm{Id}}\,}}_n)\), and \(((n+1){{\,\mathrm{\textrm{Id}}\,}}_n, {{\,\mathrm{\textrm{Id}}\,}}_n (n+1))\). To see this, let us consider \(((n+1) \sigma , \sigma ' (n+1))\). Inserting \(n+1\) at the beginning of \(\sigma \) forces \(\sigma \) to be the identity. Using a similar reasoning presented in Case 2, unless \(\sigma ' = {{\,\mathrm{\textrm{Id}}\,}}_n\), inserting \(n+1\) at the end of \(\sigma '\) will cause \({{\,\mathrm{\textrm{proj}}\,}}((n+1) \sigma , \sigma ' (n+1))\) to contain 132. A similar argument can be used for the other 3-permutations, and checking that these avoid 132 and 321 is simple. Hence, this case contributes 3 new elements in \(S^2_{n+1}(132,321)\).

Fig. 2
figure 2

Illustrations of the projection of \((\sigma _L n \sigma _R (n+1), \sigma _L' n (n+1) \sigma _R')\) for the cases \(|\sigma _L| = |\sigma _L'|\), \(|\sigma _L| < |\sigma _L'|\), and \(|\sigma _L| > |\sigma _L'|\), respectively

Now we show that for \((\sigma , \sigma ') \in S_n^2 {\setminus } S_n^2(132,321)\), we cannot obtain an element in \( S_{n+1}^2(132,321)\) by inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\). Suppose \(\sigma \) and \(\sigma '\) avoid 132 and 321 but \(\sigma ' \circ \sigma ^{-1}\) contains either pattern. We iterate the same cases as above, noting that if none of these cases hold, inserting \(n+1\) anywhere will give a 3-permutation containing 132 or 321.

  1. (1)

    We show that it is impossible to have \(\sigma \) and \(\sigma '\) avoid these patterns but have \(\sigma ' \circ \sigma ^{-1}\) contain them. Let \((\sigma , \sigma ') = (\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\) and \(\rho = {{\,\mathrm{\textrm{proj}}\,}}(\sigma , \sigma ')\). Recall that \(\sigma _L n\), \(\sigma _L' n\), \(\sigma _R\), and \(\sigma _R\)’ are all consecutively increasing. We have the same subcases as above:

    1. (a)

      \(|\sigma _L| = |\sigma _L'|\). Then \(\rho \) is \(\sigma _R' \sigma _L' n\), which avoids 132 and 321.

    2. (b)

      \(|\sigma _L| < |\sigma _L'|\). Then \(\rho \) is in the form \(\pi _L \pi _R\), where \(\pi _L\) and \(\pi _R\) are consecutively increasing and every element of \(\pi _L\) is greater than every element of \(\pi _R\). Note that \(\rho \) avoids both 132 and 321.

    3. (c)

      \(|\sigma _L| > |\sigma _L'|\). Then \(\rho \) is in the same form as the previous case.

    Hence, it is impossible for \(\sigma \) and \(\sigma '\) to avoid 132 and 321 while \(\sigma ' \circ \sigma ^{-1}\) contains them.

  2. (2)

    Let \(\sigma _R\) be empty. The case where \(\sigma _R'\) is empty follows a similar reasoning. The proof of Case 2 above shows that the 3-permutation \(((n+1) \sigma _L n, \sigma _L' n \sigma _R' (n+1))\) contains an instance of 132, and it is clear that \((\sigma _L n (n+1), \sigma _L' n \sigma _R' (n+1))\) contains an occurrence of \(\sigma ' \circ \sigma ^{-1}\). Now we consider \(((n+1) \sigma _L n, \sigma _L' n (n+1) \sigma _R')\). Let \(\ell \) be the first element of \(\sigma _L'\). Now we note that \({{\,\mathrm{\textrm{proj}}\,}}((n+1) \sigma _L n, \sigma _L' n (n+1) \sigma _R')\) is obtained from \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n, \sigma _L' n \sigma _R')\) as follows: each element belonging to the subpermutation \(\sigma _L' n\) is increased by 1, every element in \(\sigma _R'\) remains unchanged, and \(\ell \) is appended onto the end of the permutation. It is clear that if \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n, \sigma _L' n \sigma _R')\) contains an instance of 132 or 321, then \({{\,\mathrm{\textrm{proj}}\,}}((n+1) \sigma _L n, \sigma _L' n (n+1) \sigma _R')\) must also contain an occurrence of these patterns.

    Now we consider \((\sigma _L n (n+1), \sigma _L' n (n+1) \sigma _R')\). Let r be the last element in \(\sigma _R'\). Similarly, \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n (n+1), \sigma _L' n (n+1) \sigma _R')\) is obtained from the \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n, \sigma _L' n \sigma _R')\) as follows: each element in \(\sigma _R'\) decreases by 1, the minimal element 1 is replaced with \(n+1\), elements in \(\sigma _L' n\) remain unchanged, and r is appended onto the end of the permutation. If the minimal element 1 is not a part of the occurrence of 132 or 321 in \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n, \sigma _L' n \sigma _R')\), then \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n (n+1), \sigma _L' n (n+1) \sigma _R')\) still contains an occurrence of either pattern. If the minimal element 1 is part of a 132 pattern, the transformation described above turns the pattern into a 321 pattern. Now suppose the minimal element 1 is part of a 321 pattern. Call this sequence xy1. If there is an element a after xy1, then if \(y>a\), then the transformation turns xy1 into a 321 pattern. If \(y<a\), then we instead have a 132 pattern. Now if xy1 are the last elements in the permutation, then the transformation turns this into a permutation ending in 1, which contains an occurrence of 321. Hence, \((\sigma _L n (n+1), \sigma _L' n (n+1) \sigma _R')\) must contain 132 or 321.

  3. (3)

    As mentioned in Case 3 above, for us to insert \(n+1\) anywhere else into \(\sigma \) and \(\sigma '\) to avoid 132 and 321 in the resulting 3-permutation, we must have \(\sigma = \sigma ' = {{\,\mathrm{\textrm{Id}}\,}}_n\). Then \(\sigma ' \circ \sigma ^{-1} = {{\,\mathrm{\textrm{Id}}\,}}_n\), which does not contain 132 or 321, a contradiction.

We conclude that

$$\begin{aligned} a_{n+1}&= a_n + (n-1)^2 + 4(n-1) +3 \\&= a_n + n(n+2).&\end{aligned}$$

\(\square \)

Theorem 3.5

Let \(a_n = |S^2_n(231,312)|\). Then \(a_n\) satisfies the recurrence \(a_{n+1} = 2a_n + 2a_{n-1}\) with initial terms \(a_1 = 1\) and \(a_2 =4\), which corresponds to the OEIS sequence A026150.

Proof

Let \(\varvec{\sigma } = (\sigma , \sigma ') \in S_n^2(231,312)\) and write \(\varvec{\sigma }\) of the form \((\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\). Note that each element of \(\sigma _L\) and \(\sigma _L'\) are less than each element of \(\sigma _R\) and \(\sigma _R'\), respectively. Further, \(\sigma _R\) and \(\sigma _R'\) have to be consecutively decreasing. If \(\sigma _R\) is nonempty, \(n-1\) must be right-adjacent to n in \(\sigma \) to avoid instances of 231 and 312. We then have the following cases, where \(\sigma _R\) and \(\sigma _R'\) may be empty. Figure 3 illustrates an example of what \(\sigma \) may look like.

  1. (1)

    \(\varvec{\sigma }\) is of the form \((\sigma _L n, \sigma _L' n)\).

  2. (2)

    \(\varvec{\sigma }\) is of the form \((\sigma _L (n-1) n, \sigma _L' n (n-1) \sigma _R')\).

  3. (3)

    \(\varvec{\sigma }\) is of the form \((\sigma _L n (n-1) \sigma _R, \sigma _L' (n-1) n)\).

  4. (4)

    \(\varvec{\sigma }\) is of the form \((\sigma _L n (n-1) \sigma _R, \sigma _L' n (n-1) \sigma _R')\).

Fig. 3
figure 3

An example of what \(\sigma _L n (n-1) \sigma _R\) may look like when avoiding 231 and 312

Now we present each case:

  1. (1)

    \((\sigma , \sigma ') = (\sigma _L n, \sigma _L' n)\).

    The maximal element \(n+1\) must be inserted adjacent to n in both \(\sigma \) and \(\sigma '\). If not, then there would be an occurrence of 312. By evaluating their projections, we can verify that the following 3-permutations avoid 231 and 312: \((\sigma _L n (n+1), \sigma _L' n (n+1))\), \({(\sigma _L n (n+1), \sigma _L' (n+1)n)}\), \({(\sigma _L (n+1) n, \sigma _L' n (n+1))},\) and \((\sigma _L (n+1)n, \sigma _L' (n+1)n)\). Thus, each instance of \(\varvec{\sigma }\) in this case contributes 4 new 3-permutations that avoid 231 and 312.

  2. (2)

    \((\sigma , \sigma ')= (\sigma _L (n-1) n, \sigma _L' n (n-1) \sigma _R')\). Then \(n (n-1) \sigma _R'\) must be consecutively decreasing. Note that appending the maximal element \({n+1}\) onto the end of \(\sigma \) and \(\sigma '\) also avoids 231 and 312. In other words, the 3-permutation \((\sigma _L (n-1) n (n+1), \sigma _L' n (n-1) \sigma _R' (n+1))\) avoids 231 and 312. In addition, the 3-permutation \((\sigma _L (n-1) n (n+1), \sigma _L' (n+1) n (n-1) \sigma _R')\) also avoids 231 and 312.

    To see this, we first evaluate the projection of \((\sigma _L (n-1) n, \sigma _L' n (n-1) \sigma _R')\). Call this \(\gamma \). As shown in Fig. 4, we can subdivide \(\sigma _L\) into \(\pi _L\) and \(\pi _R\), where \(|\pi _L| = |\sigma _L'|\). Recall that \(n (n-1) \sigma _R'\) is consecutively decreasing, and thus, the sequence \(\pi _R (n-1) n\) must be consecutively increasing to prevent \(\gamma \) from containing an instance of 231 or 312. Note that this implies that each element of \(\pi _L\) is less than each element of \(\pi _R\). Thus, \(\gamma \) is of the form \((\sigma _L' \circ \pi _L^{-1}) n (n-1) \sigma _R'\), which we note must avoid 231 and 312 since \((\sigma , \sigma ')\) avoids these patterns. Further, note that \((\sigma _L (n-1) n (n+1), \sigma _L' (n+1) n (n-1) \sigma _R')\) avoids 231 and 312 because its projection is of the form \((\sigma _L' \circ \pi _L^{-1})(n+1)n (n-1) \sigma _R'\), which also avoids these patterns.

    Now we show that inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) cannot produce a 3-permutation that avoids 231 and 312. We must insert \(n+1\) adjacent to n in \(\sigma \). If not, then inserting \(n+1\) anywhere to the left of \(n-1\) contains an occurrence of 312. Similarly, we must insert \(n+1\) left-adjacent to n or at the end in \(\sigma '\). Inserting \(n+1\) anywhere to the right of \(n-1\) contains an occurrence of 231.

    We now show that \((\sigma _L (n-1) (n+1) n, \sigma _L' (n+1) n (n-1) \sigma _R')\) cannot avoid these patterns. Similar to Fig. 4 above, we can subdivide \(\sigma _L\) into \(\pi _L\) and \(\pi _R\), where \(\pi _L\) is of the same size as \(\sigma _L'\), and \(\pi _R(n-1)\) is consecutively increasing.

    figure a

    Then the projection is of the form \((\sigma _L' \circ \pi _L^{-1}) \pi (r+2) r (r+1)\), where r is the minimal element of \((n-1)\sigma _R'\) and \(\pi \) is a subpermutation. This contains an occurrence of 312.

    A similar calculation shows that \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L (n-1) (n+1) n, \sigma _L' n (n-1) \sigma _R' (n+1))\) is of the form \(\pi (r+1) (n+1) r\) for a subpermutation \(\pi \), which contains an occurrence of 231. Hence, each instance of \(\varvec{\sigma }\) in this case contributes two new elements in \(S_{n+1}^2(231,312)\).

  3. (3)

    \((\sigma , \sigma ')= (\sigma _L n (n-1) \sigma _R, \sigma _L' (n-1) n)\).

    Using a similar argument to the previous case, \(n(n-1)\sigma _R\) must be consecutively decreasing. As in the previous cases, \((\sigma _L n (n-1) \sigma _R (n+1), \sigma _L' (n-1) n (n+1))\) avoids 231 and 312. Moreover, \((\sigma _L (n+1) n (n-1) \sigma _R, \sigma _L' (n-1) n (n+1))\) also avoids these patterns. To see this, we first evaluate the projection of \((\sigma _L n (n-1) \sigma _R, \sigma _L' (n-1) n)\), which we will call \(\gamma \):

    figure b

    Since \(\gamma \) is of the form \((\pi _L \circ \sigma _L^{-1}) n (n-1) \textrm{rev}(\pi _R)\), we conclude that \(n(n-1)\textrm{rev}(\pi _R)\) must be consecutively decreasing to avoid occurrences of 231 and 312. We now evaluate the projection of \((\sigma _L (n+1) n (n-1) \sigma _R, \sigma _L' (n-1) n (n+1))\):

    figure c

    Now \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L (n+1) n (n-1) \sigma _R, \sigma _L' (n-1) n (n+1))\) is \((\pi _L \circ \sigma _L^{-1}) (n+1) n (n-1) \textrm{rev}(\pi _R)\), which also avoids 231 and 312, as shown in Fig. 5.

    We show that inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) cannot produce a 3-permutation that avoids 231 and 312. Using similar arguments to the previous case, it is sufficient to show that both \((\sigma _L (n+1) n (n-1) \sigma _R, \sigma _L' (n-1) (n+1) n)\) and \((\sigma _L n (n-1) \sigma _R (n+1), \sigma _L' (n-1) (n+1) n)\) contain an occurrence of 231 or 312.

    For the former 3-permutation, we take \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L (n+1) n (n-1) \sigma _R, \sigma _L' (n-1) (n+1) n)\):

    The projection is of the form \((\pi _L \circ \sigma _L^{-1}) n (n+1) (n-1) \textrm{rev}(\pi _R)\), which contains an occurrence of 231.

    For the latter 3-permutation, a similar argument shows that this projection contains an occurrence of 312. Hence, each instance of \(\varvec{\sigma }\) in this case contributes 2 new elements in \(S_{n+1}^2(231,312)\).

  4. (4)

    \((\sigma , \sigma ')= (\sigma _L n (n-1) \sigma _R, \sigma _L' n (n-1) \sigma _R')\).

    Then \(n(n-1)\sigma _R\) and \(n(n-1)\sigma _R'\) must be consecutively decreasing. We claim \(|\sigma _R| = |\sigma _R'|\). For the sake of contradiction, suppose that \(|\sigma _R'|>|\sigma _R|\). Then the 3-permutations are of the following form:

    figure d

    The projection, which we will call \(\rho \), is of the form \(\pi _1 n \pi _2 r \pi _3 (r+c)\), where r is the minimal element of \(\sigma _R'\), c is some positive integer, and \(\pi _1\), \(\pi _2\), \(\pi _3\) are subpermutations. Figure 6 illustrates this projection. Hence, \(\rho \) contains 312, a contradiction.

    A similar argument holds for \(|\sigma _R'|<|\sigma _R|\). Hence, the two permutations must be of the same size. Moreover, since both \(n(n-1)\sigma _R\) and \(n(n-1)\sigma _R'\) are consecutively decreasing, then we have \(\sigma _R = \sigma _R'\).

    We immediately see that \((\sigma _L n (n-1) \sigma _R (n+1), \sigma _L' n (n-1) \sigma _R' (n+1))\) is in \(S_{n+1}^2 (231,312)\). Moreover, note that the projection of \((\sigma _L (n+1) n (n-1) \sigma _R, \sigma _L' (n+1) n (n-1) \sigma _R')\) is of the form \((\sigma _L' \circ \sigma _L^{-1}) (\sigma _R' \circ \sigma _R^{-1}) (n-1) n (n+1)\), and hence, \((\sigma _L (n+1) n (n-1) \sigma _R, \sigma _L' (n+1) n (n-1) \sigma _R')\) also avoids 231 and 312.

    Now we show that inserting the maximal element \(n+1\) anywhere else cannot avoid 231 and 312. In fact, \(n+1\) can only be inserted either at the end of \(\sigma \) and \(\sigma '\) or left-adjacent to n. If \(n+1\) is inserted anywhere in \(\sigma _L\) or \(\sigma _L'\), then there would be an occurrence of 312. If \(n+1\) is inserted anywhere to the right of n and not at the end of the permutation, then there would be an occurrence of 231.

    We show that both the 3-permutations \((\sigma _L (n+1) n (n-1) \sigma _R, \sigma _L' n (n-1) \sigma _R' (n+1))\) and \((\sigma _L n (n-1) \sigma _R (n+1), \sigma _L' (n+1) n (n-1) \sigma _R')\) contain an occurrence of either 231 or 312.

    For the first 3-permutation, the projection looks as follows:

    figure e

    Evaluating the projection gives the form \((\sigma _L' \circ \sigma _L^{-1})(n+1) \pi (n-1)(n)\) for a subpermutation \(\pi \), which contains 312.

    A similar argument shows that \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n (n-1) \sigma _R (n+1), \sigma _L' (n+1) n (n-1) \sigma _R')\) contains an occurrence of 231. Therefore, each instance of \(\varvec{\sigma }\) in this case contributes 2 new elements in \(S_{n+1}^2(231,312)\).

Fig. 4
figure 4

The two-line notation used to evaluate \((\sigma _L' n (n-1) \sigma _R') \circ (\sigma _L (n-1)n)^{-1}\). The second line represents \(\sigma \) and the last line represents \(\sigma '\)

Now we show that 3-permutations avoiding 231 and 312 must be of one of the forms above. We have only one form to consider, where exactly one of \(\sigma _R\), \(\sigma _R'\) is empty. Let \(\sigma _R\) be empty and \(\sigma _R'\) be nonempty. In particular, \((\sigma , \sigma ')= (\sigma _L n, \sigma _L' n \sigma _R')\).

Fig. 5
figure 5

An illustration of the projection of \((\sigma _L (n+1) n (n-1) \sigma _R, \sigma _L' (n-1) n (n+1))\)

Fig. 6
figure 6

An illustration of the projection of \((\sigma _L n (n-1) \sigma _R, \sigma _L' n (n-1) \sigma _R')\) when \(|\sigma _R'|>|\sigma _R|\)

figure f

Now \(n-1\) must be adjacent to n in \(\sigma '\). If \(\sigma ' = \sigma _L' (n-1) n \sigma _R'\), then \(\sigma _R'\) must be empty to avoid an occurrence of 231. Then Case 1 covers this. If \(\sigma ' = \sigma _L' n (n-1) \sigma _R'\), then we show that \(n-1\) is adjacent to n in \(\sigma \). Suppose, for the sake of contradiction, that this is not the case. First, \(n(n-1)\sigma _R'\) must be consecutively decreasing. Taking the projection \({{\,\mathrm{\textrm{proj}}\,}}(\sigma , \sigma ')\), we conclude that it is of the form \(\pi _L n \pi _R k r\), where \(\pi _L\) and \(\pi _R\) are subpermutations, \(k \ne r+1\), and r is the minimal element in \(\sigma _R'\) (note that if \(\sigma _R'\) is empty, then the projection contains the sequence \(nk (n-1)\), which is a 312 pattern). Now we consider where the element \(r+1\) is in the permutation. If \(r+1\) is in \(\pi _L\), then there is an occurrence of 231. If \(r+1\) is in \(\pi _R\), then if \(k>r+1\), there is an occurrence of 231 and if \(k<r+1\), there is an occurrence of 312. Hence, \(n-1\) must be adjacent to n in \(\sigma \), and a similar argument from Case 2 covers this case. A similar argument also holds for nonempty \(\sigma _R\) and empty \(\sigma _R'\).

Now we show that for \((\sigma , \sigma ') \in S_n^2 {\setminus } S_n^2(231,312)\), we cannot obtain an element in \( S_{n+1}^2(231,312)\) by inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\). We will assume that \(\sigma \) and \(\sigma '\) avoid these patterns but \(\sigma ' \circ \sigma ^{-1}\) does not. We iterate through the same cases as above:

  1. (1)

    \((\sigma , \sigma ') = (\sigma _L n, \sigma _L' n)\).

    It’s straightforward to check that the projections of the following 3-permutations contain \(\sigma ' \circ \sigma ^{-1}\): \((\sigma _L n (n+1), \sigma _L' n (n+1))\), \((\sigma _L n (n+1), \sigma _L' (n+1)n)\), \((\sigma _L (n+1) n, \sigma _L' n (n+1)),\) and \((\sigma _L (n+1)n, \sigma _L' (n+1)n)\).

  2. (2)

    \((\sigma , \sigma ')= (\sigma _L (n-1) n, \sigma _L' n (n-1) \sigma _R')\).

    It is clear that \((\sigma _L (n-1) n (n+1), \sigma _L' n (n-1) \sigma _R' (n+1))\) contains \(\sigma ' \circ \sigma ^{-1}\). Now we consider \((\sigma _L (n-1) n (n+1), \sigma _L' (n+1) n (n-1) \sigma _R')\). Call its projection \(\rho \). Using the notation in Case 2 above, note that \(\pi _R (n-1) n\) must be consecutively increasing. Else \(\rho \) contains an occurrence of 231 if \(\pi _R (n-1) n\) contains 21, and \(\rho \) contains an occurrence of 312 if \(\pi _R (n-1) n\) is increasing but not consecutive. As such, \(\rho \) must be of the form \((\sigma _L' \circ \pi _L^{-1}) (n+1) n (n-1) \sigma _R'\) and \(\sigma ' \circ \sigma ^{-1}\) is of the form \((\sigma _L' \circ \pi _L^{-1}) n (n-1) \sigma _R'\). It is clear that \(\rho \) contains \(\sigma ' \circ \sigma ^{-1}\). Lastly, recall that inserting \(n+1\) anywhere else in \(\sigma \) and \(\sigma '\) must result in a 3-permutation that contains an occurrence of 231 or 312.

  3. (3)

    \((\sigma , \sigma ')= (\sigma _L n (n-1) \sigma _R, \sigma _L' (n-1) n)\).

    Using a similar logic to the previous case, \((\sigma _L n (n-1) \sigma _R (n+1), \sigma _L' (n-1) n (n+1))\) and \((\sigma _L (n+1) n (n-1) \sigma _R, \sigma _L' (n-1) n (n+1))\) contain \(\sigma ' \circ \sigma ^{-1}\), and inserting \(n+1\) anywhere else must result in a 3-permutation that contains either 231 or 312.

  4. (4)

    \((\sigma , \sigma ')= (\sigma _L n (n-1) \sigma _R, \sigma _L' n (n-1) \sigma _R')\).

    Our logic in Case 4 above shows that \((\sigma _L n (n-1) \sigma _R (n+1), \sigma _L' n (n-1) \sigma _R' (n+1))\) and \((\sigma _L (n+1) n (n-1) \sigma _R, \sigma _L' (n+1) n (n-1) \sigma _R')\) contain \(\sigma ' \circ \sigma ^{-1}\), and inserting \(n+1\) anywhere else must result in a 3-permutation that contains these patterns.

However, we must also consider when exactly one of \(\sigma _R\), \(\sigma _R'\) is empty, but similar logic as presented in our proof shows either \((\sigma , \sigma ')\) belongs to one of the cases we iterated above or inserting \(n+1\) anywhere in \(\sigma \) and \(\sigma '\) results in a 3-permutation that contains either pattern.

Therefore, we see that for every 3-permutation \(\varvec{\sigma } = (\sigma , \sigma ')\) in \(S_n^2(231,312)\), inserting the maximal element \(n+1\) onto the end of both \(\sigma \) and \(\sigma '\) always yields a 3-permutation in \(S_{n+1}^2(231,312)\); moreover, inserting the maximal element such that the relative positions of the two largest elements in both \(\sigma \) and \(\sigma '\) are preserved also always yields another 3-permutation. This contributes \(2a_n\) different 3-permutations to \(S_{n+1}^2(231,312)\). In the case that \(\varvec{\sigma }\) is of the form in Case 1 (where \(\sigma \), \(\sigma '\) each end with the maximal element n), each \(\varvec{\sigma }\) can construct two elements in \(S_{n+1}^2(231,312)\) in addition to the elements generated above, and this case contributes \(2a_{n-1}\) additional elements in \(S_{n+1}^2(231,312)\). We have that

$$\begin{aligned} a_{n+1} = 2a_n + 2a_{n-1}.&\end{aligned}$$

\(\square \)

Theorem 3.6

Let \(a_n = |S^2_n(231,321)|\). Then \(a_n\) follows the formula \(a_{n+1} = 4 \cdot 3^{n-1}\) (where \(a_1 = 1\)), which corresponds to the OEIS sequence A003946.

Proof

Since the pair of patterns \(\{231,321\}\) is trivially Wilf-equivalent to the pair of patterns \(\{312,321\}\), we will show the above recurrence relation for when \(a_n = |S^2_n(312,321)|\).

Let \(\varvec{\sigma } = (\sigma , \sigma ') \in S_n^2(312,321)\) and let \(\varvec{\sigma }\) be of the form \((\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\). Note that \(\sigma _R\) and \(\sigma _R'\) either contain one element or are empty.

We insert the maximal element \(n+1\) to the permutation. The element \(n+1\) must be inserted at the end or second-to-end in both \(\sigma \) and \(\sigma '\). We have the following cases:

  1. (1)

    \((\sigma , \sigma ') = (\sigma _L n, \sigma _L' n)\).

    We can see that \((\sigma _L n (n+1), \sigma _L' n (n+1))\), \((\sigma _L n (n+1), \sigma _L' (n+1) n)\), \((\sigma _L (n+1) n, \sigma _L' n (n+1))\), and \((\sigma _L (n+1) n, \sigma _L' (n+1) n)\) all avoid 312 and 321.

    A 3-permutation \(\varvec{\sigma }\) in this case constructs 4 distinct 3-permutations in \(S_{n+1}^2 (312,321)\).

  2. (2)

    \((\sigma , \sigma ') = (\sigma _L n, \sigma _L' n r')\) for some integer \(r'\).

    Similarly to the previous case, we see that the 3-permutations \((\sigma _L n (n+1), \sigma _L' n r' (n+1))\), \((\sigma _L n (n+1), \sigma _L' n (n+1) r')\), \((\sigma _L (n+1) n, \sigma _L' n r' (n+1))\), and \((\sigma _L (n+1) n, \sigma _L' n (n+1) r')\) all avoid 312 and 321.

    A 3-permutation \(\varvec{\sigma }\) in this case also constructs 4 distinct 3-permutations in \(S_{n+1}^2 (312,321)\).

  3. (3)

    \((\sigma , \sigma ') = (\sigma _L n r, \sigma _L' n)\) for some integer r.

    Appending the maximal element \(n+1\) at the end of \(\sigma \) and \(\sigma '\) still avoids 312 and 321. In particular, \((\sigma _L n r (n+1), \sigma _L' n (n+1))\), as well as \((\sigma _L n (n+1) r, \sigma _R' (n+1) n)\), avoids these patterns.

    Now we show that inserting \(n+1\) anywhere else must contain these patterns. In particular, note that \((\sigma _L n r (n+1), \sigma _L' (n+1) n)\) and \((\sigma _L n (n+1) r, \sigma _L' n (n+1))\) cannot avoid 312 and 321. For both 3-permutations, the projection is of the form \(\pi _L (n+1) \pi _R n\) for subpermutations \(\pi _L\) and \(\pi _R\) (where \(\pi _R\) is nonempty). This contains an instance of 312.

    Hence, 3-permutations \(\varvec{\sigma }\) in this case produce two different elements in \(S_{n+1}^2 (312,321)\).

  4. (4)

    \((\sigma , \sigma ') = (\sigma _L n r, \sigma _L' n r')\) for integers r, \(r'\).

    As in the previous cases, note that the 3-permutation \((\sigma _L n r (n+1), \sigma _L' n r' (n+1))\), as well as \((\sigma _L n (n+1) r, \sigma _L' n (n+1) r')\), avoids 312 and 321.

    Now we show that inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) cannot avoid 312 and 321. In particular, we show that \((\sigma _L n r (n+1), \sigma _L' n (n+1) r')\) and \((\sigma _L n (n+1) r, \sigma _L' n r' (n+1))\) cannot avoid 312 and 321.

    For both 3-permutations, the projection is \(\pi _L (n+1) \pi _R n r\) for some subpermutations \(\pi _L, \pi _R\). This contains an instance of 321. And hence, 3-permutations \(\varvec{\sigma }\) in this case construct 2 distinct elements in \(S_{n+1}^2 (312,321)\).

Now we show that for \((\sigma ,\sigma ') \in S_n^2 {\setminus } S_{n}^2(312,321)\), we cannot obtain an element in \( S_{n+1}^2(312,321)\) by inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\). So let \(\sigma ' \circ \sigma ^{-1}\) contain an instance of 312 or 321. Then \((\sigma , \sigma ')\) must be one of the cases above, and it is clear that the projections of the 3-permutations we obtained by inserting \(n+1\) contain \(\sigma ' \circ \sigma ^{-1}\), which must also contain an instance of these patterns. Hence, for \((\sigma ,\sigma ') \in S_n^2 {\setminus } S_{n}^2(312,321)\), we cannot obtain an element in \( S_{n+1}^2(312,321)\) by inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\).

Now we claim that in \(S_n^2(312,321)\), exactly half of the elements \(\varvec{\sigma } = (\sigma , \sigma ')\) satisfy \(\sigma (n) = n\). The base case can be seen in \(S_2^2(312,321)\). Then for our inductive step let us assume that this is the case for \(S_{n-1}^2(312,321)\). We wish to show that this is true for \(S_{n}^2(312,321)\). In each case above, exactly half of the 3-permutations constructed have the property \(\sigma (n)= n\) and the other half satisfy \(\sigma (n) \ne n\), and via induction, exactly half of the elements in \(S_n^2(312,321)\) satisfy \(\sigma (n) = n\).

Note that if \(\sigma (n) = n\), we are in Case 1 or Case 2, which contribute 4 elements in \(S_{n+1}^2(312,321)\). When \(\sigma (n) \ne n\), we are in Case 3 or Case 4, which contribute 2 elements in \(S_{n+1}^2(312,321)\).

Thus, we conclude that

$$\begin{aligned} a_{n+1} = \frac{a_n}{2}\cdot 4 + \frac{a_n}{2} \cdot 2 = 3a_n. \end{aligned}$$

We can see that \(a_2 = 4\), and we conclude that

$$\begin{aligned} a_{n+1} = 4 \cdot 3^{n-1}.&\end{aligned}$$

\(\square \)

This allows us to prove all the conjectures Bonichon and Morel [7] have made in regard to 3-permutations avoiding two patterns of size 3. However, there is one class of 3-permutations that have yet to be classified, which we now enumerate. We begin with an observation.

Observation 3.7

Let \(\sigma \) be a permutation and \(\pi \) be an involution. Then \(\sigma \) avoids \(\pi \) if and only if \(\sigma ^{-1}\) avoids \(\pi \).

Since 132 and 213 are both involutions, \(\sigma \) avoids 132 if and only if \(\sigma ^{-1}\) avoids 132. The same reasoning holds for the pattern 213. We then have a corollary:

Corollary 3.8

Let \(\pi \) be an involution. Then the 3-permutation \((\sigma , \sigma ')\) avoids \(\pi \) if and only if the 3-permutation \((\sigma ',\sigma )\) avoids \(\pi \).

This is due to the fact that \(\sigma ' \circ \sigma ^{-1}\) avoids \(\pi \) if and only if \(\sigma \circ (\sigma ')^{-1}\) avoids \(\pi \).

Theorem 3.9

Let \(a_n = |S_n^2(132,213)|\). Then \(a_n\) satisfies the recurrence

$$\begin{aligned} a_{n+1} = a_n + 3 \cdot 2^{n-1} +2(n-1) \end{aligned}$$

with the initial term \(a_1 = 1\). This corresponds to the OEIS sequence A356728.

Proof

Let \(\varvec{\sigma } = (\sigma , \sigma ') \in S_n^2(132,213)\) and let \(\varvec{\sigma }\) be of the form \((\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\).

Note that \(\sigma _L n\) and \(\sigma _L' n\) are increasing; otherwise the permutation would contain an occurrence of 213. Moreover, they must be consecutively increasing; otherwise we would have an occurrence of 132.

Adding the maximal element \(n+1\) right-adjacent to n in both \(\sigma \) and \(\sigma '\) always produces a 3-permutation in \(S_{n+1}^2(132,213)\). To see this, suppose that \(|\sigma _L| > |\sigma _L'|\). Then the projection would look as follows:

figure g

This has the form \((\pi _R \circ \sigma _R^{-1}) \pi _L \pi _M\), where \(\pi _L\) is consecutively increasing and ends with n. Figure 7 illustrates this projection. This projection must avoid 132 and 213.

Fig. 7
figure 7

An illustration of the projection of \((\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\) when \(|\sigma _L|>|\sigma _L'|\)

Now consider \((\sigma _1, \sigma _2) = (\sigma _L n (n+1) \sigma _R, \sigma _L' n (n+1) \sigma _R')\). The projection would look as follows:

figure h

This has the form \((\pi _R \circ \sigma _R^{-1}) \pi _L (n+1) \pi _M\), which still avoids 132 and 213. The case where \(|\sigma _L| = |\sigma _L'|\) follows as well. For the case \(|\sigma _L| < |\sigma _L'|\), we utilize Corollary 3.8. Note that due to symmetry, our previous argument implies that the 3-permutation \((\sigma ',\sigma )\) avoids 132 and 213, and hence Corollary 3.8 states that \((\sigma , \sigma ')\) avoids these patterns.

Hence, appending the maximal element \(n+1\) right-adjacent to n in both \(\sigma \) and \(\sigma '\) contributes \(a_{n}\) elements in \(S^2_{n+1}(132,213).\)

In the following cases, note that \(n+1\) must be inserted either at the beginning or right-adjacent to n in \(\sigma \) and \(\sigma '\). If we insert \(n+1\) to the left of n (but not at the beginning), then there is an instance of 132. Similarly, if we insert \(n+1\) to the right of n (but not adjacent to n), then there is an instance of 213. We have the following:

  1. (1)

    \(\sigma = \sigma '\).

    Then \(((n+1) \sigma , (n+1) \sigma ')\) also avoids 132 and 213. Further, note that in the special case when \(\sigma = \sigma ' = {{\,\mathrm{\textrm{Id}}\,}}_n\), then \(((n+1){{\,\mathrm{\textrm{Id}}\,}}_n, {{\,\mathrm{\textrm{Id}}\,}}_n (n+1))\) and \(({{\,\mathrm{\textrm{Id}}\,}}_n (n+1), (n+1) {{\,\mathrm{\textrm{Id}}\,}}_n)\) both avoid 132 and 213. Now we show that inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) does not avoid 132 and 213. Specifically, for all other \(\sigma \) and \(\sigma '\), we show that \(((n+1)\sigma , \sigma _L' n (n+1) \sigma _R')\) and \((\sigma _L n (n+1) \sigma _R, (n+1) \sigma ')\) cannot avoid 132 or 213. To see that the first 3-permutation cannot avoid 132 or 213, note that \({{\,\mathrm{\textrm{proj}}\,}}((n+1)\sigma , \sigma _L' n (n+1) \sigma _R')\) is of the form \(1\pi (n+1)\ell \), where \(\ell \) is the first element in \(\sigma _L' n\) and \(\pi \) is a subpermutation. This contains an occurrence of 132. A similar argument shows that the projection of the latter 3-permutation also contains 213.

    Since Simion and Schmidt [2] showed there are \(2^{n-1}\) possible permutations that avoid 132 and 213 with size n, this contributes an additional \(2^{n-1} + 2\) elements in \(S_{n+1}^2(132,213)\).

  2. (2)

    \(\sigma = {{\,\mathrm{\textrm{Id}}\,}}_n\) and \(\sigma ' \ne {{\,\mathrm{\textrm{Id}}\,}}_n\).

    We note that \((\sigma (n+1), (n+1) \sigma ')\) avoids 132 and 213. In the special case where \(\sigma _R'\) is consecutively increasing, then \(((n+1) \sigma , \sigma _L' n (n+1) \sigma _R')\) is also an element in \(S_{n+1}^2(132,213)\).

    Now we show that inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) cannot avoid 132 and 213. We first show that \((\sigma (n+1), \sigma ' (n+1))\) and \(((n+1)\sigma , (n+1) \sigma ')\) cannot avoid 132 and 213. Taking the projection of these 3-permutations evaluates to \(\sigma ' (n+1)\), which contains an occurrence of 213 because \(\sigma '\) is not the identity and therefore, must contain an occurrence of 21.

    Note that \(((n+1) \sigma , \sigma ' (n+1))\) cannot avoid these patterns because \(\sigma ' (n+1)\) contains an occurrence of 213.

    Now let \(\sigma _R'\) be decreasing. We wish to show that \(((n+1) \sigma , \sigma _L' n (n+1) \sigma _R')\) cannot avoid 132 and 213. Since \(\sigma _R'\) contains an instance of 21 and every element in \(\sigma _R'\) is smaller than every element in \(\sigma _L'\), taking \({{\,\mathrm{\textrm{proj}}\,}}((n+1) \sigma , \sigma _L' n (n+1) \sigma _R')\) gives an occurrence of 213.

    Since there are \(2^{n-1}\) different \(\sigma '\) that avoid 132 and 213, note that \((\sigma (n+1), (n+1) \sigma ')\) contributes \(2^{n-1}-1\) different elements to \(S_{n+1}^2(132,213)\). Moreover, the special 3-permutation case \(((n+1) \sigma , \sigma _L' n (n+1) \sigma _R')\) contributes \(n-1\) elements to \(S_{n+1}^2(132,213)\).

  3. (3)

    \(\sigma \ne {{\,\mathrm{\textrm{Id}}\,}}_n\) and \(\sigma ' = {{\,\mathrm{\textrm{Id}}\,}}_n\).

    This case also contributes \(2^{n-1}+n-2\) elements in \(S_{n+1}^2(132,213)\). This is a consequence of Corollary 3.8 and the reasoning discussed in Case 2.

Now we show that nothing else can contribute to \(S_{n+1}^2(132,213)\). Let \(\varvec{\sigma } = (\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\) and assume that \(\sigma _R\) and \(\sigma _R'\) are nonempty and \(\sigma \ne \sigma '\). Note that \(\sigma \) and \(\sigma '\) cannot be \({{\,\mathrm{\textrm{Id}}\,}}_n.\)

Inserting \(n+1\) at the beginning of \(\sigma \) and \(\sigma '\) gives that \({{\,\mathrm{\textrm{proj}}\,}}(\sigma , \sigma ')\) is of the form \((\sigma ' \circ \sigma ^{-1}) (n+1)\). And since \(\sigma \ne \sigma '\), then \(\sigma ' \circ \sigma ^{-1}\) cannot be the identity and contains an occurrence of 21. Hence \({{\,\mathrm{\textrm{proj}}\,}}(\sigma , \sigma ')\) contains an occurrence of 213.

We show that \(((n+1) \sigma , \sigma _L' n (n+1) \sigma _R')\) cannot avoid 132 and 213 either. To see this, let \(|\sigma _L| \ge |\sigma _L'|\). Then we evaluate the projection:

figure i

This can be represented as \(r \pi _L (n+1) \pi _R \ell \), where \(\ell \) is an element in \(\sigma _L'\) (or n if \(\sigma _L'\) is empty), r is an element in \(\sigma _R'\), and \(\pi _L\) and \(\pi _R\) are subpermutations. Since elements in \(\sigma _L'\) are greater than elements in \(\sigma _R'\), then the projection contains an occurrence of 132. Figure 8 illustrates an example.

Fig. 8
figure 8

An illustration of \({{\,\mathrm{\textrm{proj}}\,}}((n+1) \sigma , \sigma _L' n (n+1) \sigma _R')\) when \(|\sigma _L| \ge |\sigma _L'|\)

Now let \(|\sigma _L|<|\sigma _L'|\). To show the 3-permutation \( (\sigma _1, \sigma _2) = ((n+1) \sigma , \sigma _L' n (n+1) \sigma _R')\) cannot avoid 132 and 213, we show that \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _1, \sigma _2)\) contains either pattern. By Observation 3.7, this is equivalent to showing that \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _2, \sigma _1)\) contains the pattern 132 or 213. We will show that the 3-permutation \(( \sigma _L n (n+1) \sigma _R, (n+1) \sigma ')\) cannot avoid 132 and 213 when \(|\sigma _L| > |\sigma _L'|\). Then we evaluate its projection:

figure j

This is of the form \((\sigma _R' \circ \sigma _R^{-1}) (n+1) \pi _L n \pi _R\), where \(\pi _L\) and \(\pi _R\) are subpermutations. Since \(\sigma _R' \circ \sigma _R^{-1}\) must contain the minimal element 1, the projection contains an occurrence of 132. And hence, \(((n+1) \sigma , \sigma _L' n (n+1) \sigma _R')\) cannot avoid 132 and 213.

By Corollary 3.8, the 3-permutation \(((n+1) \sigma , \sigma _L' n (n+1) \sigma _R')\) cannot avoid 132 and 213 either.

Now we show that for \((\sigma , \sigma ') \in S_n^2 {\setminus } S_n^2(132,213)\), we cannot obtain an element in \( S_{n+1}^2(132,213)\) by inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\). We will assume that \(\sigma \) and \(\sigma '\) avoid these patterns but \(\sigma ' \circ \sigma ^{-1}\) does not. Recall that \(n+1\) must be inserted right-adjacent to n, except in the cases above, where \(n+1\) may be inserted at the beginning of the permutation. So let \(\sigma \ne \sigma '\), where neither are the identity. We have shown above that \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n (n+1) \sigma _R, \sigma _L' n (n+1) \sigma _R')\) contains \({{\,\mathrm{\textrm{proj}}\,}}(\sigma , \sigma ')\). Now for when \(\sigma = \sigma '\) or when one of them is the identity permutation, \({{\,\mathrm{\textrm{proj}}\,}}(\sigma , \sigma ')\) cannot contain 132 or 213, a contradiction. Inserting \(n+1\) anywhere else will contain an occurrence of 132 or 213, and hence, inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\) cannot produce an element in \( S_{n+1}^2(132,213)\).

Hence, we conclude that

$$\begin{aligned} a_{n+1} = a_n + 3 \cdot 2^{n-1} + 2(n-1).&\end{aligned}$$

\(\square \)

These theorems allow us to enumerate all 3-permutations avoiding two patterns of size 3 that correspond to existing OEIS sequences. Moreover, we have since added the sequence in Theorem 3.9 to the OEIS database [11], allowing the complete classification and enumeration of all 3-permutations avoiding two patterns of size 3.

4 Enumeration of Pattern Avoidance Classes of Size 3

Having enumerated all 3-permutations avoiding two patterns, we now turn our attention to enumerating 3-permutations avoiding three patterns, as Simion and Schmidt [2] have done with classic permutations. In Table 2, we extend Bonichon and Morel’s [7] conjectures to 3-permutations avoiding three patterns of size 3.

Table 2 Sequences of 3-permutations avoiding three permutations of size 3

Theorem 4.1

Let \(a_n = |S_n^2(132,213,312)|\). Then \(a_{n+1}\) follows the formula \(a_{n+1} = 2(n+1)\) for \(n>0\) (with initial term \(a_1=1\)).

Proof

Let \(\varvec{\sigma } {=} (\sigma , \sigma ') {\in } S_n^2(132,213,312)\). Let \(\varvec{\sigma }\) be of the form \((\sigma _L n \sigma _R, \sigma _L' n \sigma _R').\)

Note that \(\sigma _R\) and \(\sigma _R'\) have to be either empty or consecutively decreasing, and similarly, \(\sigma _L\) and \(\sigma _L'\) have to be either empty or consecutively increasing. Moreover, every element in \(\sigma _L\) and \(\sigma _L'\) must be larger than every element in \(\sigma _R\) and \(\sigma _R'\), respectively. If not, there would be an occurrence of 132.

We have the following cases:

  1. (1)

    \(\sigma _L\), \(\sigma _R\) are nonempty.

    If \(\sigma _L'\) and \(\sigma _R'\) are nonempty, consider \(\varvec{\sigma } = (\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\) in \(S_{n}^2\) (132,213, 312). Note that inserting \(n+1\) right-adjacent to n in both \(\sigma \) and \(\sigma '\) will avoid 132, 213, and 312. In particular, \((\sigma _L n (n+1) \sigma _R, \sigma _L' n (n+1) \sigma _R')\) avoids 132, 213, and 312.

    Now we show that inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) does not yield an element of \(S_{n+1}^2\) (132,213,312). Consider \(\sigma _L n \sigma _R\). We cannot insert \(n+1\) in the beginning of this permutation, or else there would be an instance of 312. Further, we cannot insert \(n+1\) anywhere to the left of n, or else there would be an instance of 132. There would also be an occurrence of 213 if \(n+1\) is inserted anywhere to the right of n that is not adjacent to n.

    Hence, \(n+1\) is forced to be right-adjacent to n in \(\sigma \). The same conclusion follows for \(\sigma '\).

    If \(\sigma _L'\) is empty, then \(\sigma ' = {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n)\). The projection \(\sigma ' \circ \sigma ^{-1}\) contains an occurrence of 132, and therefore, this case is impossible. Similarly, if \(\sigma _R'\) is empty, then \(\sigma ' = {{\,\mathrm{\textrm{Id}}\,}}_n\). Note that the projection \(\sigma ' \circ \sigma ^{-1}\) contains an occurrence of 312 since \(\sigma \) contains an occurrence of 231, and this case is also impossible.

    Therefore, every element in this case contributes 1 element in \(S_{n}^2\) (132, 213,312).

  2. (2)

    \(\sigma _L\) is empty.

    If both \(\sigma _L'\) and \(\sigma _R'\) are nonempty, then \(\varvec{\sigma } = ({{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), \sigma _L' n \sigma _R')\). Taking the projection \({{\,\mathrm{\textrm{proj}}\,}}({{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), \sigma _L' n \sigma _R')\) gives an instance of 132 because every element in \(\sigma _L'\) is larger than every element in \(\sigma _R'\). Thus, \(\varvec{\sigma }\) is not a valid element in \(S_{n}^2 (132,213,312)\), and we conclude this case is impossible.

    If \(\sigma _L'\) is empty, then we conclude that \((\sigma , \sigma ') = ({{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\). Following similar logic to the previous case, \(n+1\) must be inserted adjacent to n in both \(\sigma \) and \(\sigma '\) to avoid 312 and 213. Note that \(((n+1){{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), (n+1){{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\) avoids 132, 213, and 312. However, \({{\,\mathrm{\textrm{proj}}\,}}((n+1){{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), (n (n+1) {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_{n-1}))\) and \({{\,\mathrm{\textrm{proj}}\,}}(n(n+1){{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_{n-1}), (n+1) {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\) cannot avoid 132, 213, and 312. Therefore, \(({{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\) contributes one more element to \(S_{n+1}^2 (132,213,312)\), in addition to the one obtained by inserting \(n+1\) right-adjacent to n in both \(\sigma \) and \(\sigma '\) as discussed in the previous case.

    If \(\sigma _R'\) is empty, then \((\sigma , \sigma ') = ({{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), {{\,\mathrm{\textrm{Id}}\,}}_n)\). The element \(n+1\) must be inserted adjacent to n in \(\sigma \), and \(n+1\) must be inserted at the end of \(\sigma '\). We can see that the 3-permutation \(((n+1){{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), {{\,\mathrm{\textrm{Id}}\,}}_n (n+1))\) is an element of \(S_{n+1}^2 (132,213,312)\) and furthermore, the 3-permutation \((n (n+1) {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_{n-1}), {{\,\mathrm{\textrm{Id}}\,}}_n (n+1))\) is not an element, because its projection \(\sigma ' \circ \sigma ^{-1}\) contains an instance of 312.

    Hence, each element in this case contributes 1 element to \(S_{n+1}^2 (132,213, 312)\), with the exception of \(({{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\), which contributes 2 elements to \(S_{n+1}^2 (132,213,312)\).

  3. (3)

    \(\sigma _R\) is empty.

    If \(\sigma _L'\) is nonempty, then \(\varvec{\sigma } = ({{\,\mathrm{\textrm{Id}}\,}}_n, \sigma _L' n \sigma _R')\). Then \(n+1\) is forced to be right-adjacent to n for both \(\sigma \) and \(\sigma '\), which contributes 1 element to \(S_{n+1}^2 (132,213,312)\).

    If \(\sigma _L'\) is empty, then \((\sigma , \sigma ') = ({{\,\mathrm{\textrm{Id}}\,}}_n, {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\). Note that \(({{\,\mathrm{\textrm{Id}}\,}}_n(n+1), (n+1){{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\) avoids 132, 213, and 312. Hence, the 3-permutation \(({{\,\mathrm{\textrm{Id}}\,}}_n, {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\) contributes one more element to \(S_{n+1}^2 (132,213,312)\) in addition to the one obtained by inserting \(n+1\) right-adjacent to n in \(\sigma \) and \(\sigma '\).

    Hence, each element in this case contributes 1 element to \(S_{n+1}^2 (132,213, 312)\), with the exception of \(({{\,\mathrm{\textrm{Id}}\,}}_n, {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\), which contributes 2 elements to \(S_{n+1}^2 (132,213,312)\).

Inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) cannot provide an element in \(S_{n+1}^2 (132,213,312)\).

We show that for \((\sigma , \sigma ') \in S_n^2 {\setminus } S_n^2(132,213,312)\), we cannot obtain an element in \( S_{n+1}^2(132,213,312)\) by inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\). Let \(\sigma \) and \(\sigma '\) avoid these patterns but let \(\sigma ' \circ \sigma ^{-1}\) contain them. It is enough to check the cases above:

  1. (1)

    \(\sigma _L\), \(\sigma _R\) are nonempty.

    It is straightforward to check that \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n (n+1) \sigma _R, \sigma _L' n (n+1) \sigma _R')\) contains \(\sigma ' \circ \sigma ^{-1}\) and hence, contains an occurrence of 132, 213, or 312. The proof in Case 1 above shows that the maximal element \(n+1\) must be inserted right-adjacent to n to avoid an occurrence of these patterns in \(\sigma \) and \(\sigma '\).

  2. (2)

    \(\sigma _L\) is empty.

    Then \((\sigma , \sigma ') = ({{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), \sigma _L' n \sigma _R')\). It is also straightforward to check that when the maximal element \(n+1\) is inserted adjacent to n in both \(\sigma \) and \(\sigma '\), the projection of the resulting 3-permutation contains an occurrence of 132 if \(\sigma _R'\) and \(\sigma _L'\) are nonempty. If either \(\sigma _R'\) or \(\sigma _L'\) are empty, then it is impossible for \(\sigma ' \circ \sigma ^{-1}\) to contain instances of 132, 213, 312, a contradiction.

  3. (3)

    \(\sigma _R\) is empty.

    Then \((\sigma , \sigma ') = ({{\,\mathrm{\textrm{Id}}\,}}_n, \sigma _L' n \sigma _R')\). The projection of this 3-permutation is \(\sigma '\), and it is impossible for the projection to contain an occurrence of these patterns while \(\sigma '\) avoids them.

Therefore, we have shown \(a_{n+1} = a_n +2\). We have the base case \(a_2 = 4\), and we then have

$$\begin{aligned} a_{n+1} = 2(n+1).&\end{aligned}$$

\(\square \)

Theorem 4.2

Let \(a_n = |S_n^2(132,213,321)|\). Then \(a_{n+1}\) follows the formula \(a_{n+1} = (n+1)^2\).

Proof

Let \(\varvec{\sigma } = (\sigma , \sigma ') \in S_n^2(132,213,321)\). Write \((\sigma , \sigma ')\) as \((\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\).

Using a similar reasoning discussed in Theorem 4.1, note that \(\sigma _L\), \(\sigma _L'\), \(\sigma _R\), and \(\sigma _R'\) are consecutively increasing. Further, every element in \(\sigma _L\) and \(\sigma _L'\) is larger than every element in \(\sigma _R\) and \(\sigma _R'\), respectively.

Using the reasoning in Theorem 4.1, \((\sigma _L n (n+1) \sigma _R, \sigma _L' n (n+1) \sigma _R')\) is in \(S_{n+1}^2(132,213,321)\). This contributes \(a_n\) different 3-permutations to \(S_{n+1}^2 (132,213,321)\). We also have the following cases:

  1. (1)

    \(\sigma _R\) is empty and \(\sigma _R'\) is nonempty.

    Note that this implies that \(\sigma = {{\,\mathrm{\textrm{Id}}\,}}_n\) and \(\sigma ' \ne {{\,\mathrm{\textrm{Id}}\,}}_n\). Then \(((n+1) {{\,\mathrm{\textrm{Id}}\,}}_n, \sigma _L' n (n+1) \sigma _R')\) avoids 132, 213, and 321.

    Inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) cannot avoid 132, 213, and 321. We must insert \(n+1\) right-adjacent to n in \(\sigma '\). If \(n+1\) is left of n, then \(\sigma '\) contains an instance of 321. If \(n+1\) is right of n but not adjacent, then \(\sigma '\) contains an instance of 213.

    In \(\sigma \), we must either insert \(n+1\) at the beginning of the permutation or the end of the permutation. However, inserting \(n+1\) at the end of the permutation would correspond to a 3-permutation we have already considered above.

    And hence, \(((n+1) {{\,\mathrm{\textrm{Id}}\,}}_n, \sigma _L' n (n+1) \sigma _R')\) is the only 3-permutation we can construct in \(S_{n+1}^2(132,213,321)\). This case contributes \(n-1\) elements to \(S_{n+1}^2(132,213,321)\).

  2. (2)

    \(\sigma _R\) is nonempty and \(\sigma _R'\) is empty.

    This implies that \(\sigma ' = {{\,\mathrm{\textrm{Id}}\,}}_n\) and \(\sigma \ne {{\,\mathrm{\textrm{Id}}\,}}_n\). Note that \((\sigma _L n (n+1) \sigma _R, (n+1) {{\,\mathrm{\textrm{Id}}\,}}_n)\) belongs to \(S_{n+1}^2(132,213,321)\). Using a similar argument as in Case 1, inserting \(n+1\) in \(\varvec{\sigma }\) anywhere else does not avoid 132, 213, and 312. Hence, this case contributes \(n-1\) different 3-permutations to \(S_{n+1}^2(132,213,321)\).

  3. (3)

    Both \(\sigma _R\), \(\sigma _R'\) are empty.

    This implies that \(\sigma = \sigma ' = {{\,\mathrm{\textrm{Id}}\,}}_n\). We see that \(((n+1){{\,\mathrm{\textrm{Id}}\,}}_n,{{\,\mathrm{\textrm{Id}}\,}}_n (n+1))\), \(((n+1){{\,\mathrm{\textrm{Id}}\,}}_n, (n+1){{\,\mathrm{\textrm{Id}}\,}}_n)\), and \(({{\,\mathrm{\textrm{Id}}\,}}_n (n+1), (n+1) {{\,\mathrm{\textrm{Id}}\,}}_n)\) all avoid 132, 213, and 321. And the same reasoning as in Case 1 shows that inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) cannot avoid these patterns, and this case contributes 3 elements to \(S_{n+1}^2(132,213,321)\).

Finally, when \(\sigma \) and \(\sigma '\) are not the identity permutation, then \(\sigma _R\) and \(\sigma _R'\) are both nonempty, and the same argument in Case 1 shows that inserting \(n+1\) anywhere not right-adjacent to n in \(\sigma \) and \(\sigma '\) cannot avoid 132, 213, and 321. Hence, no other insertions of \(n+1\) in \(\varvec{\sigma }\) produce an element in \(S_{n+1}^2(132,213,321)\).

We show that for \((\sigma ,\sigma ') \in S_n^2 {\setminus } S_{n}^2(132,213,321)\), we cannot obtain an element in \( S_{n+1}^2(132,213,321)\) by inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\). We assume that \(\sigma \) and \(\sigma '\) avoid these patterns but \(\sigma ' \circ \sigma ^{-1}\) does not. Write \((\sigma , \sigma ') = (\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\). It is straightforward to check that \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n (n+1) \sigma _R, \sigma _L' n (n+1) \sigma _R')\) contains \(\sigma ' \circ \sigma ^{-1}\). Further, we have the same special cases as above:

  1. (1)

    \(\sigma _R\) is empty and \(\sigma _R'\) is nonempty.

    Then the projection \({{\,\mathrm{\textrm{proj}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n, \sigma _L' n \sigma _R')\) is \(\sigma _L' n \sigma _R'\), and hence it is impossible for the projection to contain these patterns while \(\sigma '\) avoids them.

  2. (2)

    \(\sigma _R\) is nonempty and \(\sigma _R'\) is empty.

    The projection \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n \sigma _R, {{\,\mathrm{\textrm{Id}}\,}}_n)\) is of the form \(\pi _L \pi _R\), where \(\pi _L\) and \(\pi _R\) are both consecutively increasing and each element of \(\pi _L\) is greater than each element of \(\pi _R\). A permutation of this form cannot contain 132, 213, or 321, and it is impossible for \({{\,\mathrm{\textrm{proj}}\,}}(\sigma _L n \sigma _R, {{\,\mathrm{\textrm{Id}}\,}}_n)\) to contain these patterns while \(\sigma \) avoids them.

  3. (3)

    Both \(\sigma _R\), \(\sigma _R'\) are empty.

    It is impossible for \({{\,\mathrm{\textrm{proj}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n, {{\,\mathrm{\textrm{Id}}\,}}_n)\) to contain these patterns.

Hence, we have

$$\begin{aligned} a_{n+1} = a_n + 2n + 1. \end{aligned}$$

The base case is \(a_1 = 1\), and we conclude that

$$\begin{aligned} a_{n+1} = (n+1)^2.\nonumber \\ \end{aligned}$$

\(\square \)

Theorem 4.3

Let \(a_n = |S_n^2(132,231,312)|\). Then \(a_n\) satisfies the recurrence \(a_{n+1} = a_n+3\) with initial term \(a_1 = 1\).

Proof

Let \(\varvec{\sigma } = (\sigma , \sigma ') \in S_n^2(132,231,312)\). Write \((\sigma , \sigma ')\) as \((\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\). Note that \(n \sigma _R\) and \(n \sigma _R'\) must be consecutively decreasing to avoid 312 and 132.

We insert the maximal element \(n+1\) into \(\sigma \) and \(\sigma '\) to count how many elements in \(S_{n+1}^2(132,231,312)\) there are. Note that \((\sigma (n+1), \sigma ' (n+1))\) avoids 132, 231, and 312. This contributes \(a_n\) different 3-permutations to \(S_{n+1}^2(132,231,312)\). We have the following additional cases:

  1. (1)

    \(\sigma = {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n)\) and \(\sigma ' \ne {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n)\).

    This forces \(\sigma '\) to be the identity. Then \(((n+1){{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), \sigma ' (n+1))\) avoids 132, 231, and 312. Now inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) cannot avoid these patterns. Namely, if \(n+1\) is inserted anywhere not in the beginning or end of \(\sigma \), there is an occurrence of 231. Moreover, inserting \(n+1\) into the beginning of \(\sigma '\) contains 312. If \(n+1\) is inserted anywhere not in the beginning or end of \(\sigma '\), there is an occurrence of 132 in \(\sigma '\). Hence, \(((n+1){{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), \sigma ' (n+1))\) is the only element we can construct in \(S_{n+1}^2(132,231,312)\) in this case. And this case contributes one element to \(S_{n+1}^2(132,231,312)\).

  2. (2)

    \(\sigma ' = {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n)\) and \(\sigma \ne {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n)\).

    Then similar to Case 1, \((\sigma (n+1), (n+1) {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\) avoids 132, 231, and 312, and inserting \(n+1\) anywhere else into this 3-permutation cannot result in a 3-permutation in \(S_{n+1}^2(132,231,312)\). Hence, this case contributes one element to \(S_{n+1}^2(132,231,312)\).

  3. (3)

    \(\sigma = \sigma ' ={{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n)\).

    Note that \(((n+1) {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), (n+1) {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\) avoids 132, 231, and 312. Now we show that no other insertions of \(n+1\) into this 3-permutation results in a 3-permutation that avoids these patterns. Note that \({{\,\mathrm{\textrm{proj}}\,}}( {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n) (n+1), (n+1) {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n))\) contains an occurrence of 231 and further, note that \({{\,\mathrm{\textrm{proj}}\,}}((n+1) {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n), {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n) (n+1))\) contains an occurrence of 312. Therefore, this case contributes one element to \(S_{n+1}^2(132,231,312)\).

Inserting \(n+1\) into \((\sigma , \sigma ') = (\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\) anywhere else cannot avoid 132, 231, and 312, where \(\sigma , \sigma ' \ne {{\,\mathrm{\textrm{rev}}\,}}({{\,\mathrm{\textrm{Id}}\,}}_n)\). More specifically, inserting \(n+1\) left-adjacent to n contains 132 and inserting \(n+1\) anywhere to the left of this contains 312. Further, inserting \(n+1\) anywhere to the right of n (but not at the end of the permutation) contains 231. Hence, we must insert \(n+1\) at the end of the permutation, and no other insertions of \(n+1\) in \(\varvec{\sigma }\) avoid 132, 231, and 312.

Now for \((\sigma ,\sigma ') \in S_n^2 \setminus S_{n}^2(132,231,312)\), we cannot obtain an element in \( S_{n+1}^2(132,231,312)\) by inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\). This follows a similar argument to the one presented in Theorem 4.2.

Thus, we conclude that

$$\begin{aligned} a_{n+1} = a_n+3. \end{aligned}$$

Since our base case is \(a_1 = 1\), this is equivalent to \(a_{n+1} = 3n+1\). \(\square \)

Theorem 4.4

Let \(a_n = |S_n^2(213, 231, 321)|\). Then \(a_{n+1}\) follows the formula \(a_{n+1} = 2(n+1)\) for \(n>0\) (with initial term \(a_1 = 1\)).

Proof

Let \(\varvec{\sigma } = (\sigma , \sigma ') \in S_n^2(213,231,321)\). Writing \((\sigma , \sigma ')\) as \((\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\), note that \(\sigma _L\), \(\sigma _L'\), \(\sigma _R\), and \(\sigma _R'\) are all consecutively increasing or empty.

We insert the maximal element \(n+1\) to \(\sigma \) and \(\sigma '\) in an attempt to construct an element in \(S_{n+1}^2(213,231,321)\). If \(\sigma _R\) and \(\sigma _R'\) are nonempty, we cannot construct an element of \(S_{n+1}^2(213,231,321)\) via insertion because inserting \(n+1\) to the left of n contains 321, inserting \(n+1\) right-adjacent to n contains 231, and inserting \(n+1\) anywhere else contains 213. Then it is enough to consider \((\sigma , \sigma ') = ({{\,\mathrm{\textrm{Id}}\,}}_n, {{\,\mathrm{\textrm{Id}}\,}}_n)\). We have two cases:

  1. (1)

    We insert \(n+1\) to the end of \(\sigma \).

    Then we can insert \(n+1\) anywhere in \(\sigma '\) and the resulting 3-permutation is an element of \(S_{n+1}^2(213,231,321)\). This case contributes \(n+1\) different elements to \(S_{n+1}^2(213,231,321)\).

  2. (2)

    We do not insert \(n+1\) to the end of \(\sigma \).

    Note that inserting \(n+1\) into the same position in \(\sigma \) and \(\sigma '\) avoids 213, 231, and 321. Further, \(({{\,\mathrm{\textrm{Id}}\,}}_{n-1} (n+1)n, {{\,\mathrm{\textrm{Id}}\,}}_{n} (n+1))\) also avoids these patterns.

    Inserting \(n+1\) anywhere else contains one of these patterns because the resulting projection contains either 321 or 231. Hence, this case contributes \(n+1\) different 3-permutations to \(S_{n+1}^2(213,231,321)\).

Now for \((\sigma ,\sigma ') \in S_n^2 \setminus S_{n}^2(213,231,312)\), we cannot obtain an element in \( S_{n+1}^2(213,231,312)\) by inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\). It is enough to consider \((\sigma , \sigma ') = ({{\,\mathrm{\textrm{Id}}\,}}_n, {{\,\mathrm{\textrm{Id}}\,}}_n)\). Note that it is impossible for \({{\,\mathrm{\textrm{proj}}\,}}(\sigma , \sigma ')\) to contain 213, 231, or 321 while \(\sigma \) and \(\sigma '\) avoid these patterns, and it follows that

$$\begin{aligned} a_{n+1} = 2(n+1).&\end{aligned}$$

\(\square \)

Theorem 4.5

Let \(a_n = |S_n^2(231,312,321)|\). Then \(a_n\) satisfies the recurrence

$$\begin{aligned} a_{n+1} = a_n + 3a_{n-1} \end{aligned}$$

with initial terms \(a_1 = 1\) and \(a_2 = 4\).

Proof

Let \(\varvec{\sigma } = (\sigma , \sigma ') \in S_n^2(231,312,321)\). Write \((\sigma , \sigma ')\) as \((\sigma _L n \sigma _R, \sigma _L' n \sigma _R')\).

Note that \((\sigma (n+1), \sigma ' (n+1))\) is an element of \(S_{n+1}^2(231,312,321)\). This contributes \(a_n\) different 3-permutations to \(S_{n+1}^2(231,312,321)\). We consider the following additional case: when \(\sigma _R\) and \(\sigma _R'\) are empty.

Then \((\sigma , \sigma ') = (\sigma _L n, \sigma _L' n)\), and thus, \((\sigma _L (n+1)n, \sigma _L' n(n+1))\), \((\sigma _L (n+1)n, \sigma _L' (n+1)n)\), and \((\sigma _L n(n+1), \sigma _L' (n+1)n)\) are all elements in \(S_{n+1}^2(231,312, 321)\). Inserting \(n+1\) anywhere else contains an occurrence of 312. Thus, this case contributes \(3a_{n-1}\) distinct 3-permutations to \(S_{n+1}^2(231,312,321)\).

Now when either \(\sigma _R\) and \(\sigma _R'\) are nonempty, we show that inserting \(n+1\) anywhere but the end of the 3-permutation cannot avoid 231, 312, and 321. Let \(\sigma _R\) be nonempty. Then we must insert \(n+1\) at the end of \(\sigma \); otherwise, inserting \(n+1\) to the right of n contains 231, inserting left-adjacent to n contains 321, and inserting to the left of n contains 312. And we evaluate the projection of \((\sigma _L n \sigma _R (n+1), \sigma _L' (n+1) n)\):

figure k

Since \(\sigma _R\) is nonempty, this contains an instance of 312. The case where \(\sigma _R'\) is nonempty is similar. Inserting \(n+1\) anywhere else in \(\varvec{\sigma }\) cannot produce an element in \(S_{n+1}^2(231,312,321)\).

Now for \((\sigma ,\sigma ') \in S_n^2 \setminus S_{n}^2(231,312,321)\), we cannot obtain an element in \( S_{n+1}^2(231,312,321)\) by inserting the maximal element \(n+1\) anywhere in \(\sigma \) and \(\sigma '\). It is straightforward to check that the projections of \((\sigma (n+1), \sigma ' (n+1))\), \((\sigma _L (n+1)n, \sigma _L' n(n+1))\), \((\sigma _L (n+1)n, \sigma _L' (n+1)n)\), and \((\sigma _L n(n+1), \sigma _L' (n+1)n)\) contain instances of \(\sigma ' \circ \sigma ^{-1}\) and hence, contain instances of 231, 312, or 321. The proof above shows that inserting \(n+1\) anywhere else in \(\sigma \) and \(\sigma '\) cannot avoid these patterns.

Thus, it follows that

$$\begin{aligned} a_{n+1} = a_n + 3a_{n-1}.&\end{aligned}$$

\(\square \)

5 Final Remarks and Open Problems

In this paper, we completely enumerated 3-permutations avoiding two patterns of size 3 and three patterns of size 3. The theorems in this paper prove all the conjectures by Bonichon and Morel [7] regarding 3-permutations avoiding two patterns of size 3 and extend their conjectures to classify 3-permutations avoiding all classes of three patterns of size 3. We conclude with the following open problem.

Problem 5.1

Find combinatorial bijections to explain the relationships between the 3-permutation avoidance classes found in this paper and their recurrence relations.

For example, we notice that the sequence A001787 in Theorem 3.1 counts the number of 132-avoiding permutations of length \(n+2\) with exactly one occurrence of a 123-pattern and the number of Dyck \((n+2)\)-paths with exactly one valley at height 1 and no higher valley [11]. In general, the problem of enumerating d-permutations avoiding sets of small patterns is widely open. Since several of these enumeration sequences correspond to sequences on the OEIS database [11], there are certainly interesting combinatorial properties of these 3-permutation avoidance classes, and there are several bijections to find that explain these sequences.