Lebesgue measure-preserving differentiable function Let $\lambda$ denote Lebesgue measure and let $f: [0,1] \rightarrow [0,1]$ be a differentiable function such that for every Lebesgue measurable set $A \subset [0,1]$ one has $\lambda(f^{-1}(A)) = \lambda (A)$. Prove that either $f(x) = x$ or $f(x) = 1- x$. 
I will appreciate a hint or a solution that doesn't use ergodic theory as this is an old qual problem in measure theory. $f$ is bounded and continuous and so it is integrable and hence the hypothesis of Lebesgue's Differentiation Theorem are satisfied, but I haven't seen a way to use this or if it is even applicable. 
 A: First note $f$ is onto: Otherwise the range of $f$ is a proper subinterval $[a,b],$ which implies $\lambda(f^{-1}([a,b])) = \lambda([0,1]) = 1 > b-a = \lambda([a,b]),$ contradiction.
Suppose $f'(x) = 0$ for some $x\in [0,1].$ Then $f(B(x,r))\subset B(f(x),r/4)$ for small $r>0.$ ($B(y,r)$ denotes the open ball with center $y$ and radius $r$ relative to $[0,1].$) Thus for such $r,$ $f^{-1}(B(f(x),r/4))$ contains $B(x,r).$ But $B(f(x),r/4)$ has measure no more than $2\cdot (r/4) = r/2,$ while $B(x,r)$ has measure at least $r.$ That's a contradiction. Hence $f'(x) \ne 0$ for all $x\in [0,1].$
By Darboux, $f'>0$ on $[0,1]$ or $f'<0$ on $[0,1].$  Let's assume the first case holds. Then $f$ is strictly increasing, hence a bijection on $[0,1].$ Thus if $A$ is an interval, $\lambda(A) = \lambda(f^{-1}(f(A)))= \lambda(f(A)).$ Since $f(0) = 0,$ this gives $x = \lambda([0,x]) = \lambda(f([0,x])) = f(x) - f(0) = f(x)$ for all $x\in [0,1].$ 
A: The following argument should work under the additional assumption that $f'$ is integrable. I don't know if this is something that you need to assume or if it is a limitation of my proof. It is worth mentioning that I need integrability of the derivative for two reasons: first to apply Lebesgue differentiation theorem for $f'$, and second to get that $f$ is absolutely continuous, which I need to apply the Fundamental Theorem of Calculus.

Let $\mu(\cdot) = \lambda(f^{-1}(\cdot))$. Then $\mu = \lambda$ and hence for a.e. $x \in (0,1)$ we have 
$$1 = \frac{d\lambda}{d\mu}(x) = \lim_{r \to 0}\frac{\lambda(B_r(x))}{\mu(B_r(x))} = \lim_{r \to 0}\frac{\int_{B_r(x)}d\lambda}{\mu(B_r(x))} = \lim_{r \to 0}\frac{1}{\lambda(f^{-1}(B_r(x)))}\int_{f^{-1}(B_r(x))}|f'|d\lambda,
$$ where in the last equality we used the change of coordinates $z = f(y)$. Notice that $\lambda(f^{-1}(B_r(x))) = \lambda(B_r(x)) \to 0$, hence by Lebesgue differentiation theorem, for every $y \in f^{-1}(x)$ we have that $|f'(y)| = 1.$ Moreover we have that for $y \in (0,1)$, $y \in f^{-1}(f(y))$, thus proving that $|f'| = 1$ a.e. in $[0,1]$.
To conclude the argument, we only need to show that $f'$ cannot change sign. Indeed, by the FTC, we would have that $$f(1) = f(0) + \int_0^1f'(y) = f(0) \pm 1,$$ showing that either $f(0) = 0$ and $f' = 1$ or $f(0) = 1$ and $f' = -1$.
To prove that the derivative is constant a.e., I'll show that $f$ is surjective. By continuity, $f([0,1])$ is a compact subset of $[0,1]$. Suppose by contradiction that $f$ is not surjective, then $\lambda(f[0,1]) < 1$. To find a contradiction it is enough to notice that $$1 = \lambda([0,1]) = \lambda(f^{-1}(f([0,1]))) = \lambda(f([0,1])) < 1.$$

In response to Ramiro's comment: Everywhere differentiable + integrable derivative implies absolute continuity, i.e. the FTC holds. Then I can prove what you asked as follows.
Necessarily, $f(0)$ is either $0$ or $1$. To see this notice that if there is $x \in (0,1)$ such that $f(x) \in \{0,1\}$ then let $y$ be the point such that $f(y) = \{0,1\} \setminus \{f(x)\}$. Assume without loss that $x< y$, then $$1 = |f(x) - f(y)| \le \int_x^y|f'| = y - x < 1.$$ Then assume without loss that $f(0) = 0$. Reasoning as above shows that $f(1) = 1$. Again by the FTC, $$1 = f(1) - f(0) = \int_0^1f' = \lambda(\{f' = 1\}) - \lambda(\{f' = -1\}).$$ Finally, if $\lambda(\{f' = -1\}) > 0$ we get a contradiction, hence $f' = 1$ a.e.
