Prove the following:
Every non trivial separable Hilbert space $H$ has an orthonormal basis, i.e., an orthonormal set whose linear span is dense in $H$
My attempt:
Let $V = (v_n)_{n\geq1}$ be a dense countable set of vectors in $H$. Remove all vectors that are $0$, and then, skim the sequence from the left to the right and remove every vector that is a linear combination of the previous ones. Call the obtained sequence, which is possibly finite, $(y_n)_{n\geq1}$.
By construction, this sequence of vectors is linearly independent, so we can apply the Gram-Schmidt (GS) algorithm to find a sequence $(\phi_n)_n$ of vectors such that $O := \{\phi_n\mid n\}$ is an orthonormal set of vectors.
It now suffices to show that the linear span of $O$ is dense in $H$, in order to conclude that $O$ is an orthonormal basis. For this, it suffices to show that $O^\perp = \{0\}$.
So, let $v \in O^\perp$. Then $\langle v,\phi\rangle = 0$ for every $\phi \in O$, and by linearity of the inner product, it follows that $v \in \operatorname{span}(O)^\perp$. By continuity of the inner product, it follows that $v \in \left(\overline{\operatorname{span}(O)}\right)^\perp$.
Now, $\operatorname{span} O = \operatorname{span}\{\phi_n \mid n\} =^{GS} \operatorname{span}\{y_n\mid n\} = \operatorname{span} V$
so that $\left(\overline{\operatorname{span}(O)}\right)^\perp = \left(\overline{\operatorname{span(V)}}\right)^\perp \subseteq \operatorname{span}(\overline{V})^\perp = \operatorname{span}(H)^\perp = H^\perp = \{0\}$, where we used that $X \subseteq Y \implies Y^\perp \subseteq X^\perp$ and hence $v = 0$
Is this correct?
Your proof is correct.
However, you can make it shorter. You're trying to prove that $\overline{\operatorname{span}\{\phi_n | n \in \mathbb{N}\}} = X$.
As you noticed, by the span-preserving property of Gram-Schmidt, we have
$$\operatorname{span}\{\phi_n | n \in \mathbb{N}\} = \operatorname{span}\{y_n | n \in \mathbb{N}\} = \operatorname{span}\{v_n | n \in \mathbb{N}\}$$
and hence $$\overline{\operatorname{span}\{\phi_n | n \in \mathbb{N}\}} = \overline{\operatorname{span}\{v_n | n \in \mathbb{N}\}} = X$$
since $\operatorname{span}\{v_n | n \in \mathbb{N}\}$ is assumed to be dense in $X$.
Your proof, as is, relies on the fact that $M^{\perp\perp} = M$ for all closed subspaces $M$ of $X$, a fact which only holds in Hilbert spaces. Indeed, in a non-Hilbert space it can hold $M^\perp = \{0\}$ but $M$ doesn't have to be dense.
So if you use the shorter proof above, you can in fact conclude: