On the Interval $[0,1]$, the function $f(x)=\begin{cases}x-1,&\text{if }\;x\in\mathbb Q,\\x,&\text{if }\;x\in\mathbb Q^c\end{cases}$ is not integrable I know how to do it for $$f(x)=\begin{cases} 1, &\text{if }\; x \in \mathbb Q,\\ 0,&\text{if }\; x \in \mathbb Q^c,\end{cases}$$ becuase it's too easy.
But for $$f(x)=\begin{cases} x-1, &\text{if }\;x \in \mathbb Q,\\ x, &\text{if }\;x \in\mathbb Q^c, \end{cases}$$  I am not able to find $U(P,f)$ and $L(P,f)$ where $P$ is a parition of $[0,1]$.
Is there any property that I am missing to prove it?
 A: Write $$g(x)=\begin{cases} 1,& x \in \mathbb Q\\ 0, &x \in \mathbb Q^c\end{cases},\qquad f(x)=\begin{cases} x-1, &x \in \mathbb Q\\ x, &x \in \mathbb Q^c \end{cases}.$$
Note that $f(x)=x-g(x)$. Assume that $f$ is integrable, since $h(x)=x$ is also integrable, we know that $g=h-f$ is integrable. But you have proved that $g$ is not integrable. This is a contradiction. Therefore, $f$ is not integrable.
We have used two properties of Riemannian integrals:

*

*Any continuous fucntion is Riemannian integrable. The proof uses the uniform continuity property of continuous fucntions defined on closed intervals, see this answer. Here we use this property to show the integrability of $h$. Indeed, for this $h$, the proof will be even simpler.


*Any linear combination of integrable functions is integrable.
Added. The $\epsilon-\delta$ strategy.
Notations. We use $\pi:0=x_0<x_1<\cdots<x_n=1$ to denote a partition of $[0,1]$, and use $\|\pi\|:=\max_{1\leq i\leq n}|x_i-x_{i-1}|$ to denote the mesh of $\pi$.
Lemma (Integrability of $h(x)=x$). We have
$$\lim_{\|\pi\|\to0}\sum_{i=1}^n \xi_i(x_i-x_{i-1})=\frac12,$$
where $\xi_i\in[x_{i-1},x_i]$ is chosen arbitrarily.
Proof of Lemma. Firstly, if $\xi_i$ is the mid-point of $[x_{i-1},x_i]$, i.e., $\eta_i=\frac{x_{i-1}+x_i}2$, then we get a telescoping sum
$$ \sum_{i=1}^n \eta_i(x_i-x_{i-1})=\sum_{i=1}^n \frac{x_{i-1}+x_i}2(x_i-x_{i-1})=\frac12.$$
On the other hand, for arbitrary $\xi_i$, we have
\begin{align*}
\left|\sum_{i=1}^n (\xi_i-\eta_i)(x_i-x_{i-1})\right|&\leq \sum_{i=1}^n |\xi_i-\eta_i|(x_i-x_{i-1})\\
&\leq \sum_{i=1}^n (x_i-x_{i-1})(x_i-x_{i-1})\\
&\leq \|\pi\|\sum_{i=1}^n (x_i-x_{i-1})=\|\pi\|\to0,
\end{align*}
as $\|\pi\|\to0$. Combining everything proves the lemma.
Now we prove the non-integrability of $f$. The proof is similar with the proof of the non-integrability of $g$. Recall that both rational numbers and irrational numbers are dense in every interval. For any partition $\pi$, we choose $\xi_i\in[x_{i-1},x_i]$ to be irrational numbers, then
$$\lim_{\|\pi\|\to0}\sum_{i=1}^n f(\xi_i)(x_i-x_{i-1})=\lim_{\|\pi\|\to0}\sum_{i=1}^n \xi_i(x_i-x_{i-1})=\frac12.$$
However, if we choose $\xi_i\in[x_{i-1},x_i]$ to be rational numbers, then
$$\lim_{\|\pi\|\to0}\sum_{i=1}^n f(\xi_i)(x_i-x_{i-1})=\lim_{\|\pi\|\to0}\sum_{i=1}^n (\xi_i-1)(x_i-x_{i-1})=\frac12-1=-\frac12.$$
Therefore, by definition, $f$ is not Riemannian integrable.
A: Let $\mathcal{P}_n=\{x_0,\dots,x_n\}$ be a partition of $[0,1]$, and notice that
$$M_i=\sup_{x\in[x_{i},x_{i-1}]}f(x)=x_{i},$$
$$m_i=\inf_{x\in[x_i,x_{i-1}]}f(x)=x_{i-1}-1$$
by the fact that each interval of positive length contains both rational and irrational numbers. This gives us that
$$U(f,\mathcal{P}_n)=\sum_{i=1}^n(x_i-x_{i-1})M_i=\sum_{i=1}^n(x_i-x_{i-1})x_i,$$
$$L(f,\mathcal{P}_n)=\sum_{i=1}^n(x_i-x_{i-1})m_i=\sum_{i=1}^n(x_i-x_{i-1})(x_{i-1}-1).$$
But notice that the upper sum is also the upper sum of the function $x\mapsto x$, and the lowe sum is also the lower sum of the sum the function $x\mapsto x-1$. As these functions are integrable (and hence their upper and lowe integrals equal their integrals), and as the partition was arbitrary, this means that
$$\overline{\int_0^1} f(x)~\mathrm{d}x=\int_0^1 x~\mathrm{d}x=\frac{1}{2}$$
and
$$\underline{\int_0^1} f(x)~\mathrm{d}x=\int_0^1 (x-1)~\mathrm{d}x=-\frac{1}{2}.$$
As the upper and lower integrals are not equal, it follows that $f$ is not Riemann integrable.
