$f$ is defined on $[0,1]$ and $f(x) = 0$ for $x$ irrational and $f(x) = 1/q$ for $x = p/q$ in lowest terms, then $\int_0^1 f = 0$
I have found this Is Thomae's function Riemann integrable? and this $f(x)=1/q$ for $x=p/q$ is integrable but my proof is different, so I don't think this question is a duplicate.
My proof goes like this.
We already have that the lower integral is $0$, so it's enough to show that there exists partitions $P$ with $U(f,P) < \epsilon$ for any $\epsilon > 0$
For $t \in \mathbb{N}$ we consider the partition $$P_t = \bigg\{\bigg[\frac{i-1}{2^{2t}}, \frac{i}{2^{2t}}\bigg] \bigg| i \text{ is an integer between 1 and } 2^{2t}\bigg\}$$
What I'll do is to show that $U(f.P_t) < \frac{1}{t}$
If $M_i$ is the supremum of $f$ on the $ith$ interval, then either $M_i = f\bigg(\frac{i-1}{2^{2t}}\bigg)$ or $M_i = f\bigg(\frac{i}{2^{2t}}\bigg)$ because for any rational in that interval, expressed in lowest terms, $q > 2^{2t}$
Now we have the following:
$$ \sum_{i=1}^{2^{2t}} M_i = 1 + 2t$$ The proof is with induction.
For $t = 1$
$$ P_t = \{[0, 1/4], [1/4, 2/4], [2/4,3/4],[3/4,4/4] \}$$
Thus $ \sum_{i=1}^4 M_i = 1 + 1/2 + 1/2 +1 = 3 =1 +2t$
Suppose it holds for any $t$.
The partition $P_{t+1} = \bigg\{\bigg[\frac{i-1}{2^{2t + 2}}, \frac{i}{2^{2t+2}}\bigg] \bigg| j \text{ is an integer between 1 and } 2^{2t+2}\bigg\}$ is obtained in the following way.
For any interval $[\frac{i-1}{2^{2t}}, \frac{i}{2^{2t}}]$ of $P_t$, by multiplying by $4$ we get
$$\bigg[\frac{i-1}{2^{2t}}, \frac{i}{2^{2t}}\bigg] = \bigg[\frac{4(i-1)}{2^{2t+2}},\frac{4(i-1) + 1}{2^{2t+2}}\bigg] \bigcup \bigg[\frac{4(i-1)+1}{2^{2t+2}},\frac{4(i-1) + 2}{2^{2t+2}}\bigg] \bigcup \bigg[\frac{4(i-1)+2}{2^{2t+2}},\frac{4(i-1) + 3}{2^{2t+2}}\bigg] \bigcup \bigg[\frac{4(i-1)+3}{2^{2t+2}},\frac{4(i-1) + 4}{2^{2t+2}}\bigg] $$
$M_j'$ is the sup of $f$ on the $jth$ interval and without loss of generality, we'll assume that $M_i = f\bigg(\frac{1}{2^{2t}}\bigg)$
$$ \sum_{j = 4(i-1)}^{4i} M_j' = M_i + \frac{1}{2^{2t+1}} + \frac{1}{2^{2t+1}} + \frac{1}{2^{2t}} $$
The term $\frac{1}{2^{2t+1}}$ comes from the fact that if the numerator of one of the endpoint is even, then we can factor it out.
Therefore, the intervals of $P_{t+1}$ are between intervals of $P_t$ and we have
$$ \sum_{j = 1}^{2^{2t+2}} M_j' = \sum_{i = 1}^{2^{2t}} M_i + \frac{2}{2^{2t}} = \sum_{i = 1}^{2^{2t}} M_i + 2\sum_{i = 1}^{2^{2t}} \frac{1}{2^{2t}} = 1 + 2t + 2 = 1+ 2(t+1) $$
So the induction is closed.
Finally we get $$U(f,P_t) = \sum_{i=1}^{2^{2t}}\frac{M_i}{2^{2t}} = \frac{1}{2^{2t}} \sum_{i=1}^{2^{2t}} M_i = \frac{1+2t}{2^{2t}} < \frac{1}{t}$$
The last inequality can easily be proven with derivatives.
Is my proof correct?, is it possible to make it simpler? and if it's not, how can I fix it using this approach?