Let E, F be disjoint and closed sets, with at least one of them compact. Show that d (E, F)> 0 Let $E, F  \subseteq \mathbb R^n$  be disjoint and closed sets, with at least one of the sets compact. Prove that $d(E,F)\gt 0$. With d(E,F) defined as: $d(E,F)= inf\{||x-y||: x\in E, y\in F\}$. Then prove with a counterexample that it is necessary for at least one of the sets to be compact.

*

*P.D. I think I have a probable solution to the problem. I supposed that $d(E, F)=0$ and from that I came to the conclusion that E and F are not disjoint, contradicting the hypothesis that E and F are disjoint. So d(E, F) has to be greater than zero, as the definition I have for d(E, F) can't be less than zero. In the beginning, I thought that this was alright but then the second part of the problem asks me to prove with a counterexample that it is necessary for one of the sets to be compact, and I can't see where or how to use the knowledge I have of compact sets to prove what I'm asked for. If someone could help me see what is the importance of compactness here I would really appreciate it, so in that way, I can think of a counterexample of my own. Thank you very much.

 A: Let's assume $E$ is the compact one. And suppose $d(E, F) = 0$. Then that means that there are $(x_n), (y_n)$ such that $d(x_n, y_n) < 1/n$  and $x_n \in E$ and $y_n \in F$ for all $n \in \mathbb{N}$.
Since $E$ is compact then there must be a convergent subsequence for the $(x_n)$, $(x_{n_k})$. So discard the other stuff and assume that $(x_n)$ itself is convergent (i.e, throw out everything but the convergent subsequence) take the corresponding indices to get a new $(y_n)$; this is purely a notational convenience of course. Suppose that $x \in E$ is what the $(x_n)$ converge to. Then pick any $\epsilon > 0$, there is $N \in \mathbb{N}$ such that for all $n \geq N$, $d(x_n, x) < \epsilon/2$, and also that $1/n < \epsilon /2$ (by sufficiently increasing $N$).
Then notice that for all $n \geq N$, $d(x, y_n) \leq d(x, x_n) + d(x_n, y_n) < \epsilon/2 + 1/n < \epsilon/2 + \epsilon/2 = \epsilon$. In other words, the $(y_n)$ converge to $x$ and since $F$ is closed this means that $x \in F$ which means that $E \cap F \neq \emptyset$, a contradiction. Thus we are done. Notice that this did not depend on $E, F$ being in $\mathbb{R}^n$ in particular, it could have been any sufficiently strong metric space.
A: For 2nd part of your question,
consider $A=\{ n+\frac{1}{n} : n\in \mathbb{N} \}$
and $B=\{n : n\in \mathbb{N} \}$
Then both A and B are closed, disjoint and none of them are compact.
But d(A,B)=0
