Function defined by a sum using rational numbers Let $\{r_n\}_{n=1}^\infty$ be enumeration of rational numbers, define $$f(x)=\sum_{\{ n \ / \ r_n<x \}} \frac{1}{2^n}$$
$(i)$ $f$ is continuous at irrational points
$(ii)$ $\lim_{x\rightarrow a^-} f(x) = f(a)$ $\qquad$  (left continuity)
$(iii)$ $\lim_{x\rightarrow a^+} f(x) = \sum_{\{ n \ / \ r_n \leq a \}} \frac{1}{2^n}$
$(iv)$ what is $\int_0^1 f$
Just managed to show that $f$ is discontinuous at rational points. I guess that some of the above points are similar to each other, just don't know how to deal with this kind of problems. Thank you.  
 A: Hints: 


*

*(ii) and (iii) together imply (i) and that $f$ is discontinuous at rational points. 

*(ii) and (iii) are similar: Think of the set $\{ r_n : r_n <a\}$ which defines $f(a)$. What is the "limit" of $\{r_n : r_n <a^-\}$ when $a^-\to a$ (from the left) and $\{r_n : r_n <a^+\}$ when $a^+\to a$ (from the right)?

*For (iv). Try to write $f$ as a (increasing) limit of $f_n$, where 
$$f_n(x) = \sum_{\{k\le n| r_k < x\}} \frac{1}{2^k}.$$
Calculate $\int_0^1 f_n(x) dx$ and then take $n\to \infty$. (Remark: we have that $f_n \to f$ uniformly, so $\lim_{n\to \infty} \int_0^1 f_n = \int_0^1 f$).
Further hints: I would say a bit more on how to tackle (ii) and (iii) as they are not that straight forward. 
Take (iii) as an example (similar for (ii)). We want to show 
$$ \lim_{x\to a^+} f(x) = \sum _{\{n| r_n \le a\}} \frac{1}{2^n}.$$
That $\ge $ is obvious from the definition of $f$. We want to show that $>$ is not possible. For the sake of contradiction, assume $>$ holds. Then 
$$f(x) >\delta + \sum _{\{n| r_n \le a\}} \frac{1}{2^n}$$
for all $x>a$ and for some $\delta >0$. But note that 
$$b_n :=\sum_{ k\ge n} \frac{1}{2^k} \to 0$$
as $n\to 0$, so there is $K$ so that 
$$\sum_{n=K}^\infty \frac{1}{2^n} <\delta.$$
So what can we say about $f(x)$ if $x$ is closed to $a$ so that $r_1, \cdots, r_K \notin (a, x)$?
A: Hint for (ii): For $x$ sufficiently close to $a$ (but $<a$) we can ensure that none of the first $N$ rationals appears in $[x,a)$. Hence $f(a)-f(x)$ can be bounded from above by $\sum_{n>N}2^{-n}$. 
This can be adapted for (iii).
