TITLE: Counting nilpotent self-maps of $\{1,\dots,n\}$ with image of a given cardinal
QUESTION [7 upvotes]: Let $\mathcal{C}_n$ be the monoid of self-maps $\alpha$ of $\{1\dots,n\}$ that are order-preserving ($\forall x,y$, $x\le y$ $\Rightarrow$ $\alpha(x)\le\alpha(y)$ and decreasing ($\forall x$, $\alpha(x)\le x$).
Let N($\mathcal{C_n})$ be the set of nilpotent elements of $\mathcal{C}_n$, i.e., those $\alpha\in\mathcal{C}_n$ such that some power of $\alpha$ equals the absorbing element (the constant function $1$). As mentioned in a comment, this means that $\alpha(x)<x$ for every $x>1$.

Given $r$, what is the cardinality of the subset
$$X_{n,r}=\{\alpha\in N(\mathcal{C_n}): \lvert \mathrm{im}(\alpha)\rvert=r\}?$$

REPLY [5 votes]: The answer is ${n-2\choose r-1}{n-1\choose r-1}-{n-2\choose r-2}{n-1\choose r}=\frac1{n-r}{n-2\choose r-1}{n-1\choose r}$.
Let $\{1=a_0<a_1<a_2<\ldots<a_{r-1}\}$ be the image of $\alpha\in X_{n,r}$ and denote $p_i:=\max \alpha^{-1}(a_{i-1})$ for $i=1,\ldots,r-1$. Then $p_1<p_2<\ldots p_{r-1}<n$ and $p_i\geqslant a_i$ for all $i$. Now define two lattice paths (with vertical steps $+(0,1)$ and horizontal steps $+(1,0)$). The first path goes from $A=(1,0)$ to $C=(n-r,r-1)$ and has vertices at points $(a_i-i,i-1)$ and $(a_i-i,i)$ for $i=1,\ldots, r-1$. The second goes from $B=(1,-1)$ to $D=(n+1-r,r-2)$ and has the vertices $(p_i-i+1,i-2)$ and $(p_i-i+1,i-1)$.
They should be disjoint, and any disjoint pair of paths from $A$ to $C$ and from $B$ to $D$ corresponds to some nilpotent map $\alpha\in X_{n,r}$.
Note that there is no pair of disjoint paths from $A$ to $D$ and from $B$ to $C$. So we get the above formula using Lindstrőm–Gessel–Viennot lemma
: the $2\times 2$ matrix which counts the lattice paths from $\{A,B\}$ to $\{C,D\}$ is just $$\pmatrix{{n-2\choose r-1}&{n-2\choose r-2}\\
{n-1\choose r}& {n-1\choose r-1}
&}.$$