4  Cardinality and Countability

The size of a finite set is its element count. For infinite sets this breaks down — there is no natural number to assign — and the right substitute is comparison via bijections. Two sets have the same cardinality if they can be put in bijection; one is no larger than another if it injects into the other. The main difficulty in practice is constructing these functions explicitly.

4.1 Cardinality

Definition 4.1 (Cardinality) Sets \(X\) and \(Y\) have the same cardinality, written \(|X| = |Y|\), if there exists a bijection \(f : X \to Y\). We write \(|X| \leq |Y|\) if there exists an injection \(f : X \to Y\).

The notation is suggestive: an injection \(X \hookrightarrow Y\) embeds \(X\) into \(Y\) as a copy, so \(X\) is “no larger.” A natural question is whether \(|X| \leq |Y|\) and \(|Y| \leq |X|\) together force \(|X| = |Y|\). For finite sets this is immediate. For infinite sets it requires proof.

Theorem 4.1 (Schröder–Bernstein) If there exist injections \(f : X \to Y\) and \(g : Y \to X\), then \(|X| = |Y|\).

Proof. Define \(A_0 := X \setminus g(Y)\) and \(A_{n+1} := g(f(A_n))\) for \(n \geq 0\), and set \(A := \bigcup_{n=0}^\infty A_n\). Define \(h : X \to Y\) by \[ h(x) := \begin{cases} f(x) & x \in A, \\ g^{-1}(x) & x \in X \setminus A. \end{cases} \] This is well-defined: \(g\) is injective so \(g^{-1}\) exists on \(g(Y)\), and \(X \setminus A \subset g(Y)\) since any \(x \notin g(Y)\) lies in \(A_0 \subset A\).

Injectivity. If \(x_1, x_2 \in A\): \(f(x_1) = f(x_2)\) gives \(x_1 = x_2\). If \(x_1, x_2 \in X \setminus A\): \(g^{-1}(x_1) = g^{-1}(x_2)\) gives \(x_1 = x_2\). If \(x_1 \in A\) and \(x_2 \notin A\): then \(f(x_1) = g^{-1}(x_2)\), so \(x_2 = g(f(x_1))\). Since \(x_1 \in A = \bigcup_n A_n\), we have \(x_1 \in A_n\) for some \(n\), so \(g(f(x_1)) \in A_{n+1} \subset A\), contradicting \(x_2 \notin A\).

Surjectivity. Let \(y \in Y\). If \(y \in f(A)\), write \(y = f(x)\) for \(x \in A\) and \(h(x) = y\). If \(y \notin f(A)\), then \(g(y) \notin A\) — otherwise \(y \in f(A_n)\) for some \(n\) — so \(g(y) \in X \setminus A\) and \(h(g(y)) = g^{-1}(g(y)) = y\). \(\square\)

The proof builds a partition of \(X\) into two pieces, using \(f\) on one and \(g^{-1}\) on the other. The set \(A\) is chosen precisely to make the two pieces non-overlapping in \(Y\).

Exercise. Show that \(\mathbb{R} \sim \mathbb{R} \setminus \{0\}\).

Define \(f : \mathbb{R} \to \mathbb{R} \setminus \{0\}\) by \[ f(x) := \begin{cases} x & x \notin \mathbb{Z}, \\ x + 1 & x \in \mathbb{Z}. \end{cases} \] Each integer \(n\) is shifted to \(n+1\); non-integers are fixed. Injectivity: if \(x_1 \neq x_2\), either both are non-integers (so \(f(x_i) = x_i\) are distinct), or at least one is an integer, and the case split shows \(f(x_1) \neq f(x_2)\). Surjectivity: any nonzero non-integer \(y\) is hit by \(y\) itself; any nonzero integer \(n\) is hit by \(n - 1 \in \mathbb{Z}\). The value \(0\) is not in the codomain. \(\square\)

The same idea works for any countable set: removing (or adding) countably many elements from an uncountable set does not change its cardinality. One shifts a countable subset to absorb the change.

4.2 Countability

Definition 4.2 (Countable) A set \(X\) is countably infinite if \(|X| = |\mathbb{N}|\), i.e., its elements can be arranged in a sequence \(x_1, x_2, x_3, \ldots\) in which every element appears exactly once. \(X\) is countable if it is finite or countably infinite; otherwise it is uncountable.

Equivalently, \(X\) is countable iff there exists an injection \(X \hookrightarrow \mathbb{N}\). Establishing countability amounts to constructing an explicit listing; establishing uncountability means showing no such listing can exist.

Proposition 4.1 (Subsets and unions)  

  1. Every subset of a countable set is countable.
  2. A countable union of countable sets is countable.

Proof.

  1. Let \(X\) be countable and \(A \subset X\). An injection \(f : X \hookrightarrow \mathbb{N}\) restricts to an injection \(f|_A : A \hookrightarrow \mathbb{N}\).

  2. Let \(\{A_n\}_{n \geq 1}\) be countable. Write \(A_n = \{a_{n,1}, a_{n,2}, \ldots\}\). Every element of \(\bigcup_n A_n\) appears in the array \((a_{n,k})\); enumerate along diagonals to get a surjection \(\mathbb{N} \twoheadrightarrow \bigcup_n A_n\), then remove repetitions.

The only real idea: \(\mathbb{N} \times \mathbb{N}\) can be listed in a single sequence, as the diagonal enumeration witnesses. \(\square\)

Figure 4.1: Every pair \((m,n)\) receives a finite label, so \(\mathbb{N} \times \mathbb{N}\) is countable.

Proposition 4.2 (\(\mathbb{Q}\) is countable)  

Proof. Every rational is a fraction \(p/q\) with \(p \in \mathbb{Z}\), \(q \in \mathbb{Z}^+\). The map \(p/q \mapsto (p, q)\) injects \(\mathbb{Q}\) into \(\mathbb{Z} \times \mathbb{Z}^+\). Since \(\mathbb{Z}\) is countable (shift \(\mathbb{N}\) to cover negative integers) and a countable product of countable sets is countable, \(\mathbb{Z} \times \mathbb{Z}^+\) is countable. By (a) above, \(\mathbb{Q}\) is countable. \(\square\)

Exercise. Show that \(\mathbb{Z}\) is countably infinite by constructing an explicit bijection \(\mathbb{N} \to \mathbb{Z}\).

Define \(f : \mathbb{N} \to \mathbb{Z}\) by \[ f(n) := \begin{cases} n/2 & n \text{ even}, \\ -(n+1)/2 & n \text{ odd}. \end{cases} \] This enumerates \(0, -1, 1, -2, 2, -3, 3, \ldots\) and is a bijection. \(\square\)

4.3 Uncountability of \(\mathbb{R}\)

That \(\mathbb{Q}\) is countable and dense in \(\mathbb{R}\) might suggest \(\mathbb{R}\) itself is countable. It is not, and the proof is one of the most instructive in all of mathematics.

Theorem 4.2 (\(\mathbb{R}\) is uncountable) There is no surjection \(\mathbb{N} \to \mathbb{R}\).

Proof. It suffices to show \([0,1]\) is uncountable. Suppose for contradiction that \(f : \mathbb{N} \to [0,1]\) is a surjection. Write each \(f(n)\) in its decimal expansion. Construct a real number \(x \in [0,1]\) by choosing the \(n\)-th decimal digit of \(x\) to differ from the \(n\)-th decimal digit of \(f(n)\) — say, replace any digit \(d\) by \(d+1 \pmod{9}\), avoiding \(9\) to sidestep the \(0.999\ldots = 1\) ambiguity. Then \(x\) differs from \(f(n)\) in the \(n\)-th decimal place for every \(n\), so \(x \neq f(n)\) for all \(n\), contradicting surjectivity. \(\square\)

The diagonal argument does more than establish uncountability. It exhibits a structural gap: any attempted listing of \(\mathbb{R}\) is immediately defeated by a construction that reads off the diagonal and escapes. The same argument, applied to \(\{0,1\}^{\mathbb{N}}\) (infinite binary sequences), shows that the power set of any set is strictly larger than the set itself.

Proposition 4.3 (Cantor’s theorem) For any set \(X\), there is no surjection \(X \to \mathcal{P}(X)\).

Proof. Suppose \(f : X \to \mathcal{P}(X)\). Define \(D := \{x \in X : x \notin f(x)\}\). If \(D = f(x_0)\) for some \(x_0\), then \(x_0 \in D \iff x_0 \notin f(x_0) = D\), a contradiction. So \(D\) is not in the image of \(f\), and \(f\) is not surjective. \(\square\)

In particular \(|\mathbb{N}| < |\mathcal{P}(\mathbb{N})|\), and one can show \(|\mathcal{P}(\mathbb{N})| = |\mathbb{R}|\). The question of whether there is a set of intermediate cardinality — strictly between \(|\mathbb{N}|\) and \(|\mathbb{R}|\) — is the continuum hypothesis. This is independent of the usual axioms of set theory, and plays no role in what follows.

Exercise. Show that the set of all finite subsets of \(\mathbb{N}\) is countable.

Let \(\mathcal{F}\) be the collection of finite subsets of \(\mathbb{N}\). For each \(n \geq 0\), the collection \(\mathcal{F}_n\) of subsets of size \(n\) injects into \(\mathbb{N}^n\) (list elements in increasing order), and \(\mathbb{N}^n\) is countable by an \(n\)-fold product argument. Thus each \(\mathcal{F}_n\) is countable, and \(\mathcal{F} = \bigcup_{n \geq 0} \mathcal{F}_n\) is a countable union of countable sets, hence countable. \(\square\)

Note the contrast with the set of all subsets: \(\mathcal{P}(\mathbb{N})\) is uncountable by Cantor’s theorem, yet the finite subsets alone form a countable collection. The infinite subsets account for the uncountability.

Exercise. Show that \(|(0,1)| = |\mathbb{R}|\).

The map \(f : (0,1) \to \mathbb{R}\) defined by \(f(x) = \tan(\pi(x - \tfrac{1}{2}))\) is a bijection: it is continuous and strictly increasing on \((0,1)\), with \(f(x) \to -\infty\) as \(x \to 0^+\) and \(f(x) \to +\infty\) as \(x \to 1^-\). \(\square\)

Alternatively, \(g(x) = \log(x/(1-x))\) works. The point is that boundedness is a metric property, not a cardinality property — an interval and the whole line are the same size.

We have now established the language of sets and functions: the operations on sets, the structural properties of functions, and the ways of comparing infinite sizes. The next ingredient is a notion of nearness. To make precise what it means for points to be close, for sequences to converge, and for maps to be continuous, we need additional structure — and that is where topology begins.