# Lecture 14: Cardinality and countability

• Using inverses to prove things about cardinality

• Definition of countability
• Examples: $$ℤ$$, $$ℚ^+$$.

## Using inverses to prove facts about cardinality

In the last lecture, we noted that facts like $$|A| = |A|$$ seem obvious at first glance, but are not actually obvious because $$|A| = |A|$$ means that there exists a bijection from $$A$$ to $$A$$, and not that some number is equal to itself. By redefining $$=$$, $$≤$$, and $$≥$$ for cardinalities, we need to prove that they behave nicely. These proofs can be done directly, but using inverses can make them simpler. Here are the properties that we expect $$≤$$ and $$≥$$ to satisfy:

Claims: - $$|A| ≥ |B|$$ if and only if $$|B| ≤ |A|$$ - $$|A| ≤ |A|$$ - if $$|A| ≤ |B|$$ and $$|B| ≤ |C|$$ then $$|A| ≤ |C|$$ - if $$|A| ≤ |B|$$ and $$|B| ≤ |A|$$ then $$|A| = |B|$$

Aside: the second, third, and fourth of these properties are called "reflexivity", "transitivity", and "antisymmetry" of $$≤$$; relationships that satisfy these properties are called "partial orders". We'll talk about partial orders in a week or two.

We could prove these claims directly from the definitions, by constructing surjections, injections, or bijections as necessary (and checking that the functions we create have those properties). But inverse functions make some of those proofs easier. We did the following example:

Claim: if $$|A| ≤ |B|$$ then $$|B| ≥ |A|$$.

Proof: Suppose $$|A| ≤ |B|$$. Then there exists an injection $$f : A → B$$. Since $$f$$ is an injection, it has a left inverse $$g : B → A$$, i.e. $$g \circ f = id$$. But this equations says that $$f$$ is a right inverse of $$g$$, so $$g$$ must be a surjection. Therefore there is a surjection from $$B$$ to $$A$$, so $$|B| ≥ |A|$$.

Most of the other claims have similarly simple proofs. The exception is the last (antisymmetry).

Claim: if $$|A| ≤ |B|$$ and $$|B| ≤ |A|$$ then $$|B| = |A|$$.

This is also called the Cantor-Schröder-Bernstein theorem. Here is a proof. You are not responsible for this proof, but you should read it for the following reasons: 1. it's bad practice to believe claims that don't come with proofs; 2. it shows that some things that seem like they should be obvious are quite hard to prove; and 3. it's a good example of constructing a function and showing that it is a bijection. It's also worth trying to prove the theorem on your own, to see what the difficult part is.

## Countability

Informally, a set $$X$$ is countable if its elements can be put in a (potentially infinite) list. That is, the set has a 0th element, a 1st element, a 2nd element, and so on, and each element is the $$n$$th element for some $$n$$. Put another way, we can write $$X = \{x_0, x_1, x_2, \dots\}$$.

To formalize this, notice that what we are describing is a function $$f$$ from the natural numbers to $$X$$. $$f(0)$$ gives $$x_0$$ (the 0'th element of the set), $$f(1)$$ gives $$x_1$$ (the first element), and so on. The requirement that every element of $$X$$ is in the list is another way of saying that $$f$$ must be surjective. This leads to the following definition:

Definition: $$X$$ is countable if there exists a surjection $$f : ℕ → X$$.

Equivalently, $$X$$ is countable if $$|X| ≤ |ℕ|$$ (or if $$|ℕ| \geq |X|$$). A set can fail to be countable if it is too big. We'll see an example next time.

## Examples of countable sets:

Claim: $$ℤ = \{\dots,-2,-1,0,1,2,\dots\}$$ is countable.

Proof: Let $$f : ℤ → ℕ$$ be given by $$f(n) = 2n$$ if $$n ≥ 0$$ and $$-2n-1$$ if $$n \lt 0$$. I claim $$f$$ is an injection. To see this, choose an arbitrary $$n_1$$ and $$n_2$$ and assume $$f(n_1) = f(n_2)$$. Note that $$f(n)$$ is even if and only if $$n \geq 0$$; this suggests we consider the even and odd cases separately.

Suppose $$f(n_1)$$ and $$f(n_2)$$ are even. Then $$n_1$$ and $$n_2$$ are nonnegative, so we have $$f(n_1) = 2n_1$$ and $$f(n_2) = 2n_2$$. Since $$f(n_1) = f(n_2)$$ we have $$2n_1 = 2n_2$$; canceling 2 gives $$n_1 = n_2$$ as desired.

On the other hand, $$f(n_1)$$ and $$f(n_2)$$ could be even; in this case we have $$n_1 \lt 0$$ and $$n_2 \lt 0$$ so $$-2n_1-1 = f(n_1) = f(n_2) = -2n_2 -1$$ so again $$n_1 = n_2$$.

Thus in all cases, $$n_1 = n_2$$, completing the proof.

Claim: the set of rational numbers (i.e. fractions, written $$ℚ$$) is countable.

Proof: In fact, we will show that the set of positive rationals, $$ℚ^+$$, is countable. The countability of $$ℚ$$ follows without too much more effort.

We can draw a table containing all of the rational numbers:

1 2 3 4 $$\cdots$$
1 1/1 2/1 3/1 4/1 $$\cdots$$
2 1/2 2/2 3/2 4/2 $$\cdots$$
3 1/3 2/3 3/3 4/3 $$\cdots$$
$$\vdots$$ $$\ddots$$

Note that every positive rational number is contained at least once in the table.

Now we can define a surjection $$f$$ from $$ℕ$$ to $$ℚ^+$$ by tracing each lower-left to upper-right diagonal, and listing the elements as we pass them. For example, the first few rational numbers would be:

n f(n)
0 1/1
1 1/2
2 2/1
3 1/3
4 2/2
5 3/1
6 1/4

For any rational number $$y$$, $$y$$ appears somewhere in the table, which means it lies on some diagonal, which means that eventually it will be output by $$f$$. In other words, there exists some $$n$$ with $$f(n) = y$$; so $$f$$ is surjective. Therefore $$|ℕ| \geq |ℚ|$$, so $$ℚ^+$$ is countable.

Note: this technique is (confusingly) not called diagonalization. Diagonalization refers to the technique we use in the following proof: