Continuous on rationals, discontinuous on irrationals

Let $f: R \rightarrow R$. Show that the set of points of continuity of
$f$ is a $G_{\delta}$ set. Explain why it follows from this that there
is no function that is continuous on the rationals and discontinuous
on the irrationals.

Solution:

I can prove the second part, although independently of the first.

In words:

No function can be continuous only on a countable dense set of $R$, such as $Q$. If the set, $X$, of continuity points were countable, then we could choose a nested sequence of intervals around points of $X$ where the variation in $f$ goes to 0, that eventually avoids all points of $X$. But the common point of the intervals would be a continuity point, contradiction.

How can I relate this to the first part?

Solutions Collecting From Web of "Continuous on rationals, discontinuous on irrationals"

When you look at the intersection of a sequence of set of reals where oscillation (which you call variation) of f goes to 0, all you can say is that this is a G-delta set containing all rationals. How do you know this set has an irrational number? The idea is to exploit the fact that rationals are countable to build a nested sequence of compact intervals whose intersection avoids all rationals. This argument is called the Baire category theorem.

You have to use the following:

Let X be a complete metric space and let E be a subset of X. If E and X\E are dense, then at most one of E and X\E is F-sigma.

Since the rationals are F-sigma, we have that the irrationals cannot be F-sigma. If there is a function that is continuous only on the rationals, then the rational are G-delta, which implies that the complement (the irrationals) are F-delta, which is a contradiction.