This section gives the proofs of Theorems 2 and 1. Theorem 2 implies Theorem 5. A pair of lemmas which will be useful in the proof of Theorem 2:

**Lemma** **6**.

For

*B*_{
n
}, the Bell numbers, define

${g}_{r,d,k,s}(n):={n}^{d}\sum _{i=0}^{n-k}\left(\genfrac{}{}{0.0pt}{}{n-k}{i}\right){B}_{i+s}{r}^{n-k-i}$

where *r*,*d*,*k*,*s* are non-negative integers. Then, *g*_{r,d,k,s}(*n*) is a shifted Bell polynomial of lower shift index −*k* and upper shift index *r*+*s*−*k*.

*Proof*.

It clearly suffices to prove that *g*_{r,0,k,s}(*n*) is a shifted Bell polynomial. Since *g*_{r,0,0,s}(*n*−*k*)=*g*_{r,0,k,s}(*n*), it suffices to prove that *g*_{r,s}(*n*):=*g*_{r,0,0,s}(*n*) is a shifted Bell polynomial.

For this, consider the exponential generating function

$\begin{array}{l}\sum _{n=0}^{\infty}{g}_{r,s}(n)\frac{{x}^{n}}{n!}=\sum _{n=0}^{\infty}\sum _{i=0}^{n}\left(\genfrac{}{}{0.0pt}{}{n}{i}\right){B}_{i+s}{r}^{n-i}\frac{{x}^{n}}{n!}=\sum _{a=0}^{\infty}\sum _{b=0}^{\infty}{B}_{a+s}{r}^{b}\frac{{x}^{a+b}}{a!b!}\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{7.8em}{0ex}}=\frac{{\partial}^{s}}{\partial {x}^{s}}\left(\sum _{n=0}^{\infty}{B}_{n}\frac{{x}^{n}}{n!}\right){e}^{\mathit{\text{rx}}}={e}^{\mathit{\text{rx}}}\frac{{\partial}^{s}}{\partial {x}^{s}}\left({e}^{{e}^{x}-1}\right).\phantom{\rule{2em}{0ex}}\end{array}$

This is easily seen to be equal to ${e}^{{e}^{x}-1}$ times a polynomial in *e*^{
x
} of degree *s*+*r*.

Since

*g*_{0,s}(

*n*)=

*B*_{n+s}, the generating function

${\sum}_{n=0}^{\infty}{B}_{n+s}\frac{{x}^{n}}{n!}$ equals

${e}^{{e}^{x}-1}$ times a polynomial of exact degree

*s*. From this, for all

*s*,

*r* the space of all polynomials in

*e*^{
x
} of degree at most

*s*+

*r* times

${e}^{{e}^{x}-1}$ is spanned by the set of generating functions

${\sum}_{n=0}^{\infty}{B}_{n+m}\frac{{x}^{n}}{n!}$ as

*m* runs over all integers 0,1,…,

*s*+

*r*. Since the generating function for

*g*_{r,s}(

*n*) lies in this span,

$\sum _{n=0}^{\infty}{g}_{r,s}(n)\frac{{x}^{n}}{n!}=\sum _{m=0}^{s+r}{\beta}_{s,r,m}\sum _{n=0}^{\infty}{B}_{n+m}\frac{{x}^{n}}{n!}$

for some rational numbers

*β*_{s,r,m}. It follows that for all

*n*,

${g}_{r,s}(n)=\sum _{m=0}^{s+r}{\beta}_{s,r,m}{B}_{n+m}.$

For a sequence,

**r**={

*r*_{0},

*r*_{1},⋯,

*r*_{
k
}}, of rational numbers and a polynomial

$Q\in Q[\phantom{\rule{0.3em}{0ex}}{y}_{1},\cdots \phantom{\rule{0.3em}{0ex}},{y}_{k},m]$ define

$M(k,Q,\mathbf{\text{r}},n,x):=\sum _{1\le {x}_{1}<{x}_{2}<\dots <{x}_{k}\le n}Q({x}_{1},\dots ,{x}_{k},n)\prod _{i=0}^{k}{(x+{r}_{i})}^{{x}_{i+1}-{x}_{i}-1},$

(14)

where *x*_{0}=0,*x*_{k+1}=*n*+1.

**Lemma** **7**.

Fix

*k*, let

$Q\in Z[\phantom{\rule{0.3em}{0ex}}{y}_{1},\cdots \phantom{\rule{0.3em}{0ex}},{y}_{k},m]$ and

**r**={

*r*_{0},

*r*_{1},⋯,

*r*_{
k
}} be a sequence of rational numbers. As defined above,

*M*(

*k*,

*Q*,

**r**,

*n*,

*x*) is a rational linear combination of terms of the form

$F(n)G(x){(x+{r}_{i})}^{n-k},$

where $F\in Q\left[\phantom{\rule{0.3em}{0ex}}n\right],G\in Q\left[\phantom{\rule{0.3em}{0ex}}x\right]$ are polynomials.

*Proof*.

The proof is by induction on

*k*. If

*k*=0 then definitionally,

*M*(

*k*,

*Q*,

**r**,

*n*,

*x*)=

*Q*(

*n*)(

*x*+

*r*_{0})

^{
n
}, providing a base case for our result. Assume that the lemma holds for

*k* one smaller. For this, fix the values of

*x*_{1},…,

*x*_{k−1} in the sum and consider the resulting sum over

*x*_{
k
}. Then

$\begin{array}{l}M(k,Q,\mathbf{\text{r}},n,x)\phantom{\rule{2em}{0ex}}\\ =\sum _{1\le {x}_{1}<{x}_{2}<\dots <{x}_{k-1}\le n-1}\prod _{i=0}^{k-2}{(x+{r}_{i})}^{{x}_{i+1}-{x}_{i}-1}\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{1em}{0ex}}\times \sum _{{x}_{k-1}<{x}_{k}\le n}Q({x}_{1},\dots ,{x}_{k},n){(x+{r}_{k-1})}^{{x}_{k}-{x}_{k-1}-1}{(x+{r}_{k})}^{n-{x}_{k}}.\phantom{\rule{2em}{0ex}}\end{array}$

Consider the inner sum over *x*_{
k
}:

If *r*_{k−1}=*r*_{
k
}, then the product of the last two terms is always ${(x+{r}_{k})}^{n-{x}_{k-1}-2}$, and thus the sum is some polynomial in *x*_{1},…,*x*_{k−1},*n* times ${(x+{r}_{k})}^{n-{x}_{k-1}-2}$. The remaining sum over *x*_{1},…,*x*_{k−1} is exactly of the form *M*(*k*−1,*Q*^{′},**r**^{′},*n*−1,*x*), for some polynomial *Q*^{′}, and thus, by the inductive hypothesis, of the correct form.

If *r*_{k−1}≠*r*_{
k
}, the sum is over pairs of non-negative integers *a*=*x*_{
k
}−*x*_{k−1}−1 and *b*=*n*−*x*_{
k
}−1 summing to *n*−*x*_{k−1}−2 of some polynomial, *Q*^{′} in *a* and *n* and the other *x*_{
i
} times (*x*+*r*_{k−1})^{
a
}(*x*+*r*_{
k
})^{
b
}. Letting *y*=(*x*+*r*_{k−1}) and *z*=(*x*+*r*_{
k
}), this is a sum of *Q*^{′}(*x*_{
i
},*n*,*a*)*y*^{
a
}*z*^{
b
}. Let *d* be the *a* degree of *Q*^{′}. Multiplying this sum by (*y*−*z*)^{d+1}, yields, by standard results, a polynomial in *y* and *z* of degree *n*−*x*_{k−1}−2+(*d*+1) in which all terms have either *y* exponent or *z* exponent at least *n*−*x*_{k−1}−1. Thus, this inner sum over *x*_{
k
} when multiplied by the non-zero constant (*r*_{k−1}−*r*_{
k
})^{d+1} yields the sum of a polynomial in *x*,*n*,*x*_{1},…,*x*_{k−1} times ${(x+{r}_{k-1})}^{n-{x}_{k-1}-2}$ plus another such polynomial times ${(x+{r}_{k-1})}^{n-{x}_{k-1}-2}$. Thus, *M*(*k*,*Q*,**r**,*n*,*x*) can be written as a linear combination of terms of the form *G*(*x*)*M*(*k*−1,*Q*^{′},**r**^{′},*n*,*x*). The inductive hypothesis is now enough to complete the proof.

Turn next to the proof of Theorem 2. *Proof of Theorem 2*

It suffices to prove this Theorem for simple statistics. Thus, it suffices to prove that for any pattern

*P* and polynomial

*Q* that

$M({f}_{P,Q};n)=\sum _{\lambda \in {\Pi}_{n}}{f}_{P,Q}(\lambda )=\sum _{\lambda \in {\Pi}_{n}}\sum _{s{\in}_{P}\lambda}Q(s)$

is given by a shifted Bell polynomial in

*n*. As a first step, interchange the order of summation over

*s* and

*λ* above. Hence,

$M({f}_{P,Q};n)=\sum _{s\in {\left[n\right]}^{k}}Q(s)\sum _{\begin{array}{c}\lambda \in \Pi (n)\\ s{\in}_{P}\lambda \end{array}}1.$

To deal with the sum over

*λ* above, first consider only the blocks of

*λ* that contain some element of

*s*. Equivalently, let

*λ*^{′} be obtained from

*λ* by replacing all of the blocks of

*λ* that are disjoint from

*s* by their union. To clarify this notation, let

*Π*^{′}(

*n*) denote the set of all set partitions of [

*n*] with at most one marked block. For

*λ*^{′}∈

*Π*^{′}(

*n*), say that

*s*∈

_{
P
}*λ*^{′} if

*s* in an occurrence of

*P* in

*λ*^{′} as a regular set partition so that additionally the non-marked blocks of

*λ*^{′} are exactly the blocks of

*λ*^{′} that contain some element of

*s*. For

*λ*^{′}∈

*Π*^{′}(

*n*) and

*λ*∈

*Π*(

*n*), say that

*λ* is a

*refinement* of

*λ*^{′} if the unmarked blocks in

*λ*^{′} are all parts in

*λ*, or equivalently, if

*λ* can be obtained from

*λ*^{′} by further partitioning the marked block. Denote

*λ* being a refinement of

*λ*^{′} as

*λ*⊩

*λ*^{′}. Thus, in the previous computation of

*M*(

*f*_{P,Q};

*n*), letting

*λ*^{′} be the marked partition obtained by replacing the blocks in

*λ* disjoint from

*s* by their union:

$M({f}_{P,Q};n)=\sum _{s\in {\left[n\right]}^{k}}Q(s)\sum _{\begin{array}{c}{\lambda}^{\prime}\in {\Pi}^{\prime}(n)\\ s{\in}_{P}{\lambda}^{\prime}\end{array}}\sum _{\begin{array}{c}\lambda \in \Pi (n)\\ \lambda \u22a9{\lambda}^{\prime}\end{array}}1.$

Note that the

*λ* in the final sum above correspond exactly to the set partitions of the marked block of

*λ*^{′}. For

*λ*^{′}∈

*Π*^{′}(

*n*), let |

*λ*^{′}| be the size of the marked block of

*λ*^{′}. Thus,

$M({f}_{P,Q};n)=\sum _{s\in {\left[\phantom{\rule{0.3em}{0ex}}n\right]}^{k}}Q(s)\sum _{\begin{array}{c}{\lambda}^{\prime}\in {\Pi}^{\prime}(n)\\ s{\in}_{P}{\lambda}^{\prime}\end{array}}{B}_{\left|{\lambda}^{\prime}\right|}.$

**Remark** **13**.

This is valid even when the marked block is empty.

Dealing directly with the Bell numbers above will prove challenging, so instead compute the generating function

$M(P,Q,n,x):=\sum _{s\in {\left[n\right]}^{k}}Q(s)\sum _{\begin{array}{c}{\lambda}^{\prime}\in {\Pi}^{\prime}(n)\\ s{\in}_{P}{\lambda}^{\prime}\end{array}}{x}^{\left|{\lambda}^{\prime}\right|}.$

After computing this, extract the coefficients of *M*(*P*,*Q*,*n*,*x*) and multiply them by the appropriate Bell numbers.

To compute

*M*(

*P*,

*Q*,

*n*,

*x*), begin by computing the value of the inner sum in terms of

*s*=(

*x*_{1}<

*x*_{2}<…<

*x*_{
k
}) that preserves the consecutivity relations of

*P* (namely those in

**C**(

*P*)). Denote the equivalence classes in

*P* by 1,2,…,

*ℓ*. Let

*z*_{
i
} be a representative of this

*i* th equivalence class. Then, an element

*λ*^{′}∈

*Π*^{′}(

*n*) so that

*s*∈

_{
P
}*λ*^{′} can be thought of as a set partition of [

*n*] into labeled equivalence classes 0,1,…,

*ℓ*, where the 0th class is the marked block, and the

*i* th class is the block containing

${x}_{{z}_{i}}$. Thus, think of the set of such

*λ*^{′} as the set of maps

*g*:[

*n*]→{0,1,…,

*ℓ*} so that:

- 1.
*g*(*x* _{
j
})=*i* if *j* is in the *i* th equivalence class

- 2.
*g*(*x*)≠*i* if *x*<*x* _{
j
}, *j*∈**F**(*P*) and *j* is in the *i* th equivalence class

- 3.
*g*(*x*)≠*i* if *x*>*x* _{
j
}, *j*∈**L**(*P*) and *j* is in the *i* th equivalence class

- 4.
*g*(*x*)≠*i* if ${x}_{j}<x<{x}_{{j}^{\prime}}$, (*j*,*j* ^{′})∈**A**(*P*) and *j*,*j* ^{′} are in the *i* th equivalence class

It is possible that no such

*g* will exist if one of the latter three properties must be violated by some

*x*=

*x*_{
h
}. If this is the case, this is a property of the pattern

*P*, and not the occurrence

*s*, and thus,

*M*(

*f*_{P,Q};

*n*)=0 for all

*n*. Otherwise, in order to specify

*g*, assign the given values to

*g*(

*x*_{
i
}) and each other

*g*(

*x*) may be independently assigned values from the set of possibilities that does not violate any of the other properties. It should be noted that 0 is always in this set, and that furthermore, this set depends only which of the

*x*_{
i
} our given

*x* is between. Thus, there are some sets

*S*_{0},

*S*_{1},…,

*S*_{
k
}⊆{0,1,…,

*ℓ*}, depending only on

*s*, so that

*g* is determined by picking functions

$\{1,\dots ,{x}_{1}-1\}\to {S}_{0},\{{x}_{1}+1,\dots ,{x}_{2}-1\}\to {S}_{1},\dots ,\{{x}_{k}+1,\dots ,n\}\to {S}_{k}.$

Thus, the sum over such

*λ*^{′} of

${x}^{\left|{\lambda}^{\prime}\right|}$ is easily seen to be

${(x+{r}_{0})}^{{x}_{1}-1}{(x+{r}_{i})}^{{x}_{2}-{x}_{1}-1}\cdots {(x+{r}_{k-1})}^{{x}_{k}-{x}_{k-1}-1}{(x+{r}_{k})}^{n-{x}_{k}},$

where

*r*_{
i
}=|

*S*_{
i
}|−1 (recall |

*S*_{
i
}|>0, because 0∈

*S*_{
i
}). For such a sequence,

**r** of rational numbers define

$M(k,Q,\mathbf{\text{r}},n,x,\mathbf{C}(P)):=\sum _{\begin{array}{c}1\le {x}_{1}<{x}_{2}<\dots <{x}_{k}\le n\\ \left|{x}_{i}-{x}_{j}\right|=1\text{for}\phantom{\rule{0.3em}{0ex}}(i,j)\in \mathbf{C}(P)\end{array}}Q({x}_{1},\dots ,{x}_{k},n)\prod _{i=0}^{k}{(x+{r}_{i})}^{{x}_{i+1}-{x}_{i}-1},$

(15)

where, as in Lemma 7, using the notation *x*_{0}=0,*x*_{k+1}=*n*+1.

Note that the sum is empty if

**C**(

*P*) contains nonconsecutive elements. We will henceforth assume that this is not the case. We call

*j* a follower if either (

*j*−1,

*j*) or (

*j*,

*j*−1) are in

**C**(

*P*). Clearly, the values of all

*x*_{
i
} are determined only by those

*x*_{
i
} where

*i* is not a follower. Furthermore,

*Q* is a polynomial in these values and

*n*. If

*j* is the index of the

*i* th non-follower then let

*y*_{
i
}=

*x*_{
j
}−

*j*+

*i*. Now, sequences of

*x*_{
i
} satisfying the necessary conditions correspond exactly to those sequences with 1≤

*y*_{1}<

*y*_{2}<⋯<

*y*_{k−f}≤

*n*−

*f* where

*f* is the total number of followers. Thus,

$\begin{array}{ll}M(k,Q,\mathbf{\text{r}},n,x,\mathbf{C}(P))& =\sum _{1\le {y}_{1}<{y}_{2}<\dots <{y}_{k-f}\le n-f}\stackrel{~}{Q}({y}_{1},\dots ,{y}_{k},n)\prod _{i=0}^{k}{(x+\stackrel{~}{{r}_{i}})}^{{y}_{i+1}-{y}_{i}-1}\phantom{\rule{2em}{0ex}}\\ =M(k-f,\stackrel{~}{Q},\stackrel{~}{r},n-f,x).\phantom{\rule{2em}{0ex}}\end{array}$

where the $\stackrel{~}{{r}_{i}}$ are modified versions of the *r*_{
i
} to account for the change from {*x*_{
j
}} to {*y*_{
i
}}. In particular, if *x*_{
j
} is the (*i*+1)^{
s
t
} non-follower, then $\stackrel{~}{{r}_{i}}={r}_{j-1}$.

By Lemma 7, $M(k-f,\stackrel{~}{Q},\stackrel{~}{r},n-f,x)$ is a linear combination of terms of the form *F*(*n*)*G*(*x*)(*x*+*r*_{
i
})^{n−k} for polynomials $F\in Q\left[\phantom{\rule{0.3em}{0ex}}n\right]$ and $G\in Q\left[\phantom{\rule{0.3em}{0ex}}x\right]$.

Thus, *M*(*f*_{P,Q};*n*) can be written as a linear combination of terms of the form *g*_{r,d,ℓ,s}(*n*) where *ℓ* is the number of equivalence classes in *P* and *r*,*d*,*s* are non-negative integers. Therefore, by Lemma 6 *M*(*f*_{P,Q};*n*) is a shifted Bell polynomial.

The bound for the upper shift index follows from the fact that *M*(*f*_{P,Q};*n*)=*O*(*n*^{
N
}*B*_{
n
}) and by (13) each term *n*^{
α
}*B*_{n+β} is of an asymptotically distinct size. To complete the proof of the result it is sufficient to bound the lower shift index of the Bell polynomial. By (15) it is clear the largest power of *x* in each term is (*n*−*k*). Thus, from Lemma 6, the resulting shift Bell polynomials can be written with minimum lower shift index −*k*. This completes the proof.

Next turn to the proof of Theorem 1. To this end, introduce some notation.

**Definition** **3**.

Given three patterns

*P*_{1},

*P*_{2},

*P*_{3}, of lengths

*k*_{1},

*k*_{2},

*k*_{3}, say that a

*merge* of

*P*_{1} and

*P*_{2} onto

*P*_{3} is a pair of strictly increasing functions

*m*_{1}:[

*k*_{1}]→[

*k*_{3}],

*m*_{2}:[

*k*_{2}]→[

*k*_{3}] so that

- 1.
*m* _{1}([*k* _{1}])∪*m* _{2}([*k* _{2}])=[ *k* _{3}]

- 2.
${m}_{1}(i){\sim}_{{P}_{3}}{m}_{1}(j)$

if and only if

$i{\sim}_{{P}_{1}}j$, and

${m}_{2}(i){\sim}_{{P}_{3}}{m}_{2}(j)$ if and only if

- 3.
*i*∈**F**(*P* _{3}) if and only if there exists either a *j*∈**F**(*P* _{1}) so that *i*=*m* _{1}(*j*) or a *j*∈**F**(*P* _{2}) so that *i*=*m* _{2}(*j*)

- 4.
*i*∈**L**(*P* _{3}) if and only if there exists either a *j*∈**L**(*P* _{1}) so that *i*=*m* _{1}(*j*) or a *j*∈**L**(*P* _{2}) so that *i*=*m* _{2}(*j*)

- 5.
(*i*,*i* ^{′})∈**A**(*P* _{3}) if and only if there exists either a (*j*,*j* ^{′})∈**A**(*P* _{1}) so that *i*=*m* _{1}(*j*) and *i* ^{′}=*m* _{1}(*j* ^{′}) or a (*j*,*j* ^{′})∈**A**(*P* _{2}) so that *i*=*m* _{2}(*j*) and *i* ^{′}=*m* _{2}(*j* ^{′})

- 6.
(*i*,*i* ^{′})∈**C**(*P* _{3}) if and only if there exists either a (*j*,*j* ^{′})∈**C**(*P* _{1}) so that *i*=*m* _{1}(*j*) and *i* ^{′}=*m* _{1}(*j* ^{′}) or a (*j*,*j* ^{′})∈**C**(*P* _{2}) so that *i*=*m* _{2}(*j*) and *i* ^{′}=*m* _{2}(*j* ^{′})

Such a merge is denoted as *m*_{1},*m*_{2}:*P*_{1},*P*_{2}→*P*_{3}.

Note that the last four properties above imply that given *P*_{1} and *P*_{2}, a merge (including a pattern *P*_{3}) is uniquely defined by maps *m*_{1},*m*_{2} and an equivalence relation ${\sim}_{{P}_{3}}$ satisfying (1) and (2) above.

**Lemma** **8**.

Let

*P*_{1} and

*P*_{2} be patterns. For any

*λ* there is a one-to-one correspondence:

$\left\{({s}_{1},{s}_{2}):{s}_{1}{\in}_{{P}_{1}}\lambda ,{s}_{2}{\in}_{{P}_{2}}\lambda \right\}\iff \left\{{P}_{3},{s}_{3}{\in}_{{P}_{3}}\lambda ,\text{and}{m}_{1},{m}_{2}:{P}_{1},{P}_{2}\to {P}_{3}\right\}.$

(16)

Moreover, under this correspondence

$\begin{array}{ll}{Q}_{{m}_{1},{m}_{2},{Q}_{1},{Q}_{2}}({s}_{3}):=& {Q}_{1}({z}_{{m}_{1}(1)},{z}_{{m}_{1}(2)},\dots ,{z}_{{m}_{1}({k}_{1})},n){Q}_{2}({z}_{{m}_{2}(1)},{z}_{{m}_{2}(2)},\dots ,{z}_{{m}_{2}({k}_{2})},n)\phantom{\rule{2em}{0ex}}\\ ={Q}_{1}({s}_{1}){Q}_{2}({s}_{2}).\end{array}$

(17)

*Proof*.

Begin by demonstrating the bijection defined by Eq. 16. On the one hand, given ${s}_{3}{\in}_{{P}_{3}}\lambda $ given by ${z}_{1}<{z}_{2}<\dots <{z}_{{k}_{3}}$ and *m*_{1},*m*_{2}:*P*_{1},*P*_{2}→*P*_{3}, define *s*_{1} and *s*_{2} by the sequences ${z}_{{m}_{1}(1)}<{z}_{{m}_{1}(2)}<\dots <{z}_{{m}_{1}({k}_{1})}$ and ${z}_{{m}_{2}(1)}<{z}_{{m}_{2}(2)}<\dots <{z}_{{m}_{2}({k}_{2})}$. It is easy to verify that these are occurrences of the patterns *P*_{1} and *P*_{2} and furthermore that Eq. 17 holds for this mapping.

This mapping has a unique inverse: Given *s*_{1} and *s*_{2}, note that *s*_{3} must equal the union *s*_{1}∪*s*_{2}. Furthermore, the maps *m*_{
a
}, for *a*=1,2, must be given by the unique function so that *m*_{
a
}(*i*)=*j* if and only if the *i*^{
t
h
} smallest element of *s*_{
a
} equals the *j*^{
t
h
} smallest element of *s*_{3}. Note that the union of these images must be all of [*k*_{3}]. In order for *s*_{3} to be an occurrence of *P*_{3} the equivalence relation ${\sim}_{{P}_{3}}$ must be that $i{\sim}_{{P}_{3}}j$ if and only if the *i*^{
t
h
} and *j*^{
t
h
} elements of *s*_{3} are equivalent under *λ*. Note that since *S*_{1} and *S*_{2} were occurrences of *P*_{1} and *P*_{2}, that this must satisfy condition (2) for a merge. The rest of the data associated to *P*_{3} (namely **F**(*P*_{3}),**L**(*P*_{3}), **A**(*P*_{3}), and **C**(*P*_{3})) is now uniquely determined by *m*_{1},*m*_{2},*P*_{1},*P*_{2} and the fact that *P*_{3} is a merge of *P*_{1} and *P*_{2} under these maps. To show that *s*_{3} is an occurrence of *P*_{3} first note that by construction the equivalence relations induced by *λ* and *P*_{3} agree. If *i*∈**F**(*P*_{3}), then there is a *j*∈**F**(*P*_{
a
}) with *i*=*m*_{
a
}(*j*) for some *a*,*j*. Since *s*_{
a
} is an occurrence of *P*_{
a
}, this means that the *j*^{
t
h
} smallest element of *s*_{
a
} in in **F** **i** **r** **s** **t**(*λ*). On the other hand, by the construction of *m*_{
a
}, this element is exactly ${z}_{{m}_{a}(j)}={z}_{i}$. This if *i*∈**F**(*P*_{3}), *z*_{
i
}∈**F** **i** **r** **s** **t**(*λ*). The remaining properties necessary to verify that *S*_{3} is an occurrence of *P*_{3} follow similarly. Thus, having shown that the above map has a unique inverse, the proof of the lemma is complete.

Recall, the number of singleton blocks is denoted

*X*_{1} and it is a simple statistic. To illustrate this lemma return to the example of

${X}_{1}^{2}$ discussed prior to the lemma. Let

*P*_{1}=

*P*_{2} be the pattern of length 1 with

**A**(

*P*_{1})=

*ϕ*,

**F**(

*P*_{1})=

**L**(

*P*_{1})=1. Then there are five possible merges of

*P*_{1} and

*P*_{2} into some pattern

*P*_{3}. The first choice of

*P*_{3} is

*P*_{1} itself. In which case

*m*_{1}(1)=

*m*_{2}(1)=1. The latter choices of

*P*_{3} is the pattern of length 2 with

**F**(

*P*_{3})=

**L**(

*P*_{3})={1,2},

**A**(

*P*_{3})=

*∅*. The equivalence relation on

*P*_{3} could be either the trivial one or the one that relates 1 and 2 (though in the latter case the pattern

*P*_{3} will never have any occurrences in any set partition). In either of these cases, there is a merge with

*m*_{1}(1)=1 and

*m*_{2}(1)=2 and a second merge with

*m*_{1}(1)=2 and

*m*_{2}(1)=1. As a result,

$\begin{array}{l}M({X}_{1}^{2};n)=\sum _{\lambda \in \Pi (n)}{X}_{1}{(\lambda )}^{2}=\sum _{\lambda \in \Pi (n)}{\left(\sum _{\begin{array}{c}{x}_{1}\\ {x}_{1}\in \mathbf{First}(\lambda )\\ {x}_{1}\in \mathbf{Last}(\lambda )\end{array}}1\right)}^{2}\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{4.5em}{0ex}}=\sum _{\lambda \in \Pi (n)}\sum _{\begin{array}{c}{x}_{1}\\ {x}_{1}\in \mathbf{First}(\lambda )\\ {x}_{1}\in \mathbf{Last}(\lambda )\end{array}}\sum _{\begin{array}{c}{y}_{1}\\ {y}_{1}\in \mathbf{First}(\lambda )\\ {y}_{1}\in \mathbf{Last}(\lambda )\end{array}}1\phantom{\rule{1em}{0ex}}\phantom{\rule{1em}{0ex}}=\phantom{\rule{1em}{0ex}}\phantom{\rule{1em}{0ex}}2\sum _{\lambda \in \Pi (n)}\sum _{\begin{array}{c}{x}_{1}<{x}_{2}\\ {x}_{1},{x}_{2}\in \mathbf{First}(\lambda )\\ {x}_{1},{x}_{2}\in \mathbf{Last}(\lambda )\end{array}}1+\sum _{\lambda \in \Pi (n)}\sum _{\begin{array}{c}{x}_{1}\\ {x}_{1}\in \mathbf{First}(\lambda )\\ {x}_{1}\in \mathbf{Last}(\lambda )\end{array}}1\phantom{\rule{2em}{0ex}}\end{array}$

*Proof of Theorem 1* The fact that statistics are closed under pointwise addition and scaling follows immediately from the definition. Similarly, the desired degree bounds for these operations also follow easily. Thus only closure and degree bounds for multiplication must be proved. Since every statistic may be written as a linear combination of simple statistics of no greater degree, and since statistics are closed under linear combination, it suffices to prove this theorem for a product of two simple statistics. Thus let *f*_{
i
} be the simple statistic defined by a pattern *P*_{
i
} of size *k*_{
i
} and a polynomial *Q*_{
i
}. It must be shown that *f*_{1}(*λ*)*f*_{2}(*λ*) is given by a statistic of degree at most *k*_{1}+*k*_{2}+ deg(*Q*_{1})+ deg(*Q*_{2}).

For any

*λ*${f}_{1}(\lambda ){f}_{2}(\lambda )=\sum _{{s}_{1}{\in}_{{P}_{1}}\lambda ,{s}_{2}{\in}_{{P}_{2}}\lambda}{Q}_{1}({s}_{1}){Q}_{2}({s}_{2}).$

Simplify this equation using Lemma 8, writing this as a sum over occurrences of only a single pattern in *λ*.

Applying Lemma 8,

$\begin{array}{ll}{f}_{1}(\lambda ){f}_{2}(\lambda )& =\sum _{{s}_{1}{\in}_{{P}_{1}}\lambda ,{s}_{2}{\in}_{{P}_{2}}\lambda}{Q}_{1}({s}_{1}){Q}_{2}({s}_{2})\phantom{\rule{2em}{0ex}}\\ =\sum _{{P}_{3}}\sum _{{m}_{1},{m}_{2}:{P}_{1},{P}_{2}\to {P}_{3}}\sum _{{s}_{3}{\in}_{{P}_{3}}\lambda}{Q}_{{m}_{1},{m}_{2},{Q}_{1},{Q}_{2}}({s}_{3}),\phantom{\rule{2em}{0ex}}\\ =\sum _{{m}_{1},{m}_{2}:{P}_{1},{P}_{2}\to {P}_{3}}{f}_{{P}_{3},{Q}_{{m}_{1},{m}_{2},{Q}_{1},{Q}_{2}}}(\lambda ).\phantom{\rule{2em}{0ex}}\end{array}$

Thus, the product of *f*_{1} and *f*_{2} is a sum of simple characters. Note that the quantity is a polynomial of *s*_{3} which is denoted ${Q}_{{m}_{1},{m}_{2},{Q}_{1},{Q}_{2}}({s}_{3}).$ Finally, each pattern *P*_{3} has size at most *k*_{1}+*k*_{2} and each polynomial ${Q}_{{m}_{1},{m}_{2},{Q}_{1},{Q}_{2}}$ has degree at most deg(*Q*_{1})+ deg(*Q*_{2}). Thus the degree of the product is at most the sum of the degrees.