Evanalysis
6.1Estimated reading time: 23 min

6.1 Cardinality, countability, and cardinal inequalities

Compare sizes of sets by bijections and injections, prove that Z and Q are countable, and read the Cantor-Bernstein theorem as the antisymmetry principle for cardinal size.

Course contents

Chapter 6 changes the question we ask about a set. Earlier chapters developed number systems and their operations. We now ask how large a set is, even when there is no last element to count. The answer is expressed through functions: a bijection matches two sets exactly, while an injection records one set inside another without collisions. These ideas make statements about infinite size precise.

Functions used for comparing sets

Let f:X→Yf:X\to Y be a function. Its image is

f(X)={f(x)∣x∈X}⊆Y,f(X)=\{f(x)\mid x\in X\}\subseteq Y,

and its preimage of B⊆YB\subseteq Y is

f−1(B)={x∈X∣f(x)∈B}.f^{-1}(B)=\{x\in X\mid f(x)\in B\}.

The notation f−1(y)f^{-1}(y) can mean the preimage of the singleton {y}\{y\}; it does not mean that an inverse function exists. An inverse function exists only when the map is bijective.

Definition

Injection, surjection, and bijection

The function f:X→Yf:X\to Y is injective if

f(x1)=f(x2)⟹x1=x2(x1,x2∈X).f(x_1)=f(x_2)\Longrightarrow x_1=x_2 \qquad (x_1,x_2\in X).

Thus every element of YY has at most one preimage. It is surjective if

∀y∈Y  ∃x∈X such that f(x)=y,\forall y\in Y\;\exists x\in X\text{ such that }f(x)=y,

or equivalently f(X)=Yf(X)=Y; every element of the codomain is hit. It is a bijection if it is both injective and surjective.

The codomain matters. For example, f:N→Nf:N\to N defined by f(n)=n+1f(n)=n+1 is injective but not surjective because 00 is not hit. If its codomain were N∖{0}N\setminus\{0\}, the same rule would be bijective. A claim about cardinality must therefore state both the domain and codomain.

Worked example

Checking the three properties

Consider u:{0,1,2}→{a,b,c,d}u:\{0,1,2\}\to\{a,b,c,d\} with

u(0)=a,u(1)=c,u(2)=a.u(0)=a,\qquad u(1)=c,\qquad u(2)=a.

The map is not injective because u(0)=u(2)u(0)=u(2) although 0≠20\ne2. It is not surjective because bb and dd are not outputs. This small example separates the two conditions: injectivity concerns repeated outputs, whereas surjectivity concerns omitted codomain elements.

Same cardinality and countability

Definition

Same cardinality

Sets XX and YY have the same cardinality, written

∣X∣=∣Y∣,|X|=|Y|,

if there is a bijection f:X→Yf:X\to Y.

The elements being paired need not be alike. A pairing between numbers and ordered pairs is just as legitimate as a pairing between two lists of numbers. For finite sets this agrees with ordinary counting.

Concept lensStructural

Cardinality as counting and as matching

With finite sets, size can feel like an inventory: count the elements. For arbitrary sets, the definition replaces inventory with a matching test: can every element of XX be paired with exactly one element of YY, and vice versa? This is why NN and the even natural numbers 2N={0,2,4,…}2N=\{0,2,4,\ldots\} have the same cardinality via n↦2nn\mapsto 2n, even though 2N2N is a proper subset of NN. The bijection records equal size; proper containment alone does not imply strictly smaller cardinality.

Definition

Finite set

A set XX is finite if ∣X∣=∣n∣|X|=|n| for some n∈Nn\in N, where we represent nn by the finite label set n={0,…,n−1}n=\{0,\ldots,n-1\}; when n=0n=0, this means n=∅n=\varnothing. We then write ∣X∣=n|X|=n. The empty set is finite, with ∣∅∣=0|\varnothing|=0.

Definition

Countable and at most countable

A set XX is countable in this course if it is finite or if

∣X∣=∣N∣.|X|=|N|.

Equivalently, it is at most countable when it is finite or countably infinite. Some texts use “countable” only for the infinite case, so the phrase “at most countable” removes that convention ambiguity. A set that is not at most countable is uncountable.

For a countably infinite set, an enumeration is a sequence x0,x1,x2,…x_0,x_1,x_2,\ldots containing every element exactly once. Saying “exactly once” combines surjectivity of the listing with injectivity of its index map. Merely writing down an infinite sequence is not enough: it must be clear why no element is omitted and why repetitions do not occur.

Explicit countable sets

The integers

Theorem

The integers are countable

∣Z∣=∣N∣|Z|=|N|.

Assume N={0,1,2,…}N=\{0,1,2,\ldots\}. Define

e(0)=0,e(2k−1)=k,e(2k)=−k(k≥1).e(0)=0,\qquad e(2k-1)=k,\qquad e(2k)=-k\quad(k\ge1).

This gives the list 0,1,−1,2,−2,3,−3,…0,1,-1,2,-2,3,-3,\ldots.

Proof. Every integer is either 00, a positive integer kk, or a negative integer −k-k with k≥1k\ge1. These occur respectively at index 00, index 2k−12k-1, and index 2k2k. Hence ee is surjective. The three cases have disjoint values, and within the positive or negative cases the displayed indices determine kk uniquely, so ee is injective. Therefore ee is a bijection. If NN is indexed from 11, shift the indices by one; the cardinality statement is unchanged.

This is the basic infinite-set surprise: adding all negative integers to NN does not create a larger cardinality. The comparison concerns the existence of a bijection, not whether one set contains the other.

The rationals

Theorem

The rationals are countable

The set QQ of rational numbers is at most countable, and in fact countably infinite.

Every positive rational has a unique lowest-terms representation p/qp/q, where p,q∈{1,2,3,…}p,q\in\{1,2,3,\ldots\} and gcd⁡(p,q)=1\gcd(p,q)=1. Put p/qp/q in row pp and column qq of a grid. Scan the grid by the finite diagonals p+q=2,3,4,…p+q=2,3,4,\ldots. Within each diagonal, scan in increasing numerator (any fixed order would do), and retain only coprime pairs. The beginning is

1, 12, 2, 13, 3, 14, 23, 32, 4,….1,\ \frac12,\ 2,\ \frac13,\ 3,\ \frac14,\ \frac23,\ \frac32,\ 4,\ldots.

Worked example

Why the rational diagonal scan works

Take 7/57/5. It is already in lowest terms and lies on the diagonal p+q=12p+q=12. Only finitely many diagonals precede diagonal 1212, and diagonal 1212 contains only finitely many pairs. Thus 7/57/5 is reached at a finite position. Conversely, retaining only coprime pairs means that two recorded pairs cannot represent the same positive rational: uniqueness of lowest terms forces (p,q)(p,q) to be the same pair. The scan is therefore both onto Q+Q_{+} and one-to-one.

The same argument explicitly proves both directions. No positive rational is missed because it has a lowest-terms pair, and no positive rational is repeated because that pair is unique. If the resulting list is q1,q2,q3,…q_1,q_2,q_3,\ldots, then

0,q1,−q1,q2,−q2,q3,−q3,…0,q_1,-q_1,q_2,-q_2,q_3,-q_3,\ldots

lists all of QQ exactly once. Zero occurs once, and every nonzero rational has one sign and one positive absolute value. Hence QQ is countable. It is not finite: the inclusion n↦nn\mapsto n from NN into QQ is injective, so QQ contains infinitely many distinct integers.

A diagonal scan of positive rational numbers

Figure. The diagonal scan turns a two-dimensional grid into one sequence; the lowest-terms condition removes duplicate names for the same rational.

Density is a different property. The rationals meet every nonempty open interval of the real line, but the diagonal procedure still places them in a single list. Dense does not mean uncountable.

Products of countable sets

The grid argument also gives a useful explicit pairing of two copies of NN. For a,b∈Na,b\in N, let

π(a,b)=(a+b)(a+b+1)2+b.\pi(a,b)=\frac{(a+b)(a+b+1)}2+b.

All pairs with fixed a+b=sa+b=s form a finite diagonal, and the triangular number s(s+1)/2s(s+1)/2 skips exactly the preceding diagonals. Therefore π\pi lists every pair once. More formally, from n=π(a,b)n=\pi(a,b) one recovers the unique diagonal ss satisfying s(s+1)/2≤n<(s+1)(s+2)/2s(s+1)/2\le n\lt (s+1)(s+2)/2, then b=n−s(s+1)/2b=n-s(s+1)/2 and a=s−ba=s-b. Thus π:N×N→N\pi:N\times N\to N is a bijection.

Theorem

A countable triple is countable

∣N×N×N∣=∣N∣|N\times N\times N|=|N|.

Proof. Define

Φ(a,b,c)=π(π(a,b),c).\Phi(a,b,c)=\pi(\pi(a,b),c).

Both applications of π\pi are bijections, so their composition is a bijection from N3N^3 to NN. The inverse first recovers (π(a,b),c)(\pi(a,b),c) and then recovers (a,b)(a,b). This is the concrete content of “countable times countable times countable”: a finite-dimensional grid can be scanned by successive finite diagonals. The argument also handles empty factors in the usual way: if one factor is empty, the product is empty and therefore finite; the displayed bijection concerns three copies of NN.

The same pairing handles a finite number of labelled copies of a countable set. For example, map (n,0)(n,0) and (n,1)(n,1) into NN by (n,i)↦π(n,i)(n,i)\mapsto\pi(n,i). The map is injective, so two copies of NN can be stored in one copy of NN; applying the inverse pairing to the appropriate coordinates recovers the label and the original number. This explains why an infinite list can absorb a finite amount of extra bookkeeping. It does not say that every enlargement has the same size: the existence of the particular map must still be proved.

More generally, cardinality comparisons can be transported through maps. If X→YX\to Y and Y→ZY\to Z are injections, their composition gives ∣X∣≤∣Z∣|X|\le|Z|. If both maps are bijections, the composition is a bijection. These two simple rules are the bookkeeping behind the integer, rational, and triple enumerations in this section.

Cardinal inequalities

Definition

Cardinal inequality

For sets XX and YY, write

∣X∣≤∣Y∣|X|\le |Y|

if there exists an injection X→YX\to Y. Write ∣X∣<∣Y∣|X|\lt|Y| if ∣X∣≤∣Y∣|X|\le|Y| and ∣X∣≠∣Y∣|X|\ne|Y|.

The arrow direction is essential: an injection from XX into YY says that YY has enough distinct locations to store every element of XX, so the domain is the no-larger side. The inclusion N→ZN\to Z, n↦nn\mapsto n, proves ∣N∣≤∣Z∣|N|\le|Z|; it does not alone prove equality. The enumeration of ZZ supplies the reverse size comparison, or the explicit bijection above supplies equality directly.

Worked example

A finite comparison with unused codomain elements

The map r:{1,2,3}→{a,b,c,d}r:\{1,2,3\}\to\{a,b,c,d\} given by r(1)=br(1)=b, r(2)=dr(2)=d, r(3)=ar(3)=a is injective. Thus ∣{1,2,3}∣≤∣{a,b,c,d}∣|\{1,2,3\}|\le|\{a,b,c,d\}|. It is not surjective because cc is unused, which is exactly why the inequality may be strict.

Theorem

Cardinal inequalities form a partial-order pattern

The relation ≤\le is reflexive, transitive, and antisymmetric on cardinalities. Consequently <\lt is irreflexive and transitive.

Proof. Reflexivity follows from the injective identity map idX:X→Xid_X:X\to X. For transitivity, if f:X→Yf:X\to Y and g:Y→Zg:Y\to Z are injections, then g∘fg\circ f is injective: equality of its outputs first gives equality of the ff outputs, then equality of inputs. Antisymmetry is precisely the Cantor-Bernstein theorem below. Finally, ∣X∣<∣X∣|X|\lt|X| is impossible because ∣X∣=∣X∣|X|=|X|; transitivity of strict inequality follows by combining transitivity of ≤\le with the unequal-cardinality conditions.

There is no set whose elements are all sets. Assuming such a universal set would permit a Russell-type self-membership construction and a contradiction. Accordingly, ≤\le is not being presented as one relation with a global “set of all sets” as its domain. The partial-order statements are about any chosen collection of sets, or the cardinalities represented by that collection, that we are comparing. This qualification is foundational bookkeeping; it does not change any of the maps or proofs above.

A surjection X→YX\to Y intuitively says that YY is no larger than XX, but turning that intuition into an injection Y→XY\to X requires selecting one preimage for each y∈Yy\in Y. The next note examines that choice issue; here we use injections and bijections directly, without assuming a choice function.

Cantor-Bernstein: the two injections fit together

Theorem

Cantor-Bernstein theorem

If f:X→Yf:X\to Y and g:Y→Xg:Y\to X are injections, then ∣X∣=∣Y∣|X|=|Y|.

The theorem is stronger than “two obvious lists look similar.” It constructs a bijection even when neither injection is onto. Set

A0=X,B0=g(Y),A_0=X,\qquad B_0=g(Y),

and recursively define

An+1=g(f(An)),Bn+1=g(f(Bn)).A_{n+1}=g(f(A_n)),\qquad B_{n+1}=g(f(B_n)).

Because g(Y)⊆Xg(Y)\subseteq X, these sets are nested:

A0⊇B0⊇A1⊇B1⊇A2⊇B2⊇⋯ .A_0\supseteq B_0\supseteq A_1\supseteq B_1\supseteq A_2\supseteq B_2\supseteq\cdots.

The inclusions are inductive: A1⊆B0A_1\subseteq B_0, then Bn+1⊆An+1B_{n+1}\subseteq A_{n+1}, and the preceding inclusion An⊆Bn−1A_n\subseteq B_{n-1} gives An+1⊆BnA_{n+1}\subseteq B_n. If XX or YY is empty, the two injections force both sets to be empty and the unique empty map is the required bijection; the construction below also covers that case.

The layer An∖BnA_n\setminus B_n is the part on which we will use ff; the remaining points lie in g(Y)g(Y) and will use the inverse of gg on its image.

Proof. First note that g∘f:X→Xg\circ f:X\to X is injective. For every nn, it maps An∖BnA_n\setminus B_n bijectively onto An+1∖Bn+1A_{n+1}\setminus B_{n+1}. Indeed, injectivity gives one-to-one behavior. If z∈An+1∖Bn+1z\in A_{n+1}\setminus B_{n+1}, write z=g(f(x))z=g(f(x)) with x∈Anx\in A_n; if x∈Bnx\in B_n, then z∈g(f(Bn))=Bn+1z\in g(f(B_n))=B_{n+1}, a contradiction. Therefore x∈An∖Bnx\in A_n\setminus B_n, proving onto behavior between the layers.

Define h:X→Yh:X\to Y by

h(x)={f(x),x∈An∖Bn for some n,g−1(x),x∉An∖Bn for every n.h(x)= \begin{cases} f(x),&x\in A_n\setminus B_n\text{ for some }n,\\ g^{-1}(x),&x\notin A_n\setminus B_n\text{ for every }n. \end{cases}

Here g−1g^{-1} means the inverse of the bijection g:Y→g(Y)g:Y\to g(Y), not an inverse on all of XX. The second case is defined: a point outside every layer cannot be in A0∖B0=X∖g(Y)A_0\setminus B_0=X\setminus g(Y), so it belongs to g(Y)g(Y). The layers are disjoint because they come from a nested sequence, so hh is well-defined.

To prove injectivity, suppose h(x1)=h(x2)h(x_1)=h(x_2). If both points lie in layers, injectivity of ff gives x1=x2x_1=x_2. If both are in the second case, injectivity of g−1g^{-1} gives equality. In the mixed case, say x1∈An∖Bnx_1\in A_n\setminus B_n and h(x2)=g−1(x2)h(x_2)=g^{-1}(x_2), the equality implies x2=g(f(x1))x_2=g(f(x_1)). The layer mapping just proved puts x2x_2 in An+1∖Bn+1A_{n+1}\setminus B_{n+1}, contradicting that x2x_2 was in the second case.

For surjectivity, take y∈Yy\in Y and put x=g(y)∈Xx=g(y)\in X. If xx is in no layer, then h(x)=g−1(x)=yh(x)=g^{-1}(x)=y. Otherwise x∈An∖Bnx\in A_n\setminus B_n. It cannot be in the zeroth layer, since A0∖B0=X∖g(Y)A_0\setminus B_0=X\setminus g(Y) while x∈g(Y)x\in g(Y). Hence n≥1n\ge1; the layer bijection gives an x′∈An−1∖Bn−1x'\in A_{n-1}\setminus B_{n-1} with g(f(x′))=x=g(y)g(f(x'))=x=g(y). Since gg is injective, f(x′)=yf(x')=y, and therefore h(x′)=yh(x')=y. Thus hh is surjective and bijective, proving ∣X∣=∣Y∣|X|=|Y|. No choice function is used: the construction is determined by the given ff and gg.

Why coarser layers can miss a point

The sets AnA_n alone do not record where the inverse of gg can be used. Put A=⋂n≥0AnA=\bigcap_{n\ge0}A_n. The first proposed shortcut uses ff on every difference An∖An+1A_n\setminus A_{n+1} and on AA. These pieces exhaust XX, so that proposal is simply

h1(x)=f(x)(x∈X).h_1(x)=f(x)\qquad(x\in X).

The second proposal is

h2(x)={f(x),x∈An∖An+1 for some n,g−1(x),x∈A.h_2(x)=\begin{cases} f(x),&x\in A_n\setminus A_{n+1}\text{ for some }n,\\ g^{-1}(x),&x\in A. \end{cases}

Its inverse branch is defined because A⊆A1⊆g(Y)A\subseteq A_1\subseteq g(Y), but being well-defined does not guarantee a bijection. Take X=Y=NX=Y=N, f(n)=n+1f(n)=n+1, and g(n)=ng(n)=n. Then An={n,n+1,…}A_n=\{n,n+1,\ldots\} and A=∅A=\varnothing. Both proposals give h1(n)=h2(n)=n+1h_1(n)=h_2(n)=n+1, which misses 00. The BnB_n layers in the proved construction keep the information these shortcuts discard: where the inverse branch is available and how the two branches avoid collisions.

Common mistakes and subtle points

Common mistake

One injection gives one inequality

An injection X→YX\to Y proves ∣X∣≤∣Y∣|X|\le|Y|; it does not prove equality. For equality, provide a bijection or injections in both directions and invoke Cantor-Bernstein.

Common mistake

Surjective is not the same as injective

A surjection may have many inputs mapping to one output, while an injection may leave codomain elements unused. Always check the correct quantified condition.

Common mistake

Lowest terms are part of the Q proof

Without the coprimality condition, 1/11/1, 2/22/2, and 3/33/3 would repeat one rational. The grid is countable, but the proposed list must also be injective.

Checkpoint

Which direction of map proves ∣X∣≤∣Y∣|X|\le|Y|, and what must it preserve?

State the domain, codomain, and collision condition.

Solution · Answer

An injection f:X→Yf:X\to Y proves ∣X∣≤∣Y∣|X|\le|Y|. It preserves distinctness: f(x1)=f(x2)f(x_1)=f(x_2) forces x1=x2x_1=x_2; it need not hit every element of YY.

Checkpoint

Why does the diagonal enumeration list every positive rational?

Use lowest terms and the finite value p+qp+q.

Solution · Answer

Every positive rational has a unique lowest-terms pair (p,q)(p,q). That pair lies on the finite diagonal p+qp+q, and the scan reaches every finite diagonal.

Checkpoint

Why does the Cantor-Bernstein definition use BnB_n as well as AnA_n?

Solution · Answer

B0=g(Y)B_0=g(Y) ensures that a point outside every layer belongs to g(Y)g(Y), where g−1g^{-1} is defined. Moreover, g∘fg\circ f maps An∖BnA_n\setminus B_n onto An+1∖Bn+1A_{n+1}\setminus B_{n+1}. Thus a collision between the two branches would put the point from the inverse branch in a layer, contradicting its branch condition.

Exercises

Checkpoint

Give an explicit bijection from NN to ZZ and prove both injectivity and surjectivity.

Solution · Guided solution

Use e(0)=0e(0)=0, e(2k−1)=ke(2k-1)=k, and e(2k)=−ke(2k)=-k for k≥1k\ge1. Zero, each positive integer kk, and each negative integer −k-k appear at indices 00, 2k−12k-1, and 2k2k, respectively, proving surjectivity. These three types of values are disjoint, and each formula determines kk uniquely, proving injectivity.

Checkpoint

Show directly that ∣N×N×N∣=∣N∣|N\times N\times N|=|N| using the pairing map π(a,b)=(a+b)(a+b+1)2+b\pi(a,b)=\frac{(a+b)(a+b+1)}2+b.

Solution · Guided solution

First show π\pi is bijective by recovering the unique diagonal s=a+bs=a+b and then a,ba,b. The composition Φ(a,b,c)=π(π(a,b),c)\Phi(a,b,c)=\pi(\pi(a,b),c) is a composition of two bijections, hence is a bijection from the triple product to NN.

Checkpoint

In the Cantor-Bernstein proof, why is g−1(x)g^{-1}(x) defined in the second case?

Solution · Guided solution

The zeroth layer is X∖g(Y)X\setminus g(Y). A point in no layer is therefore not in that set, so it lies in g(Y)g(Y), where the inverse of g:Y→g(Y)g:Y\to g(Y) is defined.

Read 2.2 Functions and relations for images, preimages, injections, surjections, and inverses. Then continue to 6.2 Cantor's theorem, continuum, and choice.

Practice

Work out your answer, then check it. You can revise and try again.

Loading…

Key terms in this unit