Find $\mathcal{L}(f,P)$ and $\mathcal{U}(f,P)$ for an arbitrary partition $P$ of $[0,1]$, e.g. $0=x_0<x_1<\cdots<x_n=1$. ($\mathcal{L}(f,P)$ and $\mathcal{U}(f,P)$ are the lower and upper Riemann sums, respectively.)
$$f(x) = \begin{cases} x, & \text{if }x\in\mathbb{Q}\cap[0,1], \\ 1, & \text{if } x\in (\mathbb{R}\backslash\mathbb{Q})\cap[0,1] \end{cases}$$
It's formally clear that $\mathcal{U}(f,P)=1$ by the density of the irrationals in $\mathbb{R}$. And intuitively, it's clear that $\mathcal{L}(f,P)=\frac12$, but I'm don't really have an idea on how to justify that formally. Anyone got a trick?
Edit: I've managed to prove that $\mathcal{L}(f,P)\geq \frac12$ using the uniform partition: let $x_k=\frac{k}n$ for $k=0,\cdots,1$. Then $\mathcal{L}(f,P)$ for this partition is
$$\sum_{k=1}^n(x_k-x_{k-1})\inf_{[x_{k-1},x_k]}f(x)=\sum_{k=1}^n\frac1n\left(\frac{k-1}n\right)=\frac1{n^2}\frac{n^2 - n}{2}\to\frac12$$
when $n\to\infty$. However, how can I prove that $\mathcal{L}(f,P)$ is in fact equal to $\frac12$?
By definition: $$L(f,P)=\sum_{i=1}^n\inf_{x\in[x_{i-1},x_i]}\{f(x)\}(x_i-x_{i-1}).$$ Note that, on any sub-interval [a,b] of $[0,1]$, $\inf\limits_{x\in[a,b]}\{f(x)\}=a$, since $f(x)\geq x$, thus $a$ is a lower bound of $f$ and there exists a sequence of rationals $(q_n)$, such that $q_n\in[a,b]$ and $q_n\to a$. Thus, $$\inf_{x\in[x_{i-1},x_i]}\{f(x)\}=x_{i-1}.$$ Now, substituting, we get: $$L(f,P)=\sum_{i=1}^nx_{i-1}(x_i-x_{i-1})<\sum_{i=0}^n\frac{x_{i-1}+x_i}{2}(x_i-x_{i-1})=\frac{1}{2}\sum_{i=1}^nx_i^2-x_{i-1}^2=\frac{1}{2}(1-0)=\frac{1}{2}.$$ So, $L(f,P)$ is strictly below $\frac{1}{2}$.