Let $(X,\left<\cdot ,\cdot \right>)$ a Hilbert space. Let $Y$ a closed subspace of $X$. I wish prove that $$\inf_{y\in Y}\|x-y\|=\|x-p\|.$$ where $p$ the the orthogonal projection of $x$, i.e. $p$ is the only element of $Y$ s.t. $\left<p,y\right>=\left<x,y\right>$ for all $y\in Y$.
Attempts
We have that \begin{align*} \|x-y\|^2&=\left<x,x\right>-2\left<x,y\right>+\left<y,y\right>\\ &=\left<x,x\right>-2\left<p,y\right>+\left<y,y\right>\\ &\underset{Cauchy-Schwartz}{\geq} \left<x,x\right>-2\sqrt{\left<p,p\right>\left<y,y\right>}+\left<y,y\right> \end{align*} but I don't see how to continue...
Since for all $y\in Y$, $$\left<x,y\right>=\left<p,y\right>,$$ you have that $$\left<x-p,y\right>=0,$$ for all $y\in Y$. Therefore, $$\|x-y\|^2=\|x-p+p-y\|^2\underset{\left<x-p,p-y\right>=0}{=}\|x-p\|^2+\|p-y\|^2\geq \|x-p\|^2.$$