TITLE: Using test functions to "test" whether functions vanish
QUESTION [6 upvotes]: Let $U$ be an open subset of $\mathbb R^n$ and let $f \in L_{\text {loc}}^1(U)$ (i.e. $f$ is integrable on compact subsets of $U$). Suppose $\int_U f \phi = 0$ for all test functions $\phi \in C_c^\infty(U)$.
Does this imply that $f = 0$ a.e.? If so, why?
I ask this question because I'm learning about analysis of PDEs from Evans' textbook. This fact, or something similar to it, is used everywhere, but I can't think of a rigorous proof for it. One approach I tried is to approximate indicator functions on arbitrary measurable subsets of $U$ by their mollifications, but I haven't managed to get this to work. I wonder if there is a better method.

REPLY [3 votes]: You can get $f=0$ almost everywhere. Take an $x\not= 0$, and let $B$ be a ball centered in $x$, but small enough to be away from the origin (contained in $U$). Then take $\phi_n \in C^{\infty}_c(B)$ to  be approximations of $\chi_B$ from below (just so you can use dominated convergence). Then, for every $n\in \mathbb{N}$,
$$
\int_{U}f(x)\phi_n(x)dx = 0.
$$
Then, from the dominated convergence theorem you get that
$$
\int_Bf(x)dx = 0.
$$
Dividing by the volume of the ball, you get $\frac{1}{|B|}\int_Bf(x)dx = 0$. Sending the radius of the ball to zero and using Lebesgue's differentiation theorem, you get $f \equiv 0$ a.e. in $U$. Note that you can't guarantee $f=0$ pointwise (just take $f$ not zero in a single point).