integrating sub derivative of convex function Let $f$ be a convex function on $\mathbb R$ such that $f(0)=0$, let $g$ be such that for all $x$ in $\mathbb R$, $g(x)$ is a sub-gradient of $f$ at $x$, then it seems to me that for all $x\in \mathbb R$
\begin{align*}
f(x) = \sup_{(x_0, \dots, x_{n+1})\in \mathcal S} \sum_{k=0}^{n} g(x_k) (x_{k+1}-x_k) 
\end{align*}
Where $\mathcal S = \{0\}\times\mathbb R^\ast\times\{x\} = \{ (0,x_1,\dots, x_n, x) : \forall i \in \{1,\dots,n\},~ x_i\in\mathbb R \}$.
For $f$ differentiable everywhere it seems to be the Riemann integral but when it is not, I feel like it is still an equality. Can anyone prove that it is wrong ? Or maybe is this something that exists alreadz and in this case I would appreciate some references.

It is easy to prove by property of the sub-gradient and induction that for all $(x_0, \dots, x_{n+1})\in \mathcal S$, $\sum_{k=0}^{n} g(x_k) (x_{k+1}-x_k)\leq f(x)$, I'm not sure on how to prove (or if it is doable) that there exists a sequence $(s_p)_{p\geq 1}$ of elements of $\mathcal S$ that converges to $f(x)$.
 A: Since $f$ is convex, we have $f_-'(x_1)\leq f_+'(x_1)\leq f_-'(x_2)\leq f_+'(x_2)$ for $x_1\leq x_2$. 


*

*This implies that $f:[a,b]\rightarrow \mathbb{R}$ is Lipschitz with constant $L = \max\{|f_+'(a)|,|f_-'(b)|\}+1$. Indeed, we have
$$\limsup_{x\rightarrow x_0}\frac{|f(x) - f(x_0)|}{|x-x_0|} < L$$
for every $x_0\in [a,b]$ and this implies that $f$ is $L$-Lipschitz. Lipschitz functions are absolutely continuous. Hence $f$ is absolutely continuous.   

*This also implies that $f'$ exists outside of a countable subset and is nondecreasing.


Now pick any function $g:[a,b]\rightarrow \mathbb{R}$ such that
$$g(x) = f'(x)$$
outside of a countable subset of $[a,b]$. Since $f$ is absolutely continuous, we have 
$$f(x) = g(a) + \int^x_ag(t)dt$$
Since $g$ is equal to derivative $f'$, which is nondecreasing outside of a countable subset of $[a.b]$, the integral on the right hand side can be taken to be the usual Riemann integral. Note also that $g$ is equal to (sub)derivative of $f$ outside of a countable subset of $[a,b]$. 
