Find an increasing function in $\mathbb{R}$ such that its set of discontinuity is $\mathbb{Q}$. Question: Find an increasing function in $\mathbb{R}$ such that its set of discontinuity is $\mathbb{Q}$.
Attempt: Suppose $(q_n)_{n \in \mathbb{N}}$ be an enumeration of the rationals, and define
$$f(x) := \sum_{k=1}^\infty 2^{-k} \chi_{(q_k, \infty)}(x).$$
Then the function is increasing by construction.
Now, I am stuck at showing that $f$ is discontinuous at $x \in \mathbb{Q}$.
In particular, I am having trouble showing that if for some $n \in \mathbb{N}$ such that $$x=q_n < y < \max_{q_i > q_n,i =1 \ldots, n} q_i\, ,$$ then we have
$f(x) + 2^{-n} \leq f(y)$.
Any help would be appreciated.
 A: Just look at the left-hand and right-hand limits. For any rational $x = q_k$, we have by construction $$\lim_{x \to q_k^-} f(x) = f(q_k)$$ but $$\lim_{x \to q_k^+} f(x) = f(q_k) + 2^{-k}.$$
A: Another old example is: (i) $f(0)=1.$ (ii) If $0\ne m\in \Bbb Z$ and $n\in \Bbb N$ with $\gcd(m,n)=1$ then $f(m/n)=1/n.$ (iii) If $x\in \Bbb R$ \ $\Bbb Q$ then $f(x)=0.$
For $n\in \Bbb N$ let $S(n)=\{m/d:m\in \Bbb Z \land n\ge d\in \Bbb N\}.$ If $b,c$ are distinct members of $S(n)$ then $|b-c|\ge 1/n^2$ so $S(n)$ is closed. So if $(y_j)_{j\in \Bbb N}$ is a sequence of rationals converging to $x\not \in \Bbb Q$ then for any $n\in \Bbb N$ the set $\{j: f(y_j)\ge 1/n\}$ is a subset of the $finite$ set $\{j: y_j\in S(n)\}$; Hence $\lim_{j\to\infty}f(y_j)=0=f(x).$
More generally, let $(X,d)$ be a  metric space. (i'). The set of discontinuities of any $f:X\to \Bbb R$ is an $F_{\sigma}$ subset of $X.$ (ii'). If $X$ has no isolated points and $Y$ is an $F_{\sigma}$ subset of $X$ then there is an $f:X\to [0,1]$ such that $f^{-1}(0,1]=Y$ and $Y$ is the set of discontinuities of $f.$
