Homeomorphism of the rationals In working with the classification of stable vector bundles on $\mathbb{P}^2$, I've found that I need to answer a fairly basic question from analysis/point set topology.  Here it is.
Suppose $f:\mathbb{Q}\to \mathbb{Q}$ is 


*

*strictly increasing,

*not bounded above or below,

*a local homeomorphism (with the topology induced from $\mathbb{R}$), and

*extends to a continuous map (hence a bijection) $f':\mathbb{R}\to \mathbb{R}$.


Is $f$ a homeomorphism?  (That is, is it surjective? Or, alternately, could there exist some irrational number $c$ such that $f(c)$ is rational?)
While I am dealing with a specific function, I state things in this generality because the function itself is fairly nasty and I'd rather not have to use its explicit definition more than I have to.  My guess is that it is probably too much to hope for that this be true in this generality, so in case the general version is false here is a refined version of property (3) which incorporates a bit more about my present situation:
3'. there exists a partition $\mathbb{Q}=\bigcup_{\alpha \in A} I_\alpha$ of $\mathbb{Q}$ into countably many disjoint open intervals with irrational endpoints, such that $f$ is linear (with rational coefficients) on each interval.
The difficulty (at least for me) is that, viewing the intervals as intervals in the real numbers, their complement forms some kind of Cantor set.  
Thanks!
(EDIT: Several counterexamples have shown the first formulation, with properties 1-4 are false.  I imagine the formulation with 3' instead of 3 is also false, but it seems slightly less trivial to get a counterexample due to the condition on the irrationality of the endpoints. In particular, no two intervals can "match up" at an irrational number unless $f$ has the same slope on both intervals.)
 A: I do not think that properties 1-4 guarantee that the function $f$ is even surjective.
It is well known that every countable dense linear order is isomorphic to $\mathbb{Q}$. Therefore there is an order isomorphism $f:\mathbb{Q}\rightarrow\mathbb{Q}\setminus\{0\}$. In particular, the mapping $f$ satisfies properties 1-4, but $f$ is not a homeomorphism since it is not surjective.
A: The function $f$ need not be a homeomorphism.
This is because the increasing affine function that maps $[r_1,r_2]$ to $[q_1,q_2]$ also maps $[r_1,r_2]\cap \mathbb Q$ to $[q_1,q_2] \cap \mathbb Q$ for any $r_1,r_2,q_1,q_2 \in \mathbb Q$. (Take $x \in \mathbb R \setminus \mathbb Q$ and consider a sequence $r_i \searrow x$ of rational points. Construct the function $f$ so that it maps $[r_i,r_{i-1}]$ affinely to $[2^{-i},2^{-i+1}]$ for all $i$. (Take a similar construction from below to $x$ and take your favorite extension for the rest of the rational points.) Now the continuous extension of $f$ to real numbers maps $x$ to $0$.)
A: Here is a sketch of how to construct a counterexample satisfying 3':
Fix an enumeration $\mathbb{Q}=\{q_n :n \in \mathbb{N}\}$ and let $g:\mathbb{R} \to \mathbb{R}$ be the function defined by $g(x)=\sqrt{x-\pi}$ for $x \geq \pi$ and $g(x)=-\sqrt{\pi-x}$ if $x<\pi$. It doesn´t really matter what $g$ is as long as it satisfies the following properties:
a) $g$ is a continuous increasing bijection and $g(\pi)=0$.
b) For any rational $q$ and any $\epsilon>0$, there are irrationals $l < q$ and $r > q$ such that $r-l < \epsilon$ and the affine function sending $[l,r]$ into $[g(l),g(r)]$ has rational coefficients.
c) $g$ is unbounded from above and from below.
Now one can define inductively a disjoint sequence of intervals $\{ [l_n,r_n]\}$ with irrational endpoints such that for each $n$ the affine function (lets call it $h_n$) sending $[l_n,r_n]$ into $[g(l_n),g(r_n)]$ has rational coefficients. At each step, make sure that $\pi \notin [l_n,r_n]$ and that $q_n \in (l_m,r_m)$ for some $m \leq n$.
The function $f: \mathbb{R} \to \mathbb{R}$ defined as $f(x)=h_n(x)$ if $x \in [l_n,r_n]$ and $f(x)=g(x)$ otherwise is continuous, increasing, unbounded and the function $f \upharpoonright \mathbb{Q}$ satisfies conditions 1,2,3' and 4. However $f(\pi)=0$.
A: Not a really complete answer, but look at the question mark fonction (see http://en.wikipedia.org/wiki/Minkowski%27s_question_mark_function) to a counter-example satisfying 1,2,3 and 4 : $?(\sqrt2)=7/5$, for instance.
A: First construct the Cantor set: An uncountable closed set whose complement is a dense open set containing all the rationals. There are a bunch of ways to do this.
Pull back the regular Cantor set along a homeomorphism $\mathbb R\to \mathbb R$ that sends all the rationals to the rationals not in the Cantor set, possible by the same logic as Joseph Van Name's answer.
Take a neighborhood of the rationals with arbitrarily small measure, say finite measure. The complement has positive, indeed infinite measure, and so is uncountable.
Start with an interval and keep subdividing it. Make sure that the open interval you remove in each subdivision is the one with the smallest $f(q)$ in that interval, where $f: \mathbb Q \to \mathbb N$ is a bijection.
The complement of this set is open, therefore a countable union of open intervals. Each interval has two boundary points. Choose some element of the Cantor set that is not a boundary point, and map it to some rational number. Note that it must be irrational since it is in the Cantor set. This will be our counterexample to surjectivity.
Order the open intervals. We build a function piece by piece by choosing its values on each open interval in order. For each interval, choose some linear function with rational coefficients on it that preserves monotonicity. To preserve continuity,  choose the function to be very close to failing to preserve monotonicty. The highest $y$ value should be very close to the next $y$ value we have already defined, and similarly for the lowest. This is possible because we have two degrees of freedom and two constraints, so we can choose arbitrarily good rational approximations. The gaps between undefined $y$ values go to $0$, so we can extend continuously and monotonically as the last step, just like the standard Cantor function.
If our open intervals are all bounded, we can ensure the function is unbounded with the same trick.
It is clear our function satisfies all the properties required, except the inverse image of some rational number is an irrational number.
