I have been searching for an answer to this question without much success. I know that any convex function in $\mathbb{R}$ is differentiable almost everywhere (since it is locally Lipschitz, and locally Lipschitz functions are differentiable a.e.). Also, if a convex function $f$ is differentiable at a point $x$, then for all $y$:
$$ f(y) \geq f(x) + f'(x)(y-x) $$
This is also a characterization of convexity if $f$ is $C^1$.
My question is: if we have a function that is differentiable almost everywhere, and for which the inequality above holds, can we also conclude convexity? I have tried to adapt this answer, but I think it breaks because of having differentiability only a.e.
Thanks in advance.