Show that the set of functions in $L^2[0,1]$ with a zero integral on $[0,1]$ is a closed vector subspace of $L^2[0,1]$. 
Let $H = L^2([0, 1])$ and let $K \subset H$ be defined as $K = \{f \in H \, : \, \int_{[0,1]} f \, \mathrm{d}m = 0\}$. Show that $K$ is a closed vector subspace of $H$. Find the element of $K$ that is closest to $g(x) = x$ (note $g \in H \,\backslash \, K$).

(The integrals are Lebesgue integrals, in case that's not clear.)
This problem was on a problem set for $L^p$ spaces in my undergraduate-level real analysis course. Showing that $K$ is a vector subspace is easy; it is evident that the zero function is an element of $K$ and properties of Lebesgue integration give us that for functions $f,g \in K$, we have that $f+g \in K$, and also for a scalar $c \in \mathbb{R}$, we have $cf \in K$. This shows that $K$ is a vector subspace of $H$, but as my grader noted, that is insufficient to show that this is a closed vector subspace of $H$. Unless I'm overlooking something relatively obvious, I'm not sure what I'm missing there.
So onto the second part of the question: finding the element of $K$ that is closest to $g(x) = x$. Now, the projection of $g(x) = x$ onto $K$ will satisfy this condition, and to find that, we need to find $f$ such that $\langle g-f,f \rangle = 0$, where the angle brackets denote the usual inner product on the Hilbert space $L^2$, which is $\langle h,j \rangle = \int h \bar{j} \; \mathrm{d}m$, but since we're working in the reals, the complex conjugate is irrelevant. So since we are given $g$, we can expand $\langle g-f,f \rangle$: $$\langle g-f,f \rangle = \int (g-f) \bar{f} \mathrm{d}m = \int (g-f)f \, \mathrm{d}m = \int (x-f)f \, \mathrm{d}m = 0$$
So $f(x) \equiv 0$ or $f(x) = x$, but in the latter case, $f(x) = g(x) \not\in K$, so then $f(x) \equiv 0$. The grader says, however, that it is not true that $(x-f)f = 0$, and I guess I can see why (plenty of non-zero functions have zero integral on $[0,1]$, and this isn't even considering functions that are merely equal to zero a.e., so I feel pretty silly for making that mistake), but does that change my answer? After all, I only lost one point on this section and one point on the first section. What am I missing in each part of this question?
 A: The function $u(x):=1$ $(0\leq x\leq1)$ is in $H$, and the map
$$\phi:\quad H\to{\mathbb R}, \qquad f\mapsto \langle u,f\rangle$$
is continuous. Therefore $K={\rm ker\,}(\phi)$ is a closed subspace of $H$.
It is now "geometrically obvious" how we obtain the element $g\in K$ nearest to the function ${\rm id}: \>x\mapsto x$: Subtract from ${\rm id}$ a suitable multiple $\lambda u$, such that $g:={\rm id}-\lambda u\in K$. I'd say that
$$g(x):=x-{1\over2}\qquad(0\leq x\leq1)$$
does the trick.
A: Still, it may be not the shortest way but it should work.
First, let's prove the following

Let $T: X \rightarrow \mathbb{C}$ be a linear functional from Banach space $X$ to $\mathbb{C}$. Then, $ker(T)$ is closed iff $T$ is bounded.

1) Assume that $T$ is bounded, since it's linear then it's continuous. $T^{-1}(0)=ker(T)$ $-$ a preimage of a closed set is closed under the continuous map.
2) If $ker(T)$ is closed, then it's possible to equip $X / ker(T)$ with a norm,  defined in the following way: $|| [x] || = inf \{||x|| \in [x] \}$. 
A map $p: X \rightarrow X /(ker(T))$ is continuous. Moreover, $X / (\ker(T)) \cong im(T) \subset \mathbb{C}$ (but only as vector space, we need to establish, whether the isomorphism is continuous). Indeed, it is, since $im(T)\subset \mathbb{C}$ is finite dimensional, then $X / (ker(T))$ is finite-dimensional too. But any linear map between finite-dimensional spaces is continuous. 
So, let $\varphi: X / (ker(T)) \rightarrow \mathbb{C}$, $p: X \rightarrow X /(ker(T))$, then $\psi = \varphi \circ p$ is continuous.
So, in your case the functional is $T: L^{2}[0, 1] \rightarrow L^{2}[0, 1]$, $T(f) = \int_{0}^{1}{f dm}$. From the propetries of Lebesgue integral, $T$ is linear. Moreover, $L^{2}[0, 1]$ is  Banach (actually it's  a Hilbert space). $H$ is a kernel of $T$, the last thing to check is that $T$ is bounded. Indeed, by Cauchy-Schwartz inequality $$(\int_{0}^{1}{f dm})^{2} \leq \int_{0}^{1}{f^{2} dm}$$ since $f \in L^{2}[0, 1]$ then the image of $T$ is bounded.  So, $H$ is a closed subspace.
