# What's behind the function $g(x)=\operatorname{inf}\{f(p)+d(x,p):p\in X\}$?

In several books on measure theory, I have seen the following problem:

Suppose $(X,d)$ is a metric space, on which $f$ is a nonnegative lower semicontinuous function. Show that $f$ is the pointwise limit of an increasing sequence of uniformly continuous functions.

It seems the standard solution is to construct the function $$g_n(x)=\operatorname{inf}\{f(p)+nd(x,p):p\in X\},$$ then show each $g_n$ is uniformly continuous and $g_n\le g_{n+1}$, and $g_n\to f$ pointwisely.

This becomes a standard exercise once the $g_n$ is given, but it puzzles me a lot how anyone would come up with $g_n$ in the first place.

So is there some explanation/ intuition behind the construction of these functions?

Thanks!

Another way to describe $g_n$ is: $$g_n = \sup\{ g : g \text { is n-Lipschitz and } g \le f\} \tag{1}$$ The key point is that the property of being Lipschitz with a fixed constant is preserved under taking supremum or infimum. Hence, we can take the supremum of all $n$-Lipschitz minorants of $f$, this obtaining the greatest $n$-Lipschitz minorant (or $n$-Lipschitz lower envelope) of $f$. As $n\to\infty$, it converges to $f$.
To connect (1) to your formula, observe that the requirement $g(x)\le f(x)$ together with $g$ being $n$-Lipschitz force $g(x)\ge f(p)+nd(x,p)$ for all $p$. Thus, $g\le g_n$. On the other hand, $g_n$ belongs to the family; hence it is the supremum.
The Lipschitz modulus of continuity is the simplest one to use, but one could equivalently take the supremum of all minorants that satisfy the Hölder condition of order $\alpha$ with constant $n$. Or use any sequence of moduli of continuity that grows to infinity. The idea stays the same: the set of all functions with a particular modulus of continuity is a lattice.
One can also take infimum of $n$-Lipschitz majorants, arriving at a counterpart of $g_n$: $$\begin{split} h_n(x) &= \inf\{ h : h \text { is n-Lipschitz and } h \ge f\} \\ &= \sup\{f(p)-n d(x,p) : x\in X\}\end{split} \tag{2}$$
You may want to compare (1) to another construction: $$\phi = \sup\{ h : h \text { is convex and } h \le f\} \tag{3}$$ where "convex" can also be replaced by "affine". The construction (3) makes sense only on linear spaces, since it refers to convexity. But the idea is similar: having a property that is preserved under taking supremum, we can build the greatest minorant with the given property. It's called the convex envelope of $f$, I believe.