Proving a property of a distance function with compact and closed sets I'm trying to prove the following:
I know that I need to begin by defining a function $f : C \rightarrow \mathbb{R}$ defined by $f(x) = d(x, D)$, but I haven't been able to progress in the past few hours. All help is appreciated.
 A: We have a continuous function $f\colon C\to\mathbb{R}$ defined on a compact $C$, therefore there exists $c\in C$ such that $$d(c,D)=f(c)=\inf\limits_{x\in C} f(x) =\inf\limits_{x\in C} d(x,D)= d(C,D).$$
Now, since $D$ is closed, there exists $d\in D$ such that $d(c,D)=d(c,d)$, and we're done.
A: I am assuming that $C,D\subseteq \mathbb R$. We have that $d:\mathbb R\to \mathbb R:\ x\mapsto d(x,D)$ is comtinuous.  Now, $C$ is compact, so there is a $c\in C$ and a real number $d'$ such that $d(c,D)=d'$ and $(c,d')$ is a minimum for $d$ on $C$. 
So by definition of $d$, there is a sequence $(x_n)\subseteq  D$ such that
$\tag1 d(c,x_n)=|c-x_n|<d'+1/n,$ 
$(1)$ implies that $(x_n)$ is a bounded sequence of numbers in $D,$ so that $(x_n)$ has a convergent subsequence $(x_{n_k})$. That is $x_{n_k}\to d''\in D$ (because $D$ is closed). 
We conclude that $d(c,x_{n_k})\to d(c,d'')$ (because $d$ is continuous), and that (from $(1)$), $d(c,d'')\le d'$. But, equality must hold because $d'$ is a minimum, so in fact, $d(c,d'')=d'$. 
