TITLE: Closure of a subset in a metric space
QUESTION [7 upvotes]: Let $(X,d)$ be a metric space and $S \subset X$. Show that $d_S(x):=\text{inf}\{d(x,s): s \in S\}=0 \Leftrightarrow x \in \overline S .$
Notes: $\overline S$ is the closure of S. Maybe you can use that a closed set is also closed for sequences in the set? I think the difficult part is when S is open, otherwise its trivial as the closure would be equal to S.

REPLY [8 votes]: If $x\notin \overline{S}$, then there exists $r>0$ such that $B_r(x)\cap S=\phi$. It follows that $d(x,s)\ge r>0$ for all $s\in S$ and hence $d_S(x)>0$. 
And these steps can be reversed, i.e. the steps above are actually "if and only if". So you get the proof.

REPLY [3 votes]: If $x \in \overline{S}$, then there is a sequence $(s_n)$ in $S$ converging to $x$ (e.g. take $s_n$ to be some element in $S \cap B(x;\tfrac{1}{n})$). Then $d_S(x) \leq \inf\lbrace d(x,s_n) \;\vert\; n \in \mathbb{N}\rbrace = 0$ (why?).
For the other directtion, we prove the contrapositive: If $x \notin \overline{S}$, then there is some ball around $x$ disjoint from $S$. This gives that the infimum in $d_S(x)$ must be greater than $0$ (why?).