If $(X,d)$ is a complete metric space and $A$ is closed in $(X,d)$ then show that for each $x \in X$ there exists an element $a_0 \in A$ such that $d(x,A)=d(x,a_0).$
I tried this problem several times but always got stuck at some point or another. For instance, I initially thought about showing the existence of a Cauchy sequence $(a_n)$ in A such that $d(x,a_n) \to \operatorname{inf}\{d(x,a):a \in A\}=d(x,A)$ and then by completeness of $A$ and by continuity of the function $f(a)=d(x,a)$, to prove the existence of an element $a_0$ in $A$ such that $a_n \to a_0$ which would imply $d(x,a_n)=f(a_n) \to f(a_0)=d(x,a_0)=d(x,A)$. But the problem was that I could not construct such a Cauchy sequence in $A$. All my other attempts have similarly gone in vain.
If anybody has any answer, please reply. Thank you.