% =================================================================
%  Lecture 5
%  Source: handwritten notes (Mathpix-converted) + Kashlak STAT 571
% =================================================================
\section[Lecture 5 -- Simple and Measurable Functions]{Lecture 5 \textemdash{} Simple and Measurable Functions}
\label{sec:lec05}

Having built measures (Lectures~1--4), we now turn to the objects we
actually integrate: \emph{functions} between measurable spaces. We
start with \emph{simple functions} \textemdash{} finite linear
combinations of indicators \textemdash{} which are concrete enough to
define an integral by hand, and then promote the construction to
arbitrary \emph{measurable functions} via the right preservation
lemmas. In probability language, simple functions are
finite-valued random variables, and measurable functions are random
variables.

\medskip

\textbf{Notation.} Throughout, \((\Omega,\Fcal,\mu)\) is a measure
space; for the probabilistic statements we write \((\Omega,\Fcal,\P)\)
with \(\P(\Omega)=1\). For a set \(A\), the indicator
\(\indic[\omega\in A]\) equals \(1\) when \(\omega\in A\) and \(0\)
otherwise. For \(f:\mathbb{X}\to\mathbb{Y}\) and \(B\subseteq
\mathbb{Y}\), the preimage is
\(f^{-1}(B)=\{x\in\mathbb{X}:f(x)\in B\}\). When the codomain is
\(\R\) we always equip it with its Borel \(\sigma\)-field
\(\Bcal(\R)\) unless stated otherwise.

\subsection{Simple functions and simple random variables}

A simple function is, by design, the simplest object on which an
integral can be defined: it takes only finitely many values, each on
a measurable piece of \(\Omega\).

\begin{definition}{Simple random variable}{simple-rv}
Let \((\Omega,\Fcal,\P)\) be a probability space. A
\emph{simple random variable} is a real-valued function
\(X:\Omega\to\R\) such that
\begin{enumerate}
  \item \(X\) takes only finitely many values \(x_1,\dots,x_p\in\R\);
  \item for every \(i\), the level set
        \(\{\omega\in\Omega:X(\omega)=x_i\}\in\Fcal\).
\end{enumerate}
Equivalently, there is a finite partition
\(\{A_i\}_{i=1}^{p}\subseteq\Fcal\) of \(\Omega\) (so
\(\bigsqcup_{i=1}^{p}A_i=\Omega\) with \(A_i\cap A_j=\emptyset\) for
\(i\neq j\)) and constants \(x_1,\dots,x_p\in\R\) with
\[
X(\omega) \;=\; \sum_{i=1}^{p} x_i\,\indic[\omega\in A_i].
\]
\end{definition}

\begin{remark}
For a simple random variable as above,
\(\P(X=x_i)=\P(\{\omega\in\Omega:X(\omega)=x_i\})=\P(A_i)\), and the
\emph{expectation} of \(X\) is the natural finite sum
\[
\E X \;=\; \sum_{i=1}^{p} x_i\,\P(X=x_i).
\]
\end{remark}

\begin{example}[{Binary steps on $(0,1]$}]
Take \(\Omega=(0,1]\) with Lebesgue measure \(\lambda\) and partition
\[
A_1=(0,0.25],\ A_2=(0.25,0.5],\ A_3=(0.5,0.75],\ A_4=(0.75,1],
\]
each of measure \(\lambda(A_i)=0.25\). Set \(x_i=(i-1)/4\). The
simple random variable
\(X^{(4)}(\omega)=\sum_{i=1}^{4}x_i\,\indic[\omega\in A_i]\) takes
the values \(0,0.25,0.5,0.75\) each with probability \(1/4\), so
\(\E X^{(4)}=(0+0.25+0.5+0.75)/4=0.375\). Refining the partition into
\(2^m\) pieces and letting \(m\to\infty\) recovers the uniform
distribution on \((0,1]\) in the limit.
\end{example}

The same definition makes sense on a general (not necessarily
probability) measure space, and is the starting point for the
abstract integral.

\begin{definition}{Simple function and its integral}{simple-fn}
Let \((\Omega,\Fcal,\mu)\) be a measure space. A \emph{simple
function} is a function \(f:\Omega\to\R\) of the form
\[
f(\omega) \;=\; \sum_{i=1}^{p} x_i\,\indic[\omega\in B_i],
\qquad x_i\in\R,\ B_i\in\Fcal.
\]
Its integral with respect to \(\mu\) is defined by
\[
\int f\,d\mu \;:=\; \sum_{i=1}^{p} x_i\,\mu(B_i).
\]
The sets \(B_i\) need not be disjoint, but any simple function admits
such a representation with \(\{B_i\}\) disjoint, and the value of the
integral is independent of the chosen representation.
\end{definition}

\begin{proposition}{Algebra of simple functions}{simple-algebra}
If \(f,g:\Omega\to\R\) are simple functions, then so are
\(f+g\), \(fg\), \(\max\{f,g\}\) and \(\min\{f,g\}\). For non-negative
simple functions \(f,g\) and a scalar \(c\ge 0\), the integral is
linear:
\[
\int (f+g)\,d\mu \;=\; \int f\,d\mu \,+\, \int g\,d\mu,
\qquad
\int c f\,d\mu \;=\; c\int f\,d\mu.
\]
\end{proposition}

\subsection{Measurable functions}

To extend the simple-function picture beyond finitely many values,
we replace ``\(X\) takes the value \(x_i\) on a measurable set'' with
``\(X\) pulls back \emph{every} Borel set to a measurable set''.
Working between two abstract measurable spaces costs nothing extra.

\begin{definition}{Measurable function}{measurable-fn}
Let \((\mathbb{X},\Xcal)\) and \((\mathbb{Y},\Ycal)\) be measurable
spaces. A function \(f:\mathbb{X}\to\mathbb{Y}\) is
\emph{measurable} (with respect to \(\Xcal/\Ycal\)) if
\[
f^{-1}(B) \;\in\; \Xcal \qquad \text{for every } B\in\Ycal.
\]
When \((\mathbb{Y},\Ycal)=(\R,\Bcal(\R))\) we say \(f\) is
\emph{Borel measurable}; if \(\Bcal(\R)\) is replaced by the
Lebesgue \(\sigma\)-field \(\Mcal_\lambda(\R)\), \(f\) is
\emph{Lebesgue measurable}. A measurable function on a probability
space \((\Omega,\Fcal,\P)\) with values in \((\R,\Bcal(\R))\) is a
\emph{random variable}.
\end{definition}

\begin{remark}
Preimages preserve set operations: for \(f:\mathbb{X}\to\mathbb{Y}\)
and \(A,A_i\subseteq\mathbb{Y}\),
\[
f^{-1}\!\Bigl(\bigcup_i A_i\Bigr) \;=\; \bigcup_i f^{-1}(A_i),
\qquad
f^{-1}(\mathbb{Y}\setminus A) \;=\; \mathbb{X}\setminus f^{-1}(A).
\]
Consequently \(\{f^{-1}(B):B\in\Ycal\}\) is itself a
\(\sigma\)-field on \(\mathbb{X}\); measurability of \(f\) is the
statement that this \(\sigma\)-field is contained in \(\Xcal\).
\end{remark}

The next proposition is the workhorse: to check measurability one
need only inspect a generating family.

\begin{proposition}{Measurability via a generator}{measurable-generator}
Let \(\Acal\subseteq\Ycal\) be a collection of sets with
\(\sigma(\Acal)=\Ycal\). A function \(f:\mathbb{X}\to\mathbb{Y}\) is
measurable if and only if \(f^{-1}(A)\in\Xcal\) for every
\(A\in\Acal\). In particular, since the half-lines
\(\{(-\infty,t]:t\in\R\}\) generate \(\Bcal(\R)\),
\(f:\mathbb{X}\to\R\) is Borel measurable iff
\[
\{x\in\mathbb{X}: f(x)\le t\} \;\in\; \Xcal \qquad \text{for every } t\in\R.
\]
\end{proposition}

The class of measurable functions is closed under essentially every
operation one performs in analysis.

\begin{proposition}{Stability properties of measurable functions}{measurable-stability}
Let \((\mathbb{X},\Xcal)\) be a measurable space.
\begin{enumerate}
  \item \emph{Indicators.} For every \(A\in\Xcal\) the indicator
        \(\indic[x\in A]\) is measurable, and the
        \(\sigma\)-field generated by it is
        \(\{\emptyset,A,A^c,\mathbb{X}\}\subseteq\Xcal\).
  \item \emph{Algebraic operations.} If \(f,g:\mathbb{X}\to\R\) are
        measurable, then so are \(f+g\), \(fg\), \(\max\{f,g\}\) and
        \(\min\{f,g\}\).
  \item \emph{Sequential operations.} If
        \(\{f_i\}_{i=1}^{\infty}\) are measurable functions
        \(\mathbb{X}\to\R\), then
        \(\sup_i f_i\), \(\inf_i f_i\), \(\limsup_i f_i\),
        \(\liminf_i f_i\), and \(\lim_i f_i\) (when it exists pointwise) are
        all measurable.
  \item \emph{Continuity \(\Rightarrow\) measurability.} Every
        continuous function \(f:\R\to\R\) is Borel measurable.
  \item \emph{Generating measurable structure.} Given any family
        \(\{f_i:\mathbb{X}\to\mathbb{Y}\}_{i\in I}\), the smallest
        \(\sigma\)-field on \(\mathbb{X}\) making each \(f_i\)
        measurable is
        \(\sigma(\{f_i\}_{i\in I})=
          \sigma\bigl(\{f_i^{-1}(B):i\in I,\,B\in\Ycal\}\bigr)\).
\end{enumerate}
\end{proposition}

\begin{remark}
The sequential closure in (3) is the reason measure-theoretic
integration interacts so well with limits: it lets us realise any
non-negative measurable \(f\) as the increasing pointwise limit
\(f_i\uparrow f\) of simple functions, e.g.\
\(f_i = 2^{-i}\lfloor 2^{i} f\rfloor\) (truncated above by \(i\)).
This is what powers the construction of the Lebesgue integral in
the next lecture.
\end{remark}

\subsection{Almost-everywhere equality}

The final notion in this lecture lets us ignore behaviour on
\(\mu\)-negligible sets, which is essential once integration enters.

\begin{definition}{Almost everywhere / almost surely}{ae}
Let \((\Omega,\Fcal,\mu)\) be a measure space and
\(f,g:\Omega\to\R\). We say \(f=g\) \emph{almost everywhere}
(written \(f=g\) a.e.) if the exceptional set
\[
N \;=\; \{\omega\in\Omega: f(\omega)\neq g(\omega)\}
\]
satisfies \(\mu(N)=0\). On a probability space this is also called
\emph{almost sure} equality, abbreviated a.s., and one says it holds
\emph{with probability one} (wp1).
\end{definition}

\begin{example}[{Equal almost everywhere on $(0,1]$}]
Let \(((0,1],\Bcal,\lambda)\) be the standard Borel measure space
with Lebesgue measure, and define
\(f(t)=0\) for all \(t\in(0,1]\) and
\[
g(t) \;=\;
\begin{cases}
0 & t\in(0,1]\setminus\Q,\\
1 & t\in(0,1]\cap\Q.
\end{cases}
\]
Then \(f=g\) a.e., because the exceptional set \((0,1]\cap\Q\) is
countable and hence \(\lambda\)-null: enumerating
\(\Q\cap(0,1]=\{q_m\}_{m=1}^{\infty}\) and covering \(q_m\) by
\((q_m-\varepsilon 2^{-m},q_m+\varepsilon 2^{-m+1})\) gives
\(\lambda((0,1]\cap\Q)\le 3\varepsilon\) for every
\(\varepsilon>0\), so \(\lambda((0,1]\cap\Q)=0\).
\end{example}
