# No function continuous at rational points and discontinuous at irrational points in $[0,1]$

Let $$C_f$$ and $$D_f$$ mean sets where a function is continuous and discontinuous. I’m trying to prove there is no function $$f:[0,1] \to \mathbb{R}$$ such that $$C_f = [0,1] \cap \mathbb{Q}$$ and $$D_f = [0,1] \setminus \mathbb{Q}$$.

I have seen a proof using the Baire category theorem that there cannot be two functions $$f$$ and $$g$$ where $$C_f$$ and $$C_g$$ are both dense and $$C_f = D_g$$. Thomae’s function is continuous at the irrationals and discontinuous at the rationals, so it is impossible to have a function that is discontinuous on irrationals and continuous on rationals. The proof uses a lemma that if $$C_f$$ is dense then $$D_f$$ is first category, and some of the steps are not clear to me.

Is there a more elementary proof that there is no function discontinuous on irrationals and continuous on rationals?

The set of points of continuity of a function $$f$$ is a $$G_\delta$$ (i.e. the intersection of a sequence of open sets), because it can be written as

$$\bigcap_{n \in \mathbb N} \bigcup_{\delta > 0} \{x: \text{diam}(f((x-\delta,x+\delta)))<1/n\}$$ and $$\bigcup_{\delta>0} \{x: \text{diam}(f((x-\delta,x+\delta))<1/n\}$$ is open.

$$[0,1] \cap \mathbb Q$$ is not a $$G_\delta$$ by the Baire Category Theorem. But you can prove this in an elementary way. Suppose $$G = \bigcap_{n=1}^\infty U_n$$ is a $$G_\delta$$ in $$[0,1]$$ that contains all rationals in that interval. Let $$r_n$$ be an enumeration of those rationals. You can construct inductively a nested sequence of closed intervals $$[a_n, b_n]$$ such that $$[a_n, b_n] \subset U_n$$ and does not contain $$r_n$$. Then the intersection of these intervals is a nonempty subset of $$G$$ that contains no rationals.

The set of discontinuities of any real function must be the countable union of closed sets. Since the Irrationals are not a countable union of closed sets, this is not possible.

You can, of course, have the reverse case (as you mentioned): where a function is continuous at the irrationals, and discontinuous at the rationals. This is because Q is a countable collection of closed (single point) sets.

I think I have even seen the construction of a function f such that, given any countable collection of closed sets in R, f is discontinuous on exactly that collection, and continuous everywhere else.

As for a "simpler" proof, I am not sure you can do much better than relying on the Baire Category Theorem (or one of its equivalents) somewhere along the way. This, of course, depends also on your definition of "simple". But if there is one out there (even if restricted to real functions only), and that is more intuitive to an undergraduate, I would be interested in seeing it posted here as well.