Enumeration of Permutation Classes and Weighted Labelled Independent Sets

In this paper, we study the staircase encoding of permutations, which maps a permutation to a staircase grid with cells filled with permutations. We consider many cases, where restricted to a permutation class, the staircase encoding becomes a bijection to its image. We describe the image of those restrictions using independent sets of graphs weighted with permutations. We derive the generating function for the independent sets and then for their weighted counterparts. The bijections we establish provide the enumeration of permutation classes. We use our results to uncover some unbalanced Wilf-equivalences of permutation classes and outline how to do random sampling in the permutation classes. In particular, we cover the classes $\mathrm{Av}(2314,3124)$, $\mathrm{Av}(2413,3142)$, $\mathrm{Av}(2413,3124)$, $\mathrm{Av}(2413,2134)$ and $\mathrm{Av}(2314,2143)$, as well as many subclasses.


Introduction
A permutation of size n is an arrangement of the numbers 1, 2, . . . , n. For example, 43251 is a permutation of size 5. The set of all permutations is S, and the subset of permutations of size n is S n . The standardization of a string s of distinct integers is the permutation obtained by replacing the i-th smallest entry by i. A permutation σ contains a permutation π if π is the standardization of a (not necessarily consecutive) substring s of σ. In this context, we say that π is a (classical) pattern in σ. The substring s is called an occurrence of π in σ. If σ does not contain the pattern π, we say that σ avoids π. We represent the permutation σ on a grid by placing points at coordinates (i, σ(i)). For example, the permutation σ = 194532678 is pictured in Figure 1. The pattern π = 4321 is contained in σ since it is the standardization of the substring 9532 of σ. The permutation σ avoids the pattern 54321 since it does not contain any decreasing substring of size 5.
Given a pattern π we define Av n (π) as the set of permutations of size n that avoid π, and Av(π) as ∪ n≥0 Av n (π). For a set of patterns P , we let Av n (P ) = ∩ π∈P Av n (π), and Av(P ) = ∪ n≥0 Av n (P ). The set of non-empty permutations of Av(P ) is denoted Av + (P ). A permutation class C is a set of permutations that is closed downwards, in the sense that if σ ∈ C then π ∈ C for any pattern π in σ. It turns out that for a a permutation class C we can always find a set of patterns P such that C = Av(P ), for instance we can take P = S \C. However, the the smallest set of patterns B such that C = Av(B) is called the basis of C. There are cases where the basis consists of infinitely many patterns, due to the existence of infinite anti-chains in the containment order on S, but in this paper we only consider finite bases.
In Figure 2, we see the sum and skew-sum of 123 and 21. If a permutation σ can be expressed as the sum of two non-empty permutations we say that σ is sum-decomposable. The permutation 12435 is sum-decomposable since it can be expressed as 12 ⊕ 213. Similarly, we say that a permutation is skewdecomposable if it can be written as the skew-sum of two non-empty permutations. The permutation 43512 is skew-decomposable since it is 213 ⊖ 12. A permutation is sum-indecomposable if is not sumdecomposable and skew-indecomposable if it is not skew-decomposable. The sum of a permutation σ and a set of permutations P is the set σ ⊕ P = {σ ⊕ α : α ∈ P }, and likewise σ ⊖ P = {σ ⊖ α : α ∈ P }. We also define the sum, and skew-sum, of two sets of permutations in the obvious way.
123 ⊕ 21 123 ⊖ 21  Bean et al. (2020) introduced the staircase encoding, a function which maps a permutation to a staircase grid where cells are filled with non-negative integers. In this context, each integer is the size of the monotone sequence in its cell. In this paper, we refine the staircase encoding as a function which maps a permutation to a staircase grid where cells are filled with permutations. Using this function, we retrieve the generating function n>0 |Av n (P )| x n of several permutation classes.
We first recover the results for Av(123) and Av(132) from Bean et al. (2020) in Section 2, using our more refined encoding and weighted independent sets. Our technique is then extended to describe the structure of Av(2314, 3124) and Av(2413, 3142) in Section 3 and 4. In Section 5, we recall the updown core graph introduced by Bean et al. (2020) and use it to enumerate Av (2314,3124,2413,3142), before introducing a new core graph in Section 6 that is used to give the structure of Av (2314,3124,3142). Our notion of weighted independent sets is then generalized to allow labelling. This enables for a more refined choice of permutations in our encoding, and is used to enumerate Av (2413,3142,3124) in Section 7 and Av(2413, 3124) in Section 8. By allowing some interleaving between cells in the staircase grid representation of a permutation, we obtain the enumeration for Av (2413,2134) and Av(2314Av( , 2134 in Sections 9 and 10. Finally, in Section 11 we use results from previous sections to prove two unbalanced Wilf-equivalences. Our results handle in a unified framework the enumeration of many permutation classes that were first enumerated in Albert et al. (2014); Atkinson and Stitt (2002); Callan et al. (2017); Kremer (2000Kremer ( , 2003; Le (2005); . Moreover, the results also allow one to easily enumerate many subclasses of these classes.
To check whether these methods apply to a particular class we have added routines to the python package Permuta. For details see Section 12.

Mesh patterns
We end this section with a short introduction to mesh patterns which are utilised in some of our proofs. A reader familiar with them might skip directly to Section 2. A mesh pattern p is a pair (π, R) with π ∈ S k and R ⊆ {0, 1, . . . , k} 2 . Pictorially, we represent a mesh pattern in a similar way as a classical pattern, and we shade, for each (x, y) ∈ R, the unit square with bottom left corner in (x, y). The mesh pattern p = (132, {(0, 0), (0, 2), (1, 2), (2, 2), (2, 3), (3, 2)}) is pictured below.
Intuitively, an occurrence of a mesh pattern p = (π, R) in a permutation σ is an occurrence of π in σ such that, if we stretch the shading of π onto σ, σ has no point in the shaded region. For example, we consider the permutation 35142 and pick two different occurrences of 132 in it (see Figure 3). We stretch the shading of p for both occurrences. The one on the left is an occurrence of p since no points of σ are in the shading, however, the right one is not an occurrence of p since the 3 of σ is in the region corresponding to the box (0, 2) in p. Formally, the definition of mesh pattern containment is as follows. Definition 1.1 (Brändén and Claesson (2011)). Let π ∈ S k and σ ∈ S n . An occurrence of the mesh pattern p = (π, R) in a permutation σ is a subset ω of the plot of σ, G(σ) = {(i, σ(i)) : i ∈ {1, 2, . . . , n}} such that there are order preserving injections α, β : {1, . . . , k} → {1, . . . , n} satisfying the following conditions. Firstly, ω is an occurrence of π in the classical sense, i.e., i. ω = {(α(i), β(j)) : (i, j) ∈ G(σ)}.
Unlike for classical patterns, it can occur that Av(p) = Av(q) for two different mesh patterns, p, q. For instance the mesh patterns (21, ∅) and (21, {(1, 0), (1, 1), (1, 2)}) have the same avoiding permutations, since a permutation has an inversion if and only if it has a descent. Many of these coincidences are captured by the Shading Lemma (Hilmarsson et al., 2015, Lemma 11).
Throughout the paper, we will use the Shading Lemma to argue that the occurrence of a classical pattern implies the occurrence of a mesh pattern. For example, in the proof of Lemma 4.1 we argue that an occurrence of 2314 implies an occurrence of .
The argument goes as follows. Let σ be a permutation with an occurrence of 2314. We can shade the box (2, 0) by replacing the 1 of the occurrence by the bottomost point in that box. The box (0, 1) can also be shaded by replacing the 2 of the occurrence with the leftmost point in that cell.

Encoding permutations on grid
A letter σ i in a permutation σ is called a left-to-right minimum if σ j > σ i for all j < i. We denote with Av (n) (B) the permutations in Av(B) with exactly n left-to-right minima. For a coarser representation, take a permutation σ in Av (n) (B) and place the left-to-right minima on the main diagional of a n× n grid, and the remaining points into the cells of the grid with respect to their relative positions. We then replace the points in each cell by the permutation they are forming in this cell. This is called the the staircase encoding of σ and is denoted SE(σ). Figure 4 shows the staircase encoding of the permutation 659817432. As permutations contained in cells in the same row or same column can interleave in multiple ways, the staircase encoding is not an injective map. For example, the permutations 659814327 and 659718432 both have the staircase encoding shown in Figure 4 (c).
By construction, the staircase encoding only uses the cells above and to the right of the left-to-right minima. We define the staircase grid B n as the set of cells of the staircase encoding of a permutation with n left-to-right minima. The cells are indexed using matrix coordinates, i.e., B n = {(i, j) : 1 ≤ i ≤ n and i ≤ j ≤ n}. We say that B 0 is the empty staircase grid which corresponds to the staircase encoding of ε, the empty permutation. Bean et al. (2020) used the staircase grid to enumerate Av(123) and Av(132). We briefly review these in terms of our refined staircase encoding.
A cell in the staircase encoding of a permutation that avoids 123 contains a permutation avoiding 12, since any occurrence of 12 together with one of the left-to-right minima would give an occurrence of 123. Moreover, the presence of a point in a cell forces other cells to be empty. For example, in the encoding of Figure 4, we have the staircase encoding of the 123 avoiding permutation 659817432. As the cell (1, 3) contains a point, the cell (2, 2) must be empty if the encoding is one of a permutation avoiding 123. These constraints are symmetric and can be represented as a graph, where the cells of B n are the vertices and there is an edge between every pair of cells that cannot both contain a point of the permutation. This graph is called the up-core of B n .
Definition 2.1 (Definition 4.3 in Bean et al. (2020)). Let n ≥ 0 be an integer. The up-core of B n is the labelled undirected graph U(B n ) with vertex set B n and edges between (i, j) and (k, ℓ) if i > k, j < ℓ.
If a permutation avoids 132, we get similar restrictions on the staircase encoding. First, every cell avoids 21 for a similar reason as above. Second, some pairs of cells cannot both contain a point. Those restrictions are also described by a graph called the down-core.
Definition 2.2 (Definition 4.3 in Bean et al. (2020)). Let n ≥ 0 be an integer. The down-core of B n is the labelled undirected graph D(B n ) with vertex set B n and edges between (i, j) and (k, ℓ) if i < k, j < ℓ and the rectangle {i, i + 1, . . . k} × {j, j + 1, . . . , ℓ} is a subset of B n . See Figure 5 for examples of U(B 4 ) and D(B 4 ). We say that a cell of the staircase encoding is active if it contains a non-empty permutation. From the construction of the graphs, we can see that the set of active cells of the staircase encoding of a permutation in Av(123) (resp. Av (132)) is an independent set of U(B n ) (resp. D(B n )). The image under the staircase encoding of Av(123) is the set of staircase encodings that are independent sets of U(B n ), where the permutations in every cell avoid 12.  In order to formalize our previous statement, we introduce weighted independent sets, an independent set where a weight is given to each of its vertices. In this paper, the weights will always be permutations.
We denote by WI(G, S) the set of all weighted independents sets of a graph G where the weights are permutations from the set S. Using this notation, we have that SE(Av (n) (123)) ⊆ WI(U(B n ), Av + (12)) and SE(Av (n) (132)) ⊆ WI(D(B n ), Av + (21)).
The i-th row of a permutation consists of the points with values between the value of the i-th left-toright minima and the (i + 1)-st left-to-right minima of the permutation. Avoiding 123 forces rows of the permutation to be decreasing. This means that for two cells (i, j) and (i, k) with j < k the points in (i, j) are above the points in (i, k), i.e., larger in value. A decreasing row is pictured in Figure 6. For a 132 avoiding permutation, the rows of the permutation are increasing, i.e., for a pairs of cells (i, j) and (i, k) with j < k the points in (i, j) are below the points in (i, k), i.e., lower in value.
The j-th column of a permutation consists of the points with index between the indices of the j-th and (j + 1)-st left-to-right minima of a permutation. In a similar manner as above, we say that the j-th column is increasing (resp. decreasing) if for each pair of cells (i, j) and (k, j) with i > k the points in (i, j) are on the left (resp. right) of the points in (k, j). The columns of a 123 avoiding permutation are decreasing while the columns of a 132 avoiding permutation are increasing.
As mentioned before, the staircase encoding is not an injective map since many permutations can have the same staircase encoding. However, by restricting to the set of permutations with increasing (resp. decreasing) rows and columns the staircase encoding is an injection. The inverse of the staircase encoding restricted to permutations with increasing (resp. decreasing) rows and columns is dperm (resp. uperm).
Definition 2.3. For a staircase encoding E, we define • uperm(E) as the permutation σ with decreasing rows and columns such that SE(σ) = E.
• dperm(E) as the permutation σ with increasing rows and columns such that SE(σ) = E.
Both uperm and dperm are injective maps from the set of staircase encodings to the set of all permutations. Lemma 2.4 follows from the definition.
Lemma 2.4. The maps SE • uperm and SE • dperm are the identity on the set of all staircase encodings.
Remark 2.5. Formally, the staircase encoding is a map from the set of all permutations to the set of staircase grids filled with permutations. However, throughout the paper we consider the restriction of SE to a smaller set such that the restriction is a bijection to its image. Hence, when the context is clear (as in the theorem below), SE might refer to a restriction of the staircase encoding.
Theorem 2.6 (Lemma 2.2 in Bean et al. (2020)). The map SE is a bijection between Av (n) (123) and the weighted independent sets WI(U(B n ), Av + (12)). It is also a bijection between Av (n) (132) and the weighted independent sets WI(D(B n ), Av + (21)) By Theorems 2.4 and 3.3 from Bean et al. (2020) we know that the number of independent sets of size k in U(B n ), or D(B n ), is given by the coefficient of x n y k in the generating function F(x, y) that satisfies If we substitute y with x 1−x into F(x, y), we obtain the generating function where the coefficient of x n is the number of 123 avoiding permutation of size n.
Corollary 2.7. The generating function for Av(123) and Av (132) 3 Going from size 3 to size 4 patterns As seen in Section 2, avoiding the pattern 123 creates restrictions on which pairs of cells in the staircase grid can contain points of the permutation. These restrictions were encoded by the up-core graph. The same restrictions are enforced on the set of active cells of the staircase encoding for permutation avoding 2314 or 3124. The two patterns are pictured in Figure 7(a). In this figure, the black points can be thought of as left-to-right minima of the permutation and red points as points in the cells of the staircase grid. Avoiding either of those patterns ensures that two cells connected by up-core edges cannot be active simultaneously. Moreover, the pattern 2314, the row-up pattern, denoted r u , forces the rows to be decreasing. Similarly, the pattern 3124, the column-up pattern, denoted c u , forces the columns to be decreasing. The down-core restrictions can also be enforced using size 4 patterns. To do so, we introduce the row-down pattern 2413, denoted r d , and the column-down pattern 3142, denoted c d . As for the up-core, thinking of the black points as the left-to-right minima of the permutation and the red points as points in cells (see Figure 7(b)), we can see this results in the same constraints as in the down-core. Moreover, these patterns force rows and columns to be increasing. The above discussion is formalized in the next two lemmas. ii. the columns of σ are decreasing if σ ∈ Av(c u ), iii. the rows of σ are increasing if σ ∈ Av(r d ), iv. the columns of σ are increasing if σ ∈ Av(c d ).
Proof: We only prove i. since the other cases can be handled similarly. Let σ be a permutation and suppose that one of the rows is not decreasing. This row has at least two active cells, therefore σ has at least two left-to-right minima. Hence, when drawn on a staircase grid, this row contains two cells A and B such that B is to the right of A, and B contains a point higher than a point in A. These two points together with the left-to-right minima to the left of the columns containing A and B form an occurrence of r u in σ.
Lemma 3.2. Let σ be a permutation with n left-to-right minima and C be the set of active cells of the staircase encoding of σ. Then C is an independent set of Proof: It is sufficient to show i., which we do by proving the contrapositive: suppose that two active cells of the staircase encoding of a permutation σ are connected by an edge of U(B n ). Hence, one of the cells is above and to the right of the other. Moreover, since they are in distinct rows and distinct columns of B n , there exist three left-to-right minima as shown on Figure 8. The red point and the blue point together with the two points in the active cells form a c u pattern. Replacing the red point by the green one yields an occurrence of the pattern r u . Hence, σ is not in the union Av(r u ) ∪ Av(c u ).
In sections 4 to 9, we study different combinations of the patterns r u , c u , r d and c d . This leads to different graphs, weights and constraints on the rows and columns of the staircase grid. With each combination of patterns, we describe a set of patterns P that can be added to the basis while keeping the structural properties of the class that we need for enumeration. Even when not specified explicitly, we assume throughout the paper that the empty permutation is not in the set P . The results are presented in order of increasing complexity, with each section introducing a new tool that is used to build different structural descriptions and generating function arguments. Table 1 presents an overview of the results in the upcoming sections. The notation P × that appears in the table is introduced in Definition 7.2.

Permutation classes
Conditions on the set P Enumeration result Av(r d , c u , 1 ⊕ P ) P is skew-indecomposable and P × is sum-indecomposable Corollary 8.3 Av(r d , 2134, P ) P satisfies conditions described in Section 9 Corollary 9.5 Av(r u , 2143, P ) P satisfies conditions described in Section 10 Corollary 10.5 Tab. 1: Overview of the classes we cover in the upcoming sections.
4 Weighted independent sets of the up-core and the down-core Lemmas 3.1 and 3.2 say that every permutation in Av(r u , c u ) can be constructed by first taking an independent set of the up-core of a staircase grid, and weighting the cells with permutations in Av(r u , c u ).
We will show how this can be used to enumerate the class Av(r u , c u ) and many of its subclasses. We first show an auxiliary result used in the proof of our main results.
Lemma 4.1. Let P be a set of skew-indecomposable permutations. Then for n ≥ 1, uperm(WI(U(B n ), Av + (r u , c u , P ))) ⊆ Av (n) (r u , c u , 1 ⊕ P ). (2) Proof: First, for a skew-indecomposable permutation π, we will show Assume that σ ∈ uperm(WI(U(B n ), Av + (π))) contains 1⊕π. Then, a rectangular region of the staircase grid of σ contains π. As the set of active cells is an independent set of the up-core, the rows and columns are decreasing, and π is skew-indecomposable, π occurs in a single cell. This is a contradiction, since the weights are from Av + (π).
We will complete the proof by showing that Let σ be a permutation in uperm(WI(U(B n ), Av + (r u , c u ))). If σ contains either r u or c u then σ contains one of the mesh patterns m 1 or m 2 in Figure 9, by the Shading Lemma. If the cell (1, 0) of m 1 (resp. cell (0, 1) of m 2 ) contains a point then, by picking the leftmost point in that region, the permutation σ contains an occurrence of m 2 (resp. m 1 ) that is below (resp. to the left) of the occurrence we are m 1 m 2 m 3 m 4 Fig. 9: A permutation that contains ru or cu contains m1 or m2, as well as m3 or m4.
considering. Repeat this argument on the new occurrence. As σ is finite, we will repeat a finite number of times until we find an occurrence of m 3 or m 4 in Figure 9. Assume σ i1 σ i2 σ i3 σ i4 is an occurrence of m 3 in σ. Either σ i1 and σ i3 are both left-to-right minima in σ, or both are not left-to-right minima in σ. If they are left-to-right minima of σ then σ i2 and σ i4 are in different columns of the staircase grid, and moreover different rows as rows are decreasing. This implies that two connected cells in U(B n ) are active, contradicting the fact that an independent set was used. Therefore, σ i1 and σ i3 are not left-to-right minima of σ. There is, therefore, a point (k, σ k ) with k < i 1 and σ k < σ i3 . This new point together with the original occurrence is an occurrence of 1 ⊕ r u . As r u is skew-indecomposable, this contradicts Equation (3).
Hence, we have shown that σ avoids m 3 . A similar argument shows that m 4 is also avoided, and hence r u and c u are avoided by σ.
Theorem 4.2. Let P be a set of skew-indecomposable permutations. Then SE is a bijection between Av (n) (r u , c u , 1 ⊕ P ) and WI(U(B n ), Av + (r u , c u , P )).
Proof: Let σ be a permutation in Av (n) (r u , c u , 1 ⊕ P ). By Lemma 3.2, the active cells of the staircase encoding of σ form an independent set of U(B n ), and the subpermutations in each cell of the staircase encoding are in Av(r u , c u , P ). Hence, By applying SE on both sides of Equation (2) in Lemma 4.1, we get by Lemma 2.4 WI(U(B n ), Av + (r u , c u , P )) ⊆ SE(Av (n) (r u , c u , 1 ⊕ P )).
Since permutations avoiding r u and c u have decreasing rows and columns, the map SE is injective when restricted to Av (n) (r u , c u , 1 ⊕ P ). Therefore, SE is a bijection between Av (n) (r u , c u , 1 ⊕ P ) and WI(U(B n ), Av + (r u , c u , P )).
The following corollary shows how to compute the generating function for any basis covered by the theorem.
Corollary 4.3. Let P be a set of skew-indecomposable permutations and A(x) be the generating function of Av(r u , c u , P ).
Moreover, the size of the permutation obtained is the number of left-to-right minima added to the sizes of the weights of the independent set. This implies F(x, A(x) − 1) is the generating function for Av(r u , c u , 1 ⊕ P ).
Corollary 4.3 can be used to compute the generating function of Av(2314, 3124), that was first enumerated by Kremer (2000). The generating function A(x) for Av(2314, 3124) satisfies Solving gives which is the generating function for the large Schröder numbers, which can be found in the Online Encyclopedia of Integer sequences OEIS (2021) as sequence A006318. Corollary 4.3 can also be used to enumerate the subclass Av(2314, 3124, 1234), first enumerated by Callan et al. (2017). In this case, the cells of the independent sets are filled with permutations in Av(2314, 3124, 123) = Av(123). Since the generating function of the latter class is 1− , the generating function of Av(2314, 3124, 1234) is There are three different skew-indecomposable permutations of size 3. Those permutations are 123, 132 and 213. Therefore, Theorem 4.2 gives a structural description of Av(2314, 3124) and subclasses obtained by also avoiding any subset of {1234, 1243, 1324}. This gives 8 classes with bases consisting of only size four patterns. Since, there are 13 skew-indecomposable permutations of size 4, the theorem gives structural description of 2127 bases (i) that contain size 4 and 5 patterns.
Theorem 4.2 extends the number of permutation classes that the up-core describes. A similar method can be used for the down-core to enumerate permutation classes beyond Av(132).
Lemma 4.4. Let P be a set of sum-indecomposable permutations. Then for n ≥ 1 Theorem 4.5. Let P be a set of sum-indecomposable permutations. Then SE is a bijection between The proofs are left to the reader as they are similar to the proofs of Lemma 4.1 and Theorem 4.2. Corollary 4.6 follows naturally from Theorem 4.5.
Corollary 4.6. Let P be a set of sum-indecomposable permutations and A(x) be the generating function As a consequence of the previous corollary, A(x), the generating function of Av(2413, 3142), first enumerated by Kremer (2000), also satisfies Equation (4) and is given by Equation (5). This result can enumerate 8 classes with bases consisting of size four patterns and many more if we consider longer patterns.
It is worth noting that any subclass of Av(2413, 3142) (as well as the class itself) contains finitely many simple permutations and can be enumerated using a more general method called the substitution decomposition, described in Albert and Atkinson (2005). Bassino et al. (2017) extended the method to allow for random sampling. We outline briefly in Section 12 how the the structural description introduced in this paper can be used to randomly sample in permutation classes, including many with infinitely many simple permutations.

Inflating the updown-core
In the previous section, we enumerated Av(2314, 3124) and Av(2413, 3142) and many of their subclasses. However, the intersection of the two classes, namely the subclass Av(2314, 3124, 2413, 3142), cannot be enumerated using the theorems so far. Together those patterns put stricter constraints on the staircase encoding that we have not encountered yet. In this section, we combine different graphs to represent these constraints and, in particular, give the enumeration of Av(2314, 3124, 2413, 3142) and many of its subclasses. Again, this class and any subclasses could be enumerated using the substitution decomposition. However, the techniques used in this section are an important stepping stone for the upcoming sections.
To represent the new constraint, we introduce the column-edges that connect cells in the same column of a grid and the row-edges that connect cells in the same row. More formally: Definition 5.1.
• The column-core graph C(B n ) is the graph whose vertices are the cells of B n and where there is an edge between cells (i, j) and (k, ℓ) if i = k and j = ℓ.
• The row-core graph R(B n ) is the graph whose vertices are the cells of B n and where there is an edge between cells (i, j) and (k, ℓ) if i = k and j = ℓ.
We combine the edges of the four graphs U(B n ), D(B n ), C(B n ) and R(B n ) in the natural way. For example, the graph UDC(B n ) has the cells of B n as vertices and the edges of U(B n ), D(B n ) and C(B n ). Figure 10 shows UDC(B 4 ). As we did for the up-core and the down-core with Lemma 3.2, we describe sufficient conditions for the staircase encoding of a permutation to respect the constraints enforced by the column-core and the row-core.
Lemma 5.2. Let σ be a permutation with n left-to-right minima and C be the set of active cells of the staircase encoding of σ. Then C is an independent set of Proof: By Lemma 3.1 if σ ∈ Av(r u , r d ), the rows of σ are both increasing and decreasing. Therefore, there is at most one active cell in each row, and so the active cells correspond to an independent set in R(B n ). The proof of ii. is similar.
Proof: By Lemmas 3.2 and 5.2 we have that Let σ be a permutation in uperm(WI(UDRC(B n ), Av + (r d , c d , r u , c u , P ))). As any independent set of UDRC(B n ) is an independent set of U(B n ) and we have that uperm(WI(UDRC(B n ), Av + (r d , c d , r u , c u , P ))) ⊆ uperm(WI(U(B n ), Av + (r u , c u ))) Therefore, by Lemma 4.1 it follows that σ ∈ Av(r u , c u ). By observing that uperm and dperm are equivalent when building from an independent set of RC(B n ), it follows from a symmetric argument and Lemma 4.4 that σ ∈ Av(r d , c d ).
Assume that σ contains a pattern 1 ⊕ π, where π ∈ P . Without loss of generality, we can assume that the 1 in the occurrence is a left-to-right minimum in σ. Then π occurs in the rectangular region of cells north-east of the minimum. By the constraints of UDRC(B n ), there can be at most one active cell in this region, and so π is contained in this cell. This contradicts the fact that active cells are filled with permutations avoiding π. Therefore, σ avoids 1 ⊕ P , and moreover σ ∈ Av (n) (r d , c d , r u , c u , 1 ⊕ P ). We get or equivalently by applying SE on both sides Since permutations avoiding r u and c u have decreasing rows and columns, the map SE is injective when restricted to Av (n) (r u , c u , r d , c d , 1⊕P ). Therefore, SE is a bijection between Av (n) (r u , c u , r d , c d , 1⊕P ) and the image of that set which is WI(UDRC(B n ), Av + (r u , c u , r d , c d , P )).
Since the graph UDRC(B n ) is the same graph as the updown-core of B n defined in Bean et al. (2020), Lemma 4.13 of the same paper gives that the number of independent sets of size k in UDRC(B n ) is given by the coefficient of x n y k in the generating function As in Section 4, we get an enumeration result for the classes Av(r d , c d , r u , c u , 1 ⊕ P ).
Corollary 5.4. Let P be a set of permutations and A(x) be the generating function of

Solving the equation
which is the generating function for Av (2413,3142,2314,3124). This class was first enumerated by Atkinson and Stitt (2002) and the sequence appears on OEIS as A078482.

New cores
To this point we have considered permutation classes that can be described by filling the independent sets of the graphs U(B n ), D(B n ) and UDRC(B n ), which were first used by Bean et al. (2020) to enumerate permutation classes avoiding size 3 patterns. In this section, we begin to consider new graphs that were not motivated by permutation classes avoiding size 3 patterns. We first consider UDC(B n ). The active cells in the staircase encoding of a permutation σ avoiding c u and c d are an independent set of C(B n ). By Lemma 3.2, they are also an independent set of U(B n ) and D(B n ). In order to make the filling of independent sets unique we need that the rows are either increasing or decreasing, i.e., σ avoids r u or r d . In this section, we consider additionally avoiding r u , and delay the discussion of avoiding r d to Section 7.
Theorem 6.1. Let P be a set of skew-indecomposable permutations. Then SE is a bijection between Av (n) (r u , c u , c d , 1 ⊕ P ) and WI(UDC(B n ), Av + (r u , c u , c d , P )).
Proof: Let σ ∈ uperm(WI(UDC(B n ), Av + (r u , c u , c d , P ))). As UDC(B n ) contains the edges of U(B n ) we have uperm(WI(UDC(B n ), Av + (r u , c u , c d , P ))) ⊆ uperm(WI(U(B n ), Av + (r u , c u , c d , P ))) and so by Lemma 4.1, σ avoids r u , c u , 1 ⊕ c d and 1 ⊕ P . Suppose that σ contains an occurrence of c d , then by the Shading Lemma it also has an occurrence of the mesh pattern with the same underlying pattern and cells (0, 2) and (1, 0) shaded. Further, the avoidance of r u and 1 ⊕ c d imply that there is an occurrence with the cells (0, 1) and (0, 0) also shaded. Let σ i1 σ i2 σ i3 σ i4 be an occurrence of this mesh pattern, shown in Figure 11. Both σ i1 and σ i2 are left-to-right minima of σ. Therefore, σ i3 and σ i4 are in two separate active cells, contradicting the fact that the active cells are an independent set of D(B n ) and C(B n ). Hence, σ ∈ Av(r u , c u , c d , 1 ⊕ P ) and uperm(WI(UDC(B n ), Av + (r u , c u , c d , P ))) ⊆ Av (n) (r u , c u , c d , 1 ⊕ P ).
By applying SE to both sides we get By Lemmas 3.2 and 5.2, Moreover, by Lemma 3.1 the rows and columns are decreasing, therefore, restricted to Av (n) (r u , c u , c d , 1 ⊕ P ), SE is injective and a bijection to its image which is WI(UDC(B n ), Av(r u , c u , c d , P )).
In order to use the theorem above for enumerative purposes, we need to find the generating function where the coefficient of x n y k is the number of independent sets of size k in UDC(B n ). We prove a slightly more general statement that tracks the number of rows occupied by the independent set. Although, not required for the permutation classes discussed in this section it will be necessary for the results in Section 7.
Proposition 6.2. The number of independent sets of size k occupying ℓ rows in UDC(B n ) is given by the coefficient of x n y k z ℓ in the generating function Proof: An independent set in UDC(B n ) can contain an arbitrary number of vertices in the topmost row, i.e., vertices of the form (1, j). The number of such vertices is called the degree. If the degree is 0, then the subgraph induced by the remaining vertices is isomorphic to a smaller core UDC(B n−1 ). If the degree is not 0, let k = max{j : (1, j) is a vertex of the independent set}, i.e., k is the column of the rightmost vertex in the topmost row. The independent set cannot contain a vertex (ℓ, m) if 1 < ℓ ≤ k or if ℓ = 1 and m ≥ k. This corresponds to the region shaded in gray in Figure 12. Moreover, the vertices {(1, j) : 1 ≤ j < k} share no edges. We can, therefore, chose independently if they are in the independent set. The graph induced by the remaining vertices (ℓ, m) with ℓ > k and m > k, form an instance of the graph UDC(B n−k ). In Figure 12 this is the yellow region. Hence, G(x, y, z) satisfies Solving this equation gives the closed form claimed in the proposition.
As the proof of Theorem 6.1 gives a unique encoding of the permutation classes Av(r u , c u , c d , 1 ⊕ P ) we derive the following corollary to give their enumeration. Corollary 6.3. Let P be a set of skew-indecomposable permutations and A(x) be the generating function of Av(r u , c u , c d , 1 ⊕ P ). Then A(x) satisfies where B(x) is the generating function of Av(r u , c u , c d , P ).

Generalizing the fillings
As Section 6 considers the basis {r u , c u , c d }, one could hope that we can handle {r d , c d , c u } similarly. Unfortunately, the proof of Theorem 6.1 relies heavily on the fact that c d is skew-indecomposable. To repeat the argument for {r d , c d , c u }, one would need c u to be sum-indecomposable which is not the case. However, tracking an additional statistic on the independent set allows us to enumerate these classes. Even if the classes considered in the section could be enumerated using the substitution decomposition, the tracking we are about to introduce will also be used in sections 8, 9 and 10 for many classes that cannot be enumerated with the substitution decomposition.
If we consider the staircase encoding of σ ∈ Av (n) (r d , c d , c u ), we have from Lemmas 3.2 and 5.2 that the set of active cells form an independent set of UDC(B n ) and that the rows are increasing. Hence, if one cell in a row contains an occurrence of 312 and is not the rightmost non-empty cell of the row, an occurrence of c u = 3124 is created (see Figure 13). If an active cell contains 312 but is the rightmost cell in the row then no c u pattern is created since the cells above and to the right are empty. Hence, the staircase encoding of a permutation avoiding the pattern c u avoids 312 in its cells except the rightmost active cell of each row. In order to describe the set of staircase encodings of permutations in Av(r d , c d , c u ) we enrich our definition of a weighted independent set to a weighted labelled independent set. We first define a labelling function r on an independent set. This function maps a vertex v of an independent set I to a label in the set {y, z}.

r(v, I) =
y if v is not the rightmost cell of I in its row, z otherwise.
Definition 7.1. For a graph G on the staircase grid, we define WI r (G, Y, Z) as the set of weighted independent sets of G where the weight of a vertex v in an independent set I is an element of Y if r(v, I) = y or an element of Z if r(v, I) = z.
We introduce an operation that removes the last value of a permutation if this value is the maximum of the permutation.
Theorem 7.3. Let P be a set of permutations such that P × contains only sumindecomposable permutations. Then SE is a bijection between Av (n) (r d , c d , c u , 1 ⊕ P ) and WI r (UDC(B n ), Av + (312, P × ), Av + (r d , c d , c u , P )).
Proof: From Lemmas 3.2, and 5.2 and the discussion above, we have that To show the reverse inclusion, we partition P into two sets depending on whether the permutation ends with its maximum or not. We set Both Av(312, P × ) and Av(r d , c d , c u , P ) are subclasses of Av(r d , c d , P 1 ), so we get dperm(WI r (UDC(B n ), Av + (312, P × ), Av + (r d , c d , c u , P ))) ⊆ dperm(WI(UDC(B n ), Av + (r d , c d , P 1 ))) ⊆ dperm(WI(D(B n ), Av + (r d , c d , P 1 ))).
We also need to show that c u and 1 ⊕ P 2 are avoided.
Let σ be a permutation in dperm(WI r (UDC(B n ), Av + (312, P × ), Av + (r d , c d , c u , P ))). We first show that for π ∈ P 2 ∪ {c u }, 1 ⊕ π does not occur. By the hypothesis, we know that π = α ⊕ 1, with α sum-indecomposable. If 1 ⊕ π is contained in σ, then π is fully contained in a rectangular region of the grid. In such a region, the active cells of the encoding are in the same row. Hence, π is contained in a single row. Since the rows are increasing and α is sum-indecomposable, the only way to split the occurrence is to have an occurrence of α in a cell and an occurrence of 1 in a cell to the right. This is not allowed by the way the vertices can be weighted. Hence, it is contained in a single cell which is also forbidden. Therefore, by contradiction, 1 ⊕ π is avoided for any π in P 2 ∪ {c u }.
In particular 1 ⊕ c u is avoided. Using the Shading Lemma to shade the cells (0, 2) and (1, 0), the avoidance of r d to shade (0, 1) and the avoidance of 1 ⊕ c u to shade (0, 0), we see that if c u is contained in σ then σ contains an occurrence of the mesh pattern . An occurrence of this mesh pattern violates either the column-edges constraint or the up-edges constraints. Thus c u is avoided, and we have dperm(WI r (UDC(B n ), Av + (312, P × ), Av + (r d , c d , c u , P ))) ⊆ Av (n) (r d , c d , c u , 1 ⊕ P ), and, by Lemma 2.4, WI r (UDC(B n ), Av + (312, P × ), Av + (r d , c d , c u , P )) ⊆ SE(Av (n) (r d , c d , c u , 1 ⊕ P )).
By Lemma 3.1, the rows and columns of a permutation in Av (n) (r d , c d , c u , 1 ⊕ P ) are decreasing and therefore, restricted to this set, the map SE is injective. Hence, SE is a bijection between Av (n) (r d , c d , c u , 1 ⊕ P ) and SE(Av (n) (r d , c d , c u , 1 ⊕ P )) = WI r (UDC(B n ), Av + (312, P × ), Av + (r d , c d , c u , P )).
Recall that G(x, y, z) is the generating function of independent sets of UDC(B n ) where x tracks the size of the grid, y the size of the independent set, and z the number of rows of the independent set. Therefore, G(x, y, z y ) is the generating function where y tracks the number of cells labelled y by the labelling function r and z tracks the number of cells labelled z. Let C 1 and C 2 be two permutation classes enumerated by A(x) and B(x). Let F (x) be the generating function for the number of weighted independent sets where the cells labelled y are weighted with a non-empty permutation from C 1 and the cells labelled z are weighted with a non-empty permutation from C 2 . Then This leads to the following enumeration result: Corollary 7.4. Let P be a set of permutations such that P × contains only sum-indecomposable permutations, and A(x) be the generating function of Av(r d , c d , c u , 1 ⊕ P ). Then A(x) satisfies is the generating function of Av(r d , c d , c u , P ) and C(x) is the generating function of Av(312, P × ).
As an example, we derive A(x), the generating function of Av(2413, 3142, 3124) which was first derived by Callan et al. (2017) and appears in the OEIS as A033321. Since the basis is {r d , c d , c u },

B(x) = A(x). Moreover, Av(312) is enumerated by the Catalan numbers and C(x)
The equation can be solved to get the explicit form of the generating function.

Avoiding the row-down and column-up patterns
In this section, we consider permutation classes described by weighted independent sets of the graphs UD(B n ). This corresponds to removing one of the three patterns from the results in sections 6 and 7.
Theorem 8.1. Let P be a set of skew-indecomposable permutations such that all permutations of P × are sum-indecomposable. Then SE is a bijection between Av (n) (r d , c u , 1 ⊕ P ) and WI r (UD(B n ), Av + (312, P × ), Av + (r d , c u , P )).
Proof: By Lemma 3.1, the map SE is injective when restricted to Av (n) (r d , c u , 1⊕P ) as each permutation in this set has decreasing columns and increasing rows. Therefore, to show that SE is the claimed bijection, it is sufficient to show that SE(Av (n) (r d , c u , 1 ⊕ P )) = WI r (UD(B n ), Av + (312, P × ), Av + (r d , c u , P )).
By Lemma 3.2 any encoding in SE(Av (n) (r d , c u , 1 ⊕ P )) is an independent set of UD(B n ). Moreover, since the rows are increasing, all active cells but the rightmost of each row avoid 312 and P × as discussed at the beginning of Section 7. This implies SE(Av (n) (r d , c u , 1 ⊕ P )) ⊆ WI r (UD(B n ), Av + (312, P × ), Av + (r d , c u , P )).
Take I in WI r (UD(B n ), Av + (312, P × ), Av + (r d , c u , P )). We consider σ, the permutation obtained from I by building the permutation with decreasing columns and increasing rows. We show that σ is in Av (n) (r d , c u , 1 ⊕ P ). We start by showing that σ avoids 1 ⊕ r d , 1 ⊕ c u and 1 ⊕ P . In an occurrence of any of these patterns in σ, we can assume that the 1 is a left-to-right minimum. Hence, we have to show that r d , c u and P are avoided in the square formed by the set of cells that are north and east of a left-to-right minimum. Let π be any pattern in {r d , c u } ∪ P . We know that π is skew-indecomposable and that π × is sum-indecomposable.
Assume that π occurs in a square region of the cells that are north and east of a left-to-right minimum. We consider the rightmost column in the region that contains a point of the occurrence of π. In this column, we consider the topmost cell that contains such a point. In Figure 14, this cell is colored blue. By construction, the gray region is empty. Moreover, there is no point of the permutation in the green region (resp. the red region) because the set of active cells is an independent set of D(B n ) (resp. U(B n )). Since the columns are decreasing, if the occurrence contains any point in a cell below the blue one, π is skew-decomposable. Hence, the only active cell in the column is the blue one. Finally, since the row is increasing and π × is sum-indecomposable, π is either fully contained in the blue cell, which is forbidden, or π × is fully contained in a cell that is not the rightmost active one in the row, which is also forbidden. Consequently, 1 ⊕ r d , 1 ⊕ c u and 1 ⊕ P are avoided. Using shading arguments as done in previous proofs, we can show that if σ contains an occurrence of r d or c u then σ contains an occurrence of either of the mesh patterns or .
An occurrence of either of those pattern violates the edge, increasing rows, or decreasing column constraints. Hence, σ is in Av (n) (r d , c u , 1 ⊕ P ) and This proves that the image of Av (n) (r d , c u , 1 ⊕ P ) under SE is the set claimed in the theorem.
In order to enumerate these classes, we first enumerate the independent sets of UD(B n ) while keeping track of the number of rows.
Proposition 8.2. The number of independents set of size k in UD(B n ) occupying ℓ rows is given by the coefficient of x n y k z ℓ in the generating function that satisfies .
Proof: We consider the topmost row of B n . If it contains no vertex of the independent set, then we are looking at the independent set in a smaller core graph and it contributes x W(x, y, z) to W(x, y, z).
If the topmost row contains vertices of the independent set, we consider its rightmost vertex. The vertex is highlighted in blue in Figure 15. The cells in the yellow region do not contain any vertices of the independent set because they are connected to the blue cell by an edge. The vertices of the independent set are, therefore, in the hook formed by the white and blue cells, and the pink region. The pink region is completely disconnected from the hook and hence the vertices of the independent set in this region correspond to an independent set of a smaller core.
To find W, we need to enumerate the independent set of the hook that contains the corner cell of the hook. We say that the leg length of the hook is the number of cells in the horizontal strip. If the coefficient of x n y k z ℓ in D(x, y, z) is the number of such sets of k vertices using ℓ rows in the hook of leg length n, then W(x, y, z) = 1 + x W(x, y, z) + D(x, y, z) W(x, y, z). To find the generating function D(x, y, z) we first notice that any vertices that we take in the vertical leg add to the row count of the independent set while vertices in the horizontal leg do not change the row count. First, the case where the hook is a single cell contributes xyz to D(x, y, z).
Second, if the leg length of the hook is greater than 1, the cells at the end of each leg are not connected to the hook by any edges of the graph. Hence, we have complete freedom to put them in the independent set. Therefore, the second case is of the form (xyz)(xyz + x)(y + 1)(· · · ). As they are accounted for, we completely ignore the corner cell and the two cells at the end of the leg and focus on enumerating the part of the independent set in the remaining cells.
If no cell of the vertical leg is in the independent set, then any cell of the horizontal leg can be in it. Otherwise, if there are i cells above the topmost active cell of the vertical leg then the i leftmost cells of the horizontal leg are the only cells from that leg that can be in the independent set (see Figure 16).  Hence, which completes the proof.
Using the same reasoning as in Section 7 we derive the following enumeration result: Corollary 8.3. Let P be a set of skew-indecomposable permutations such that all permutations in P × are sum-indecomposable and A(x) be the generating of Av(r d , c u , 1 ⊕ P ). Then A(x) satisfies is the generating function of Av(r d , c u , P ) and C(x) is the generating function of Av(312, P × ).

Avoiding r d and 2134
In this section, we consider the pattern 2134 that has not been considered yet. As when we analysed r u , c u , r d and c d , we consider the two black points of Figure 17 as left-to-right minima of the permutation.
Then, we study the effect of the two red points on the staircase encoding of the permutation, its rows and its columns. An occurrence of 2134 where the two black points are left-to-right minima cannot have a point in the cell of the leading diagonal of the grid. Hence, the pattern does not enforce any restrictions on those cells. However, in the remaining cells, the pattern 2134 has the same effect as 123 has on the grid B n−1 since there are always two left-to-right minima to the left and below those cells. Let G(B n−1 ) be a graph with cells of B n−1 as vertices. Let S be a subset of B n . For the remainder of the paper, we will make a small abuse of the definition and say that S is an independent set of G(B n−1 ) if the set {(x, y − 1) : (x, y) ∈ S and x = y} is an independent set of G(B n−1 ). In other words, a subset of B n is an independent set of a graph on B n−1 if it is an independent set of the graph obtained by overlaying G(B n−1 ) on B n as in Figure 18. Using similar arguments as we did for Lemmas 3.1, 3.2 and 5.2, we can prove the following lemmas.
Lemma 9.1. Let σ be a permutation in Av (n) (2134). We consider the set C of active cells of the staircase encoding of σ that are not in the main diagonal of the grid. Then • C is an independent set of U (B n−1 )

• cells in C contain decreasing permutations
Moreover, if we remove the cells of the leading diagonal from σ, the rows and columns are decreasing.
Lemma 9.2. Let σ be a permutation in Av (n) (2134, r d ). The set of active cells of the staircase encoding of σ is and independent set of R(B n−1 ).
For the rest of this section, we let P be set of patterns, such that for all π in P : • π avoids , and • π ∈ S ⊕(Av + (12)\{1}).
Note, r d and 2134 satisfy these conditions. As further examples, the permutations 312 and 1423 also satisfy the conditions. For two graphs on staircase grids of different sizes, we define the merge of those graphs by gluing them by the top right corner cell. Figure 19 shows an example of a merge. The merge of two graphs A and B is denoted A ∨ B. In order to describe the structure of the staircase encodings of the permutations in Av(r d , 2134, 1 ⊕ P ), we define a labelling φ where the set of labels is {y, z, s, t}. For a subset I of the staircase grid and vertex v of this set, we let Figure 20 shows an independent set labelled with φ.
As we did for WI r , we define WI φ (G, Y, Z, S, T ), as the set of weighted independent sets of G such that for a vertex v in the independent set I, the weights of v is an element of During the rest of the section we consider the set WI φ (D(B n ) ∨ UR(B n−1 ), Av + (12), Av + (r d , 2134, P )\{1}, Av + (213, P × ), Av + (r d , 2134, P )).
For sake of brevity, we name it I n in this section.
Theorem 9.3. There is a bijection between Av (n) (r d , 2134, 1 ⊕ P ) and I n .
Proof: Let I be a weighted independent set in I n . Let E be the staircase encoding such that cell v contains the corresponding permutation, except when φ(v, I) = z. In this case, we write the weight as αmβ where m is the maximum, and in this cell of E, we add αβ.
Define f to be a map which maps I to the permutation f (I) with staircase encoding E such that • the rows of f (I) are increasing, • excluding points in the leading diagonal, the columns are decreasing, • in an active cell v labelled z, with weight αmβ, α is to the left and β is to the right of the points in the column. Figure 21 shows the map f applied to an independent set. We will show that f is the bijection desired. Assume that σ = f (I) contains 1 ⊕ π for some π ∈ P . If σ contains 1 ⊕ π, then it contains an occurrence where the 1 in the occurrence is a left-to-right minimum in σ. Therefore, σ contains an occurrence π in a rectangular region of the staircase grid. This region is pictured in Figure 22  In this region, without loss of generality we can assume the cell in the lower left corner is in the leading diagonal. The permutations that fill the active cells avoid P , therefore, the occurrence has points in at least two cells. In this region, consider the leftmost cell not in the leading diagonal containing a point of the occurrence of π. If this cell is in the first column, then by the definition of I the columns to the right are not active in f (I). The column consists of a decreasing permutation in the cells not in the leading diagonal (see Figure 22 (b)). As π avoids , the occurrence can use exactly one point in these cells, say k. Therefore, an occurrence of π is of the form αkβ, where the α and β are in the cell in leading diagonal, which contradicts the definition of f . Otherwise, the leftmost cell not in the leading diagonal is not in the first column. By the definition of I, the columns to the right and left are empty if they are not in the diagonal. Moreover, this column is decreasing as shown in Figure 22 (c). Therefore, since the blue cell avoids π × , it follows that π ∈ S ⊕(Av + (12)\{1}), contradicting the second condition of P . Hence, we have shown that f (I) avoids 1 ⊕ π.
If σ contains an occurrence of 2134 then it either contains an occurrence of 1 ⊕ 2134 or an occurrence of (2134, {(0, 0)}). By the Shading Lemma, the latter implies an occurrence of m 1 , see Figure 23. If m 1 occurs then the 2 and the 1 of the occurrence are left-to-right minima of the permutation. The 3 and 4 of the occurrence violate either a decreasing cell constraint if they are in the same cell or an up-edge or decreasing column constraint if they are not. Hence, if σ contains an occurrence of 2134 it also contains an occurrence of 1 ⊕ 2134. As 2134 satisfies the conditions of P this implies σ avoids 2134. If σ contains an occurrence of r d then by a similar argument as above, it either contains an occurrence of 1 ⊕ r d or m 2 . Moreover, if σ contains an occurrence of m 2 , we can find an occurrence of m 3 or m 4 . An occurrence of m 3 would violate the row increasing constraint or a down-edge constraint. The 5 and the 2 in an occurrence of m 4 are in the same column of the staircase grid as they cannot have any left-to-right minima between them. The 5 and 4 in an occurrence of m 4 are also in the same column, otherwise they violate a down-edge or a row-edge constraint. Hence, since the 2 in an occurrence is in a different row than the 5 and 4, we have a violation of the way we build the column. Therefore, m 4 does not occur in σ and σ avoids m 2 . We conclude that if σ contains r d then it contains 1 ⊕ r d . As r d satisfies the conditions of P this implies σ avoids r d .
The injectivity of f follows from the uniqueness of the map. For surjectivity, we consider a permutation σ in Av (n) (r d , 2134, 1⊕P ). The rows of σ are increasing by Lemma 3.1. By Lemma 9.1, the cells labelled y in σ contain decreasing permutations. Cells labelled s avoid 213 and P × since there is a guaranteed point of the permutation to the north east of the points in those cells. The cells labelled z and t avoid r d , 2134 and P . Moreover, the active cells of σ form an independent set of D(B n ) ∨ UR(B n−1 ) by Lemma 9.1 and 9.2.
We study how cells in the same column interact. We consider a column of the staircase grid. By Lemma 9.1, except for the bottommost cell, the column is decreasing and each cell contains a decreasing sequence. If there is a point in the bottom cell with index between two points of the decreasing sequence, then it creates an occurrence of r d . Hence, the bottommost cell can only have points on both sides of the decreasing sequences. Figure 24 shows a typical column. In the bottommost cell, any point in the gray region would create a r d pattern. Moreover, the content of this cell cannot create one of the forbidden patterns with one of the points above. Hence, it can only split in a place where a new maximum could be added without creating a pattern in {r d , 2134} ∪ P . The content of this cell comes from a permutation αmβ ∈ Av(r d , 2134, P ) where m is the maximum, α is placed on the left of the decreasing sequence and β on the right. This shows that σ can be obtained from an element of I n by applying f .
To compute the generating function of Av(2134, r d , 1⊕P ), we need to compute the generating function for the independent set of D(B n ) ∨ UR(B n−1 ) for n ∈ N. For these sets we track the number of vertices with each label by a different variable.
Proposition 9.4. Let H(x, y, z, s, t) be the generating function of independent sets of D(B n ) ∨ UR(B n−1 ) such that the variable y, z, s, t track the number of vertices with labels y, z, s, t in the set.
Proof: We observe that the vertices in the leading diagonal of D(B n ) ∨ UR(B n−1 ) are disconnected from the graph. Hence, they can be freely added or removed from any independent set. Because of the row constraint on B n−1 , the topmost row can contain at most one vertex that is not in the leading diagonal. First, if the independent set does not contain such a vertex then it contributes x(1 + t) H(x, y, z, s, t) to H.
From Theorem 9.3 and Proposition 9.4, we get the enumeration of Av(r d , 2134, 1 ⊕ P ).
Using the corollary above, we can compute A(x), the generating function of Av(2134, 2413) that was first enumerated by Albert et al. (2014). In this example, P is empty. Hence, B(x) = A(x) and C(x) is the generating function for the Catalan numbers. We get that the generating function A(x) satisfies This equation can be solved explicitly to find the enumeration that appears in OEIS as A165538.
10 Avoiding r u and 2143 Using similar techniques as in the previous section we enumerate classes of the form Av(r u , 2143, 1 ⊕ P ) where each pattern π in P satisfies • π avoids , and • π ∈ S ⊖ Av + (21).
For the entire section, we let P be such a set. We look at the pattern 2143 in Figure 26 as we did for 2134. If we consider the two black points as left-to-right minima of a permutation, then the two red points will enforce a down-core structure on the staircase grid except for the leading diagonal. The following lemmas follow from similar arguments as in Lemma 10.1. Let σ be a permutation in Av (n) (2143). We consider the set C of active cells of the staircase encoding of σ that are not in the main diagonal of the grid. Then • C is an independent set of D(B n−1 ), • cells in C contain increasing permutations.
Moreover, if we remove the cells of the leading diagonal from σ, the rows and columns are increasing.
Lemma 10.2. Let σ be a permutation in Av (n) (2143, r u ). The set of active cells of the staircase encoding of σ is an independent set of R(B n−1 ).
From the two previous lemmas and Lemma 3.2, we know that for σ in Av (n) (r u , 2143) the active cells of SE(σ) are an independent set of U(B n ) ∨ DR(B n−1 ). To describe the structure of the staircase encoding of the permutations in Av(r u , 2143, 1 ⊕ P ) we introduce new labelled weighted independent sets. First, for a subset I of the staircase grid and a vertex v of I, we set Theorem 10.3. There is a bijection between Av (n) (r u , 2143, 1 ⊕ P ) and WI ψ (U(B n ) ∨ DR(B n−1 ), Av + (21), Av + (r u , 2143, P )\{1}, Av + (r u , 2143, P )).
Proof: For conciseness, we denote with I n the set of weighted independent sets stated in the theorem. Let I be a weighted independent set in I n .
Let E be the staircase encoding such that a cell v contains the same permutation as in I, except when φ(v, I) = z. In this case, we write the weight as αmβ where m is the maximum, and add αβ to cell v.
Define f to be a map which maps I to the permutation f (I) with staircase encoding E such that • the rows of f (I) are decreasing, • excluding points in the leading diagonal, the columns are increasing, • in an active cell v labelled z, with weight αmβ, α is to the left and β is to the right of the points in the column.  Figure 28 shows the map f applied to an independent set.
We show that f is the desired bijection. Assume that σ = f (I) contains 1 ⊕ π for some π ∈ P . If σ contains 1 ⊕ π, then it contains an occurrence where the 1 in the occurrence is a left-to-right minimum in σ. Therefore, σ contains an occurrence π in a rectangular region of the staircase grid. This region is pictured in Figure 29  In this region, without loss of generality, we can assume the cell in the lower left corner is in the leading diagonal. The permutations contained in each active cell avoid P , therefore, the occurrence has points in at least two cells. In this region, consider the leftmost cell not in the leading diagonal containing a point of the occurrence of π. If this cell is in the first column then, by the definition of I, only cells in the leftmost column and the bottommost row can be active. Moreover, the row-edges imply that only one cell in the bottom row that is not in the leading diagonal can be active. The column consists of an increasing permutation in the cells not in the leading diagonal and the rows are decreasing (see Figure 29 (b)). As π is not in S ⊖ Av + (21), the bottommost cell in this figure is empty. Also, as π avoids , the occurrence can use exactly one point in the remaining white cells, say k. Therefore, the occurrence of π is of the form αkβ, where the α and β are in the cell in leading diagonal, which contradicts the definition of f . Otherwise, the leftmost cell not in the leading diagonal is not in the first column. By the definition of I, only the column of this cell and the bottommost row can be active. Moreover, this column is increasing and the bottom row is decreasing. Only one white cell of the bottom row can be active because of the rowedges. This is shown in Figure 29 (c). Therefore, it follows, since π ∈ S ⊖ Av + (21), that the bottommost cell is empty. Hence π is an increasing permutation, which contradicts the first condition on P . Hence, we have shown that f (I) avoids 1 ⊕ π.
If σ contains an occurrence of 2143 then it either contains an occurrence of 1 ⊕ 2143 or an occurrence of (2143, {(0, 0)}). By the Shading Lemma, the latter implies an occurrence of m 1 (see Figure 30). If m 1 occurs then the 2 and the 1 of the occurrence are left-to-right minima of the permutation. The 3 and 4 of the occurrence violate either an increasing cell constraint if they are in the same cell or a down-edge constraint if they are not. Hence, if σ contains an occurrence of 2143 it also contains an occurrence of 1 ⊕ 2143. As 2143 satisfies the conditions of P this implies σ avoids 2143. If σ contains an occurrence of r u then by a similar argument as above, it either contains an occurrence of 1 ⊕ r u or m 2 . Moreover, if σ contains an occurrence of m 2 , we can find an occurrence of m 3 or m 4 . An occurrence of m 3 would violate the row decreasing constraints or the up-edges constraints. The 4 and the 2 in an occurrence of m 4 are in the same column of the staircase grid since they cannot have any left-to-right minima between them. The 5 and 4 in an occurrence of m 4 are also in the same column otherwise they violate an up-edge constraint. Hence, since the point at index 4 is in a different row than the ones at index 3 and 5, we have a violation of the way we build the column. Therefore, m 4 does not occur in σ and σ avoids m 2 . We conclude that if σ contains r u then it contains 1 ⊕ r u . As r u satisfies the conditions of P , this implies σ avoids r u .
The injectivity of f follows from the uniqueness of the map. For surjectivity, we consider a permutation σ in Av (n) (r u , 2143, 1 ⊕ P ). The rows of σ are decreasing by Lemma 3.1. By Lemma 10.1, the cells labelled y in σ contain increasing permutations. The cells labelled z and s avoid r u , 2143 and P . Moreover, the active cells of σ form an independent set of U(B n ) ∨ DR(B n−1 ) by Lemmas 10.1 and 10.2.
Finally, we need to consider the points in a column of the staircase grid. By Lemma 10.1, except for the bottommost cell, the column is increasing and each cell contains an increasing permutation. If there is a point in the bottom cell with index between two points of the increasing sequence, then it creates an occurrence of r u . Hence, the bottommost cell can only have points on either side of the increasing sequence. Figure 31 shows a typical column. In the bottommost cell, any point in the gray region would create an r u pattern. Moreover, the points in this cell together with another point in this column cannot create one of the forbidden patterns. Hence, it can only be split in a place where a new maximum could be added without creating a pattern in {r u , 2143} ∪ P . Therefore, the points in the cell are of the form αβ where α is to the left of the other points in the column, β is to the right of the other points in the column, and αmβ ∈ Av(r u , 2143, P ).
Therefore we have shown that σ can be obtained from an element of I n by applying f .
To compute the generating function of Av(r u , 2143, 1⊕P ), we need to compute the generating function for the independent set of U(B n ) ∨ DR(B n−1 ) for n ∈ N. For these sets we track the number of vertices and their labels with different variables.
Proposition 10.4. Let J(x, y, z, s) be the generating function of independent sets of D(B n ) ∨ UR(B n−1 ) such that the variables y, z, s track the number of vertices with label y, z, s in the set. Then J(x, y, z, s) satisfies J(x, y, z, s) = 1 + x(s + 1) J(x, y, z, s) + xy(z + 1)(J(x, y, z, s) − 1) 1 − x(y + 1) .
Proof: We consider the top row of the graph. The leftmost cell is completely disconnected from the graph, hence, it can be freely added to the independent set. The row constraint on B n−1 implies the topmost row contains at most one vertex that is not in the leading diagonal. First, if the independent set does not contain such a vertex then it contributes x(s + 1) J(x, y, z, s) to J.
Otherwise, the graph decomposes as shown on Figure 32 and we get a contribution of where the J(x,y,z,s) x(s+1) term is due to the pink region which is precisely a smaller core, where a single disconnected cell has been removed. Hence, J(x, y, z, s, t) satisfies J(x, y, z, s) = 1 + x(s + 1) J(x, y, z, s) + xy(s + 1) 1 − x(y + 1) x(z + 1) J(x, y, z, s) − 1 x(s + 1) as claimed in the proposition.
From Theorem 10.3 and Proposition 10.4, we get the enumeration of Av(r u , 2143, 1 ⊕ P ).
Using the corollary above, we can compute A(x), the generating function of Av(2314, 2143) that was first enumerated by Le (2005). In this example, P is empty. Hence, B(x) = A(x). We get that the generating function A(x) satisfies This equation can be solved explicitly to find the generating function This generating function gives the enumeration that appears in OEIS as A109033.

Unbalanced Wilf-equivalence
A combination of many of our results can be used to prove that some classes have the same enumeration. When two classes have the same enumeration, we say that they are Wilf-equivalent. This equivalence is said to be unbalanced if one of the bases has a pattern of size k, but the other basis does not, like in the next theorem.
The class Av(r d , 123) is the same class as Av(r u , c u , r d , 123) since 123 is contained in r u and c u . Moreover, the last class is a symmetry of Av(r u , c u , c d , 123). Hence, by Corollary 6.3, We also have that Av(213, 1423) is a symmetry of Av(132, c u ) which is the same class as Av(r d , c d , c u , 132). Hence, by Corollary 7.4, We showed that B 1 (x) = B 2 (x) and we know that C 1 (x) = C 2 (x) = 1 1−x . Therefore, we have that A 1 (x) = A 2 (x).
Theorem 11.2. The classes Av(2134, 2413) and Av (2314,3124,13524,12435) are Wilf-equivalent. Proof: In our notation, the two classes are Av(r d , 2134) and Av(r u , c u , 13524, 12435). Let A 1 (x) be the generating function of Av(2134, r d ) as computed in Section 9. Let A 2 (x) be the generating function of Av(r u , c u , 13524, 12435). By Corollary 4.3, A 2 (x) = F(x, B(x) − 1) where B(x) is the generating function of Av(r u , c u , r d , 1324). As this class is a symmetry of Av(r u , c u , c d , 1324), by Corollary 6.3, B(x) = G(x, C(x) − 1) where C(x) is the generating function for Av(r u , c u , r d , 213). The previous class is in fact Av(213). Hence, C(x) is the generating function for the Catalan numbers. Rewinding the previous step, we can compute A 2 (x) explicitly. A simple verification then shows that A 1 (x) = A 2 (x).

Conclusion
The technique of enumeration studied in this paper has been implemented in the python package Permuta, developed by the Ardal et al. (2019). To test if any of the theorems in this paper apply to a basis one can use the code snippet below. It will print a reference to any of the results in the paper that apply to any symmetry of the basis of interest. from permuta import Perm from permuta.enumeration_strategies import find_strategies basis = [Perm((1,2,0,3)), Perm((2,0,1,3)), Perm((0,1,2,3))] for strat in find_strategies(basis): print(strat.reference()) Tracking more bases with the same cores Let π be a skew-indecomposable permutation. In Theorem 4.2, we described the structure of bases of the form {r u , c u , 1 ⊕ π}. It seems possible to enumerate classes whose basis are of the form {r u , c u , 21 ⊕ π}. In this case, the staircase encoding would contain permutations avoiding {r u , c u , π} in the cells that are not in the leading diagonal and permutations avoiding {r u , c u , 21⊕π} in the cells in the leading diagonal. Hence, tracking the vertices of the independent set that are in the leading diagonal would be sufficient to enumerate this class. It is likely that this reasoning can be extended to replace 21 with an arbitrary decreasing sequence.
Increasing the size of the patterns. In Section 3, we go from size 3 to size 4 patterns. To do so, we gave a set of patterns of size 4 that put the same constraints on the staircase grid as 123 did. This idea is not limited to size 4 patterns. We can easily see that the nine patterns of size 5 in Figure 33 enforce the same constraints as 123 on the staircase grid. Therefore, one can expect the results to generalize to greater size. However, to do so, two major issues need to be overcome. First, one needs to be sure that if a pattern occurs in a permutation, then there needs to be an occurrence of the pattern using the left-to-right minima of the permutation. This can be done with the addition of other patterns to the basis. Computation shows that for the size 5 cases, 7 patterns is the smallest number of patterns that can be added to do so. Secondly, the technique will not give information about the permutations with exactly two left-to-right minima. Independent sets on boundary grids. The letter π i in a permutation π is a right-to-left maximum if π j < π i of all j > i. Building a skew-shaped grid from the left-to-right minima and the right-to-left maxima we get the boundary encoding of the permutation. Figure 34 shows an example of a boundary encoding. One might be able to use the boundary encoding to generalize the method of the staircase encoding, but in this new case, any permutation avoiding 123 could potentially be a boundary.
Wilf-equivalence and bijective proof. In Section 11, we uncovered two Wilf-equivalences by computing the generating functions with our results. The proof of Theorem 11.1 nicely highlights a structural argument for the Wilf-equivalence as both classes are built from the same core. However, it is not the case in the proof of Theorem 11.2. It would be interesting to establish a bijection between the two classes using the core structure.
Random sampling Most of the techniques used throughout can be directly, or with minor changes, translated to the language of combinatorial specifications (see Flajolet and Sedgewick (2009)). This opens the door to many existing tools, including, but certainly not limited to generating the permutations in a class, or uniformly sampling permutations in a class (see Flajolet et al. (1994); Duchon et al. (2004)). For example, it is not too hard to see how to convert the argument used in Bean et al. (2020) to find F(x, y), the generating function for independent sets of the down-cores, to a specification. From Corollary 4.6, we know that A(x), the generating function of Av(r d , c d ), satisfies A(x) = F(x, A(x)−1). If we work with the q, t-analog of A(x) where q tracks the number of left-to-right minima of the permutations and t tracks the number of active cells, that is A(x, q, t) = F(qx, tA(x) − t), then by looking at this distribution we can pick randomly the number of minima, and active cells. We can then use the specification for F(x, y), and standard techniques to uniformly sample an independent set from the down-core of appropriate size. Finally, by recursively choosing the permutations to fill the corresponding active cells in the same manner, we will be able to sample uniformly from Av(r d , c d ).
This approach could be applied to the methods within our paper, perhaps requiring some extra 'bookkeeping' along the way.