Inversion sequences avoiding 021 and another pattern of length four

We study the enumeration of inversion sequences that avoid pattern 021 and another pattern of length four. We determine the generating trees for all possible pattern pairs and compute the corresponding generating functions. We introduce the concept of d -regular generating trees and conjecture that for any 021 -avoiding pattern τ , the generating tree T ( { 021 , τ } ) is d -regular for some integer d .


Introduction
An integer sequence e = e 0 e 1 • • • e n is called an inversion sequence of length n if 0 ≤ e i ≤ i for each 0 ≤ i ≤ n.We use I n to denote the set of inversion sequences of length n.There is a bijection between I n and the set of permutations of length n + 1, denoted by S n+1 .Let τ be a word of length k over the alphabet [k] := {0, 1, • • • , k − 1}, we say that an inversion sequence e ∈ I n contains the pattern τ if there is a subsequence of length k in e that has the same relative order with τ ; otherwise, we say that e avoids the pattern τ .For instance, e = 010213 ∈ I 5 avoids the pattern 201 because there is no subsequence e j e k e l of length three in e with j < k < l and e k < e l < e j .On the other hand, e = 010213 contains the patterns 010 and 0012.For a given pattern τ , we use I n (τ ) to denote the set of all τ -avoiding inversion sequences of length n.Similarly, for a given set of patterns B, we set I n (B) = ∩ τ ∈B I n (τ ).The first results on the pattern-avoiding inversion sequences were obtained by Mansour and Shattuck (2015) and Corteel et al. (2016) for the patterns of length three.Later, Martinez and Savage (2018) generalized and extended the notion of pattern-avoidance for the inversion sequences to triples of binary relations that lead to new conjectures and open problems.Various other pattern-avoidance conditions such as vincular patterns, pairs of patterns, and longer patterns are also studied for inversion sequences; for relevant results, see Auli and Elizalde (2021); Bouvel et al. (2018); Beaton et al. (2019); Cao et al. (2019); Chern (2023); Duncan and Steingrímsson (2011); Callan et al. (2023); Lin (2018Lin ( , 2020)); Mansour and Shattuck (2022); Yan andLin (2020-2021); Lin and Fu (2021); Lin and Yan (2020) and references therein.In the context of inversion We use C n and M n to denote the Catalan and Motzkin numbers, respectively.Their generating functions are C . For a letter or number s, we use s m to denote the string of m s, that is, 2 An algorithmic approach based on generating trees For each class of inversion sequences avoiding a fixed set of patterns, there is a corresponding generating tree that encodes the elements of the class as its vertices under some specific rules.We refer the reader to Section 2 of Kotsireas et al. (2024) for the details.
We use I B = ∪ ∞ n=0 I n (B) to denote the set of all inversion sequences avoiding the pattern set B. The corresponding generating tree T (B) is a rooted, labeled, plane tree whose vertices are the objects of I B with the following properties: (i) each element of I B appears exactly once in the tree; (ii) element of size n appears at level n in the tree (the root has level 0); (iii) there is a set of succession rules that determine the number of children and their labels for each vertex.The tree T (B) will be empty if no inversion sequence of arbitrary length avoids the set B. Otherwise, the root's label will always be 0, that is, 0 ∈ T (B).From the root, whose level is zero, we construct the remainder of the tree T (B) in a recursive way where the n th level of the tree consists exactly the elements of I n (B) arranged in such a way that the parent of an inversion sequence e 0 e 1 • • • e n ∈ I n (B) is the unique inversion sequence e 0 e 1 • • • e n−1 ∈ I n−1 (B).We obtain the children of e 0 e 1 • • • e n−1 ∈ I n−1 (B) from the set {e 0 e 1 • • • e n−1 e n | e n = 0, 1, . . ., n} by obeying the restrictions of the patterns in B. We arrange the nodes from the left to the right so that if e = e 0 e 1 • • • e n−1 i and e = e 0 e 1 • • • e n−1 j are children of the same parent e 1 • • • e n−1 , then e appears on the left of e if i < j.Based on this initial tree T (B), we define an equivalence relation on the set of the nodes of this tree and obtain a second representation of the tree corresponding to the class I B which is more efficient for enumerating purposes.We relabel the vertices of the tree T (B) as follows.Define T (B; e) as the subtree of the inversion sequence e as the root and its descendants in T (B).We say that e is equivalent to e , denoted by e ∼ e , if and only if T (B; e) ∼ = T (B; e ) (in the sense of plane trees).Let T (B) be the same tree T (B) where we replace each node e by the first node e ∈ T (B) from top to bottom and from left to right in T (B) such that T (B; e) ∼ = T (B; e ).Clearly, the generating tree T (B) has a root 0, for any B such that 0 ∈ B.
Let B be any set of patterns, and let T (B) be the generating tree for the class I n (B).The length of a node v ∈ T (B) is defined to be the number of letters in v, and it is denoted by len(v).For any k ≥ 1, let D k (B) be the multi-set of all nodes of length k at level k − 1 in T (B).For each node v ∈ D k (B), we denote the multi-set of all children of v at level k in T (B) by N k (B; v).A generating tree T (B) is said to be d-regular if there exists k ≥ 1 such that • the number of different nodes in D r (B) equals d, for all r > k; • for any v ∈ D r (B) and w ∈ N r (B; v), the number of occurrences of w in N r (B; v) does not depend on r, whenever r > k.
T (B) is 0-regular if and only if the generating tree T (B) is finite.We present an example of dregular and non-regular trees to illustrate the definition.If B = {021, 0123}, then the generating tree T (B) has the following rules where Based on our results (see Table 1), we have the following conjecture.
We will use the following procedure to study the generating functions for the sequences where τ is any pattern of length four that avoids 021.
The five-step Procedure: The main results of this paper are applications of the five-step procedure described briefly in the introduction.We will now outline the details of the procedure for the pattern set B = {021, 1002}.First, we obtain the rules of the generating tree T (B) by using the algorithm developed in Kotsireas et al. (2024).We then get an explicit formula for the generating function from the rules of generating tree in a systematic way that can be programmed in software.
• Step 1-An educated guess for the rules of T (B): Based on the output of the algorithm of Kotsireas et al. (2024), we guess that the rules of the generating tree T (B) can be described as follows: the generating tree T (B)'s root is denoted by a 1 , and the succession rules are: and h = 01020.In Kotsireas et al. (2024), elementary examples show how the algorithm works, so we refer the reader to it for the details.We use R to denote the (proposed) set of rules of the tree. • Step 2-Verifying the set of rules for T (B): We prove that the proposed set of rules R hold for any level in the tree.Note that we have to show that when we add a letter j = 0, 1, . . ., len(v) for the father v of a rule, we obtain a rule in R. For instance, consider the rule h h, we can add a letter j = 0, 1, . . ., 5: since the inversion sequences avoid B, we see that T (B; h0) ∼ T (B; h).

Thus the rule h
h holds for T (B).Similarly, we can show that the rules R describe all the rules of T (B).
• Step 3-From the rules of T (B) to a one-parameter infinite system of equations: For each rule of the type v v in R, we define the generating function A v (x) as the generating function for the number of nodes at level n in the subtree T (B; v) of T (B), where the root of this subtree is the vertex v that stays at level 0. Then each rule of the type v v (1) v (2) • • • v ( ) can be translated into an equation for the generating functions as Note that if we have a finite number of rules, then there will be a finite system of equations.For the above rules, we have where , and H(x) = A h (x).
• Step 4-A finite system of equations for bivariate generating functions: There are many different methods to solve such system of recurrence relations.In this paper, we observe that for each set of patterns B = {021, τ } with a 021-avoiding four-letter pattern τ , the system of recurrence relations is linear, and it is parametrized by one parameter m.
We will use bivariate generating functions to solve the recurrence relations.Consider A m (x) parametrized by one parameter m, we define the bi-variate generating function as where s indicates the minimal value of m such that the recurrence for the generating function A m (x) holds.From the above recurrence relations, we obtain • Step 5-Obtaining the generating function F B (x) with the kernel method: In order to solve such system, we use kernel method several times.We apply the algorithm in Hou and Mansour (2008). Let , we consider the equation of E(x, v) with v = v 0 , which leads to Then by setting this into the same equation of E(x, v), we obtain For the second step, we take the equation of D(x, v) at limit v = v 0 , which leads to Then by setting this into the same equation of D(x, v), we obtain Similarly, we solve other cases.Let v 0 = x, for C(x, v) with v = v 0 , we first obtain C(x, 0) and then obtain an explicit formula for C(x, v).The case of B(x, v) and A(x, v) follow with the same v = v 0 .Hence we obtain which leads to that the generating function A(x, 0) is given by Clearly, A(x, 0) = A 1 (x) is the generating function for the number of inversion sequences in I n (B).
An explicit formula for the enumerating sequence {|I n ({021, 1002})|} n≥1 follows from the generating function: All other cases are based on similar techniques as described above.For some {021, τ }-avoiding inversion sequence classes, we observe that finding the root of the kernel requires the solution of a third or fourth-order polynomial.We will provide the details of the proofs of such cases in the following sections.

Four letter patterns
In this section, we consider the set of inversion sequences of length n that avoid both 021 and τ , where τ is any pattern of length four that avoids 021.We summarize our results in Table 1; the results follow from the procedure discussed in the previous section (for the Maple file which includes all the computations, we refer the reader to Mansour (2022b)).We obtain exact formulas for the generating functions Most of them are algebraic of degree at most 6 and only involve the square root of 1 − 4x.We will give all the details of the above procedure for five cases to show how we find analytic expressions for the generating functions.In Corollary 3.9, we summarize the exact enumerating formulas for all pattern cases except the ones whose generating functions don't lead to a nice closed formula.
Tab. 1: Succession rules for the generating trees T (B) and generating functions F B (x) for pattern set B = {021, τ }, where τ is any pattern of length four that avoids 021.

Beginning of
End of Table 1 Theorem 3.1 Let B ∈ {{021, 1001}, {021, 1011}, {021, 1101}}.Then, the generating function Proof: By the generating tree succession rules for T ({021, 1001}), T ({021, 1011}), and T ({021, 1101}) in Table 1, it follows that for all x, Define A m (x), B m (x), and C m (x) to be the generating functions for the number of nodes at level n in T ({021, 1001}; a m ), T ({021, 1001}; b m ), and T ({021, 1001}; c m ), respectively, where its root stays at level 0. Then Then the above recurrences can be written as . By finding A(x, v) from the first equation and C(x, v) from the second equation, we obtain that the second equation can be written as where (here i 2 = −1) Solving this system for A 1 (x), B 1 (x), and A 2 (x) + C 1 (x), we obtain Hence, the generating function A 1 can be written as .
By using a computer programming, we can express v 4 in terms of A 1 .Given that K(v 4 ) = 0, we find that the generating function . By the Lagrange inversion formula, we complete the proof. 2 From Table 1, we see that the patterns 0101 and 0111 when paired with 021 have the same generating trees.Our next result enumerates these pattern pairs.Theorem 3.2 The generating functions F {021,0101} (x) and F {021,0111} (x) are given by f (x), where f (x) = x(1+f (x)) 1−x(1+f (x)) 2 .Moreover, for all n ≥ 1, Proof: By the generating tree succession rules for T ({021, 0101}) and T ({021, 0111}) in Table 1, we have By translating the rules of the generating tree T ({021, 0101}) to generating function, we obtain ). Finding A(x, v) from the first equation and substituting it into the second equation, we obtain The kernel of this equation is given by K . The equation K(v) has three roots, that is, K(v j ) = 0 for j = 1, 2, 3, where By taking either v = v 1 or v = v 2 into the equation, we get a system of equations.Solving this system for A(x, 0) and B(x, 0), we obtain Since K(v 3 ) = 0, we have that A(x, 0) satisfies the equation By the Lagrange inversion formula, we obtain which, by comparing coefficient of x n , we complete the proof.
Inversion sequences avoiding 021 and another pattern of length four By taking v = v j , j = 1, 2, we obtain = 0.
Solving this system for B 1 (x) and C 1 (x), we have explicit formulas for B 1 (x) and C 1 (x): Hence, by the equation of B(x, v), we obtain an explicit formula for B(x, v).In particular, we have ), which completes the proof. 2 Remark 3.4 By the proof of Theorem 3.3 and Theorem 3.5 The generating function F {021,1012} (x) is given by , Proof: By translating the rules of the generating tree T ({021, 1012}) in Table 1 to generating functions, we have

Toufik Mansour, Gökhan Yıldırım
Finding C(x, v) from the third equation and substituting its expression into the second equation, we obtain The kernel of this equation is given by K . The equation K(v) = 0 has three roots, that is, K(v j ) = 0 for j = 1, 2, 3, where By taking either v = v 1 or v = v 2 into the equation, we get a system of equations.Solving this system for B(x, 0) and C(x, 0), we obtain , as claimed. 2 Remark 3.6 By the proof of Theorem 3.5 and using that Theorem 3.7 The generating function F {021,1202} (x) is given by , Proof: By translating the rules of the generating tree T ({021, 1202}) in Table 1 to generating functions, we have Finding D(x, v) from the fourth equation and substituting its expression into the third equation, we obtain The kernel of this equation is given by K . The equation K(v) = 0 has three roots, namely, K(v j ) = 0 for j = 1, 2, 3, where By taking either v = v 1 or v = v 2 into the equation, we get a system of equations.Solving this system for B(x, 0) and C(x, 0), we obtain . Thus, by expressions of C(x, 0) and D(x, 0), we have explicit formulas for C(x, v) and D(x, v).
Hence, by considering the equation of B(x, v) with v = 2x, we obtain which, by using this expression and C(x, v), we obtain an explicit formula for B(x, v).
By considering the equation of A(x, v) with v = x, we obtain , as claimed. 2 Remark 3.8 By the proof of Theorem 3.7 and using that v 3 is a root of Before we study the pair of 021 and 0000 in Section3.1,we present the following corollary that states explicit formulas for |I n ({021, τ )| where τ is any 021-avoiding four-letter pattern except three cases, 1110, 1012 and 1202.For these three patterns, we could not succeed to find explicit formulas.The formulas follow from determining the coefficient of the term x n in the generating functions F {021,τ } (x), where we omit the details.

Case B={021,0000}
In this section, we study the pair of patterns 021 and 0000.The generating tree T ({021, 0000}) has a long list of succession rules and the solution to the equations for the generating functions requires some technical steps.By applying our algorithm, we found that the generating tree T ({021, 0000}) has the following set of rules.The root has the label 0 and the succession rules are the following: a 331 (2), a 321 (2), 0 3 1, 0 3 2, 0 3 3, 0 3 2 3 a 321 (2), 0 3 1, 0 3 2, 0 3 3 Toufik Mansour, Gökhan Yıldırım Note that there are two relations for these three roots By taking either v = v 1 or v = v 2 into (9), we obtain a system of two equations with variables A 323 (0) and A 332 (0).Solving the system and using (10), we obtain By substituting expressions of A 323 (0) and A 332 (0) into equations of A 323 (v) and A 332 (v) of NS3 and solving for A 323 (v) and A 332 (v), we obtain .
Step 4: We will not present the exact expressions because most of them are quite long.For the next step, we consider the equation of A 232 (v) in System NS3.After using the expressions of A 323 (v), A 323 (0), A 332 (v), and A 332 (0), we obtain an equation of the form where f (v) denotes the derivative of f with respect to v. By substituting either v = v 1 or v = v 2 , we obtain a system of two equations with the variables A 232 (0) and A 223 (0).Solving this system and using ( 10 By substituting either v = v 1 or v = v 2 , we obtain a system of two equations with the variables A 132 (0) and A 123 (0).Solving this system and using (10), we obtain explicit formulas for A 132 (0) and A 123 (0) in terms of the root v 0 and x.Then, by substituting expressions of A 323 (0), A 332 (0), A 223 (0), A 232 (0), A 132 (0), A 123 (0), A 323 (v), A 332 (v), A 223 (v), and A 232 (v) into the equations of A 123 (v) and A 132 (v) of NS3 and solving for A 123 (v) and A 132 (v), we derive explicit formulas for A 123 (v) and A 132 (v) in terms of the root v 0 and v, x.
All the explicit expressions of these generating functions can be found in the following Maple worksheet Mansour (2022a).
Step 6: Up to now, we have explicit formulas for the generating functions A r (v) (also for A r (0)), for all r ∈ {123, 132, 223, 232, 323, 332}.By the expressions of E1, we get explicit formulas for all A r (v) which leads to explicit expressions for A r (0), where r = ijk and 1 ≤ i, k ≤ 3 and j = 1, 2.
Step 7: At the last step, we solve System S1 by using expressions A r (0) from the previous step.In particular, we obtain an explicit formula for A 0 .
The computations used in Steps 1-7 are programmed in Mansour (2022a).

Concluding remarks
Table 1 presents the generating trees for all the cases I n ({021, τ }) whenever τ is a four-letter pattern that avoids 021.Moreover, the table includes the explicit formulas for the corresponding generating functions F {021,τ } (x).We see that Conjecture 2.1 holds for length-four patterns.Our method successfully solves the case 0000, but we are curious whether there is a more straightforward solution for it or not.
There are 106 patterns of length five that avoid 021.We applied our algorithm to each class and found that the Conjecture 2.1 holds for 021-avoiding five-letter patterns.More precisely, we determined the generating trees and obtained explicit formulas for the generating functions F {021,τ } (x) whenever τ is a five-letter pattern that avoids 021.Since the computations are too long, especially for the following four cases τ = 00000, 00001, 00011, 00012, we decided not to present them here.But the explicit formulas of the generating functions for five-letter pattern cases are available in Mansour and Yıldırım (2022).

,
exactly once and the child b k of b k−1 ∈ D k (B) occurs exactly twice.Hence, T (B) is 2-regular.Let B = {000, 0011}.The generating tree T (B) has the following rules: where a m = 012 • • • m and b m = a m 0. Note that D k (B) contains a k−1 exactly once and b k−2 exactly k − 1 times, for all k ≥ 1.Thus, T (B) is not d-regular for any d.