Is there a Borel-measurable function which maps every interval onto $\mathbb R$? Using AC, one easily defines a function $F:\mathbb R\to \mathbb R$ such that the $F$-image of any real interval $(a,b)$ ($a<b$) is equal to $\mathbb R$. 
(Equivalently, the $F$-preimage of any real singleton has to be a dense set in $\mathbb R$.) Does there exist a Borel-measurable $F$ with this property?
 A: This is Exercise 9.M from A. C. M. van Rooij, W. H. Schikhof: A Second Course on Real Analysis.$\newcommand{\dcc}[1]{\lfloor#1\rfloor}$

Exercise 9.M. (Another function that maps every interval onto $[0,1]$) For $x\in[0,1]$ let
  $0.x_1x_2x_3\dots$ be the standard dyadic development of $x-\dcc x$:
  $$x_n=\dcc{2^n x}-2\dcc{2^{n-1}x}$$
  where $\dcc x$ is the entire part of $x$. Define $\phi\colon{\mathbb R}\to{\mathbb R}$ by
  $$\phi(x)=\limsup\limits_{n\to\infty}\frac{x_1+x_2+\dots+x_n}n$$
  Show that $\phi$ maps every interval onto $[0,1]$. (Hint: First show that $\phi(x)=\phi(y)$ if there exist $p,q\in\mathbb N$ such that
  $x_p=y_q$, $x_{p+1}=y_{q+1}$, $x_{p+2}=y_{q+2}$, etc., so that it suffices to show that $\phi$ maps $[0,1]$ onto $[0,1]$. Now let $t\in[0,1]$, $t\ne1$. Find an $x\in[0,1]$ such that $x_1+\dots+x_n=\dcc{nt}$ for every $n$ and prove that $\phi(x)=t$. Finally, find an $x$ with $\phi(x)=1$.)

The same function appears as Problem 1.3.29 in Kaczor, Nowak: Problems in Mathematical Analysis Vol II and it is given also in an answer here: Can we construct a function $f:\mathbb{R} \rightarrow \mathbb{R}$ such that it has intermediate value property and discontinuous everywhere?. The same function was also used by Andrés E. Caicedo as an example of a function which is of Baire class 2 but not of Baire class 1: Examples of Baire class 2 functions. (See also his blog post: 414/514 Examples of Baire class two functions)
As all functions $x_n$ are Borel measurable, so is the function $\phi$.
For this function, the image of a non-trivial interval is only the interval $[0,1]$. But we can get function which maps this onto reals by composition with some continuous Borel surjection from a unit interval to reals. 
A: Let $\{I_n:n\in\mathbb N\}$ be the set of all open intervals with rational endpoints. Construct pairwise disjoint sets $A_n$ $(n\in\mathbb N)$ such that each $A_n$ is homeomorphic to the Cantor set and $A_n\subseteq I_n$. For each $n\in\mathbb N$ define a continuous surjection $f_n:A_n\to[-n,n]$. Define $f:\mathbb R\to\mathbb R$ so that $f(x)=f_n(x)$ if $x\in A_n$ and $f(x)=x$ if $x\notin\bigcup_{n\in\mathbb N}A_n$. It's easy to see that $f$ is Borel measurable and maps every interval onto $\mathbb R$.
P.S. As Martin Sleziak pointed out in a comment the functions $f_n$ can be chosen to be at most two-to one, in which case $f^{-1}(x)$ will be a countable dense set for each $x\in\mathbb R$.
