Can anyone explain or/and provide a proof of the following statement?
I am reading a book on Combinatorics. In the book the author provides the following statement along with an explanation:
The cardinality of the set of all the functions from an n-set to an m-set is $m^n$.
The explanation given is:
Let $D = \{1, 2 .... , n\}$ be the n-set and let $R = \{r_1, r_2, ....., r_m\}$. Given any function $f$ from $D$ to $R$, we write down the sequence $(f(1), f(2), ... , f(n))$ of length $n$ with entries from $R$.
I am not able understand the explanation so I am looking for a more elaborate or a more visual proof/explanation of the statement.
A function from a set $A$ to a set $B$ assigns to every element in $A$ precisely one element in $B$. If $A=\{a_1,\ldots,a_n\}$ and $B=\{b_1,\ldots,b_m\}$, this means that for every $a_i$ we can choose one of the $b_1,\ldots, b_m$ as its image.
Lets give an easy example. Suppose you have bought two plain white t-shirts $t_1$ and $t_2$ from the store, and you have bought three different colours of paint; blue, yellow and red. Then the a function from $T=\{t_1,t_2\}$ to $C=\{$blue, red, yellow$\}$ is a choice of a color for each shirt. For the first shirt $t_1$ there are $3$ different choices. For the second shirt $t_2$ there are again $3$ choices. These choices are mutually independent so we get $3\times 3=3^2$ choices of functions.
We can generalise this to $n$ t-shirts $t_1,\ldots, t_n$ and $m$ colours $c_1,\ldots, c_m$. For the first shirt we can choose between all the $m$ colours, for the second shirt we can again choose between all these colours, and so we end up with $m\times m\times \ldots \times m$ different combinations, which is precisely $m^n$.