Prove that $f$ defined by $f(x)=1$ if $x \in \mathbb{Q}$, $f(x)=0$ if $x \in \mathbb{R}\setminus \mathbb{Q}$, is not integrable Prove that 
$$f\left ( x \right )= \begin{cases}
1 & x \in \mathbb{Q}, \\ 
0 & x\in \mathbb{R}\setminus \mathbb{Q}.
\end{cases}$$
is not integrable.
I came across this. I think that the function itself is not continuous? But I do not think that is a legitimate answer to this question.
 A: An important remark: since the function $f(x) = \begin{cases} 1 & x \in \mathbb{Q} \\ 0 & x \in \mathbb{R} \setminus \mathbb{Q} \end{cases}$ is clearly Lebesgue-integrable (being equal to $0$ almost everywhere), you are probably asking about Riemann integrability. In this case, though, you have a problem: the concept of Riemann integrability is defined only for functions defined on bounded intervals, and $f$ is defined on $\Bbb R$. I believe that what you meant to ask about is the following slightly modified function: $g(x) = \begin{cases} 1 & x \in [a,b] \cap \mathbb{Q} \\ 0 & x \in [a,b] \setminus \mathbb{Q} \end{cases}$. In this case, an answer can be given using Lebesgue's criterion of Riemann integrability: a bounded $f$ is Riemann-integrable on $[a,b]$ if and only if the set of discontinuities of $f$ has Lebesgue measure $0$.
Let $x \in [a,b] \cap \Bbb Q$. Then $f(x)=1$. Pick a sequence of irrational numbers $(x_n)_{n\in\Bbb N}$ with $x_n \to x$. Then $f(x_n)=0 \not\to 1=f(x)$, so $f$ is not continuous in $x$.
Let $x \in [a,b] \setminus \Bbb Q$. Then $f(x)=0$. Pick a sequence of rational numbers $(x_n)_{n\in\Bbb N}$ with $x_n \to x$. Then $f(x_n)=1 \not\to 0=f(x)$, so $f$ is not continuous in $x$.
The above argument shows that $f$ is discontinuous in all the points of $[a,b]$, which is a set of Lebesgue measure $b-a \ne 0$, therefore Lebesgue's criterion tells us that $f$ is not Riemann-integrable on $[a,b]$.
A: Let $S(f,P)$ and $s(f,P)$ be the upper and low sums of $f$ with respect to partition $P$ of interval $[0,1]$. Let $M_i=\sup\{f(x)| x \in I_i\}$ and $m_i=\inf\{f(x)| x \in I_i\}$, where $I_i$ is the $i$th interval of the partition $P$. Note that $M_i=1$ for all $i$, because every interval $I_i$ of the partition $P$ contains rational numbers. On the other hand, $m_i=0$ for all $i$ because every interval $I_i$ of the partition $P$ contains irrational numbers. By definition,
$$S(f,P)=\sum_{i=1}^nM_i\mu(I_i)=\sum_{i=1}^n1\mu(I_i)=\sum_{i=1}^n\mu(I_i)=1-0=1$$
$$s(f,P)=\sum_{i=1}^nm_i\mu(I_i)=\sum_{i=1}^n0\mu(I_i)=0$$
Thus, $f$ is not Riemann integrable because the upper and lower integrals are not equal. (The upper integral is the limit of the upper sums and the lower integral is the limit of the lower sums).
A: The peculiarity of this function is that it has an infinite number of discontinuities in any finite interval over which it is Riemann-integrated.
Here, the upper and lower Riemann sums do not coincide. Hence it is not Riemann integrable. But it is Lebesgue integrable.
For further reading, you may check this.
