TITLE: Functions $\mathbb{R}^2\to\mathbb{R}^2$ that preserve lines
QUESTION [6 upvotes]: The simplest case of the Fundamental Theorem of Projective Geometry states that, if $f: \mathbb{R}^2\to\mathbb{R}^2$ is a bijection that preserves lines – in the sense that if $L\subseteq\mathbb{R}^2$ is a line then so is $f[L]$ – then $f$ is an affine transformation. [1]
The condition that $f$ be a bijection is stronger than necessary, and it is sufficient to ask for $f$ to be injective. (Proof: let $L_1$ and $L_2$ be two parallel lines in $\mathbb{R}^2$; then $f[L_1]$ and $f[L_2]$ are also parallel lines: they are lines since $f$ preserves lines, and parallel since $f$ is injective. Take any point $p\in\mathbb{R}^2$, and take a line $L$ through $p$ not parallel to $f[L_1]$ and $f[L_2]$. This line intersects $f[L_1]$ in some point, say $f(p_1)$, and it intersects $f[L_2]$ in some point, say $f(p_2)$. The image under $f$ of the line through $p_1$ and $p_2$ must be the line through $f(p_1)$ and $f(p_2)$, which contains $p$, and therefore $p$ is in the image of $f$.)
My question is: can the condition be weakened further? For example, if we assume only that $f: \mathbb{R}^2\to\mathbb{R}^2$ preserves lines, must $f$ be an affine transformation?

Added later: Thanks to @Wojowu in the comments for explaining how to construct a function $\mathbb{R}^2\to\mathbb{R}$ that maps every line to the whole of $\mathbb{R}$, which answers the second question I asked.
So: what if we also insist that there be three non-collinear points in the image of $f$? It follows that there must be two distinct lines in the image of $f$, and then the argument above (more or less) shows that $f$ is surjective. But must it be injective?

[1] For a proof of the general case see e.g. Andrew Putman, The fundamental theorem of projective
geometry.

REPLY [3 votes]: Let $f : \mathbb{R}^2 \rightarrow \mathbb{R}^2$ be a function that maps lines to lines, and suppose that there are three non-collinear points in the image of $f$.
Lemma 1: If $f[\ell_1]$ and $f[\ell_2]$ are distinct parallel lines, then $\ell_1$ and $\ell_2$ are distinct parallel lines.
Proof: Suppose otherwise. Then $\ell_1$ and $\ell_2$ intersect at a point $x$, and $f(x)$ must lie on both $f[\ell_1]$ and $f[\ell_2]$; this is clearly impossible since the lines are parallel.
Lemma 2: Let $a, b, c, d \in \mathbb{R}^2$ be four points such that $f(a), f(b), f(c), f(d)$ form the vertices of a non-degenerate parallelogram (in that order). Then $a, b, c, d$ also form the vertices of a non-degenerate parallelogram in the same order, so in particular $a + c = b + d$.
Proof: Apply Lemma 1 twice, once to each pair of opposite edges.
Lemma 3: If four points in the image of $f$ form the vertices of a non-degenerate parallelogram, then they each have one preimage under $f$.
Proof: Suppose otherwise. Then there are two points $a, a' \in \mathbb{R}^2$ with $f(a) = f(a')$; let $f(b), f(c), f(d)$ be the other three vertices of a non-degenerate parallelogram (in that order). Then we have $a + d = b + c$ and $a' + d = b + c$ by applying Lemma 2, whence it follows that $a = a'$.
Lemma 4: $f$ is surjective.
Proof: Let $x,y,z$ be three points such that $f(x), f(y), f(z)$ are non-collinear points. It follows that $x,y,z$ are also non-collinear. The line through $x,y$ maps to the line through $f(x),f(y)$. Given any point $P$ in the plane of $f(x), f(y), f(z)$, we can take the line through $f(z)$ and $P$ and let it intersect the line through $f(x)$ and $f(y)$ at a point $Q$, which is in the image of $f$ and is therefore $f(w)$ for some point $w$. The line through $w$ and $z$ maps to the line through $f(z)$ and $f(w)$, which contains $P$, so $P$ is indeed in the image of $f$.
Lemma 5: $f$ is injective.
Proof: Since $f$ is surjective by Lemma 4, every point $f(a)$ in the image of $f$ is the vertex of a non-degenerate parallelogram with its other three vertices in the image of $f$. By Lemma 3, there cannot be a point $a' \ne a$ with $f(a) = f(a')$. The result follows.
Corollary: $f$ is a bijection, so is an affine transformation by the claim at the beginning of the OP.
Can we weaken the condition even further? In particular, if we weaken 'maps lines to lines' to 'preserves collinearity' (the difference being that a line can map to a proper subset of a line), then does the result still hold? Lemma 2 holds (and so does Lemma 3), so the difficult part is proving surjectivity.