Weakly convex functions are convex Let us consider a continuous function $f \colon \mathbb{R} \to \mathbb{R}$. Let us call $f$ weakly convex if
$$
\int_{-\infty}^{+\infty}f(x)[\varphi(x+h)+\varphi(x-h)-2\varphi(x)]dx\geq 0 \tag{1}
$$
for all $h \in \mathbb{R}$ and all $\varphi \in C_0^\infty(\mathbb{R})$ with $\varphi \geq 0$.
I was told that $f$ is weakly convex if, and only if, $f$ is convex; although I can imagine that (1) is essentially the statement $f'' \geq 0$ in a weak sense, I cannot find a complete proof.
Is this well-known? Is there any reference?

If you take a family of symmetric mollifiers $\rho_\sigma$ compactly supported in $B_\sigma(0)$, and let $f_\sigma = \rho_\sigma \ast f$ denote the convolution of $f$ with $\rho_\sigma$, then for any $\varphi\in C_c^\infty(\mathbb R)$ you have that $\int f_\sigma \varphi = \int f \varphi_\sigma$. In particular
$$\int f_\sigma(x) [\varphi(x+h)+ \varphi(x-h) - 2\varphi(x) ]= \int f(x) [\varphi_\sigma(x+h)+ \varphi_\sigma(x-h) - 2\varphi_\sigma(x) ] \ge 0$$
for $\varphi \ge 0$.
Hence after substitution and multiplication by $h^{-2}$ for $h\ne 0$, we get
$$\int \frac{f_\sigma(x+h)+f_\sigma(x-h) - 2f_\sigma(x) }{h^2} \varphi(x)  \ge 0$$
Letting $h\to 0$, it follows from this that $f_\sigma'' \ge 0$. So $f_\sigma$ is convex for all $\sigma > 0$. On the other hand, since $f$ is continuous, $f_\sigma \to f$ pointwise. So $f$ is convex, itself.
On the other hand, if $f$ is convex, then $f(x+h) - f(x) \ge f(x) - f(x-h)$, so $f(x+h) + f(x-h) -2 f(x) \ge 0$. From this the integral inequality follows.
