A Short Introduction to Metric Spaces
Section 4: Compactness


In the final three sections of this introduction to metric spaces, we will look at three important properties that metric spaces and their subsets can have: compactness, completeness, and connectedness. All of these are generalizations of familiar properties of sets in (R,d). Any closed, bounded subset of R is compact. R itself is the principal example of a complete metric space. And any interval in R is connected. This section introduces compactness. But before we can even define compactness, we need the concept of an open cover.

Definition 4.1: Let (M,d) be a metric space, and let X be a subset of M. An open cover of X (in M) is a collection of open subsets of M such that every point of X is contained in at least one of the open sets in the collection. In other words, an open cover is a set {Oα|αA} of open subsets of M such that XαAOα (where A is some index set).

Definition 4.2: Let X be a subset of a metric space (M,d), and suppose that C={Oα|αA} is an open cover of M. A subcover of X from C is a subset of C that is still an open cover of X. A subcover that is finite is said to be a finite subcover.

Definition 4.3: Let (M,d) be a metric space, and let K be a subset of M. K is said to be a compact subset of M if every open cover of K in M has a finite subcover. If every open cover of M itself has a finite subcover, then M is said to be a compact metric space.

If K is a subset of a metric space (M,d), we seem to have two different meanings for compactness of K, because K can be considered to be a subspace of (M,d). That is, we can consider the metric space (K,d), where d is the subspace metric on K, and ask whether (K,d) is a compact metric space. So if I simply say "K is compact," do I mean that K is a compact subset in (M,d) or do I mean that (K,d) is a compact metric space? Fortunately, there is no ambiguity in saying simply that K is compact, because the two conditions are equivalent:

Theorem 4.1: Let (M,d) be a metric space, and let K be a subset of M. Then K is a compact subset of M if and only if the subspace (K,d) is a compact metric space.

Proof: Suppose that K is a compact subset of M. To show that (K,d) is a compact metric space, let {Uα|αA} be a collection of open subsets in the metric space (K,d) that covers K. We need to find a finite subcover of K from {Uα|αA}. By Theorem 2.1, for each α, there is an open subset Oα of M such that Uα=KOα. The collection {Oα|αA} is then an open cover of K in M. Since K is a compact subset of M, there is finite subcover {Oα1,Oα2,,Oαn} of K from {Oα|αA}. But then {Uα1,Uα2,,Uαn} is a finite subcover of K from {Uα|αA}. To see this, let kK. Then there is some i such that kOαi. Since kK and kOαi, then kKOαi. That is, kUαi. So, every element of k is contained in some Uαi.

Conversely, suppose that (K,d) is a compact metric space, and let {Oα|αA} be an open cover of K in M, so that each Oα is an open subset of M. Then, again using Theorem 2.1, {KOα|αA} is an open cover of K consisting of open sets in (K,d). This open cover has a finite subcover {KOαi|i=1,2,,n}. And it is then clear that {Oαi|i=1,2,,n} is a finite subcover of K from {Oα|αA}. ∎


As our first example, we show that every bounded, closed interval in R is compact. This is a special case of the well-known Heine-Borel Theorem, which says that every bounded, closed subset of Rn is compact. We will not prove the general result here.

Theorem 4.2: Every bounded, closed interval in R is compact.

Proof: Let a,bR with a<b, and consider the bounded, closed interval [a,b]. Suppose that C={Oα|αA} is an open cover of [a,b] in R. Consider the set X={x[a,b]|the interval [a,x] has a finite subcover from C}. Now, aOβ for some β, and therefore {Oβ} is a finite cover of [a,a] from C. So, aX, and X is non-empty. Furthermore X is bounded above by b. By the least upper bound axiom, every non-empty subset of R that is bounded above has a least upper bound. Let λ be the least upper bound of X. Note that aλb because aX and b is an upper bound for X. That is, λ[a,b].

We show that λX and that λ=b. This will finish the proof of the theorem, since by definition of X, it will mean that [a,b] has a finite subcover from C.

Since λ[a,b], and C is an open cover of [a,b], there is a βA such that λOβ. Since Oβ is open, there is an ε>0 such that (λε,λ+ε)Oβ. Since λ is the least upper bound for X, there must be some xX such that x>λε, for otherwise, λε would be an upper bound for X that is smaller than λ. Since xX, there is a finite subcover of [a,x] from C, say {Oα1,Oα2,,Oαn}. But then since [x,λ]Oβ, we get a finite subcover of [a,λ] by adding Oβ to {Oα1,Oα2,,Oαn}. So, by definition of X, λX.

Finally, we show that λ=b. Suppose for the sake of contradiction that λ<b. Let y=λ+12min(ε,bλ). Then yOβ and therefore {Oβ,Oα1,Oα2,,Oαn} is a finite subcover of [a,y] from C. And y[a,b], because λ<y<b. This means yX and λ<y. But that contradicts the fact that λ is an upper bound for X. This contradiction shows that λ=b, which finishes the proof. ∎

On the other hand, an open interval in R is not compact. For example, consider the open interval (0,1). The collection {(0,11n)|n=2,3,4,} is an open cover of (0,1) that has no finite subcover. You are asked to verify this in Exercise 4.1. Similarly, the half-open interval [0,1) is not compact. You might think about what goes wrong if you try to apply the proof of Theorem 4.2 to the set [0,1). In fact, as our next theorem shows, any compact subset of a metric space must be closed. Take careful note of how the finite subcover property is used in the proof; the technique is common in proofs about compactness.

Theorem 4.3: Let (M,d) be a metric space, and supposed that K is a compact subset of M. Then K is a closed subset of M.

Proof: We show K is closed by showing that its complement, MK, is open. Let zMK. We must find an ε>0 such that Bε(z)MK. For each xK, let εx=12d(x,z). Since zK, εx>0, so that Bεx(x) is an open set. Note that xBεx(x), and zBεx(x). The collection {Bεx(x)|xK} is an open cover of K, since any xK is covered by the open set Bεx(x). Since K is compact, there is a finite subcover {Bεxi(xi)|i=1,2,,n}. Let ε=min(εx1,εx2,,εxn}.

We show that Bε(z)MK, which will finish the proof. To show this, let yBϵ(z). We want to show yMK, that is, yK. Consider xi, where 1in. By the triangle inequality, d(xi,y)+d(y,z)d(xi,z)=2εxi. So, subtracting d(y,z) from both sides of the inequality, d(xi,y)2εxid(y,z)>2εxiεxi=εxi. (The last inequality follows because d(y,z)<εεxi.) Then, since d(xi,y)>εxi, y is not in the open ball of radius εxi about xi. Since this is true for every i and the open balls Bεxi(xi) cover K, we have that yK. ∎

It is also true that every compact set is bounded, but we need a definition of bounded that applies to all metric spaces, not just to R. "Bounded" should mean that the subset "does not extend to infinity," that is, that it is contained in some open ball around some point. But we will use an equivalent definition, which says that a set is bounded if there is a limit on how far apart two points in the set can be. We can define the "diameter" of such a subset:

Definition 4.4: Let (M,d) be a metric space. A subset X of M is said to be bounded if and only if the set of real numbers {d(x,y)|x,yX} is bounded above. For a non-empty bounded set X, we define diam(X), the diameter of X, to be the least upper bound of the set {d(x,y)|x,yX} (which exists by the least upper bound property of R, since the set is bounded above).

Note that by this definition, the empty set is bounded, but we will not attempt to define the diameter of the empty set.

Theorem 4.4: Let (M,d) be a metric space, and supposed that K is a compact subset of M. Then K is bounded.

Proof: If K is empty, then it is bounded. Suppose that K is not empty. Let x be any element of K, and consider the collection of open balls of integral radius, {Bi(x)|i=1,2,}. Since every element of K has some finite distance from x, this collection is an open cover of K, Since K is compact, it has a finite subcover {Bi1(x),Bi2(x),,Bin(x)}, where we can assume i1<i2<<in. But since Bi1(x)Bi2(x)Bin(x), this means that Bin by itself already covers K. Then, for y,zK, y and z are in Bin(x), and d(y,z)d(y,x)+d(x,z)in+in. It follows that 2in is an upper bound for {d(y,z)|y,zK}. So, K is bounded. ∎

We have shown that every compact subset of a metric space is closed and bounded. However, the converse does not hold in general. That is, it is not the case that every closed, bounded set is compact. However, that is true for subsets of Rn, with the usual metric, and this fact gives a complete characterization of compact subsets of Rn. We will not prove this, but Exercise 4.8 proves it for the case n=1.

We turn to another property of compact sets. The Bolzano-Weirstrass Theorem for closed, bounded intervals in R says that any infinite subset of such an interval has an accumulation point in the interval. A similar result holds for a compact subset of a metric space. The proof is again an application of the finite subcover property.

Theorem 4.5: Let (M,d) be a metric space and let K be a compact subset of M. Then any infinite subset of K has an accumulation point that is an element of K.

Proof: We prove the contrapositive. Let XK. Assume that X has no accumulation point in K. We must show that X is finite. Let zK. Since z is not an accumulation point of X, there is an εz>0 such that X(Bεz(z){z})=. Thus, XBεz(z) either is empty or is the single point {z}. The set of open balls {Bεz(z)|zK} is an open cover of K. Since K is compact, there is a finite subcover. That is, there are finitely many points z1,z2,,zn such that the corresponding open balls already cover K. But each of the n open balls in that subcover contains at most one point of X, and it follows that X has n or fewer points. So we have proved that X is finite. ∎

Another version of the Bolzano-Weirstrass says that every bounded infinite sequence in R has a convergent subsequence. We prove an analogous theorem for compact sets.

Theorem 4.6: Let (M,d) be a metric space, and suppose that K is a compact subset of M. Let {xi}i=1 be any sequence of points in K. Then {xi}i=1 has a subsequence that converges to a point in K.

Proof: If the terms of the sequence include only finitely many different points of K, then at least one of those points, say x, occurs infinitely often in the sequence. Then {xi}i=1 has a constant subsequence consisting of all the occurrences of x, and that subsequence converges to x, which is in K since every xi is in K.

So, suppose that the terms of the sequence include infinitely many different points in K. Since K is compact, the infinite subset containing all of the terms of the sequence has an accumulation point in K, by the previous theorem. Let z be that accumulation point. We show that {xi}i=1 has a subsequence that converges to z. We use the result from Exercise 1.8, which implies that for any ϵ>0, the open ball Bϵ(z) contains infinitely many of the terms of the sequence. Since z is an accumulation point of the set consisting of all the xi, there is an index i1 such that xi1B1(z). Then, since B1/2(z) contains infinitely many terms of the sequence, there is an index i2>i1 such that xi2B1/2(z). Then, since B1/3(z) contains infinitely many terms of the sequence, there is an index i3>i2 such that xi3B1/3(z). Proceeding in this way, we obtain indices i1<i2<i3< such that xinB1/n(z) for all nN. It follows easily that the subsequence {xin}n=1 converges to z. ∎

We finish with an important theorem about the relationship between continuity and compactness: The image of a compact set under a continuous function is a compact set.

Theorem 4.7: Let (A,ρ) and (B,τ) be metric spaces, and let f:AB be a continuous function. Then for any compact subset K of A, the image f(K) is a compact subset of B.

Proof: Let K be a compact subset of A. To show that f(K) is compact, we must show that any open cover of f(K) has a finite subcover. Suppose that {Oα|αI} is an open cover of f(K) in B. By Theorem 3.3, each set f1(Oα) is open in A. Furthermore, the collection {f1(Oα)|αI} covers K, since for kK, f(k)Oβ for some β, and then kf1(Oβ). Since K is compact, it has a finite subcover, {f1(Oα1),f1(Oα2),,f1(Oαn)}. I claim that {Oα1,Oα2,,Oαn} is a finite subcover of f(K) from {Oα|αI}. In fact, let bf(K). That is, b=f(a) for some aK. Now, af1(Oαi) for some i. So, b=f(a)f(f1(Oαi))Oαi. That is, every element of f(K) is covered by some Oαi. ∎


Exercises

Exercise 4.1 Show that the open interval (0,1) is not a compact subset of R by verifying that {(0,11n)|n=2,3,4,} is an open cover of (0,1) that has no finite subcover.

Exercise 4.2 Show that the closed interval [0,) is not a compact subset of R by finding an open cover of [0,) that has no finite subcover.

Exercise 4.3 Consider a metric space (X,δ) where δ is the discrete metric as defined in Exercise 1.5. Let Y be any infinite subset of X. Show that Y is closed and bounded but not compact.

Exercise 4.4 Consider the subspace Q of R. That is, consider the metric space (Q,d), where d is the restriction of the usual metric on R to Q. Let X=Q[0,1]={xQ|0x1}. Show that X is a closed, bounded subset of (Q,d) that is not compact. Hint: Use Theorem 2.1 for part of the proof.

Exercise 4.5 Let (M,d) be a metric space, and let X be a non-empty subset of M. Show that the following are equivalent:

  1. X is bounded (in the sense that it has a finite diameter)
  2. For every zX, there is a number Nz such that XBNz(z).
  3. There is a zX and a number N such that XBN(z)

Hint: The proof of Theorem 4.3 already did part of the work.

Exercise 4.6 A subset X of a metric space is said to be totally bounded if for every ε>0, X can be covered by a finite collection of open balls of radius ε. Show that every compact set is totally bounded. Hint: Start with one open ball of radius ε for every element of X.

Exercise 4.7 Let (M,d) be a metric space. Let K be a compact subset of M, and let C be a closed subset of K. Then C is compact. Hint: The set MC is an open set; try adding this set to an open cover of C.

Exercise 4.8 Show that any bounded, closed subset of R is compact. Hint: Use the previous exercise and Theorem 4.2.

Exercise 4.9 Let (M,d) be a non-empty compact metric space and let f:MR be a continuous function (where R has its usual metric). Show that f achieves a minimum value and a maximum value. That is, there is an aM such that for all xM, f(x)f(a), and there is a bM such that for all xM, f(x)f(b). This is a generalization of the Extreme Value Theorem. Hint: Use the fact that f(M) is compact, and apply and Exercise 1.10 along with some theorems from this section.

Exercise 4.10 This exercise considers the idea of the distance between sets. Let (M,d) be a metric space, let X and Y be non-empty subsets of M. Define d(X,Y)=glb{d(x,y)|xX and yY}. Note that if XY then d(X,Y)=0. Find an example where XY= but d(X,Y)=0. Now suppose that X and Y are non-empty compact subsets of M. Show that d(X,Y)=0 if and only if XY=. Hint: Suppose XY= and yY. Then, because MX is open, there is an εy>0 such that XBεy(y)=. (Note that the result remains true if we just assume that X is closed and Y is compact.)