# Iterated integral exists, but is not integrable

On the domain $D:[0,1]\times[0,1]\times[0,1], ~f(x,y,z)$ is defined to be: \begin{align*} &1~ \text{for rational}~ x,\\ &2~ \text{for irrational}~ x,~0\leq y \leq \frac{1}{2}\\ &0~ \text{for irrational}~ x,~\frac{1}{2}< y \leq 1. \end{align*}

The question asks to show that the iterated integral $\int_0^1\int_0^1\int_0^1f(x,y,z)~dz~dy~dx$ exists, but $f$ is not integrable.

I assume that the value for the iterated integral is simply 1, since $\mathbb{Q}$ is countable but $\mathbb{R}\setminus\mathbb{Q}$ is uncountable, and thus it is safe to assume that $x$ will take on irrational values for most of the interval $[0,1]$, with rational values negligible.

However, would that be a precise answer?

Also, I understand that $f$ would be nowhere continuous, but I am not sure how to extend that thought to rigorously show that $f$ would not be integrable.

My attempt was to show that an iterated Riemann sum would take on the form of: $$\sum_i^n \frac{1}{n}~ f(x_i,y_i,z_i),$$ but since there are infinitely many both irrational and rational $x$ in any given interval, $f(x_i,y_i,z_i)-f(x_{i+1},y_{i+1},z_{i+1})$ would always yield a nonzero value, which by definition should tend to $0$ should the number of iterations approach infinity.

Thanks for any help!

For example (A). Pick $x$ always to be rational. Then each sum is $1$, the limit is $1$.
(B) Pick rational $x$ for $0\le y\le \frac12$ but irrational $x$ for $\frac12<y\le1$. Then each sum evaluates to $\frac12$ and the limit is $\frac12$.
(C) Pick irrational $x$ for $0\le y\le \frac12$ but rational $x$ for $\frac12<y\le1$. Then each sum evaluates to $\frac32$ and the limit is $\frac32$.