TITLE: Closed subsets of a compact metric space with distance zero from each other
QUESTION [5 upvotes]: I am currently taking a Metric Spaces course, and during an activity, I had to prove the following result:
Let $(X,d)$ be a compact metric space and $A,B \subset X$ two closed subsets such that $d(A,B)=0$. Then $A \cap B \neq \emptyset$.
My reasoning was the following. Using the fact that $d(A,B) = 0$, for every $n \in \mathbb{N}$, we may obtain $a_n \in A$ and $b_n \in B$ such that $d(a_n,b_n) < \frac1n$. This gives us two sequences $(a_n)_{n \in \mathbb{N}} \subset A$ and $(b_m)_{m \in \mathbb{N}}\subset B$ with the property that for every $\epsilon>0$, there is a natural number $n_0$ such that $d(a_n,b_n) < \epsilon$ for every $n \geq n_0$.
From the compactness of $X$ we obtain a subsequence $(a_{n_k})_{k \in \mathbb{N}}$ of $(a_n)$ which converges to some point $a \in X$. We know that in fact $a \in A$ because $A$ is closed. Now the claim is that $a \in A \cap B$. To show this, it is sufficient to show that $a \in \overline{B}$.
For any real number $r>0$ we know that there exists an $n_0 \in \mathbb{N}$ such that $d(a_n,b_n)< \frac r2$ for every $n \geq n_0$, and from the convergence of the subsquence $(a_{n_k})$, there exists and $n_{k_0} \in \mathbb{N}$ such that $d(a,a_{n_k}) < \frac r2$ for every $n_k \geq n_{k_0}$. Then, taking any $n_k \geq \max\{n_0,n_{k_0}\}$ we have
$$d(a,b_{n_k}) \leq d(a,a_{n_k})+d(a_{n_k},b_{n_k}) < \frac r2 + \frac r2 = r,$$
so that $b_{n_k}$ lies in the open ball of radius $r$ centered in $a$, thus showing that $a \in \overline{B}$.
While I was discussing my attempt of proof with the person that was applying the activity, she claimed that it was not correct because I had to be more careful when using the indexes of the subsequence $(a_{n_k})$ to identify specific terms of the sequence $(b_n)$ as I did in the last inequality above. She argued that I should first consider the sequence $(b_{n_k})_{k \in \mathbb{N}}$ with the same indices of the subsequence $(a_{n_k})$, obtain a convergent subsequence of $(b_{n_k})$ and then use this new subsequence during the proof. I didn't really understand why this would be necessary or what is the problem with the argument above.
So I would like some help to know if what I did is correct, or to understand where is the problem if the proof happens to be wrong. Thanks in advance!

REPLY [2 votes]: This is a long comment to illustrate a slightly different method. It uses some  results that you might not be familiar with. 

For any metric space $(U,e)$ and $\phi\ne V\subset U,$ the function $f(u)=\inf\{e(u,v):v\in V\}=e(u,V)$ is continuous from $U$ to $\Bbb R.$ The proof is elementary.
The continuous image of a compact space is compact.  The proof is elementary. And for a  subspace $A$ of a compact Hausdorff space $X$ (for example, when $X$ a compact metric space) we have: $A$ is compact iff $A$ is closed in $X$.
So in your Q, assuming $A\ne \phi \ne B$, the function $f_A(a)=d(a,B)$ for $a\in A$ is continuous from $A$ to $\Bbb R $. So $f_A(A)$  is a compact non-empty subset of $\Bbb R$  and therefore $\min f_A(A)$ exists. 

If $\min f_A(A)=r>0$ then $\forall a\in A\;\forall b\in B\;(d(a,b)\geq r)$, that is, $d(A,B)\geq r>0.$ 
If $\min f_A(A)=0$ then  there exists $a_0$ in $A$ with $f_A(a_0)=0.$ That is $\inf \{d(a_0,b):b\in B\}=0.$  So every open ball of positive radius, centered at $a_0,$ contains a member of $B.$ So $a_0\in \overline B=B.$
Remark. If $C,D$ are closed non-compact subsets of a metric space $(Y,e)$ it may be that $\inf \{e(a,b):a\in A,\;b\in B\}=0$ and $A\cap B=\phi.$ For example let $Y=\Bbb R$ with $e(x,y)=|x-y|.$ Let $A=\Bbb Z^+$ and $B=\{n+2^{-n}: n\in \Bbb Z^+\}.$