distance between a point and a set or closure of it Let $X$ be a metric space with metric $d$. Let $x\in X$ and let $A$ be a subset of $X$ and define 
$$d(x,A)=\inf\{d(x,a)\mid a\in A\}.$$ 
Prove that $d(x,A)=d(x,\mathrm{cl}(A))$ where $\mathrm{cl}(A)$ is the closure of $A$.
First of all, one direction is obvious: $d(x,\mathrm{cl}(A))\leq d(x,A)$, but I have a hard time proving the reverse direction.
 A: Let $f: X\to \Bbb R$ the continuous function given by $f(y)=d(x,y)$. You want to calculate $d(x,A)=\inf f(A)$. Since $f$ is continuous, $\newcommand{cl}{\operatorname{cl}}f^{-1}(\cl(f(A)))\supseteq\cl A$.
So $f(\cl(A))\subseteq f(f^{-1}(\cl(f(A))))\subseteq\cl f(A)$. Hence, $d(x,\cl A)=\inf f(\cl(A))\ge \inf\cl f(A)$.
However, since the $\inf$ of a subset of $\Bbb R$ is the least limit of a sequence in it, it holds $\inf S=\inf\cl S$. Therefore $$d(x,\cl A)=\inf f(\cl(A))\ge \inf\cl f(A)=\inf  f(A)=d(x,A)$$
A: I will be using the notation $\overline{A}$ to mean the closure of set $A$.
Let $y\in \overline{A}$. Using the result found in here, we get $d(y,A)=0$. Let $\epsilon>0$. Then $\epsilon >d(y,A)$. Thus, there exits $a\in A$ such that $d(y,a)<\epsilon$. Thus
 $$d(x,A)\leq d(x,a)\leq d(x,y)+d(y,a)<d(x,y)+\epsilon.$$
Hence,
$$d(x,A)< d(x,y)+\epsilon\quad \text{for all }\epsilon>0.$$
Hence, 
$$d(x,A)\leq d(x,y).$$
Thus,
$$d(x,A)\leq d(x,y)\quad \text{for all }y\in\overline{A}.$$
Hence, $$d(x,\overline{A})=\inf\{d(x,y):y\in\overline{A}\}\geq d(x,A).$$ 
You already said that $d(x,\overline{A})\leq d(x,A)$ is obvious.
Hope this help.
A: Suppose $y \in cl(A)$. If $y\in A$ there isn't anything significant to notice.  $d(x,y) \in D= \{d(x,a)|a \in A\}$ and $d(x,y) \ge \inf D = d(x,A)$.
If $y \not \in A$ then $y$ is a limit point of $A$ so for any $\epsilon > 0$ there is a $w \in A$ so that $d(w,y) < \epsilon$ and $d(x,w) \le d(x,y) + d(w,y) $ so $d(x,y) \ge d(x,w) - d(w,y) > d(x,w) -\epsilon \ge d(x,A) -\epsilon$.
So $\epsilon$ is arbitrary if $d(x,y) < d(x,A)$ then we can get a contradiction by fixing $\epsilon = d(x,A) - d(x,y)$ which would contradictorily  mean  $d(x,y) > d(x,y)$.
So $d(x,y) \ge d(x,A)$ so $d(x,A)$ is a lower bound of $B = \{d(x,b)|b\in cl(A)\}$.  So $d(x, cl(A)) \ge d(x, A)$.
We can do the same argument to show the other way around but as you noted, it is obvious that as $A \subset cl(A)$ so $D \subset B$ and so $d(x,A) = \inf D \ge \inf B = d(x, cl(A))$.  
So $d(x, A) \ge d(x, cl(A))$ and $d(x,A) = d(x,cl(A))$.
======
...or...
Suppose $d(x,A) > d(x,cl(A)) $.
Then let $y \in d(x,cl(A)$ and let $d(x, cl(A) \le d(x,y) < d(x,A)$.  Then $y \not \in A$ so $y$ is a limit point of $A$.  Let $\epsilon = d(x,A) - d(x,y)$.  Then there is a $w \in A$ so that $d(w,y) < \epsilon$.  So $d(x,A) \le d(x,w) \le d(x,y) + d(w,y) < d(x,y) + \epsilon = d(x,A)$ so $d(x,A) < d(x,A)$; a contradiction.
So $d(x,A) \le d(x,cl(A)$.
