Consider a function $f:\mathbb{R} \rightarrow [0,1 ]$ defined by:
$\begin{equation*} f(x)=\left\{ \begin{array}{rl}0 & \text{if } x\leq 0,\\ 1 & \text{if } x\geq 1, \\ 1/2 & \text{if } x\in [1/3,2/3] \\ 1/4 & \text{if } x\in [1/9,2/9] \\3/4 & \text{if } x\in [7/9,8/9] \\ \vdots \end{array}\right. \end{equation*}$
I tried to prove this by contradiction. When i tried to integrate i am getting the answer in terms of values of $\phi$ in cantor set where $\phi$ is any measurable $C^{\infty}$ function. I am unable to go further.
I think weak derivative of $f$ means $ g \in L^1_{loc}(\mathbb{R}) $ such that the distribution derivative of f is induced by $g$ i.e. for all test functions $ \phi \in C^\infty_c(\mathbb{R}) $ we have $$ \int_\mathbb{R} g\phi\ dx = -\int_\mathbb{R} f\phi' dx $$ Now if we assume there exists a weak derivative $g$ then clearly $ g(x) = f'(x) $ almost everywhere. But if $f$ is the Cantor function then $ f'(x) = 0\ a.e $. Hence $ g(x) = 0\ a.e $. Now for any $\alpha > 1$ we choose $ \phi \in C^\infty_c(\mathbb{R}) $ such that $ \phi(x) = 1 $ for all $ x \in [0,1] $ and $ \phi(x) = 0 $ for all $ x \geq \alpha $ Then we find that $\int_\mathbb{R} g(x)\phi(x) dx = 0 $ as $ g(x) = 0\ a.e $ but $$ -\int_\mathbb{R} f(x)\phi'(x) dx = -\int^\alpha_0 f(x)\phi'(x) dx = -\int^\alpha_1\phi'(x) dx = \phi(1)-\phi(\alpha) = 1 \neq 0 $$ Hence we have a contradiction.