Let $f,g\in L^1(\Omega), \Omega\in\mathbb{R}^n$. Define $M=\{ \phi\in C_c^{\infty}(\Omega): \langle f, \phi\rangle_{L^2}=0\}$.
I want to prove the following statement: $\langle g,\phi\rangle_{L^2}=0$ for all $\phi\in M$ implies that there exists $\lambda\in\mathbb{R}$ so that $$g(x)=\lambda f(x)$$ almost everywhere in $\Omega$.
I'm missing a proof idea. Is it worthwhile to consider $h=g-\lambda f$? Any help is greatly appreciated!
We make use of the fact that $L^2(\Omega)$ is a Hilbert space, and $C_c^\infty(\Omega)\subset L^2(\Omega)$ is dense.
$M$ is a dense subset of $\operatorname{span}\{f\}^\perp$, see the proof below. Therefore $\operatorname{cl}M = \operatorname{span}\{f\}^\perp$ (with $\operatorname{cl}$ being the closure).
There holds $M^\perp = (\operatorname{cl}M)^\perp$. Therefore $M^\perp = \operatorname{span} \{f\}^{\perp\perp} = \operatorname{span}\{f\}$.
Appendix: Density of $M$ in the orthogonal complement. There might be more elegant proofs, but here's one possible approach: Let $g\in\operatorname{span} \{f\}^{\perp}$ (and not in $C_c^\infty$). Then there are two sequences in $C_c^\infty$:
Both follows from the already stated fact that $C_c^\infty(\Omega)\subset L^2(\Omega)$ is dense. The $\phi_n$ can be decomposed orthogonally into $$\phi_n = \mu_n + \lambda_n f,\quad \text{ for }\mu_n\in f^\perp\text{ and }\lambda_n\in\mathbb C,$$ and $\lambda_n\to 0$, because $\phi_n\to g \in f^\perp$. The only remaining problem is that the $\mu_n\notin C_c^\infty(\Omega)$ necessarily. This is where we use $\psi_n$ to further decompose the $\phi_n$: First note that the sequence $(\psi'_n)$ also satisfies $\psi_n'\to f$: $$\psi'_n:=\frac{\|f\|^2}{\langle \psi_n, f\rangle}\psi_n.$$ We use this in the decomposition of $\phi_n$: $$\phi_n = [\mu_n + \lambda_n(f-\psi_n')] + \lambda_n\psi_n'.$$
Therefore, also $\phi_n':= \mu_n + \lambda_n(f-\psi_n')\in C_c^\infty \cap \{f\}^\perp$ converges to $g$. Hence $M\subset\{f\}^\perp$ is dense.