TITLE: A and B disjoint, A compact, and B closed implies there is positive distance between both sets
QUESTION [93 upvotes]: Claim: Let $X$ be a metric space. If $A,B\subset X$ are disjoint, $A$ is compact, and $B$ is closed, then there is $\delta>0$ so that $ |\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.

REPLY [2 votes]: 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.