Deciding whether $f$ is Lebesgue integrable Background: I'm learning Lebesgue's theory of integration. We have set up the outer measure, then defined the Lebesgue measure using Carthedory's criterion, then showed operations under which the set of Lebesgue measurable sets is stable (e.g. complements and countable union). We have defined measurable functions and now set up Lebesgue's integral using simple functions. We have just proved MCT.
Question: I'm having trouble deciding when a function $f$ is Lebesgue integrable over an interval. The definition of $f$ being integrable we follow is that (i) $f$ is measurable and (ii) $\int f^+, \int f^- <\infty$, where $f^+:=\max(f,0)$ and $f^-:=\max(-f,0)$.
How would I say whether this function is integrable? Let $f$ be defined on $\mathbb{R}$ as $x$ if $x$ is rational, and $0$ if $x$ is irrational.
So far, I've rewritten $f$ as $f(x)=x\chi_{\mathbb{Q}}(x)$. Then $f$ is measurable since $g(x)=x$ is measurable and $\mathbb{Q}$ is a measurable set, so its characteristic function is measurable, and then note that $f$ is a product of measurable functions, hence measurable.
I'm not sure how to show $\int f^+, \int f^- <\infty$ because I don't know how to integrate over $\mathbb{Q}$. Any ideas?
 A: Let $S\subseteq[0,\infty)$ such that $s\in S$ iff a simple nonnegative function $g(x)=\sum_{k=1}^nc_k1_{A_k}(x)$ exists that satisfies $g(x)\leq|x|1_{\mathbb Q}(x)$ and $s=\sum_{k=1}^nc_k\lambda(A_k)$.
Here the $A_k$ can be taken as disjoint measurable sets.
Then by definition:$$\int|x|1_{\mathbb Q}(x)\lambda(dx)=\sup S$$
Now observe that under the mentioned conditions we have: $$c_k>0\implies A_k\subseteq\mathbb Q\implies\lambda(A_k)=0$$
This tells us that $S=\{0\}$ and consequently:$$\int|x|1_{\mathbb Q}(x)\lambda(dx)=0$$
This does not only work for function $x\mapsto|x|$ but for every nonnegative measurable function, and the approach purely relies on definition.
In general if $\lambda(A)=0$ and $h$ is a nonnegative measurable function then:$$\int h1_Ad\lambda=0$$
A: For any measurable function $f$ and measurable set $A$ we have $$\int_A f(x)\lambda(dx)\leq \lambda(A)\cdot\sup_{x\in A}f(x)$$ Now note that $$\int x\cdot\chi_\mathbb Q(x)\lambda(dx)=\int_\mathbb Qx\lambda(dx)$$
First, compute for $K>0 $ the integral $$\int_{[-K,K]}x\cdot\chi_\mathbb Q(x)\lambda(dx)$$ and think about what happens when $K\to\infty$.
A: Let's show that $\int f^+ \, d\lambda < \infty$.
Any non-negative measurable function $f \colon X \to \mathbb R^+$ is the pointwise limit of a monotonic increasing sequence of non-negative simple functions $(f_n)$. In particular, let us define
\begin{align*}
I_{n,k} &= \left[\frac{k-1}{2^n},\frac{k}{2^n}\right) \text{ for } k=1,2,\ldots,2^{2n}\\
I_{n,2^{2n}+1} &= [2^n,\infty)\\
A_{n,k} &= f^{-1}(I_{n,k}) \text{ for } k=1,2,\ldots,2^{2n}+1\\
f_n &= \sum_{k=1}^{2^{2n}+1}\frac{k-1}{2^n}{\mathbf 1}_{A_{n,k}}
\end{align*}
Since $f_n \uparrow f^+$, by monotone convergence, $\int f_n \, d\lambda \uparrow \int f^+ \, d\lambda$. Furthermore,
\begin{align*}
\int f_n \, d\lambda = \sum_{k=1}^{2^{2n}+1}\frac{k-1}{2^n} \, \lambda(A_{n,k})
\end{align*}
Since $A_{n, k} = \mathbb Q \cap I_{n, k}$, we infer that $\lambda(A_{n, k}) = 0$, whence $\int f_n \, d\lambda = 0$. This implies, finally, that
\begin{align*}
\int f^+ \, d\lambda = 0
\end{align*}
