2.11 Practice Problems
Problem 2.1. Let \(X\) be any non-empty set and define \[d(x,y)=\begin {cases}0 & \text {if } x=y\\ 1 & \text {if } x\neq y\end {cases}\] Prove that \((X,d)\) is a metric space, and describe its open balls.
Show solution
Solution.
The axioms
\(d\) takes only the values \(0\) and \(1\), so \(d(x,y)\geq 0\), and \(d(x,y)=0\) holds exactly when \(x=y\) by definition. Symmetry is immediate, since the condition ”\(x=y\)” is symmetric.
For the triangle inequality, take \(x,y,z\) and consider \(d(x,z)\). If \(x=z\) then \(d(x,z)=0\) and there is nothing to prove. If \(x\neq z\) then \(d(x,z)=1\), and \(y\) cannot equal both \(x\) and \(z\), so at least one of \(d(x,y)\), \(d(y,z)\) is \(1\). Hence \(d(x,y)+d(y,z)\geq 1=d(x,z)\).
The balls
\[B(x;r)=\begin {cases}\{x\} & \text {if } r\leq 1\\ X & \text {if } r>1 .\end {cases}\] So every singleton is open, and therefore every subset is open. This discrete metric is the standard source of counterexamples: in it every set is both open and closed, every function is continuous, and the only convergent sequences are those eventually constant.
Problem 2.2. Let \((X,d)\) be a metric space and define \(d^*(x,y)=\dfrac {d(x,y)}{1+d(x,y)}\). Show that \((X,d^*)\) is a bounded metric space.
Show solution
Solution. Boundedness is immediate: \(d^*=\frac {d}{1+d}<1\) always, so every distance is less than \(1\).
Non-negativity, and \(d^*(x,y)=0\iff x=y\), follow from the same properties of \(d\) since \(1+d>0\). Symmetry is inherited.
For the triangle inequality, note first that \(t\mapsto \frac {t}{1+t}\) is increasing on \([0,\infty )\), since its derivative \(\frac {1}{(1+t)^2}\) is positive. So from \(d(x,z)\leq d(x,y)+d(y,z)\), \[d^*(x,z)=\frac {d(x,z)}{1+d(x,z)}\leq \frac {d(x,y)+d(y,z)}{1+d(x,y)+d(y,z)} .\] Splitting the right-hand side and enlarging each denominator by dropping the other distance, \[\frac {d(x,y)}{1+d(x,y)+d(y,z)}+\frac {d(y,z)}{1+d(x,y)+d(y,z)} \leq \frac {d(x,y)}{1+d(x,y)}+\frac {d(y,z)}{1+d(y,z)}=d^*(x,y)+d^*(y,z).\]
The point of the construction is that \(d\) and \(d^*\) have the same open sets, so boundedness is not a topological property — any metric space can be remetrised to be bounded without changing which sequences converge.
Problem 2.3. For subsets \(A,B\) of a metric space write \(d(A)=\sup _{x,y\in A}d(x,y)\) for the diameter. Prove that if \(A\subseteq B\) then \(d(A)\leq d(B)\), and that if \(A\cap B\neq \emptyset \) then \(d(A\cup B)\leq d(A)+d(B)\).
Show solution
Solution.
Monotonicity
Every pair \(x,y\in A\) is also a pair in \(B\), so the supremum defining \(d(A)\) is taken over a subset of the pairs defining \(d(B)\). A supremum over a smaller set is no larger, so \(d(A)\leq d(B)\).
The union
Pick \(z\in A\cap B\), which exists by hypothesis. Let \(x,y\in A\cup B\). If both lie in \(A\) then \(d(x,y)\leq d(A)\); if both lie in \(B\) then \(d(x,y)\leq d(B)\); and in either case the bound \(d(A)+d(B)\) holds since diameters are non-negative. If \(x\in A\) and \(y\in B\), route through \(z\): \[d(x,y)\leq d(x,z)+d(z,y)\leq d(A)+d(B),\] because \(x,z\in A\) and \(z,y\in B\). So \(d(A)+d(B)\) bounds every pair, hence bounds the supremum.
The hypothesis \(A\cap B\neq \emptyset \) is essential: two sets far apart have small diameters but a large union diameter, which is why the general statement carries the extra term \(d(A,B)\).
Problem 2.4. Prove that a Cauchy sequence in a metric space is bounded, and that a convergent sequence is Cauchy. Show by example that the converse of the second statement fails.
Show solution
Solution.
Convergent \(\implies \) Cauchy
If \(S_n\rightarrow l\) then given \(\varepsilon >0\) there is \(N\) with \(d(S_n,l)<\frac {\varepsilon }{2}\) for \(n\geq N\), so for \(n,m\geq N\) \[d(S_n,S_m)\leq d(S_n,l)+d(l,S_m)<\varepsilon .\]
Cauchy \(\implies \) bounded
Take \(\varepsilon =1\) in the Cauchy condition: there is \(N\) with \(d(S_n,S_N)<1\) for all \(n\geq N\). The finitely many earlier terms lie within \[M=\max \{d(S_1,S_N),\dots ,d(S_{N-1},S_N)\}\] of \(S_N\). So every term lies within \(\max (M,1)\) of \(S_N\), and the sequence is bounded.
The converse fails
Work in \(E=(0,1)\) with the usual metric and take \(S_n=\frac 1n\). Then \[d(S_n,S_m)=\left |\frac 1n-\frac 1m\right |\leq \frac 1n+\frac 1m\rightarrow 0,\] so the sequence is Cauchy in \(E\). But its only candidate limit is \(0\), which is not in \(E\), so it does not converge in \(E\). Completeness is exactly the extra hypothesis that rules this out, and it is the subject of the next section.
Show solution
Solution. Let \(f:(X,d)\rightarrow (Y,\rho )\) be continuous with \(X\) compact, and let \(\varepsilon >0\).
By continuity, each \(x\in X\) has a \(\delta _x>0\) such that \(\rho (f(x),f(x'))<\frac {\varepsilon }{2}\) whenever \(d(x,x')<\delta _x\). The balls \(B\left (x;\frac {\delta _x}{2}\right )\) cover \(X\), so by compactness finitely many suffice, say about \(x_1,\dots ,x_n\). Put \[\delta =\tfrac 12\min \{\delta _{x_1},\dots ,\delta _{x_n}\}>0 ,\] a minimum of finitely many positive numbers, which is the step that fails without compactness.
Now suppose \(d(u,v)<\delta \). The point \(u\) lies in some \(B\left (x_i;\frac {\delta _{x_i}}{2}\right )\), and then \[d(v,x_i)\leq d(v,u)+d(u,x_i)<\delta +\frac {\delta _{x_i}}{2}\leq \delta _{x_i},\] so both \(u\) and \(v\) are within \(\delta _{x_i}\) of \(x_i\). Hence \[\rho \big (f(u),f(v)\big )\leq \rho \big (f(u),f(x_i)\big )+\rho \big (f(x_i),f(v)\big ) <\frac {\varepsilon }{2}+\frac {\varepsilon }{2}=\varepsilon .\] Since \(\delta \) depends only on \(\varepsilon \), \(f\) is uniformly continuous.
Without compactness this is false: \(f(x)=\frac 1x\) on \((0,1)\) is continuous but not uniformly so.
Problem 2.6. Show that \(\mathbb {Q}\) is countable but \(\mathbb {R}\) is not, and deduce that the irrationals are uncountable.
Show solution
Solution.
\(\mathbb {Q}\) is countable
This is the corollary proved above: \(\mathbb {Q}\) is the union over \(n\in \mathbb {N}\) of the countable sets \(\{m/n:m\in \mathbb {Z}\}\), and a countable union of countable sets is countable.
\(\mathbb {R}\) is not
Cantor’s diagonal argument. Suppose the reals in \([0,1)\) could be listed as \(r_1,r_2,r_3,\dots \), each written as a decimal \(r_k=0.a_{k1}a_{k2}a_{k3}\dots \) Define a new number \(b=0.b_1b_2b_3\dots \) by choosing \[b_k=\begin {cases}5 & \text {if } a_{kk}\neq 5\\ 6 & \text {if } a_{kk}=5,\end {cases}\] which avoids the ambiguity of trailing nines. Then \(b\in [0,1)\) but \(b\neq r_k\) for every \(k\), since they differ in the \(k\)-th place. So no list can be complete.
The irrationals
If \(\mathbb {R}\setminus \mathbb {Q}\) were countable then \(\mathbb {R}=\mathbb {Q}\cup (\mathbb {R}\setminus \mathbb {Q})\) would be a union of two countable sets, hence countable — a contradiction. So the irrationals are uncountable.
In a strong sense almost every real number is irrational, even though the rationals are dense.
Show solution
Solution. Let \(F=\{p_1,\dots ,p_m\}\) and let \(\xi \) be an open cover of \(F\). Each \(p_k\) lies in some \(G_k\in \xi \), and then \(\{G_1,\dots ,G_m\}\) is a subfamily of \(\xi \) with at most \(m\) members covering \(F\). It is finite because \(F\) is.
Nothing about the metric was used. Finiteness is the trivial case of compactness, and it is worth noticing that the argument is the one every compactness proof imitates: produce the finite subcover by making one choice per point of a finite set.
Problem 2.8. Show that the union of two compact subsets of a metric space is compact, and give an example showing that the union of infinitely many compact sets need not be.
Show solution
Solution. Let \(K\) and \(L\) be compact and let \(\xi \) be an open cover of \(K\cup L\). It covers \(K\), so finitely many members \(G_1,\dots ,G_m\) cover \(K\); it also covers \(L\), so finitely many members \(H_1,\dots ,H_n\) cover \(L\). Then \[K\cup L \subset G_1\cup \cdots \cup G_m\cup H_1\cup \cdots \cup H_n ,\] a union of \(m+n\) members of \(\xi \).
For the second part take \(K_n=\Big [\dfrac 1n,1\Big ]\) in \(\mathbb {R}\). Each is closed and bounded, hence compact, but \[\bigcup _{n=1}^{\infty }K_n = (0,1] ,\] which was shown above not to be compact. The proof above breaks down at exactly the right place: \(m+n\) is finite, but an infinite union of finite collections need not be finite.
Problem 2.9. Let \((X,d)\) be compact and let \(f:X\rightarrow \mathbb {R}\) be continuous and strictly positive. Show that \(\displaystyle {\inf _{x\in X}f(x)>0}\), and give an example on a non-compact space where the infimum is \(0\) although \(f\) is strictly positive throughout.
Show solution
Solution. By the extreme value theorem \(f\) attains its infimum: there is \(q\in X\) with \(f(q)=\inf f\). Since \(f\) is strictly positive, \(f(q)>0\), so the infimum is positive.
On \((0,1]\), which is not compact, take \(f(x)=x\). It is continuous and strictly positive at every point, yet \(\inf f = 0\) and the value \(0\) is never attained. The infimum has escaped to a point that is not in the space — which is the whole difference compactness makes.
Show solution
Solution. A compact space is totally bounded, so for each \(n\) it can be covered by finitely many balls of radius \(\dfrac 1n\); let \(D_n\) be the set of their centres, a finite set. Put \(D=\bigcup _{n=1}^{\infty }D_n\), a countable union of finite sets and therefore countable.
\(D\) is dense: given \(x\in X\) and \(\varepsilon >0\), choose \(n\) with \(\dfrac 1n<\varepsilon \); the point \(x\) lies in one of the radius-\(\dfrac 1n\) balls, whose centre belongs to \(D_n\subset D\) and is within \(\varepsilon \) of \(x\). So \(X\) has a countable dense subset.
Problem 2.11. Let \(K\) be a compact subset of a metric space \(X\) and let \(x\in X\). Show that there is a point of \(K\) nearest to \(x\), that is, a \(p\in K\) with \[d(x,p) = \inf _{y\in K}d(x,y).\]
Show solution
Solution. The function \(f:K\rightarrow \mathbb {R}\) given by \(f(y)=d(x,y)\) is continuous; indeed the triangle inequality gives \(\big |d(x,y)-d(x,z)\big |\leq d(y,z)\), so \(f\) is even non-expansive. A continuous real function on a non-empty compact space attains its infimum, so the infimum is \(f(p)=d(x,p)\) for some \(p\in K\).
Nearest points need not exist without compactness, and need not be unique with it: in \(\mathbb {R}^2\) every point of the unit circle is nearest to the origin. Existence is what compactness buys; uniqueness is a separate question, answered in Section 4 for convex sets in an inner product space.
Questions on this section
Stuck on something here? Ask below and it stays attached to this topic.