Restriction on the injective, continuous image of $\mathbb{R}$ into $\mathbb{R}^2$. Given a injective, continuous function $f:\mathbb{R}\to\mathbb{R}^2$, it can be proved that the image $f(\mathbb{R})$ has empty interior; actually it can be proven a stronger version i.e. that $f(\mathbb{R})$ is a set of first category. I was thinking about this fact and I thought a couple of questions:

*

*In the same hypotesis, it is also true that $f(\mathbb{R})$ is a nowhere dense set?

*Does there exists such a function s.t. $\mathbb{Q}^2\subseteq f(\mathbb{R})$?

Clearly the two questions cannot have both an affermative answer, in fact each implies the negation of the other.
How can these questions can be approached?
 A: Suppose that $A\subset {\mathbb R}^2$ is a countable subset. Below a polygonal arc in the plane is the image of an injective piecewise-linear map $[0,1]\to {\mathbb R}^2$.
Here are the steps of the proof which I leave to you as exercises.

*

*Show that every polygonal arc in ${\mathbb R}^2$ does not separate ${\mathbb R}^2$, i.e. its complement is connected.


*Suppose that $L\subset {\mathbb R}^2$ is a polygonal arc and $p\in L$, $q\in {\mathbb R}^2\setminus L$. Show that $p, q$ can be connected by a polygonal arc in ${\mathbb R}^2$ that intersects $L$ only at $p$.


*Now, enumerate $A$, $A=\{a_n: n\in {\mathbb N}\}$. Set $A_n=\{a_1,...,a_n\}$. Inductively construct polygonal arcs $L_n\subset {\mathbb R}^2$ connecting points $p_n, q_n$ so that $A_n\subset L_n$ and $L_{n+1}$ is a concatenation of $L_n$ with a polygonal arc $L'_n$, such that $L_n\cap L'_{n}=\{p\}$ is $n$ is even and $L_n\cap L'_{n}=\{q\}$ if $n$ is odd.


*Conclude the existence of a piecewise-linear injective map ${\mathbb R}\to {\mathbb R}^2$ whose image contains $A$.
A: Moishe Kohan stated in his comment that if $A \subset \mathbb R^2$ is a countable subset, there is an injective continuous map $f:\mathbb R \to \mathbb R^2$ whose image contains $A$. We shall prove it.
Let us first observe that it suffices to show that for some $p \in A$ there exists an injective continuous map $f: [0,\infty) \to \mathbb R^2$ such that $f(0) = p$ and $A \subset f([0,\infty))$.  If we know this, we proceed as follows. Let $q \in \mathbb R^2 \setminus A$. Then $A' = A \cup \{q\}$ is countable and there is an injective continuous map $f': [0,\infty) \to \mathbb R^2$ such that $f'(0) = q$ and $A' \subset f'([0,\infty))$. Then $f' \mid_{(0,\infty)}$ is a continuous injection whose image contains $A$. Now take a homeomorphism $\phi : \mathbb R \to (0,\infty)$ and define $f = f' \mid_{(0,\infty)} \circ \phi$.
For any $M \subset \mathbb R$ we define $M^* = M \times \{0\} \subset \mathbb R^2$.
We need the following lemma:
Let $J  = [r,s]$ be a closed interval and $p, p' \in \mathbb R^2 \setminus J^*$. Then there exists a homeomorphism $h : \mathbb R^2 \to \mathbb R^2$ such that $h(q) = q$ for $q \in J^*$ and $h(p) = p'$.
For the proof we use the same arguments as in my answer to Is the $\Bbb{R}^2\setminus\{P_1,...,P_n\}$ plane homeomorphic to $\Bbb{R}^2\setminus\{Q_1,...,Q_n\}$?.

*

*For $a, b, b' \in \mathbb R$ and $l > 0$ let us define $$\psi^y_{a,b,b',l} : \mathbb R^2 \to \mathbb R^2, \psi^y_{a, b, b', l}(x,y) =  \begin{cases} (x,y) & \lvert x - a  \rvert \ge l \\ (x,y + \frac{(b' - b)(l - \lvert x - a \rvert) }{l}) & \lvert x - a  \rvert \le l \end{cases}$$
This is a well-defined continuous map which vertically shifts $(a,b)$ to $(a,b')$ and  keeps all points outside the open vertical strip $\lvert x - a \rvert < l$ fixed. It is a homeomorphism whose inverse is $\psi^y_{a,b',b,l}$ (since $\psi^y_{a,b,b',l} \circ \psi^y_{a,b',b,l} = id$ and $\psi^y_{a,b',b,l} \circ \psi^y_{a,b,b',l} = id$).


*A similar defnition yields a horizontal shift-homeomorphism $\psi^x_{a,a',b,l}$.  It shifts $(a,b)$ to $(a',b)$ and keeps all points outside the open horizontal strip $\lvert y - b \rvert < l$ fixed.


*Consider $p, p'$ as in the lemma. If $p$ lies on the $x$-axis $\mathbb R^*$, use a suitable vertical shift $\psi$ keeping $J^*$ fixed such that $\psi(p) \notin J^*$. If $p$ does not lie on the $x$-axis, we take the trivial vertical shift $\psi = id$. Do the same with $p'$ to find a vertical shift $\psi'$. Take two horizontal shifts $\varphi, \varphi'$ keeping $J^*$ fixed such that $\varphi(\psi(p))$ and $\varphi'(\psi'(p'))$ have the same $x$-coordinate. Finally let $\chi$ be a vertical shift  keeping $J^*$ fixed such that $\chi(\varphi(\psi(p))) = \varphi'(\psi'(p'))$. Then $h = (\psi')^{-1} \circ (\varphi')^{-1} \circ \chi \circ \varphi \circ \psi$ is the desired homeomorphism.
We now prove the above theorem. Our strategy is to construct (based on the above lemma) a sequence of homeomorphims $H_n : \mathbb R^2 \to  \mathbb R^2$ such that

*

*$H_{n+1} \mid_{[0,n]^*} = H_n \mid_{[0,n]^*}$


*$A_n = H_n([0,n]^*) \cap A$ exhausts $A$, i.e. $\bigcup A_n =  A$.
Note that $A_n \subset A_{n+1}$ by 1.
Given these $H_n$, we get continous injections
$$f_n : [0,n] \to \mathbb R^2, f_n(x) = H_n(x,0) .$$
These maps yield a continuous $f : [0,\infty) \to \mathbb R^2$ such that $f\mid_{[0,n]} = f_n$. It is injective: Consider $x_1, x_2 \in [0,\infty)$ such that $f(x_1) = f(x_2)$. We have $x_1, x_2 \in [0,n]$ for sufficiently large $n$, thus $f_n(x_1) = f(x_1) = f(x_2) = f_n(x_2)$ which implies $x_1 = x_2$. Moreover, we have $f([0,\infty)) = f(\bigcup_n ([0,n]) = \bigcup_n f([0,n]) = \bigcup_n f_n([0,n]) = \bigcup_n H_n([0,n]^*) = \bigcup_n A_n = A$.
It remains to construct the $H_n$. Write $A = \{p_0,p_1,p_2,\ldots \}$. We do not exclude the case that $A$ is finite, i.e. $A = \{p_0,p_1,p_2,\ldots p_N\}$ for some $N$.
We take $H_0$ to be the translation which maps  $(0,0)$ to $p_0$. Let $A_0 = \{p_0\}= H_0([0,0]^*) \cap A$ and $B_1 =  A \setminus A_0$. If $B_1$ is empty, we take $H_1 = H_0$. If it is nonempty, let $i_1$ be the minimal index such that $p_{i_1} \in B_1$. Clearly $i_1 = 2$. Take $h_1$ to be a homeomorphism which keeps $(0,0) = [0,0]^*$ fixed and maps $(1,0)$ to $p_{i_1}$. Let $H_1 = h_1 \circ H_0$. Let $A_1 = H_1([0,1]^*) \cap A$ and $B_2 = A \setminus A_1$. If $B_2$ is empty, we take $H_2 = H_1$. If it is nonempty, let $i_2$ be the minimal index such that $p_{i_2} \in B_2$. Clearly $i_2 > i_1 = 2$. Take $h_2$ to be a homeomorphism which keeps $[[0,1]]$ fixed and maps $(2,0)$ to $p_{i_2}$. Let $H_2 = h_2 \circ H_1$. Continue this process inductively: In the inductive step define the set $B_{n+1} = A \setminus A_n$. If it is empty, take $H_{n+1} = H_n$. Otherwise let $i_{n+1}$ be the minimal index such that $p_{i_{n+1}} \in B_{n+1}$ and let  $h_{n+1}$ be a homeomorphism keeping $[0,n]^*$ fixed and mapping $(0,n+1)$ to $p_{i_{n+1}}$. Take $H_{n+1} = h_{n+1} \circ H_n$ and $A_{n+1} = H_{n+1}([0,n+1]^*)$.
The process may "stop" at some $n$ (if $A_n = A$), in that case all $H_m = H_n$ for $m > n$. But if all $B_n$ are nonempty, then we get a strictly increasing sequence $(i_n)$ and by construction $\{p_0,\ldots,p_{i_n-1} \} \subset H_n([0,n]^*) = A_n$ which shows that the sequence $A_n$ is exhausting.
Intuitively, we use the $H_n$ to construct an injective path of a vacuum cleaner on a carpet, which is powdered by the points ("dust particles") of $A$, moving step by step from one point of $A$ to another point of $A$ and sucking away all points of $A$ it passes along this path. It may happen that after finitely many steps all (possible infinitely many!) points of $A$ have been sucked away, but in general we need infinitely many steps to do so.
