Integral of rationals

It depends if you're talking about a Riemann integral or a Lebesgue integral.

If we are talking about a Riemann integral, the answer is that we cannot define the integral because any sub-interval of $[0,1]$ - no matter how small - contains a rational and an irrational. For this reason the upper integral and lower integral will not be the same (here the $\sup f = 1$ and $\inf f = 0$ on any sub-interval).

If you are talking about a Lebesgue integral, the answer is yes. This is because integrating over $[0,1]$ and $[0,1] \setminus \mathbb Q$ will give the same answer under certain conditions. You'd need to know a little bit of measure theory to completely understand the details, but the formulation of the Lebesgue integral tells you that integrating over a set of measure zero (the rationals for example) will be zero, and thus $$\int_{[0,1]} f(t) dt = \int_{[0,1] - \mathbb Q} f(t) dt + \int_{\mathbb Q} f(t) dt = \int_{[0,1]- \mathbb Q} 1 dt + 0 = 1$$

I'm omitting some details, but hopefully this provides some insight.


$f$ isn't Riemann-integrable but Lebesgue-integrable and indeed its integral is $1$, because $f=1$ almost everywhere on $[0,1]$, since $\mathbb{Q}$ is countable.


It depends on your definition of integral. The Riemann integral, the first one taught in calculus classes, does not have a value because the lower sum is always zero and the upper sum is always one. The Lebesgue integral of this function exists and is $1$ as your intuition suggests.