Search the atlas

Finite and countably infinite sets

Use bijections and enumerations to distinguish finite sets, countably infinite sets and larger cardinalities.

Finite and countably infinite sets

Cardinality measures how many elements a set contains, regardless of what those elements are or how they are ordered. Two sets have the same cardinality if there is a bijection between them. Each element of either set then has exactly one partner in the other.

The entry on cardinality gives the definition. Here we use it to distinguish finite sets, countably infinite sets and uncountable sets.

1. Finite sets

For a positive integer n∈Nn\in\mathbb N, write

In={1,2,…,n}.I_n=\{1,2,\ldots,n\}.

A set AA is finite of cardinality nn if there is a bijection In→AI_n\to A. The empty set has cardinality zero. We write

∣A∣=n.|A|=n.

Counting by a bijection gives the same answer in any order. For a finite set, a map A→AA\to A is injective exactly when it is surjective.

If two finite sets are disjoint, then

∣A∪B∣=∣A∣+∣B∣,|A\cup B|=|A|+|B|,

For any pair of finite sets,

∣A×B∣=∣A∣ ∣B∣.|A\times B|=|A|\,|B|.

If the sets overlap, subtract the elements counted twice.

∣A∪B∣=∣A∣+∣B∣−∣A∩B∣.|A\cup B|=|A|+|B|-|A\cap B|.

2. Infinite sets

A set is infinite if it cannot be put in bijection with any finite initial segment InI_n. An infinite set can be in bijection with a proper subset of itself.

For example, the map

n⟼2nn\longmapsto2n

is a bijection between N\mathbb N and the even natural numbers. The fact that a proper subset is strictly smaller holds for finite sets and need not extend to infinite ones.

3. Countability and enumeration

A set AA is countably infinite if there is a bijection

e:N⟶A.e:\mathbb N\longrightarrow A.

The function ee enumerates AA. Every element appears exactly once, at a finite index. A set is at most countable if it is finite or countably infinite.

A list with repetitions that reaches every element defines a surjection from N\mathbb N. To obtain an enumeration without repetitions, keep only the first appearance of each element.

4. The integers are countably infinite

Enumerate the integers by alternating signs.

0,1,−1,2,−2,3,−3,…0,1,-1,2,-2,3,-3,\ldots

With N={0,1,2,…}\mathbb N=\{0,1,2,\ldots\}, an explicit formula is

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\geq1).

Every integer occurs once. Although the list goes on forever, each individual integer is reached after finitely many steps.

5. Countable products and unions

The set N×N\mathbb N\times\mathbb N is countably infinite. Group the pairs by the sum of their coordinates.

(0,0),(0,1),(1,0),(0,2),(1,1),(2,0),…(0,0), (0,1),(1,0), (0,2),(1,1),(2,0),\ldots

Each diagonal is finite and every pair lies on some diagonal. This construction also shows that

  • A product of finitely many countably infinite sets is countably infinite.
  • A countable union of at most countable sets is at most countable when enumerations are available. Remove duplicate entries where needed.
  • Every subset of an at most countable set is at most countable.

6. The rational numbers are countably infinite

Any rational can be written as p/qp/q with p∈Zp\in\mathbb Z and q∈Nq\in\mathbb N, q>0q\gt0. The pairs (p,q)(p,q) form a subset of Z×N\mathbb Z\times\mathbb N and hence are at most countable.

Several fractions can represent the same number, for example 1/2=2/41/2=2/4. Retain only reduced fractions with positive denominator or skip repeated values during enumeration. It follows that

∣Q∣=∣N∣.|\mathbb Q|=|\mathbb N|.

The density of Q\mathbb Q on the line is compatible with countability. Density concerns where points lie, while cardinality compares sets by bijections.

7. The real numbers are uncountable

For a contradiction, suppose all numbers in (0,1)(0,1) could be listed by their decimal expansions.

x1=0,a11a12a13…,x2=0,a21a22a23…,…x_1=0,a_{11}a_{12}a_{13}\ldots, \quad x_2=0,a_{21}a_{22}a_{23}\ldots, \quad\ldots

At position nn, choose a digit bnb_n different from anna_{nn}. To avoid a trailing sequence of 99, choose the new digit from 11 and 22. The number

y=0,b1b2b3…y=0,b_1b_2b_3\ldots

differs from xnx_n at least at digit nn. It therefore belongs to the interval but is missing from the list. This contradiction shows that (0,1)(0,1) and hence R\mathbb R are uncountable.

The argument rules out every proposed enumeration, however it is constructed.

8. Power sets and Cantor’s theorem

For any set AA, the singleton map a↦{a}a\mapsto\{a\} embeds AA in its power set P(A)\mathcal P(A). The cardinality of P(A)\mathcal P(A) is strictly greater because there is no surjection f:A→P(A)f:A\to\mathcal P(A).

Suppose such a surjection existed. The diagonal set

D={a∈A:a∉f(a)}D=\{a\in A:a\notin f(a)\}

would equal f(d)f(d) for some d∈Ad\in A. But this gives

d∈D⟺d∉f(d)=D,d\in D \quad\Longleftrightarrow\quad d\notin f(d)=D,

a contradiction. Infinite sets therefore come in different cardinalities.

9. Comparing cardinalities

A bijection proves equality of cardinalities. An injection A→BA\to B shows that AA has cardinality at most that of BB. If there are injections in both directions, the Cantor–Bernstein theorem gives a bijection.

To make an elementary proof precise,

  1. Specify the sets and state the convention for N\mathbb N.
  2. Construct an explicit map or a list that reaches every element.
  3. Check injectivity and surjectivity separately.
  4. Account for repeated entries or nonunique representations.
  5. Explain why the construction works for every element.

Applications and limits of cardinality

On a finite space of equally likely outcomes, counting gives

P(A)=∣A∣∣Ω∣.P(A)=\dfrac{|A|}{|\Omega|}.

A discrete probability law assigns masses summing to one on a finite or countable support. An uncountable space alone does not guarantee a probability density. For more on these distinctions, see random variables, probability mass functions and probability densities.

If components with n1,…,nkn_1,\ldots,n_k possible states can be combined freely, there are ∏i=1kni\prod_{i=1}^k n_i configurations. This product explains the rapid growth of exhaustive verification. With bb bits there are at most 2b2^b alternatives. To encode NN alternatives, choose the smallest integer bb satisfying 2b≥N2^b\geq N.

A computer stores finite descriptions. Quantization and finite precision turn a continuous model into a finite collection of representable states. Counting them clarifies resolution, memory requirements and information loss. Geometry, probability and frequency of use also matter when distinguishing states in practice.

Common errors

  • Assuming every proper subset has smaller cardinality.
  • Confusing density with uncountability.
  • Writing an infinite list without showing that it reaches every element.
  • Counting different fractions that represent the same rational as different numbers.
  • Interpreting countability as finiteness or practical feasibility.
  • Using decimal diagonalization without handling numbers with two decimal expansions.

Checking your understanding

Construct enumerations of Z\mathbb Z and Q\mathbb Q. Explain why N×N\mathbb N\times\mathbb N is countably infinite, distinguish density from cardinality and construct a real number that escapes any proposed list.

Worked problems on countability and cardinality

These problems apply the criteria for finite and countably infinite sets. The entry on cardinality gives the definition. Compare sets by maps between their elements. Geometric size, density and order answer different questions.

We use the convention

N0={0,1,2,…}.\mathbb N_0=\{0,1,2,\ldots\}.

Here countably infinite means in bijection with N0\mathbb N_0. At most countable includes finite and countably infinite sets. Uncountable means neither finite nor countably infinite. The twenty exercises include four introductory problems, eleven intermediate problems and five more demanding ones.

Prerequisites and scope

You will use sets and set operations, number systems, and injective, surjective and bijective functions. We also use Cantor–Bernstein and the fact that the image of an at most countable set is at most countable.

The focus is cardinality. Combinatorial counting, inclusion–exclusion, density, completeness, upper and lower bounds, extrema, suprema and infima are separate topics. In particular, distinguish a finite string from an infinite sequence.

The formulas and tables below specify the exact pairings, enumerations and diagonals used in the proofs.

I. Finite sets and first comparisons

Exercise 1. Counting distinct roots

Find the set AA of integers nn satisfying

(n+2)(n−1)2(n−4)=0(n+2)(n-1)^2(n-4)=0

and find its cardinality.

Aim. Distinguish the number of distinct roots from their algebraic multiplicities.

Solution

The zero-product rule gives the roots −2-2, 11 and 44. The root 11 has multiplicity two, but appears only once in the set.

A={−2,1,4},∣A∣=3.A=\{-2,1,4\}, \qquad |A|=3.

Check. At each of the three integers at least one factor vanishes. At every other integer all factors are nonzero.

Exercise 2. Removing distinct elements

Let AA be a set with ∣A∣=7|A|=7. Find ∣A∖{x,y}∣|A\setminus\{x,y\}| in the three cases

  1. x,y∈Ax,y\in A e x≠yx\ne y;
  2. x=y∈Ax=y\in A;
  3. x∈Ax\in A e y∉Ay\notin A.

Aim. Count the distinct elements removed when a name or value may occur more than once.

Solution

Two different elements are removed in the first case, and only one in each of the remaining cases. Hence

∣A∖{x,y}∣={5,x,y∈A, x≠y,6,x=y∈A,6,x∈A, y∉A.|A\setminus\{x,y\}|= \begin{cases} 5, & x,y\in A,\ x\ne y,\\ 6, & x=y\in A,\\ 6, & x\in A,\ y\notin A. \end{cases}

Check. In the second case {x,y}={x}\{x,y\}=\{x\}. In the third case deleting an element outside the set leaves AA unchanged.

Exercise 3. Proper inclusion in finite sets

Prove that if A⊊BA\subsetneq B and BB is finite, then

∣A∣<∣B∣.|A|<|B|.

Deduce that for finite sets, A⊆BA\subseteq B and ∣A∣=∣B∣|A|=|B| imply A=BA=B.

Aim. Identify how a finite set compares with each of its proper subsets.

Method. Partition BB into AA and the elements belonging only to BB.

Solution

Since the inclusion is proper, B∖AB\setminus A is nonempty. Furthermore,

B=A∪˙(B∖A),B=A\mathbin{\dot\cup}(B\setminus A),

with a disjoint union. Both pieces of the finite set BB are finite, so

∣B∣=∣A∣+∣B∖A∣.|B|=|A|+|B\setminus A|.

Nonemptiness gives ∣B∖A∣≥1|B\setminus A|\ge1, hence ∣B∣>∣A∣|B|>|A|.

If A⊆BA\subseteq B and ∣A∣=∣B∣|A|=|B|, the inclusion cannot be proper. Therefore A=BA=B.

Check. Finiteness matters. The squares form a proper subset of the natural numbers with the same cardinality as the entire set.

Exercise 4. A parameter separating finite and infinite cases

For k∈Zk\in\mathbb Z, consider

Ak={kn:n∈N0}.A_k=\{kn:n\in\mathbb N_0\}.

Classify AkA_k as finite or countably infinite for each possible kk.

Aim. Check the degenerate parameter before interpreting a formula as an enumeration.

Solution

If k=0k=0, every product is zero.

A0={0},∣A0∣=1.A_0=\{0\}, \qquad |A_0|=1.

If k≠0k\ne0, the map

fk:N0→Ak,fk(n)=knf_k:\mathbb N_0\to A_k, \qquad f_k(n)=kn

is onto by the definition of AkA_k. It is also one-to-one, because kn1=kn2kn_1=kn_2 and k≠0k\ne0 imply n1=n2n_1=n_2. Thus AkA_k is countably infinite.

Check. The sign of kk changes the values but preserves bijectivity. All inputs give the same value only when k=0k=0.

Exercise 5. As many squares as natural numbers

Let

S={n2:n∈N0}.S=\{n^2:n\in\mathbb N_0\}.

Show that S⊊N0S\subsetneq\mathbb N_0 but ∣S∣=∣N0∣|S|=|\mathbb N_0|.

Aim. Exhibit a proper subset of an infinite set with the same cardinality.

Solution

The natural number 22 is not a square, so S⊊N0S\subsetneq\mathbb N_0. The map

q:N0→S,q(n)=n2q:\mathbb N_0\to S, \qquad q(n)=n^2

is surjective by the definition of SS. On the nonnegative integers it is injective, because n12=n22n_1^2=n_2^2 implies n1=n2n_1=n_2. It is therefore bijective and

∣S∣=ℵ0.|S|=\aleph_0.

Check. Exercise 3 assumed a finite ambient set, so there is no contradiction.

II. Enumerations and countable constructions

Exercise 6. Adding two elements to the natural numbers

Let α\alpha and β\beta be two distinct objects outside N0\mathbb N_0, and define

A=N0∪{α,β}.A=\mathbb N_0\cup\{\alpha,\beta\}.

Construct a bijection between AA and N0\mathbb N_0.

Aim. Show that adding finitely many elements preserves the cardinality of a countably infinite set.

Method. Reserve the first two indices for the new objects and shift all original indices.

Solution

Define

g:A→N0,g(x)={0,x=α,1,x=β,x+2,x∈N0.\begin{gathered} g:A\to\mathbb N_0, \\ g(x)= \begin{cases} 0, & x=\alpha,\\ 1, & x=\beta,\\ x+2, & x\in\mathbb N_0. \end{cases} \end{gathered}

Its inverse is

g−1(m)={α,m=0,β,m=1,m−2,m≥2.g^{-1}(m)= \begin{cases} \alpha, & m=0,\\ \beta, & m=1,\\ m-2, & m\ge2. \end{cases}

The inverse establishes bijectivity, so AA is countably infinite.

Check. The values 00 and 11 each have exactly one preimage. Each m≥2m\ge2 comes from the natural number m−2m-2.

Exercise 7. Enumerating all integers

Define a bijection e:N0→Ze:\mathbb N_0\to\mathbb Z that gives the order

0,−1,1,−2,2,−3,3,…0,-1,1,-2,2,-3,3,\ldots

Aim. Turn an informal enumeration into an explicit bijection.

Method. Use even indices for nonnegative integers and odd indices for negative integers.

Solution

Set

e(2k)=k,e(2k+1)=−(k+1),k∈N0.\begin{gathered} e(2k)=k, \\ e(2k+1)=-(k+1), \\ k\in\mathbb N_0. \end{gathered}

Its first values are

nn

00

11

22

33

44

55

66

e(n)e(n)

00

−1-1

11

−2-2

22

−3-3

33

Each z∈Zz\in\mathbb Z has the unique preimage

e−1(z)={2z,z≥0,−2z−1,z<0.e^{-1}(z)= \begin{cases} 2z, & z\ge0,\\ -2z-1, & z<0. \end{cases}

Hence ee is bijective and ∣Z∣=ℵ0|\mathbb Z|=\aleph_0.

Check. The two inverse formulas give nonnegative even and odd indices, respectively, and together cover all integers.

Exercise 8. Finitely many copies of the natural numbers

Fix r∈N>0r\in\mathbb N_{>0}. Prove that

N0×{0,1,…,r−1}\mathbb N_0\times\{0,1,\ldots,r-1\}

is countably infinite.

Aim. Interleave a finite number of copies of a countably infinite set.

Method. Encode the copy number as the remainder on division by rr.

Solution

Define

φ(n,j)=rn+j.\varphi(n,j)=rn+j.

If rn1+j1=rn2+j2rn_1+j_1=rn_2+j_2, the two expressions have the same remainder modulo rr. Thus j1=j2j_1=j_2 and then n1=n2n_1=n_2. This proves injectivity.

For each m∈N0m\in\mathbb N_0, Euclidean division supplies unique nn and jj such that

m=rn+j,0≤j<r.m=rn+j, \qquad 0\le j<r.

This proves surjectivity and hence bijectivity.

Check. For r=3r=3 the pairs occur in the order (0,0),(0,1),(0,2),(1,0),…(0,0),(0,1),(0,2),(1,0),\ldots. None are repeated or omitted.

Exercise 9. The union of two at most countable sets

Suppose AA and BB are at most countable. Show that A∪BA\cup B is at most countable, allowing the lists to repeat elements.

Aim. Distinguish a list that reaches every element from a bijection without duplicates.

Method. Interleave one list for AA and one for BB. Repetitions cannot enlarge the image beyond the union.

Solution

If either set is empty the result is immediate. Otherwise choose lists

a0,a1,a2,…andb0,b1,b2,…a_0,a_1,a_2,\ldots \qquad\text{and}\qquad b_0,b_1,b_2,\ldots

reaching all elements. For a finite nonempty set, the entries can repeat. Define

c2n=an,c2n+1=bn.c_{2n}=a_n, \qquad c_{2n+1}=b_n.

Every element of A∪BA\cup B occurs in cc. This gives a surjection from N0\mathbb N_0 onto A∪BA\cup B, so the union is at most countable. If it is infinite, keeping only first occurrences yields a bijection with N0\mathbb N_0.

Check. Repeating a value can prevent cc from being injective, but it cannot omit an element reached by either list or add elements outside the union.

Exercise 10. Enumerating pairs of natural numbers

Prove that N02\mathbb N_0^2 is countably infinite using

π(m,n)=(m+n)(m+n+1)2+n.\pi(m,n)= \dfrac{(m+n)(m+n+1)}{2}+n.

Aim. Convert a diagonal traversal into an explicit bijection.

Method. Group pairs by their coordinate sum s=m+ns=m+n. Triangular numbers mark the first index on each diagonal.

Solution

Write

Ts=s(s+1)2.T_s=\dfrac{s(s+1)}{2}.

On the diagonal m+n=sm+n=s the formula reduces to π(m,n)=Ts+n\pi(m,n)=T_s+n. The first pairs and their ranks are

Rank

00

11

22

33

44

55

66

77

88

99

Pair

(0,0)(0,0)

(1,0)(1,0)

(0,1)(0,1)

(2,0)(2,0)

(1,1)(1,1)

(0,2)(0,2)

(3,0)(3,0)

(2,1)(2,1)

(1,2)(1,2)

(0,3)(0,3)

Given a rank rr there is a unique ss such that

Ts≤r<Ts+1.T_s\le r<T_{s+1}.

Recover the corresponding pair as follows.

n=r−Ts,m=s−n.n=r-T_s, \qquad m=s-n.

This reconstruction is unique, so π\pi is bijective.

Check. From TsT_s to Ts+1−1T_{s+1}-1 inclusive there are exactly s+1s+1 ranks, the number of points on diagonal m+n=sm+n=s.

Exercise 11. Why the rational numbers are countably infinite

Prove that Q\mathbb Q is countably infinite using reduced representations and the preceding results.

Aim. Encode rationals uniquely, taking account of signs, denominators and equivalent fractions.

Method. Write each rational as its unique reduced fraction with positive denominator. Then encode the numerator–denominator pair.

Solution

Each q∈Qq\in\mathbb Q has a unique representation

q=pd,p∈Z,d∈N>0,gcd⁡(∣p∣,d)=1.\begin{gathered} q=\dfrac{p}{d}, \\ p\in\mathbb Z, \\ d\in\mathbb N_{>0}, \\ \gcd(|p|,d)=1. \end{gathered}

This defines an injection

Q⟶Z×N>0.\mathbb Q\longrightarrow \mathbb Z\times\mathbb N_{>0}.

Its target is countable. Encode Z\mathbb Z by the inverse from exercise 7, encode N>0\mathbb N_{>0} by d↦d−1d\mapsto d-1, then use the pairing function π\pi from exercise 10. There is also an injection n↦nn\mapsto n from N0\mathbb N_0 to Q\mathbb Q.

The Cantor–Bernstein theorem now gives

∣Q∣=∣N0∣=ℵ0.|\mathbb Q|=|\mathbb N_0|=\aleph_0.

Check. Requiring d>0d>0 fixes the sign convention. Reduction to lowest terms removes duplicates such as 12\dfrac{1}{2} and 24\dfrac{2}{4}.

Exercise 12. All finite binary strings

Let {0,1}∗\{0,1\}^{*} be all finite binary strings, including the empty string ε\varepsilon. Construct a bijection with N>0\mathbb N_{>0}.

Aim. Distinguish finite words of arbitrary length from infinite sequences.

Method. Prefix each word with 11 and read the result as the binary expansion of a positive integer.

Solution

Define c(w)c(w) as the natural number whose binary representation is the concatenation 1w1w. For example,

ww

ε\varepsilon

00

11

0000

0101

1010

1111

1w1w

11

1010

1111

100100

101101

110110

111111

c(w)c(w)

11

22

33

44

55

66

77

Every positive integer has a unique binary expansion beginning with 11. Removing that digit recovers the unique word ww. Thus cc is a bijection.

Check. The empty word corresponds to the binary numeral 11.

Exercise 13. Subsets of a countably infinite set

Let AA be countably infinite and B⊆AB\subseteq A. Prove that BB is at most countable and that it is countably infinite if it is infinite.

Aim. Prove the result without requiring a formula for the subset or assuming it is finite.

Method. Use an enumeration of AA to identify BB with a set of natural-number indices. List the chosen indices in increasing order.

Solution

Let f:N0→Af:\mathbb N_0\to A be a bijection and define

I=f−1(B)⊆N0.I=f^{-1}(B)\subseteq\mathbb N_0.

Restricting ff gives a bijection I→BI\to B. If II is finite, so is BB. If II is infinite, define

i0=min⁡I,ik+1=min⁡(I∖{i0,…,ik}).\begin{gathered} i_0=\min I, \\ i_{k+1}=\min\bigl(I\setminus\{i_0,\ldots,i_k\}\bigr). \end{gathered}

Each minimum exists by well-ordering. The remainder cannot become empty, since II is infinite. Every i∈Ii\in I is eventually listed. Otherwise ii would remain available forever, and every new minimum would be at most ii. Infinitely many distinct minima cannot all belong to the finite set {0,1,…,i}\{0,1,\ldots,i\}. Thus k↦f(ik)k\mapsto f(i_k) enumerates BB.

Check. The construction orders natural-number indices. It requires no order, density or limiting process on AA.

III. Countable unions and diagonal arguments

Exercise 14. A countable union of sets with given enumerations

For every k∈N0k\in\mathbb N_0 let AkA_k be at most countable. For each nonempty AkA_k, a list reaching all its elements is supplied. Finite lists may be extended by repetition. Prove that

U=⋃k∈N0AkU=\bigcup_{k\in\mathbb N_0}A_k

is at most countable.

Aim. Combine a countable family of given lists into one list.

Assumptions. The enumerations are supplied, so no simultaneous choice is required. If the union is nonempty, use a fixed element to fill the rows of empty sets. Repetitions do not affect the image.

Method. Visit pairs of indices and positions using the bijection π:N02→N0\pi:\mathbb N_0^2\to\mathbb N_0 from exercise 10.

Solution

If U=∅U=\varnothing, the claim is immediate. Otherwise fix u∗∈Uu_*\in U. For Ak≠∅A_k\ne\varnothing, write the given list as

ak,0,ak,1,ak,2,…,a_{k,0},a_{k,1},a_{k,2},\ldots,

and for Ak=∅A_k=\varnothing set ak,n=u∗a_{k,n}=u_* for every nn. Define

F(k,n)=ak,n.F(k,n)=a_{k,n}.

The map FF sends N02\mathbb N_0^2 onto UU. For each x∈Ux\in U there is an index kk with x∈Akx\in A_k, and that list has a position nn with ak,n=xa_{k,n}=x. Composing FF with π−1\pi^{-1} gives a surjection

N0⟶U.\mathbb N_0\longrightarrow U.

Its image is at most countable. If UU is infinite, keeping the first occurrence of each element produces a bijection with N0\mathbb N_0.

Check. Diagonal ss visits the s+1s+1 pairs satisfying k+n=sk+n=s. Each pair belongs to exactly one diagonal.

Exercise 15. A diagonal argument for the power set

Prove that P(N0)\mathcal P(\mathbb N_0) is uncountable.

Aim. Construct a subset missing from any proposed enumeration.

Assumptions. Suppose a list A0,A1,A2,…A_0,A_1,A_2,\ldots contains every subset of N0\mathbb N_0. Position nn in row AnA_n indicates whether nn belongs to that subset.

Method. Reverse each membership decision on the diagonal n∈Ann\in A_n.

Solution

Define

D={n∈N0:n∉An}.D=\{n\in\mathbb N_0:n\notin A_n\}.

For every k∈N0k\in\mathbb N_0,

k∈D⟺k∉Ak.k\in D \quad\Longleftrightarrow\quad k\notin A_k.

Thus DD and AkA_k disagree on at least kk. The subset DD belongs to P(N0)\mathcal P(\mathbb N_0) but is absent from the list, contradicting completeness.

Check. We do not seek an element outside all the AkA_k. We construct a new subset differing from row kk at position kk.

Exercise 16. Cantor’s theorem for any set

Let AA be any set. Show that no surjection exists

f:A→P(A)f:A\to\mathcal P(A)

and deduce ∣A∣<∣P(A)∣|A|<|\mathcal P(A)|.

Aim. Generalize diagonalization without assuming AA is countable.

Assumptions. The set AA may be finite, infinite or empty. Strict inequality requires both an injection from AA to its power set and the impossibility of a bijection.

Method. Collect the elements missing from their own images. Compare this set with each possible value f(a)f(a).

Solution

Suppose ff were surjective. Define

D={a∈A:a∉f(a)}.D=\{a\in A:a\notin f(a)\}.

Since D∈P(A)D\in\mathcal P(A), surjectivity gives some d∈Ad\in A with f(d)=Df(d)=D. This implies

d∈D⟺d∉f(d)=D,d\in D \quad\Longleftrightarrow\quad d\notin f(d)=D,

a contradiction. No function A→P(A)A\to\mathcal P(A) is surjective.

The map a↦{a}a\mapsto\{a\} is an injection from AA to P(A)\mathcal P(A). Since no bijection is possible,

∣A∣<∣P(A)∣.|A|<|\mathcal P(A)|.

Check. When A=∅A=\varnothing, the domain is empty and P(A)={∅}\mathcal P(A)=\{\varnothing\}. The inequality still holds.

Exercise 17. A decimal diagonal in the unit interval

Use Cantor’s diagonal argument to prove directly that (0,1)(0,1) is uncountable.

Aim. Construct a real number missing from the list while handling the two expansions of a terminating decimal.

Assumptions. For each real number choose the decimal expansion without an infinite tail of 99. Two different normalized expansions then give different numbers.

Method. Use only digits 11 and 22 in the new decimal, preventing a tail of 99.

Solution

Suppose a complete list exists.

Row

Digit 00

Digit 11

Digit 22

Digit 33

Further digits

x0x_0

a00a_{00}

a01a_{01}

a02a_{02}

a03a_{03}

…\ldots

x1x_1

a10a_{10}

a11a_{11}

a12a_{12}

a13a_{13}

…\ldots

x2x_2

a20a_{20}

a21a_{21}

a22a_{22}

a23a_{23}

…\ldots

x3x_3

a30a_{30}

a31a_{31}

a32a_{32}

a33a_{33}

…\ldots

Define

bn={1,ann≠1,2,ann=1,b_n= \begin{cases} 1, & a_{nn}\ne1,\\ 2, & a_{nn}=1, \end{cases}

and set y=0,b0b1b2…y=0,b_0b_1b_2\ldots. The number yy belongs to (0,1)(0,1) and has no infinite tail of 99. For every nn, digit bnb_n differs from anna_{nn}, so y≠xny\ne x_n. The proposed list is incomplete.

Check. Choosing between 11 and 22 forces a difference on the diagonal and avoids ambiguities such as 0,24999…=0,25000…0,24999\ldots=0,25000\ldots.

IV. The continuum and applications

Exercise 18. Intervals and the real line

Prove that (0,1)(0,1), [0,1][0,1] and R\mathbb R have the same cardinality.

Aim. Distinguish cardinality from proper inclusion and geometric length.

Method. Apply Cantor–Bernstein to the two intervals and give an explicit trigonometric bijection from the open interval to the line.

Solution

The inclusion (0,1)↪[0,1](0,1)\hookrightarrow[0,1] is injective. For the other direction, the map

j:[0,1]→(0,1),j(x)=x+13j:[0,1]\to(0,1), \qquad j(x)=\dfrac{x+1}{3}

is injective with image [13,23]⊂(0,1)[\dfrac{1}{3},\dfrac{2}{3}]\subset(0,1). Hence Cantor–Bernstein gives

∣(0,1)∣=∣[0,1]∣.|(0,1)|=|[0,1]|.

The map

h:(0,1)→R,h(x)=tan⁡ ⁣(π(x−12))\begin{gathered} h:(0,1)\to\mathbb R, \\ h(x)=\tan\!\left(\pi\left(x-\dfrac{1}{2}\right)\right) \end{gathered}

is bijective with inverse

h−1(y)=12+arctan⁡yπ.h^{-1}(y)= \dfrac{1}{2}+\dfrac{\arctan y}{\pi}.

Therefore all three sets have cardinality c\mathfrak c.

Check. The inverse sends every real number into (0,1)(0,1) because

−π2<arctan⁡y<π2.-\dfrac{\pi}{2}<\arctan y<\dfrac{\pi}{2}.

Exercise 19. Finite strings and infinite sequences

Compare {0,1}∗\{0,1\}^{*}, the set of finite binary strings, with {0,1}N0\{0,1\}^{\mathbb N_0}, the set of infinite binary sequences.

Aim. Show how the same alphabet can generate sets of different cardinalities.

Method. Use the encoding of finite strings above. For an infinite sequence, record the positions occupied by 11.

Solution

Exercise 12 gave a bijection

{0,1}∗⟷N>0,\{0,1\}^{*}\longleftrightarrow\mathbb N_{>0},

so finite strings are countably infinite. Now define

Φ:{0,1}N0→P(N0),Φ((bn))={n:bn=1}.\begin{gathered} \Phi:\{0,1\}^{\mathbb N_0}\to\mathcal P(\mathbb N_0), \\ \Phi((b_n))=\{n:b_n=1\}. \end{gathered}

From a subset AA recover the unique characteristic sequence

bn={1,n∈A,0,n∉A.b_n= \begin{cases} 1, & n\in A,\\ 0, & n\notin A. \end{cases}

This makes Φ\Phi a bijection. Its target is uncountable by exercise 15, so infinite binary sequences are uncountable too.

Check. A finite word has finitely many positions. An infinite sequence assigns a value at every natural-number index. Truncating it gives a different object.

Exercise 20. Finite programs and uncomputable functions

A programming language has a finite alphabet. Each program is a finite string that computes at most one function

f:N0→{0,1}.f:\mathbb N_0\to\{0,1\}.

Prove that some such functions cannot be computed by any finite program.

Aim. Derive a conclusion in theoretical computer science without having to exhibit a particular uncomputable function.

Assumptions. Valid programs form a subset of the finite strings. Different programs may compute the same function, and some programs may fail to halt. Neither feature increases the number of total functions that can be computed.

Method. Compare the set of programs with the set of infinite binary sequences.

Solution

List strings first by length and then lexicographically at each length. All finite strings over a finite alphabet are therefore at most countable, as is the subset of valid programs.

All functions N0→{0,1}\mathbb N_0\to\{0,1\} form the set {0,1}N0\{0,1\}^{\mathbb N_0}, uncountable by exercise 19. Let PtotP_{\mathrm{tot}} be the valid programs computing total binary-valued functions. The map sending each program in PtotP_{\mathrm{tot}} to its computed function has at most countable domain. Its image is at most countable and cannot contain all binary-valued functions.

Therefore some binary-valued functions on N0\mathbb N_0 are not computed by any finite program.

Check. The argument counts programs computing total functions. It does not assume every string is a program or every program terminates.

Guide to the proofs

Goal

Suitable construction

Show a set is finite

A bijection with {0,…,n−1}\{0,\ldots,n-1\}

Show it is countably infinite

A bijection with N0\mathbb N_0

Show it is at most countable

An injection into the natural numbers, or for a nonempty set, a surjection from them

Compare two cardinalities

An explicit bijection, or injections both ways and Cantor–Bernstein

Prove uncountability

A diagonal construction producing an element outside any proposed list

Construct a larger cardinality

Pass from AA to P(A)\mathcal P(A)

State exactly which kind of map has been constructed. A list with repeated entries can establish at most countability even if the list itself is not a bijection. Proper inclusion gives strictly smaller cardinality in finite sets. For infinite sets compare the cardinalities using maps.

Back to contents