$f^{-1}(c)$ is measurable for each $c.$ Is $f$ necessarily measurable? I am trying to answer the following question:

Suppose $f$ is a real-valued function on $\mathbb R$ such that $f^{-1}(c)$ is measurable for each $c.$ Is $f$ necessarily  measurable?

Here is the solution I found online:
"Let $E$ denote a non-measurable subset of $(0,1).$ We know such a set exists from Theorem $17$ of Chapter $2.$ Consider the function $f$ defined as
$$f(x) = e^x . (2 \chi_E - 1)$$ where $\chi_E$ is the characteristic function of the set $E.$ Then $\{x\in \mathbb R: f(x) > 0 \} = E$ is not a measurable set. However $f$ is one-to-one, so $f^{-1}(c)$ is either empty or a singleton set and therefore measurable."
My questions are:

*

*I am not sure what is the intuition behind the author defining $f(x)$ in terms of the the characteristic function of the non-measurable function $E$. And what is the relation between $c$ and the function given in the example. Any elaboration will be greatly appreciated!


*Also, is there a proof for that the Vitali characteristic function is a nonmeasurable function? or just it is because its domain is nonmeasurable?
 A: A function $f$ is measurable if for every measurable set $S$ of the codomain, $f^{-1}(S)$ is also measurable.
What that solution is doing is showing a counterexample to the claim in your question. The definition is poorly written. It should have been
$$f(x) = e^x(2\chi_E(x) - 1)$$
Another way of expressing it would be
$$f(x) = \begin{cases}e^x,&x \in E\\-e^x,&x \notin E\end{cases}$$
So this is just the exponential function with the points not in $E$ negated. The exponential function is one-to-one, as is its opposite. And since the images of those two functions do not overlap, $f$, which switches between the two based on membership in $E$, is one-to-one as well. The importance of this is that for any $c \in \Bbb R$, either $c$ is in the image of $f$, in which case $f^{-1}(c)$ will be a single point, or $c$ is not in the image of $f$, in which case $f^{-1}(c) = \emptyset$. Since both singleton sets and the empty set are measurable, this means that $f$ meets your condition that $f^{-1}(c)$ is measurable for all $c$.
But $(0,\infty)$ is also a measurable set. Yet $f^{-1}((0,\infty)) = E$, which is not measurable. This means $f$ is not a measurable function, contrary to the claim.

Why is $f$ defined this way? Well, we need to define a function which satisfies your property, but is not measurable. To show a function is not measurable requires a non-measurable set.
But while we can prove non-measurable sets must exist, that proof has to be indirect. We cannot explicitly build one. A non-measurable set has to be uncountable, so we cannot list its members. It also cannot be expressed as a sequence of basic set operations on simple sets - those are all measurable.
Not being able to explicitly build a non-measurable set means we also cannot explicitly build a non-measurable function. The build of the function would also provide a build for some non-measurable set.
So instead, they start with some arbitrary non-measurable set $E$. Given this non-constructible starting point, they can explicitly build the rest. What they need is a function which

*

*is one-to-one. This isn't required, but it is an easy way to meet the $f^{-1}(c)$ being always measurable condition. All countable sets are measurable, and if $f$ is one-to-one, then $f^{-1}(c)$ has either $0$ or $1$ element.

*separates the image of $E$ from the image of $\Bbb R \setminus E$. Again, this isn't necessary, but completely segregating the two images provides a simple way to have a measurable set whose inverse image under $f$ is the non-measurable set $E$.

And this is what they've done, as I described above.
