The following is not a homework problem. I am doing it for self study.

Prove that any continuous function from $\mathbb{R}$ to $\mathbb{Q}$ is constant.

Here is my proof:

Let $f:\mathbb{R}\rightarrow \mathbb{Q}$ be such a function.

? We first show that $\mathbb{Q}$ is disconnected. Let $p$ be an irrational number. Then we can write $\mathbb{Q}$ as $$ \big( \mathbb{Q} \cap (-\infty,p) \big) \cup \big( \mathbb{Q} \cap (p,\infty) \big), $$ which is a disconnection of $\mathbb{Q}$.

Moreover, $\mathbb{Q}$ is also totally disconnected, as any open subset $U$ of $\mathbb{Q}$ must contain two rational numbers and there is always an irrational number between the two, and we can use that rational number to create a disconnection. Therefore the only connected subsets of $\mathbb{Q}$ are the singleton sets $\{q\}$, where $q \in \mathbb{Q}$, which are closed.

We will show that $f(\mathbb{R})$ must be connected. Assume not, then $$ f(\mathbb{R})= U\cup V, $$ where $U$ and $V$ are nonempty open subsets of $\mathbb{Q}$ such that $$ U \cap V= \emptyset .$$ This implies $$ \mathbb{R} = f^{-1} \big( U \cup V \big) = f^{-1}(U)\cup f^{-1}(V), $$ where $f^{-1}(U),f^{-1}(V)$ are nonempty, nonintersecting subsets of $\mathbb{R}$. This, however, is a contradiction, as $\mathbb{R}$ is connected. Therefore no such set $U$ and $V$ can exist.

As we have already shown, the only connected subsets of $\mathbb{Q}$ are the singleton sets $\{q\}$, so $f(\mathbb{R})$ must be such a set.

Something about this does not seem quite satisfactory, as if I am missing something. Could anyone tell me a flaw in my logic? Also, is there a more satisfactory way to prove this theorem?

  • 1
    $\begingroup$ The proof is fine. $\endgroup$ Feb 22 '12 at 14:49
  • 3
    $\begingroup$ It looks good to me. Note your proof can be used to show the more general fact that the image of a connected set under a continuous function is connected. For functions from $\mathbb{R}$ to $\mathbb{R}$, this is essentially the intermediate value theorem. $\endgroup$ Feb 22 '12 at 14:50
  • 1
    $\begingroup$ The only thing I'd change is that $U$ and $V$ need to be open subsets of $f(\mathbb R)$, not open subsets of $\mathbb Q$. The open subsets of $f(\mathbb R)$ are necessarily intersections of $f(\mathbb R)$ with open subsets of $\mathbb Q$, but the condition that they have empty intersection means that you want $U,V$ open in $\mathbb Q$ such that $f(\mathbb R)\subset U\cup V$ and $f(\mathbb R)\cap U\cap V=\emptyset$ $\endgroup$ Feb 22 '12 at 15:38
  • 2
    $\begingroup$ Alternatively, you could define $i:\mathbb Q\rightarrow \mathbb R$ to be the natural inclusion and then show that $i$ is continuous, and that therefore $i\circ f:\mathbb R\rightarrow \mathbb R$ is continuous. Then use the intermediate value theorem to show that if $i\circ f$ isn't constant, there must be an irrational value in its range, which is impossible since the range if $i\circ f$ is contained in the rationals in $\mathbb R$. $\endgroup$ Feb 22 '12 at 16:03
  • 1
    $\begingroup$ @Michael: There's no ambiguity really, though, it there? Is this a pet peeve of yours? $\endgroup$
    – TonyK
    Nov 21 '12 at 17:13

Your argument is correct. Perhaps what is unsatisfying is that you're actually making an argument which applies much more generally. You seem to be proving the following theorem:

Suppose $X,Y$ are topological spaces and $f:X\to Y$ is a continuous map. If $X$ is connected, then $f(X)$ is connected.

If you are comfortable simply quoting this, then you're done once you've shown that $\mathbb{Q}$ is totally disconnected and $\mathbb{R}$ is connected: the image of $\mathbb{R}$ under any continuous map must be connected and the only connected subspaces of $\mathbb{Q}$ are singletons, so the image of $\mathbb{R}$ under any continuous map is a singleton.

If not, simply modify your argument to prove the theorem I stated. Your proof is correct: a disconnecting pair of open sets in the range will pull back to a disconnecting pair of open sets in the domain, giving a contradiction. The only modification you need is removing reference to $\mathbb{R}$ and $\mathbb{Q}$ and replacing them with general topological spaces.


Suppose you know that

  • Every continuous function from $\mathbb{R}$ to $\mathbb{Q}$ is a continuous function from $\mathbb{R}$ to $\mathbb{R}$.
  • The intermediate value theorem holds.
  • The irrationals are dense in $\mathbb{R}$.

Then a nonconstant continuous function would have to pass through the irrational numbers between any two of its values.

So then I suppose I would ask which of the three bulleted points were already established and which to prove as lemmas.

Nobody should ever write "Prove that any continuous function from whatever to whatever is constant." That could be understood as "Pick any continuous function from whatever to whatever and prove that it's constant", but what is more likely intended is "Prove that every continuous function from whatever to whatever is constant." Merely changing "any" to "every" eliminates all ambiguity.


The topology on $\mathbb Q$ is the one induced on $\mathbb Q$ as a subset of $\mathbb R$. Thus, for every open set $U_{\mathbb R}$ of $\mathbb R$ the set $U_{\mathbb Q}=U_{\mathbb R}\cap \mathbb Q$ is open in $\mathbb Q$. If $f:\mathbb{R}\rightarrow \mathbb{Q}$ is continuous, the preimage $f^{-1}(U_{\mathbb Q})$ of every open set $U_{\mathbb Q}$ of $\mathbb Q$ is open in $\mathbb R$. But then we can consider $f$ as a function from $\mathbb R$ to $\mathbb R$, and by the above the preimage of every open set will still be open, so this is a continuous function from $\mathbb R$ to $\mathbb R$ that takes only rational values. Since there are irrational numbers between any two rational numbers, such a function must be constant by the intermediate value theorem.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.