Cardinality of Set of All Mappings

Theorem
The cardinality of the set of all mappings from $$S$$ to $$T$$ (that is, the total number of mappings from $$S$$ to $$T$$) is:

$$\left|{T^S}\right| = \left|{T}\right| ^ {\left|{S}\right|}$$

Proof
Let $$\left|{S}\right| = n$$ and $$\left|{T}\right| = m$$.


 * First suppose that $$n = 0$$, i.e. that $$S = \varnothing$$.

The only element of $$T^\varnothing$$ is the null relation $$\varnothing \times T$$. So $$\left|{T^\varnothing}\right| = 1 = m^0$$.

So the result holds for $$n = 0$$.


 * Next, suppose that $$m = 0$$, i.e. that $$T = \varnothing$$.

From Null Mapping, the null relation $$\mathcal{R} = \varnothing \subseteq S \times T$$ is not a mapping unless $$S = \varnothing$$.

So if $$n > 0$$, then $$\left|{\varnothing^S}\right| = 0 = 0^n$$ and the result holds.

If $$S = \varnothing = T$$, $$\left|{T^S}\right| = 1 = 0^0 = m^n$$, and the result holds.

This fits in with the preferred definition of the value of $$0^0$$.


 * Finally, suppose $$m > 0$$ and $$n > 0$$.

Let $$\sigma: \mathbb{N}_n \to S$$ and $$\tau: T \to \mathbb{N}_n$$ be bijections.

Then the mapping $$\Phi: T^S \to \left({\mathbb{N}_m}\right)^{\left({\mathbb{N}_n}\right)}$$ defined as:

$$\forall f \in T^S: \Phi \left({f}\right) = \tau \circ f \circ \sigma$$

(where $$\left({\mathbb{N}_m}\right)^{\left({\mathbb{N}_n}\right)}$$ is the set of all mappings from $$\mathbb{N}_n$$ to $$\mathbb{N}_m$$) is also a bijection.

So we need only consider the case where $$S = \mathbb{N}_n$$ and $$T = \mathbb{N}_m$$.


 * Let $$m \in \mathbb{N}^*$$.

For each $$n \in \mathbb{N}$$, let $$\mathbb{T} \left({n, m}\right)$$ be the set of all mappings from $$\mathbb{N}_n$$ to $$\mathbb{N}_m$$. Let:

$$\mathbb{S} = \left\{{n \in \mathbb{N}: \left|{\mathbb{T} \left({n, m}\right)}\right| = m^n}\right\}$$

We have seen that $$0 \in \mathbb{S}$$.

Let $$n \in \mathbb{S}$$.

Let $$\rho: \mathbb{T} \left({n+1, m}\right) \to \mathbb{T} \left({n, m}\right)$$ defined by:

$$\forall f \in \mathbb{T} \left({n+1, m}\right): \rho \left({f}\right) =$$ the restriction of $$f$$ to $$\mathbb{N}_n$$

Given that $$g \in \mathbb{T} \left({n, m}\right)$$, and $$k \in \mathbb{N}_m$$, let $$g_k: \mathbb{N}_{n+1} \to \mathbb{N}_m$$ be defined by:

$$ \forall x \in \mathbb{N}_{n+1}: g_k \left({x}\right) = \begin{cases} g \left({x}\right): & x \in \mathbb{N}_n \\ k: & x = n \end{cases} $$

Then:

$$\rho^{-1} \left({\left\{{g}\right\}}\right) = \left\{{g_0, \ldots, g_{m-1}}\right\}$$

Thus $$\rho^{-1} \left({\left\{{g}\right\}}\right)$$ has $$m$$ elements. So clearly:

$$\left\{{\rho^{-1} \left({\left\{{g}\right\}}\right): g \in \mathbb{T} \left({n, m}\right)}\right\}$$

is a partition of $$\mathbb{T} \left({n+1, m}\right)$$.

Hence, as $$n \in \mathbb{S}$$, the set $$\mathbb{T} \left({n+1, m}\right)$$ has $$m \cdot m^n = m^{n+1}$$ elements by Number of Elements in Partition.

Thus $$n + 1 \in \mathbb{S}$$.

By induction, $$\mathbb{S} = \mathbb{N}$$ and the proof is complete.

Comment
The question of whether to define $$0^0 = 0$$ or $$0^0 = 1$$ keeps students awake arguing for hours. Here's another argument, in case you're not convinced, for defining $$0^0 = 1$$ as opposed to $$0^0 = 0$$ - another result kept nice and neat.