# A and B disjoint, A compact, and B closed implies there is positive distance between both sets

Claim: Let $X$ be a metric space. If $A,B\in X$ are disjoint, if A is compact, and if B is closed, then $\exists \delta>0: |\alpha-\beta|\geq\delta\;\;\;\forall\alpha\in A,\beta\in B$.

Proof. Assume the contrary. Let $\alpha_n\in A,\beta_n\in B$ be chosen such that $|\alpha_n-\beta_n|\rightarrow0$ as $n\rightarrow \infty$.

Since A is compact, there exists a convergent subsequence of $\alpha_n\;(n\in\mathbb{N})$, $\alpha_{n_m}\;(m\in\mathbb{N})$, which converges to $\alpha\in A$.

We have

$$|\alpha-\beta_{n_m}|\leq|\alpha-\alpha_{n_m}|+|\alpha_{n_m}-\beta_{n_m}|\rightarrow0 \;\;\;as\;\;m\rightarrow\infty.$$ Hence $\alpha$ is a limit point of B and since B is closed $\alpha\in B$, contradiction.

Is my proof correct? I feel as though I am missing something simple which would trivialize the proof.

• I think your proof is correct. – Joel Cohen Jun 30 '11 at 17:16
• Looks right to me... – Arturo Magidin Jun 30 '11 at 17:23
• It might make you more sure of the proof's leavel of detail to consider how it fails if we assume A closed but not compact, e.g. in the plane. – hardmath Jun 30 '11 at 17:27
• @Asaf: It does not work for $A$ only closed. Pick $A=\{(x,y): y \leq 0\}$ and $B=\{(x,y): y \geq e^{-x}\}$ in $\Bbb{R}^2$. These are closed, disjoint in a metric space, and do not have the needed property. Consider points $(n,0)\in A; (n,e^{-n}) \in B$ for $n \to \infty$. – Beni Bogosel Jun 30 '11 at 17:34
• @Asaf: The bounded assumption is necessary. Consider $A=\mathbb{N}$ and $B$={$n+1/n|n\in \mathbb{N}$}. – Benji Jun 30 '11 at 17:34

Yes, your proof is perfectly okay and I don't think you can get it any cheaper than you did it.

Let me expand a little on what you can do with these arguments (also providing details to gary's answer). I'm not saying my proof at the end is better than yours in any way, I'm just showing a slightly alternative way of looking at it.

Define the distance between two non-empty subsets $A,B \subset X$ to be $d(A,B) = \inf_{a \in A, b \in B} d(a,b)$ and write $d(x,B)$ if $A = \{x\}$.

1. If $B \subset X$ is arbitrary and non-empty then $x \mapsto d(x,B)$ is $1$-Lipschitz continuous, that is $|d(x,B) - d(y,B)|\leq d(x,y)$ for all $x,y \in X$.
2. We have $d(x,B) = 0$ if and only if $x \in \overline{B}$.
3. If $d(\cdot,A) = d(\cdot,B)$ then $\overline{A} = \overline{B}$.
1. Choose $b\in B$ such that $d(x,b) \leq d(x,B) + \varepsilon$. Then the triangle inequality yields $d(y,B) - d(x,B) \leq d(y,b) - d(x,b) + \varepsilon \leq d(y,x) + \varepsilon$. By symmetry we get $|d(x,B) - d(y,B)| \leq d(x,y) + \varepsilon$, and 1. follows because $\varepsilon$ was arbitrary. Update: In this closely related answer I show that $1$ is in fact the best Lipschitz constant as soon as $B$ isn't dense. Don't miss Didier's answer to the same thread which relies on a useful general fact which is as easy to prove and Zarrax's answer providing a cleaned-up argument of the one I'm giving here.

2. Choose $b_n \in B$ with $d(x,b_n) \leq d(x,B) + \frac{1}{n} = \frac{1}{n}$. Then $d(x,b_n) \to 0$ and hence $x \in \overline{B}$. Conversely, if $b_n \to x$ then $d(x,b_n) \to 0$ hence $d(x,B) = 0$.

3. Immediate from 2.

Let me combine these facts: assume $A$ is compact and $B$ is closed. As $d(\cdot, B): X \to [0,\infty)$ is continuous by 1. above, we conclude from compactness of $A$ that $d(\cdot,B)$ assumes its minimum when restricted to $A$ (if you think about how one usually proves this, you'll find your argument again!). Hence there is $a \in A$ with the property that $d(a',B) \geq d(a,B)$ for all $a' \in A$. But if $d(a,B) = 0$ then $a \in B$ by 2. above, since $B = \overline{B}$. So either $A$ and $B$ are not disjoint or $d(a',B) \geq d(a,B) \gt 0$. By choosing $\delta \in (0,d(a,B))$, we get the claim again.

Finally, if you don't assume that one among $A$ and $B$ is compact, then the result is false. There was the example $A = \mathbb{N}$ and $B = \{n + \frac{1}{n}\}_{n\in\mathbb{N}}$ given in the comments, or, a bit more geometrically appealing to me, let $A$ be the $x$-axis in $\mathbb{R}^2$ and $B$ the graph of the function $x \mapsto \frac{1}{x}$, $x \neq 0$.

• Oh, I see only now that you were the one giving the example. Hm. Silly me :) – t.b. Jul 1 '11 at 0:07

EDIT: New and (hopefully)Improved!: As stated above, and as pointed out by Theo, a having both $A,B$ be closed but neither of them compact is not enough, a counterexample being that of S={(x,0)} and $S'=\{(x,1/x)\}$ in $\mathbb{R}^n$, as well as other counters given in the above comments. And the above assumption of $A,B$ both closed doesn't either allows us to conclude from $d(A,B)=0$, that there is an $a$ in $A$ with $d(a,B)=0$; for this last, we need to use the full hypothesis, i.e., we need $A$ to be compact. After showing that $A,B$ as given and $d(A,B)=0$ implies the existence of $a$ with $d(a,B)=0$, we use the fact that points at distance $0$ from a subset $S$ of a metric space are precisely the points in the closure of $S$, to lead to the contradiction that $A,B$ are not disjoint if we assume $d(A,B)=0$.

So we prove that $d(A,B)\neq0$ for $A$ compact, $B$ closed and $A,B$ disjoint. Without compactness, the best we can conclude from $d(A,B)=0$, is that there are sequences $\{a_n\}$ in A and $\{b_n\}$ in B, with $d(a_n,b_n) \lt 1/n$. But now we use compactness+ metric, to use that there is a convergent subsequence $\{a_{n_k}\}$ of $a_n$; say the limit is a. Then, given any positive integer n, we can select an index j in $\{a_{n_k}\}$ with $d(a_{n_k},b_{n_m})\lt 1/2n$ for $m\gt j$, and, by convergence of ${a_{n_k}}$ to a, it follows that $d(b_{n_k},a)$, and so (triangle ineq) a is in B, (since B is assumed closed, and a closed subset of a metric space contains all points at distance 0 from B; specifically, in a metric space, the closure of a subset contains all points at distance 0 from that subset), contradicting the assumption that A,B are disjoint.

Note that the choice of $S:=\{(x,0)\}$ and $S':=\{(x,1/x) : x \in \mathbb{R}\}$ is not a counterexample, since the sequence $\{1/x\}$ does not have a convergent subsequence. Then S is not compact.

• That did not come out right: If d(A,B)=0, then there exists sequences ${a_n}$ in A and ${b_n}$ in B, with $d(a_n,b_n)$<1/n. By compactness of A, there is a subsequence $a_{n_k}\rightarrow->a$, with a in A , as compact (sub) spaces are complete metric spaces. Then there are $a_{n_j}$ and $a_{n_k}$ with $d(a,a_{n_j})< 1/2n_j$ and $d(a_{n_j},b_{n_j})$<1/2n_j, from which $d(a,b_{n_j})<1/n_j$ for indices >j , from which it follows that d(a,B)=0. – gary Jul 3 '11 at 0:24
• @Theo: I will consolidate soon, please give me a bit of time. – gary Jul 3 '11 at 6:39
• @Qiaochu: problem is that I lost my login; the computer I usually use automatically seems to recognize me, even without my logging-in, but I don't know what my password is; is the alphanumeric code in "open ID" enough to log in? – gary Jul 3 '11 at 6:41
• @Qiaochu: Please forgive my ignorance, but this computer automatically logs me in, but, if I were to use another computer, what would I do to log in? – gary Jul 3 '11 at 7:06
• @Theo: I did my editing. Hope this one is better; sorry for the mess. – gary Jul 5 '11 at 17:24