$x_0$ is in the closure of $M$ iff there is no bounded linear functional on $X$ Following is Corollary 3.6 from Barbara Macclaur's Elementary Functional Analysis.

Suppose that $X$ is a normed linear space, $x_0 \in X$ and $M$ is a (not necessarily closed) subspace in $X$. Suppose that $d\equiv \hbox{dist}(x_0,M)>0$ where $\hbox{dist}(x_0,M)=\inf\{\|x_0-y\|:y\in M\}$. There exists $\varphi \in X^*$ with $\varphi(x_0)=1,\varphi=0$ on $M$, and $\|\varphi\|=1/d$. In particular, $x_0$ is in the closure of $M$ if and only if there is no bounded linear functional on $X$ that is $0$ on $M$ and nonzero at $x_0.$

I'm studying Hahn-Banach theorem and related topics. The book has given no proof and I'm having trouble understanding the corollary. What is the proof of this corollary?
 A: A linear function from a normed linear space to $\Bbb R$ or to $\Bbb C$ is bounded iff it is continuous. If $M$ is any subset of $X$ and $d(x_0, M)=0$ then $x_0\in \overline M.$ If  $x_0\in \overline M$ then $any$ function $f$ on $X$  such that $f(x_0)\ne 0$ and $f[M]=\{0\}$ will be discontinuous at $x_0.$
For the converse, let $\Bbb S$ be the scalars, i.e. $\Bbb S=\Bbb R$ or $\Bbb S =\Bbb C.$
Let  $0<d=$ dist$(x_0)$. Let $M'$ be the vector space generated by $M\cup \{x_0\},$ i.e. $M'=\{sx_0-y: s\in \Bbb S \land y\in M\}$ because $M$ is a vector subspace. For any $z\in M'$ there is a unique $s\in \Bbb S$ and a unique $y\in M $ such that $z=sx_0-y.$ Because if $sx_0-y=s'x_0-y'$ then $(s-s')x_0=y-y'=0\in M,$ so $s=s'$ (and hence also $y-y'=(s-s')x=0x_0=0)$ ; otherwise we would have $x_0=(s-s')^{-1}(y-y')\in M.$
So for $z=sx_0-y \in M'$ the function  $f(z)=s$ is well-defined .
We have $f(x_0)=1$. For any  $z\in M$ we have $f(z)=0.$ For any $z=sx_0-y\in M'\setminus M$ we have $s\ne 0$ so $s^{-1}y\in M$ so $$\|z\|=|s|\cdot \|x_0-s^{-1}y\|\ge |s|\inf \{\|x_0-y'\|: y'\in M\}=$$ $$=|s|d=|f(z)|d$$ so $\|z\|d^{-1}\ge |f(z)|.$ Therefore $$ (i)\quad \sup_{0\ne z\in M'}\frac {|f(z)|}{\|z\|}\le d^{-1}.$$ Now let $(y_n)_{n\in \Bbb N}$ be a sequence in $M$ such that $\lim_{n\to\infty}\|x_0-y_n\|=d.$ Then $\frac {|f(x_0-y_n)|}{\|x_0-y_n\|}=\frac {1}{\|x_0-y_n\|}$ converges to $d^{-1}.$ Therefore $$ (ii)\quad \sup_{0\ne z\in M'}\frac {|f(z)|}{\|z\|}\ge d^{-1}.$$ Finally by $(i)$ and (ii) and by the Hahn-Banach Theorem, $f$ extends to $ \varphi \in X^*$ with $\|\varphi\|=  d^{-1}.$
