Pattern avoidance for set partitions \`a la Klazar

In 2000 Klazar introduced a new notion of pattern avoidance in the context of set partitions of $[n]=\{1,\ldots, n\}$. The purpose of the present paper is to undertake a study of the concept of Wilf-equivalence based on Klazar's notion. We determine all Wilf-equivalences for partitions with exactly two blocks, one of which is a singleton block, and we conjecture that, for $n\geq 4$, these are all the Wilf-equivalences except for those arising from complementation. If $\tau$ is a partition of $[k]$ and $\Pi_n(\tau)$ denotes the set of all partitions of $[n]$ that avoid $\tau$, we establish inequalities between $|\Pi_n(\tau_1)|$ and $|\Pi_n(\tau_2)|$ for several choices of $\tau_1$ and $\tau_2$, and we prove that if $\tau_2$ is the partition of $[k]$ with only one block, then $|\Pi_n(\tau_1)|<|\Pi_n(\tau_2)|$ for all $n>k$ and all partitions $\tau_1$ of $[k]$ with exactly two blocks. We conjecture that this result holds for all partitions $\tau_1$ of $[k]$. Finally, we enumerate $\Pi_n(\tau)$ for all partitions $\tau$ of $[4]$.


Introduction
A set partition of a set S is a collection of disjoint nonempty subsets B 1 , . . . , B m of S whose union is S. We call the subsets B i blocks, and we write σ = B 1 / · · · /B m ⊢ S.
If S is a set of positive integers and σ ⊢ S, then the standardization of σ is the set partition of {1, 2, . . . , |S|} obtained by replacing the smallest element of S by 1, the second smallest element of S by 2, and so on.
If n is a positive integer we let [n] = {1, 2, . . . , n} and define The concept of pattern avoidance for set partitions was introduced by Klazar in Klazar (2000). If k ≤ n and we have σ ⊢ [n] and τ ⊢ [k], then we say σ contains τ as a pattern if there is a subset S of [n] such that the standardization of the restriction of σ to S is τ . If σ does not contain τ , we say that σ avoids τ . We let Π n (τ ) = {σ ∈ Π n : σ avoids τ }. The present paper is a contribution to the study of Klazar's definition of pattern avoidance, but we should mention right away that there are other definitions. One of these arises from the well-known correspondence between set partitions and restricted growth functions. Recall that a restricted growth function (RGF) is a word a 1 a 2 · · · a ℓ of positive integers such that a 1 = 1 and, for i ≥ 2, we have a i ≤ 1 + max{a 1 , . . . , a i−1 }. The integer ℓ is called the length of the RGF. If σ ∈ Π n , we define a corresponding RGF of length n, denoted by RGF(σ), as follows. First write σ = B 1 /B 2 / · · · /B m , where min B 1 < min B 2 < · · · < min B m .
(This is called the standard form of σ.) Then let RGF(σ) = a 1 · · · a n , where i ∈ B ai . We can obtain an alternative notion of pattern avoidance for set partitions by using a natural notion of avoidance for RGF's. If k ≤ n and a = a 1 · · · a n and b = b 1 · · · b k are RGFs, we say that a contains b if a has a subsequence whose standardization is b, otherwise we say that a avoids b. This notion of RGF avoidance has been studied extensively (see Mansour's comprehensive book Mansour (2013)). It does not coincide with Klazar's notion. For if σ avoids τ in Klazar's sense, then RGF (σ) avoids RGF (τ ); but the converse may fail. For example 145/23 contains 12/34, yet RGF(145/23) = 12211 avoids RGF(12/34) = 1122.
There is yet a third notion of pattern avoidance for set partitions that involves arc-diagrams (See Bloom and Elizalde (2013); Chen et al. (2007); Riordan (1975); Touchard (1952)). A well studied notion in this context is that of non-nesting and non-crossing set partitions which arise from the avoidance of certain arc-configurations. We wish to point out that under Klazar's definition non-crossing set partitions are those that omit 13/24. Interestingly, there is no single pattern σ such that the non-nesting partitions are precisely those that omit σ, in Klazar's sense. To see this, observe that the only candidate for σ is 14/23 since the non-nesting set partitions of length 4 are Π 4 \ {14/23}. Yet, the set partition 135/24 is non-nesting but contains 14/23.
If β k denotes the partition of [k] that has only one block, then computer evidence suggests that, for every k ≥ 4 and every τ = β k in Π k we have τ ≺ β k , and in fact |Π n (τ )| < |Π n (β k )| for all n > k. In Section 3 of our paper we prove this result for all τ with exactly two blocks, and we conjecture (Conjecture 3.1) that the result holds for all τ = β k . We also consider partitions π such that there is exactly one doubleton block and all other blocks are singletons. We prove that for every such π, if σ k denotes the partition all of whose blocks are singletons, then for all n > k. This result should be compared with Klazar's result in Klazar (2000) that for all such π and σ k the generating function of |Π n (π)| is rational (whereas the generating function for |Π n (β k )| is not).
with equality if a < k − 1, and therefore β k,a ∼ β k,b when 2 ≤ a, b ≤ k − 1. Finally, we have This theorem together with computational evidence for all patterns of length ≤ 9 suggests the following conjecture.
The first assertion of Theorem 2.1 is a simple consequence of complementation. To prove the second assertion, we construct an injection for each 2 ≤ a ≤ k − 1, and show that φ a is a bijection if a < k − 1. Before we can write down this mapping we need a few lemmas and observations. We start with these immediately and delay the proof of Theorem 2.1 to the end of this section.
To begin, fix k and 2 ≤ a ≤ k − 1. Observe that π ⊢ [n] contains β k,a if and only if π contains a block B such that a − 1 ≤ |{x ∈ B : x < c}| and k − a ≤ |{x ∈ B : x > c}| (2.1) for some c / ∈ B. Consequently, we say a finite set B of integers contains β k,a if it satisfies (2.1), otherwise we say B avoids β k,a . Consequently, a set partition π avoids β k,a if and only if all of its blocks avoid β k,a . Now, consider the anatomy of a block B that avoids β k,a+1 but contains β k,a . Since B contains β k,a , there exists some c / ∈ B so that a − 1 ≤ |{x ∈ B : x < c}| and k − a ≤ |{x ∈ B : x > c}|.
Furthermore, since B avoids β k,a+1 , the set on the left must have size exactly a − 1. For the same reason, the set on the right must be of the form for some ℓ ≥ 1. Therefore the block B looks like where the elements in the shaded block are consecutive in value and the rightmost block's smallest element is y 1 . By decrementing the values in the shaded region, we effectively slide the gray rectangle as far left as possible, obtaining the new block B ′ : Remark 2.1. We remark that in B ′ , the elements in the gray block are consecutive in value and the largest element in the leftmost block is one less than the smallest element in the gray block. Consequently, B ′ avoids β k,a while containing β k,a+1 .
The new block B ′ gives rise to a new set partition as summarized in our next definition.
Definition. Let π ⊢ [n] and assume the ith block B of π avoids β k,a+1 and contains β k,a . So B is as depicted in (2.2). Now let B ′ be the block depicted in (2.3). We define slide i (π) ⊢ [n] to be the set partition π ′ = B ′ /σ where σ is the set partition of [n] \ B ′ that is order-isomorphic to the set partition obtained by deleting B from π.
We illustrate this definition with the following short example.
Lemma 2.1. If π, B, and B ′ are as in the above definition and B is the ith block (in standard form) of π, then B ′ is the ith block in slide i (π).
Proof: First observe that as a ≥ 2, then min(B) = min(B ′ ). Now set It follows from our construction of B ′ that so B ′ is no earlier than the ith block in slide i (π) and so B ′ is no later than the ith block in slide i (π).
As the definition of our mapping φ a involves repeated "slide" operations, we require a lemma guaranteeing that blocks not involved in the slide operation do not change "too much". Our next lemma spells out exactly what is meant by this.
. Assume that for some fixed i, the block B i avoids β k,a+1 and contains β k,a and set slide i (π) = B ′ 1 /B ′ 2 / · · · /B ′ m . Then for any 1 ≤ c ≤ k and j = i, the block B ′ j avoids β k,c if and only if B j avoids β k,c .
First, we claim that w t + 1 = w t+1 if and only if w ′ t + 1 = w ′ t+1 . For the moment, let us assume this claim. Next we make the following general observation: Any block B j avoids β k,c if and only if whenever x ∈ B j is such that c − 1 ≤ |{y ∈ B j : y ≤ x}| and k − c ≤ |{y ∈ B j : y ≥ x}|, Assuming w t and w t+1 are consecutive in value it follows that they both lie in either the set (2.4), the set (2.5), or in the interval I. In the first two cases, it easily follows from our above equalities that w ′ t + 1 = w ′ t+1 . In the third case, the set equality in (2.4) along with the fact that |I| = |J| implies that w ′ t , w ′ t+1 ∈ J. Since J is an interval, we conclude that w ′ t , w ′ t+1 are consecutive in value. The proof that if w ′ t and w ′ t+1 are consecutive in value, then w t and w t+1 are too, is analogous. Its details are omitted.
Finally, we are in a position to define φ a . For any π ∈ Π n (β k,a+1 ) first set π 0 = π and let m be the number of blocks in π. Having defined π i we obtain π i+1 by considering the (i + 1)st block of π i . If this block contains β k,a , then set π i+1 = slide i+1 (π i ), otherwise we set π i+1 = π i . Lastly we set φ a (π) = π m .
We pause to point out that our mapping φ a is well defined. First, we note that Lemma 2.2 guarantees that the (i + 1)st block in π i avoids β k,a+1 . (This is crucial since if this block contained β k,a+1 and also contained β k,a our sliding operation would not be defined.) Additionally, Lemma 2.2 together with Remark 2.1 guarantees that φ a (π) avoid β k,a .
Before proving that φ a is a bijection we demonstrate this mapping.
The above algorithm for φ 3 yields the following steps, where the elements affected by each slide are highlighted.

Proof Proof of Theorem 2.1:
As each slide in the definition of φ a is certainly reversible, it follows that the mapping If a < k − 1, then k − a ≥ 2, so the composition of injective maps and proves that φ a is bijective. This completes the proof of the second assertion of Theorem 2.1.
To prove the third assertion, we show that the injection φ k−1 : Π n (β k,k ) → Π n (β k,k−1 ) is not surjective when n ≥ 2k − 2. To see this, it will be helpful to observe that if π ∈ Π n (β k,k ) then at most one block of π has k − 1 or more elements. For if one block has elements x 1 < · · · < x k−1 and another block has elements y 1 < · · · < y k−1 , then either x k−1 < y k−1 or y k−1 < x k−1 , so π contains the partition β k,k , a contradiction. It now follows from the definition of φ k−1 that for every π ∈ Π n (β k,k ) there is at most one block of size greater than or equal to k − 1 in φ k−1 (π). But if n ≥ 2k − 2 then the element 1, 2, . . . , k − 1/k, . . . , 2k − 2/(2k − 1), . . . , n of Π n (β k,k−1 ) has at least two blocks of size k − 1.
3 Partial Ordering by ≺

The pattern β k
We recall that β k denotes the element of Π k that has only one block. If τ is any element of Π k other than β k itself, computer evidence suggests that τ ≺ β k and |Π n (τ )| < |Π n (β k )| for all n > k.
It follows from Theorems 3.1, 3.2, and 3.3 that Conjecture 3.1 is true for k = 4.
Proof: Suppose σ ∈ Π k and σ has exactly two blocks, so σ = A/B, with 1 ∈ A. Suppose a 1 , b 1 , a 2 , b 2 , . . . , a j , b j are positive integers and a j+1 is a nonnegative integer such that the first a 1 elements of To prove the theorem we establish, for any given n > k, a nonsurjective injection To define ϕ, take any π ∈ Π n − Π n (β k ). If π ∈ Π n − Π n (σ), let ϕ(π) = π. Now suppose π ∈ Π n (σ). Since π ∈ Π n − Π n (β k ), π has at least one block with at least k elements. We obtain ϕ(π) from π by partitioning each such block C in the following way.
Recalling that σ = A/B, let |B| = m, so that m = b 1 + · · · + b j . Write where q ≥ 1 and 0 ≤ r < m are integers. Then we have We order the elements of C from smallest to largest and define a subset A * of C of cardinality |A| + r, as follows. Let the first a 1 elements of A * be the first a 1 elements of C. Skip over the next qb 1 elements of C, and let the next a 2 elements of C be the next a 2 elements of A * . Then skip over the next qb 2 elements of C and let the next a 3 elements of C be the next a 3 elements of A * . Continuing in this way, define the first a 1 +· · ·+a j+1 = |A| elements of A * . Then add the last r elements of C to A * , so that |A * | = |A|+r.
Next we define subsets B 1 , . . . , B q of C such that |B i | = m for 1 ≤ i ≤ q. Take the first qb 1 elements of C that were skipped over in the construction of A * , and put the first b 1 of these elements in B 1 , the next b 1 of these elements in B 2 , and so on. Then take the next qb 2 elements of C that were skipped over in the construction of A * and put the first b 2 of these elements in B 1 , the next b 2 of these elements in B 2 , and so on. Continuing in this way, complete the construction of B 1 , . . . , B q .
We partition C into blocks A * , B 1 , . . . , B q . By construction, we see that for each B i , the partition A * /B i contains the partition σ. We have |B i | = m < k and |A * | = |A| + r < |A| + m = k.
To show this, observe that each block of ϕ(π) is a subset of a block of π, and that if D, E are blocks of ϕ(π) such that the partition D/E contains σ, then since π ∈ Π n (σ), D and E must be subsets of the same block of π. Thus we obtain π from ϕ(π) by coalescing into one block the elements of any blocks D, E of ϕ(π) such that D/E contains σ.
Finally, to show that ϕ is not surjective, first suppose that m + 1 < k and consider the partition γ of [n] whose blocks are A, B ∪ {k + 1} and n − k − 1 singleton blocks. Then γ ∈ Π n − Π n (σ). Suppose π ∈ Π n − Π n (β k ) and ϕ(π) = γ. Since m + 1 < k, we have γ ∈ Π n (β k ), so γ = π and thus π ∈ Π n (σ). Since ϕ(π) = γ, it follows from the definition of ϕ that A ∪ B ∪ {k + 1} is contained in some block F of π, and |F | > k. In defining ϕ(π), the block A * derived from F contains the smallest element of F , namely 1, so A * = A (since A is the block of γ that contains 1). The other blocks derived from F have m elements each. This is impossible, since the block B ∪ {k + 1} is derived from F . Now consider the case m + 1 = k. In this case σ = β k,1 . Since β k,1 ∼ β k,k by Theorem 2.1 and ϕ is not surjective when σ = β k,k by the preceding paragraph, it follows that ϕ is not surjective when σ = β k,1 .

The pattern σ k
We recall that σ k = 1/2/3/ · · · /k. In this subsection we prove that for all δ ∈ Π k , whose blocks consist of all singletons except for one doubleton block, We begin with a lemma.
for all n > k, where α ′ is obtained by incrementing all the values in α by 1.
Proof: Proving the inequality on the left is sufficient, since the inequality on the right then follows by complementation.
The existence of this injection proves our claim.
To prove our next theorem, we first recall the bijection between restricted growth functions and set partitions as described in the Introduction. Next, define RGF <k n to be the set of all w ∈ RGF in the letters {1, . . . , k − 1} with length n. It immediately follows that the standard bijection between RGF and set partitions restricts to a bijection between RGF <k n and Π n (σ k ). Theorem 3.2. Let δ be a pattern of length k ≥ 4 that consists of all singletons except for exactly one doubleton. Then Proof: If a and b are the elements of the doubleton block of δ, we consider cases depending on the value of |a − b|.
To deal with the case |a−b| ≥ 3, it suffices, by Lemma 3.1, to prove the result for δ = 1k/2/3/ · · · /k− 1. For such a δ, we see that every set partition in Π n (δ) is obtained from a unique set partition B 1 / · · · /B m ∈ Π n−1 (δ) by inserting n into one of the k − 2 rightmost blocks B m−(k−3) , . . . , B m or by inserting n into a new singleton block. We encode these insertion choices as follows: Now define the set R <k n to be the set of all words w in the letters 1, 2, . . . , k − 1 such that w 1 = 1 and w s ≤ 1 + # of 1's in the subword w 1 · · · w s−1 .
Using the above encoding, it is clear that we have an injective mapping from Π n (δ) into the set R <k n . This mapping is not surjective for n > k ≥ 4 since then the set partition 1(k − 1)/2(k + 1)/3/ · · · /k − 2/k/k + 2/ · · · /n / ∈ Π n (δ) is mapped, under the above encoding, to the word It now suffices to prove that | RGF <k n | = |R <k n | since | RGF <k n | = |Π n (σ k )| as mentioned above. To see this consider a word w ∈ RGF <k n and decompose it according to the first occurrence, from left to right, of each letter. Doing so w decomposes into the subwords As w ∈ RGF <k n we know that m ≤ k − 1. In the case that m < k − 1 we define w ′ to be the new word given by incrementing each of the subwords u i by 1 and replacing each letter's first occurrence by a 1. So w ′ decomposes, according to its occurrences of 1's, as It easily follows that w ′ ∈ R <k n since the letters in u i + 1 are at most i + 1 and are preceded by exactly i occurrences of the letter 1.
In the case that m = k − 1, we modify this mapping only slightly. Here we define w ′ to be the word so that all subwords, except the last one, u k−1 , are incremented by 1. Note this second case is needed since the letter k − 1 might occur in u k−1 and the letter k is not available. Again it is clear that w ′ ∈ R <k n . In this way we obtain an injective mapping from RGF <k n to R <k n . Furthermore, this mapping is easily seen to be surjective as we can decompose any word v in R <k n according to its first k − 1 ones and then reverse the above mapping. It only remains to prove that applying the reverse mapping to any v ∈ R <k n results in a word w ∈ RGF <k n . This easily follows from the observation that if v s is a letter in v with j ones to its left, then v s ≤ j + 1 = max(w 1 , . . . , w s−1 ) + 1.
First assume j < k − 1. In this case, if v s = 1, then w s = v s − 1 and if v s = 1, then w s = j + 1. Either way, such letters satisfy the condition of a restricted growth function. The case when j ≥ k − 1 is similar. Its details are left to the reader.

Theorem 3.3.
For all k ≥ 2 and n ≥ 1 Moreover, this inequality is strict provided n > k > 2.
Proof: First, we show, by induction on k, that there exists a family of injections for all k ≥ 2 and n ≥ 1. To streamline this notation we drop the subscript n and write ψ k instead of ψ k,n . To begin our induction argument note that |Π n (σ 2 )| = 1 = |Π n (β 2 )|. Now, consider π = B 1 / · · · /B m ∈ Π n (σ k+1 ) and observe that B 2 / · · · /B m can be considered a set partition of [n − |B 1 |] that avoids σ k . Therefore ψ k (B 2 / · · · /B m ) is well defined, avoids β k , and has blocks of size < k. (If B 2 / · · · /B m = ∅ we set ψ k (∅) = ∅.) With this in mind, the division algorithm yields where 0 ≤ r ≤ k − 1. Provided r > 0 let C 0 /C 1 /C 2 / · · · /C q be the set partition of B 1 where C 0 consists of the first r numbers of B 1 and C 1 consists of the next k numbers, etc. Note that in the case r = 0 we simply ignore C 0 . Finally, we define ψ k+1 (π) = C 0 /C 1 / · · · /C q /ψ k (B 2 / · · · /B m ), so that C 1 , . . . , C q are the only blocks of size k in this partition. Note that if r > 0, then 1 ∈ C 0 , otherwise 1 ∈ C 1 . Consequently, ψ k+1 is injective since ψ k is injective and B 1 may be recovered by taking the union of all blocks of size k in ψ k+1 (π) along with the block containing 1.
It only remains to show that our mappings ψ n,k are not surjective when n > k > 2. To see this observe that in the construction of ψ n,k (π) the first block of π (in standard form) is partitioned into consecutive segments as described above. As a result, no partition in the image of ψ n,k could contain the blocks: 1 3/2 4 5 · · · (k + 1), because both blocks would have to come from B 1 , but this violates consecutiveness. Hence these mappings cannot be surjective.

Corollary 3.1. Let δ be any pattern of length k consisting of all singletons except for one doubleton. Then,
for all n > k ≥ 4.
The proof of this corollary is a direct consequence of the previous two theorems.

Enumeration
In this section we concentrate on the enumeration of |Π n (τ )| for patterns τ ⊢ [4]. As enumerations for the patterns 1/2/3/ · · · /k and β k = 12 · · · k are well known using exponential generating functions and Sagan in Sagan (2010) enumerated the general pattern 12/3/4/ · · · /k, we concentrate on all others with one exception. As the enumeration for the pattern 1/23/4 devolves into numerous (uninteresting) cases and Klazar in Klazar (2000) showed that the resulting generating function is rational, we choose to omit this pattern from our discussion.
To summarize the enumerations established in the following subsections (as well as those mentioned above) we include the following table of results where exp m = m i=0 x i i! and S(n, k) denotes the Stirling numbers of the second kind and . Aside from the omitted pattern 1/23/4, every pattern of length 4 is, up to complementation, included in the table.

The pattern 14/2/3
Let us begin by recalling the standard recursive construction for building set partitions. That is, every set partition in Π n is obtained by taking a set partition in Π n−1 and either adding n to an existing block or appending n as a singleton. To enumerate Π n (14/2/3) we consider a refinement of this recursive construction. First, observe that if π ∈ Π n (14/2/3), where in standard form π = B 1 / · · · /B m , we have either n ∈ B m−1 or n ∈ B m , as any other choice would force an occurrence of the pattern 14/2/3. From this observation we may immediately restrict our attention to set partitions which are built by recursively placing the next largest element into either a singleton block, the last block, or the second to last block.
To formalize this refinement let us define W n to be the subset of all words in the letters a, b, c, that start with an a and have the property that any occurrence of the letter c must be preceded by at least two a's. Using this we obtain an injection ϕ : W n → Π n which is defined recursively as follows. First, set ϕ(a) = 1. Then, for any w ∈ W n , define ϕ(w) to be the set partition obtained from π ′ = ϕ(w 1 · · · w n−1 ) by appending n as a singleton if w n = a, inserting n into the (existing) rightmost block of π ′ if w n = b, or inserting n into the second to last block of π ′ if w n = c. Note that our insistence that words in W n have the property that any c is preceded by at least two a's guarantees that if w n = c, then π ′ contains at least two blocks. It is clear for our definition that ϕ is injective. Additionally, it follows from our first observation in this subsection that Π n (14/2/3) ⊆ ϕ(W n ).
Before continuing we next provide an example of this construction in Example 4.1. An immediate consequence of Example 4.1, is that Π n (14/2/3) ϕ(W n ). Consequently, we seek a subset of W n whose image under ϕ is precisely Π n (14/2/3). To this end consider the subset W * n consisting of all w ∈ W n with the property that the letters between any two c's do not contain exactly one a. Observe that in Example 4.1 w ∈ W * n but v is not. Lemma 4.1. The restricted mapping ϕ : W * n → Π n (14/2/3) is a bijection.

Proof:
We first show that Π n (14/2/3) ⊆ ϕ(W * n ). To this end consider w ∈ W n \ W * n and let i < j < k be such that w i = w k = c and w j = a is the only occurrence of the letter a between these two c's. Next, set ϕ(w) = B 1 / · · · /B m so that i ∈ B t , for some t. As w i = c that means that ℓ := min(B t+1 ) < i. As there is no a between w i and w j we see that j ∈ B t+2 . Moreover, as there is no a between w j and w k we see that k ∈ B t+1 . This provides our desired contradiction since the integers ℓ < i < j < k in the blocks B t , B t+1 , and B t+2 create an occurrence of the forbidden pattern 14/2/3.
By definition of the map ϕ, we see that min(B i ) > max(B j ) for all j + 1 < i. From this it follows that any occurrence of 14/2/3 in ϕ(w) must occur among three consecutive blocks B t , B t+1 , B t+2 and involve integers ℓ < i < j < k such that ℓ, k ∈ B t+1 , i ∈ B t , and j ∈ B t+2 . This immediately implies that w i = w k = c and that w j = a is the only a between these two c's. This contradiction permits us to conclude that ϕ(W * n ) = Π n (14/2/3) as claimed.
Theorem 4.2. We have Proof: By our previous lemma it suffices to find n≥1 |W * n |z n . To this end we consider three cases depending on how many c's our word contains.
The words in W * n with no c's are easily counted by the expression z 1−2z . On the other hand, the words with exactly one c's are counted by where the second term follows since any occurrence of a c must be preceeded by at least two a's. Lastly, we consider words containing at least two c's. It is clear from the definitions that such words decompose as a b ′ s and a ′ s at least one a c · · · c · · · c · · · c b ′ s and a ′ s , so that between any two consecutive c's we do not have exactly one a. Counting the words between any two consecutive c's we have since such words are in the letters a and b but cannot have exactly one a. In terms of G(z) we see that counts the case where our words have at least two c's. Summing these three cases yields the desired result.

The pattern 1/24/3
The enumeration of the pattern 1/24/3 closely resembles that of the enumeration of 14/2/3 found in the previous section. As a result, we begin similarly by observing that if π = B 1 / · · · /B m ∈ Π n (1/24/3) then we can only have n ∈ B 1 or n ∈ B m , as any other choice creates our forbidden pattern. Recalling the set W n defined in the previous subsection, we define (recursively) the function φ : W n → Π n .
First set φ(a) = 1. Next, for any w ∈ W n , define φ(w) to be the set partition obtained from φ(w 1 · · · w n−1 ) = B 1 / · · · /B m by inserting n into a singleton block if w n = a, inserting n into the block B m if w n = b, and lastly, inserting n into the block B 1 provided w n = c. It now follows, since the words in W n have the property that any c must be preceded by at least two a's, that φ is injective. It also follows, from our initial observation, that Π n (1/24/3) ⊆ φ(W n ). Note that φ(v) / ∈ Π 5 (1/24/3).
We see from this example that Π n (1/24/3) φ(W n ). As in the previous section, we seek a subset of W n whose image under φ is precisely Π n (1/24/3). To this end, define W * * n to be the set of all w ∈ W n such that 1) no a falls between any two c's in w, and 2) any c in w which is preceded by at least three a's cannot be immediately followed by a b.
In the next lemma we prove that W * * n is this desired set. To facilitate the reading of its proof we pause to highlight a couple key observations. Setting w ∈ W n with φ(w) = B 1 / · · · /B m , we first see that max(B s ) < min(B s+1 ) for all s > 1. Our second observation is that w i = a is the tth a in our word (from left to right) if and only if min(B t ) = i. With these observations in mind we now state and prove our lemma.
Proof: We first show that Π n (1/24/3) ⊆ φ(W * * n ). To do so, it suffices to show that if w ∈ W n \ W * * n , then φ(w) / ∈ Π n (1/24/3). Begin by setting φ(w) = B 1 / · · · /B m . We address the two ways in which w can fail to be a member of W * * n separately. First, assume condition 1) fails, and let i < j < k be such that w i = w k = c and w j = a. In particular, i, k ∈ B 1 . Moreover, as any c must be preceded by at least two a's, then it follows that min(B 2 ) < i < k. It also follows that if w j is the tth a in w, then t ≥ 3. Consequently, the blocks B 1 , B 2 , and B t contain an occurrence of 1/24/3.
Next, let us assume condition 2) fails. Here we assume that there exists some index i so that w i w i+1 = cb and w i is preceded by at least three a's. It immediately follows that φ(w 1 · · · w i−1 ) has t ≥ 3 blocks and that in φ(w), i ∈ B 1 , i + 1 ∈ B t and min(B 2 ) < min(B t ) < i < i + 1. Consequently, the blocks B 1 , B 2 , and B t , contain an occurrence of our forbidden pattern. We conclude that Π n (1/24/3) ⊆ φ(W * * n ).
Next, we demonstrate the other inclusion. Fix w ∈ W * * n and, for a contradiction, assume that φ(w) / ∈ Π n (1/24/3). Set φ(w) = B 1 / · · · /B m . As φ(w) contains an occurrence of 1/24/3 we must have m ≥ 3. As max(B s ) < min(B s+1 ) for all s > 1 we see that any occurrence of 1/24/3 in φ(w) must involve B 1 and two other blocks B r and B s with r < s. If the integers that form this pattern are i < j < k < ℓ then we have exactly two cases.
Case 1: j, ℓ ∈ B 1 , i ∈ B r , and k ∈ B s In this case, we see that as i ∈ B r , then w j = w ℓ = c. As the letters between w j and w ℓ cannot contain an a we conclude that w k = b. It now follows that w j · · · w ℓ must contains a cb. Additionally, the facts that the letters between w j and w ℓ do not contain an a, and that j < k < ℓ, and that w min(Bs) = a, imply that min(B s ) < j. Furthermore, as min(B r ) ≤ i < j we see that w 1 = w min(Br ) = w min(Bs) = a, and 1 < min(B r ) < min(B s ) < j. This contradicts the fact that w satisfies condition 2) in the definition of W * * n .
Case 2: i ∈ B r , j, ℓ ∈ B s and k ∈ B 1 From the definition of φ, we clearly have Moreover, as i ∈ B r and i < k, then w k = c. Further as ℓ = min(B s ), then w ℓ = b. Lastly, it is clear that the subword w k+1 · · · w ℓ−1 cannot contain the letter a. (If it did, then ℓ could not be in B s .) This means w contains a cb preceded by at least three a. Again this contradicts the fact that w satisfies condition 2) in the definition of W * * n . This completes our proof.
Theorem 4.4. We have Proof: By our previous lemma it suffices to enumerate W * * n . To do so we consider three cases depending on the number of c's. Clearly, the words in W * * n with no c's are counted by the expression z 1−2z . Next consider words that contain at least one c and have the additional property that the first c appears after the second a but before the third a (if it exists). Such words must be of the form ab · · · ba b ′ s and c ′ s at least 1 c or ab · · · ba b ′ s and c ′ s at least 1 c a a ′ s and b ′ s .
These two forms are counted by Lastly, we consider the case that our first c is preceded by at least three a's. In this case such words must be of the form ab · · · bab · · · ba a ′ s and b ′ s c · · · c or ab · · · bab · · · ba a ′ s and b ′ s c · · · c a a ′ s and b ′ s .
Together such words are counted by the expression Adding these three terms together and simplifying yields the desired expression.
With the recursive structure of 1/24/3-avoiding set partitions established, we now conclude the proof the case |a − b| = 2 in the proof of Theorem 3.2, by establishing the following lemma. Proof: Let A n be the set of all partitions of [n] with exactly 2 blocks and let A * n be the set of all partitions with exactly 3 blocks in which n is a singleton. (Note A * n is a subset of both Π n (1/24/3) and Π n (1/2/3/4).) Now let C n be the set of all partitions in Π n (1/24/3) with the property that removing n gives a partition with at least 3 blocks. Similarly, let D n be the set of all partitions in Π n (1/2/3/4) with the property that removing n results in a set partition with exactly 3 blocks. By our above note and the fact that the patterns involved have at least 3 blocks, it follows that It now suffices to show that |C n | < |D n | for n ≥ 5. We proceed by induction on n. As |Π 5 (1/24/3)| = 39 and |Π 5 (1/2/3/4)| = 41, we must have |C 5 | < |D 5 |. From the description of 1/24/3-avoiding permutations given in the first paragraph of this section, it follows that |C n+1 | ≤ 3|C n |. Additionally, it is clear that |D n+1 | = 3|D n |. Together we get where the second inequality follows by our inductive hypothesis. (Note the first inequality may not be an equality as in Example 4.3.)

The pattern 12/34
Theorem 4.5. We have Before proving this result it will be helpful to state and prove a couple of lemmas.
Lemma 4.4. Any set partition which avoids 12/34 has at most one block of size greater than 2.
Proof: For a contradiction assume π ∈ Π n (12/34) contains two blocks B = {x 1 , . . . , x a } and C = {y 1 , . . . , y b } where a, b ≥ 3. Without loss of generality we may further assume that x 2 < y 2 . On the other hand, this implies that the blocks B and C must contain an occurrence of 12/34 which is impossible.
The proof of the next lemma is straightforward. The details are left to the reader.
Remark 4.1. It immediately follows from the previous lemma that if x 1 < · · · < x k are the minimum entries among all the blocks of size 2 and y 1 , . . . , y k are the maximum entries among all the blocks of size 2 then we must have x i < min(y 1 , . . . , y k ), Proof Proof of Theorem 4.5: To start, let us first count those set partitions in Π n (12/34) whose block sizes do not exceed 2. To count such set partitions with exactly k blocks of size 2, we first choose a subset x 1 < · · · < x k < y 1 < · · · y k of size 2k from [n]. (The n − 2k integers not chosen become singletons.) We then may choose to match up each of the x i 's with exactly one of the y i 's in any of the k! ways. It follows from the above remark that all set partitions in Π n (12/34) whose block sizes do not exceed 2 are of this form. A simple argument further shows that any set partition built in this manner must also avoid 12/34. Consequently, the number of such set partitions is given by Now let us consider the set partitions in Π n (12/34) that contain k blocks of size 2 and exactly one block of size ℓ ≥ 3. To build such a partition, we first choose a subset of size 2k + ℓ from [n]. Let us denote the members of this subset by x 1 < · · · < x k+1 < z 1 < · · · < z ℓ−2 < y 1 < · · · < y k+1 .
(Again, the n − 2k − ℓ integers not chosen become singletons in our final set partition.) Next, choose exactly one element from the x i 's and one element from the y i 's along with all the z i 's to form our block of size ℓ. Next, as in the preceding case we are free to match each of the remaining x i 's to each of the remaining y i 's in all k! possible ways to form our k blocks of size 2. Lemma 4.5 guarantees that any such set partition is built in this manner. Furthermore, it is straightforward to show that any set partition built in this manner avoids 12/34. Consequently, the number of such set partitions is given by Adding these two terms gives our final result.

The pattern 14/23
To begin, let us concentrate on the subset Π * n (14/23) consisting of all set partitions in Π n (14/23) that do not contain singletons. We first show that the set partitions in this subset can be constructed via a simple recursive procedure. To do this we first need the following definition.
Definition. For any π ∈ Π * n (14/23) we say k is a cap provided each i ≥ k is the maximum element in its block. Let ι(π) be the number of caps in π.
Next, we define the sets Π * n as follows. First, set Π * 2 = {{1, 2}}. For n ≥ 3, define Π * n to be the set of all partitions obtained by either of the following two operations.

n-insertion
For any π ∈ Π * n−1 insert n into the block containing n − 1.

n-augmentation
For σ ∈ Π * n−2 where n ≥ 4 doing the following. Fix k to be either one of the ι(π) caps in σ or set k = n− 1. Then, increment all the values in σ which are ≥ k. Finally, append the doubleton block {k, n}.
But either choice results in an occurrence of the forbidden pattern 14/23. Hence n ∈ B as claimed. The other possibility is for B = {k, n + 1}. As π avoids 14/23 it follows that every i strictly between k and n + 1 must be a cap. Consequently, π was constructed from some set partition in Π * n (14/23) = Π * n via n + 1-augmentation.
With this lemma established, we are now ready to enumerate this pattern.

The pattern 134/2
To enumerate this pattern we require the well studied notion of weak integer compositions. In particular, we denote by C n,k the set of all weak integer compositions of n with k parts. Additionally we denote by M k,f the set of all set partitions of [2k + f ] with f singletons and k doubletons. (Observe these are just matchings with f fixed points.) Lastly, we define the refined set Π n,k,f (134/2) to be the set of all set partitions in Π n (134/2) with exactly k + f blocks where exactly f of them are singletons.
Deferring the proof of this lemma to the end of this section, we continue with our enumeration.
As it is well known that |C n−f −2k,k | = n−f −k− We record this result in our last theorem. We now turn our attention to the proof of Lemma 4.7. We begin with a simple characterization of 134/2-avoiding set partitions. Its straightforward proof is omitted.
Proof Proof of Lemma 4.7: Consider a set partition π = B 1 / . . . /B m ∈ Π n (134/2) so that f of the blocks are singletons and the remaining k = m − f blocks B i1 , . . . , B i k are not singletons. Now let be the resulting weak composition of n−f −2k with k parts. (As each of the blocks B ij are of the form in Lemma 4.8, the parts of our composition are just their corresponding values for ℓ in this decomposition.) Furthermore, by throwing out all but the min and max of each block, and applying standardization map, we obtain a set partition σ of [f + 2k] with exactly f singletons and k doubletons. Finally, we define φ(π) = (λ, σ). (We illustrate this construction in Example 4.9.) As this map is easily seen to be bijective, the proof is complete.