A functional corollary of Lusin's separation theorem
Although for long I've been taught and I believed that everything reasonable you'll ever encounter is Borel-measurable,
I've recently stumbled on the fact that proving that something is Borel can actually require more work than expected.
So I thought I’d share a little “sandwich theorem” I worked out recently. I find it kind of cute, but of course it had to be
relegated as technical stuff in the appendix (Proposition 4, here).
For the record, I'm pretty new to descriptive set theory, and someone with more of a grasp of it might find rather naive both the problem and my
approach to tackle it. Yet, I could not find such statement anywhere explicitly stated.
In a nutshell, what I'll
show is that given a lower semi-analytic function $l$ and an upper semi-analytic function $u$, such that $u\leq l$, there is
a Borel function $f$ such that $u\leq f\leq l$. This is a consequence of a classical result by Lusin, stating that, given an analytic
set $A$ included in a coanalytic set $C$, there is a Borel set $B$ satisfying $A\subseteq B\subseteq C$.
Problem statement
A few preliminaries to start with... A set $A\subseteq\mathbb R^n$ is called analytic if there is a Borel set $B\subseteq\mathbb R^{n+1}$ such that $\pi(B) = A$, where $\pi$ is the projection $(x_1,\dots, x_{n+1})\mapsto (x_1,\dots,x_n)$. A set whose complement is analytic is called coanalytic. Clearly, any Borel set is both analytic and coanalytic. A fundamental result from descriptive set theory is Lusin's separation theorem, stating that we can always find a Borel set squeezed between an analytic and a coanalytic set. This implies that any set that is both analytic and coanalytic is Borel.
Let $A$ be an analytic set in $\mathbb R^n$ and $C$ a coanalytic set in $\mathbb R^n$, such that $A\subseteq C$. Then, there is a Borel set $B$ such that $A\subseteq B\subseteq C$.
Let us fix a Borel set $\mathcal X\subseteq\mathbb R^n$. A function $u:\mathcal X\to\bar{\mathbb{R}}$ is called upper semi-analytic if its upper level sets $\{u\geq z\}$ and $\{u>z\}$ are analytic sets in $\mathbb R^n$. A function $l:\mathcal X\to\bar{\mathbb{R}}$ is called lower semi-analytic if its lower level sets $\{l\leq z\}$ and $\{l\lt z\}$ are analytic sets in $\mathbb R^n$. It is easily checked that $f$ is Borel if, and only if, it is both lower and upper semi-analytic. Interestingly, it is possible to separate upper and lower semi-analytic functions by Borel functions, in a similar spirit to what happened with analytic, coanalytic, and Borel sets with Lusin's separation theorem. This is formalised by the next statement, which is a slight extension of Proposition 4 in On the optimality of coin-betting for mean estimation.
Let $\mathcal X\subseteq\mathbb R^n$ be a Borel set. Let $u:\mathcal X\to\bar{\mathbb{R}}$ be upper semi-analytic, and $l:\mathcal X\to\bar{\mathbb{R}}$ be lower semi-analytic. If, for every $x\in\mathcal X$, $u(x)\leq l(x)$ then there is a Borel function $f:\mathcal X\to\bar{\mathbb R}$ such that $u\leq f\leq l$, pointwise on the whole $\mathcal X$.
How to prove the “sandwich theorem”?
First, we can notice that if $u$ and $l$ are indicator functions, then the result follows directly from Lusin's theorem. Indeed, say that $u = \mathbf{1}_U$ and $l = \mathbf{1}_L$. Since $u$ is upper semi-analytic, then $U = \{u>1/2\}$ is analytic. Analogously, $ \{ l \lt 1/2 \}$ is analytic as $l$ is lower semi-analytic, and so $L$ is coanalytic. Asking that $u\leq l$ pointwise implies that $U\subseteq L$. By Lusin's theorem, there is a Borel $B$ such that $U\subseteq B\subseteq L$. Then $f = \mathbf{1}_B$ is Borel-measurable and satisfies $u\leq f\leq l$.
Next, let us consider the case of simple functions, namely we assume that $u$ and $l$ are valued on a finite set $\mathcal Y = \{y_1,\dots,y_N\}$. We assume that $\mathcal Y$ is ordered increasingly, namely $y_{i+1}>y_i$. Let $U_i = \{u\geq y_i\}$, which is analytic, and $L_i = \{l\geq y_i\}$, which is coanalytic. Asking that $u\leq l$ pointwise implies that $U_i\subseteq L_i$. By Lusin's separation theorem there is a Borel set $B_i$ such that $U_i\subseteq B_i\subseteq L_i$. (As a side note, $U_1 = L_1 = B_1 = \mathcal X$ as $u$ and $l$ are everywhere greater than or equal to $y_1 = \min\mathcal Y$.) Now, let $D_N = B_N$, and then define iteratively $D_i = B_i\setminus B_{i+1}$. All these sets are clearly Borel, and we can define the Borel-measurable function $f = \sum_{i=1}^N y_i\mathbf{1}_{D_i}$. By construction, we also have that $\{f\geq y_i\}=B_i$, which shows that $u\leq f\leq l$ pointwise.
Now, we can focus on the case where both $u$ and $l$ are bounded functions. By rescaling and translating if necessary, we can assume without loss of generality that they both take values in $[0,1]$. First, let us show that there is a non-decreasing sequence $(u_n)$ of upper semi-analytic simple functions that converge pointwise to $u$. This can be easily constructed. For each $n$, for $t=0,\dots,2^n$, let $A_t^n = \{u\geq t/2^n\}$. Now define $u_n$ as follows. On $A_{2^n}^n$ we set $u_n$ equal to $1$. For $t = 0,\dots,2^n-1$, for $x\in A_t^n\setminus A_{t+1}^n$, set $u_n(x) = t/2^n$. Since $A_0^n = \mathcal X$ and $A_t^n\supseteq A_{t+1}^n$, in this way $u_n$ is uniquely defined on the whole $\mathcal X$. It is a quick check that each $u_n$ is simple and upper semi-analytic, and that the sequence $(u_n)$ is non-decreasing and converges pointwise to $u$. With an analogous construction, we can obtain a non-increasing sequence $l_n$ of simple lower semi-analytic functions that converges pointwise to $l$. Note also that by construction we have $u_n\leq u\leq l\leq l_n$ pointwise, for each $n$. From what we have already proved for simple functions, we know that for each $n$ there is a Borel-measurable function $f_n$, such that $u_n\leq f_n\leq l_n$ pointwise. Letting $f=\limsup_{n\to\infty} f_n$, we get that $u\leq f\leq l$ pointwise, and $f$ is Borel-measurable.
Finally, let us consider the general case, where $u$ and $l$ are potentially unbounded and take values in $\bar{\mathbb{R}}$. $u$ is upper semi-analytic, $l$ is lower semi-analytic, and $u\leq l$ pointwise. For each integer $n\geq 1$, define $u_n = \max\{-n, \min\{u,n\}\}$ and $l_n = \max\{-n, \min\{l,n\}\}$. Then each $u_n$ is bounded and upper semi-analytic, and each $l_n$ is bounded and lower semi-analytic. Moreover, $u_n\leq l_n$ pointwise. By what we have already shown, we know that there is $f_n$ Borel-measurable such that $u_n\leq f_n\leq l_n$. Clearly, $u_n\to u$ and $l_n\to l$ for $n\to\infty$. We can now define $f = \limsup_{n\to\infty} f_n$. This is a Borel-measurable function, and satisfies $u\leq f\leq l$, as we wanted.