Is Dirichlet function Riemann integrable? "Dirichlet function" is meant to be the characteristic function of rational numbers on $[a,b]\subset\mathbb{R}$. 
On one hand, a function on $[a,b]$ is Riemann integrable if and only if it is bounded and continuous almost everywhere, which the Dirichlet function satisfies.
On the other hand, the upper integral of Dirichlet function is $b-a$, while the lower integral is $0$. They don't match, so that the function is not Riemann integrable.
I feel confused about which explanation I should choose... 

The Dirichlet function $f : [0, 1] → \mathbb R$ is defined by

$$f(x) = \begin{cases}
1, & x ∈  \mathbb Q \\
0, & x ∈ [0, 1] - \mathbb Q
\end{cases}$$

That is, $f$ is one at every rational number and zero at every irrational number.
This function is not Riemann integrable. If $P = \{I_1, I_2, . . . , I_n\}$ is a partition
of [0, 1], then
$M_k = \sup
I_k
 = 1, m_k = \inf
I_k
= 0$,
since every interval of non-zero length contains both rational and irrational numbers.
It follows that
$U(f; P) = 1, L(f; P) = 0$
for every partition $P$ of $[0, 1]$, so $U(f) = 1$ and $L(f) = 0$ are not equal.
The Dirichlet function is discontinuous at every point of $[0, 1]$, and the moral
of the last example is that the Riemann integral of a highly discontinuous function
need not exist.
