# Continuous function that take irrationals to rationals and vice-versa. [duplicate]

Can someone help me?

How can I prove that there isn't an everywhere continuous function $f:\mathbb R \rightarrow \mathbb R$ that transforms every rational into an irrational and vice-versa?

-

## marked as duplicate by Pedro Tamaroff♦, Asaf Karagila, Amzoti, Micah, user17762 Apr 21 '13 at 2:22

Let $\mathbb{I} = \mathbb{R}\backslash\mathbb{Q}$ and suppose $f(\mathbb{I})\subseteq\mathbb{Q}$. $f(\mathbb{R}) = f(\mathbb{Q})\cup f(\mathbb{I})\subseteq f(\mathbb{Q})\cup\mathbb{Q}$, which is countable. Since $f$ is continuous, $f(\mathbb{R})$ is connected. Thus, $f(\mathbb{R})$ is countable and connected, hence it is a singleton $\{x\}$ and $f$ is constant.

Clearly, no constant function fulfils the conditions you require, hence there is no continuous $f$ such that $f(\mathbb{I})\subseteq\mathbb{Q}$ and $f(\mathbb{Q})\subseteq\mathbb{I}$.

-

Since there are only countably many rational numbers, such a function would map the rationals into a countable set $S$ of irrationals. So it would map all real numbers into $S\cup\mathbb Q$ (mapping the rationals into $S$ and the irrationals into $Q$). On the other hand, being continuous, your function would have to map the reals (a connected set) onto a connected set. But the only countable connected sets of reals are the singletons. So your function would have to be constant, which contradicts the requirement that it map rationals to irrationals and vice versa.

-

Since $\mathbb{R}=\cup_{q\in\mathbb{Q}}f^{-1}(\mathbb{q})\bigcup\cup_{q\in\mathbb{Q}}\{q\}$ and $\mathbb{Q}$ is countable then Baire categoty theorem says that for some $q\in\mathbb{Q}$ we have that $f^{-1}(q)$ has non-empty interior. Then there exists some non-empty interval $I$ such that $f$ is constant. Absurd

-