\documentclass[12pt,a4paper]{book}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{wasysym}
\usepackage{ulsy}


\begin{document}

\newtheorem{thm}{Theorem}[section]
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\theoremstyle{remark}
\newtheorem{rem}[thm]{Remark}
\theoremstyle{definition}
\newtheorem{Def}[thm]{Definition}
\newtheorem{exercise}[thm]{Exercise}
\newtheorem{example}[thm]{Example}

\setcounter{chapter}{3}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{The Lebesgue Integral}

\section{Measurable functions}
\begin{Def}
\label{measurable_function}
Let $\mathbb{X}$ and $\mathbb{Y}$ be arbitrary sets and let $\mathfrak{S}_\mathbb{X}$ and $\mathfrak{S}_\mathbb{Y}$ be the systems of their subsets. An abstract function $f: \mathbb{X} \to \mathbb{Y}$ is called ($\mathfrak{S}_\mathbb{X}, \mathfrak{S}_\mathbb{Y}$)-measurable if $A \in \mathfrak{S}_\mathbb{Y}$ implies that $f^{-1}(A) \in \mathfrak{S}_\mathbb{X}$.
\end{Def}

Note that although one says "measurable", there is no measures in the Definition \ref{measurable_function}. \\
For instance, if we let $\mathbb{X} := \mathbb{R}^1$, $\mathbb{Y} := \mathbb{R}^1$ and $\mathfrak{S}_\mathbb{X}$, $\mathfrak{S}_\mathbb{Y}$ be the systems of all open sets then a function $f : \mathbb{R}^1 \to \mathbb{R}^1$ is measurable iff it is continuous. \\
But one usually can assign measures on $\mathfrak{S}_\mathbb{X}$ and $\mathfrak{S}_\mathbb{Y}$ and, as you guess, the most interesting case is when  $\mathfrak{S}_\mathbb{X}$ and $\mathfrak{S}_\mathbb{Y}$ are the $\sigma$-algebras. \\ 

The idea of measurable function is critical for the theory of the Lebesgue integral as well as for probabability theory. 

\begin{Def}
\label{mu_measurable_function}
Consider a measure space, i.e. a triple $(\mathbb{X}, \mathcal{A}, \mu)$, where $\mathbb{X}$ is an abstract space, $\mathcal{A}$ is a $\sigma$-algebra of subsets of $\mathbb{X}$ and $\mu$ is a measure on $\mathcal{A}$. \\
A real function $f: \mathbb{X} \to \mathbb{R}$ is called $\mu$-measurable if for any Borel(!) set $A \subset \mathbb{R}$ holds that $f^{-1}(A) \in \mathcal{A}$ 
\end{Def}

\begin{rem}
if $\mathbb{X}$ if a probability space then $f$ is a [real valued] random variable, its $\mu$-measurability means that for every Borel set on $\mathbb{R}$ there is an event in $\mathcal{A}$. 
The converse is not necessarily true, i.e. there may be an event $E \in \mathcal{A}$ such that $f(E) \subset \mathbb{R}$ is not a Borel set.
\end{rem}

In what follows I will usually write "measurable" instead of "$\mu$-measurable" unless it causes a confusion. \\

Using only the ideas from Real Analysis it is hard (though possible) to construct an non-measurable function. But if we engage very basic probability theory then here is a simple and very edifying example. Let us toss a coin two times. If we obtain head twice I pick 2\$ otherwise I get nothing. If, in turn, there is a head at the 1st toss, you pick 1\$ (the second toss is irrelevant for you). Denote our probability space as $\Omega$. The powerset of $\Omega$ is the $\sigma$-algebra, which contains all events, i.e. 
$$
\mathcal{P}(\Omega) = 
	\{ \Omega, \varnothing, HT, HH, TH, TT, \{HH \cup HT\}, \{TH \cup TT\} \}
$$
  So my profit is a mapping $G: \Omega \to R$ and yours is $\bar{G}: \Omega \to R$. 
Both mappings are measurable w.r.t. $\mathcal{P}(\Omega)$.
However, if we are given only an information about the 1st toss, we can describe it as the following $\sigma$-algebra
$$
	\mathcal{A} := \{ \Omega, \varnothing, \{HH \cup HT\}, \{TH \cup TT\} \} 
$$
$\bar{G}$ is measurable w.r.t. $(\Omega, \mathcal{A})$ but $G$ is not.
Indeed, consider an event that my profit is more than 1\$. 
The set $G^{-1}((1, \infty)) = \{\omega : G > 1\} = HH$ is not in $\mathcal{A}$, whereas $(1, \infty)$ is obviously a Borel set. \\
Note, if we e.g. consider an event that I got more than 2\$ then  $G^{-1}((2, \infty)) = \{\omega : G > 2\} = \varnothing$ is in $\mathcal{A}$. But as you remember, according to the Definition \ref{measurable_function} any(!) Borel set must have a counterpart in $\mathcal{A}$.






 
 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
