# Prove that $d(A,B)=d(x_{0},y_{0})$

Let $X$ be a metric space, $A$ a compact subset of $X$ and $B$ a closed subset such that $A\bigcap B=\emptyset$. Prove that $d(A,B)=d(x_{0},y_{0})$ for some $x_{0}\in A$ and $y_{0}\in B$. Please help me

• Stimulus: What have you tried so far? Reaction: adds Please help me to the question. O well... – Did Jan 12 '13 at 18:04
• I'm guessing $B \subset X$. If so, $B$ is also compact as the closed subsets of compact sets are again compact. – emka Jan 13 '13 at 3:11
• possible duplicate of real analysis question about compactness – Ittay Weiss Jan 13 '13 at 7:04
• @Ittay: Very close, but not a duplicate, I think. $A$ and $B$ are assumed to be compact in the other question. – Martin Jan 13 '13 at 8:18
• very true Martin. My apologies. – Ittay Weiss Jan 13 '13 at 8:22

The statement in the question is wrong.

Example 1: Let $X = \{0\} \cup (1,\infty)$ with the metric induced by $\mathbb{R}$. Let $A = \{0\}$ and $B = (1,\infty)$. Note that $A$ is compact and open, and $B$ is closed. Then $d(A,B) = 1$ but there is no $y_0 \in B$ such that $d(0,y_0) = 1$.

Example 2: It was suggested that completeness of $X$ helps. Consider the closed subspace $X = \{0\} \cup \{(1+2^{-n})e_n \mid n \in \mathbb{N}\}$ of $\ell^2(\mathbb{N})$ where $e_n$ is the $n$-th standard basis vector $e_n = (0,\dots,0,1,0,\dots)$. Set $A = \{0\}$ and $B = \{(1+2^{-n})e_n \mid n \in \mathbb{N}\}$. Then $d(A,B) = 1$ and $A$ is compact, but there is no $y_0 \in B$ such that $d(0,y_0) = 1$.

The statement of the question is true if closed balls in $X$ are compact, or if $B$ is assumed to be compact. To see this, take $(a_n) \subset A$ and $(b_n) \subset B$ such that $d(a_n,b_n) \to d(A,B)$. Pass to suitable convergent subsequences of $a_n$ (by compactness of $A$) and $b_n$ (either by compactness of $B$ or by noting that this is a bounded sequence, hence it is contained in some ball). Show that the limit points lie in $A$ and $B$, respectively, and that they have distance $d(A,B)$.

First show that if $d(x, B) = inf\{d(x, y) : y \in B\} = s$ then for some $y_0 \in B$, $d(x, y_0) = s$ (This will use the fact that $B$ is complete so you also need to assume that $X$ is complete). Next show that $x \rightarrow d(x, B)$ defines a continuous function on $X$. Finally use the fact continuous real valued functions attain their extrema on compact spaces.

Edit: As Martin points out below, $d(x, B)$ may not be attained in general. So let me just add that the above argument works only when either $B$ is also totally bounded or closed balls in $X$ are compact.

• Completeness of $B$ is not enough. There is no reason for a sequence $(y_n) \subset B$ such that $d(x,y_n) \to d(x,B)$ to be a Cauchy sequence. – Martin Jan 13 '13 at 8:14
• You are absolutely right. I edited my answer accordingly. – Anonymous Jan 13 '13 at 11:25