Lemma 18.3.2. Let $-\infty < a < b < \infty$, $f, g \in C([a,b]; \real)$, and $N \subset [a, b]$ be at most countable such that:
$f, g$ are right-differentiable on $[a, b] \setminus N$.
For every $x \in [a, b] \setminus N$, $D^{+}f(x) \le D^{+}g(x)$.
then for any $x \in [a, b]$, $f(x) - f(a) \le g(x) - g(a)$.
Proof. First assume that for every $x \in [a, b] \setminus N$, $D^{+}f(x) < D^{+}g(x)$.
Let $\seq{x_n}$ be an enumeration of $N$. For each $x \in [a, b]$, let $N(x) = \bracs{n \in \natp|x_n \in [a, x)}$. Let $\eps > 0$ and define
then by continuity of $f$ and $g$, $S$ is closed.
Let $x \in S$ and suppose that $s < b$. If $x \in [a, b] \setminus N$, then since
there exists $\delta > 0$ such that $f(x + t) - f(x) < g(x + t) < g(x)$ for all $t \in [0, \delta)$. In which case, $[x, x + \delta) \subset S$.
If $x = x_{n} \in N$, then by continuity of $f$ and $g$, there exists $\delta > 0$ such that $f(x + t) - f(x) \le g(x + t) - g(x) + 2^{-n}$ for all $t \in (0, \delta)$. Hence $[x, x + \delta) \subset S$ as well.
Therefore $S = [a, b]$. As this holds for all $\eps > 0$, $f(b) - f(a) \le g(b) - g(a)$.
Finally, suppose that $D^{+}f(x) \le D^{+}g(x)$ for all $x \in [a, b] \setminus N$. Let $\eps > 0$ and $h(x) = g(x) + \eps(x - a)$. By the preceding case, $f(b) - f(a) \le g(b) - g(a) + \eps(b - a)$. As this holds for all $\eps > 0$, $f(x) - f(a) \le g(x) - g(a)$.$\square$