Suppose $g : [0,1] \rightarrow \mathbb{R}$ is bounded and measurable and $$ \int_{0}^{1}f(x)g(x)dx = 0 $$ whenever $f$ is continuous and $\int_{0}^{1}f(x)dx = 0$. Prove that $g$ is equal to a constant a.e
How do I solve it? I tried integration by parts, but it didn't work...
Let $c := \int_0^1 g(x)\, dx$. Then for any $f \in C([0,1])$ we have (as $f - \int_0^1 f(x)\, dx $ has integral 0), $$ \int_0^1 f(x)g(x)\,dx = \int_0^1 \left(\int_0^1 f(y)\,dy\right)g(x)\, dx = c \cdot \int_0^1 f(x)\, dx $$ Let $U \subseteq [0,1]$ be open. There is a sequence of $f_n \in C([0,1])$ converging pointwise to $\chi_U$, applying the above for $f_n$ and taking limits (legit due to Lebesgue's dominated convergence theorem), $$ \int_U g(x)\, dx = c \cdot \lambda(U). $$ But now $A \mapsto \frac 1c \int_A g(x)\, dx$ is a measure on $[0,1]$ agreeing with $\lambda$ on the open sets, hence on all measurable sets, giving $c\lambda(A) = \int_A g(x)\, dx$, for all measurable $A$.
Now for $\epsilon > 0$: $$ c \lambda(\{g > c+\epsilon\}) = \int_{\{g > c+\epsilon\}} g\, dx \ge (c+ \epsilon)\lambda(\{g > c+\epsilon\}) $$ hence $\lambda(\{g > c +\epsilon\}) = 0$. As $\epsilon > 0$ was arbitrary, $g \le c$ almost everywhere. Considering $\{g < c - \epsilon\}$ and arguing as above, shows $g = c$ almost everywhere.