About the continuity of the function $f(x) = \sum\limits_k2^{-k}\mathbf 1_{q_k \leq x}$

Solution 1:

To prove 2), begin with the following facts:

  1. If the interval $(a,b]$ contains some $q_k$ for $1\le k\le n$, then $f(b)-f(a)\ge 2^{-n}$.

  2. 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:

  1. 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$.

  2. 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.