# Right continuous function that is continuous over rationals

Let's assume that $f: \mathbb{R} \rightarrow \mathbb{R}$ is a right continuous function that is continuous on rational points. It is clear that f need not to be continuous. In fact it fails to be RCLL. Now I'm wondering if f is continuous almost everywhere with respect to the Lebesgue measure. I'm guessing the answer is "no" but I can't find a counterexample. Could anyone help comment on this? Thanks!

-
For those who don’t know, RCLL is right continuous with left limits. – Brian M. Scott Aug 23 '12 at 18:24
In fact, I claim $f$ is continuous except at countably many points. – GEdgar Aug 23 '12 at 18:28
@GEdgar Could you explain the reason? – user7762 Aug 23 '12 at 20:19
Francophones may know of RCLL functions better as càdlàg functions – kahen Aug 23 '12 at 20:32

Let $D$ be the set of points of discontinuity of $f$, and let $\mathscr{I}$ be the set of open intervals with rational endpoints. For each $x\in D$ there is an $I_x\in\mathscr{I}$ such that $f(x)\in I_x$ and there is a sequence $\langle y_x(n):n\in\Bbb N\rangle$ converging to $x$ such that $f\big(y_x(n)\big)\notin I_x$ for each $n\in\Bbb N$. If $D$ is uncountable, there are an uncountable $D_0\subseteq D$ and an $I\in\mathscr{I}$ such that $I_x=I$ for each $x\in D_0$.
Suppose that for each $x\in D_0$ there is a rational $q_x>x$ such that $(x,q_x)\cap D_0=\varnothing$. Clearly this implies that $q_x\le y$ whenever $x,y\in D_0$ with $x<y$ and hence that $(x,q_x)\cap(y,q_y)=\varnothing$. But then $\{(x,q_x):x\in D_0\}$ is an uncountable family of pairwise disjoint open intervals in $\Bbb R$, which is impossible. Thus, we may choose $x\in D_0$ such that $(x,y)\cap D_0\ne\varnothing$ for every $y>x$.
For each $n\in\Bbb N$ fix $x_n\in(x,x+2^{-n})\cap D_0$. Since $x_n\in D_0$, there is a sequence $\langle y_{x_n}(k):k\in\Bbb N\rangle$ converging to $x_n$ such that $f\big(y_{x_n}(k)\big)\notin I$ for each $k\in\Bbb N$. In particular, there must be a point $y_n\in(x,x+2^{-n})$ such that $f(y_n)\notin I$. But then $\langle y_n:n\in\Bbb N\rangle$ converges to $x$ from the right, so $f(x)\notin I$, which is a contradiction. Thus, $D$ must be countable and hence of Lebesgue measure $0$.