$\int_0^1 fg\geq 0$ for every non negative, continuous $g$ implies $f\geq 0$ a.e. I'm trying to solve the following problem.
Let $f$ be an integrable function in $(0,1)$. Suppose that $$\int_0^1fg\geq0$$
for any non negative, continuous $g:(0,1)\to\mathbb{R}$. Prove that $f\geq0$ a.e. in $(0,1)$.
I'm a little unsure on what it is that I must prove in order to conclude that $f\geq0$. I tried to show that $\int_0^1f^2\geq0$ but I couldn't get very far.
I'm seeking hints on how to solve this. Thanks.
 A: Suppose that $A \subset (0,1)$ is measurable, is of positive measure and $f<0$ on $A$. The idea is that we want to construct a continuous function $g$ such that $$\int_0^1 fg\, dx<0. $$ A logical way to do this would be to choose $g$ such that $g\geqslant 0$ in $A$ and $g=0$ on $(0,1) \setminus A$. However, since $A$ is only a measurable set, in general $g$ will be discontinuous.
The way to get around this is to use the result I mentioned in the comments. A direct corollary of this result is that, given $\varepsilon >0$, there exists a (relatively) closed set $F \subset A$ such that $\vert A \setminus F \vert <\epsilon$. Choosing $\epsilon = \vert A \vert /2 >0$, we have that $$\vert F \vert=\vert A \vert - \vert A \setminus F\vert= \vert A \vert /2 >0.$$ Since $\vert F \vert >0$, the interior of $F$ is nonempty. Thus, there exists an open set $U$ compactly contained in the interior of $ F$ (just take a small ball for example). Define $g$ such that $g$ is continuous, nonnegative, $g=0$ in $A\setminus F$, and $g=1$ in $U$. Then \begin{align*} \int_0^1 fg \, dx &=\int_F fg \, dx \\
&=\int_U f \, dx + \int_{F\setminus U} fg \, dx \\
&\leqslant \int_U f \, dx \\&<0.
\end{align*} This completes the proof.
A: Fix $x\in (0,1).$ Let $n\in \mathbb N$ large enough so that $(x-1/n,x+1/n)\subseteq  (0,1).$ We can find continuous functions  $0\le g_n\le 1$ on $(0,1)$, centered at $x$, supported in $(x-1/2n,x+1/2n)$ and such that $g_n(x)=1.$ (bump triangles will do). Note that $g_n(t)\to \chi_{\{x\}}(t)$ as $n\to \infty.$
Now, by hypothesis, $\displaystyle \int_0^1fg_ndt\ge 0.$ And since $|fg_n|\le |f|\in L^1((0,1))$, the DCT applies to show that
$0\le \lim \displaystyle \int_0^1fg_ndt=\int_0^1\lim fg_ndt=\int_0^1f(t)\cdot \chi_{\{x\}}(t)dt=f(x)\int_0^1dt=f(x).$
A: Notation: $m(S)$ is the Lebesgue measure of a set $S$.
Let $A=f^{-1}[0,\infty).$ Let $B=[0,1]$ \ $A$. We have $\int_0^1f(x)dx=\int_Af(x)dx+\int_Bf(x)dx.$
We need: For any $r>0$ there exists $s>0$ such that for any measurable $E,$ if $m(E)<s$ then  $\int_{E\cap A}f(x)dx<r.$
Suppose by contradiction that $m(B)>0.$ We have $B=\cup_{n\in\Bbb N}B(n)$ where $B(n)=f^{-1}[-1/n,-\infty).$  So fix some $n\in\Bbb N$ such that $m(B(n))>0$.
Let $C\subseteq B(n)$ be closed in $[0,1]$ with $m(C)>m(B(n))/2.$
Let $r=(1/n)(m(B(n)/4).$ Take $s>0$ such that $\int_{E\cap A}f<r$ whenever $E$ is measurable and $m(E)<s.$
Let $D\subseteq [0,1] \setminus C$ be closed in $[0,1]$ with $m(D)>m([0,1] \setminus C)-s.$
Since $C,D$ are closed and disjoint we can take a continuous $g:[0,1]\to [0,1]$ with $C=g^{-1}\{1\}$ and $D=g^{-1}\{0\}.$
Let $E=[0,1]\setminus (C\cup D).$ Since $fg=f
\le -1/n$ on $C,$ and $fg=0$ on $D,$ and $fg\le 0$ on $E\cap B$, and $fg\le f$ on $A$, and since $m(E)<s,$ we have $$\int_0^1 fg=\int_Cf+\int_ Efg\le$$ $$\le \int_Cf+\int _{E\cap A}fg\le$$ $$\le \int_Cf+\int_{E\cap A}f<$$ $$< (-1/n)(m(B(n)/2)+\int_{E\cap A}f=$$ $$=-2r+\int_{E\cap A}f<-2r+r<0.$$
