# Writing $\mathbb{R}$ as a countable union of nowhere dense sets.

I am trying to answer this question:

Let $$f$$ be a real-valued function on a metric space $$X.$$ Show that the set of points at which $$f$$ is continuous is the intersection of a countable collection of open sets. Conclude that there is no real-valued function on $$\mathbb{R}$$ that is continuous at the rational numbers only.

Here is my answer for the first part:

For $$n\in\mathbb{N}$$, consider the sets $$U_n:=\{x\in X:\exists\delta>0,\forall y,z \in X, \, y,z\in B(x,\delta)\implies |f(y) - f(z)|<1/n\}.$$

I managed to prove that those $$U_{n}$$ are open and that the set of continuities of $$f$$ is a $$G_{\delta}$$ set and that $$U_{n}$$ is dense. Now following the sequence of steps required to complete the solution of the problem regarding to the second part as suggested here

Prove that there doesn't exist any function $f:\mathbb R\to \mathbb R$ that is continuous only at the rational points.

I have to do the following: for $$f:\mathbb R\to \mathbb R$$

1. Suppose $$f$$ is continuous at the rationals. Show $$U_n$$ is also dense. Hence, $$U_n^c$$ is closed and nowhere dense.

2. Using the previous statement and the fact that the rationals are countable, write $$\mathbb{R}$$ as a countable union of nowhere dense sets, contradicting the Baire category theorem.

Taking complements can be used to restate the Baire category theorem in the following equivalent way: a countable intersection of dense open subsets of $$\mathbb{R}$$ is dense. \

My question is:

I know that $$\mathbb{Q}$$ is in $$U_{n}$$ (not in $$U_n^c$$ which are nowhere dense sets) how this can lead me to write $$\mathbb{R}$$ as a countable union of nowhere dense sets.

As explained in the answer you linked, the set of points at which $$f$$ is continuous (i.e. $$\mathbb{Q}$$) is the intersection of all the $$U_n$$. Thus: \begin{align*}\mathbb {Q}&=\bigcap_{n\in\mathbb{N}} U_n\\ \mathbb{R}-\mathbb{Q}&=\bigcup_{n\in\mathbb{N}} U_n^c\\ \mathbb{R}&=\bigcup_{n\in\mathbb{N}} U_n^c\bigcup_{q\in\mathbb{Q}}\{q\}\end{align*}
Since $$\mathbb{Q}$$ is countable and $$\{q\}$$ is nowhere dense we obtain $$\mathbb{R}$$ as a countable union of nowhere dense sets
• Sorry for this question if it is not so much related, but I proved this : \textbf{Showing that Show $U_n$ is also dense.}\\ Since by $\textbf{Second.}$ (the proof that $f$ is continuous at every $x \in X$) with $X = \mathbb{R}$, we know that upon fixing $n,$ that every point of continuity of $f$ belongs to $U_n$ and since $f$ is assumed to be continuous at all rational points, then $U_n$ contains $\mathbb Q$. And since $\mathbb{Q}$ is dense in $\mathbb{R}$(by Advanced Calculus), hence $U_n$ is dense in $\mathbb{R}.$ \\
• … and seems to me when I saw your prove that my proof is incorrect …. is $U_n$ is the dense set or the intersection of the $U_n$?