Proof (orthogonal complement in Hilbert space)

Note $Y^\perp = \bigcap_{y\in Y} \ker θ_y$ where $$ \begin{align*} θ_y: H &\to \mathbb{F} \\ x &\mapsto \langle x,y\rangle \end{align*} $$ is a linear map, bounded as $\|\langle x,y\rangle\| \leq \|y\|\|x\|$ by Cauchy-Schwarz. Since $\ker θ_y$ is closed, $Y^\perp$ is a closed subspace of $H$.

Therefore it suffices to show $H$ is the algebraic direct sum of $Y$ and $Y^\perp$.

  1. $Y \cap Y^\perp = \set{0}$, because if $x\in Y \cap Y^\perp$, then $\langle x,x\rangle = 0$ so $x = 0$.

  2. To see $H = Y + Y^\perp$, fix some $x\in H$, and let $y\in Y$ be the unique closest point of $Y$ to $x$. We want to show $z = x-y\in Y^\perp$.

    Suppose not, meaning there is some $y'\in Y$ such that $\langle y',z\rangle \neq 0$. WLOG assume $\langle y',z\rangle>0$ by replacing $y'$ with $e^{iθ} y'$.

    But $$ \begin{align*} \|x - \underbrace{(y + λy')}_{\in Y}\|^2 ={}& \|z - λy'\|^2 \\ ={}& \langle z-λy', z-λy'\rangle \\ ={}& \|z\|^2 + λ^2 \|y'\|^2 - 2λ\langle y',z\rangle \\ ={}& \|z\|^2 - λ(2\langle y',z\rangle - λ\|y'\|^2) \end{align*} $$ is smaller than $\|z\|^2$ for sufficiently small $λ>0$, which is impossible as $\|z\| = \|x - y\| = d(x,Y)$.