Is a function null if its integrals over all rectangles vanish?

In answering this question we have used the following result.

Lemma If a measurable function $f \colon \mathbb{R}^n \to \mathbb{R}$ is such that, for every (compact) rectangle $R$,

$$\int_R f(x)\,dx=0,$$

then $f=0$ almost everywhere.

I'm pretty much sure this is true, both for recalling having read about it somewhere and for its intuitive obviousness. However, when cooking up a proof, I couldn't avoid making use of the additional assumption $f \in L^1_{\rm{loc}}(\mathbb{R}^n)$. You can read my try here (I've explicitly mentioned the point in which the additional assumption is exploited).

How to dispense with that?

In comments below Didier, Julian and Byron noted that the condition $\int_R f(x)\,dx=0$ on the rectangle $R$ implicitly says $f \in L^1(R)$. And so, requiring it to hold for every compact rectangle implies $f \in L^1_{\rm{loc}}(\mathbb{R}^n)$. Of course you're right: to sum things up, my question is totally trivial!!! :-)

I guess it is now universally clear that I'm a novice (still a student, in fact).

Thank you very much for helping.

-
yes, the rectangles are a basis for the sigma algebra. you could replace $f$ by $g=1$ if $f\neq0$ $g=0$ otherwise and show that $g$ is identically zero – yoyo Mar 24 '11 at 15:41
How do you define $\int_R f(x) dx$ when $f$ is not in $L^1_{\rm loc}(\mathbb{R}^n)$? – Byron Schmuland Mar 24 '11 at 17:37
Re your edit, this is just to mention that I see absolutely no problem with asking (what you call) a trivial question on MSE the way you did. You gave some motivation, you described your thoughts and attempts, it just happened that there was a simple answer, and so what? If you get the occasion to talk with some great minds in mathematics, I can assure you that, very often, they will explain to you how novice they are on such and such subject and the dumb mistakes they made once... – Did Mar 24 '11 at 19:08
@Didier: You know, comments like your last are very valuable for a student. I'm starting to like this community! Thank you. – Giuseppe Negro Mar 24 '11 at 20:06

As I understand this post, the OP asks about the necessity, or not, of the hypothesis that $f\in L^1_{\mathrm{loc}}(\mathbb{R}^n)$ for the lemma to hold (as opposed to, how to prove the lemma).

But the hypothesis of the lemma makes no sense unless $f\in L^1_{\mathrm{loc}}(\mathbb{R}^n)$ since, to be simply able to write something like $\displaystyle\int_Rf(x)\mathrm{d}x$, one must assume that $f\in L^1(R)$. And to ask that $f\in L^1(R)$ for every (compact) rectangle $R$ is equivalent to asking that $f\in L^1_{\mathrm{loc}}(\mathbb{R}^n)$.

-

Let's write $f(x)=g(x)-h(x)$ where $g$ and $h$ are the positive and negative part of $f$. Then $\int_rg=\int_rh<\infty$ for every rectangle $r$ by your assumption. Let us restrict from $\mathbb{R}^n$ to a rectangle $P$. It's enough to show that $f$ is 0 a.e. in $P$ for every $P$. Now $\mu_1:A\mapsto\int_A g$ and $\mu_2:A\mapsto\int_A h$ ($A\subset P$ measurable) are finite measures on $P$. We have $\mu_1(r)=\mu_2(r)$ for every rectangle $r\subset P$ by your assumption. Since rectangles form a $\pi$-system, we know that $\mu_1=\mu_2$ by Dynkin theorem (=monotone class theorem). Hence $g=h$ a.e., hence $f=g-h=0$ a.e.

Edit: thanks to Nate (replaced $\lambda$ by $\pi$)

-
I get your idea but I think we adopt different definitions of $\lambda$-system: I adhere to this. So I would reformulate your last sentence like this: "Since the $\lambda$-system generated by the rectangles is the whole Borel $\sigma$-algebra, we know that $\mu_1=\mu_2$". Don't you agree? – Giuseppe Negro Mar 24 '11 at 16:41
The collection of measurable sets $B$ such that $\mu_1(B) = \mu_2(B)$ is a $\lambda$-system (a very useful fact!). The set of rectangles is a $\pi$-system which generates the Borel $\sigma$-algebra. – Nate Eldredge Mar 24 '11 at 17:07
ah sorry (thanks Nate), I should have said $\pi$-system, and that it then follows by Dynkin $\pi/\lambda$ theorem – user8268 Mar 24 '11 at 17:24
@user8268: Ok. I understood you meant that but was afraid you were using different definitions instead. By the way, nice proof! @Nate Eldredge: (referring to: "A very useful fact!") Now that you're pointing this out, I recall having seen this fact many times, especially during probability theory and stochastic processes courses. But I had never focused on it. Thank you. – Giuseppe Negro Mar 24 '11 at 18:42

As noted by user8268 (and by Didier as I was writing this), your assumption implies that $f$ is locally integrable. The definition of integral for a signed function $f$ includes the condition that the integral of $f^+$ or of $f^-$ is finite.

Now, the Lebesgue differentiation theorem implies that if the integral of $f$ vanishes on all rectangles, then $f=0$ almost everywhere. It is even enough that the integral vanishes on a family of rectangles of eccentricity between two bounds $M$ and $M^{-1}$.

-