# $f: [0,1] \to \mathbb{R}$ absolutely continuous, $f' \in \{0,1\}$ (a.e.), $f(0)=0$. Prove that for some measurable subset $A$, $f(x)=m(A \cap (0,x))$

Problem: Suppose that $$f: [0,1] \to \mathbb{R}$$ is absolutely continuous, $$f' \in \{0,1\}$$ (a.e.) and $$f(0)=0$$. Prove that for some measurable subset $$A \subset [0,1]$$ and every $$x \in [0,1]$$ we have $$f(x)=m(A \cap (0,x))$$

I have proved it on my own. Please help me verify and tell me how much of the problem you think I have solved. (This was an exam problem and I'm trying to verify my given answer). I didn't have time to study derivatives for the real analysis exam and my argument might lack a bit of rigor, I think.

Edit: I'm going to write down my proof as an answer to mark this question solved.

Suppose that $$f: [0,1] \to \mathbb{R}$$ is absolutely continuous, $$f' \in \{0,1\}$$ (a.e.) and $$f(0)=0$$. Prove that for some measurable subset $$A \subset [0,1]$$ and every $$x \in [0,1]$$ we have $$f(x)=m(A \cap (0,x))$$

Since $$f$$ is absolutely continuous, we know that it comes from an indefinite integral like below:

$$f(x) = f(0) + \int_0^xf'$$

Set $$A = \{x\in [0,1] : f'(x) = 1\}$$, $$B = \{x\in [0,1] : f'(x) = 0\}$$ and $$C = (A\cup B)^c$$. By assumption, $$m(C)=0$$. Moreover, since $$f'$$ is a measurable function (being the limit of the measurable function $$\mathrm{Diff}_{1/n}(f)$$ when $$n$$ goes to infinity), $$A$$ and $$B$$ are measurable sets and $$C$$ is measurable because its measure is $$0$$ and we're working with Lebesgue measure.

Using the assumptions, we have:

$$f(x) = 0 + \int_0^x f' \times \mathbf{1}_A + \int_0^x f' \times \mathbf{1}_B + \int_0^x f' \times \mathbf{1}_C$$

But the two integrals on the right will vanish and we'll get

$$f(x) = \int_0^x1\times \mathbf{1}_A = m(A \cap(0,x))$$

Remark: $$\mathbf{1}_X$$ denotes the indicator function on the set $$X$$.