# distance between sets in a metric space

I was given this innocent looking homework question.

Given two nonempty sets $A,B \subseteq X$ where $(X,d)$ is a metric space.

1. Show that $\mathrm{dist}(A,B) = \inf \{d(x,y) \mid x \in A, y \in B \}$ is well-defined.
2. Suppose $A \cap B = \phi$. Suppose $A$ is closed and $B$ is compact. Show that $\mathrm{dist}(A, B) > 0$.

Aren’t both (1) and (2) properties of the fact that $S = \{ d(x,y) \mid x \in A, y \in B \}$ is a subset of $P = \{ x \mid x \ge 0 \}$, which is bounded?

for (1): $S \subseteq P$ and $P$ bounded implies $S$ is bounded. Hence $\mathrm{inf} S$ exists. Since $\mathrm{inf} S$ is unique, we conclude that $\mathrm{dist}(A, B)$ is well defined.

for (2): Since $\mathrm{inf} P \ge 0$ and $S \subseteq P$, $\mathrm{dist}(A, B) \ge 0$. Since $A \cap B = \phi$, $x \ne y$ $\forall x \in A, y \in B$. Then $d(x,y) \ne 0$. Hence $\mathrm{dist}(A,B) > 0$.

Am I missing something very very obvious? Where does compactness come into play?

#### Solutions Collecting From Web of "distance between sets in a metric space"

For 1, $S$ might be unbounded, contrary to your statement. But you have exactly the right idea: it is bounded below by 0, and that is all you need.

$\def\dist{\operatorname{dist}}$But for 2 your idea is no good. Let $A = (-1,0)$ and $B = (0, 1)$. Then $A\cap B = \phi$, and yet $\dist(A, B) = 0$. There are no two points $a\in A, b\in B$ with distance zero, as you said, but there are points $a,b$ at arbitrarily small distance, and that is all we need for the infimum of $S$ to be zero. So if we want to prove that $\dist(A,B)>0$, it is not enough to know that $A$ and $B$ are disjoint; we need some additional information about $A$ and $B$. That is where the compactness comes in.

In fact it’s not even enough for the two sets to be closed; the usual example is that the hyperbola $H = \{ \langle x,y\rangle \mid xy = 1 \}$ is closed and the $x$-axis $L = \{ \langle x,y\rangle \mid y = 0 \}$ is closed, but $\dist(H, X) = 0$ because for any positive $s$ we can choose $0<t<s$ and then $h = \left\langle \frac1t, t\right\rangle, \ell = \left\langle \frac1t, 0\right\rangle$ are closer than $s$.

You should show that $d_S(x):=\operatorname{inf}_{s\in S}d(s,x)$ is a continous function (for all subsets $S$). If you have that, then
$$d(A,B)=\operatorname{inf}_{x\in B}d_A(x)=\operatorname{inf}_{x\in A}d_B(x)$$
Now if $B$ is compact $d_A$ has a Minimum $m$ on $B$, say at the point $b\in B$. By definition, we find a sequence $a_n \in A$ such that $d(a_n,b)\rightarrow m$. If $m=0$, this would imply that $a_n \rightarrow b$. But $A$ is closed, so $b\in A$ is impossible $\Rightarrow m>0$