[proofplan]
We derive the orthogonal decomposition $H = M \oplus M^\perp$ from the [Projection onto Closed Convex Sets](/theorems/240) theorem. A closed subspace is a closed convex set, so the projection $P_M$ is well-defined. The key observation is that the variational inequality upgrades to an orthogonality equality when $K$ is a subspace, because subspaces are closed under scaling. The double complement identity $M^{\perp\perp} = M$ follows from the decomposition and the non-degeneracy of the inner product.
[/proofplan]
[step:Show the projection onto a subspace satisfies orthogonality]
[claim:Orthogonality of the projection]
Let $M \subseteq H$ be a closed subspace and $x \in H$. Then $z = P_M x$ if and only if $z \in M$ and $(x - z, m)_H = 0$ for all $m \in M$. That is, $x - P_M x \in M^\perp$.
[/claim]
[proof]
By the [Projection onto Closed Convex Sets](/theorems/240) theorem, $z = P_M x$ if and only if $z \in M$ and $(x - z, y - z)_H \le 0$ for all $y \in M$.
Fix any $m \in M$. Since $M$ is a subspace, $y := z + m \in M$, so $(x-z, m)_H \le 0$. Replacing $m$ by $-m$ (also in $M$) gives $(x-z, -m)_H \le 0$, i.e., $(x-z, m)_H \ge 0$. Together: $(x-z, m)_H = 0$.
Conversely, if $(x-z, m)_H = 0$ for all $m \in M$, then for any $y \in M$, writing $m = y - z \in M$: $(x-z, y-z)_H = 0 \le 0$, so the variational inequality holds.
[/proof]
[guided]
The upgrade from inequality to equality is the fundamental difference between projecting onto a convex set and projecting onto a subspace. By the [Projection onto Closed Convex Sets](/theorems/240) theorem, $z = P_M x$ satisfies the variational inequality $(x - z, y - z)_H \leq 0$ for all $y \in M$.
For a general closed convex set $K$, this is the best we can do: the test points $y$ must lie in $K$, so we cannot freely replace $y$ by $2z - y$ (which might lie outside $K$).
For a subspace $M$, closure under addition and scalar multiplication gives us more freedom. Fix any $m \in M$. Since $z \in M$ and $M$ is a subspace, both $y = z + m$ and $y = z - m$ lie in $M$. The variational inequality with $y = z + m$ gives
\begin{align*}
(x - z, m)_H \leq 0,
\end{align*}
and with $y = z - m$ gives
\begin{align*}
(x - z, -m)_H \leq 0, \quad \text{i.e.,} \quad (x - z, m)_H \geq 0.
\end{align*}
Together: $(x - z, m)_H = 0$ for every $m \in M$, which is the orthogonality condition $x - P_M x \in M^\perp$.
[/guided]
[/step]
[step:Establish the orthogonal decomposition $H = M \oplus M^\perp$]
Every $x \in H$ can be written as
\begin{align*}
x = \underbrace{P_M x}_{\in M} + \underbrace{(x - P_M x)}_{\in M^\perp}.
\end{align*}
This gives $H = M + M^\perp$. The sum is direct: if $v \in M \cap M^\perp$, then $(v, v)_H = 0$ (since $v \in M^\perp$ tested against $v \in M$), so $v = 0$.
[/step]
[step:Prove the double orthogonal complement identity $M^{\perp\perp} = M$]
[claim:Double complement]
$M^{\perp\perp} = M$.
[/claim]
[proof]
The inclusion $M \subseteq M^{\perp\perp}$ is immediate: if $m \in M$, then $(m, z)_H = 0$ for all $z \in M^\perp$, so $m \in M^{\perp\perp}$.
For the reverse, let $x \in M^{\perp\perp}$. By the decomposition, $x = m + m^\perp$ with $m \in M$ and $m^\perp \in M^\perp$. Then $m^\perp = x - m$. Since $x \in M^{\perp\perp}$ and $m \in M \subseteq M^{\perp\perp}$, we have $m^\perp \in M^{\perp\perp}$. But $m^\perp \in M^\perp$ as well, so $(m^\perp, m^\perp)_H = 0$, giving $m^\perp = 0$ and $x = m \in M$.
[/proof]
[/step]