Integrating against compactly supported functions Let $\Omega$ be an open bounded set in $\mathbb R^n$ and let $f : \Omega \to \mathbb R$. Assume $f$ is continuous and satisfies
$$ \int_\Omega f(x)g(x)\; \mathrm{d}x = 0 $$
for any $g$ compactly supported in $\Omega$. Show that $f$ is identically zero in $\Omega$.
I think I have a proof by contradiction, but I would like to do better. Suppose $f(x_0)> 0$ for some $x_0 \in \Omega$. Then $f$ is positive in some neighborhood o $\Omega$ Let $g$ be equal to 1 in some compact subset of this neighborhood, so that 
$$\int_\Omega f(x)g(x) > 0,$$
a contradiction.
My idea was to somehow force $|f(x)| < \varepsilon$ for all $\varepsilon > 0$, but I can't come up with the right estimates. 
 A: Fix a point $x_0$. Let $\epsilon > 0$ be given. There exists $\delta > 0$ with the property that $|x-x_0| < \delta$ implies $|f(x) - f(x_0)| < \epsilon$, and in turn $f(x_0) < f(x) + \epsilon$.
Let $g \ge 0$ be compactly supported in $(x_0 - \delta,x_0 + \delta)$ with integral $1$.  Then
$$ f(x_0) = \int f(x_0) g(x) \, dx \le \int (f(x) + \epsilon) g(x) \, dx = \epsilon \int g(x) \, dx = \epsilon.$$
A nearly identical argument will give you $f(x_0) \ge -\epsilon$, so that $|f(x_0)| \le \epsilon$ as required.
A: The argument you outlined looks like the simplest one and, by the way, it's not a contradiction argument,
but a contrapositive argument, since you prove that $ ( \text{not } B ) \implies ( \text{not } A ) $ instead of proving that $ A \implies B $.
A direct argument could be the following one but it needs a bit of Lebesgue's measure and integration theories.
First of all, the class of "test functions" $ g $ is not explicitly stated in your question: since you wrote "any $ g $ compactly supported in $ \Omega $",
I'm assuming that $ g $ is any Lebesgue integrable function.
Actually the same statement holds true for smaller classes of test functions: the smaller the class, the more technical the proof.
Now, in order to transform your argument in a direct argument, one could consider the set
$ F_{\epsilon} := \{ x \in \Omega : |f(x)|>\epsilon \} $, for $ \epsilon > 0 $, which is open since $ f $ is continuous, and, thus,
measurable.
Moreover $ F_{\epsilon} $ is empy if and only if it has zero Lebesgue measure (non-empty open sets have positive measure since they must contain a non-trivial ball).
So, instead of showing that $ |f(x)| > \epsilon $ implies the negation of the assumption, one can show that the assumption implies that
the set $ F_{\epsilon} $ is empty for all $ \epsilon > 0 $.
To this aim, fix any compact set $ K \subset \Omega $ and consider the test function $ g $ as follows:
$$
g(x) :=
\begin{cases}
+1 & \text{if } x \in K \text{ and } f(x) > \epsilon \\
-1 & \text{if } x \in K \text{ and } f(x) < -\epsilon \\
0  & \text{otherwise.}
\end{cases}
$$
Observe that $ g $ is a measurable bounded function since $ K $ is compact and $ f $ is continuous.
Moreover $ g $ is zero outside the compact set $ K $ and, thus, it is Lebesgue integrable on $ \Omega $.
The assumption implies that:
$$
0 = \int_{\Omega} f g dx = \int_{ K \cap \{ f > \epsilon \} } f dx - \int_{ K \cap \{ f < -\epsilon \} } f dx \ge
\epsilon \mu ( K \cap \{ f > \epsilon \} ) + \epsilon \mu(  K \cap \{ f < -\epsilon \} ) = \epsilon \mu ( F_{\epsilon} \cap K ),
$$
where $ \mu $ stands for the Lebesgue measure.
Therefore we have that $ \mu( F_{\epsilon} \cap K ) = 0 $ for all compact sets $ K \subset \Omega, $ which implies that $ \mu( F_{\epsilon} ) = 0 $ and, hence,
that $ F_{\epsilon} $ is empty.
The same proposition holds true also if one restrict the class of test functions $ g $ to that of continuous functions or even to $ C^{\infty} $ functions but
the argument above needs technical adjustments to work: the function $ g $ I've chosen is not continuous so one has to show that it can be smoothly modified outside
$ K \cap F_{\epsilon} $ such that it is still compactly supported in $ \Omega $ and has the same sign of $ f $ wherever it is non zero.
However, if you want a proof that uses just Riemann integration, then my argument fails since the open sets $ F_{\epsilon} $ need
not be Peano-Jordan measurable.
Your argument remains probably the simplest argument.
