# Distance between closed and compact sets.

This question is (1-21)(b) from M. Spivak’s Calculus on Manifolds.

Question:
If $A$ is closed, $B$ is compact, and $A \cap B = \emptyset$, prove that there is $d > 0$ such that $||y – x|| \geq d$ for all $y \in A$ and $x \in B$.

Now, I interpret this as an instruction to find a single $d$ that works for all $y \in A$ and $x \in B$. However, I can’t see why the following is not a counter-example:

Consider the set
$$A_0 = (-\infty, 0) \cup \left[\bigcup_{n=1}^{\infty} \left(\frac{1}{n + 1}, \frac{1}{n}\right)\right] \cup (1, \infty)$$
where $(a,b)$ denotes the open interval as usual. Since $A_0$ is a union of open sets, it too is open. Thus
$$A = \mathbb{R} – A_0 = \left\{ \frac{1}{n} \quad \colon \quad n \in \mathbb{N}\right\}$$
is closed. The set
$$B = [-1, 0]$$
is certainly compact. Moreover, $A \cap B = \emptyset$. However, for all $d > 0$, there exists a $y \in A$ such that
$$||0 – y|| = ||y|| < d$$

I must be overlooking something somewhere. Any help spotting where will be appreciated.

#### Solutions Collecting From Web of "Distance between closed and compact sets."

Here we prove the result of the book:

Recall that the function $x\mapsto d(x,A)$ is continuous and that (since $A$ is closed):
$$x\in A\iff d(x,A)=0$$

$$d=\inf_{x\in B}d(x,A)$$

The function

$$f:B\to \mathbb{R}\quad,\quad x\mapsto d(x,A)$$
is continuous on the compact $B$ then it’s bounded and there’s $x_0\in B$ s.t
$$f(x_0)=\min_{x\in B}f(x)=d=d(x_0,A)>0$$
since $x_0\not\in A$

The counter-example fails as the set $A$ contains $0$ so $A \cap B \ne \emptyset$. I had overlooked this fact for some reason.