A bijection between evil-avoiding and rectangular permutations

Evil-avoiding permutations, introduced by Kim and Williams in 2022, arise in the study of the inhomogeneous totally asymmetric simple exclusion process. Rectangular permutations, introduced by Chiriv\`i, Fang, and Fourier in 2021, arise in the study of Schubert varieties and Demazure modules. Taking a suggestion of Kim and Williams, we supply an explicit bijection between evil-avoiding and rectangular permutations in $S_n$ that preserves the number of recoils. We encode these classes of permutations as regular languages and construct a length-preserving bijection between words in these regular languages. We extend the bijection to another Wilf-equivalent class of permutations, namely the $1$-almost-increasing permutations, and exhibit a bijection between rectangular permutations and walks of length $2n-2$ in a path of seven vertices starting and ending at the middle vertex.


Introduction
A permutation π contains a permutation σ as a pattern if some subsequence of the values of π has the same relative order as all of the values of σ.Otherwise, π avoids σ.Two classes of pattern-avoiding permutations, called evil-avoiding and rectangular permutations, have been of recent interest due to their algebraic significance.Kim and Williams gave the following definition of evil-avoiding permutations.

Definition 1. [KW22]
A permutation that avoids the patterns 2413, 4132, 4213 and 3214 is called evilavoiding. 1  In this paper, we exhibit such a bijection.In fact, our bijection preserves not only the size of a permutation but also the number of recoils, as motivated in [KW22] and explained below.Definition 4. A recoil of a permutation π ∈ S n is a value i ∈ {1, 2, . . ., n − 1} so that i occurs after i + 1 in π, which means π −1 i > π −1 i+1 .Equivalently, i is a recoil of π if i is a descent of π −1 .Kim and Williams [KW22] enumerated evil-avoiding permutations of size n with k recoils.A quick computational check shows that for small n, there are the same number of evil-avoiding permutations of length n with k recoils as rectangular permutations of length n with k recoils, thus motivating the following notion.
Definition 5. Two classes of pattern-avoiding permutations are strongly Wilf-equivalent if for every n and k the classes have the same counts of permutations in S n with k recoils.
In [KW22], Kim and Williams observed that there are several permutation classes enumerated by OEIS sequence A006012, including (1) permutations π ∈ S n for which the pairs (i, π i ) with i < π i , considered as closed intervals [i + 1, π i ], do not overlap; equivalently, for each i ∈ [n] there is at most one j ≤ i with π j > i, (2) permutations on {1, 2, . . ., n} with no subsequence abcd such that bc are adjacent in position and max(a, c) < min(b, d), (3) rectangular permutations, hence the following suggestion, which may be regarded as a refinement of Suggestion 1.

Suggestion 2. [KW22]
Biject evil-avoiding permutations with k recoils (where we let k vary) with any of the above sets of permutations in S n .
We construct such a refined bijection.
Theorem 3.There is an explicit bijection between evil-avoiding and rectangular permutations in S n with k recoils.
For example, the bijection sends the evil-avoiding permutation in Figure 1 to the rectangular permutation in Figure 2.
A formal statement of the bijection appears in Section 3, Theorem 4. We encode each evil-avoiding permutation and each rectangular permutation as elements of regular languages L Evil and L Rect , respectively, then construct a bijection between these languages preserving the length and number of recoils of the corresponding permutations.
The significance of evil-avoiding permutations is rooted in Schubert calculus.There is a type of Markov chain called the asymmetric simple exclusion process (ASEP) in which particles hop on a one-dimensional lattice subject to the condition that at most one particle may occupy a given site.The inhomogeneous totally asymmetric simple exclusion process (inhomogeneous TASEP) is a type of ASEP where the sites 1, 2, . . ., n are arranged in a ring and the hopping rate depends on the weight of the particles.For more details on the inhomogeneous TASEP, see [KW22], [LW12], [AL14], [AM13], and [Can16].An interesting feature about ASEPs is that the steady-state probabilities at each site often contain Schubert polynomials, for reasons that are not entirely understood.In the case of the inhomogeneous TASEP, Kim and Williams demonstrate that a specialization of the steady-state probabilities at states corresponding to evil-avoiding permutations can be written as a "trivial factor" times a product of (double) Schubert polynomials [KW22].The number of Schubert polynomials in the steady-state formula is equal to the number of recoils in the corresponding evil-avoiding permutation [KW22].
Rectangular permutations arise in the context of representation theory.The name "rectangular" was coined by Chivrì, Fang, and Fourier in 2021 and we briefly summarize its origin here; we direct the reader to their paper [CFF21] for more details.
Let Φ denote the root system of the Lie algebra sl n+1 , let α 1 , . . ., α n denote the simple roots of sl n+1 , and let n} denote the set of positive roots.The support supp(α i,j ) of the root α i,j is defined to be the subset {i, i + 1, . . ., j} of {1, 2, . . ., n}.The set Φ + admits a poset structure with partial order relation given by α k, ≤ α i,j when k ≥ i and j ≥ .The meet α i,j ∧ α k, is defined by α max(i,k),min(j, ) when it exists and dually, the join α i,j ∨ α k, is defined by α min(i,k),max(j, ) .
The rest of the paper is organized as follows.Section 2 gives preliminary definitions and constructions, and Section 3 introduces operators for constructing rectangular and evil-avoiding permutations and explicitly state the bijection between the languages L Rect and L Evil .Sections 4 and 5 establish the bijection between L Rect and rectangular permutations and between L Evil and evil-avoiding permutations.Section 6 illustrates the bijection for a number of small permutations.Section 7 discusses 1-almost-increasing permutations and bijects them with rectangular permutations.Section 8 provides a bijection between a family of paths and rectangular permutations.Finally, Section 9 discusses possible future directions, algebraic and enumerative.

Preliminaries
Let S n be the symmetric group on the set {1, . . ., n}.We say that a permutation π ∈ S n has size n and write π in tabular form as [π 1 π 2 • • • π n ].For n ≥ 0, we denote by e n the identity in S n .
We may grade the rectangular permutations by the size of the permutation, or double grade these permutations by the size and the number of recoils.Let Rect denote the set of all rectangular permutations, let Rect(n) denote the set of rectangular permutations in S n , and let Rect(n, k) denote the set of rectangular permutations in S n with k recoils.The evil-avoiding permutations can be singly or doubly graded in the same way, and we define Evil, Evil(n), and Evil(n, k) analogously.
Since our bijection involves regular expressions (regexes), we will define these here the way Sipser does [Sip98].Informally, Definition 8.A regular expression (regex) is a formula that describes a language (set of words) over an alphabet Σ.A regex is either ∅ or it is built recursively from individual elements of Σ∪{ε} using the operations of (1) concatenation (•)(•), (2) OR (•|•) (an alternative between two simpler patterns), or (3) the unary Kleene star (•) * (R * allows 0 or more repetitions of the pattern R).
The symbol ε represents the empty string.For example, ((a|ε)b) * (a|ε) generates words in {a, b} * with no adjacent a's.For clarity, we can also use the unary Kleene plus (•) + (R + allows 1 or more repetitions of the pattern R).For example, (a|b) + describes any positive-length string of a's and b's.
It is equivalent to be able to describe a language (a subset of Σ * ) as the set of words generated by a regular expression and to say that there is a deterministic finite automaton (DFA) accepting the words [Sip98].Definition 9. A deterministic finite automaton M is a 5-tuple (Q, Σ, δ, q 0 , F ) where (1) Q is a finite set of states, (2) Σ is an alphabet consisting of a finite set of input symbols, (3) δ is a transition function from Q × Σ to Q, (4) q 0 ∈ Q is an initial state, (5) F ⊂ Q is a set of accepting states.
We will consider many lengthening operators (denoted ρ i,j or γ a,b ) on permutations.These operators have domains that are subsets of ∪ ∞ n=0 S n .Applying a lengthening operator to a permutation in S n in the operator's domain produces a permutation in S n+1 .
Definition 10.The insertion operator ρ i,j takes in a permutation π, inserts the value i at index j, and increments by 1 all values in π greater than or equal to i. Equivalently, the permutation matrix for the result has the original permutation matrix as the (i, j) minor formed by deleting the ith row and jth column, which are both all 0s except for a 1 in the (i, j) position.If π ∈ S n then ρ i,j (π) is defined when 1 ≤ i ≤ n + 1 and 1 ≤ j ≤ n + 1.In tabular form, all entries at least i are increased by 1, then an i is inserted between positions j − 1 and j.If σ = ρ i,j (π), then for 1 ≤ k ≤ n + 1, We also define an operator γ a,b which does not increase the length of a permutation.It will be used to define one of the operators on evil-avoiding permutations.
Definition 11.The shifting operator γ a,b takes in a permutation π ∈ S n , removes the value at index a, and inserts it at index b for a > b.More formally, if τ = γ a,b (π), then for 1 ≤ k ≤ n, Additionally, we will make use of an indicator variable 1 S to describe the actions of our operators on individual values in permutations.
Definition 12.For a statement S, the indicator variable 1 S is defined as follows:

The bijection
In this section, we construct two regular languages of operators on permutations based on rectangular and evil-avoiding permutations, L Rect and L Evil .We find regular expressions for these languages and construct a length-preserving bijection between them.In Sections 4 and 5, we will establish that these languages are encodings of rectangular and evil-avoiding permutations respectively.
3.1.Rectangular permutations.We define four operators on rectangular permutations: ψ 1 , ψ 2 , ψ u , and ψ d .Each increases the size of the permutation by one, and we restrict the domains of some of the operators.Similar operators were introduced by Biers-Ariel to count permutations avoiding the patterns 1324, 1423, 2314, and 2413 [Bie17], which are trivially Wilf-equivalent to rectangular permutations.
The map ψ 1 is the insertion operator ρ 1,1 .It increments by 1 all values of the permutation, then inserts a 1 at the beginning.The domain of ψ 1 is all rectangular permutations of size at least 0. Applying ψ 1 does not change the number of recoils in a permutation.
The map ψ 2 is the insertion operator ρ 1,2 with a restricted domain.We restrict ψ 2 to rectangular permutations with a first element greater than 1, that is, rectangular permutations of size at least 2 that could not be in the image of ψ 1 .(We are restricting the domain of ψ 2 to ensure that ψ 2 and ψ d , defined later, have disjoint images, which helps us avoid ambiguous encodings.)This restriction means that ψ 2 (π) has the same number of recoils as π.
The map ψ u applies ρ π1,1 to permutation π.To ensure that ψ u and ψ 1 have disjoint images, we restrict ψ u to rectangular permutations of size at least 2 whose first element is not 1.Applying ψ u does not change the number of recoils of a permutation.
The map ψ d applies ρ π1+1,1 to permutation π.This operator is defined on all rectangular permutations of size at least 1.Applying ψ d always increases the number of recoils by one.
Here are some examples of the four operators.For more such examples, see Table 1 in Section 6.
Example.The permutation σ = [3214] does not start with 1 and is in the domain of all four of these operators, and the images are Example.The permutation τ = [126354] starts with a 1, so it is not in the domain of ψ 2 or ψ u as these operations would duplicate the values of ψ d (τ ) = [2137465] and ψ 1 (τ ) = [1237465], respectively.

Operators on Rectangular Permutations
A composition in these operators can be abbreviated as a word in alphabet A r = {1, 2, u, d}, e.g., ψ u • ψ d • ψ 1 corresponds to the word ud1.
We prove in Section 4 that each rectangular permutation can be expressed uniquely as a composition of maps in A * r = {ψ 1 , ψ 2 , ψ u , ψ d } applied to e 0 .The procedures of ψ 2 and ψ d could be applied more widely, but since the domains are restricted to ensure uniqueness, they cannot be applied to any permutation in the image of ψ 1 .Since only ψ 1 can be applied to the identity in S 0 , the word encoding a permutation of positive length must end in 1. Words in A * r satisfying these restrictions form a regular language, which is a language that can be described with a regular expression.
Lemma 1.Let L Rect be the language in A * r of compositions of positive length of {ψ 1 , ψ 2 , ψ u , ψ d } applied to the permutation in S 0 .
(1) The words of L Rect are precisely the words in A * r that end in 1 with no 21 or u1.
Proof.Only ψ 1 can be applied to the element of S 0 , so the first (rightmost) operator must be ψ 1 , and the word must end in 1.The domains of ψ 2 and ψ u are restricted to exclude precisely the images of ψ 1 , so the substrings 21 and u1 are forbidden.There are no other restrictions.
One way to produce the regular expression is to consider splitting a word encoding a rectangular permutation by the d's (if any) into strings in {1, 2, u} * .Since there are no 21 or u1 substrings, the 1s must be to the left of the 2 and u symbols (if any), so the strings between the d's must be of the form 1 * (2|u) * .Further, there must be a terminal 1, so the last substring must be all 1's.Hence, a regular expression generating 3.2.Evil-avoiding permutations.We can similarly encode evil-avoiding permutations as compositions of size-increasing operators applied to the permutation e 0 in S 0 .These operators are ψ p , ψ q , ψ r , and ψ s , each of which has domain equal to a proper subset of evil-avoiding permutations.Compositions of these operators can be abbreviated as words in A e = {p, q, r, s}.
The operator ψ p works the same way as ψ 1 and ρ 1,1 , but is restricted to evil-avoiding permutations with at least one recoil (i.e., to nonidentity permutations).
The operator ψ r is defined on all evil-avoiding permutations of size at least 1.On an evil-avoiding permutation in S n , this is ρ 1,n+1 .
The operator ψ s is defined on evil-avoiding permutations that have e t as a suffix for some positive integer t.We allow there to be no values before the 1, so that any identity permutation of size at least 0 is included in the domain of ψ s .This operator is a restriction of ρ t+1,n+1 = ρ πn,n+1 .
Here are some examples of the four operators.For more such examples, see Section 6, Table 1.
Example.The permutation τ = [45123] is in the domain of all four operators ψ p , ψ q , ψ r , and ψ s .The images are In Section 5, we show that every evil-avoiding permutation can be written uniquely as a composition of these operators applied to the permutation of S 0 .Because of domain restrictions, not all words in A * e = {ψ p , ψ q , ψ r , ψ s } are valid.Lemma 2. Let L Evil be the language in A * e of compositions of {ψ p , ψ q , ψ r , ψ s } of positive length applied to the permutation in S 0 .
(1) The words of L Evil are precisely the words in A * e ending in s with no sp or sq and neither p nor q before the terminal string of s's.
Proof.The operator ψ s can be applied to the identity e 0 of S 0 , while ψ p , ψ q , and ψ r cannot, so a word in L Evil must end in s.The domain of ψ s is restricted so that it can only be applied after ψ r or ψ s , so the substrings sp and sq are forbidden.The operators ψ p and ψ q cannot be applied to the identity e n ↔ s n , so before the terminal string of s's there can only be an r (or nothing).There are no other restrictions.
To obtain the regular expression for such words, split on the r's, if any, to produce a sequence of words in {p, q, s} * .The last word must be a string of s's of positive length, hence it can be described by s + .In each earlier word, the s's must come after all of the p's and q's, so it can be described by (p|q) * s * .Thus, a regular expression for L Evil is ((p|q) * s * r) * s + .

Definition of the bijection.
Theorem 4.There is a length-preserving bijection b : L Rect → L Evil given by the below operations: (1) substituting 2 → p, u → q, d → r, and 1 → s, (2) reversing the prefix before the last r, if it exists.This bijection has inverse b −1 : L Evil → L Rect given by: (1) reversing the prefix before the last r, if it exists, (2) substituting p → 2, q → u, r → d and s → 1.
The fact that b is a bijection and b −1 is its inverse follows immediately from the regular expressions (1 * (u|2) * d) * 1 + and ((p|q) * s * r) * s + for L Rect and L Evil .

A regular expression for rectangular permutations
We next establish the encoding of rectangular permutations of positive length as words in L Rect , which is generated by the regular expression (1 * (2|u) * d) * 1 + .Throughout the proofs in this section, we say that two values π i , π j in a permutation π are adjacent if |π i − π j | = 1.In particular, we do not require |i − j| = 1.Lemma 3. If π is rectangular, then any of the permutations ψ 1 (π), ψ 2 (π), ψ u (π), and ψ d (π) that are defined are also rectangular.
Proof.These operators can be viewed as inserting an element into the first position for ψ 1 , ψ u , ψ d or second position for ψ 2 .We only need to demonstrate that there are no patterns 2413, 2431, 4213, and 4231 using the added element since any patterns without the added element would have been present in π.
The added element of ψ 1 (π) is a leading 1.Any pattern involving this entry has a leading 1, but none of the forbidden patterns start with a 1, so if π is rectangular, so is ψ 1 (π).
The added elements of ψ u and ψ d are in the first position and are adjacent to the value in the second position.In all of the forbidden patterns, the first two values in the pattern are not adjacent.Thus, any forbidden pattern in ψ u (π) or ψ d (π) using the first value cannot also use the second value.Then, we can replace the first value with the second value to produce the same forbidden pattern, which means π also would have to have that forbidden pattern.Thus, if π is rectangular, so are ψ u (π) and ψ d (π) (if defined).
The added element of ψ 2 (π) is a 1 in the second position.If the 1 is used in a pattern, the pattern must have a 1 in the first or second position, but none of 2413, 2431, 4213, or 4231 have a 1 in the first or second position.Thus, if π is rectangular, so is ψ 2 (π) (if defined).
Lemma 4. For n ≥ 1, every rectangular permutation in Rect(n) is uniquely expressible as a map in the set {ψ 1 , ψ 2 , ψ u , ψ d } applied to an element of Rect(n − 1).
Proof.We claim that every rectangular permutation π must have adjacent first two elements or a 1 in one of the first two positions.To see why, assume otherwise.Then the first two elements π 1 , π 2 are not adjacent.Let v be a value at least min(π 1 , π 2 ) and at most max(π 1 , π 2 ).Then the positions {1, 2, π −1 1 , π −1 v } form a 2413, 2431, 4213, or 4231, which is a contradiction.Thus, the claim is shown. If The restrictions of the domains for the four operators mean there is no ambiguity in deciding which operator produced π.
The following corollary follows immediately by induction.
Corollary 1.Every rectangular permutation can be expressed uniquely as a composition of ψ 1 , ψ 2 , ψ u , and ψ d .
Further, we can determine the number of recoils in a permutation from the corresponding composition.
Lemma 5.The operators ψ 1 , ψ 2 , and ψ u do not change the number of recoils of a permutation.The operator ψ d increases the number of recoils by 1.This lemma can be checked in a straightforward manner by examining each recoil π i in π and the recoil's image under ψ 1 , ψ 2 , ψ u , or ψ d .Under any of the first three maps, this process accounts for all of the recoils in the image permutation, but under the fourth map, there is one recoil unaccounted for in the image permutation, namely the one formed by π 1 .
The following corollary is then immediate.
Corollary 2. The permutations in Rect(n, k) are encoded uniquely by the words in L Rect of length n with k d's.

A regular expression for evil-avoiding permutations
We now establish the encoding of evil-avoiding permutations of positive length as words in L Evil , which is generated by the regular expression ((p|q) * s * r) * s + .
The proof of this bijection involves some machinery in [KW22] used to analyze and count evil-avoiding permutations.We use slightly different notation than in [KW22] in some places, which we indicate explicitly.This definition does not require λ to be a partition of n.

Definition 16. [KW22]
For 1 ≤ k ≤ n − 2, let ParSeq(n, k) denote the set of all sequences of partitions (λ 1 , . . ., λ k ) such that each λ i is valid for n, and for all 1 ≤ i ≤ k − 1, if is the smallest part of λ i , then the first (n − ) parts of λ i+1 are equal.If k = 0, then ParSeq(n, k) consists of one element, the empty sequence.
The sets St(n, k) and ParSeq(n, k) are natural to examine, as we explain.Observe that the sets Evil(n−1, k) and St(n, k) can be bijected by f : In preparation for the next proposition, we recall that the Lehmer code of a permutation π is the tuple c = (c 1 , . . ., c n ) where c i = |{j | j > i, π j < π i }|.
In [KW22], Kim and Williams also define the injective maps Ψ 1 , Ψ 2 , and Φ i,k,n , whose images partition the set ParSeq(n, k) into disjoint parts and make it simpler to count recursively.
where, for all i ≥ 1, µ i is obtained from λ i by duplicating its first part.

Proposition 2. [KW22]
The set ParSeq(n, k) equals the disjoint union Kim and Williams used this to prove a recurrence for the size of ParSeq(n, k) in [KW22] Proposition 3.14.It also implies the following corollary: Corollary 3. Every partition sequence in ParSeq(n 0 , k 0 ) is a composition of maps in {Ψ 1 , Ψ 2 , Φ i,k,n } applied to an empty sequence in some ParSeq(n 1 , 0).Theorem 5. Every evil-avoiding permutation can be written uniquely as a composition of maps in the set {ψ p , ψ q , ψ r , ψ s } applied to the identity in S 0 .
Theorem 6.The maps ψ p , ψ q , ψ i,k,n may be written as and compare with P • f (1, π 1 + 1, . . ., π n−2 + 1).Let c = (c 1 , . . ., c n−1 ) be the Lehmer code of the inverse of f (π), and let a 1 . . ., a k be the positions of the descents in c.Then the ith partition in the partition sequence P • f (π) may be written as To get the Lehmer code of the inverse of f (1, π 1 + 1, . . ., π n−2 + 1) from c, we insert a 0 at the start of c because the first entry of the Lehmer code of the inverse of a permutation counts the number of values in the permutation before the 1.Thus, the ith partition in the partition sequence , c ai−1+1 , . . ., c ai ).
Comparing λ i with µ i , we see that the latter is the same as the former, except with an extra copy of n − 1 − a i , which is the largest part of λ i .(Observe that in the expression for λ i , the subtrahend clearly has leading zeroes when i ≥ 2, and when i = 1, we have c 1 = 0.) Note also that Ψ 1 acts on a partition sequence by mapping each partition to one with the first part duplicated, so Ψ . Now, we show that (We consider ψ i,k,n before ψ q to make the exposition clearer.)Using a similar technique as for ψ p , we compute P • f (π) and compare with P • f (π ikn ).As computed earlier in this proof, the jth partition in the partition sequence π may be written as with c defined as above.
To get the Lehmer code of the inverse of f (π ikn ), observe that ), so we have as our Lehmer code (0, i − 1, . . ., i − 1 Thus, the first partition in the partition sequence The jth partition, for j > 1, in the partition sequence Comparing λ j with µ j+1 , we observe that the latter is the same as the former, except with n − i leading copies of i − a j .Note that Φ i,k,n takes a partition sequence (λ 1 , λ 2 , . . ., λ k−1 ) to ((i − 1), µ 1 , µ 2 , . . ., µ k−1 )), where µ j is obtained from λ j by duplicating the first part of λ j n − i times, so the partition sequences match up as desired, and in fact Φ i,k,n Finally, we consider ψ q , and divide into cases based on whether π is (a, b)-sandwiched.Case 1: π is (a, b)-sandwiched.
We can compute i.e., all nonzero parts of λ 1 are equal.For i > 1, we can write Now observe that the Lehmer code for f (g(π)) −1 can be written as From this, we can calculate that the first partition in the partition sequence P • f (g(π)) is and the ith partition for i > 1 is Note that in the first subcase, when π is (a, b)-sandwiched, Ψ 2 takes (λ 1 , . . ., λ k ) to (µ 1 , . . ., µ k ), where µ 1 is λ 1 with the first part duplicated and then increased by 1, and for i > 1, µ i is λ i with the first part duplicated.This is precisely what we found, so Ψ 2 • P • f (π) = P • f (g(π)).It is a tedious though straightforward term-by-term arithmetic calculation to verify The proof is similar to the one for the previous case.As computed earlier, the ith partition in the partition sequence P • f (π) may be written as and, in particular, Then the Lehmer code of f (t + 1, π 1 + 1 π1>t , . . ., π n−2 + 1 πn−2>t ) −1 is (0, c 2 + 1, c 3 + 1, . . ., c t+1 + 1, 0, c t+2 , c t+3 , . . ., c n ) with a 1 = t + 1.We may then write and then comparing µ 1 with λ 1 part by part, we see that µ 1 is identical to λ 1 except with the first part incremented by 1.Since there is a 0 at index t + 2 in the Lehmer code for π, offsetting the Lehmer code for f (t + 1, π 1 + 1 π1>t , . . ., π n−2 + 1 πn−2>t ) −1 back by 1, we get for i > 1, So in the second subcase, when π is not (a, b)-sandwiched, Ψ 2 takes (λ 1 , . . ., λ k ) to (µ 1 , . . ., µ k ) where µ 1 is λ 1 with the first part increased by 1, and for i > 1, µ i is λ i with the first part duplicated.We find that Ψ 2 • P • f (π) = P • f (t + 1, π 1 + 1 π1>t , . . ., π n−2 + 1 πn−2>t ).So the forms for ψ p , ψ q , ψ i,k,n stated at the start of this proposition are equivalent to the forms provided in Section 3. Proposition 3. If k = 0, then Evil(n, k) contains only the identity permutation of length n.For k > 0, and the terms on the right-hand side are pairwise disjoint.
Proof.The first sentence of the proposition is true because every nonidentity permutation has at least 1 recoil.To see the second part, observe that from the proof of Proposition 3.14 in [KW22] we have a very similar result, namely where the terms on the right-hand side are disjoint.
After conjugating both sides by P • f , we get the desired result.
Proposition 4. The operators ψ p , ψ q , and ψ s preserve the number of recoils.The operator ψ r increases the number of recoils by one.
Proof.Observe that each value in ψ v (π) for any v ∈ {p, q, s} depends on at most one value in π, and no two values in ψ v (π) depend on the same value in π.Throughout the proof, we say that a recoil x at index i in π is mapped to a recoil y at index j in σ = ψ v (π) if the expression for σ j depends on π i and the evaluation y of σ j at x = π i is a recoil.To see that ψ p preserves the number of recoils, observe that a recoil π i in π is mapped to recoil π i + 1, and this map produces all recoils in ψ p (π). (The value 1 is first in ψ p (π) so cannot be a recoil.) To see that ψ q preserves the number of recoils, we casework on whether π is (a, b)-sandwiched.If not, observe that a recoil π i in π is mapped to recoil π i + 1 πi>t in ψ q (π) regardless of whether π i > t or π i < t or π i = t, and this map produces all recoils in ψ q (π).If π is (a, b)-sandwiched, then π always contains the recoil a + b, and ψ q (π) = (a + b + 1, 1, 2, . . ., a + 1, π a+1 + 1, π a+2 + 1, . . ., π n−b + 1, a + 2, a + 3 . . ., a + b) necessarily contains a + b as a recoil.Any other recoil in π takes the form π i for a + 1 ≤ π ≤ n − b and is mapped to π i + 1.Now, the values 1, 2, . . ., a + b − 1 fail to be recoils in π and the values 1, 2, . . ., a + b − 1, a + b + 1 fail to be recoils in ψ q (π), so we have accounted for all possible recoils in π and its image ψ q (π), and shown these recoils to be in bijection.
To see that ψ s preserves the number of recoils, observe that the smallest recoil in π is t, and that a recoil π i in π is mapped to π i + 1 in ψ s (π).This map produces all recoils in ψ s (π).(The recoils in ψ s (π) all appear before the 1.) To see that ψ r increases the number of recoils by one, observe that a recoil π i in π is mapped to recoil π i + 1 in ψ r (π), and this map produces all recoils in ψ r (π) except for the recoil 1.Now, making the observation that ψ i,k,n = ψ n−i−1 s •ψ r , we can describe the set of words in A e = {p, q, r, s} that the set of evil-avoiding permtuations is in bijection with.This set was stated in Lemma 2.
Corollary 4. The words of L Evil encode evil-avoiding permutations uniquely.
5.1.Other consequences.In a word of L Rect encoding a rectangular permutation, the number of recoils in the permutation equals the number of d's.The bijection converts d's to r's, which count the recoils in the associated evil-avoiding permutation.Since the bijection preserves the number of recoils, the following consequence is immediate.
Corollary 5.There is an explicit bijection between rectangular permutations and evil-avoiding permutations in S n with k recoils.[KW22] proved a number of enumerative results about evil-avoiding permutations.The bijection between evil-avoiding permutations and L Evil allows us to provide some simpler proofs.

Kim and Williams
Kim and Williams enumerated Evil(n, k) using a recurrence and induction, but the structure of L Evil lets us enumerate this directly, which we can also do for Rect(n, k).
Proof.Permutations in Evil(n, k) correspond to words in L Evil of size n with k r's.The r's split the word into k + 1 pieces, where the last piece is all s's.Let i be the total number of p's and q's in the word.These i p's and q's can be distributed into the first k pieces between the r's in i+k−1 k−1 ways.The remaining n − k − i positions must be s's, and at least one s must be in the last piece, so there are n − k − i − 1 spares.We can allocate these among k + 1 pieces in n−i−1 k ways.For each such allocation of the letters to the k + 1 pieces, the s s must come at the end of the pieces, so the remaining choice is which of the i p|q positions are p's and which are q's.There are 2 i ways to make this choice.Thus, for each i, there are 2 Proposition 3 gives the following recurrence for | Evil(n, k)| with k > 0 : There is a simpler recurrence, also mentioned in [KW22] in the proof of their Corollary 3.15.
Theorem 8.For k > 0 and n > 1, Proof.This follows algebraically from the previous recurrence, but it also admits a relatively short combinatorial proof.By Propositions 3 and 4, Evil(n, k) is the disjoint union of the images of ψ p , ψ q , and ψ s on the intersections of their domains with Evil(n − 1, k) together with the image of ψ r on Evil(n − 1, k − 1).
The operators ψ p and ψ q are defined on all of Evil(n−1, k), and contribute 2|Evil(n − 1, k)| permutations.The operator ψ r is defined on all of Evil(n − 1, k − 1) and contribute |Evil(n − 1, k − 1)| permutations.The operator ψ s is only defined on permutations that end with a copy of e t for some t ≥ 1.The intersection with Evil(n − 1, k) are those permutations that are not in This decomposition of Evil(n, k) combinatorially proves

Table of examples
We give examples of the bijection between rectangular and evil-avoiding permutations below.The language of this expression is all strings in {1, 2, d, u} with no 21 or u1 substring that do not end in 2 or u.This is almost the same as L Rect .We can make a bijection by adding a terminal 1.This proves the theorem.

Future directions
We discuss possible future directions, both algebraic and enumerative.
In the algebraic direction, the bijection between rectangular and evil-avoiding permutations may help us derive the inhomogeneous TASEP steady-state probabilities corresponding to rectangular permutations.Kim and Williams express these steady-state probabilities corresponding to evil-avoiding permutations as a "trivial factor" times a product of (double) Schubert polynomials (for a more precise statement, see Theorem 1.11 in [KW22]), so there is hope that the rectangular permutations may give rise to nice steady-state expressions.
Going in an enumerative direction, one could try to biject other pairs of objects counted by A006012, as suggested by Williams in personal communication [Wil22].Two sets of objects seem likely to shed light on evil-avoiding permutations, either because they are permutation classes or are clearly recursively constructed.The last was included in [KW22] as particularly interesting.
(1) paths of length 2n with n = 0 starting at the initial node on the path graph with 7 vertices, (2) permutations on [n] with no subsequence abcd such that (i) bc are adjacent in position and (ii) max(a, c) < min(b, d).From another enumerative perspective, we may want to consider which sets of permutations can be bijected using similar techniques as those used here.Permutations avoiding {4312, 4231}, {4312, 4213}, {4231, 4213}, {4213, 4132}, and {4213, 3214} are known to be equinumerous.When they are triply graded by size, recoils, and descents, these five sets of permutations still appear equinumerous.It would be interesting to construct a bijection between any pair of these five sets of permutations, and particularly so if the bijection preserves the number of recoils and/or descents.Evil-avoiding and rectangular permutations also seem to be equinumerous when triply graded by size, recoils, and descents.
Here, we used regular languages to biject two particular families of permutations.This technique may be more widely applicable to other permutation families, but there is a limitation that the generating functions of regular languages must be rational (the sequences satisfy linear recurrence relations).Many families of pattern-avoiding permutations are known not to have rational generating functions, e.g., permutations avoiding any one pattern of size three are counted by Catalan numbers, and the generating function for Catalan numbers is algebraic but not rational.However, some pattern-avoiding permutation families have rational generating functions.For these permutation families, it would be interesting to check if there are natural bijections with regular languages.If so, then the techniques of this paper might be used to establish many other nontrivial Wilf-equivalences.

Acknowledgments
The author thanks Joseph Gallian and the University of Minnesota Duluth REU during which this research was conducted, Amanda Burcroff, Andrew Kwon, and Mitchell Lee for valuable feedback on the paper, and all participants and advisors for helpful discussions.This work was done with support from Jane Street Capital, the NSA (grant number H98230-22-1-0015), the NSF (grant number DMS-2052036), and Harvard University.

Table 1 :
The bijection for all rectangular permutations in S 1 , S 2 , S 3 , S 4 and three randomly selected permutations in S 5 .Rect.perm.Word in L Rect Word in L Evil Evil-av.perm.