Distance between a point and a closed set in metric space

Here is what I am thinking.

Let (X,d) be a metric space and let C be a closed subset of X.

Fix any poin p in X.

Then, there exists a point q in C such that d(p,q) = distance(p,C).

I think this statement is true, so I tried to the following proof.

For any natural number n, let a_n be a point in C such that d(p,a_n) < distance(p,C)+1/n

But,then I am lost as to what to do next.

I want to use the fact that any convergent sequence in C converges to a point in C, but I am not sure how to proceed.

Or, is what I am trying to prove even true??

Solutions Collecting From Web of "Distance between a point and a closed set in metric space"

Topology is weird sometimes.

It ends up that the statement you are trying to prove is true in $\Bbb R^n$ (in which we can use the Heine Borel theorem as in this proof), but is not true for bigger metric spaces.

Note, however, that as long as bounded and closed sets are compact, this statement holds.

Another counterexample: we can consider the metric space given by $X = (0,1) \cup \{2\}$ under the $|\cdot|$ topology. Note that the set $C =(0,1)$ is closed in $X$, but there is no point in $C$ whose distance from $p = 2$ is $1$.