Q:

If two functions are equal in $L^2$, are they equal in other spaces?

Let $f\in L^{2}$ and $g\in W^{k,2}$ and assume that
$(f,v)_{L^2}=(g,v)_{L^2}\quad \forall v\in L^2$.
Does this imply that $f=g$ and therefore $f$ is in $W^{k,2}$

A:

Based on the comment of Bananach:
Using $v=f-g$ one can see that they are equal in $L^2$.
Because $W^{k,2}$ is a subspace of $L^2$, it follows that
$f\in W^{k,2}$ and $f=g$ in W^{k,2}$.
As you said, we also know that $f = g$ almost everywhere.
There are spaces where the above would not be true.
For instance, if we replace $W^{k,2}$ with $C[0,1]$ in the question,
then $f$ does not need to be continuous, but $f$ is equal a.e.\ to the continuous function $g$.

