Distances between closed sets on metric spaces

Which says that $\mathbb R^n$ the distance between a point $b$ and a set $X$ defined by$$ \inf \left\{ d(b,x) \mid x \in X \right\} $$

The proposition:

If $X$ is closed, this distance is reached at some point in the set $X$.

To prove it I assumed without loss of generality that $X$ is also bounded, because if not, it intersected with (e.g.) $$ B_b (n) = \left\{ x \in \mathbb R^n \mid d(b,x) \leqslant n \right\}, $$ where $n$ for example, can be chosen as the first natural number such that the intersection is not empty, and obviously the rest of the points of $X$, are at a greater distance, and will not be candidates.

Then define $$ f(x) = \left| x - b \right| \quad \text{for }x \in X $$ and since the domain is compact we conclude the result, that reaches its minimum at some point in the set. This demonstration clearly not true for any metric space, because being closed and bounded is not enough to be compact in general, but anyway maybe it can be shown in a more general way. That is my question, is this true?


No, such a statement does not hold for a general metric space. Let $V$ be the metric space $[-1, 0) \cup (0, 1]$, and $X = (0,1]$ (verify that $X$ is closed and bounded in $V$). Then for $b = -1$, the set of distances $$ \{ |x-b| \,:\, x \in (0, 1] \} $$ has the infimum $1$, but no minimum value.

Theo's comment describes a stronger counterexample showing that this conclusion does not follow even assuming the completeness of the underlying metric space. Consider the space $\ell^p$ of sequences (say, $p=2$), and let $X$ be the set of sequences $a_n$, where $a_n$ is $1+\frac{1}{n}$ in the $n$th entry, and zero in every other entry. Boundedness of $X$ is clear; it is also closed since it has no limit points. However, for $b=0$, the distance $d(b,a_n)$ gets arbitrarily close to, but never, $1$.