Skip to content

7.2 Cardinality and Countability

Cardinality, finite and infinite sets, countable sets, uncountable sets, and Cantor diagonal arguments.

Cardinality is the part of set theory that compares the sizes of sets. For finite sets this agrees with ordinary counting, but for infinite sets the idea becomes more subtle, because two infinite sets may have the same size even when one appears to sit inside the other as a proper subset.

Size by Correspondence

The basic idea is that two sets have the same size when their elements can be paired without omission or repetition. This avoids relying on ordinary counting, which works only for finite sets.

For example, the sets:

A={a,b,c} A=\{a,b,c\}

and:

B={1,2,3} B=\{1,2,3\}

have the same size because we can pair:

a1,b2,c3 a \leftrightarrow 1, \quad b \leftrightarrow 2, \quad c \leftrightarrow 3

In finite cases this means both sets have the same number of elements. In infinite cases this becomes the definition of having the same cardinality.

Definition 7.42 (Equipotence)

Two sets AA and BB are equipotent if there exists a bijection:

f:AB f:A\to B

In this case we say that AA and BB have the same cardinality, and we write:

A=B |A|=|B|

The notation A|A| denotes the cardinality of AA, meaning the size of AA considered up to bijection.

Example 7.43

The set:

N={0,1,2,3,} \mathbb{N}=\{0,1,2,3,\dots\}

and the set of even natural numbers:

E={0,2,4,6,} E=\{0,2,4,6,\dots\}

have the same cardinality.

Define:

f:NE f:\mathbb{N}\to E

by:

f(n)=2n f(n)=2n

This function is injective because:

2m=2nm=n 2m=2n \to m=n

It is surjective because every even natural number has the form 2n2n for some nNn\in\mathbb{N}.

Thus ff is a bijection, and therefore:

N=E |\mathbb{N}|=|E|

This example shows that an infinite set can have the same cardinality as one of its proper subsets.

Lemma 7.44 (Equipotence Is an Equivalence Relation)

Equipotence is an equivalence relation on sets.

That is, for all sets AA, BB, and CC:

A=A |A|=|A|

if:

A=B |A|=|B|

then:

B=A |B|=|A|

and if:

A=BandB=C |A|=|B| \quad \text{and} \quad |B|=|C|

then:

A=C |A|=|C|

Proof

Reflexivity follows from the identity function:

idA:AA \mathrm{id}_A:A\to A

which is a bijection, so AA has the same cardinality as itself.

Symmetry follows because if f:ABf:A\to B is a bijection, then by Lemma 7.37 there exists an inverse bijection:

f1:BA f^{-1}:B\to A

so BB has the same cardinality as AA.

Transitivity follows because if f:ABf:A\to B and g:BCg:B\to C are bijections, then the composition:

gf:AC g\circ f:A\to C

is also a bijection. Hence AA and CC have the same cardinality.

Finite Sets

A set is finite when its elements can be counted by some natural number. We define this using bijections with initial segments of the natural numbers.

For nNn\in\mathbb{N}, write:

[n]={0,1,,n1} [n]=\{0,1,\dots,n-1\}

Thus:

[0]= [0]=\varnothing

[1]={0} [1]=\{0\}

[2]={0,1} [2]=\{0,1\}

[3]={0,1,2} [3]=\{0,1,2\}

Definition 7.45 (Finite Set)

A set AA is finite if there exists some nNn\in\mathbb{N} and a bijection:

f:[n]A f:[n]\to A

In this case we say that AA has nn elements and write:

A=n |A|=n

A set is infinite if it is not finite.

Example 7.46

The set:

A={a,b,c} A=\{a,b,c\}

is finite because there is a bijection:

f:[3]A f:[3]\to A

given by:

f(0)=a,f(1)=b,f(2)=c f(0)=a,\quad f(1)=b,\quad f(2)=c

Therefore:

A=3 |A|=3

The empty set is finite because:

[0]= [0]=\varnothing

and the identity map:

\varnothing\to\varnothing

is a bijection.

Lemma 7.47 (Finite Cardinality Is Unique)

If a set AA is in bijection with [m][m] and also in bijection with [n][n], then:

m=n m=n

Proof

It is enough to show that there is no bijection between [m][m] and [n][n] when mnm\ne n.

Assume without loss of generality that m<nm<n. Then [m][m] has fewer positions than [n][n]. A function from [m][m] to [n][n] can assign at most one output to each of the mm inputs, so its image contains at most mm elements. Since [n][n] has nn elements and m<nm<n, at least one element of [n][n] cannot be in the image. Therefore no function [m][n][m]\to[n] can be surjective.

Hence no bijection exists between [m][m] and [n][n] when mnm\ne n, so the number of elements of a finite set is well defined.

Countable Sets

Countability extends the idea of listing elements. A set is countable if its elements can be arranged in a sequence, possibly with repetitions removed, so that every element eventually appears.

Definition 7.48 (Countable Set)

A set AA is countable if there exists a surjection:

f:NA f:\mathbb{N}\to A

Equivalently, AA is countable if it is finite or there exists a bijection:

g:NA g:\mathbb{N}\to A

When there exists a bijection NA\mathbb{N}\to A, the set AA is called countably infinite.

Example 7.49

The set N\mathbb{N} is countably infinite, since the identity function:

idN:NN \mathrm{id}_{\mathbb{N}}:\mathbb{N}\to\mathbb{N}

is a bijection.

The set of even natural numbers is countably infinite by the bijection:

n2n n\mapsto 2n

The set of odd natural numbers is countably infinite by the bijection:

n2n+1 n\mapsto 2n+1

Lemma 7.50 (Every Subset of a Countable Set Is Countable)

If AA is countable and BAB\subseteq A, then BB is countable.

Proof

Since AA is countable, there exists a surjection:

f:NA f:\mathbb{N}\to A

If B=B=\varnothing, then BB is finite and hence countable.

Assume BB is nonempty, and choose an element:

b0B b_0\in B

Define a function:

g:NB g:\mathbb{N}\to B

as follows. For each nn, if f(n)Bf(n)\in B, set:

g(n)=f(n) g(n)=f(n)

If f(n)Bf(n)\notin B, set:

g(n)=b0 g(n)=b_0

Then gg maps N\mathbb{N} into BB. We claim that gg is surjective. Let bBb\in B. Since ff is surjective onto AA, there exists nNn\in\mathbb{N} such that:

f(n)=b f(n)=b

Because bBb\in B, the definition gives:

g(n)=f(n)=b g(n)=f(n)=b

Therefore every element of BB is hit by gg, so BB is countable.

Countability of the Integers

The integers extend the natural numbers by adding negative numbers:

Z={,3,2,1,0,1,2,3,} \mathbb{Z}=\{\dots,-3,-2,-1,0,1,2,3,\dots\}

Although Z\mathbb{Z} appears larger than N\mathbb{N}, it is still countable because its elements can be listed in a sequence.

Lemma 7.51 (The Integers Are Countable)

The set Z\mathbb{Z} is countably infinite.

Proof

Define:

f:NZ f:\mathbb{N}\to\mathbb{Z}

by:

f(0)=0 f(0)=0

and for n1n\geq 1:

f(2n1)=n f(2n-1)=n

f(2n)=n f(2n)=-n

This gives the listing:

0,1,1,2,2,3,3, 0,1,-1,2,-2,3,-3,\dots

Every integer appears exactly once in this list. The number 00 appears at index 00. If k>0k>0, then k=f(2k1)k=f(2k-1). If k<0k<0, then k=f(2k)k=f(-2k). Therefore ff is surjective.

One may also check that no two indices give the same integer, so ff is injective. Hence ff is a bijection, and:

Z=N |\mathbb{Z}|=|\mathbb{N}|

Countability of Products

A key fact is that the product of two countable sets is countable. The main example is:

N×N \mathbb{N}\times\mathbb{N}

This means that all ordered pairs of natural numbers can be listed in a single sequence.

Lemma 7.52 (The Product of Two Countable Sets Is Countable)

If AA and BB are countable, then:

A×B A\times B

is countable.

Proof

It is enough to prove that:

N×N \mathbb{N}\times\mathbb{N}

is countable, because if AA and BB are countable, then their elements can be listed using natural numbers, and pairs of elements can be listed by first listing pairs of indices.

We list the pairs (m,n)(m,n) by increasing value of:

m+n m+n

The list begins:

(0,0) (0,0)

(0,1),(1,0) (0,1),(1,0)

(0,2),(1,1),(2,0) (0,2),(1,1),(2,0)

(0,3),(1,2),(2,1),(3,0) (0,3),(1,2),(2,1),(3,0)

Every pair (m,n)(m,n) appears in the finite block where:

m+n=k m+n=k

Since every natural number kk eventually appears, every pair appears somewhere in the list. Therefore there is a surjection:

NN×N \mathbb{N}\to\mathbb{N}\times\mathbb{N}

Hence:

N×N \mathbb{N}\times\mathbb{N}

is countable.

Since any product A×BA\times B of countable sets is the image of a countable set under a suitable map, it is also countable.

Corollary 7.53 (Finite Products of Countable Sets Are Countable)

If:

A1,A2,,An A_1,A_2,\dots,A_n

are countable sets, then:

A1×A2××An A_1\times A_2\times \cdots \times A_n

is countable.

Proof

The proof is by induction on nn.

For n=1n=1, the statement is the definition of countability.

Assume the result holds for nn. Then:

A1××An A_1\times \cdots \times A_n

is countable by the induction hypothesis. Since An+1A_{n+1} is countable, Lemma 7.52 implies:

(A1××An)×An+1 (A_1\times \cdots \times A_n)\times A_{n+1}

is countable. This set is naturally identified with:

A1××An×An+1 A_1\times \cdots \times A_n\times A_{n+1}

Thus the result holds for n+1n+1.

Countability of the Rational Numbers

The rational numbers are fractions:

Q={ab:aZ, bZ, b0} \mathbb{Q}=\left\{\frac{a}{b}:a\in\mathbb{Z},\ b\in\mathbb{Z},\ b\ne 0\right\}

There are infinitely many rational numbers between any two distinct rational numbers, but the whole set is still countable.

Lemma 7.54 (The Rational Numbers Are Countable)

The set Q\mathbb{Q} is countable.

Proof

Every rational number can be represented by a pair:

(a,b)Z×(Z{0}) (a,b)\in\mathbb{Z}\times(\mathbb{Z}\setminus\{0\})

where:

ab \frac{a}{b}

is the corresponding rational number.

The set Z\mathbb{Z} is countable by Lemma 7.51, and the subset:

Z{0} \mathbb{Z}\setminus\{0\}

is countable by Lemma 7.50.

Therefore:

Z×(Z{0}) \mathbb{Z}\times(\mathbb{Z}\setminus\{0\})

is countable by Lemma 7.52.

The map:

(a,b)ab (a,b)\mapsto \frac{a}{b}

is a surjection from this countable product onto Q\mathbb{Q}. Hence Q\mathbb{Q} is countable.

This proof does not require each rational number to have a unique representation, because countability only requires that every rational number appears at least once in some list.

Countable Unions

A countable union of countable sets is countable. This result is one of the main tools for proving that large looking sets are still countable.

Lemma 7.55 (Countable Union of Countable Sets)

Let:

A0,A1,A2, A_0,A_1,A_2,\dots

be countable sets. Then:

nNAn \bigcup_{n\in\mathbb{N}} A_n

is countable.

Proof

Since each AnA_n is countable, for each nn there exists a surjection:

fn:NAn f_n:\mathbb{N}\to A_n

Define:

F:N×NnNAn F:\mathbb{N}\times\mathbb{N}\to \bigcup_{n\in\mathbb{N}} A_n

by:

F(n,m)=fn(m) F(n,m)=f_n(m)

This function is surjective. Indeed, if:

anNAn a\in \bigcup_{n\in\mathbb{N}} A_n

then there exists nn such that:

aAn a\in A_n

Since fnf_n is surjective, there exists mm such that:

fn(m)=a f_n(m)=a

Therefore:

F(n,m)=a F(n,m)=a

By Lemma 7.52, the set N×N\mathbb{N}\times\mathbb{N} is countable. Since the union is the image of a countable set under FF, it is countable.

Uncountable Sets

A set is uncountable if it is not countable. The first and most important example is the power set of the natural numbers.

Definition 7.56 (Uncountable Set)

A set AA is uncountable if there is no surjection:

f:NA f:\mathbb{N}\to A

Equivalently, AA is uncountable if its elements cannot be listed in a sequence indexed by the natural numbers.

Theorem 7.57 (Cantor Diagonal Theorem)

The power set:

P(N) \mathcal{P}(\mathbb{N})

is uncountable.

Proof

Suppose, for contradiction, that:

P(N) \mathcal{P}(\mathbb{N})

is countable.

Then there exists a surjection:

f:NP(N) f:\mathbb{N}\to \mathcal{P}(\mathbb{N})

Thus every subset of N\mathbb{N} appears somewhere in the list:

f(0),f(1),f(2),f(3), f(0), f(1), f(2), f(3), \dots

Define a subset DND\subseteq\mathbb{N} by:

D={nN:nf(n)} D=\{n\in\mathbb{N}: n\notin f(n)\}

Since DD is a subset of N\mathbb{N}, it is an element of:

P(N) \mathcal{P}(\mathbb{N})

Since ff is assumed to be surjective, there exists some kNk\in\mathbb{N} such that:

f(k)=D f(k)=D

Now ask whether:

kD k\in D

By definition of DD:

kDif and only ifkf(k) k\in D \quad \text{if and only if} \quad k\notin f(k)

But:

f(k)=D f(k)=D

so:

kDif and only ifkD k\in D \quad \text{if and only if} \quad k\notin D

This is impossible. Therefore the assumption that such a surjection exists must be false. Hence:

P(N) \mathcal{P}(\mathbb{N})

is uncountable.

Corollary 7.58

There are different sizes of infinity.

Proof

The set N\mathbb{N} is infinite and countable. The set:

P(N) \mathcal{P}(\mathbb{N})

is infinite and uncountable by Theorem 7.57. Therefore:

NP(N) |\mathbb{N}| \ne |\mathcal{P}(\mathbb{N})|

Thus not all infinite sets have the same cardinality.

Cantor Theorem

The diagonal argument works for every set, not only for N\mathbb{N}.

Theorem 7.59 (Cantor Theorem)

For every set AA, there is no surjection:

f:AP(A) f:A\to\mathcal{P}(A)

In particular:

A<P(A) |A|<|\mathcal{P}(A)|

in the sense that the power set has strictly larger cardinality than AA.

Proof

Suppose, for contradiction, that:

f:AP(A) f:A\to\mathcal{P}(A)

is surjective.

Define:

D={aA:af(a)} D=\{a\in A:a\notin f(a)\}

Then:

DA D\subseteq A

so:

DP(A) D\in\mathcal{P}(A)

Since ff is surjective, there exists dAd\in A such that:

f(d)=D f(d)=D

Now:

dD d\in D

if and only if:

df(d) d\notin f(d)

Since:

f(d)=D f(d)=D

this becomes:

dD d\in D

if and only if:

dD d\notin D

This contradiction shows that no such surjection exists.

Real Numbers and Uncountability

The real numbers are uncountable. One way to prove this is to show that the interval:

(0,1) (0,1)

is uncountable.

The proof uses a diagonal construction similar to Cantor theorem.

Theorem 7.60 (Uncountability of the Unit Interval)

The interval:

(0,1) (0,1)

is uncountable.

Proof

Suppose, for contradiction, that:

(0,1) (0,1)

is countable.

Then the real numbers in (0,1)(0,1) can be listed as:

x0,x1,x2, x_0,x_1,x_2,\dots

Write each xnx_n in decimal form:

xn=0.dn0dn1dn2 x_n=0.d_{n0}d_{n1}d_{n2}\dots

To avoid ambiguity from decimal expansions ending in repeated 99 digits, choose decimal expansions that do not eventually become all 99.

Now define a new real number:

y=0.e0e1e2 y=0.e_0e_1e_2\dots

where each digit ene_n is chosen so that:

endnn e_n\ne d_{nn}

and also:

en9 e_n\ne 9

For instance, one may choose:

en={1if dnn12if dnn=1 e_n= \begin{cases} 1 & \text{if } d_{nn}\ne 1 \\ 2 & \text{if } d_{nn}=1 \end{cases}

Then yy is a real number in (0,1)(0,1). Moreover, for each nn, the number yy differs from xnx_n in the nnth decimal digit. Therefore:

yxn y\ne x_n

for every nn.

This contradicts the assumption that the list contains every real number in (0,1)(0,1). Hence:

(0,1) (0,1)

is uncountable.

Corollary 7.61

The set of real numbers R\mathbb{R} is uncountable.

Proof

The interval:

(0,1) (0,1)

is a subset of:

R \mathbb{R}

If R\mathbb{R} were countable, then every subset of R\mathbb{R} would be countable by Lemma 7.50. But Theorem 7.60 shows that (0,1)(0,1) is uncountable. Therefore R\mathbb{R} is uncountable.

Comparing Cardinalities

Cardinality can be compared using injections and surjections.

Definition 7.62 (Cardinality Comparison)

We write:

AB |A|\leq |B|

if there exists an injection:

f:AB f:A\to B

We write:

A<B |A|<|B|

if:

AB |A|\leq |B|

and:

AB |A|\ne |B|

This definition says that AA has size at most BB if AA can be embedded into BB without identifying distinct elements.

Example 7.63

There is an injection:

NZ \mathbb{N}\to\mathbb{Z}

given by:

nn n\mapsto n

Thus:

NZ |\mathbb{N}|\leq|\mathbb{Z}|

There is also an injection:

ZN \mathbb{Z}\to\mathbb{N}

because Z\mathbb{Z} is countable.

Therefore:

N=Z |\mathbb{N}|=|\mathbb{Z}|

Theorem 7.64 (Cantor Schroeder Bernstein)

If there is an injection:

f:AB f:A\to B

and an injection:

g:BA g:B\to A

then there exists a bijection:

h:AB h:A\to B

Consequently:

A=B |A|=|B|

Proof

We give the standard construction.

Since f:ABf:A\to B and g:BAg:B\to A are injections, think of AA as sitting inside BB through ff, and BB as sitting inside AA through gg.

Define:

A0=Ag[B] A_0=A\setminus g[B]

These are the elements of AA that are not hit by gg.

For each nNn\in\mathbb{N}, define:

An+1=g[f[An]] A_{n+1}=g[f[A_n]]

Let:

A=nNAn A^*=\bigcup_{n\in\mathbb{N}} A_n

Now define:

h:AB h:A\to B

by:

h(a)=f(a) h(a)=f(a)

if:

aA a\in A^*

and:

h(a)=g1(a) h(a)=g^{-1}(a)

if:

aA a\notin A^*

This is well defined in the second case because if aAa\notin A^*, then in particular aA0a\notin A_0, so ag[B]a\in g[B], and since gg is injective there is a unique bBb\in B such that:

g(b)=a g(b)=a

One checks that hh is injective and surjective.

On the part AA^*, the map hh uses ff to move elements from AA to BB. Outside AA^*, the map uses the inverse of gg on its image. The construction separates the elements that must move forward by ff from the elements that can move backward by g1g^{-1}.

Thus hh is a bijection from AA to BB.