Let $q: \mathbb{N} \to \mathbb{Q}$ be a bijection and denote the image of $k \in \mathbb{N}$ by $q_k$.
Let $f: \mathbb{R} \to (0,1)$, $$ f(x) = \underset{q_k \leq x}{\sum_{k \in \mathbb{N}}} 2^{-k} $$
Show that:
1) $f$ is strictly increasing
2) $f$ is continuous at $x$ iff $x \in \mathbb{R} \setminus \mathbb{Q}$.
My work:
Let $x, y \in \mathbb{R}$, $x < y$. Then there exists $q_n \in \mathbb{Q}$ s.t. $x < q_n < y$. Now $$ f(x) = \underset{q_k \leq x}{\sum_{k \in \mathbb{N}}} 2^{-k} < \underset{q_k \leq x}{\sum_{k \in \mathbb{N}}} 2^{-k} + 2^{-n} \leq \underset{q_k \leq y}{\sum_{k \in \mathbb{N}}} 2^{-n} = f(y) $$ so $f$ is strictly increasing.
I think my proof of 1) is ok, but how can I prove 2)?
To prove 2), begin with the following facts:
If the interval $(a,b]$ contains some $q_k$ for $1\le k\le n$, then $f(b)-f(a)\ge 2^{-n}$.
If the interval $(a,b]$ does not contain $q_k$ for $1\le k\le n$, then $f(b)-f(a)\le 2^{-n}$
The proof of 1. amounts to observing that $f(b)-f(a)$ contains a term equal to $2^{-n}$. The proof of 2 is $$f(b)-f(a)\le \sum_{k>n}2^{-k} = 2^{-n}$$
To finish, connect the above to the following:
If $x=q_k$ for some $k$, then for every $\delta>0$, the $\delta$-neighborhood of $x$ contains points $a,b$ such that $a<q_k<b$.
If $x\notin \mathbb Q$, then for every $n$ there is $\delta>0$ such that the $\delta$-neighborhood of $x$ does not contains $q_1,\dots,q_n$. Consequently, $f(b)-f(a)\le 2^{-n}$ for any two points in this neighborhood.