# Orthonormal basis in Hilbert spaces

I have a general question but I'm going got ask it in a very restrictive setup.

It is known that an equivalent condition for a system $\left\{e^{i\lambda t}\right\} _{\lambda\in\Lambda}$ being an ONB in a $L^{2}\left(S\right)$ (where $S\subset\mathbb{R}$ some bounded set of positive lebesgue measure, and $\Lambda\subset\mathbb{R}$ some discrete set) is that Parseval's identity will be true for all $f\in L^{2}\left(S\right)$, i.e. $\left\Vert f\right\Vert ^{2}=\underset{\lambda\in\Lambda}{\sum}\left|\left\langle f,e^{i\lambda t}\right\rangle \right|^{2}$.

I know that in fact it is enough to have Parseval's identity just for all functions of the kind $f_{x}\left(t\right)=\chi_{_{S}}\left(t\right)\cdot e^{ixt}$, $x\in\mathbb{R}$.

My question is why is this true? I mean, orthogonality is trivial. But how can one deduce completeness from this? Is it trivial to show that if Parseval's identity holds for such functions then it holds for all functions in the closure of its linear span? (the fact that $\left\{ \chi_{_{S}}\left(t\right)\cdot e^{ixt}\right\} _{x\in\mathbb{R}}$ spans $L^{2}\left(S\right)$ is trivial).

Thanks

Given an orthonormal sequence of vectors $(f_j)$ in Hilbert space $\mathcal H$, define an operator $T:\mathcal{H}\to\mathcal{H}$ by $$Tf=\sum_{j}\langle f,f_j\rangle f_j\tag1$$ By Bessel's inequality the coefficients $c_j=\langle f,f_j\rangle$ are in $\ell_2$, so the series in (1) converges. Moreover, we have $$\|Tf-f\|^2 =\langle Tf-f, Tf-f \rangle = \text{(...magic happens)} = \|f\|^2-\sum_{j}|c_j|^2\tag2$$
So, the validity of Parseval's identity for $f$ is equivalent to $Tf=f$. Since $T$ is bounded and linear, it suffices to check $Tg_k=g_k$ for some set $\{g_k\}$ with dense linear span.