# Cardinality of set of functions with given domain and co-domain

I am reading a book (Klein, Philip. Coding the Matrix: Linear Algebra through Computer Science Applications)and came across the following statement:

I'm having trouble understanding what this means, I realize it's talking about the cardinalities, but I don't understand the "pun" and can't come up with a concrete example to illustrate this "fact".

The pun is really just that - $|D^F| = |D|^{|F|}$. The reason it's "funny" is that there's really no reason to use that notation except to make things line up like that. A "pun" is usually using a word that is related to the situation but not appropriate to the use, but used anyway because it sounds like what would be appropriate (e.g., cat-astrophe when speaking of a feline disaster). In this case, we're using notation related to the situation which (prior to this definition) isn't actually appropriate, but looks like what is appropriate (i.e., playing on the visual similarity of $|D^F|$ and $|D|^{|F|}$.

As for a concrete example: let $A = \{0, 1\}$ and $B = \{a, b, c\}$. $B^A$ has nine members ($f(0)$ can be $a$, $b$, or $c$, and $f(1)$ can as well). $|B|^{|A|} = 3^2 = 9$.

• Please check. I think you want $A^B$. You should do the one with $9$ since my almost simultaneous answer does the $8$. – Ethan Bolker Feb 19 '17 at 22:15
• @EthanBolker No, $B^A$ is correct. The $A$ I provided has cardinality $2$, $B$ has cardinality $3$; if it were that $A^B$ had cardinality $9$, it would be false that $|A^B| = |A|^{|B|}$. – Reese Feb 19 '17 at 22:28
• @Reese ok, I'm still having trouble, when you say "... has nine members (f(0) can be a, b, or c, and f(1) can as well)...." - I only count 6 possible combinations, how are you getting 9? – JMM Feb 20 '17 at 3:29
• @JMM For ease of notation, I'll denote by $(x, y)$ the function taking $0$ to $x$ and $1$ to $y$. Then the nine functions are $(a, a)$, $(a, b)$, $(a, c)$, $(b, a)$, $(b, b)$, $(b, c)$, $(c, a)$, $(c, b)$, and $(c, c)$. Notice that the choice of $f(1)$ is independent of the choice of $f(0)$. – Reese Feb 20 '17 at 3:32
• @Reese got it, thanks!! – JMM Feb 20 '17 at 3:36

For an example to illustrate the fact let $F$ have three elements and $D = \{0,1\}$ two. Then each function from $F$ to $D$ assigns a $0$ or a $1$ to each element of $F$ and so essentially corresponds to a subset of $F$. There are $8 = 2^3$ of those.

I think the "pun" is the idea that you can "distribute" the absolute value operation on the left to get the expression on the right.

For any set $A$, $|A|$ is the cardinal of the set $A$. Almost by definition, for any two sets $A,A'$ the equation $|A|=|A'|$ means that there exists a bijection $A \leftrightarrow A'$.

For any sets $F,D$, the set $D^F$ is defined to be the set of all functions with domain $F$ and range $D$. And then, like any other set, $|D^F|$ is the cardinal of the set $D^F$.

Now there's a little lemma: Given two cardinals $\alpha,\beta$, for any sets $A,A',B,B'$, if $|A|=|A'|=\alpha$ and $|B|=|B'|=\beta$ then $|A^B|=|(A')^{B'}|$. This lemma is proved by constructing a bijection $A^B \leftrightarrow (A')^{B'}$ (it's not hard to prove, try it).

Next, there's a definition: given two cardinals $\alpha,\beta$, the cardinal $\alpha^\beta$ is defined to be the cardinal of any set of the form $A^B$ where $A$ and $B$ are chosen so that $|A|=\alpha$ and $|B|=\beta$. The lemma says this is well-defined, independent of the choice of $A$ and $B$.

Finally, there's a pun: $|D^F|=|D|^{|F|}$, which is an immediate consequence of the definition, using $\alpha=|D|$ and $\beta=|F|$.