Metric space $(X,d)$ with distance $D(x,S)=\inf\{d(x,y)|y\in S\}$ for $S$ subset of $X$ Let $(X,d)$ be a metric space with $S$ a non-empty subset of $X$. For $x\in X$ we define the distance $D$ between $x$ and $S$ as $D(x,S)=\inf\{d(x,y)|y\in S\}$.

How do I prove that $\overline{S}$ is the set of all $x\in X$ such that $D(x,S)=0$?  

What I have done:
1 I know that $\overline{S}$ is the smallest subset $F$ of $X$ such that $S\subseteq F$, so it seems logical that $\overline{S}$ is the set of all $x\in X$ such that $D(x,S)=0$. But I wouldn't know how to show this.
 A: Suppose $x \in \overline{S}$. We want to see that $d(x,S) = 0$. So pick $r>0$ fixed for now. As $x \in \overline{S}$, the open ball $B(x,r)$ intersects $S$, so there is some $s_r \in S$ such that $d(x,s_r) < r$ (that's what it means to be in the open ball..). As $d(x,S) = \inf \{d(x,s) : s \in S \} \le d(x,s_r) < r$. So $d(x,S) < r$, and ths holds for every $r>0$ we pick. So $d(x,S) = 0$ (if it were $>0$, we'd pick $r = \frac{d(x,S)}{2} > 0$ and get a direct contradiction).
Suppose now that $d(x,S) = 0$, we want to show $x \in \overline{S}$, or equivalently, every open ball around $x$ intersects $S$. So pick $r>0$, and consider $B(x,r)$. It this would be disjoint from $S$, then for all $s \in S$, we have $d(x,s) \ge r$. This means that $r$ would be a lower bound for $\{d(x,s): s \in S\}$, and as the infimum is the largest lower bound of a set, $0 < r \le d(x,S)$, contradicting $d(x,S) = 0$. So $B(x,r)$ is not disjoint from $S$, so it intersects $S$. This works for all $r>0$, so $x \in \overline{S}$.
A: If $D(x,S) = 0$, you can find (by definition if the infimum) a sequence $x_n \in S$ converging to $x$. So $x \in \bar S$. Similarly, the existence of such a sequence proves that $D(x,S) = 0$.
You should convince yourself that your definition of $\bar S$ implies that $\bar S$ is the set of all points which can be approximated by elements of $S$.
If $x \in \bar S$ you get again a sequence $x_n \in S$ converging to $x$. It then follows that $D(x,S) = \inf_{s \in S} d(x,s) \leq d(x,x_n)$ for all $n \in \mathbb N$. But $d(x,x_n)$ gets arbitrary close to $0$, as $n$ gets large.
A: Note that for any $s\in S$, we have $d(x,S) \le d(x,s) \le d(y,s) + d(x,y)$, taking infimum we get $d(x, S) \le d(y,S) + d(x,y)$, by symmetry we get $|d(x,S) - d(y,S)| \le d(x,y)$ so the function $f: X \to \mathbb R$, defined by $f(x) = d(x, S)$, is uniformly continuous. Thus, $f^{-1}(0)$ is closed, and clearly $S \subset f^{-1}(0)$, so $\overline S \subset f^{-1}(0)$. 
If $x\not\in \overline S$ then there is a ball of radius $\epsilon > 0$ around $x$  disjoint from $\overline S$, in that case $d(x, S) \ge \epsilon > 0$, so $x\not\in f^{-1}(0)$. Thus, $\overline S = f^{-1}(0)$.
