Closure of a subset in a metric space

Solution 1:

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.

Solution 2:

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?).