Let $f:[a, b] \rightarrow \mathbb{R}$ and define $g:[a, b] \to \mathbb R$ by $$ g(x) := \begin{cases} f^{\prime}(x) & \text{if } f \text { differentiable at } x \in (a, b),\\ 0 & \text {otherwise}. \end{cases} $$
Then $g$ is Borel measurable. Let $\lambda$ be the Lebesgue measure on $[a, b]$. I would like to prove below result, i.e.,
Theorem If $f$ is increasing, then $g \ge 0$ and $\int_a^b g \mathrm d \lambda \le f(b)-f(a)$.
Could you confirm if my below attempt is fine?
Proof It's clear that $g \ge 0$. Let $$ g_n(x) := \begin{cases} \frac{f\left(x+\frac{1}{n}\right)-f(x)}{\frac{1}{n}} & \text{if } f \text { differentiable at } x \in [a, b-\frac{1}{n}], \\ 0 & \text {otherwise}. \end{cases} $$
Then $g_n \to g$ everywhere. Because $f$ is differentiable $\lambda$-a.e., we get $$ g_n =\frac{f\left(x+\frac{1}{n}\right)-f(x)}{\frac{1}{n}} \quad \text{for } \lambda \text{-a.e. } x \in \left [a, b-\frac{1}{n} \right]. $$
By Fatou's lemma, $$ \begin{align} \int_a^b g \mathrm d \lambda &\le \liminf_n \int_a^b g_n \mathrm d \lambda \\ &= \liminf_n \int_a^{b-1/n} g_n \mathrm d \lambda \\ &= \liminf_n n \left [ \int_{a+1/n}^b f \mathrm d \lambda - \int_{a}^{b-1/n} f \mathrm d \lambda\right ] \\ &= \liminf_n n \left [ \int_{b-1/n}^b f \mathrm d \lambda - \int_{a}^{a+1/n} f \mathrm d \lambda \right ] \\ &\le \liminf_n n \left [ \frac{f(b)}{n}- \frac{f(a)}{n} \right ] \text{ because } f \text{ is increasing} \\ &= f(b)-f(a). \end{align} $$
This completes the proof.