distance between closed and compact set my professor gave us this excercise:
The distance of two subsets $S_{1}$ and $S_{2}$ of a given complete metric space $(X, d)$ :
$$ d\left(S_{1}, S_{2}\right)=\inf \left\{d(x, y): x \in S_{1}, y \in S_{2}\right\}.$$
a) Suppose $S_{1}$ contains only one point $x$ and $S_{2}$ is closed. Prove $d\left(S_{1}, S_{2}\right)=d(x, y)$ for some $y \in S_{2}$.
b) Suppose $S_{1}$ is compact and $S_{2}$ is closed. Prove $d\left(S_{1}, S_{2}\right)=d(x, y)$ for some $x \in S_{1}$ $y \in S_{2}$.
I managed to do the first item (using a Cauchy sequence and the fact that X is a metric space), but the second one is giving me some problems, first I tried to use sequences but I did't go anywhere, I also though about seeing $d$ as a continous function in the product space, but a compact x closed is not compact, so I can't ensure that I get the minimum. Any idea would help. Thanks.
EDIT: My proof of a) If $S_1 \cap S_2 \neq \varnothing$ there is nothing to prove. If $S_1=\{x\}$,  let us suppose that $S_1 \cap S_2 = \varnothing$, then we can consider $(y_n)_{n\in \mathbb{N}}$ a sequence such that $y_n \in S_2$ for any $n \in \mathbb{N}$ and such that $d(x,y_j)\leq d(x,y_i)$ if $i<j$. Clearly $(y_n)_{n\in \mathbb{N}}$ is a Cauchy sequence, therefore it converges to a $y \in S_2$ (due to the fact that $S_2$ is closed and therefore it contains all its accumulation points).
 A: Here is a counterexample to (a) and therefore also to (b).
Let $X$ be the set of all nonnegative integers. Define a metric $d$ on $X$ by setting $d(x,x)=0$, $d(0,x)=d(x,0)=1+\frac1x$ for $x\gt0$, and $d(x,y)=2$ for $x,y\gt0$.
The metric space $(X,d)$ is complete (every Cauchy sequence is eventually constant) and locally compact (the induced topology is discrete).
Let $S_1=\{0\}$ and $S_2=X\setminus\{0\}$. Then $d(S_1,S_2)=d(0,S_2)=1$ but $d(0,y)\gt1$ for every $y\in S_2$.
A: The claim is false in general. See the counterexample in the comments However, it is true if $X$ is a Topological Vector Space in which closed balls are compact. i.e if $X$ has what are called "nice closed balls":
for each integer $n$ there is a pair $(x_n,y_n)\in S_1\times S_2$ such that $d(x_n,y_n)<d(S_1,S_2)+1/n$. Since $d(x_n,y_n)\ge d(S_1,S_2)$ this means that $d(s_n,y_n)\to d(S_1,S_2)$.  Since $S_1$ is compact there is a subsequence $(x'_n)$, of $(x_n),$ that converges to some $x\in S_1$. That is, $x'_n\to x\in S_1$. Note that in particular this means that $(x'_n)$ is bounded so $d(y'_n,0)\le d(y'_n,x'_n)+d(x'_n,0)<C<\infty.$ Thus, the closed ball $B_{2C}(0)$ is compact and contains $(y'_n)$, so we get a subsequence $(y''_n$) of $(y'_n)$ that converges to some $y\in B\cap S_2$ (because $S_2$ is closed).Then, of course, $x''_n$ still converges to $x$ and so $(x,y)$ is the pair that does the job.
