Show that for each $x \in X$ there exists $ a \in A$ with $d(x,a) = dist(x,A)$ Let $A$ be a compact set. Show that for each $x \in X$ there exists $ a \in A$ with $d(x,a) = dist(x,A)$. Show that if A is only closed then this is not valid in general.
Should I use the convexity of A to prove this? (since every bounded sequence in X has a convergent subsequence).
 A: I suppose that $(X,d)$ is a metric space and that $A$ is a compact subset of $X$.
Let $x \in X$. Then $dist(x,A)= \inf_{a \in A}d(x,a)$. Hence there is a sequence $(a_n)$ in $A$ such that $d(x,a_n) \to dist(x,A)$.
A is compact, hence $(a_n)$ contains a convergent subsequence $(a_{n_k})$ with limit $a \in A$.
Then we have:
$d(x,a)= \lim_{k \to \infty}d(x,a_{n_k})=dist(x,A)$.
A: If you fix $x$, then the map $a \mapsto d(x, a)$ is continuous. Restrict it to a compact set $A$, and the resulting set, being the continuous image of a compact set, is also compact in $\mathbb{R}$. In particular, it must have a minimum.
A: (1) Assume that $X$ is a metric space. $f: A\rightarrow \mathbb{R},\
f(a )=d(x,a)$. So $f$ is continuous so that since $A$ is compact,
$f$ has a minimum at $a_0$.
Hence $f(a_0)=d(a_0,x)\leq d(a,x)$ for all $a\in A$.
(2) If $X_i=[0,1]$ and $
 Y=\bigcup_i\ X_i$ is disjoint union, then
$X$ is a quotient of $Y$ by identifying $0$ in $X_i$.
Consider $a_i=\frac{1}{2}+\frac{1}{2i}\in X_n$ and let $A=\{ a_i|
i\in \mathbb{N}\}$. Then $A$ is closed.
Here $d(0,a_i)\rightarrow \frac{1}{2}$ but there is no $a\in A$ s.t.
$d(0,a)=\frac{1}{2}$
A: Note that if $A$ is compact, then it is bounded and therefore, $\mathrm{d(x,a)}$ is finite. This could fail if $A$ were only closed.
By definition,$$\mathrm{d(x,A)=\inf\{\mathrm{d(x,a)}: a\in A\}}$$
Therefore, if $\mathrm{d(x,a)}=\alpha$, for any $\epsilon>0$, there exists $a_{\epsilon} \in A$ such that $$\alpha \leq d(x,a_{\epsilon})<\alpha+\epsilon$$
Now take $\epsilon=\frac{1}{n}$ and you will get a sequence in $A$ and because $A$ is compact and therefore closed, the limit must be in $A$. 
Therefore, $\lim_{n\to \infty}{a_n}=a_* \in A$ and $$\lim_{n\to \infty}\mathrm{d(x,a_n)}=\mathrm{d(x,\lim_{n\to \infty}a_n)}=\mathrm{d(x,a_*)}$$
The second equality holds because metric is continuous in both components.
