Real function such that preimage of every constant is measurable Let $f:\mathbb R \to \mathbb R$ such that for each $c \in \mathbb R$, the set $\{x \in \mathbb R:f(x)=c\}$ is measurable (Lebesgue measurable), is $f$ measurable?
I've came up with a solution and I would like to know if it is correct, anyone is welcome to post a nicer, shorter or just different answer.
Let $V \subset [0,1]$ be the Vitali set. I define the function $f:\mathbb R \to \mathbb R$ as $$f(x) := \begin{cases} x, & \text{if}\ x\in V,\\\\ x-2, & \text{if} \space x \in [0,1] \setminus V, \\\\ -10 &\text{else}   \end{cases}$$
For $c \in V$, $f^{-1}(\{c\})=\{c\}$, if $c \in [-2,-1]$, then $f^{-1}(\{c\})=\{c+2\}$, $f^{-1}(\{-10\})=\mathbb R \setminus [0,1]$ and for all other $c$ we have $f^{-1}(\{c\})=\emptyset$. For each $c$, we have that the preimage is a measurable set.
Now, $\{f>-\dfrac{1}{2}\}=V$, which is not measurable, so $f$ can't be measurable. In conclusion, in general, the hypothesis given does not imply that the function is measurable.
Any corrections are greatly appreciated.
 A: Let $V$ be any nonmeasurable set and define
$$f(x)=\begin{cases}
\ \ e^x\ \ \text{ if }\ x\notin V,\\
-e^x\ \text{ if }\ x\in V.
\end{cases}$$
Then $\{x:f(x)=c\}$ is measurable since it has at most one element, while $f$ is not measurable since $\{x:f(x)\lt0\}=V.$
A: For another example, let $B$ be a Hamel basis of $\mathbb R$ over the rationals $\mathbb Q$.  Each real number $x$ can be written uniquely as
$x = \sum_{b \in B} c_b(x) b$ where  $c_b(x)$ are rational numbers and
for each $x$, only finitely many $c_b(x)$ are nonzero.  Pick out one 
element $b_0 \in B$, and let $f(x) = x - c_{b_0}(x) b_0 = \sum_{b \ne b_0} c_b(x) b$.
For each $y$, $f^{-1}(y) =  y + \mathbb Q b_0$ is countable, and therefore 
measurable. 
Now why is $f$ non-measurable?  Note that $c_b(x+y) = c_b(x) + c_b(y)$ for all $x, y \in \mathbb R$, $b \in B$, so that $f(x+y) = f(x) + f(y)$, i.e. $f$ is additive.  It is a nice exercise in Lebesgue's density theorem to show that any measurable additive function is linear (i.e. $f(x) = c x$ for some $c \in \mathbb R$), and it's easy to see that our $f$ is not of that form.
