# MAT 112 Integers and Modern Applications for the Uninitiated

## Section9.1Definition of Cardinality

We introduce the terminology for speaking about the number of elements in a set, called the cardinality of the set. In the video in Figure 9.1 we give a intuitive introduction and a formal definition of cardinality. More details can be found below.
In the example below we illustrate the properties that we would want a precise definition of cardinality to have.

### Example9.2.What should the cardinalities of sets be ?

We discuss possible cardinalities of some sets.
1. The empty set $$\{\}$$ contains no elements, so its cardinality should be $$0\text{.}$$
2. The set $$\{\mathtt{m}\}$$ contains one element, namely the character $$\mathtt{m}\text{,}$$ so its cardinality should be $$1\text{.}$$
3. The set $$\{\mathtt{m},\mathtt{a}\}$$ contains two (distinct) elements, namely the characters $$\mathtt{m}$$ and $$\mathtt{a}\text{,}$$ so its cardinality should be $$2\text{.}$$
4. The set $$\{1,2,3,4,5\}$$ contains five (distinct) elements, namely the numbers $$1\text{,}$$ $$2\text{,}$$ $$3\text{,}$$ $$4\text{,}$$ and $$5\text{,}$$ so its cardinality should be $$5\text{.}$$
We start with a definition of the cardinality of the empty set.

### Definition9.3.

The cardinality of the empty set $$\{\}$$ is $$0\text{.}$$
We write $$\#\{\}=0$$ which is read as “the cardinality of the empty set is zero” or “the number of elements in the empty set is zero.”
We have the idea that cardinality should be the number of elements in a set. This works for sets with finitely many elements, but fails for sets with infinitely many elements. We approach cardinality in a way that works for all sets. First we define when we consider two sets to have the same cardinality. Certainly two sets $$A$$ and $$B$$ have the same number of elements if we can pair each element in $$A$$ with an element in $$B$$ such that each element of $$A$$ is in exactly one pair and each element of $$B$$ is in exactly one pair. These pairs define an invertible function from $$A$$ to $$B\text{.}$$ This observation yields our definition of equality of cardinality.

### Definition9.4.

Let $$A$$ and $$B$$ be non-empty sets. The sets $$A$$ and $$B$$ have the same cardinality means that there is an invertible function $$f:A\to B\text{.}$$
This definition does not specify what we mean by the cardinality of a set and does not talk about the number of elements in a set. This will come in handy, when we consider the cardinality of infinite sets in the next section.

### Example9.5.$$\{0,1,2,3,4\}$$ and $$\{\mathtt{a},\mathtt{e},\mathtt{i},\mathtt{o},\mathtt{u}\}$$ have the same cardinality.

We show that the two sets $$\Z_5=\{0,1,2,3,4\}$$ and $$V=\{\mathtt{a},\mathtt{e},\mathtt{i},\mathtt{o},\mathtt{u}\}$$ have the same cardinality.
To show that $$\Z_5$$ and $$V\text{,}$$ by Definition 9.4, we need to find an invertible function $$f:\Z_5\to V\text{.}$$ Consider the function $$f:\Z_5\to V$$ given by:
 $$x$$ $$0$$ $$1$$ $$2$$ $$3$$ $$4$$ $$f(x)$$ $$\mathtt{a}$$ $$\mathtt{e}$$ $$\mathtt{i}$$ $$\mathtt{o}$$ $$\mathtt{u}$$
Inspecting the table we see that the function $$f$$ is invertible. In particular, the inverse of $$f^{-1}$$ of $$f$$ is given by:
 $$y$$ $$\mathtt{a}$$ $$\mathtt{e}$$ $$\mathtt{i}$$ $$\mathtt{o}$$ $$\mathtt{u}$$ $$f^{-1}(y)$$ $$0$$ $$1$$ $$2$$ $$3$$ $$4$$
By presenting an invertible function $$f:\Z_5\to V$$ we have proven that the sets $$\Z_5$$ and $$V$$ have the same cardinality.
Note that in our proof we could also have used the function $$f^{-1}:V\to\Z_5$$ or any other invertible function between the two functions, since Definition 9.4 only requires the existence of any invertible function.
Often it is easier to show that two sets have the same cardinality than showing that they do not have the same cardinality, because it is easier to proof the existence of such a function by simply presenting on than proving that there is no such function.

### Example9.6.$$\{0,1,2\}$$ and $$\{\mathtt{s},\mathtt{t}\}$$ do not have the same cardinality.

We show that the two sets $$\Z_3=\{0,1,2\}$$ and $$U=\{\mathtt{s},\mathtt{t}\}$$ do not have the same cardinality by showing that there is no invertible function from $$\Z_3$$ to $$U\text{.}$$
Let $$f:\Z_3\to U\text{.}$$ Then $$f(0)\in U$$ and $$f(1)\in U$$ and $$f(2)\in U\text{.}$$ As we want $$f$$ to be invertible no two of $$f(0)$$ and $$f(1)$$ and $$f(2)$$ can be the same. As $$U$$ only contains the elements $$\mathtt{s}$$ and $$\mathtt{t}$$ this is impossible. Namely if $$f(0)\ne f(1)$$ we either have
\begin{equation*} f(0)=\mathtt{s}\text{ and }f(1)=\mathtt{t} \end{equation*}
or
\begin{equation*} f(0)=\mathtt{t}\text{ and }f(1)=\mathtt{s} \end{equation*}
Since the codomain $$U$$ only contains $$\mathtt{s}$$ and $$\mathtt{t}$$ the image $$f(2)$$ has to be either $$\mathtt{s}$$ and $$\mathtt{t}\text{,}$$ which means that we must have either $$f(2)=f(0)$$ or $$f(2)=f(1)\text{.}$$ This means that $$f$$ cannot be invertible.
The principle used in Example 9.6 can be also be applied when the sets have more elements.

### Example9.7.$$\N$$ and $$\{\mathtt{s},\mathtt{t}\}$$ do not have the same cardinality.

We show that the set of natural numbers $$\N=\{1,2,3,\dots\}$$ and $$U=\{\mathtt{s},\mathtt{t}\}$$ do not have the same cardinality by showing that there is no invertible function from $$\N$$ to $$U\text{.}$$
Let $$f:\N\to U\text{.}$$ Then $$f(1)\in U$$ and $$f(2)\in U$$ and $$f(2)\in U$$ and so on. As we want $$f$$ to be invertible no two of $$f(1)$$ and $$f(2)$$ and $$f(3)$$ and so on can be the same. As $$U$$ only contains the elements $$\mathtt{s}$$ and $$\mathtt{t}$$ this is impossible. Namely if $$f(1)\ne f(2)$$ we either have
• $$f(1)=\mathtt{s}$$ and $$f(2)=\mathtt{t}$$ or
• $$f(1)=\mathtt{t}$$ and $$f(2)=\mathtt{s}$$
Since the codomain $$U$$ only contains $$\mathtt{s}$$ and $$\mathtt{t}$$ the image $$f(3)$$ has to be either $$\mathtt{s}$$ and $$\mathtt{t}\text{,}$$ which means that we must have either $$f(3)=f(1)$$ or $$f(3)=f(2)\text{.}$$ This means that $$f$$ cannot be invertible.
If, in Definition 9.4 the set $$B$$ can be chosen as one of the sets $$\Z_n\text{,}$$ we use this to define the cardinality of the set $$A\text{.}$$

### Definition9.8.

Let $$A$$ be a set. If there is $$n\in \N$$ such that $$A$$ and $$\Z_n$$ have the same cardinality, we say that the cardinality of $$A$$ is $$n$$ and write $$\#A=n\text{.}$$
We read $$\#A=n$$ as “the cardinality of $$A$$ is $$n$$” or “the number of elements of $$A$$ is $$n\text{.}$$
Read Definition 9.4 and Definition 9.8 once more and complete the definition in Checkpoint 9.9.

### Checkpoint9.9.Definition of cardinality.

Complete the following:
Let $$A$$ and $$B$$ be nonempty sets.
We say that $$A$$ and $$B$$ have the same
• select
• cardinality
• depth
• height
• volume
• width
if there exists
• select
• a good
• an injective
• an invertible
• a nice
• an onto
function $$f:A\to B\text{.}$$
We say that the
• select
• cardinality
• depth
• height
• volume
• width
of $$A$$ is $$n$$ if there is
• select
• a good
• an injective
• an invertible
• a nice
• an onto
function from $$A$$ to
• select
• the set of natural numbers
• the set of integers
• {0,1,2,...,n-1}
• {0,1,2,..,n}
• {n}
• {-n,-n+1,-n+2,...,1}
.
If such a function exists we call $$A$$ finite.
If $$A$$ is finite we denote the
• select
• cardinality
• depth
• height
• volume
• width
of $$A$$ by $$\# A\text{.}$$
When an invertible function from a set to $$\Z_n$$ where $$m\in\N$$ is given the cardinality of the set immediately follows from the definition.

### Example9.10.Cardinality of the set $$\A$$ of characters.

The function $$C:\A\to\Z_{27}$$ given in Figure 8.1 is invertible. Thus $$\#\A=27\text{.}$$
In Checkpoint 9.11 determine the cardinality of a set when an invertible function from a set to $$\Z_n$$ where $$m\in\N$$ is given.

### Checkpoint9.11.Cardinality from invertible function.

Let $$Y$$ be a set. Assume there is an invertible function
\begin{equation*} m:Y\to \mathbb{Z}_{9} \end{equation*}
the number of elements in $$Y$$ is .
When we follow the definition of cardinality to show that a set has a certain cardinality, we use a backwards approach. Using our intuition of cardinality we count the number of elements in the set. Assume that we have counted $$n$$ elements. To prove that the cardinality of the set is $$n$$ we construct an invertible function from the set to $$\Z_n\text{.}$$

### Example9.12.Cardinality of $$\{\mathtt{m},\mathtt{a},\mathtt{t},\mathtt{h}\}$$.

Let $$B=\{\mathtt{m},\mathtt{a},\mathtt{t},\mathtt{h}\}\text{.}$$ We count $$4$$ elements and now apply Definition 9.8 to show that $$\#B=4\text{.}$$ Let $$f:B\to \Z_4$$ given by:
\begin{align*} f(\mathtt{m})\amp:=0\\ f(\mathtt{a})\amp:=1\\ f(\mathtt{t})\amp:=2\\ f(\mathtt{h})\amp:=3 \end{align*}
As the function $$f$$ is invertible, the cardinality of $$B$$ is $$4\text{.}$$
In Checkpoint 9.13 find $$n\in\N$$ such that there is an invertible function from $$\{0,1,2,\dots,n\}$$ to a given set and use this information to determine the cardinality of that set.

### Checkpoint9.13.Find cardinality.

Let $$Z=\lbrace 24,25,26,\dots,32\rbrace\text{.}$$
Because there is an invertible function
$$m:\Bigl\lbrace 0,1,2,...,$$$$\Bigr\rbrace\to Z$$
we have $$\# Z=$$.
We revisit the examples from the beginning of this section.

### Example9.14.Applying the definition of cardinality.

We give the cardinalities of some sets. In all but the first example we list an invertible function whose existence gives the cardinality of the set. This function in most cases is not unique, we only need to know that such a function exists.
1. $$\#\{\}=0$$ by Definition 9.3.
2. $$\#\{\mathtt{m}\}=1\text{,}$$ because the function $$f:\{\mathtt{m}\}\to\Z_1$$ given by $$f(\mathtt{m})=0$$ is invertible (recall that $$\ZZ_1=\{0\}$$).
3. $$\#\{\mathtt{m},\mathtt{a}\}=2\text{,}$$ because the function $$f:\{\mathtt{m},\mathtt{a}\}\to\Z_2$$ given by $$f(\mathtt{m})=0$$ and $$f(\mathtt{a})=1$$ is invertible.
Note that we can use any invertible function from $$\{\mathtt{m},\mathtt{a}\}$$ to $$\Z_2$$ to show that $$\#\{\mathtt{m},\mathtt{a}\}=2\text{.}$$ In this case there is only one other invertible function, namely $$g:\{\mathtt{m},\mathtt{a}\}\to\Z_2$$ given by $$g(\mathtt{m})=1$$ and $$g(\mathtt{a})=0\text{.}$$
4. $$\#\{1,2,3,4,5\}=5\text{,}$$ because the function $$f:\{1,2,3,4,5\}\to\Z_5$$ given by $$f(1)=0\text{,}$$ $$f(2)=1\text{,}$$ $$f(3)=2\text{,}$$ $$f(4)=3\text{,}$$ and $$f(5)=4$$ is invertible.
Note that we can use any invertible function from $$\{1,2,3,4,5\}$$ to $$\Z_5$$ to show that $$\#\{1,2,3,4,5\}=5\text{.}$$ For example, $$g:\{1,2,3,4,5\}\to\Z_5$$ given by $$f(1)=1\text{,}$$ $$f(2)=2\text{,}$$ $$f(3)=3\text{,}$$ $$f(4)=4\text{,}$$ and $$f(5)=0\text{.}$$
In practice, for many sets, we do not need to find such an invertible function $$f$$ to determine the cardinality of the set. Often counting the element suffices.

### Example9.15.Cardinalities of some sets.

We give the cardinality of some other sets.
1. $$\displaystyle \nr{\{\}}=0$$
2. $$\displaystyle \nr{\{1,2,3,4\}}=4$$
3. $$\displaystyle \nr{\{x\mid x\in\N \text{ and } x\lt 100\}} = 99$$
4. $$\displaystyle \nr{\{ 2,4,6,8,10 \}} = 5$$
5. $$\displaystyle \nr{\{1,2,3,\ldots,500\}} = 500$$
6. $$\displaystyle \nr{\{0,1,2,\ldots,500\}} = 501$$
7. $$\displaystyle \nr{\{0,1,2,\ldots,499\}} = 500$$
8. $$\displaystyle \nr{\Z_7}=\nr{\{0,1,2,3,4,5,6\}}=7$$
9. $$\displaystyle \nr{\Z_7^\otimes}=\nr{\{1,2,3,4,5,6\}}=6$$

### Example9.16.Cardinalities of special sets.

We give the cardinality of two more of the sets from Definition 5.23. Let $$n \in \mathbb{N}\text{.}$$ Then
1. $$\nr{\Z_n} = \nr{\{0,1,2,\dots,n-1\}} = n\text{,}$$ because the identity function $$\id_{\Z_n}$$ is invertible.
2. $$\nr{\Z_n^\otimes} = \nr{\{1,2,\dots,n-1\}} = n-1\text{.}$$ because the function $$f:\Z_n^\otimes\to\Z_{n-1}$$ given by $$f(x)=x-1$$ is invertible.

### Checkpoint9.17.Number of elements.

$$\#\lbrace 28,29,30,\dots,34\rbrace=$$
$$\#\lbrace \rbrace=$$
$$\#\lbrace 0 \rbrace=$$
$$\#\lbrace 1 \rbrace=$$
$$\#\lbrace 30 \rbrace=$$
$$\#\lbrace 28, 29, 30 \rbrace=$$