TITLE: composition of Lebesgue measurable functions is not Lebesgue mesurable
QUESTION [6 upvotes]: Let $f,g:\mathbb{R}\longrightarrow \mathbb{R}$ be Lebesgue measurable. If $f$ is Borel measurable, then $f\circ g$ is Lebesgue mesuarable. In general, $f\circ g$ is not necessarily Lebesgue measurable. Is there any counterexample?

REPLY [5 votes]: Let $g:\mathbb R\to \mathbb R$ be any Borel function with the following property: there exists a Lebesgue-measurable set $B$ such that $g^{-1}(B)$ is not Lebesgue-measurable. Such functions do exist (see below).
Now take $f:=\mathbf 1_{B}$. Then $f$ is Lebesgue-measurable because $B$ is, but $f\circ g=\mathbf 1_{g^{-1}(B)}$ is not Lebesgue-measurable.
Existence of the function $g$. Take any one-to-one Borel function $g:\mathbb R\to\mathbb R$such that $g^{-1}(C)$ does not have measure $0$, where $C$ is the usual Cantor ternary set. There exist even continuous functions with this property (see e.g. the link given by FisiaiLusia). If you don't require continuity, just take a one-to-one Borel function $g_0$ such that $g_0(\mathbb R) =C$. Let us show that $g$ has the required property.
Since $g^{-1}(C)$ does not have measure $0$, it contains a set $A$ which is not Lebesgue-measurable. (If you take $g=g_0$, you just need to know that there exists at least one non-measurable set in $\mathbb R$). Set $B:=g(A)$. Then $B$ is Lebesgue-measurable because it is contained in the measure $0$ set $C$; and $A=g^{-1}(B)$ because $g$ is one-to-one. So $g^{-1}(B)$ is indeed non-measurable.