Given any set $E\subseteq [0,1]$, does there exists any differentiable function $g$ such that $g'(x)=\mathbb{1}_{E}(x)$ for all $x\in [0,1]?$ ($\mathbb{1}_{E}$ is the indicator function of $E$)
I do not know how to answer this in general but this is what I did.
If $E$ is not Lebesgue measurable, then such function does not exist. Indeed, we know that $\mathbb{1}_E$ is a Lebesgue-measurable function if and only if $E$ is a Lebesgue-measurable set. Now, since $g'(x)=\lim\limits_{n\to\infty}\dfrac{g(x+1/n)-g(x)}{1/n}$ is measurable, as a limit of a sequence of measurable functions, we cannot have $g'(x)=\mathbb{1}_E(x)$ since $\mathbb{1}_E$ is not measurable.
Is what I did a good approach to this problem? For an arbitrary set $E\subseteq [0,1]$, is it possible to prove that such a function does not exist?
Derivatives satisfy the intermediate value property. See Darboux's theorem.