Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let $A, B$ be subsets of a metric space $X$. If $A$ is compact and $B$ is closed, show that the distance between $A$ and $B$ is achieved.

Attempt at a proof:

Let $A$ be compact and $B$ be closed. Let $m=d(A,B)=\inf_{b\in B} d(A,B)$. Then, there are two possibilities:
(a) $\exists b\in B$, $d(a,b)=m$. If this is the case, we're done.
(b) $\forall b\in B$, $d(a,b)>m$. In this case,

there exists a sequence $\{b_n\}\subseteq B:$ $d(a,b_n)\rightarrow m$ as $n\rightarrow\infty$ by definition of infinum. Then there exists a subsequence $\{b_{n_k}\}$: $d(b_{n_1},a)>d(b_{n_2},a)>...$ which is monotonic decreasing. Then note that $d(b_{n_k},a)<d(b_{n_1},a)<\infty$. So it's a bounded sequence. Now I want to show that it has a convergent subsequence that converges to $b\in B$ and then I want to do the same for $A$. And then finally to show that $d(a,b)=m$ in fact. Any clues to how to get there?

share|cite|improve this question
@JonasMeyer. The argument given in your link uses the fact that closed balls are compact – azarel Feb 14 '12 at 4:15
@azarel: Thanks, I had only supeficially looked at it. Emir: Sorry about the hasty close vote. – Jonas Meyer Feb 14 '12 at 4:18
This is not true as stated. Let $X = \{0\} \cup (1,2)$ with the Euclidean metric, $A = \{0\}$, $B=(1,2)$. $A$ is compact and $B$ is closed (in $X$!) but $d(A,B) = 1$ is not equal to $d(a,b)$ for any $a \in A$, $b \in B$. Are there more assumptions you've missed? – Nate Eldredge Feb 14 '12 at 4:18
Here is a counterexample in a complete connected space. If $(e_n)$ is an orthonormal sequence in an infinite dimensional Hilbert space, $A=\{0\}$, and $B=\{(1+1/n)e_n\}$, then $B$ is closed, $A$ is compact, $d(A,B)=1$, but $d(a,b)>1$ for all $a\in A$ and $b\in B$. – Jonas Meyer Feb 14 '12 at 4:24
does the proof apply if B is not compact but closed only? – user54200 Dec 25 '12 at 14:19
up vote 6 down vote accepted

If one of the sets is just closed you're plenty of counterexamples to your statement. See the comments. If both sets are compact, we can use something similar to your arguments to prove the result. Just with a bit of careful.

So, consider $X$ a metric space and $A$, $B$ compact subsets of $X$. There exist sequences $\{a_n\}$ in $A$ and $\{b_n\}$ in $B$, such that $$\lim_{n\to\infty}d(a_n,b_n)=d(A,B).$$ In metric spaces the notion of compactness is equivalent to sequential compactness. Then, since $A$ is compact, there is a subsequence $\{a_{n_k}\}$ such that $$\lim_{k\to\infty} a_{n_k}=a\quad\text{ with }\quad a\in A.$$ Note that $$\lim_{k\to\infty} d(a_{n_k},b_{n_k})=d(A,B).$$ Since $B$ is compact, there is a subsequence $\{b_{n_{k_j}}\}$, such that $$\lim_{j\to\infty} b_{n_{k_j}}=b\quad\text{ with }\quad b\in B.$$ Note that $$\lim_{j\to\infty} d(a_{n_{k_j}},b_{n_{k_j}})=d(A,B),$$ but, since $d$ is a continuous function$^*$, the above equality says $$d(a,b)=d(A,B)\quad\text{ with }\quad a\in A,\, b\in B.$$

$^*$ Indeed, consider $d:A\times B\to \mathbb{R}$. By considering the metric $D((a_1,b_1),(a_2,b_2))=d(a_1,a_2)+d(b_1,b_2)$ (just as we needed) in $A\times B$ and the usual metric in $\mathbb{R}$, you can see that $d$ is continuous.

As was pointed out in the comments, you can see that $A\times B$ is compact in $X\times X$ with the metric given above. Since $d$ is continuous in the compact $A\times B$, $d$ attains its extremums. That gives you the desired result.

share|cite|improve this answer
Or you could compactify all of this (pun intended) by noting that $A\times B$ is compact (for obvious reasons) and then note that you're secretly just invoking the Extreme value theorem. – Alex Youcis Feb 14 '12 at 8:06
I was trying to argue like the OP in his post. However I haven't noted that. Thanks for point that out @AlexYoucis. – leo Feb 14 '12 at 16:17

I assume that $A$ and $B$ are compact subspaces. As it was was proved here the function $d(\cdot,B):A\to \mathbb{R}_+:a\mapsto\inf\{d(a,b):b\in B\}$ is continuous. But it is defined on the compact space $A$, hence there exist $a_0\in A$ such that $$ d(a_0,B)=\inf\{d(a,B):a\in B\}=d(A,B) $$ Similarly the function $d(\{a_0\},\cdot):B\to\mathbb{R}_+:b\mapsto\inf\{d(a_0,b):b\in B\}$ is continuous function on the compact metric space $B$, hence there exist $b_0\in B$ such that $$ d(\{a_0\},b_0)=\inf\{d(\{a_0\},b):b\in B\} $$ What is equivalent to $$ d(a_0,b_0)=d(a_0,B)=d(A,B) $$ for some $a_0\in A$ and $b_0\in B$.

share|cite|improve this answer
I think what Alex had in mind is that $d : A \times B \to \mathbb{R}_+$ is a continuous function on a compact set. – Nate Eldredge Feb 14 '12 at 15:14
So I can say that this is my idea :) – Norbert Feb 14 '12 at 15:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.