Existence of minimal measurable majorant of an arbitrary function $f:X\rightarrow \bar{\mathbb{R}}$ Let $(X, \mathcal M, \mu)$ be  a measure space.
Let $f:X\rightarrow \bar{\mathbb{R}}$ be a function.
A user wrote in his answer to this question(Lebesgue's monotone convergence theorem for upper integrals) that there is a measurable function $f^*: X\rightarrow \bar{\mathbb{R}}$ with the following properties.

(1) $f\le f^*$
(2) For any measurable $g:X\rightarrow \bar{\mathbb{R}}$ with $f\le g$, $f^*(x)\le g(x)$ almost everywhere on $X$

How do you prove this?
 A: This is not true in general. To see this, let us first assume the
following:


*

*Every singleton set $\left\{ x\right\} $ with $x\in X$ is measurable.

*There are no null-sets except for $\emptyset$.


In this case, we show that the only possible choice is $f^{\ast}=f$.
We will then show that we can take a measure space $\left(X,\mathcal{M},\mu\right)$
for which the above properties hold, but so that $f$ is not measurable.
This will give the desired contradiction.
To see $f^{\ast}=f$, note first that we have $f\leq f^{\ast}$ almost
everywhere and hence everywhere by (2). Now, let $x\in X$ be arbitrary.
The function
$$
f_{x}:=\infty\cdot\chi_{\left\{ x\right\} ^{c}}+f\left(x\right)\cdot\chi_{\left\{ x\right\} }
$$
is measurable by (1) and satisfies $f_{x}\geq f$. Hence, $f^{\ast}\leq f$
almost everywhere and hence everywhere by (2). In particular, $f^{\ast}\left(x\right)\leq f_{x}\left(x\right)=f\left(x\right)$.
But we saw $f\leq f^{\ast}$ above, which yields $f=f^{\ast}$.
Now, for the specific choice of $\left(X,\mathcal{M},\mu\right)$,
let $X=\mathbb{R}$, 
$$
\mathcal{M}=\left\{ A\subset\mathbb{R}\,\mid\, A\text{ countable or }A^{c}\text{ countable}\right\} ,
$$
let $\mu$ be the counting measure and let $f=\chi_{A}$ for any $A\subset\mathbb{R}$
with $A\notin\mathcal{M}$ (for example $A=\left(0,\infty\right)$).
As a further remark, note that $\left(X,\mathcal{M},\mu\right)$ is
semi-finite.

Now, let us show that the claim holds if $\mu$ is $\sigma$-finite.
The idea is pretty simple: We can (essentially) assume our measure space to be of finite measure. Then, we obtain the desired "upper envelope" by minimizing $\int g \, d\mu$ among all those measurable functions which satisfy $f \leq g$ almost everywhere. The main difficultis are ensuring that the infimum is actually a (finite!) minimum. Now, let us jump into the details (which can probably be simplified considerably).
Let $X=\bigcup_{n\in\mathbb{N}}X_{n}$ with $\mu\left(X_{n}\right)<\infty$.
We can assume the $\left(X_{n}\right)_{n\in\mathbb{N}}$ to be (pairwise)
disjoint (why?). Note that we can assume $f:X\to\left[-1,1\right]$,
since the map
$$
\phi:\overline{\mathbb{R}}\to\left[-1,1\right],x\mapsto\begin{cases}
1, & x=\infty,\\
\frac{x}{1+x}=1-\frac{1}{1+x}, & x\in\mathbb{R},\\
-1, & x=-\infty
\end{cases}
$$
is (Borel) measurable with measurable inverse map, so that we can
consider $\phi\circ f$, find $\left(\phi\circ f\right)^{\ast}$ and
then find $f^{\ast}=\phi^{-1}\circ\left(\phi\circ f\right)^{\ast}$.
Here, I leave the details to you.
Now, for each $n\in\mathbb{N}$, let
$$
\mathcal{F}_{n}:=\left\{ g:X_{n}\to\overline{\mathbb{R}}\,\mid\, f\leq g\text{ and }-1\leq g\leq1\text{ almost everywhere and }g\text{ measurable}\right\} .
$$
Note that this set is nonempty, since $\left(x\mapsto1\right)\in\mathcal{F}_{n}$.
Furthermore, we have $-\mu\left(X_{n}\right)\leq\int_{X_{n}}g\,{\rm d}\mu\leq\mu\left(X_{n}\right)$
for all $g\in\mathcal{F}_{n}$, so that
$$
\alpha_{n}:=\inf_{g\in\mathcal{F}_{n}}\int_{X_{n}}g\,{\rm d}\mu
$$
is a well-defined finite number. Now, let $\left(g_{m}^{\left(n\right)}\right)_{m\in\mathbb{N}}$
be a sequence in $\mathcal{F}_{n}$ with $\int_{X_{n}}g_{m}^{\left(n\right)}\,{\rm d}\mu\xrightarrow[m\to\infty]{}\alpha_{n}$.
By switching to $\widetilde{g_{m}^{\left(n\right)}}:=\min\left\{ g_{1}^{\left(n\right)},\dots,g_{m}^{\left(n\right)}\right\} $,
we can assume without loss of generality that $g_{m+1}^{\left(n\right)}\leq g_{m}^{\left(n\right)}$
for all $m$. For this, note that we have $\widetilde{g_{m}^{\left(n\right)}}\geq f$
almost everywhere and hence $\widetilde{g_{m}^{\left(n\right)}}\in\mathcal{F}_{n}$,
which also implies
$$
\alpha_{n}\leq\int_{X_{n}}\widetilde{g_{m}^{\left(n\right)}}\,{\rm d}\mu\leq\int_{X_{n}}g_{m}^{\left(n\right)}\,{\rm d}\mu\xrightarrow[m\to\infty]{}\alpha_{n}.
$$
Thus, $\left(g_{m}^{\left(n\right)}\right)_{m\in\mathbb{N}}$ is a
decreasing sequence of measurable functions, so that $g^{\left(n\right)}:=\lim_{m\to\infty}g_{m}^{\left(n\right)}$
defines a measurable function $g^{\left(n\right)}:X_{n}\to\mathbb{R}$.
It is easy to see $g^{\left(n\right)}\in\mathcal{F}_{n}$ and thus
$$
\alpha_{n}\leq\int_{X_{n}}g^{\left(n\right)}\,{\rm d}\mu\leq\int_{X_{n}}g_{m}^{\left(n\right)}\,{\rm d}\mu\xrightarrow[m\to\infty]{}\alpha_{n}.
$$
Now, define
$$
g:X\to\mathbb{R},x\mapsto g^{\left(n\right)}\left(x\right)\text{ if }x\in X_{n}.
$$
I leave it to you to verify that $g$ is measurable with $f\leq g$
almost everywhere.
Now, let $h:X\to\overline{\mathbb{R}}$ be measurable with $f\leq h$
almost everywhere. In particular, $-1\leq f\leq h$ almost everywhere.
Now, $\tilde{h}:=\min\left\{ 1,h\right\} $ is also measurable with
$-1\leq f\leq\tilde{h}\leq1$ almost everywhere. Thus, $\tilde{h}|_{X_{n}}\in\mathcal{F}_{n}$.
This easily yields $\psi_{n}:=\min\left\{ \tilde{h}|_{X_{n}},g^{\left(n\right)}\right\} \in\mathcal{F}_{n}$
and thus
$$
\alpha_{n}\leq\int_{X_{n}}\psi_{n}\,{\rm d}\mu\leq\int_{X_{n}}g^{\left(n\right)}\,{\rm d}\mu_{n}\leq\alpha_{n}.
$$
Hence,
$$
0=\int_{X_{n}}g^{\left(n\right)}-\psi_{n}\,{\rm d}\mu\quad\overset{\psi_{n}\leq g^{\left(n\right)}}{=}\quad\int_{X_{n}}\left|g^{\left(n\right)}-\psi_{n}\right|\,{\rm d}\mu,
$$
which implies $g^{\left(n\right)}-\psi_{n}=0$ almost everywhere on
$X_{n}$. Hence, $g^{\left(n\right)}=\psi_{n}=\min\left\{ \tilde{h}|_{X_{n}},g^{\left(n\right)}\right\} $
almost everywhere on $X_{n}$, which implies 
$$
g\left(x\right)=g^{\left(n\right)}\left(x\right)\leq\tilde{h}\left(x\right)\leq h\left(x\right)
$$
for almost all $x\in X_{n}$. Using $X=\bigcup_{n\in\mathbb{N}}X_{n}$,
we see $g\leq h$ almost everywhere, as desired.
Thus, we can choose $f^{\ast}=g$.
