# Lecture 5: cardinality and countability

• cardinality definitions: $$|X| \leq |Y|$$, $$|X| \geq |Y|$$, $$|X| = |Y|$$, countable
• countable examples

## Definitions

For now, we will not use the symbol $$|X|$$ by itself. It does not mean "the number of elements of the set", although our definitions will be consistent with this meaning. Until told otherwise, you may only use the symbol $$|X|$$ as part of the phrases "$$|X| \leq |Y|$$", "$$|X| \geq |Y|$$", or "$$|X| = |Y|$$". This will prevent you from accidentally using reasoning that only applies to finite sets.

Definitions: Let $$X$$ and $$Y$$ be sets.

• $$|X| \geq |Y|$$ means "there exists a surjection $$f : X → Y$$.
• $$|X| \leq |Y|$$ means "there exists an injection $$f : X → Y$$.
• $$|X| = |Y|$$ means "there exists a bijection $$f : X → Y$$.

MCS uses the notation "X surj Y" (respectively "inj" or "bij"), but this can be confusing: surjectivity is a property of functions, not sets. For example, just because you find one non-injective function from $$X$$ to $$Y$$ does not mean that $$|X| \nleq |Y|$$.

## Properties of cardinality

It is not obvious that this use of $$\leq$$ and $$\geq$$ is justified. There are many things to prove, most of which are easy. We proved one of them:

Claim: (Cantor-Schroder-Bernstein) $$|X| \geq |Y|$$ then $$|Y| \leq |X|$$.

Proof: Suppose $$|X| \geq |Y|$$. Then by definition, there exists a surjection $$f : X → Y$$. We showed last time that $$f$$ must have a right inverse $$g : Y → X$$ (which means $$f \circ g = id$$). This means $$g$$ has a left inverse (namely $$f$$), so $$g$$ must be injective. Therefore there is an injection from $$Y$$ to $$X$$, so $$|Y| \leq |X|$$ as required.

Other properties you could check for practice:

• if $$|X| \leq |Y|$$ then $$|Y| \geq |X|$$
• if $$|X| \leq |Y|$$ and $$|Y| \leq |Z|$$ then $$|X| \leq |Z|$$
• if $$|X| = |Y|$$ then $$|X| \leq |Y|$$ and $$|X| \geq |Y|$$
• $$|X| = |X|$$
• if $$|X| = |Y|$$ then $$|Y| = |X|$$.

There is one property that is true, but the proof is very non-obvious:

Claim: if $$|X| \leq |Y|$$ and $$|Y| \leq |X|$$ then $$|Y| = |X|$$.

The proof is beyond the scope of the course, but it is worth starting it to see why it is hard. If you are curious, here is a proof from a previous semester. You are not responsible for knowing this proof, but it only uses techniques that you should be comfortable with so you should be able to read it.

Note: You may use these properties without proof, unless we ask you to prove them.

## Countability

Informally, a set $$X$$ is countable if you can put it in a (potentially infinite) list. This can be formalized by saying that there is a "first element", a "second element", and so on, and each element is the "nth" element for some $$n$$. In other words, there should exist a surjection $$f : \mathbb{N} → X$$. Even more concisely:

Definition: $$X$$ is countable if $$|\mathbb{N}| \geq |X|$$.

Equivalently, $$X$$ is countable if

• there exists a surjection $$f : \mathbb{N} → X$$
• there exists an injection $$f : X → \mathbb{N}$$
• $$|X| \leq |\mathbb{N}|$$.

If $$|X| = |\mathbb{N}|$$ then we say $$X$$ is countably infinite.

## Examples

• the set $$\mathbb{N}$$ is countable; the identity function is a surjection

• the set $$X = \mathbb{N} \cup \{-1\}$$ is countable; let $$f : \mathbb{N} → X$$ be given by $$f(n) = n - 1$$. You can check that $$f$$ is surjective

• the set of integers $$\mathbb{Z}$$ is countable. Let $$f : \mathbb{N} → \mathbb{Z}$$ be given by $$f(n) ::= -n/2$$ if $$n$$ is even and $$(n+1)/2$$ if $$n$$ is odd. We must show $$f$$ is surjective, i.e. for all $$i \in \mathbb{Z}$$, there exists $$n \in \mathbb{N}$$ such that $$f(n) = i$$. To do so, choose an arbitrary $$i$$. If $$i \gt 0$$, let $$n = 2i - 1$$. We see that $$n$$ is odd, so $$f(n) = (n+1)/2 = i$$, and thus $$i$$ is in the image of $$f$$. If $$i \leq 0$$ on the other hand, we can choose $$n = -2i$$. Then $$n$$ is even, so $$f(n) = -(-2i)/2 = i$$, and again, we see that $$i$$ is in the image of $$f$$. In either case, $$i$$ is in the image of $$f$$, so $$f$$ must be surjective.

• Next time we will show that $$\mathbb{Q}$$ is countable, but $$\mathbb{R}$$ is uncountable.