Convergence of convex functions I can prove the following result.

Theorem 1. Let $f_n:\mathbb{R}^n\to \mathbb{R}$ be a sequence of convex functions
that converges almost everywhere to a function  $f:\mathbb{R}^n\to\mathbb{R}$.
Then $f$ is convex in the
sense that there is a convex function $F:\mathbb{R}^n\to\mathbb{R}$
such that $F=f$ a.e.

I am sure, it must be known.

Question 1. Where can I find a proof?

Edit. I added one more question (see below) and the answers published back in October 2022 apply to Question 1.
Theorem 1 implies the following fact that I could not find in any book:

Theorem 2. If $f\in W^{2,1}_{\rm loc}(\mathbb{R}^n)$ (Sobolev space) satisfies
$v^T D^2f(x)v\geq 0$ for almost all $x$ and all $v$, then $f$ is convex.

Indeed, if $f_\epsilon$ is an approximation by convolution (with a positive mollifier), then $v^T D^2f_\epsilon(x)v\geq 0$ and hence $f_\epsilon$ is convex since it is smooth. Now $f_\epsilon\to f$ a.e. along with Theorem 1 implies that $f$ is convex.

Question 2. Has Theorem 2 been written somewhere?

This is a simple result, but I am quite surprised I could not find it in any textbook.
 A: It follows from Theorem 10.8 in
R. Tyrrell Rockafellar. Convex analysis. Princeton Mathematical Series, No.
28. Princeton University Press, Princeton, N.J., 1970.
This theorem essentially says the following: if $f_n$ are convex functions on an open domain $\Omega\subset\mathbb{R}^n$ that converge pointwise (to a finite value) on a dense subset of $\Omega$, then the limit exists for every point of $\Omega$, this limit is a convex function, and the convergence is uniform on every compact set inside $\Omega$.
A: I hope it's OK to post with a proof rather than a reference; when I started writing I thought this would be shorter...
Lemma. Let $(f_n \mid n \geq 1)$ be a sequence of convex functions $f_n: \mathbf{R}^d \to \mathbf{R}$, assumed to converge a.e. to a function $f: \mathbf{R}^d \to \mathbf{R}$. Then (i) the convergence is locally uniform, and (ii) $f$ is convex.

*

*Throughout let $D_R \subset \mathbf{R}^d$ be the $d$-dimensional disc of radius $R$. We will use the three nested discs $D_1 \subset D_2 \subset D_5$, ultimately showing that the convergence is uniform on the innermost one: we prove first (in Claim 1) that the $f_n$ are bounded above on $D_5$, next (in Claim 2) that they are bounded below on $D_2$, and finally (in Claim 3) that they are equicontinuous on $D_1$. The conclusion follows by Arzela-Ascoli.


*Recall first that convex functions are continuous (on the interior of their domains); this is true in particular for every $f_n$.


*For all points $x \in \mathbf{R}^d$ and unit vectors $v \in \mathbf{R}^d$, let $\mathbf{L}_{x,v} \subset \mathbf{R}^d$ be the affine line through $x$ directed by $v$. For example, let $x \neq y \in \mathbf{R}^d$, and $v = y - x/\lvert y - x \rvert$. Any convex function $h: \mathbf{R}^d \to \mathbf{R}$ remains convex when restricted to $\mathbf{L}_{x,v}$, and along this line one has $h(x+tv) \geq h(x) + t(h(y)-h(x))/\lvert y - x \rvert$ for all $t \not\in (0,\lvert y - x \rvert)$. We will use this repeatedly with $h = f_n$.
Claim 1. There is $M > 0$ so that $f_n \leq M$ in $D_5$ for all $n$.
Proof. If not, then there is a sequence of points $x_n \in D_3$ along which $M_n := f_n(x_n) \to + \infty$. Let $\mathbf{L}_{x_n,v}$ be an arbitrary line through $x_n$. Along it, $f_n(x_n + tv) \geq f_n(x_n) + t (f_n(x_n + v) - f_n(x_n))$ for all $t \not \in (0,1)$. Pick $t < -1$ or $t > 1$ depending on the sign of $f_n(x_n + v) - f_n(x_n)$. For one of the half-lines one has $f_n \geq M_n$ along it. By varying $v$ one finds that $f_n \geq M_n$ on at least half of the annulus $D_2(x_n) \setminus D_1(x_n)$: $\mathcal{H}^d( \{ x \in D_2(x_n) \setminus D_1(x_n) \mid f_n(x) \geq M_n \}) \geq  \mathcal{H}^d( D_2 \setminus D_1) / 2$. This is absurd because $D_2(x_n) \subset D_5$, and $f_n$ converges a.e. to $f$ in that set. $\blacksquare$
Claim 2. There is $C > 0$ so that $f_n \geq - CM$ in $D_2$ for all $n$.
Proof. We argue by contradiction: as $f_n \leq M$ on $D_5$, if there were a sequence of points $x_n \in D_2$ with $f_n(x_n) \leq -C_n M_n \to \infty$, then $f_n \to -\infty$ on $D_2$. But this is impossible because $f_n$ converges a.e. in $D_2$.
Take thus some fixed $C > 0$, some sequence $C_n \to +\infty$, and two sequences of points $x_n,y_n \in D_2$ so that $f_n(x_n) = -C_n M$ but $f_n(y_n) \geq -CM.$
Let $v_n = y_n - x_n / \lvert y_n - x_n \rvert$. Along the line $\mathbf{L}_{x_n,v_n}$,
\begin{align}
f(x_n + t v_n)
&\geq f(x_n) + t(f(y_n) - f(x_n))/\lvert y_n - x_n \rvert \\
&\geq -C_n M + t(-CM + C_n M)/\lvert y_n - x_n \rvert \\
&\geq MC_n(-1 + t(1 - C/C_n)/\lvert y_n - x_n \rvert)
\end{align}
for all $t > \lvert y_n - x_n \rvert$. We may assume that $C_n/100 > C \geq 1$ say; therefore if $t \in [2 + \lvert y_n - x_n \rvert, 3 + \lvert y_n - x_n \rvert]$ then
\begin{equation}
f(x_n + t v_n)
\geq MC_n(-1 + 2 (1 - C/C_n)) \geq 99M.
\end{equation}
But for this range of $t$, $x_n + t v_n \in D_5$, where $f_n \leq M$; this is absurd. $\blacksquare$
Claim 3. The $f_n$ are $2CM$-Lipschitz in $D_1$.
Proof.
We argue again by contradiction. Let $x_n,y_n \in D_1$ be two sequences of points along which $f_n(y_n) \geq f_n(x_n)$ and $f_n(y_n) - f_n(x_n) > 2CM \lvert y_n - x_n \rvert$. Let $v_n$ be the unit vector from $x_n$ to $y_n$. Along the line $\mathbf{L}_{x_n,v_n}$,
\begin{equation}
f_n(x_n + tv_n) > f_n(x_n) + 2tCM \geq CM
\end{equation}
for all $t \in [1 + \lvert y_n - x_n \rvert,2+\lvert y_n - x_n \rvert]$. This is absurd because $x_n + t v_n \in D_5$ for this range of $t$, where $f_n \leq M$. $\blacksquare$
A: This is trickier than it seems. It is easy to see that the limit $f$ satisfies Jensen's inequality a.e., a property sometimes known as almost convexity. In the univariate case, $f$ being almost convex is known to imply that it is equal to some convex function $F$ a.e. (see for example Parnami and Vasudeva On the Stability of Almost Convex Functions). In dimension greater than 1, it is unclear that this is true without extra assumptions. Maybe the following paper could be helpful: La Torre and Rocca, Almost everywhere convex functions on Rn and weak derivatives.
