We use the notation and claims of Elementary Identities in a Real Inner Product Space, The Norm Metric of a Real Inner Product Space: Triangle Inequalities, Limits and Continuity and Nearest-Point Projection onto a Nonempty Closed Convex Subset of a Real Hilbert Space, the latter applied to K=M. For a subset AβH, Aβ₯ is its orthogonal complement.
Preliminaries. Every closed linear subspace N of H is nonempty since 0HββN (condition 1 of Linear Subspace), and convex, since for x,yβN and every tβR with 0β€t and tβ€1 the vector tx+(1βt)y lies in N by conditions 2 and 3 of Linear Subspace. So Nearest-Point Projection onto a Nonempty Closed Convex Subset of a Real Hilbert Space applies to every closed linear subspace, in particular to M. We record two facts used repeatedly.
(i) For every subset AβH, Aβ₯ is a closed linear subspace of H. By Elementary Identities in a Real Inner Product Space (ii), 0HββAβ₯, and by conditions (b) and (c) of Real Inner Product Spaces (i), Aβ₯ is closed under sums and scalar multiples; so it is a linear subspace. If (xmβ) is a sequence in Aβ₯ converging to xβH, then for each aβA the real sequence (β¨xmβ,aβ©), which is constantly 0, converges to β¨x,aβ© by The Norm Metric of a Real Inner Product Space: Triangle Inequalities, Limits and Continuity (v); by claim 1 of Uniqueness of Limits and Boundedness of Convergent Real Sequences (the constant sequence converges to 0), β¨x,aβ©=0. Hence xβAβ₯, and Aβ₯ is closed by Sequential Characterization of Closed Subsets of a Metric Space.
(ii) Aβ(Aβ₯)β₯ and Aβ©Aβ₯β{0Hβ}. For aβA and wβAβ₯, β¨a,wβ©=β¨w,aβ©=0 by symmetry; and if aβAβ©Aβ₯ then β£aβ£2=β¨a,aβ©=0, so a=0Hβ by Elementary Identities in a Real Inner Product Space (iii).
Claim 1. Let xβH and zβM. By Nearest-Point Projection onto a Nonempty Closed Convex Subset of a Real Hilbert Space (ii), z=PMβx if and only if β¨xβz,yβzβ©β€0 for every yβM. If xβzβMβ₯, then for yβM we have yβzβM, so β¨xβz,yβzβ©=0β€0. Conversely, suppose β¨xβz,yβzβ©β€0 for every yβM, and let mβM. For tβ{1,β1} the point y=z+tm lies in M and yβz=tm, so tβ¨xβz,mβ©β€0 by Elementary Identities in a Real Inner Product Space (i); t=1 gives β¨xβz,mβ©β€0 and t=β1 gives 0β€β¨xβz,mβ©, hence β¨xβz,mβ©=0. Thus xβzβMβ₯.
Claim 2. Let x,xβ²βH and Ξ»βR. The vector PMβx+PMβxβ² lies in M, and (x+xβ²)β(PMβx+PMβxβ²)=(xβPMβx)+(xβ²βPMβxβ²) lies in Mβ₯ by claim 1 and (i). By claim 1, PMβ(x+xβ²)=PMβx+PMβxβ². Likewise Ξ»PMβxβM and Ξ»xβΞ»PMβx=Ξ»(xβPMβx)βMβ₯, so PMβ(Ξ»x)=Ξ»PMβx; thus PMβ is linear. For xβM, PMβx=x by Nearest-Point Projection onto a Nonempty Closed Convex Subset of a Real Hilbert Space (iii); applying this to PMβxβM gives PMβ(PMβx)=PMβx.
Claim 3. Let xβH. Since PMβxβM and xβPMβxβMβ₯ (claim 1), β¨PMβx,xβPMβxβ©=0, so Elementary Identities in a Real Inner Product Space (v) applied to x=PMβx+(xβPMβx) gives β£xβ£2=β£PMβxβ£2+β£xβPMβxβ£2. Since squares are nonnegative, the translation rule (claim 3 of Elementary Arithmetic in an Ordered Field) gives β£PMβxβ£2β€β£xβ£2 and β£xβPMβxβ£2β€β£xβ£2, and claim 2 of Monotonicity of Squaring on the Nonnegative Elements of an Ordered Field gives the two inequalities.
Claim 4. Mβ₯ is a closed linear subspace by (i), and Mβ©Mβ₯={0Hβ} by (ii) and 0HββMβ©Mβ₯. Let xβH. The vector xβPMβx lies in Mβ₯ (claim 1), and xβ(xβPMβx)=PMβxβMβ(Mβ₯)β₯ by (ii); so by claim 1 applied to the closed linear subspace Mβ₯, PMβ₯βx=xβPMβx. Finally, Mβ(Mβ₯)β₯ by (ii); conversely let xβ(Mβ₯)β₯. Then xβPMβxβMβ₯, so β¨x,xβPMβxβ©=0, and also β¨PMβx,xβPMβxβ©=0 since PMβxβM; subtracting (Elementary Identities in a Real Inner Product Space (i)) gives β£xβPMβxβ£2=β¨xβPMβx,xβPMβxβ©=0, so x=PMβxβM by Elementary Identities in a Real Inner Product Space (iii).
Claim 5. Existence: x=PMβx+(xβPMβx) with PMβxβM and xβPMβxβMβ₯ by claim 1. Uniqueness: if m+mβ²=n+nβ² with m,nβM and mβ²,nβ²βMβ₯, then mβn=nβ²βmβ² lies in Mβ©Mβ₯={0Hβ} by claim 4, so m=n and mβ²=nβ².
Claim 6. Let L be a linear subspace of H and LΛ its closure, which is closed by claim 2 of The Closure is the Smallest Closed Superset and contains L by claim 1 there. We first show that LΛ is a linear subspace and that LΛβ₯=Lβ₯. By Sequential Characterization of the Closure in a Metric Space, a point lies in LΛ if and only if it is the limit of a sequence in L. If x,yβLΛ are limits of sequences (xmβ), (ymβ) in L, then x+y and Ξ»x are limits of the sequences (xmβ+ymβ) and (Ξ»xmβ) in L by The Norm Metric of a Real Inner Product Space: Triangle Inequalities, Limits and Continuity (iv), so lie in LΛ; and 0HββLβLΛ. Since LβLΛ, every element of LΛβ₯ lies in Lβ₯. Conversely let wβLβ₯ and xβLΛ with xmββx, xmββL; then β¨x,wβ© is the limit of the constant sequence (β¨xmβ,wβ©)=(0) by The Norm Metric of a Real Inner Product Space: Triangle Inequalities, Limits and Continuity (v), so β¨x,wβ©=0 by claim 1 of Uniqueness of Limits and Boundedness of Convergent Real Sequences, and wβLΛβ₯.
Now L is dense in H if and only if LΛ=H (Dense Subset of a Topological Space). If LΛ=H, then Lβ₯=Hβ₯βHβ©Hβ₯={0Hβ} by (ii), and 0HββLβ₯, so Lβ₯={0Hβ}. Conversely, if Lβ₯={0Hβ}, then LΛβ₯={0Hβ}, and applying claim 4 to the closed linear subspace LΛ gives LΛ=(LΛβ₯)β₯={0Hβ}β₯=H, the last equality by Elementary Identities in a Real Inner Product Space (ii).