\section{Introduction}\label{sec: intro}

The Hopf algebra $\textsl{NCSym}$ of symmetric functions in noncommuting variables was introduced in \cite{BRRZ:2008}, following the work of Wolf, Rosas, and Sagan \cite{Wol:1936,RosSag:2006}. We refer the reader to these sources for details on its realization as formal sums of monomials invariant under $\mathfrak{S}_n$ (for all $n>0$). For our goals, it suffices to describe $\textsl{NCSym}$ abstractly in terms of generators and relations, which we do in Section \ref{sec: ncsym}.

The Hopf algebra $\textsl{NCSym}$ is cocommutative (by definition) and freely generated as an algebra (essentially the main result of Wolf). Following \cite{BRRZ:2008}, we choose the \emph{atomic set partitions} $\bm{\dot\Pi}$ as a free generating set (see Section \ref{sec: ncsym}). The Cartier-Milnor-Moore theorem then guarantees that $\textsl{NCSym}$ is isomorphic to $\mathfrak U(\mathfrak L(\bm{\dot\Pi}))$, the universal enveloping algebra of the free Lie algebra generated by $\bm{\dot\Pi}$. This note grew out of an attempt to realize this isomorphism explicitly.

In Section \ref{sec: prelims}, we record some useful combinatorial machinery. Section \ref{sec: ncsym} contains a precise definition of the Hopf algebra $\textsl{NCSym}$ as well as the statements and proofs of our main results. In Section \ref{sec: summary}, we comment on: (i) an important connection between $\textsl{NCSym}$ and supercharacter theory; and (ii) key structural features of our proofs that will be further developed in \cite{LauMas:1}.

\subsection*{Acknowledgements} We thank Marcelo Aguiar and Nantel Bergeron for useful conversations and for pointing us to the related work of Patras and Reutenauer.

\section{Combinatorial Preliminaries}\label{sec: prelims}
We record some useful shorthand for manipulating set partitions and set compositions. Throughout, we let $\mathbb{N}$ and $\mathbb{P}$ denote the set of nonnegative integers and positive integers, respectively. Also, given $n\in\mathbb{P}$, we let $[n]$ denote the subset $\{1,2,\dotsc,n\}$.

\subsection{Set partitions}\label{sec: set parts}
Fix $X\subseteq \mathbb{P}$ and let $\mathbf{A} = \{A_1,\dotsc, A_r\}$ be a set of subsets of $X$. We say that $\mathbf{A}$ is a \demph{set partition} of $X$, written $\mathbf{A} \vdash X$, if and only if $A_1\cup\dotsb\cup A_r=X$, $A_i\neq\emptyset$ ($\forall i$), and $A_i\cap A_j=\emptyset$ ($\forall i\neq j$).
We order the parts in increasing order of their minimum elements.
The \demph{weight} $|\mathbf{A}|$ of $\mathbf{A}$ is the cardinality of $X$ and the \demph{length} $\length{\mathbf{A}}$ of $\mathbf{A}$ is its number of parts ($r$).
In what follows, we lighten the heavy notation for set partitions, writing, e.g., the set partition $\{\{1,3\},\{2,8\},\{4\}\}$ as $13.28.4$. We write $\bm\Pi(X)$ for the set partitions of $X$ and $\bm\Pi(n)$ when $X=[n]$.

Given any $A\subseteq \mathbb{N}$ and $k\in \mathbb{N}$, we write $\shift{A}{k}$ for the set
\[
	\shift{A}{k}:=\{a+k \mid a\in A\}.
\]
By extension, for any set partition $\mathbf{A}=\{A_1,A_2,\ldots,A_r\}$ we set
$
	\shift{\mathbf{A}}{k}:=\{\shift{A_1}{k},\shift{A_2}{k},$ $\ldots,\shift{A_r}{k}\}.
$
The operator $\shift{(\hbox{--})}{k}$ has a complement $\std{(\hbox{--})}$ called the \demph{standardization} operator. It maps set partitions $\mathbf{A}$ of any cardinality $n$ subset $X\subseteq \mathbb{P}$ to set partitions of $[n]$, by defining $\std{\mathbf{A}}$ as the pullback of $\mathbf{A}$ along the unique increasing bijection from $[n]$ to $X$. For example, $\std{(18.4)} = 13.2$ and $\std{(18.4.67)}=15.2.34$.
Given set partitions $\mathbf{B} \vdash [m]$ and $\mathbf{C} \vdash [n]$, we let $\mathbf{B} {\textcolor{mymagenta}{|}} \mathbf{C}$ denote the set partition $\mathbf{B} \cup \shift{\mathbf{C}}{m}$ of $[m+n]$.

\begin{definition}\label{def: atomic}
A set partition $\mathbf{A}=\{A_1,A_2,\ldots,A_r\}$ of $[n]$ is \demph{atomic} (``connected'' in \cite{HivNovThi:2008}) if there {does not} exist a subset $\mathbf{B}\subseteq \mathbf{A}$ and an integer $m<n$ such that $\mathbf{B} \vdash [m]$. Conversely, $\mathbf{A}$ is not atomic if there are set partitions $\mathbf{B}$ of $[n']$ and $\mathbf{C}$ of $[n'']$ splitting $\mathbf{A}$ in two: $\mathbf{A} = \mathbf{B} {\textcolor{mymagenta}{|}} \mathbf{C}$.
\end{definition}

For example, the partition $17.235.4.68$ is atomic, while $12.346.57.8$ is not. The maximal splitting of the latter would be $12 {\textcolor{mymagenta}{|}} 124.35 {\textcolor{mymagenta}{|}} 1$.
We denote the atomic set partitions by $\bm{\dot\Pi}$.

If $\mathbf{A}$ is a set partition with $r$ parts, and $K\subseteq[r]$, we write $A_K$ to denote the sub partition $\{A_k \mid k\in K\}\subseteq \mathbf{A}$. For example, if $\mathbf{A}=17.235.4.68$, then $\mathbf{A}_{\{1,3,4\}} = 17.4.68$.

\subsection{Set compositions}\label{sec: set comps}
Fix $K\subseteq \mathbb{P}$ and let $\gamma = (\gamma_1,\dotsc, \gamma_s)$ be a sequence of subsets of $K$. We say that $\gamma$ is a \demph{set composition} of $K$, written $\gamma \vDash K$, if and only if $\gamma_1\cup\dotsb\cup \gamma_s=K$, $\gamma_i\neq\emptyset$ ($\forall i$), and $\gamma_i\cap \gamma_j=\emptyset$ ($\forall i\neq j$).
The \demph{weight} $|\gamma|$ and \demph{length} $\length{\gamma}$ are defined as for set partitions.
We use ``$\bm|$'' in place of ``.'' in our shorthand for set compositions, e.g., the set composition $(\{3,8\},\{1,2\},\{4\})$ is abbreviated as $38\cmrg12\cmrg4$. We write $\bm\Gamma(K)$ for the set partitions of $K$ and $\bm\Gamma(r)$ when $K=[r]$.

If $\gamma$ is a set composition of $X$ and $K\subseteq X$, we write $\gamma{}_{\!}\rfloor_K$ for the induced set composition of $K$. For example, if $\gamma = 38\bm| 12\bm| 4$ and $K = \{3,4,8\}$, then $\gamma{}_{\!}\rfloor_K = 38\bm| 4$. Similarly, $\gamma{}_{\!}\rfloor_{\{1,3\}} = 3\bm| 1$.
Note that $\gamma{}_{\!}\rfloor_{\{1,3\}}$ is not the same as $\gamma_{\{1,3\}}$. Following the notation introduced for set partitions, we let $\gamma_{\{1,3\}}$ denote the subsequence $38\bm| 4$ of $\gamma$.

Given two set compositions $\gamma,\rho \vDash K$, we say that $\gamma$ \demph{refines} $\rho$, written $\gamma \succ \rho$, if each block of $\rho$ is the union of a contiguous string of blocks of $\gamma$. For example, $2\cmrg4\cmrg3\cmrg17\bm| 9 \succ 234\cmrg179 \succ 123479$.

\subsection{Set compositions as functions on set partitions}\label{sec: functions}
Let $\mathbf{A}$ be a set partition of $X$ with $r$ parts and suppose $\gamma=(\gamma_1,\dotsc,\gamma_s)$ is a set composition of $K\subseteq[r]$. We define a new set partition $\gamma[\mathbf{A}]$ as follows:
\begin{gather}\label{eq: gamma of A}
	\gamma[\mathbf{A}] := \std{\mathbf{A}_{\gamma_1}} {\textcolor{mymagenta}{|}} \std{\mathbf{A}_{\gamma_2}} {\textcolor{mymagenta}{|}} \dotsb {\textcolor{mymagenta}{|}} \std{\mathbf{A}_{\gamma_{s}}} \,.
\end{gather}
See Figure \ref{fig: gamma of A} for several examples.
\begin{figure}[hbt]
\[
\begin{array}{r|lll}
 & 13.29.458.7 & 13.28.456.7 & 15.28.346.7  \\[0.4ex]
\hline
13\cmrg2\  & 12.345.67 & 12.345.67 & 14.235.67 \\
2\cmrg34\  & 12.346.5 & 12.345.6 & 12.345.6 \\
1\cmrg234\  & 12.38.457.6 & 12.38.456.7 & 12.38.457.6  \\
\end{array}
\]
\caption{Set partitions $\gamma[\mathbf{A}]$ for several examples of $\gamma$ and $\mathbf{A}$.}
\label{fig: gamma of A}
\end{figure}

\section{Structure of $\textsl{NCSym}$}\label{sec: ncsym}

Let $\textsl{NCSym}=\bigoplus_{n\geq0} \textsl{NCSym}_n$ denote the graded $\mathbb{Q}$ vector space whose $n$th graded piece consists of formal sums of set partitions $\mathbf{A} \in \bm\Pi(n)$. We give $\textsl{NCSym}$ the structure of graded Hopf algebra as follows. The algebra structure is given by
\begin{gather}\label{eq: ncsym product}
	\mathbf{A} \bm\cdot \mathbf{B} = \mathbf{A} {\textcolor{mymagenta}{|}} \mathbf{B} \quad\hbox{and}\quad 1_{\textsl{NCSym}} = \bm\emptyset \,,
\end{gather}
where $\bm\emptyset$ is the unique set partition of the empty set. The coalgebra structure is given by
\begin{gather}\label{eq: ncsym coproduct}
	\Delta(\mathbf{A}) = \sum_{K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L = [r]} \std{(\mathbf{A}_K)} \otimes \std{(\mathbf{A}_L)} \quad\hbox{and}\quad \varepsilon(\mathbf{A}) = 0 \hbox{\ for all\ }\mathbf{A}\neq\bm\emptyset \,.
\end{gather}
Here, $\mathbf{A}$ is a set partition with $r$ parts, and $K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L = [r]$ is understood as an ordered disjoint union, i.e., $K\cup L = [r], K\cap L = \emptyset,$ and $K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L \neq L \mathrel{\ensuremath{\mathaccent\cdot\cup}} K$.

In terms of the symmetric function interpretation of $\textsl{NCSym}$, the formulas above correspond to working in the basis of \demph{power sum symmetric functions}. The compatibility of product and coproduct is proven in \cite{BRRZ:2008}, the product formula is proven in \cite{BerZab:2009}, and the coproduct formula is proven in \cite{BHRZ:2006}. A combinatorially meaningful formula for the antipode in $\textsl{NCSym}$ has been missing until now (Theorem \ref{thm: ncsym antipode}).

Evidently, $\textsl{NCSym}$ is cocommutative and freely generated by $\bm{\dot\Pi}$. The Cartier-Milnor-Moore theorem guarantees algebraically independent primitive elements $p(\mathbf{A})$ of $\textsl{NCSym}$ associated to each $\mathbf{A} \in\mathcal P$. We find them below (Theorem \ref{thm: ncsym primitives}).

\subsection{Primitive generators of $\textsl{NCSym}$}\label{sec: ncsym primitives}
We aim to prove the following result.

\begin{theorem}\label{thm: ncsym primitives}
Let $\bm\Gamma'(r)$ denote the set compositions $\gamma$ of $[r]$ with $1\in\gamma_1$. If $\mathbf{A}$ is a set partition with $r$ parts, then
\begin{gather}\label{eq: ncsym primitives}
p(\mathbf{A}) := \sum_{\gamma\in\bm\Gamma'(r)} (-1)^{\length{\gamma}-1} \gamma[\mathbf{A}]
\end{gather}
is a nonzero primitive if $\mathbf{A}\in\bm{\dot\Pi}$ and zero otherwise.
\end{theorem}

\begin{remark} An arbitrary choice was made in \eqref{eq: ncsym primitives}, namely demanding that the distinguished element $1$ belongs to the first block of $\gamma$. Different choices of distinguished elements (and distinguished blocks) give rise to different sets of primitives. Summing over these choices produces a projection operator onto the space of all primitives.
This operator can be understood in the context of the work Patras and Reutenauer on Lie idempotents \cite{PatReu:1999,PatReu:2002a}.
Fisher \cite{Fis:thesis} uses similar idempotents to work out primitive formulas for several Hopf monoids in species. His formulas, which were discovered independently, also give rise to \eqref{eq: ncsym primitives}.
\end{remark}

To prove Theorem \ref{thm: ncsym primitives}, we need a lemma about \emph{left quasi-shuffles.} Let $\mathbf{P}=\langle \mathrm{fin}(2^\mathbb{P}) \rangle$ denote the free monoid generated by the finite subsets of $\mathbb{P}$ and let $\mathbb{Q}\mathbf{P}$ denote the corresponding free algebra. We use ${\textcolor{mymagenta}{|}}$ to separate letters in the words $w\in\mathbf{P}$. Given a word $u=u_1{\textcolor{mymagenta}{|}}\dotsb{\textcolor{mymagenta}{|}} u_k$ on $k$ letters and an index $i\leq k$, we write $u_{[i]}$ for the prefix $u_1{\textcolor{mymagenta}{|}}\dotsb{\textcolor{mymagenta}{|}} u_i$ and $u^{[i]}$ for the suffix $u_{i+1}{\textcolor{mymagenta}{|}}\dotsb{\textcolor{mymagenta}{|}} u_k$.

We say that words $u=u_1{\textcolor{mymagenta}{|}}\dotsb{\textcolor{mymagenta}{|}} u_k$ and $v=v_1{\textcolor{mymagenta}{|}}\dotsb{\textcolor{mymagenta}{|}} v_l$ in $\mathbf{P}$ are \emph{disjoint} if $\bigl(\bigcup_i u_i\bigr) \cap \bigl(\bigcup_j v_j\bigr) = \emptyset$. (We identify the set compositions $\bm\Gamma(K)$ with the words $w\in\mathbf{P}$ that further satisfy $w_i\cap w_j = \emptyset$ for $i\neq j$ and $\bigcup_j w_j = K$.)

The \demph{quasi-shuffle} $u\nshuff v$ of two disjoint words $u,v\in \mathbf{P}$ is defined recursively as follows:
\begin{itemize}
\item $u \nshuff \emptyset = u$ and $\emptyset \nshuff v = v$;
\item if $u=a{\textcolor{mymagenta}{|}} u'$ and $v=b{\textcolor{mymagenta}{|}} v'$, then
\[
	u \nshuff v = \left\{a{\textcolor{mymagenta}{|}} w : w\in u'\nshuff v \right\} \cup
		\left\{ab{\textcolor{mymagenta}{|}} w : w\in u'\nshuff v' \right\} \cup
		\left\{b{\textcolor{mymagenta}{|}} w : w\in u\nshuff v' \right\} .
\]
\end{itemize}
Here $\emptyset$ denotes the unique set composition of the emptyset and ``$ab$'' denotes the union $a\cup b$, a single letter in $\mathbf{P}$.
The quasi-shuffle governs the formula for the product of two monomial symmetric functions in noncommuting variables. We need a subset of these that we call the \demph{left quasi-shuffles:}
\[
	u \mathrel{\tilde\nshuff} v = \left\{a{\textcolor{mymagenta}{|}} w : w\in u'\nshuff v \right\} \cup
		\left\{ab{\textcolor{mymagenta}{|}} w : w\in u'\nshuff v' \right\}
\]
for nonempty disjoint words $u=a{\textcolor{mymagenta}{|}} u'$ and $v=b{\textcolor{mymagenta}{|}} v'$ in $\mathbf{P}$. (Note that the recursive definition involves $\nshuff$, not $\mathrel{\tilde\nshuff}$.)

\begin{example} Consider the set compositions $1\mrg3$ and $24$. We have
\[
	1{\textcolor{mymagenta}{|}} 3 \mathrel{\tilde\nshuff} 24 = \bigl\{1{\textcolor{mymagenta}{|}} 3 {\textcolor{mymagenta}{|}} 24, \, 1{\textcolor{mymagenta}{|}} 234, 1{\textcolor{mymagenta}{|}} 24{\textcolor{mymagenta}{|}} 3, \, 124{\textcolor{mymagenta}{|}} 3\bigr\} \,.
\]
Note that for each left quasi-shuffle $\gamma$ above, $\gamma{}_{\!}\rfloor_{\{1,3\}} = 1\mrg3$ and $\gamma{}_{\!}\rfloor_{\{2,4\}} = 24$.
\end{example}

\begin{lemma}\label{thm: mcsym primitives} Let $\bm\Gamma'(r)$ denote the set compositions $\gamma$ of $[r]$ with $1\in\gamma_1$. Given any partition $K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L = [r]$ with $1\in K\subsetneq[r]$, we have
\[
	\sum_{\gamma\in\bm\Gamma'(r)} (-1)^{\length{\gamma}} \gamma{}_{\!}\rfloor_K \otimes \gamma{}_{\!}\rfloor_L = 0 \,,
\]
as an element of $\mathbb{Q}\mathbf{P}\otimes \mathbb{Q}\mathbf{P}$.
\end{lemma}

\begin{proof} Consider a term $u \otimes v$ in the sum. (The hypothesis $K\neq [r]$ guarantees that $v\neq\emptyset$.) The compositions $\gamma$ that satisfy $\gamma{}_{\!}\rfloor_K = u$ and $\gamma{}_{\!}\rfloor_L = v$ are precisely the left quasi-shuffles $u \mathrel{\tilde\nshuff} v$. We now establish a bijection between those of even length and those of odd length. This will complete the proof.

A left quasi-shuffle $w\in u\mathrel{\tilde\nshuff} v$ falls into one of two types according to whether or not the first letter of $v$ appears as a letter in $w$: after beginning with some (possibly empty) initial prefix of $u$, say up to the $i$th letter $u_i$, the rest of the word $w$ looks like either $u_{i+1}{\textcolor{mymagenta}{|}} v_1{\textcolor{mymagenta}{|}} w'$ or $u_{i+1}v_1{\textcolor{mymagenta}{|}} w'$ for $w'$ in $u^{[i+1]}\nshuff v^{[1]}$. Here, again, $u_{i+1}v_1$ denotes $u_{i+1}\cup v_1$. The indicated pairing $w \mapsto \phi(w)$ ($u_{i+1}{\textcolor{mymagenta}{|}} v_1 \mapsto u_{i+1}v_1$) decreases the number of letters by one. Thus $w$ and $\phi(w)$ contribute opposite signs to the coefficient of $u\otimes v$.
\end{proof}

\begin{proof}[Proof of Theorem \ref{thm: ncsym primitives}]
Since $\Delta$ is cocommutative, we need only consider the terms $\std{\gamma[\mathbf{A}]_K} \otimes \std{\gamma[\mathbf{A}]_L}$ from each $\Delta(\gamma[\mathbf{A}])$ satisfying $1\in K$. Notice that ${\gamma[\mathbf{A}]_K} = {\bigl(\gamma{}_{\!}\rfloor_{K'}\bigr)[\mathbf{A}]}$ for some $K'\subseteq[r]$ (with $1\in K'$ if $1\in\gamma_1$). Thus
\begin{gather*}
\sum_{\gamma\in\bm\Gamma'(r)} (-1)^{\length{\gamma}}
	\sum_{\substack{K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L = [r] \\ 1\in K}}
	\std{\gamma[\mathbf{A}]_K} \otimes \std{\gamma[\mathbf{A}]_L}
\intertext{%
is the same sum as}
\sum_{\substack{K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L = [r] \\ 1\in K}}
	\sum_{\gamma\in\bm\Gamma'(r)} (-1)^{\length{\gamma}}
	\std{\bigl(\gamma{}_{\!}\rfloor_K\bigr)[\mathbf{A}]} \otimes \std{\bigl(\gamma{}_{\!}\rfloor_L\bigr)[\mathbf{A}]} \,,
\intertext{%
or even}
\Biggl(\sum_{\substack{K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L = [r] \\ 1\in K}}
	\sum_{\gamma\in\bm\Gamma'(r)} (-1)^{\length{\gamma}}
	\gamma{}_{\!}\rfloor_K \otimes \gamma{}_{\!}\rfloor_L \Biggr)[\mathbf{A}\otimes \mathbf{A}]

	\,.
\end{gather*}
Lemma \ref{thm: mcsym primitives} reduces this expression to ${(0)[\mathbf{A}\otimes\mathbf{A}]}=0$ when $K\neq[r]$. When $K=[r]$, the expression is precisely $p(\mathbf{A})\otimes 1$. Conclude that $p(\mathbf{A})$ is a primitive element when $\mathbf{A}$ is atomic.

To show that $p(\mathbf{A})$ is nonzero when $\mathbf{A}$ is atomic, we merely remark that $\gamma[\mathbf{A}]$ has at least as many atoms as $\gamma$ has parts. It is only when $\mathbf{A}\in\bm{\dot\Pi}$ and $\gamma=[r]$ that a single atom is obtained: $\gamma[\mathbf{A}]$ contributes $\mathbf{A}$ to the sum $p(\mathbf{A})$ only when $\gamma=[r]$. Thus $p(\mathbf{A})\neq 0$.

We now show that $p(\mathbf{A})=0$ when $\mathbf{A}$ is not atomic. Suppose $\mathbf{A}=\mathbf{A}'{\textcolor{mymagenta}{|}}\mathbf{A}''$ and put $\length{\mathbf{A}} = r, \length{\mathbf{A}'} = r'$. (Note that $r'<r$ by assumption.) Divide the set compositions $\gamma\in \bm\Gamma'(r)$ into two types according to the following dichotomy. If $\gamma_i$ is the first letter, from the left, satisfying $\gamma_i \cap \{r'+1,\dotsc,r\} \neq \emptyset$, then either $\gamma_i\cap\{1,\dotsc,r'\}$ is empty or it is not. The pairing $\gamma\mapsto \phi(\gamma)$ ($\gamma_{i-1}{\textcolor{mymagenta}{|}}\gamma_i \mapsto \gamma_{i-1}\gamma_i$) decreases the number of letters by one. However, the difference is not visible at the level of functions on $\mathbf{A}$. That is, $\gamma[\mathbf{A}] = \phi(\gamma)[\mathbf{A}]$. This completes the proof.
\end{proof}

\begin{corollary}The set $\{p(\mathbf{A}) \mid \mathbf{A}\in\bm{\dot\Pi}\}$ comprises irredundant (algebraically independent) generators of the Lie algebra of primitive elements of $\textsl{NCSym}$.
\end{corollary}

\begin{proof}
First we show algebraic independence of $\{p(\mathbf{A}) \mid \mathbf{A}\in\bm{\dot\Pi}\}$. Let $<$ be a total order on the set $\bm{\dot\Pi}$ satisfying $\mathbf{A} < \mathbf{A}'$ when $|\mathbf{A}|>|\mathbf{A}'|$. If we extend $<$ to a lexicographic ordering of $\bm\Pi$ in the usual manner, then the leading (minimum) term of $p(\mathbf{A})$ is $\mathbf{A}$. (As remarked in the proof above, the only term in $p(\mathbf{A})$ with one atom is $\mathbf{A}$.) Conclude that any polynomial in the $p(\mathbf{A})$s ($\mathbf{A}\in \bm{\dot\Pi}$) has the same leading term as the corresponding polynomial in the $\mathbf{A}$s. Hence the $p(\mathbf{A})$s freely generate $\textsl{NCSym}$.

Turning to the Lie algebra of primitive elements in $\textsl{NCSym}$, we recall the construction of Hall polynomials.
Given an ordered alphabet $X$ and a word $w=x_1\dotsc x_t$ over $X$, we say that $w$ is a \demph{Lyndon word} if $w$ is lexicographically smaller than all its proper suffixes $x_i\dotsb x_t$ ($i>1$). A classical result has that all Lyndon words $w$ have a unique proper decomposition $w=uv$ with $v$ Lyndon of maximum length. See \cite{Reu:1993}. We define the Hall polynomial $[[w]]$ by forming the Lie bracket $[u,v]$ at successively smaller Lyndon factorizations. For example, if $w=aabb$, then the Lyndon factorization of $w$ is $(a,abb)$; next, $abb$ is further factored as $(ab,b)$ and $ab$ is factored as $(a,b)$. The resulting Hall polynomial is $[[w]] = [a,[[a,b],b]]$.

If $w$ is Lyndon, then the leading term of $[[w]]$ is $w$. A consequence is the classical result that the Hall polynomials $\{[[w]] \mid w\hbox{ is Lyndon}\}$ form a basis of the free Lie algebra generated by $X$. Turning to $\textsl{NCSym}$, the first paragraph of the proof shows that we may replace the alphabet $\bm{\dot\Pi}$ with the alphabet $\{p(\mathbf{A}) \mid \mathbf{A} \in \bm{\dot\Pi}\}$. Conclude that the Hall polynomials
$[[p(\mathbf{A}')p(\mathbf{A}'')\dotsb p(\mathbf{A}^{(t)})]]$, with $\mathbf{A}'{\textcolor{mymagenta}{|}} \mathbf{A}''{\textcolor{mymagenta}{|}} \dotsb{\textcolor{mymagenta}{|}} \mathbf{A}^{(t)}$ Lyndon in the atoms $\mathbf{A}^{(i)}$, form a basis of the Lie algebra of primitive elements in $\textsl{NCSym}$.
\end{proof}

\subsection{The antipode of $\textsl{NCSym}$}\label{sec: ncsym antipode}
We aim to prove the following result.

\begin{theorem}\label{thm: ncsym antipode}
Suppose $\mathbf{A}$ is a set partition with $r$ parts and let $\bm\Gamma(r)$ denote the set compositions of $[r]$. The antipode $S$ of $\textsl{NCSym}$ acts on $\mathbf{A}$ by
\begin{gather}\label{eq: ncsym antipode}
S({\mathbf{A}}) = \sum_{\gamma\in\bm\Gamma(r)} (-1)^{\length{\gamma}} \gamma[\mathbf{A}] \,.
\end{gather}
\end{theorem}

\begin{remarks} {\it 1.} This description of the antipode typically contains many cancellations. For example, it says that
$S(12.3) = -(12.3) + (12.3) + (1.23)$.
There may even be cancellations when $\mathbf{A}$ is atomic. We invite the reader to compute $S(14.2.3)$, which {\it a priori} has 13 terms, but in fact has only nine.
On the other hand, \eqref{eq: ncsym antipode} is irredundant for many atomic $\mathbf{A}$.
\smallskip

{\it 2.} In case $\mathbf{A}$ is not atomic, we can do better. Suppose $\mathbf{A}=\mathbf{A}'{\textcolor{mymagenta}{|}}\mathbf{A}''{\textcolor{mymagenta}{|}}\dotsb{\textcolor{mymagenta}{|}}\mathbf{A}^{(t)}$ is a splitting of $\mathbf{A}$ into atomic pieces, and let $\length{\mathbf{A}^{(i)}} = r_i$ with $\sum_i r_i = r$. Finally, let $\bm\Gamma(\overleftarrow r)$ denote all refinements of the set composition
\[
	\overleftarrow r = \bigl(\{r{-}r_t{+}1,\dotsc,r\},\dotsc,\{r_1{+}1,\dotsc,r_1{+}r_2\},\{1,\dotsc,r_1\}\bigr) .
\]
Then
\begin{gather}\label{eq: alternate antipode}
	S(\mathbf{A}) = \sum_{\gamma\in\bm\Gamma(\overleftarrow r)} (-1)^{\length{\gamma}} \gamma[\mathbf{A}] \,.
\end{gather}
This follows immediately from the fact that $S$ is an algebra antimorphism and \eqref{eq: ncsym antipode} holds on atomic set partitions. Using this formula, we may express $S(13.2.4)$ using three terms, $S(13.2.4) = (1.24.3) - (1.23.4) - (1.2.34)$. Using \eqref{eq: ncsym antipode} would have required us to write down 13 terms, 10 of which would cancel.
The relationship between \eqref{eq: alternate antipode} and Theorem 14.31 of \cite{AguMah:1} will be explored in \cite{LauMas:1}.
\end{remarks}

\begin{proof}[Proof of Theorem \ref{thm: ncsym antipode}]
Since the antipode is guaranteed to exist in graded connected bialgebras, we need only check that \eqref{eq: ncsym antipode} provides a left convolution inverse of $\mathrm{id}$. Writing $m$ for multiplication in $\textsl{NCSym}$, we have
\begin{align*}
m(S\otimes\mathrm{id})\Delta(\mathbf{A}) &= m(S\otimes\mathrm{id})\left(\sum_{K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L=[r]} \std{\mathbf{A}_K} \otimes \std{\mathbf{A}_L}\right)
= m(S\otimes\mathrm{id})\left(\sum_{K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L=[r]} K[\mathbf{A}]\otimes L[\mathbf{A}]\right)  \\
\intertext{(viewing $K$ and $L$ as set compositions with one part)}
 &= m \sum_{K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L=[r]} \left(\sum_{\gamma\in\bm\Gamma_{|K|}} (-1)^{\length{\gamma}}\gamma[K[\mathbf{A}]]\right)\otimes L[\mathbf{A}] \\
&= \left(\sum_{K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L=[r]} \sum_{\gamma\in\bm\Gamma_{K}} (-1)^{\length{\gamma}}(\gamma\bm| L)\right) \! [\mathbf{A}] \,.
\end{align*}
We show that this sum is the zero function on $\mathbf{A}$. We have
\begin{align*}
\sum_{K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L=[r]} \sum_{\gamma\in\bm\Gamma_{K}} (-1)^{\length{\gamma}}(\gamma\bm| L) &=
	\sum_{\gamma\in\bm\Gamma_{[r]}} (-1)^{\length{\gamma}}\gamma \ \  + \
	\sum_{\substack{K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L=[r] \\ K\neq[r]}} \sum_{\gamma\in\bm\Gamma_{K}} (-1)^{\length{\gamma}}(\gamma\bm| L) \\
&= 	\sum_{\emptyset\subsetneq L\subseteq[r]}\sum_{\substack{\gamma\in\bm\Gamma_{[r]}\\ \gamma=\gamma'\bm| L}} (-1)^{\length{\gamma'\bm| L}}(\gamma'\bm| L) \ \ -
	\sum_{\substack{K\mathrel{\ensuremath{\mathaccent\cdot\cup}} L=[r] \\ K\neq[r]}} \sum_{\gamma\in\bm\Gamma_{K}} (-1)^{\length{\gamma\bm| L}}(\gamma\bm| L) \\
&= 0 \,,
\end{align*}
as claimed. We conclude that $m(S\otimes\mathrm{id})\Delta(\mathbf{A}) = 0$ for $|\mathbf{A}|>0$, which completes the proof.
\end{proof}

\section{Summary Remarks}\label{sec: summary}

\subsection{Supercharacter theory}\label{sec: SC}
Let $\mathbb{F}_q$ be a finite field with $q$ elements. The classification problem for irreducible representations of the upper triangular groups $U_n(\mathbb{F}_q)$ is known to be of wild type. After the work of Andr\'e and Yan \cite{And:1995,Yan:1}, it seems a good first step at understanding the character theory of $U_n(\mathbb{F}_q)$ is to study its \emph{supercharacters} and \emph{superclasses}. Superclasses are formed by clumping together certain conjugacy classes of $U_n(\mathbb{F}_q)$. To each superclass is associated a supercharacter, which is the corresponding sum of characters. See \cite{DiaIsa:2008} for an excellent exposition by Diaconis and Isaacs.

Following this approach to the problem, and mimicing the classical constructions in the representation ring of the symmetric groups, Thiem \cite{Thi:2010} gave the space of supercharacters $\mathcal{SC}_q$ a Hopf algebra structure, with product and coproduct coming from superinflation and restriction.\footnote{More precisely, the coproduct is not explicitly defined there, nor is the product / coproduct compatibility checked, but these were subsequently verified  by Thiem (private communication). The details of his Hopf algebra construction will appear in the report \cite{AIM}.} The result was something that bore a strong resemblance to $\textsl{NCSym}$ for $q=2$. One of the main topics of the AIM workshop \cite{AIM} was to explore this connection and see what could be said for $q$ arbitrary. Quite a lot of progress was made in several directions. Relevant to the present discussion is that $\mathcal{SC}_2$ is indeed isomorphic to $\textsl{NCSym}$ as Hopf algebras.

The isomorphism above is straightforward, simply taking superclass functions $\kappa_\mathbf{A}$ to monomial symmetric functions $m_\mathbf{A}$. (See \cite{Thi:2010} and \cite{BRRZ:2008} for notation.)
In light of this, it would be very interesting to have analogs of \eqref{eq: ncsym primitives} and \eqref{eq: ncsym antipode} for the monomial basis. Some exciting progress was made in this direction on the last day of the workshop, but some details still need to be checked before any formal statement can be made \cite{Nantel}.

\subsection{Transfer of structure}\label{sec: transfer}
In Section \ref{sec: ncsym}, we used the idea of set compositions as functions on set partitions to formulate our results. As the proofs of these results indicate, this idea can be mined further. There is a graded connected cocommutative Hopf algebra structure on $\mathbb{Q}\mathbf{P}$ which is freely generated as an algebra by $\mathrm{fin}(2^\mathbb{P})$. Formulas for primitives and the antipode in $\mathbb{Q}\mathbf{P}$ mimic \eqref{eq: ncsym primitives} and \eqref{eq: ncsym antipode}.

More is true. In fact, the $\mathbb{Q}\mathbf{P}$ formulas engender \eqref{eq: ncsym primitives} and \eqref{eq: ncsym antipode} via a transfer of structure coming from a \emph{measuring} of Hopf algebras. We leave the details to \cite{LauMas:1}, where further examples of transfer of structure will be worked out. We quote a key theorem from that work.

\begin{theorem}\label{thm: transfer}
Let $A, B$ be Hopf algebras and let $C$ be a coalgebra. Suppose $\theta
\colon  B\otimes C\to A$ is a \emph{covering} (a surjective coalgebra map that \emph{measures} $B$ to $A$). Let $\iota \colon A\to B\otimes C$ be any linear section of $\theta$, that is, $\theta\circ \iota = \mathrm{id}$.
Then the following hold.
\begin{enumerate}
\item\label{itm: primitive} If $p\in B$ is primitive, then for every $c\in C$ the element $\theta(p,c)\in A$ is primitive.
\item\label{itm: antipode} $S_A = \theta\circ (S_B\otimes\mathrm{id})\circ \iota$.
\end{enumerate}
\end{theorem}

Here, $\mathbb{Q}\mathbf{P}$ covers $\textsl{NCSym}$ by taking $C$ to be the free pointed coalgebra on set partitions; the covering $\theta(\gamma\otimes \mathbf{A})$ is the evaluation $\gamma[\mathbf{A}]$ discussed
in Section \ref{sec: functions}. In \cite{LauMas:1}, we also discuss coverings by $\textsl{NSym}$, where $\textsl{NSym}$ is the Hopf algebra of noncommutative symmetric functions \cite{GKLLRT:1995} freely generated by symbols $H_n$ that comultiply as
\[
	\Delta(H_n) = \sum_{i+j=n} H_i \otimes H_j \,.
\]
Such coverings exist for every graded cocommutative Hopf algebra $A$ and are given by setting $C$ to be the underlying coalgebra of $A$ and $\theta$ to be the unique covering for which $\theta(H_n \otimes a) := \pi_n(a)$, where $\pi_n$ is the projection to the $n^\mathrm{th}$ graded component of $A$.
Again, primitive and antipode formulas in $\textsl{NSym}$ are transfered via Theorem \ref{thm: transfer}. Formula \eqref{itm: antipode} in the theorem simply recovers Takeuchi's formula for the antipode, whereas Formula \eqref{itm: primitive} is used to obtain Takeuchi-type formulas for primitives in $A$. In particular, we obtain generators for the space of primitives (analogous to Theorem \ref{thm: ncsym primitives}) as well as a projection onto the space of all primitives.

\bibliographystyle{abbrv}


\section{Introduction}\label{sec:intro}
This paper is aim to study statistics on bounded permutations and $213$-avoiding bounded permutations.

Let us give an overview of notation and terminology first.
Denote by $S_n$  the set of the permutations of $[n]$, where $[n]=\{1,2,\ldots,n\}$.
For a permutation $\pi=\pi_1 \pi_2 \cdots \pi_n$ in $S_n$,
a pair $(\pi_i,\pi_j)$ is called an inversion if $i<j$ and $\pi_i>\pi_j$.
Let $\inv(\pi)$ denote the number of inversions of $\pi$.
An element $i$ is called a descent of $\pi$ if $\pi_i >\pi_{i+1}$ and the descent number $\des(\pi)$ is defined to be the number of the descents of $\pi$. We say $i$ is an excedance of $\pi$ if $\pi_i > i$. While, $i$ is called
a weak excedance of $\pi$
if $\pi_i \geq i$.  Otherwise, $i$ is called a non-weak excedance.
Any permutation
statistics with the same distribution as $\inv$ are referred to as Mahonian statistics, while those equidistributed
with  $\des$ and the excedance number are called Eulerian statistics.

Given a word $w=w_1 w_2 \cdots w_n$  of length $n$, let
\begin{align*}
  \Lmap(w) &= \{i\colon w_j <w_i \text{ for all } j<i \}, \\
 \Lmal(w) &=  \{w_i \colon w_j <w_i \text{ for all } j<i \}, \\
  \Rmip(w) &= \{i\colon w_j >w_i \text{ for all } j>i \},\\
  \Rmil(w) &= \{w_i \colon w_j >w_i \text{ for all } j>i \}, \\
  \Rmal(w) &= \{w_i\colon w_j <w_i \text{ for all } j>i \}
\end{align*}
be the set of left-to-right maximum places, left-to-right maximum letters,
right-to-left minimum positions, right-to-left minimum letters  and
right-to left maximum letters respectively.
Their corresponding numerical statistics are denoted by
$\lmax(w) = \# \Lmal(w)$, $\rmin(w) = \#\Rmil(w)$ and
$\rmax(w) = \# \Rmal(w).$

Besides the linear orders, permutations can be also seen as functions.
For example, we may consider $\sigma=34152$ as a function $\sigma \colon [5] \to [5]$ with $
\sigma(1)=3,
\sigma(2)=4, \sigma(3)=1, \sigma(4)=5$ and $\sigma(5)=2$.
Thus, we can write $\sigma=(13)(245)$  and call it a cycle notation of $\sigma$.
Assume that $\sigma=\sigma_1 \sigma_2 \cdots \sigma_n$ and the bijection
$i \mapsto \sigma_i$ has $r$ disjoint cycles, whose minimum elements are $c_1, c_2,\ldots, c_r$.
Let $\Cyc(\sigma)=\{c_1, c_2,\ldots, c_r\}$  and the number of cycles of $\sigma$, $\cyc(\sigma)$, is defined to be the cardinality of $\Cyc(\sigma)$.

An occurrence of a classical pattern $p$ in a permutation $\sigma$ is a subsequence of $\sigma$ that is order-isomorphic to $p$.  Babson and Steingr\'{i}msson \cite{BS} generalized the notion of permutation patterns, to what are now known as vincular patterns, see \cite{Kitaev2011}.
 Adjacent letters in a vincular pattern which are
 underlined must stay adjacent when they are placed  back to the original permutation.
 For an instance, $41253$  contains only one occurrence of the vincular pattern $\underline{31}42$ in its subsequence $4153$, but not in $4253$.

Motivated by juggling sequence and bubble sort, Chung, Claesson, Dukes and Graham \cite{ChungClaesson} introduced the maximum drop size statistic on permutations. For more about bounded permutations, see \cite{ChungGraham, Joanna, Hyatt}.
We say that $\pi \in S_n$ has a drop at $i$ if $\pi_i <i$ and the drop size is meant to be $i-\pi_i$.
The maximum drop size of $\pi$ is defined by
\begin{equation*}
\mathrm{maxdrop(\pi)}=\max\{i-\pi_i\colon 1 \leq i \leq n\}.
\end{equation*}
Let $A(n,k)=\{\pi \in S_n \colon \maxdrop(\pi) \leq k\}$.
For convenience, we call permutations with bounded drop size
the bounded permutations.

Petersen\cite{Petersen} introduced a new  statistic, which is called the sorting index. Given a permutation $\pi$ in $S_n$, it is known that $\pi$
has a unique decomposition into transpositions
\[\pi=(i_1,j_1)(i_2,j_2)\cdots (i_k,j_k),\]
where
\[j_1<j_2< \cdots <j_k\]
and
\[i_1<j_1,i_2<j_2,\ldots,i_k<j_k.\]
The sorting index is defined by
\[\mathrm{sor(\pi)}=\sum_{r=1}^{k}(j_r-i_r).\]

Petersen showed that the sorting index is Mahonian.
Moreover, by using two different factorizations of $\sum_{\pi \in S_n} \pi$, he derived that
\begin{equation*}
    \sum_{\pi \in S_n} q^{\mathrm{sor(\pi)}}t^{\mathrm{cyc(\pi)}}=\sum_{\pi \in S_n} q^{\mathrm{inv(\pi)}}t^{\mathrm{rmin(\pi)}}=\prod_{i=1}^{n}
    (t+[i]_q-1),
\end{equation*}
where $[i]_q=1+q+\cdots+q^{i-1}$.

Based on the standard algorithm for generating a random permutation, Wilson\cite{wilson2010} defined a permutation statistic $\DIS$. It turns out that for a permutation $\pi$ in $S_n$, we have $\DIS(\pi^{-1})=\sor(\pi)$.
The first of our main results in this paper is to generalize Petersen's results to   bounded permutations, which are stated as
follows.

\begin{theorem}\label{thm:tha}
For $0 \leq k<n$, $(\inv,\lmax)$ and $(\DIS,\cyc)$ have the same joint distribution over $A(n,k)$. Moreover,  we have
\begin{equation*}
     \sum_{\sigma \in A(n,k)} q^{\inv(\sigma)}t^{\lmax(\sigma)}=\sum_{\sigma \in A(n,k)} q^{\DIS(\sigma)}t^{\cyc(\sigma)}=(t+[k+1]_q-1)^{n-k}
     \prod_{i=1}^{k}(t+[i]_q-1).
\end{equation*}
\end{theorem}
Moreover, we will show that a bijection constructed by Foata and Han \cite{Han} can be restricted to give an explanation of the equidistribution above.

Hyatt and Remmel \cite{HyattRemmel} initialed
the study of pattern avoiding bounded permutations. They gave the number of $231$-avoiding bounded permutations with $j$ descents.
 Our second main result is concerned with
 the distribution of descents over $213$-avoiding bounded permutations.
Let $A_{n,k}(\sigma)$
 denote the set of $\sigma$-avoiding permutations in $A(n,k)$.
 We have the following proposition.

\begin{proposition}\label{prop:213ballot}
For $0 \leq k \leq n$, we have $A_{n,k}(213)$ is enumerated by the
ballot number $C_{n,k}$, where
\[C_{n,k}=\frac{n-k+1}{n+1}{{n+k}\choose{k}}.\]
\end{proposition}

Let $S_n^k(321)$ be the set of $321$-avoiding permutations of length $n$ with the last element $k+1$. Lin and Kim \cite{LinKim}
mentioned that  $S_{n+1}^k(321)$ is enumerated by $C_{n,k}$.
Bailey \cite{Bailey} introduced non-negative $n,k$-arrangements
of $1$'s and $-1$'s. Assume that $\Gamma_{n,k}$ is the set of sequences with non-negative partial sums that can be formed by
 $n$ $1$'s and $k$ $-1$'s. Namely, given $a=a_1 a_2 \cdots a_{n+k} \in \Gamma_{n,k}$, we have $a_1+\cdots +a_{i} \geq 0$ for $1 \leq i \leq n+k$. Bailey showed that $\Gamma_{n,k}$ is also counted by
 $C_{n,k}$.

Let $\vnw(\pi)$ be the number of the non-weak excedances  that are before the last element of $\pi$.
For $a \in \Gamma_{n,k}$, let $\vpk(a)$ be the number of $a_i=1$ such that $a_i$ is not the rightmost $1$ and $a_{i+1}=-1$ for $1 \leq i \leq n+k-1$.
It should be mentioned that
$a$ can be also seen as a ballot path from $(0,0)$ to $(n,k)$,
while the statistic $\vpk$ can be seen as a variation of  the number of NE-turns over ballot paths as studied by Su \cite{Su}.

We will show a stronger equidistribution
over $A_{n,k}(213)$, $S_{n+1}^k(321)$ and $\Gamma_{n,k}$.

\begin{theorem}\label{thm:equidis}
Statistic $\des$ over $A_{n,k}(213)$,
statistic $\vnw$ over $ S^k_{n+1}(321)$ and statistic $\vpk$ over $ \Gamma_{n,k}$ are equally distributed.
\end{theorem}

\begin{theorem}\label{thm:generating}
Let
\[G(p,q,z)=\sum_{\pi \in A_{n,k}(213),\, 0 \leq k \leq n}p^{\des(\pi)} q^{k}z^n,  \]
then we have
\begin{align}
G(p,q,z)=\frac{1-pqz-(1-z)q+(zq-pqz-q)\widetilde{F}_0}{1-z-pqz-(1-z)q}, \label{eq:main}
\end{align}
where
\[
\widetilde{F}_0=\frac{1-zq(1+p)-\sqrt{(1+zq(1-p))^2-4zq}}{2pqz}.
\]
\end{theorem}

The outline of this paper is as follows. In Section \ref{sec:TH1}, we shall prove Theorem~\ref{thm:tha} algebraically and bijectively.
In Section \ref{sec:TH23}, we will investigate
$A_{n,k}(213)$ as well as the distributions of $\des$
over $A_{n,k}(213)$.

\section{A proof of Theorem~\ref{thm:tha}}\label{sec:TH1}

In this section, we will give two different factorizations of $\sum_{\sigma \in S(n,k)} \sigma$ by maintaining Petersen's method,
where
$$S(n,k)=\{\sigma \in S_n \colon \max_i(\sigma_i-i )\leq k\}.$$
These two factorizations allow us to give a proof of Theorem \ref{thm:tha}.

Recall that both the set of transpositions $T=\{(i,j) \colon 1 \leq i<j \leq n \}$
and the set of adjacent transpositions $S=\{(i,i+1)\colon 1\leq i \leq n-1\}$
are  generating sets for $S_n$. For convenience, we write $t_{i,j}=(i,j)$ and $s_i=(i,i+1)$.  The readers are recommended to see \cite{Brenti} for a comprehensive introduction.

Given a permutation $\pi$ in $S_{n-1}$, in order to generate a permutation in $S_n$, we may insert $n$ in all
possible positions of $\pi$. This can be performed analogously to
generate a permutation in $S(n,k)$ from $S(n-1,k)$.
Clearly, $S(n,k)=S_n$ when $n \leq k$ and $S(n,0)=12 \cdots n$.
Hence, we need only to consider the cases when $0 < k < n$.
In terms of the group algebra, for  $0 < k < n$, we define
\begin{equation*}
\Psi_{i,k}= \left\{
  \begin{array}{ll}
1+s_i + s_i s_{i-1}+ \cdots +s_i s_{i-1} \cdots s_1, & \mbox{ $0<i<k$,}\\[6pt]
1+s_i + s_i s_{i-1}+ \cdots +s_i s_{i-1} \cdots s_{i+1-k}, & \mbox{ $k \leq i \leq n-1$.}
 \end{array} \right.
\end{equation*}
Notice that each element in $\Psi_{i,k}$ can be seen as a reduced expression in $S_{i+1}$.

\begin{lemma}
For $n \geq 2$ and $0< k< n$, we have
\begin{equation}\label{eq:PSI}
  \sum_{w \in S(n,k)}w=\Psi_{1,k}\Psi_{2,k}\cdots\Psi_{n-1,k}.
\end{equation}
\end{lemma}

\begin{proof}
 We will give a proof by induction on $n$. It is clear that $\sum_{w \in S(2,k)} w=\Psi_{1,k}$. We assume that
equation (\ref{eq:PSI}) holds for $n=m-1$, namely,
\begin{equation}\label{eq:induction_m-1}
  \sum_{u \in S(m-1,k)} u=\Psi_{1,k}\Psi_{2,k}\cdots\Psi_{m-2,k}.
\end{equation}
We proceed to prove that it holds for $n=m$.
Clearly, we can identify the elements in $S(m-1,k)$ with the set $$\{\sigma \in S(m,k) \colon \sigma(m)=m\}.$$
Assume that $\sigma=\sigma_1\sigma_2\cdots \sigma_{m-1}m \in  S(m,k)$,
there are two cases to consider.
If $k > m-1$, then we have
\begin{align*}
 \sigma \cdot \Psi_{m-1,k}&= \sigma+ \sigma s_{m-1}+ \cdots +\sigma s_{m-1} s_{m-2} \cdots s_1 \\
  &=\sigma_1\sigma_2\cdots \sigma_{m-1}m+\sigma_1\sigma_2\cdots m\sigma_{m-1}+ \cdots +m\sigma_1\sigma_2\cdots \sigma_{m-1}.
\end{align*}
If $k < m$,  we have
\begin{align*}
 \sigma \cdot \Psi_{m-1,k}&= \sigma+ \sigma s_{m-1}+\sigma s_{m-1} s_{m-2} \cdots +\sigma s_{m-1} s_{m-2} \cdots s_{m-k} \\
  &=\sigma_1\sigma_2\cdots \sigma_{m-1}m+\sigma_1\sigma_2\cdots m\sigma_{m-1}+ \cdots + \sigma_1\sigma_2\cdots\sigma_{m-k-1} m \sigma_{m-k}\cdots  \sigma_{m-1}.
\end{align*}
Note that $m$ appears at
all possible positions in the above two cases such that $max_i\{\pi_i -i \}\leq k$. Hence, we have
\begin{equation}\label{eq:induction_m}
\sum_{w \in S(m,k)} w=\sum_{\sigma \in S(m,k), \sigma(m)=m} \sigma \cdot \Psi_{m-1,k}= \sum_{u \in S(m-1,k)} u \cdot \Psi_{m-1,k}.
\end{equation}
Then, equation (\ref{eq:PSI}) follows from (\ref{eq:induction_m-1})
and (\ref{eq:induction_m}). This completes the proof.
\end{proof}

Based on the factorization above, we obtain the following theorem.
\begin{theorem}\label{tha1}
For $n \geq 1$ and $0< k \leq  n$, we have
\begin{equation}\label{eq:orign}
\sum_{\sigma \in A(n,k)} q^{\mathrm{inv(\sigma)}}t^{\mathrm{lmax(\sigma)}}=(t+[k+1]_q-1)^{n-k}
     \prod_{i=1}^{k}(t+[i]_q-1).
\end{equation}
\end{theorem}

\begin{proof}
It is easy to see that  $\sigma \in A(n,k)$ if and only if
$\sigma^{-1} \in S(n,k)$ and  $lmax(\sigma)=rmin(\sigma^{-1})$.
It follows that
 \[\sum_{\sigma \in A(n,k)} q^{\mathrm{inv(\sigma)}}t^{\mathrm{lmax(\sigma)}}
 =
 \sum_{\sigma \in S(n,k)} q^{\mathrm{inv(\sigma)}}t^{\mathrm{rmin(\sigma)}}.
 \]
 Hence, to prove (\ref{eq:orign}), it suffices to show that
 \begin{equation}\label{eq:suffice}
 \sum_{\sigma \in S(n,k)} q^{\mathrm{inv(\sigma)}}t^{\mathrm{n-rmin(\sigma)}}=(1+t[k+1]_q-t)^{n-k}
     \prod_{i=1}^{k-1}(1+t[i+1]_q-t).
 \end{equation}

Let $\varphi$  be a linear map from $\mathbb{Z}[S(n,k)]$
to $\mathbb{Z}[q,t]$ such that $\mathrm{\varphi(\sigma)=q^{inv(\sigma)}t^{n-rmin(\sigma)}}$.
By the definition of $\Psi_{i,k}$, we see that
\begin{equation}\label{eq:varphipsi}
\varphi(\Psi_{i,k})= \left\{
  \begin{array}{ll}
 1+qt+\cdots +q^i t, & \mbox{ $0<i<k$},\\[6pt]
 1+qt+\cdots +q^k t, & \mbox{ $k \leq i \leq n-1$}.
 \end{array} \right.
\end{equation}

For $u \in S(i,k)$ with $u_i=i$ and $k+1 \leq i \leq n$, we deduce that
\begin{align*}
  \varphi(u \cdot \Psi_{i-1,k}) &= \varphi(u)+ \varphi(u s_{i-1})+\varphi(u s_{i-1} s_{i-2}) + \cdots +\varphi(u s_{i-1} s_{i-2} \cdots s_{i-k})\\[3pt]
   &=\varphi(u)+qt\varphi(u)+q^2t\varphi(u)+
   \cdots+q^kt\varphi(u)\\[3pt]
&=\varphi(u) \varphi(\Psi_{i-1,k}).
\end{align*}
Similarly, we may show that $\varphi(u \cdot \Psi_{i-1,k})=\varphi(u) \varphi(\Psi_{i-1,k})$  for $1 < i \leq k$.

Hence, we deduce that
\begin{align*}
   \varphi(\Psi_{1,k}\Psi_{2,k} \cdots \Psi_{n-1,k})  & =\varphi(\sum_{w \in S(n,k),w_n=n} w \cdot\Psi_{n-1,k} )  \\[3pt]
    &=\sum_{w \in S(n,k),w_n=n} \varphi(w \cdot\Psi_{n-1,k} ) \\[3pt]
    &=\sum_{w \in S(n,k),w_n=n} \varphi(w) \varphi(\Psi_{n-1,k} )\\[3pt]
    &=\varphi(\sum_{w \in S(n,k),w_n=n} w) \varphi(\Psi_{n-1,k} )\\[3pt]
    &=\varphi(\Psi_{1,k}\Psi_{2,k} \cdots \Psi_{n-2,k})\varphi(\Psi_{n-1,k} ).
\end{align*}
Then, (\ref{eq:suffice}) follows from (\ref{eq:varphipsi}).
\end{proof}

By setting $t=1$ in (\ref{eq:orign}), we deduce the following corollary, which coincides with Corollary 2.2
in \cite{ChungClaesson}.
\begin{corollary}
For $n \geq 1$ and $0< k \leq  n$, we have
\begin{equation*}
\sum_{\sigma \in A(n,k)} q^{\mathrm{inv(\sigma)}} =[k+1]_q ^{n-k} [k]_q! .
\end{equation*}
\end{corollary}

Analogously, we proceed to give another factorization of $\sum_{\sigma \in S(n,k)} \sigma$.
For  $0 < k < n$, we define
\begin{equation*}
   \Phi_{i,k}=
   \begin{cases}
  1+t_{i,i+1} + t_{i-1,i+1} + \cdots + t_{1,i+1}; & \mbox{ $0<i < k$}\\
  1+t_{i,i+1} + t_{i-1,i+1} + \cdots + t_{i+1-k,i+1}. & \mbox{ $k \leq i \leq n-1$}\\
   \end{cases}
\end{equation*}

The following lemma shows that how each element in $S(n,k)$
can be generated in terms of the minimal length product of reflections.

\begin{lemma} \label{fac_a2}
For $n \geq 2$ and $0< k< n$, we have
\begin{equation}\label{eq:PHI}
  \sum_{\sigma \in S(n,k)} \sigma=\Phi_{1,k}\Phi_{2,k}\cdots\Phi_{n-1,k}.
\end{equation}
\end{lemma}

\begin{proof}
We will give a proof by induction. Clearly,  $\sum_{\sigma \in S(2,k)} \sigma=\Phi_{1,k}$. We assume that
equation (\ref{eq:PHI}) holds for $n=m-1$.
Now we need to prove that it holds for $n=m$.
Recall that given an element $\sigma=\sigma_1\cdots \sigma_{m-1} $ in $S(m-1,k)$, we may identify  $\sigma$ with the permutation $ \sigma_1 \sigma_2\cdots \sigma_{m-1}m.$ We consider two cases.
If $k > m-1$, then we have
\begin{align*}
 \sigma \cdot \Phi_{m-1,k}&= \sigma+ \sigma t_{m-1,m}+ \cdots +\sigma t_{1,m} \\
  &=\sigma_1\sigma_2\cdots \sigma_{m-1}m+\sigma_1\sigma_2\cdots m\sigma_{m-1}+ \cdots +m\sigma_2\cdots \sigma_{m-1}\sigma_{1}.
\end{align*}
If $ k< m$, then we have
\begin{align*}
 \sigma \cdot \Phi_{m-1,k}&= \sigma+ \sigma t_{m-1,m}+ \cdots +\sigma t_{m-k,m} \\
  &=\sigma_1\sigma_2\cdots \sigma_{m-1}m+\sigma_1\sigma_2\cdots m\sigma_{m-1}+ \cdots + \sigma_1\sigma_2\cdots\sigma_{m-k-1} m \sigma_{m-k+1}\cdots \sigma_{m-1}\sigma_{m-k}.
\end{align*}
Notice that in the second case, the position of $m$ is restricted.
It can only change the position with $\sigma_{m-k},\sigma_{m-k+1}, \ldots, \sigma_{m-1}$.
Thus each element $\pi$ in the above sum satisfy that $max_i\{\pi_i -i \}\leq k$.
Hence, we deduce that
$$
\sum_{w \in S(m,k)} w=\sum_{\sigma \in S(m,k), \sigma(m)=m} \sigma \cdot \Phi_{m-1,k}=\Phi_{1,k}\Phi_{2,k}\cdots\Phi_{m-1,k}.$$
\end{proof}

The factorization above leads to the following theorem.
\begin{theorem} \label{tha2}
For $n \geq 1$ and $0< k \leq  n$, we have
\begin{equation}\label{eq:orign2}
\sum_{\sigma \in A(n,k)} q^{\mathrm{DIS(\sigma)}}t^{\mathrm{cyc(\sigma)}}=(t+[k+1]_q-1)^{n-k}
     \prod_{i=1}^{k}(t+[i]_q-1).
\end{equation}
\end{theorem}

\begin{proof}
Since $\mathrm{sor(\sigma^{-1})=DIS(\sigma)}$  and $\mathrm{cyc(\sigma)=cyc(\sigma^{-1})}$,
it suffices to show that
 \begin{equation}\label{eq:suffice2}
 \sum_{\sigma \in S(n,k)} q^{\mathrm{sor(\sigma)}}t^{n-\mathrm{cyc(\sigma)}}=(1+t[k+1]_q-t)^{n-k}
     \prod_{i=1}^{k-1}(1+t[i+1]_q-t).
 \end{equation}

Let $\phi$  be a linear map from $\mathbb{Z}[S(n,k)]$
to $\mathbb{Z}[q,t]$ such that $\mathrm{\phi(\sigma)=q^{sor(\sigma)}t^{n-cyc(\sigma)}}$.
From the construction, it is easily seen that
\begin{equation*}
  \phi(\Phi_{i,k})=
   \begin{cases}
  1+qt+\cdots +q^i t; & \mbox{ $0<i<k$}\\
  1+qt+\cdots +q^k t. & \mbox{ $k \leq i \leq n-1$}\\
   \end{cases}
\end{equation*}

Let $\sigma=\sigma_1\sigma_2\cdots\sigma_m$ with $\sigma_m=m$.
When exchange the position of $\sigma_m$ and $\sigma_i$, we investigate how the statistics $\mathrm{sor}$ and $\mathrm{cyc}$ behaves in $\sigma$. It is easily seen that
the statistic  $\mathrm{sor}$ is increased by $m-i$.
If $i=m$,
the statistic  $\mathrm{cyc}$ remains the same.
If $i<m$,   $\mathrm{cyc}$ is decreased by $1$.

Assume that $u \in S(i,k)$ with $u_i=i$ and $k+1 \leq i \leq n$. We can verify that
\begin{align*}
  \phi(u \cdot \Phi_{i-1,k}) & =\phi(u)+\phi(ut_{i-1,i})+ \cdots + \phi(ut_{i-k,i}) \\[3pt]
   &=\phi(u)+qt\phi(u)+\cdots+q^kt\phi(u)\\[3pt]
   &=\phi(u) \phi(\Phi_{i-1,k}).
\end{align*}
Similarly, we may prove that $ \phi(u \cdot \Phi_{i-1,k})=\phi(u) \phi(\Phi_{i-1,k})$ for $1<i \leq k$.

Hence, we deduce that $\phi(\Phi_{1,k}\Phi_{2,k} \cdots \Phi_{n-1,k})=\phi(\Phi_{1,k})\phi(\Phi_{2,k}) \cdots \phi(\Phi_{n-1,k})$.
It follows that
\begin{align*}
  \sum_{\sigma \in S(n,k)} q^{\mathrm{sor(\sigma)}}t^{\mathrm{n-cyc(\sigma)}} & =\phi(\sum_{\sigma \in S(n,k)} \sigma) \\[3pt]
  &=\phi(\Phi_{1,k}\Phi_{2,k} \cdots \Phi_{n-1,k}) \\[7pt]
  &=\phi(\Phi_{1,k})\phi(\Phi_{2,k}) \cdots \phi(\Phi_{n-1,k})\\[3pt]
  &=(1+t[k+1]_q-t)^{n-k}
     \prod_{i=1}^{k-1}(1+t[i+1]_q-t).
\end{align*}
This completes the proof.
\end{proof}

Combining Theorem \ref{tha1} and Theorem \ref{tha2}, we
give a proof of Theorem \ref{thm:tha}.

It should be mentioned that Chen, Gong and Guo\cite{Chen}
found that a bijection on $S_n$ defined by Foata and Han\cite{Han} mapped the statistics $\mathrm{(inv,rmin)}$ to
$\mathrm{(sor, cyc)}$. In fact, we claim that this bijection
also serves as a bijection on $S(n,k)$ that sends $\mathrm{(inv,rmin)}$ to $\mathrm{(sor, cyc)}$, which leads to a bijective proof of the equidistribution of $\mathrm{(inv,rmin)}$ and
$\mathrm{(sor, cyc)}$ over $S(n,k)$.
We present Foata and Han's bijection first.

Let $\mathrm{SE_n}$ be the set of all sequences  $a=(a_1,a_2,\ldots,a_n )$ such that $1 \leq a_i \leq i$ for $i \in [n]$. The Lehmer code of a permutation $\sigma=\sigma_1\sigma_2\cdots \sigma_n \in S_n$ is defined to be the sequence $a=Leh(\sigma)=(a_1,a_2,\ldots,a_n )$, where
$$
a_i=|\{j\colon 1 \leq j \leq i, \sigma_j \leq \sigma_i\}|.
$$
Define the A-code of a permutation $\sigma$ by $\mathrm{\text{A-code}(\sigma)=Leh ~\sigma^{-1}}$.
For $\sigma \in S_n$ and $i \in [n]$, let $k =k(i)$ be the smallest integer $k \geq 1$ such that $\sigma^{-k}(i) \leq i$. Then define
$$
\text{B-code}(\sigma)=(b_1,b_2, \ldots, b_n)~~ \text{with} ~~
b_i:=\sigma ^{-k(i)}(i).
$$
Let $\gamma=(\text{B-code})^{-1}\circ \text{A-code}$.

Combining the results of Foata and Han\cite{Han}  and Chen et al.\cite{Chen}, it is easy to see that
\[
(\inv,\Rmil,\Lmap)\sigma=(\sor,\Cyc,\Lmap)\gamma(\sigma).
\]

We assert the following proposition without giving a proof.
\begin{proposition}\label{prop:keeplmax}
 For $\sigma \in S_n$,
\begin{itemize}
  \item [1.] $Lmal(\sigma)=Rmip(\sigma^{-1})=Rmip(Leh(\sigma^{-1}))=Rmip(\text{A-code}(\sigma))$.
  \item [2.]  $Lmal(\sigma)=Rmip(\text{B-code}(\sigma))$.

\end{itemize}
\end{proposition}
Following Proposition \ref{prop:keeplmax}, we deduce that
$Lmal(\sigma)=Lmal(\gamma(\sigma))$.
Notice that the bijection $\gamma$ also keeps $\mathrm{Lmap}$. It follows that $\gamma$ also keeps the
statistic $\mathrm{\max_i \{\sigma_i-i\}}$, which
implies that $\gamma$ is   a bijection on $S(n,k)$.

\begin{proposition}
The map  $\gamma=(\text{B-code})^{-1}\circ \text{A-code}$
keeps the statistic $r:=\mathrm{\max_i \{\sigma_i-i\}}$,
that is, for any permutation $\sigma \in S_n$, we have
\[r (\sigma)=r(\gamma(\sigma)).\]
\end{proposition}
\begin{theorem}
$\gamma$ can be restricted to a bijection over $S(n,k)$ such that for $\sigma \in S(n,k)$
\[(\inv,\Rmil)\sigma=(\sor,\Cyc)\gamma(\sigma).\]
\end{theorem}
\begin{example}
Given $\sigma=571492638$, then $\text{A-code}(\sigma)=123215285$ and
$\text{B-code}^{-1}(123215285)=573291486$.
Hence, we have $\gamma(571492638)=573291486$.
It is easy to check that
\begin{align*}
  \Lmal(571492638)&=\Lmal(573291486)=\{5,7,9\},\\[3pt]
  \Lmap(571492638)&=\Lmap(573291486)=\{1,2,5\},\\[3pt]
  r(571492638)&=r(573291486)=5.
\end{align*}
\end{example}

\section{ $A_{n,k}(213)$ and Distribution of $\des$ over  $A_{n,k}(213)$ }\label{sec:TH23}

In this section, we will show that $A_{n,k}(213)$ is calculated by
the ballot number. Further, we provide bijections between any two of the structures $A_{n,k}(213)$, $S_{n+1}^{k}(321)$ and $\Gamma_{n,k}$.
Based on this, we deduce the distribution of $\des$ over $A_{n,k}(213)$,
which can be seen as  refinements of both Narayana numbers and ballot numbers.

To give a proof of Proposition \ref{prop:213ballot},
we first recall some properties of $C_{n,k}$.
The beginnings of $C_{n,k}$ are given in Table 1

\begin{table}[htp]\label{tab:ballot}
\begin{center}
\begin{tabular}{ c| c c c c c c c c }

  \hline
  {n}$\backslash${k} & 0 & 1 & 2 & 3 & 4 & 5 &6 &7\\ \hline
  0 & 1 &   &   &   &   &  & & \\
  1 & 1 & 1 &   &   &   &  & & \\
  2 & 1 & 2 & 2 &   &   &  & & \\
  3 & 1 & 3 & 5 & 5 &   &  & & \\
  4 & 1 & 4 & 9 & 14 & 14 & & &  \\
  5 & 1 & 5 & 14 & 28 & 42 & 42 &  &  \\
  6 & 1 & 6 & 20 & 48 & 90 & 132 & 132 &  \\
  7 & 1 & 7 & 27 & 75 & 165 & 297 & 429 &429  \\
  \hline
\end{tabular}
\end{center}
\vspace{0.5cm}
\caption{The beginnings of the ballot number $C_{n,k}$}
\end{table}
It can be checked that $C_{n,k}$ satisfies the following recurrences
\begin{eqnarray}
  C_{n,k} &=& C_{n-1,k}+C_{n,k-1}, \label{eq:re1}\\[4pt]
  C_{n,k}&=& C_{n-1,k}+C_{n-1,k-1}+\cdots + C_{n-1,1}+C_{n-1,0}. \label{eq:re2}
\end{eqnarray}

\begin{lemma}\label{lem:lastmaxdrop}
For $\pi \in S_n(213)$, we have
$\maxdrop(\pi)=n-\pi_n$.
\end{lemma}

\begin{proof}
Assume that $\pi_n=i$, we have
$1,2, \ldots, i$ is a subsequence of $\pi$.
It follows that $\pi^{-1}(j)\leq n-i+j$ for $1 \leq j \leq i-1$, namely,  $\pi^{-1}(j)-j \leq n-i$. Moreover, it is easy to check that  $ \pi^{-1}(j)-j < n-i$ for $ i<j \leq n$, as desired.
\end{proof}

Now we are ready to give a proof of Proposition \ref{prop:213ballot}.
\begin{proof}[Proof of Proposition~\ref{prop:213ballot}]
Assume that
$A^i_{n}(213)=\{ \pi \in A_{n}(213) \colon \pi_n=n-i\}$. Then, we have
\[A_{n,k}(213)=  \bigcup_{i=0}^k  A^i_{n}(213). \]

We aim to show that  $\# A^i_{n}(213) = \# A_{n-1,i}(213).$
Based on Lemma \ref{lem:lastmaxdrop},
this can be verified through a simple bijection from $A^i_{n}(213)$
to $A_{n-1,i}(213)$ by deleting the last element and getting the standard order. Hence, $\#A_{n,k}(213)=  \Sigma_{i=0}^k  \# A_{n-1,i}(213)$. In view of equation (\ref{eq:re2}), we deduce that $\#A_{n,k}(213)=  C_{n,k}$.
\end{proof}

\begin{corollary}
Sets  $A_{n,k}(132)$, $A_{n,k}(2\underline{13})$ and
$A_{n,k}(\underline{13}2)$ are all enumerated by $C_{n,k}$.
\end{corollary}

\begin{proof}
Since $\pi^{rc} \in S_{n,k}(132)$  if and only if
$\pi  \in A_{n,k}(213)$, then  $\#A_{n,k}(213)=\#A_{n,k}(132)$.
Notice  that $\pi$ is $213$-avoiding if and only if $\pi$
is $2\underline{13}$-avoiding, see Lemma 2.8 in \cite{Fu}. Hence, $\#A_{n,k}(213)=\#A_{n,k}(2\underline{13})$. Similarly,
we have $\#A_{n,k}(132)=\#A_{n,k}(\underline{13}2)$, as desired.
\end{proof}

As mentioned by Lin and Kim \cite{LinKim},
 $S_{n+1}^k(321)$ is enumerated by $C_{n,k}$.
 We will deduce a recurrence  of $\#S_{n}^k(321)$, which
proves this fact again.
\begin{proposition}\label{prop:321}
For $0 \leq k \leq n$, we have $\#S_{n+1}^k(321)=C_{n,k}$.
\end{proposition}

\begin{proof}
We divide $S_n^k(321)$ into two parts, namely,
\[S_n^k(321)=\{\pi \in S_n^k(321)  \colon k \geq \pi^{-1}(k) \} \cup \{\pi \in S_n^k(321)  \colon k < \pi^{-1}(k) \}.\]
It suffices to show that
\begin{equation}\label{eq:321a}
  \#\{\pi \in S_n^k(321)  \colon k \geq \pi^{-1}(k) \}=C_{n-1,k-1},
\end{equation}
and
\begin{equation}\label{eq:321b}
  \#\{\pi \in S_n^k(321)  \colon k < \pi^{-1}(k) \}=C_{n-2,k}.
\end{equation}

To show (\ref{eq:321a}), it is enough to construct a bijection
from $\{\pi \in S_n^k(321)  \colon k \geq \pi^{-1}(k) \}$
to $\{\pi \in S_{n}^{k-1}(321) \}$ by exchanging $k$ and $k+1$ in a permutation.

To show (\ref{eq:321b}), we need to construct a bijection from
$\{\pi \in S_n^k(321)  \colon k < \pi^{-1}(k) \}$
to $\{\pi \in S_{n-1}^k(321)\}$. Given $\pi \in S_n^k(321)$
with $k < \pi^{-1}(k)$, it is easy to see that $\pi_{n-1}=k$
or $\pi_{n-1}=n$.
If $\pi_{n-1}=n$, then delete $n$.
If $\pi_{n-1}=k$,  then delete $k$ and change $k+2$ to $k$ and
$i$ to $i-1$ for $k+3 \leq i \leq n$. It is easy to check that this map is a bijection and we omit it here.
In view of (\ref{eq:re1}), we complete the proof.
\end{proof}

In the following, we will construct bijections from
$A_{n,k}(213)$ to $\Gamma_{n,k}$ and  from
$S^k_{n+1}(321)$ to $\Gamma_{n,k}$ to give a proof of
Theorem \ref{thm:equidis}.
\begin{proof}[Proof of Theorem \ref{thm:equidis}]
Firstly, we
construct a bijection $\alpha$ from  $A_{n,k}(213)$ to $\Gamma_{n,k}$.

Given $\pi=\pi_1 \pi_2 \cdots \pi_n \in A_{n,k}(213)$,
let the right-to-left maximum letters of $\pi$ be $\pi_{i_1}, \pi_{i_2},
\ldots,\pi_{i_r}$ with $i_1 <i_2 < \cdots <i_r$ and $\pi_{i_1}
>\pi_{i_2}> \cdots > \pi_{i_r}$.
Create an non-negative $n,k$-arrangement $a=\alpha(\pi)$ by the following steps
\begin{itemize}
  \item Firstly, writing $i_1$ $1$'s.
  \item Secondly, for $j$ from $1$ to $r-1$, adjoining $(\pi_{i_{j}}-\pi_{i_{j+1}})$ $-1$'s with
$(i_{j+1}-i_{j})$ $1$'s .
  \item Lastly, writing $(\pi_n-n+k)$ $-1$'s.
\end{itemize}

It is easy to check that $a$ has $i_r$ $1$'s and $(\pi_{i_1}-n+k)$ $-1$'s.
Since $i_r=n$ and $\pi_{i_1}=n$, then $a$ is an $n,k$-arrangement.
Notice that,  for $1 \leq j \leq r-1$, elements larger than $\pi_{i_{j+1}}$ is at the position
$i_j$ or to the left. Hence, $i_j \geq n- \pi_{i_{j+1}}$, which implies that $a$ is non-negative.

To show that $\alpha$ is a bijection, we shall construct its inverse.
Let $a \in \Gamma_{n,k}$  with $\vpk(a)=r-1$ and $r \geq 1$.
Assume that $a$ has $p_i$ $1$'s and $n_i$ $-1$'s alternatively for
$1 \leq i \leq r$, then the corresponding $\pi$ in $A_{n,k}(213)$
can be constructed as follows.

The positions of the right to left maxima of $\pi$  are
$n-p_r- p_{r-1}-\cdots -p_2$,  $n-p_r-p_{r-1}-\cdots-p_3$, $\cdots$, $n-p_r$, $n$.
The values of the right to left maxima of $\pi$ are
$n-k+n_{r}+n_{r-1}+\cdots +n_1$, $n-k+n_{r}+n_{r-1}+\cdots +n_2$, $\cdots$, $n-k+n_r$.
Then  picking out the largest $p_r-1$ remaining elements that are smaller than $n-k+n_r$ and filling them in the positions between $n-p_r$ and $n$ in increasing order. Similarly,
we can fill the positions between $n-p_r-\cdots-p_{j+1}-p_j$
and $n-p_r-\cdots-p_{j+1}$ in the same way for $1<j<r$.
From the construction of $\pi$, it is easily to check that
$\pi$ is $132$-avoiding.
By Lemma \ref{lem:lastmaxdrop}, we obtain that
$\maxdrop(\pi) = n - \pi_n = n-(n-k+n_r)=k-n_r\leq k$.
Hence $\pi$ is a permutation in $A_{n,k}(213)$ and
$\alpha$ is a bijection between $A_{n,k}(213)$ and $\Gamma_{n,k}$.

Moreover, it is easy to see from the construction of the bijection $\alpha$ that $\des(\pi)=\rmax(\pi)-1=\vpk(a)$.

Now, we proceed to give a bijection $\beta$ from $S_{n+1}^k(321)$ to $\Gamma_{n,k}$.
Notice  that
 a permutation is $321$-avoiding if and only if both the subsequence formed by its weak excedance values and the one formed
by the remaining non-weak excedance values are increasing.
Given

$\pi=\pi_1 \pi_2 \cdots \pi_{n+1}
 \in S_{n+1}^k(321)$,
let the non-weak excedance values
of $\pi$ that are before position $n+1$ be $\pi_{i_1}, \pi_{i_2},
\ldots,\pi_{i_r}$ with $i_1 <i_2 < \cdots <i_r$ and $\pi_{i_1}
<\pi_{i_2}< \cdots < \pi_{i_r}$.
Create a non-negative $n,k$-arrangement $a=\beta(\pi)$ by the following steps
\begin{itemize}
  \item Firstly, writing $(i_1-1)$ $1$'s and $\pi_{i_1}$ $-1$'s.
  \item Secondly, for $j$ from $1$ to $r-1$, adjoining $(i_{j+1}-i_{j})$ $1$'s with $(\pi_{i_{j+1}}-\pi_{i_{j}})$ $-1$'s.
  \item Lastly, writing $(n+1-i_{r})$ $1$'s and $(k-\pi_{i_r})$ $-1$'s.
\end{itemize}

 Since $i_j-1 \geq \pi_{i_j}$ and $n \geq k$, it is
easy to check that $a$ is an non-negative $n,k$-arrangement.

To show $\beta$ is a bijection,  we will construct its inverse.
Let $a \in \Gamma_{n,k}$ with $\vpk(a)=r-1$
and $p_i$ $1$'s and $n_i$ $-1$'s alternatively for
$1 \leq i \leq r$.
 We construct  the corresponding $\pi$ in $S^k_{n+1}(321)$ as follows.

Elements $k-n_{r}- \cdots -n_3-n_2 $,  $k-n_{r}- \cdots -n_3 $, $\cdots$, $k-n_{r}$ are at the positions
$p_1+1$, $p_1+p_2+1$, $\cdots$, $p_1+p_2+\cdots +p_{r-1}+1$.
Element $k+1$
is at the position $n+1$. The remaining elements are placed
in the remaining places in increasing order.

By the definition of $\beta$, we may easily deduce that  $\vpk(a)=\vnw(\pi)$. The proof is completed.
\end{proof}

\begin{example} Let $n=8$, $k=7$ and
 $\pi=83475612$, the right to left maxima of $\pi$
are $\pi_1=8, \pi_4=7, \pi_6=6, \pi_8=2$.
Then, we have \[a=\alpha(\pi)=1,-1,1,1,1,-1,1,1,-1,-1,-1,-1,1,1,-1.\]

As the inverse of $\alpha$, for
 $a=1,-1,1,1,1,-1,1,1,-1,-1,-1,-1,1,1,-1$,
we have $n=8$, $k=7$, $r=\vpk(a)+1=4$, $p_1=1$, $p_2=3$, $p_3=2$, $p_4=2$,
$n_1=1$, $n_2=1$, $n_3=4$ and $n_4=1$.
Then $8,7,6,2$ are placed at positions $1,4,6,8$
and $\pi=\alpha^{-1}(a)=83475612$.

Let $n=8$, $k=7$ and $\sigma=314527698$. The non-weak excedance values of $\sigma$ that are before position $9$
are $\sigma_2=1, \sigma_5=2, \sigma_7=6$.
Then, we have \[b=\beta(\sigma)=1,-1,1,1,1,-1,1,1,-1,-1,-1,-1,1,1,-1.\]

As the inverse of $\beta$, for $b=1,-1,1,1,1,-1,1,1,-1,-1,-1,-1,1,1,-1$,
we have $n=8$, $k=7$, $r=\vpk(b)+1=4$, $p_1=1$, $p_2=3$, $p_3=2$, $p_4=2$,
$n_1=1$, $n_2=1$, $n_3=4$ and $n_4=1$.
Then $1,2,6$ are placed at positions $2,5,7$
and $\sigma=\beta^{-1}(b)=314527698$.
\end{example}

For  completeness, we present the bijection from $A_{n,k}(213)$ to $S_{n+1}^k(321)$ as follows.

Given $\pi=\pi_1 \pi_2 \cdots \pi_n \in A_{n,k}(213)$,
let the right-to-left maximum letters of $\pi$ be $\pi_{i_1}, \pi_{i_2},
\ldots,\pi_{i_r}$ with $i_1 <i_2 < \cdots <i_r$ and $\pi_{i_1}
>\pi_{i_2}> \cdots > \pi_{i_r}$.
Construct a permutation $\sigma \in S^k_{n+1}(321)$ by the following
steps:

\begin{itemize}
  \item The positions of the non-weak excedances of $\sigma$ before the last element  are $i_1+1$, $i_2+1$, $\ldots$, $i_{r-1}+1$.
  \item  The values of the the non-weak excedances of $\sigma$ before the last element  are $n-\pi_{i_2}$, $n-\pi_{i_3}$, $\ldots$,
      $n-\pi_{i_r}$.
  \item  Place $k+1$ in the $n+1$-th place and then put the remaining elements to the remaining places in increasing order.
\end{itemize}

It is easy to check that it is a bijection and the inverse of the bijection is omitted. As an example, $83475612$ is mapped to $314527698$.

In the following, we will give the distribution of $\des$
over $A_{n,k}(213)$. By Theorem \ref{thm:equidis},
it suffices to deduce the distribution of $\vpk$ over $\Gamma_{n,k}$.

\begin{proof}[Proof of Theorem \ref{thm:generating}]
Let
\[F(p,q,z)=\sum_{a \in \Gamma_{n,k},\, 0 \leq k \leq n
} p^{\vpk(a)} q^{n-k}z^n,\]

\[F^u(p,q,z)=\sum_{a \in \Gamma^u_{n,k},\, 0 \leq k \leq n
} p^{\vpk(a)} q^{n-k}z^n,\]

\[F^d(p,q,z)=\sum_{a \in \Gamma^d_{n,k},\, 0 \leq k \leq n
} p^{\vpk(a)} q^{n-k}z^n.\]
where $\Gamma^u_{n,k}$ ($\Gamma^d_{n,k}$) is the set of  arrangements $a \in \Gamma(n,k)$ with  $a_{n+k}=1$ ($a_{n+k}=-1$).

Let
\begin{equation*}
  F(p,q,z)=\sum_{k \geq 0} F_k(p,z)q^k = \sum_{n \geq 0} f_n(p,q)z^n,
\end{equation*}
\begin{equation*}
  F^u(p,q,z)=\sum_{k \geq 0} F^u_k(p,z)q^k = \sum_{n \geq 0} f_n^u(p,q)z^n,
\end{equation*}
\begin{equation*}
  F^d(z,p,q)=\sum_{k \geq 0} F^d_k(p,z)q^k = \sum_{n \geq 0} f^d_n(p,q)z^n.
\end{equation*}
Then we have $f^u_1(p,q)=q$.  By considering two cases of the
the last element of an non-negative $n,k$-arrangement,
being $1$ or $-1$,  we deduce the following two recurrences.
For $n \geq 1$, we have
\begin{equation}\label{eq:furecurrence}
  f^u_{n+1}(p,q) =q f^u_{n}(p,q)  + pq f^d_{n}(p,q).
\end{equation}
For $n \geq 0$, we have

\begin{equation}\label{eq:fdrecurrence}
    f^d_{n+1}(p,q) =q^{-1} f^u_{n+1}(p,q)  + \{q^{ \geq 0}\}(q^{-1} f^d_{n+1}(p,q)),
\end{equation}
where $\{q^{ \geq 0}\}$ is the linear operator extracting all terms
in the power series representation containing non-negative powers of $q$.

Summing (\ref{eq:furecurrence}) over $n \geq 1$ and summing
(\ref{eq:fdrecurrence}) over $n \geq 0$, we deduce that
\begin{align*}
  \sum_{n \geq 1} f^u_{n+1}(p,q) z^{n+1}&=\sum_{n \geq 1} (q f^u_{n}(p,q)  + pq f^d_{n}(p,q)) z^{n+1}, \\[4pt]
  \sum_{n \geq 0} f^d_{n+1}(p,q) z^{n+1}&=\sum_{n \geq 0} (q^{-1} f^u_{n+1}(p,q)  + \{q^{ \geq 0}\}(q^{-1} f^d_{n+1}(p,q))) z^{n+1}.
\end{align*}
We deduce that
\begin{align}
  &F^u(p,q,z)-qz=qz F^u(p,q,z)+pqzF^d(p,q,z) , \label{eq:genre1} \\[5pt]
 &F^d(p,q,z)=q^{-1}F^u(p,q,z)+q^{-1}F^d(p,q,z)-q^{-1}F_0(p,z), \label{eq:genre2}
\end{align}
where
\[F_0(p,z)=\sum_{a \in \Gamma_{n,n},\, n \geq 1} p^{\vpk(a)} z^n.\]

Recall that the Narayana number $N_{n,m}$ is the number of Dyck path
of semilength $n$ having $m$ peaks and
\begin{equation*}
  \sum_{1 \leq m \leq n} N_{n,m} x^n y^m= \frac{1-x(1+y)-\sqrt{(1+x(1-y))^2-4x}}{2x},
\end{equation*}
see \cite{Callan} for reference.

\begin{align}\label{eq:F0}
 F_0(p,z)&=\frac{\sum_{1 \leq m \leq n} N_{n,m} z^n p^m}{p} \notag\\[4pt]
 &=\frac{1-z(1+p)-\sqrt{(1+z(1-p))^2-4z}}{2zp}.
\end{align}

By solving (\ref{eq:genre1}) and (\ref{eq:genre2}), we derive that
\begin{align*}
  F^u(p,q,z) & = \frac{(1-q^{-1})qz-pzF_0(z,p)}{1-qz-pz-(1-qz)q^{-1}},    \\[6pt]
  F^d(p,q,z) & = \frac{z-q^{-1}(1-qz)F_0(z,p)}{1-qz-pz-(1-qz)q^{-1}}.
\end{align*}

Then
\begin{align*}
  F(p,q,z) & =1 + F^u(z,p,q)+ F^d(z,p,q) \\[5pt]
   & =\frac{1-pz-(1-qz)q^{-1}+(z-pz-q^{-1})F_0(z,p)}{1-qz-pz-(1-qz)q^{-1}}.
\end{align*}
Hence, by changing $q$ to $q^{-1}$ and $z$ to $zq$ above we
obtain (\ref{eq:main}).
\end{proof}

\section*{Acknowledgement}
The first author was supported by the National Natural Science Foundation of China (No.~11701420) and
Natural Science Foundation Project of Tianjin Municipal Education Committee (No.~2017KJ243,~No.~2018KJ193).
The second author was supported by the National Natural Science Foundation of China (No.~11801378,~No.~12071440) and the Zhejiang Provincial Natural Science Foundation of China (No.~LQ17A010004).