Fix $1<p<\infty$. Let $f \in L^p(E)$, where $E$ is a measurable subset of $\mathbb{R}^d$. Assume that $$ \int_E f(x)g(x)dx =0 $$ for all compactly supported continuous functions $g: \mathbb{R}^d \to \mathbb{R}$. Is it true that $f(x)=0$ for almost every $x \in E$?
Here is what I thought:
(1) Let $q$ be such that $1/p + 1/q=1$. I claim that $\displaystyle \int_E f(x)g(x)dx =0$ for all $g \in L^q$. This is because the space of compactly supported continuous functions is dense in $L^q(E)$, so by Holder's inequality we obtain the claimed result.
(2) Now consider the natural isomorphism between ${L^q}^\ast$ and $L^p$. The linear functional $\kappa_f (g):=\displaystyle \int_E f(x)\cdot g(x) dx$ is hence zero in ${L^q}^\ast$, so $f(x)$ is equivalent to the zero function in $L^p$, so $f(x)=0$ a.e.
I was wondering if the preceding argument is valid? Is there a more straight-forward way of showing the result (e.g. without using the duality)? Any help is appreciated!
It looks good. Here's a proof that doesn't go through the dual space. However it's really not all that different from what you have.
Since $f\in L^p$, we obtain from a version of Hölder's inequality (seen here as "Extremal equality") a function $g\in L^q$ such that $$\|f\|_p=\left|\int_E f(x)g(x)\,dx\right|.$$ Given $\varepsilon>0$, there exists by the density of the compactly supported continuous functions in $L^q$ a compactly supported continuous function $h$ such that $\|g-h\|_q\|f\|_p<\varepsilon$. Then, by Hölder's inequality and our hypothesis, we have $$ \|f\|_p=\left|\int_Ef(x)g(x)\,dx\right| \leq \int_E|f(x)||g(x)-h(x)|\,dx + \left|\int_E f(x)h(x)\,dx\right| \leq \|f||_p\|g-h\|_q < \varepsilon. $$ Therefore $\|f\|_p=0$, which implies $f=0$ a.e.