Optimality condition of a convex function that is a.e. differentiable Let $f:\mathbb{R}\rightarrow\mathbb{R}$ be convex, and let $A \subseteq \mathbb{R}$ be a Lebesgue-measurable set such that $\lambda(\mathbb{R}\setminus A)=0$, and such that for every $x \in A$, $f$ is differentiable at $x$ and $f'(x)$ is finite.
Suppose there is a partition of $\mathbb{R}$ into three non-empty intervals, $\mathbb{R} = I\uplus J\uplus K$, such that for every $(x,y,z) \in I\times J\times K$, $x<y<z$, and such that


*

*for every $x \in I\cap A$, $f'(x) < 0$,

*for every $y \in J\cap A$, $f'(y) = 0$,

*for every $z \in K\cap A$, $f'(z) > 0$.
a. Can it be inferred that, for every triple $(x,y,z)\in I\times J\times K$, $f(x) \geq f(y) \leq f(z)$?
b. Can it be inferred that, for every triple $(x,y,z)\in I\times J\times K$, $f(x) > f(y) < f(z)$?
 A: If $f$ is convex and $f'(x) = 0$, then $x$ is a global minimiser of $f$,
hence a. is true.
In the following, let $x$ be any global minimiser.
For b., if $f'(a)>0$, for example, then there is some nearby $a'$ such that
$f(a')< f(a)$, and since $f(a') \ge f(x)$ we see that $f(a) > f(x)$. Similarly if $f'(a) <0$.
However, Daniels example above shows that there may be (at most) one point $a \in I$  at which $f(a) = f(x)$ and similarly for $J$.
Note that if $f(x') = f(x)$ then $f(y) = f(x) $ for all $y \in [x',x]$, hence
there can be at most one point $a \in I$ for which $f(a) = f(x)$.
As an aside, note that $f'$ is non decreasing, whenever it exists.
Also, if $f$ is convex and defined on an open set, it is locally Lipschitz hence
ae. differentiable.
Addendum: The above reasoning doesn't cover the case where $J$ is
a singleton and the singleton is not contained in $A$. Let $J = \{x\}$.
Since $f$ is locally Lipschitz, it is absolutely continuous on any
bounded interval, hence we have
$f(a) = \int_x^a f'(t) dt$. If $ a < x$, then $f'(t) <0$ for ae. $t \in [a,x]$
and hence $f(a) > f(x)$. Similarly for $a>x$. Hence $x$ is a strict
minimum.
