Doubt about counterexample of the Monotone convergence theorem and Riemann integral

integrationlebesgue-integralriemann-integration

In this question Why does the monotone convergence theorem not apply on Riemann integrals? there is the typical counterexample showing that the monotone convergence theorem does not hold for Riemann integrals. My question is: Why is $f_n(x)$ Riemann integrable for all $n$?

From the Lebesgue criterion, a function is Riemann integrable if it is bounded and the set of discontinuites has Lebesgue measure $0$. The boundedness is clear, however, I thought that $f_n(x)$ would be discontinuous for all $x \in [0,r_{n-1}]$ (assuming the enumeration of the rationals $r_1,r_2,…$ is ordered from lowest to highest) since if $x$ is an irrational number in $[0,r_{n-1}]$ I can find a sequence $x_k$, $k = 1,2,…$ in $[0,r_{n-1}]$ of rational numbers such that $f_n(x_k) = 1$ for all $k$ and $f_n(x) = 0$. And the reverse argument if $x \in [0,r_{n-1}]$ is rational. Finally the Lebesgue measure of $[0,r_{n-1}]$ is $r_{n-1}$ which is not $0$.

Also the upper Riemann sums should be strictly greater than zero since for some interval $[x_i, x_{i+1}]$ it will happen that $\sup_{x \in [x_i, x_{i+1}]} f_n(x) = 1$ (since rationals are dense in the reals) while the lower Riemann sum will always be zero.

What am I missing in these arguments?

Best Answer

The existing comments and answers tend to explain why the result is true, with less that I can see on where you error is.

It's not true that $f_n$ is discontinuous at every rational in $[0,r_n]$. In fact $f_n$ is continuous everywhere except at $r_1,\dots,r_n$. Your $f_n(x_k)=1$ only holds when $k\le n$, so you can't let $k\to\infty$ (with $n$ fixed) the way you do.