Is my proof correct? (minimal distance between compact sets) I'm working out the following problem form Ahlfors' Complex Analysis text:
"Let $X$ and $Y$ be compact sets in a complete metric space $(S,d)$. Prove that there exist $x \in X,y \in Y$ such that $d(x,y)$ is a minimum."
My attempt:
Define $E:=\{d(x,y): x \in X,y \in Y \}$. We will prove that $E \subset \mathbb R$ is compact.
Firstly we will prove that $E$ is bounded:
$X$ is compact, and therefore it is bounded. That is, there exist $x_0 \in X,r_1>0$ such that $d(x,x_0)<r_1$ for all $x \in X$. $Y$ is also compact, and similarly there exist $y_0 \in Y,r_2>0$ such that $d(y,y_0)<r_2$ for all $y \in Y$.
Now, for any $d(x,y) \in E$, we have $$d(x,y) \leq d(x,x_0)+d(x_0,y_0)+d(y,y_0)<r_1+d(x_0,y_0)+r_2 =:M.$$ This proves that $E$ is bounded.
And now we will prove that $E$ is also closed:
Let $a_n=d(x_n,y_n)$ be sequence in $E$, which is convergent in $\mathbb R$. We will prove that its limit $a:=\lim_{n \to \infty} a_n$ is in $E$.
$(x_n)$ is a sequence in the compact set $X$, therefore it admits a convergent subsequence $(x_{n_k}) \to \bar{x}$. $(y_{n_k})$ is a sequence in the compact set $Y$, and therefore it admits a convergent subsequence $(y_{n_{k_l}}) \to \bar{y}$. The sequence $(x_{n_{k_l}},y_{n_{k_l}})_l$ converges to $(\bar{x},\bar{y})$ in the product space, and the continuity of the metric gives $a=\lim_{l \to \infty} a_{n_{k_l}}=\lim_{l \to \infty} d(x_{n_{k_l}},y_{n_{k_l}})=d(\bar{x},\bar{y})$. This shows that $a \in E$ as required.
In summary I have shown that $E$ is compact, and from a well-known theorem it has a minimum.
Is this proof OK? I think that the completeness of $S$ is unnecessary.
Thank you.
 A: The boundedness of $E$ isn't really the problem. We only need $E$ to be bounded below, which is the case : it is the set of the values of a positive function.
The main part is to prove that $E$ is closed. And the fact that a bounded closed subset of $\mathbb{R}$ contains its minimum isn't really a famous theorem : it's only the fact that the infimum of a set is a limit point of it, and therefore contained in it if the set is closed.
A: I just wanted to mention that your characterization of compactness is not quite correct. Compact is equivalent to closed and bounded in $\mathbb{R}^n$, but it is not true in general. In the case of metric spaces,a set is compact if and only if it is complete and totally bounded. 
However, in this case is enough to see that $E$ is closed as Plop mentioned in his answer so you are fine. Another way to see it is to consider the function $d:S\times S\rightarrow\mathbb{R}$, which is continuous, so it must take a minimum on the compact set $X\times Y\subset S \times S$.
A: You are right. The completeness of $S$ is unnecessary.
In your proof we only need $X$ and $Y$ to be closed, so that we know hat $\bar{x} \in X$ and $\bar{y} \in Y$.
I assume you are using Ahlfors' book. There is some confusion in the book on whether compactness always implies closed-ness in a generic metric space.
It says on the one hand,

The reader will find no difficulty in proving that a complete subset of a metric space is closed...

, and on the other,

... but $\textbf{R}$ and $\textbf{C}$ are complete, and complete subsets of a complete space are closed.

The latter is a lot more restrictive.
I guess Ahlfors got confused when he wrote the 2nd sentence and the exercise.
