Do everywhere discontinuous functions like these one described exist?

These are the properties that such functions should (could?) have:

1) $$f(\mathbb R)=\mathbb R$$

2) $$f$$ is everywhere discontinuous

3) $$\mathbb Q \subseteq f( \mathbb I)$$

4) $$f(\mathbb Q) \subset \mathbb I$$

That is, such functions should (could?) have all these properties simultaneously: They map the whole $$\mathbb R$$ onto the whole $$\mathbb R$$, they are everywhere discontinuous, they map the set of all irrational numbers $$\mathbb I$$ into some set that contains all rationals, and they map the set of all rationals into some subset of the set of all irrationals.

Remark: This is not a homework, I am just eager into doing research of everywhere discontinuous functions.

Let $$g : \mathbb{I} \to \mathbb{R}$$ be onto (such a function exists because $$\mathbb{I}$$ and $$\mathbb{R}$$ have the same cardinality), and partition $$\mathbb{Q}$$ into two disjoint dense sets $$Q_1, Q_2$$. Then let $$f(x) = \begin{cases} g(x), & x \in \mathbb{I} \\ -\sqrt{2}, & x \in Q_1 \\ \sqrt{2}, & x \in Q_2.\end{cases}$$

• $Q_1$ and $Q_2$ should be "everywhere close to each other", right? – user720692 Nov 3 at 23:10
• @YamMir: Yes, that is accomplished by having them both be dense. For instance, you may take $Q_1$ to be the set of dyadic rationals $n/2^k$, and $Q_2 = \mathbb{Q} \setminus Q_1$. – Nate Eldredge Nov 3 at 23:11
• Do you know of some concrete constructed example of such $g$ which is from $\mathbb I$ onto $\mathbb R$? – user720692 Nov 3 at 23:15
• @YamMir: Pick your favorite countable set of irrationals, $A = \{a_1, a_2, \dots\}$, and enumerate the rationals as $\{q_1, q_2, \dots\}$. If $n$ is even, let $g(a_n) = a_{n/2}$. If $n$ is odd, let $g(a_n) = q_{(n+1)/2}$. If $x \in \mathbb{I} \setminus A$, let $g(x)=x$. – Nate Eldredge Nov 3 at 23:18

Sure.

$$f(x)=\begin{cases}x+\sqrt 2&\text{if }x=a+b\sqrt 2\text{ with }a\in\Bbb Q, b\in\Bbb Z\\x&\text{otherwise}\end{cases}$$

• But if $r$ is rational and not of the form $r=a+b\sqrt 2$ then $f(r)=r$ so $f(\mathbb Q) \cap \mathbb I \nsubseteq \mathbb I$, so $0$ is a problem? – user720692 Nov 3 at 22:21
• I think I misunderstood something, I will think about your example again. – user720692 Nov 3 at 22:28
• But all the irrationals which are not of the form $a+b\sqrt{2}$ are mapped into themselves, how can then $\mathbb Q \subseteq f( \mathbb I)$ be true? What do I miss? – user720692 Nov 3 at 22:31