Prove that $\inf\limits_{z \in S^{\perp}} \| x - z \| = \sup \left \{ \lvert \langle x , y \rangle \rvert\ \big |\ y \in S, \|y \| \leq 1 \right \}.$ 
Let $H$ be a Hilbert space and $S$ be a subspace of $H.$ Let $x \in H$ and $\left \|x \right \| = 1.$ Prove that $$\inf\limits_{z \in S^{\perp}} \left  \|x - z  \right \| = \sup \left \{\left \lvert \left \langle x , y \right \rangle \right \rvert\ \big |\ y \in S, \left \|y \right \| \leq 1 \right \}.$$

My attempt $:$ Let $L = \inf\limits_{z \in S^{\perp}} \left  \|x - z  \right \|$ and $M = \sup \left \{\left \lvert \left \langle x , y \right \rangle \right \rvert\ \big |\ y \in S, \left \|y \right \| \leq 1 \right \}.$  If $x \in S^{\perp}$ then clearly $L = 0$ and $M = 0$ (because if $x \in S^{\perp}$ then for any $y \in S$ we have $\left \langle x,y \right \rangle = 0$). Also if $x \in S$ then we have \begin{align*} L & = \inf\limits_{z \in S^{\perp}} \sqrt {\|x\|^2 + \|z\|^2} \\ & = \inf\limits_{z \in S^{\perp}} \sqrt {1 + \|z\|^2} \\ & = \sqrt {1 + \inf\limits_{z \in S^{\perp}} \|z\|^2} \\ & = 1 \end{align*} and for all $y \in S$ with $\|y\| \leq 1$ we have by Cauchy Schwarz's inequality $$\left \lvert \langle x,y \rangle \right \rvert \leq \|x\| \|y\| \leq 1.$$ This shows that $M \leq 1.$ Also since $x \in S$ with $\|x\| = 1$ we have by taking $y = x$ $$\langle x,x \rangle = \|x\|^2 = 1.$$ So $M = 1.$ Therefore $L = M$ holds if $x \in S \cup S^{\perp}.$ Now $H = S \oplus S^{\perp}.$ So every element of $H$ can be written as $x = u + v,$ where $u \in S$ and $v \in S^{\perp}.$ For this case \begin{align*} \|(u+v) - z \|^2 & = \|u+v\|^2 + \|z\|^2 - \langle v , z \rangle  - \langle z , v \rangle \\ & = \|u+v\|^2 + \|z\|^2 - 2 \mathfrak {R} \left ( \langle v,z \rangle \right ) \\ & \geq \|u+v\|^2 + \|z\|^2 - 2 \left \lvert \langle v , z \rangle \right \rvert \\ & \geq \|u+v\|^2 + \|z\|^2 - 2\|v\| \|z\| \\ & = \left (\|u+v\|^2 - \|v\|^2 \right ) + \left (\|z\| - \|v\| \right )^2 \\ & \geq \|u+v\|^2 - \|v\|^2 \end{align*} So by taking $z = v$ we have $$L = \sqrt {\|u+v\|^2 - \|v\|^2} = \sqrt {\|u\|^2 + 2 \mathfrak {R} \langle u,v \rangle} = \|u\|\ \ (\text {since}\ u \perp v).$$ Now for any $y \in S$ with $\|y\| \leq 1$ we have \begin{align*} \left \lvert \langle u + v , y \rangle \right \rvert & = \left \lvert \langle u , y \rangle + \langle v , y \rangle \right \rvert \\ & = \left \lvert \langle u,y \rangle \right \rvert\ \ \ \ \ \ \ \ (\text {Since}\ v \perp y ) \\ & \leq \|u\| \|y\| \\ & \leq \|u\| \end{align*} Now if $u = 0$ then $x = v \in S^{\perp}$ in which case we have already proved that $L = M.$ So WLOG we may assume that $u \neq 0.$ Then by taking $y = \dfrac {u} {\|u\|}$ we have $M = \|u\|.$ So in this case also we have $L = M,$ as required.
QED
Does my proof hold good? Please check it.
Thanks in advance.
EDIT $:$ I don't think that what I did is correct. Because Hilbert space can't have such decomposition unless $S$ was given to be closed.

It's not clear why you first take the case $x\in S$, as it is  fairly particular.
When $x\in S^\perp$, one gets directly that $L=M=0$. So we may assume $x\not\in S^\perp$. Also, neither $L$ nor $M$ change if we replace $S$ with its closure, so we may assume that $S$ is closed.
What you have is, since $H=S\oplus S^\perp$, that $x=x_S+x_{S^\perp}$. As $S^\perp$ is a subspace, for $z\in S^\perp$ we have $x-z=x_S-(z-x_{S^\perp})$. Then
$$
L=\inf\{\|x_s-z\|:\ z\in S^\perp\}=\|x_S\|,
$$
since $\|x_s-z\|^2=\|x_s\|^2+\|z\|$ for any $z\in S^\perp$. Now, for any $y\in S$ with $\|y\|=1$, we have
$$
|\langle x,y\rangle|=|\langle x_S,y\rangle|\leq\|x_S\|\,\|y\|=L, 
$$
so $M\leq L$. And
$$
M\geq\Bigg|\bigg\langle x,\frac{x_S}{|x_S\|}\bigg\rangle\Bigg|=\|x_S\|=L. 
$$
