Determine whether $f(x) = x 1_{\mathbb{Q} \cap [0,1]}(x)$ is Riemann integrable The question is from Mathematical Analysis, Douglass pg.286 Exercise 18.

Define a function $f(x)$ on $[0, 1]$ such that $f(x)=x$ if $x$ is rational, and $f(x)=0$ if $x$ is irrational. Find $L(f)$ and $U(f)$, and determine whether $f$ is in $R[a, b]$.

My attempt:
For any partition $\pi=\{0=x_0, x_1, ...x_p=1\} \in \Pi[0, 1]$, there exists an irrational between every interval $[x_{j-1}, x_j]$, so the minimum of each interval would be $0$, so we could conclude that $L(f)=0$. $U(f)$ is the part that I am having some hard time with.
Take the same partition as above, but in this case, take such that each $x_i$'s are rational. Then, for each interval $[x_{j-1}, x_j]$, the supremum of $f$ in this interval would be the largest rational, which is $x_j$. Then,
$$U(f, \pi)=\sum_{j=1}^{p}M_j\Delta x_j=\sum_{j=1}^{p}x_j(x_j-x_{j-1})$$
At this stage, I struggled to get an inequality that would make me conclude that $L(f)\neq U(f)$, but I failed to do it. I saw that $U(f)=\frac{1}{2}$ from another article, and I'm not sure whether this specific partition would do me the job. I plugged in about 5 to 6 small partitions of $[0, 1]$ and it seems that it would do the job, but I'm not sure how to prove it. Can someone help me out with this proof?
 A: Given any partition $P$ with points $0=x_0< x_1 < \ldots < x_n = 1$ we have  $\sup_{x\in [x_{j-1},x_j]} f(x) = x_j$ for $j=1,2,\ldots, n$.  This holds whether the endpoints are rational or irrational, as a consequence of the density of the rationals.  Consequently, it follows that
$$U(f,P) = \sum_{j=1}^n x_j(x_j - x_{j-1})$$
As you observed, this is an upper Darboux sum for the function $x \mapsto x$ on $[0,1]$ and for any partition $P$ we have
$$U(f,P) \geqslant \inf_{P'} U(f,P') = \int_0^1 x \, dx = \frac{1}{2}$$
It is also not difficult to show that $U(f,P) > \frac{1}{2}$ directly. Note that $x_j > \frac{1}{2}(x_j + x_{j-1})$ and
$$U(f,P) = \sum_{j=1}^n x_j(x_j - x_{j-1})>  \sum_{j=1}^n \frac{1}{2}(x_j+x_{j-1})(x_j - x_{j-1})\\ = \frac{1}{2}\sum_{j=1}^n (x_j^2 - x_{j-1}^2) = \frac{1}{2}(x_n^2 - x_0^2)= \frac{1}{2} (1-0) = \frac{1}{2}$$
As you showed, $L(f,P) = 0$ for any partition. Since $U(f,P - L(f,P) > \frac{1}{2}$ it follows that $f$ is not Riemann integrable.
A: Let $P$ be a partition of $[0,1].$ Then
$$U(f,P)\ge U(f,P\cup \{1/2\})$$ $$\ge U(f,(P\cup \{1/2\})\cap [1/2,1]))\ge \frac{1}{2}\cdot \frac{1}{2} =\frac{1}{4}.$$
This is true for any partition $P.$ Thus $U(f)\ge 1/4 >0 = L(f).$
