Suppose $C\subset\mathbb{R}^n$ is a convex set and $f:C\to\mathbb{R}$ is a convex function. I wonder if the following statement is true.
Suppose $g:C\to\mathbb{R}^n$ satisfies $g(x)\in\partial f(x)$ for all $x\in C$. Then for all $x,y\in C$, it holds that $$ f(y)-f(x)=\int_0^1g(x+t(y-x))^T(y-x)\ dt. $$
I think I can prove that this is true, but I couldn't find such a result online, so I wonder if my proof is incorrect. Are there any references that contain this kind of result?
My proof: Let $\ell(t)=f(x+t(y-x))$. Then $\ell:[0,1]\to\mathbb{R}$ is convex, and $$ \partial\ell(t)=\lbrace d^T(y-x):d\in\partial f(x+t(y-x))\rbrace. $$ In particular, $g(x+t(y-x))^T(y-x)\in\partial\ell(t)$. Since $\ell$ is convex, then for almost every $t\in[0,1]$, $\ell$ is differentiable at $t$, and thus $g(x+t(y-x))^T(y-x)=\ell'(t)$. Moreover, since $\ell$ is convex, then $\ell$ is locally Lipschitz hence absolutely continuous on every compact interval. Therefore, $$ f(y)-f(x)=\ell(1)-\ell(0)=\int_0^1\ell'(t)\ dt=\int_0^1g(x+t(y-x))^T(y-x)\ dt. $$
A possible reference could be Theorem 2.3.4 (p. 179) of the following textbook:
Hiriart-Urruty, Jean-Baptiste; Lemaréchal, Claude, Fundamentals of convex analysis, Grundlehren. Text Editions. Berlin: Springer. x, 259 p. (2001). ZBL0998.49001.