This is pretty difficult, so I will only tell you what the steps are. It would take much too long to write out the full proof. In all of these definitions and theorems, H is a Hilbert space. I will assume that H is such that there exists a countable basis. (This assumption is standard when we're dealing with single-particle quantum theories, but I've been told that it's too restrictive for quantum field theory). I'm using the convention that the inner product is linear in the second variable.
Definition: An orthonormal basis of H is an orthonormal set that's not a proper subset of any other orthonormal set.
Theorem: Suppose that K is a closed convex subset of H. For each x in H, there's a unique x
0 in K that's at the minimum distance from x. (In other words, this x
0 satisfies d(x,x
0)=d(x,K)).
Theorem: Suppose that M is a closed linear subspace of H. For each x in H, the following conditions on x
0 in M are equivalent:
(a) x
0 is the unique vector at the minimum distance from x.
(b) x-x
0 is orthogonal to M.
Definition: The map x\mapsto x_0 is called the orthogonal projection onto the closed linear subspace M. Orthogonal projections are also called projection operators.
Theorem: If E={e
1,...,e
n} is an orthonormal set, and P is the projection operator for the linear subspace spanned by the members of E, then for all x in H,
Px=\sum_{k=1}^n\langle e_k,x\rangle e_k.
(This is proved by showing that x minus the sum on the right is orthogonal to the subspace, and then appealing to the previous theorem).
Theorem: If E={e
1,e
2,...} is an orthonormal set, then for all x in H,
\sum_{k=1}^\infty|\langle e_k,x\rangle|^2\leq\|x\|^2.
(The inequality above is called Bessel's inequality).
Theorem: For each x in H, the sequence of partial sums of the series \sum_{k=1}^\infty \langle e_k,x\rangle e_k is a Cauchy sequence. (By definition of "Hilbert space", this means that the series is convergent).
Theorem: If E={e
1,e
2,...} is an orthonormal basis, then for each x in H, x-\sum_{k=1}^\infty \langle e_k,x\rangle e_k is orthogonal to E (and therefore =0).
You will need to use other results along the way, like the Pythagorean theorem for Hilbert spaces, and this theorem about series whose terms are real numbers:
Theorem: If \sum_{k=1}^\infty a_k is a convergent series in \mathbb R, then \lim_m\sum_{k=m}^\infty a_k=0.
This stuff is covered pretty well in
Conway, but I don't recommend the rest of the book. It's ridiculously hard to read. Kreyszig would be a much better choice. (That's what people are telling me. I haven't read it myself).