Formula for number of surjective functions in case where codomain is greater than domain We were deriving the formula for number of surjective functions from f: $X \to Y$, where $|X| = n$ and $|Y| = m$. The formula that we have is:
$$\sum_{k=0}^m(-1)^k (m-k)^n {m \choose k}$$
Now, if $m>n$ we have no surjective functions, as codomain is greater than domain and the answer should be zero. The formula gives the right answer, but I cannot figure out why does it work algebraically.
Any hints on why does this sum equals to zero when $m > n$?
 A: We have
$$\begin{align*}
\sum_{k=0}^m (-1)^k (m-k)^n {m\choose k}
&= n! [z^n] \sum_{k=0}^m (-1)^k \exp((m-k)z) {m\choose k}\\
&= n! [z^n] \exp(mz) \sum_{k=0}^m (-1)^k \exp(-kz){m\choose k}\\
&= n! [z^n] \exp(mz) (1-\exp(-z))^m\\
&= n! [z^n] (\exp(z)-1)^m.
\end{align*}$$
Now $\exp(z)-1 = z + \cdots$ so $(\exp(z)-1)^m = z^m + \cdots$ and hence $n! [z^n] (\exp(z)-1)^m = 0$ when $n\lt m.$
A: There are two proofs I can think of. The first uses exponential generating functions. Note that
$$
\frac{(m-k)^n}{n!}=[x^n]e^{(m-k)x}
$$
Here, $[x^n]$ is the "coefficient-of" operator, so $[x^n]f(x)$ is the coefficent of $x^n$ in the power series $f(x)$. Therefore,
$$
\begin{align}
\sum_{k=0}^m(-1)^k(m-k)^n\binom{m}k
&=n!\sum_{k=0}^m \binom{m}k(-1)^k[x^{n}]e^{(m-k)x}
\\&=n![x^{n}]\sum_{k=0}^m \binom{m}k(-1)^k(e^{x})^{m-k}
\\&=n![x^n](e^x-1)^m
\end{align}
$$
Finally, note $e^x-1=x+x^2/2+\dots$, so that $(e^x-1)^m=x^m+$ higher order terms, meaning the coefficient of $[x^n]$ in $(e^x-1)^m$ is zero when $n<m$.

The second is to note that $\sum_{k=0}^m(-1)^k(m-k)^n\binom{m}k$ is the zeroth term of the $m^{th}$ forward difference of the sequence $a_i=i^n$. Furthermore, for a nonzero polynomial of degree $n$, the forward difference has degree at most $n-1$. For example,
\begin{aligned}
\Delta(i^n)&=(i+1)^n-i^n &&\xrightarrow{i=0}1^n-0^n 
\\
\Delta(\Delta(i^n))&=(i+2)^n-2(i+1)^n+i^n &&\xrightarrow{i=0}2^n-2\cdot 1^n+0^n 
\\
\Delta(\Delta(\Delta(i^n)))&=(i+3)^n-3(i+2)^n+3(i+1)^n-i^n &&\xrightarrow{i=0}3^n-3\cdot 2^n+3\cdot 1^n-0^n
\end{aligned}
Note that on the right, we exactly have the summations for $m=1$, $m=2$, and $m=3$ (respectively), and in the middle column, there are polynomials with degree at most $n-1,n-2$ and $n-3$ (respectively).
A: More generally, the sum is $0$ if you replace $(m-k)^n$ with any polynomial in $k$ with degree $<m$:
Summation of series involving binomial coefficients and polynomial of degree at most n-1
A: In this answer, $3$ proofs of
$$
\sum_{j=0}^m(-1)^{m-j}\binom{m}{j}\binom{j}{k}=[m=k]\tag1
$$
are given, where $[\cdots]$ are Iverson brackets.
Any polynomial, $P(x)$, of degree $n$ can be written as
$$
P(x)=\sum_{k=0}^nc_k\binom{x}{k}\tag2
$$
for some constants $c_k$.
Then the $m^\text{th}$ forward difference of $P(x)$ is
$$
\begin{align}
\sum_{j=0}^m(-1)^{m-j}\binom{m}{j}P(x+j)
&=\sum_{j=0}^m(-1)^{m-j}\binom{m}{j}\sum_{k=0}^nc_k\sum_{i=0}^k\binom{x}{i}\binom{j}{k-i}\tag{3a}\\
&=\sum_{k=0}^nc_k\sum_{i=0}^k\binom{x}{i}\sum_{j=0}^m(-1)^{m-j}\binom{m}{j}\binom{j}{k-i}\tag{3b}\\
&=\sum_{k=0}^nc_k\sum_{i=0}^k\binom{x}{i}[m=k-i]\tag{3c}\\
&=\sum_{k=0}^nc_k\binom{x}{k-m}\tag{3d}
\end{align}
$$
Explanation:
$\text{(3a)}$: apply $(2)$ and Vandermonde's Identity
$\text{(3b)}$: change the order of summation
$\text{(3c)}$: apply $(1)$
$\text{(3d)}$: apply the Iverson brackets
If $n\ge m$, $(3)$ shows that the $m^\text{th}$ forward difference of a polynomial of degree $n$, is a polynomial of degree $n-m$.
If $n\lt m$, then each term of the sum in $\text{(3d)}$ will be $0$. Therefore,
$$
\begin{align}
\sum_{k=0}^m(-1)^k(m-k)^n\binom{m}{k}
&=\sum_{k=0}^m(-1)^{m-k}\binom{m}{k}k^n\tag{4a}\\
&=\sum_{k=0}^m(-1)^{m-k}\binom{m}{k}P(0+k)\tag{4b}
\end{align}
$$
Explanation:
$\text{(4a)}$: substitute $k\mapsto m-k$
$\text{(4b)}$: $P(x)=x^n$
$\text{(4b)}$ is the $m^\text{th}$ forward difference of $P(x)=x^n$ at $x=0$, which, by $(3)$ is $0$ if $n\lt m$.
