Last page built the stage: σ-algebras, and the functions whose preimages land in them. This page is about two moves we'll make constantly from here on. First, taking limits of measurable functions, even when the limits don't exist in the usual sense. Second, building every nonnegative measurable function out of the simplest pieces there are: functions that only take finitely many values. That second move is exactly how the Lebesgue integral gets defined.
Measure theory takes limits all the time, and sequences don't always cooperate. $(-1)^n$ never settles down. But it clearly has a "top" it keeps coming back to and a "bottom" it keeps coming back to. The trick is to stop asking where the sequence goes and ask instead how high its tail can reach.
Chop off the first $k - 1$ terms and take the sup of what's left. Doing that for every $k$ gives a sequence of tail sups, and those can only go down, since each tail is part of the one before it. Its limit is the number we want.
Let $(a_n)$ be a sequence in $[-\infty, \infty]$. Its upper limit and lower limit are $$\limsup_{n \to \infty} a_n = \inf_{k \in \mathbb{N}} \left( \sup_{n \ge k} a_n \right), \qquad \liminf_{n \to \infty} a_n = \sup_{k \in \mathbb{N}} \left( \inf_{n \ge k} a_n \right).$$
Inf of sups, sup of infs. Here's the picture: a window slides along the sequence, and the sup and inf of whatever's still inside the window close in on the two limits.
lim sup is just a pessimist's sup. It refuses to believe anything the sequence did early on.
The early terms don't matter at all. The big first terms set the first few tail sups, and then they fall out of the window for good. Let's do that sequence by hand.
Find $\limsup a_n$ and $\liminf a_n$ for $a_n = (-1)^n\left(1 + \frac{1}{n}\right)$.
The terms are $-2, \frac{3}{2}, -\frac{4}{3}, \frac{5}{4}, -\frac{6}{5}, \ldots$: the even terms $1 + \frac{1}{n}$ are positive and decrease toward $1$, and the odd terms $-(1 + \frac{1}{n})$ are negative and increase toward $-1$.
The tail starting at $n = k$ has its biggest term at its first even index $n$, so $\sup_{n \ge k} a_n = 1 + \frac{1}{n}$ for that $n$. These tail sups are $\frac{3}{2}, \frac{3}{2}, \frac{5}{4}, \frac{5}{4}, \frac{7}{6}, \ldots$, and their inf is $1$. So $\limsup a_n = 1$.
The same way, each tail inf is $-(1 + \frac{1}{n})$ at the tail's first odd index: $-2, -\frac{4}{3}, -\frac{4}{3}, -\frac{6}{5}, \ldots$, with sup $-1$. So $\liminf a_n = -1$.
Neither limit is a term of the sequence. No term equals $1$; the even terms only get close.
That last line is worth holding onto: an upper limit is not a maximum. What it does have is a guarantee that it exists, always, no convergence needed.
Every sequence $(a_n)$ in $[-\infty, \infty]$ has an upper limit and a lower limit, and $\liminf a_n \le \limsup a_n$.
Proof. Every subset of $[-\infty, \infty]$ has a sup and an inf in $[-\infty, \infty]$, so $S_k = \sup_{n \ge k} a_n$ and $I_k = \inf_{n \ge k} a_n$ exist for every $k$, and so do $\inf_k S_k$ and $\sup_k I_k$. As $k$ grows the tail shrinks, so $S_k$ decreases and $I_k$ increases; that's why $\limsup a_n = \lim_k S_k$ and $\liminf a_n = \lim_k I_k$.
For any $j$ and $k$, let $m = \max\{j, k\}$. Then $I_j \le I_m \le a_m \le S_m \le S_k$. So every $I_j$ is at most every $S_k$. Taking the sup over $j$ gives $\liminf a_n \le S_k$ for every $k$, and then taking the inf over $k$ gives $\liminf a_n \le \limsup a_n$. $\blacksquare$
Upper and lower limits are mirror images: flip the sign of every term, and the top becomes the bottom. Prove it; it's the fact that lets you prove anything about $\liminf$ by proving it for $\limsup$.
Show that $\limsup (-a_n) = -\liminf a_n$ for every sequence $(a_n)$ in $[-\infty, \infty]$.
Proof. For any set $E \subseteq [-\infty, \infty]$, $\sup\{-x : x \in E\} = -\inf E$, since negation reverses the order. So for every $k$,
$$\sup_{n \ge k} (-a_n) = -\inf_{n \ge k} a_n.$$
Taking the inf over $k$ and using the same fact once more, $\limsup (-a_n) = \inf_k \left(-\inf_{n \ge k} a_n\right) = -\sup_k \inf_{n \ge k} a_n = -\liminf a_n$. $\blacksquare$
So when does a sequence actually converge? Exactly when the top and the bottom meet. Here "converge" is in $[-\infty, \infty]$: $a_n \to \infty$ means that for every real $M$, eventually $a_n > M$.
A sequence $(a_n)$ in $[-\infty, \infty]$ converges to $L \in [-\infty, \infty]$ if and only if $\liminf a_n = \limsup a_n = L$.
Proof. Write $S_k = \sup_{n \ge k} a_n$ and $I_k = \inf_{n \ge k} a_n$, so $I_k \le a_k \le S_k$, with $I_k$ increasing to $\liminf a_n$ and $S_k$ decreasing to $\limsup a_n$.
($\impliedby$) Suppose both limits equal $L$. If $L$ is real and $\varepsilon > 0$, then eventually $I_k > L - \varepsilon$ and $S_k < L + \varepsilon$, so $|a_k - L| < \varepsilon$. If $L = \infty$, then for every real $M$, eventually $I_k > M$, so $a_k \ge I_k > M$. If $L = -\infty$, the same argument runs with $S_k$.
($\implies$) Suppose $a_n \to L$ with $L$ real, and let $\varepsilon > 0$. Some $N$ has $L - \varepsilon < a_n < L + \varepsilon$ for all $n \ge N$, so $L - \varepsilon \le I_k \le S_k \le L + \varepsilon$ for every $k \ge N$. Both limits lie in $[L - \varepsilon, L + \varepsilon]$ for every $\varepsilon$, so both equal $L$. If $L = \infty$: for every real $M$, eventually $a_n > M$, so eventually $I_k \ge M$. That makes $\liminf a_n = \infty$, and $\limsup a_n \ge \liminf a_n$ forces it to be $\infty$ too. $L = -\infty$ is the mirror image. $\blacksquare$
Convergence in $[-\infty, \infty]$ is more generous than convergence in $\mathbb{R}$, and the theorem tells you exactly how generous.
Which of these converge in $[-\infty, \infty]$: $a_n = n\left(2 + (-1)^n\right)$, and $b_n = (-1)^n n$?
For $a_n$: since $2 + (-1)^n \ge 1$, every term has $a_n \ge n$. So the tail from $k$ on has $\inf_{n \ge k} a_n \ge k$, and these infs go to $\infty$: $\liminf a_n = \infty$. Then $\limsup a_n \ge \liminf a_n$ forces $\limsup a_n = \infty$ too. The limits agree, so $a_n \to \infty$, even though the terms wobble ($1, 6, 3, 12, 5, \ldots$).
For $b_n$: every tail has arbitrarily large even terms and arbitrarily negative odd terms, so every tail sup is $\infty$ and every tail inf is $-\infty$. The limits are $\infty$ and $-\infty$, which disagree, so $(b_n)$ doesn't converge, not even to $\pm\infty$.
The definition is great for proofs and clumsy for computing. Nobody finds $\limsup$ by writing out every tail sup. What you actually do is split the sequence into pieces that each settle down, like the evens and the odds above, and compare where the pieces go. This theorem is why that works.
Let $(a_n)$ be a sequence in $[-\infty, \infty]$ and $L = \limsup a_n$.
So $\limsup a_n$ is the largest limit of a subsequence, and, applying this to $(-a_n)$, $\liminf a_n$ is the smallest.
Proof. Write $S_k = \sup_{n \ge k} a_n$, which decreases to $L$.
(b) If $a_{n_j} \to c$, then for each $k$, $a_{n_j} \le S_k$ as soon as $n_j \ge k$, so $c \le S_k$. Taking the inf over $k$, $c \le L$.
(a) If $L = \infty$, every $S_k$ is $\infty$, so every tail has terms as large as we like: pick $n_1 < n_2 < \cdots$ with $a_{n_j} > j$. If $L = -\infty$, pick $n_1 < n_2 < \cdots$ with $S_{n_j} < -j$; then $a_{n_j} \le S_{n_j} < -j$. If $L$ is real, build $n_1 < n_2 < \cdots$ one at a time: given $n_{j-1}$, choose $k > n_{j-1}$ with $S_k < L + \frac{1}{j}$. Since $S_k \ge L > L - \frac{1}{j}$, some $n_j \ge k$ has $a_{n_j} > L - \frac{1}{j}$, and $a_{n_j} \le S_k < L + \frac{1}{j}$. So $a_{n_j} \to L$.
(c) Each $L_i$ is the limit of a subsequence, so $L_i \le L$ by (b). Conversely, by (a) some subsequence converges to $L$. It has infinitely many indices in some $N_i$, and those terms form a subsequence of the terms indexed by $N_i$, so they converge to $L_i$, and also to $L$. So $L = L_i$, and $L = \max_i L_i$. The statement for $\liminf$ follows by applying this to $(-a_n)$ and the exercise above. $\blacksquare$
Part (c) is the computing tool. For the first example: the evens go to $1$ and the odds to $-1$, so the answers are $\max\{1, -1\} = 1$ and $\min\{1, -1\} = -1$. That's the whole computation. Here it is on two sequences where the tail sups would be a pain.
Find $\limsup$ and $\liminf$ of $a_n = n^{(-1)^n}$ and of $c_n = \sin\!\left(\frac{n\pi}{2}\right) + \frac{1}{n}$.
For $a_n$, split $\mathbb{N}$ into the evens and the odds. The even terms are $a_{2k} = 2k \to \infty$, and the odd terms are $a_{2k+1} = \frac{1}{2k+1} \to 0$. So $\limsup a_n = \max\{\infty, 0\} = \infty$ and $\liminf a_n = \min\{\infty, 0\} = 0$.
For $c_n$, $\sin\left(\frac{n\pi}{2}\right)$ cycles $1, 0, -1, 0$, so split $\mathbb{N}$ by $n \bmod 4$. The four pieces tend to $1$, $0$, $-1$, and $0$, since $\frac{1}{n} \to 0$ on each. So $\limsup c_n = 1$ and $\liminf c_n = -1$.
Now try it live: pick a sequence, drag the window's left edge, and watch the tail's sup and inf.
Now go the other way. Here the sequence is $a_n = \alpha + \beta(-1)^n + \frac{\gamma}{n}$, and you pick $\alpha$, $\beta$, $\gamma$. Each mission is a pair of limits to hit, and the last one asks for a sequence whose upper limit is never reached by any term.
The $\frac{\gamma}{n}$ term never changes either limit; it only decides whether the terms approach the limits from above or from below. Now compute some. Split the sequence into pieces that settle down, then compare.
Loading practice engine...
Limits add: $\lim (a_n + b_n) = \lim a_n + \lim b_n$. Upper limits only half-add, and the gap between the two sides is where a lot of later inequalities come from.
Let $(a_n)$ and $(b_n)$ be sequences in $[-\infty, \infty]$. Show that
$$\limsup (a_n + b_n) \le \limsup a_n + \limsup b_n,$$
provided none of the sums has the form $\infty - \infty$. Then find an example where the inequality is strict.
Proof. Let $A_k = \sup_{n \ge k} a_n$ and $B_k = \sup_{n \ge k} b_n$, decreasing to $A = \limsup a_n$ and $B = \limsup b_n$. If $A + B = \infty$ there's nothing to prove. Otherwise neither $A$ nor $B$ is $\infty$ (if $A = \infty$, then $B \neq -\infty$ by hypothesis, and $A + B = \infty$). Since $A_k$ decreases to $A < \infty$, eventually $A_k < \infty$, and likewise eventually $B_k < \infty$. Fix such a $k$. For every $n \ge k$, $a_n \le A_k$ and $b_n \le B_k$, so $a_n + b_n \le A_k + B_k$, a sum with no $+\infty$ in it. Hence
$$\sup_{n \ge k} (a_n + b_n) \le A_k + B_k.$$
Let $k \to \infty$. The left side decreases to $\limsup (a_n + b_n)$. On the right, if $A$ and $B$ are both real, $A_k + B_k \to A + B$. If one of them, say $A$, is $-\infty$, then $B_k \le B_{k_0} < \infty$ for a fixed $k_0$ and all $k \ge k_0$, so $A_k + B_k \le A_k + B_{k_0} \to -\infty = A + B$. Either way, $\limsup (a_n + b_n) \le A + B$.
Strict example. Let $a_n = (-1)^n$ and $b_n = -a_n$. Then $a_n + b_n = 0$, so the left side is $0$, while $\limsup a_n = \limsup b_n = 1$ makes the right side $2$. The two sequences take turns being big, so their tops never happen at the same time. $\blacksquare$
And one more property, the one you'll use without thinking: inequalities between sequences survive. Strictness doesn't, though ($0 < \frac{1}{n}$, but both have lower limit $0$).
Show that if $a_n \le b_n$ for every $n \in \mathbb{N}$, then $\liminf a_n \le \liminf b_n$.
Proof. Fix $k$. For every $n \ge k$, $\inf_{m \ge k} a_m \le a_n \le b_n$, so $\inf_{m \ge k} a_m$ is a lower bound for the tail $\{b_n : n \ge k\}$, and therefore $\inf_{n \ge k} a_n \le \inf_{n \ge k} b_n$. This holds for every $k$, so the sups over $k$ keep the order: $\liminf a_n \le \liminf b_n$. $\blacksquare$
Now point all of that at functions. A sequence of functions $f_n\colon X \to [-\infty, \infty]$ gives a sequence of numbers $(f_n(x))$ at every single point $x$, and we can take its sup, its upper limit, and so on, one point at a time.
Let $f_n\colon X \to [-\infty, \infty]$ for each $n \in \mathbb{N}$. The functions $\sup_n f_n$, $\inf_n f_n$, $\limsup f_n$, and $\liminf f_n$ are defined pointwise: $$\left(\sup_n f_n\right)(x) = \sup_n f_n(x), \qquad \left(\limsup_{n \to \infty} f_n\right)(x) = \limsup_{n \to \infty} f_n(x),$$ and likewise for $\inf_n f_n$ and $\liminf f_n$. If $f_n(x)$ converges for every $x \in X$, the function $f(x) = \lim_{n \to \infty} f_n(x)$ is the pointwise limit of $(f_n)$.
The good news is that measurability survives every one of these. The reason is short: "the sup is bigger than $a$" means "some $f_n$ is bigger than $a$", and that's a countable union.
Let $(X, \mathcal{M})$ be a measurable space and let each $f_n\colon X \to [-\infty, \infty]$ be measurable. Then $\sup_n f_n$, $\inf_n f_n$, $\limsup f_n$, and $\liminf f_n$ are measurable.
Proof. Let $g = \sup_n f_n$ and $a \in \mathbb{R}$. A sup is bigger than $a$ exactly when one of the numbers is, so
$$g^{-1}((a, \infty]) = \bigcup_{n=1}^{\infty} f_n^{-1}((a, \infty]),$$
a countable union of members of $\mathcal{M}$. By the $(a, \infty]$ test, $g$ is measurable.
Next, if $h\colon X \to [-\infty, \infty]$ is measurable, so is $-h$: $(-h)^{-1}((a, \infty]) = h^{-1}([-\infty, -a))$, the preimage of an open set. Then $\inf_n f_n = -\sup_n (-f_n)$ is measurable.
Finally, each $g_k = \sup_{n \ge k} f_n$ is measurable by the first step, so $\limsup f_n = \inf_k g_k$ is measurable by the second. And $\liminf f_n = -\limsup (-f_n)$, by the exercise above, applied at each point. $\blacksquare$
Sup and upper limit of functions can be very different, because the upper limit forgets anything that happens only finitely often at a point.
On $\mathbb{R}$, let $f_n = \chi_{[n, n+1)}$, which is $1$ on $[n, n+1)$ and $0$ elsewhere. Find $\sup_n f_n$ and $\limsup f_n$.
Fix $x$. If $x \ge 1$, then $x$ lies in exactly one interval $[n, n+1)$, so the sequence $(f_n(x))$ is $0, \ldots, 0, 1, 0, 0, \ldots$, with a single $1$. If $x < 1$, it's all $0$s.
So $\sup_n f_n(x) = 1$ for $x \ge 1$ and $0$ for $x < 1$: $\sup_n f_n = \chi_{[1, \infty)}$. But every tail of $(f_n(x))$ is eventually all $0$s, so $\limsup f_n = 0$ everywhere, and the $f_n$ converge pointwise to $0$. The block slides off to infinity, and at each point it passes by only once.
Compare that with continuity. A limit of continuous functions can fail to be continuous. Here's the standard example, $x^n$ on $[0, 1]$, and watch what happens at the right end.
Each $x^n$ is continuous, and the limit jumps from $0$ to $1$ at $x = 1$. Continuity broke. Measurability can't break that way: when the limit exists, it's the upper limit, and the upper limit is measurable. That gives the corollary you'll quote most often.
Let $(X, \mathcal{M})$ be a measurable space.
Proof. (a) At each $x$ the sequence $(f_n(x))$ converges, so its limit is its upper limit, by the convergence theorem above. So $f = \limsup f_n$, which is measurable.
(b) Write $f_n = u_n + i v_n$ and $f = u + iv$. Each $u_n = \operatorname{Re} f_n$ is real measurable (the corollary on complex measurable functions, last page). At each point $u_n(x) \to u(x)$, so $u = \limsup u_n$ is measurable by part (a). It's real-valued, and an open subset of $\mathbb{R}$ is open in $[-\infty, \infty]$, so $u$ is real measurable. The same goes for $v$, and then $f = u + iv$ is measurable by that corollary again. $\blacksquare$
Notice the hypothesis: the $f_n$ themselves have to be measurable; a limit can't manufacture measurability out of nothing. There's one more hidden hypothesis, and it's the reason σ-algebras insist on countable unions.
The sup result needs countably many functions. With uncountably many it fails. Let $V \subseteq \mathbb{R}$ be a set that isn't Borel, and for each $t \in V$ let $f_t = \chi_{\{t\}}$, which is $1$ at $t$ and $0$ everywhere else. Each $f_t$ is Borel measurable, but $\sup_{t \in V} f_t$ is $1$ on $V$ and $0$ off it, and that isn't measurable. The proof above broke at the union $\bigcup_t \{f_t > a\}$, which is no longer countable.
That uses the indicator notation $\chi$ a little early; it gets its own definition in a minute.
A max of two functions is a sup of a sequence in disguise: just repeat the second function forever. So maxes and mins come for free.
Show that if $f, g\colon X \to [-\infty, \infty]$ are measurable, then so are $\max\{f, g\}$ and $\min\{f, g\}$.
Proof. Let $f_1 = f$ and $f_n = g$ for every $n \ge 2$. At each point, $\sup_n f_n(x) = \max\{f(x), g(x)\}$, so $\max\{f, g\} = \sup_n f_n$ is measurable. And $\min\{f, g\} = -\max\{-f, -g\}$, where $-f$ and $-g$ are measurable, as in the proof above. $\blacksquare$
The most useful max of all is the max with $0$. It splits any function into a part that sits above the axis and a part that sits below it.
Let $f\colon X \to [-\infty, \infty]$. The positive part and negative part of $f$ are $$f^+ = \max\{f, 0\}, \qquad f^- = -\min\{f, 0\}.$$
Watch out for the sign in $f^-$: both parts are nonnegative. Here's the split.
At each point one of the two parts is $0$, so there's never an $\infty - \infty$, and
$$f = f^+ - f^-, \qquad |f| = f^+ + f^-.$$
By the exercise, $f^+$ and $f^-$ are measurable whenever $f$ is. This is how the Lebesgue integral will handle functions that take both signs: integrate each part, which is nonnegative, then subtract. There are lots of other ways to write $f$ as a difference of two nonnegative functions. Here's one next to the parts.
Find $f^+$ and $f^-$ for $f(x) = x^2 - 1$ on $\mathbb{R}$, and compare them with the split $f = g - h$, where $g(x) = x^2$ and $h(x) = 1$.
$f \ge 0$ exactly when $|x| \ge 1$. So $f^+(x) = x^2 - 1$ for $|x| \ge 1$ and $0$ for $|x| < 1$, while $f^-(x) = 1 - x^2$ for $|x| < 1$ and $0$ for $|x| \ge 1$.
The other split uses $g = x^2$ and $h = 1$, both nonnegative. Compare: $f^+ \le g$ and $f^- \le h$ everywhere. At $x = 0$, for instance, $f^+(0) = 0 \le 0 = g(0)$ and $f^-(0) = 1 \le 1 = h(0)$; at $x = 2$, $f^+(2) = 3 \le 4 = g(2)$ and $f^-(2) = 0 \le 1 = h(2)$. The parts are never bigger, and that's no accident.
The parts are the most economical split there is.
If $f = g - h$ with $g, h\colon X \to [0, \infty]$ (never $\infty - \infty$), then $f^+ \le g$ and $f^- \le h$.
Proof. Since $h \ge 0$, $f = g - h \le g$, and $0 \le g$. So $f^+ = \max\{f, 0\} \le g$. In the same way $-f = h - g \le h$ and $0 \le h$, and $f^- = -\min\{f, 0\} = \max\{-f, 0\} \le h$. $\blacksquare$
So any other split pays for extra on both sides: if $f = g - h$, then $g - f^+ = h - f^-$ is the same extra amount added to both. That's why $f^+$ and $f^-$ are the split everyone uses.
Here are the building blocks. A Riemann sum is built from step functions on intervals. The Lebesgue version drops the intervals and keeps only the "finitely many values" part.
A function $s\colon X \to \mathbb{C}$ is a simple function if its range $s(X)$ is a finite set.
That's all: finitely many values. No continuity, no intervals, no measurability (that's a separate question). The simplest simple functions take one value on a set and $0$ off it.
Let $A \subseteq X$. The characteristic function of $A$ is $\chi_A\colon X \to \mathbb{C}$, $$\chi_A(x) = \begin{cases} 1, & x \in A, \\ 0, & x \notin A. \end{cases}$$
Say it "chi A". Here's the most famous one, an old friend.
Is $\chi_{\mathbb{Q}}\colon \mathbb{R} \to \mathbb{C}$ simple? Is it Borel measurable?
It takes only the values $0$ and $1$, so it's simple, even though it jumps at every single point.
For measurability, look at preimages of an open set $V \subseteq \mathbb{C}$: $\chi_{\mathbb{Q}}^{-1}(V)$ is $\mathbb{R}$ if $V$ contains both $0$ and $1$, $\mathbb{Q}$ if it contains only $1$, $\mathbb{R} \setminus \mathbb{Q}$ if it contains only $0$, and $\emptyset$ if it contains neither. $\mathbb{Q}$ is a countable union of points, so it's Borel, and so is its complement. So yes, $\chi_{\mathbb{Q}}$ is Borel measurable.
This is the function from the very first animation on σ-Algebras & Measurable Functions, the one whose Riemann upper and lower sums never meet. It's about to become the easiest function there is to integrate.
The example's argument works for any set $A$, and it's worth recording, because it says exactly when an indicator is measurable.
Two values. Two! And it still broke the Riemann integral. Simple is not the same as easy.
Let $(X, \mathcal{M})$ be a measurable space and $A \subseteq X$. Then $\chi_A$ is measurable if and only if $A \in \mathcal{M}$.
Proof. For an open $V \subseteq \mathbb{C}$, $\chi_A^{-1}(V)$ is $X$, $A$, $A^c$, or $\emptyset$, depending on which of $0$ and $1$ lie in $V$. If $A \in \mathcal{M}$, all four are in $\mathcal{M}$, so $\chi_A$ is measurable. Conversely, if $\chi_A$ is measurable, take $V$ the open disc of radius $\frac{1}{2}$ about $1$: then $A = \chi_A^{-1}(V) \in \mathcal{M}$. $\blacksquare$
So a set you can't measure gives a simple function you can't measure. Keep that in mind while you sort these: the only thing "simple" asks is how many values.
Drag each function into a bin.
The ones that trip people up are bounded functions like $\arctan$, which aren't simple, and wildly jumpy ones like $\chi_{\mathbb{Q}}$, which are. Now pick them out of a lineup.
Loading practice engine...
Every simple function is a sum of characteristic functions, and there's one best way to write it: one term per value.
Let $s\colon X \to \mathbb{C}$ be simple, with distinct values $\alpha_1, \ldots, \alpha_n$, and let $A_i = s^{-1}(\{\alpha_i\})$. Then the sets $A_1, \ldots, A_n$ are pairwise disjoint, their union is $X$, and
$$s = \sum_{i=1}^{n} \alpha_i \chi_{A_i}.$$
This is the canonical form of $s$. If $(X, \mathcal{M})$ is a measurable space, $s$ is measurable if and only if every $A_i \in \mathcal{M}$.
Proof. Each $x \in X$ has exactly one value $s(x)$, which is exactly one of the $\alpha_i$, so $x$ lies in exactly one $A_i$. That makes the $A_i$ pairwise disjoint with union $X$. If $x \in A_j$, every term of the sum vanishes at $x$ except $\alpha_j \chi_{A_j}(x) = \alpha_j = s(x)$.
($\implies$) If $s$ is measurable: $\mathbb{C} \setminus \{\alpha_i\}$ is open, so its preimage $X \setminus A_i$ is in $\mathcal{M}$, and so is $A_i$.
($\impliedby$) If every $A_i \in \mathcal{M}$ and $V \subseteq \mathbb{C}$ is open, then $x \in s^{-1}(V)$ exactly when the value of $x$ lies in $V$, so
$$s^{-1}(V) = \bigcup_{i \,:\, \alpha_i \in V} A_i,$$
a finite union of members of $\mathcal{M}$. $\blacksquare$
Notice the order: "simple" comes first, and measurability is a separate check on the level sets. $\chi_A$ for a non-measurable $A$ is simple, and no choice of measurable sets will write it. Simple functions usually arrive written some other way, as a sum over overlapping sets, and then you have to rewrite them.
Write $s = 2\chi_{[0, 3)} + 3\chi_{[2, 5)}$ on $\mathbb{R}$ in canonical form.
Cut $\mathbb{R}$ at the endpoints $0, 2, 3, 5$ and add up the coefficients on each piece:
So the values are $0, 2, 3, 5$, and
$$s = 2\chi_{[0, 2)} + 5\chi_{[2, 3)} + 3\chi_{[3, 5)} + 0 \cdot \chi_{(-\infty, 0) \cup [5, \infty)}.$$
The last term is $0$, so it's usually left off. The value $5$ wasn't a coefficient anywhere in the original sum; it only shows up where the intervals overlap.
Here's that rewrite as a picture: the two blocks stack, and then the stack gets re-cut into pieces of constant height.
Build your own. Stretch the intervals, change the coefficients, and watch the canonical form re-cut itself. The missions are about the things that surprise people: values that cancel, and level sets that come in more than one piece.
Now read off a level set. Cut at the endpoints, add the coefficients, and collect the pieces with the value you're asked about. Watch the endpoints: open or closed matters.
Loading practice engine...
The cut-and-add move is also how you show simple functions are closed under arithmetic.
Let $s$ and $t$ be simple measurable functions on $(X, \mathcal{M})$. Show that $s + t$ and $st$ are simple measurable functions. If $s$ takes $n$ values and $t$ takes $m$ values, how many values can $s + t$ take?
Proof. Write both in canonical form, $s = \sum_{i=1}^{n} \alpha_i \chi_{A_i}$ and $t = \sum_{j=1}^{m} \beta_j \chi_{B_j}$. The sets $A_i \cap B_j$ are in $\mathcal{M}$, pairwise disjoint, and cover $X$, and on $A_i \cap B_j$ we have $s + t = \alpha_i + \beta_j$ and $st = \alpha_i \beta_j$. So each function takes at most $nm$ values, and each of its level sets is a union of some of the sets $A_i \cap B_j$, so it's in $\mathcal{M}$. By the canonical form proposition, both are measurable.
So $s + t$ takes at most $nm$ values, and $nm$ can happen: on a set of $nm$ points labeled $(i, j)$, take $s(i, j) = i$ and $t(i, j) = nj$ for $0 \le i < n$ and $0 \le j < m$. Then $s + t = i + nj$ takes all $nm$ values $0, 1, \ldots, nm - 1$. $\blacksquare$
Here's the payoff. Every nonnegative measurable function, however wild, is an increasing limit of simple measurable functions. The idea is Lebesgue's: don't chop up the domain, chop up the range. Slice $[0, \infty]$ into levels of height $2^{-n}$, round every value down to the level below it, and lump everything above $n$ into the top level. That rounding is one fixed function of the value, the same for every $f$.
For $n \in \mathbb{N}$, the staircase function $\varphi_n\colon [0, \infty] \to [0, \infty)$ is $$\varphi_n(t) = \begin{cases} \dfrac{\lfloor 2^n t \rfloor}{2^n}, & 0 \le t < n, \\[1ex] n, & n \le t \le \infty. \end{cases}$$
Here $\lfloor x \rfloor$ is the floor, the largest integer at most $x$. Each new $n$ makes the steps half as tall and raises the ceiling by one. Watch the staircases climb toward the diagonal $y = t$.
Every step splits in two, and both halves sit at or above the old step, so the staircases never go down. Here are the numbers at one value of $t$.
Compute $\varphi_n(1.3)$ for $n = 1, \ldots, 5$, and $\varphi_n(\infty)$.
For $n = 1$, $1.3 \ge 1$, so the cap applies: $\varphi_1(1.3) = 1$.
For $n \ge 2$, $1.3 < n$, so round $2^n \cdot 1.3$ down:
The values $1, 1.25, 1.25, 1.25, 1.28125$ never go down and creep up toward $1.3$. They can stall for a while (the next level up just hadn't been reached yet), but never decrease. And $\varphi_n(\infty) = n$ for every $n$, which climbs to $\infty$.
Those three behaviors (never decreasing, staying at or below $t$, and converging) hold everywhere. They're what the theorem needs, so let's prove them once, about $\varphi_n$ alone.
For every $n \in \mathbb{N}$:
Proof. (a) The values of $\varphi_n$ are the multiples $\frac{k}{2^n}$ with $0 \le k \le n2^n$, finitely many. For measurability, use the $(a, \infty]$ test. If $a < 0$, then $\varphi_n^{-1}((a, \infty]) = [0, \infty]$; if $a \ge n$, it's $\emptyset$, since $\varphi_n \le n$. If $0 \le a < n$, pick the whole number $m$ with $\frac{m}{2^n} \le a < \frac{m+1}{2^n}$; then $\frac{m+1}{2^n} \le n$. The values of $\varphi_n$ are multiples of $\frac{1}{2^n}$, so $\varphi_n(t) > a$ exactly when $\varphi_n(t) \ge \frac{m+1}{2^n}$, which happens exactly when $t \ge \frac{m+1}{2^n}$. So
$$\varphi_n^{-1}((a, \infty]) = \left[\tfrac{m+1}{2^n}, \infty\right],$$
a closed set. In every case the preimage is a Borel set.
(b) If $t < n$, then $\lfloor 2^n t \rfloor \le 2^n t$ gives $\varphi_n(t) \le t$; if $t \ge n$, $\varphi_n(t) = n \le t$. For the monotonicity there are three cases. If $t < n$, write $k = \lfloor 2^n t \rfloor$. Then $2^{n+1} t \ge 2k$, so $\lfloor 2^{n+1} t \rfloor \ge 2k$ and $\varphi_{n+1}(t) \ge \frac{2k}{2^{n+1}} = \varphi_n(t)$. If $n \le t < n + 1$, then $\varphi_{n+1}(t) = \frac{\lfloor 2^{n+1} t \rfloor}{2^{n+1}} \ge \frac{2^{n+1} n}{2^{n+1}} = n = \varphi_n(t)$. If $t \ge n + 1$, then $\varphi_{n+1}(t) = n + 1 > \varphi_n(t)$.
(c) If $t < n$, then $2^n t - 1 < \lfloor 2^n t \rfloor \le 2^n t$; dividing by $2^n$ gives $0 \le t - \varphi_n(t) < 2^{-n}$. For a real $t$, this holds for every $n > t$, so $\varphi_n(t) \to t$. For $t = \infty$, $\varphi_n(\infty) = n \to \infty$. $\blacksquare$
All the work is done. Now feed $f$ into the staircase.
Let $(X, \mathcal{M})$ be a measurable space and $f\colon X \to [0, \infty]$ measurable. Then there are simple measurable functions $s_n\colon X \to [0, \infty)$ such that
One choice is $s_n = \varphi_n \circ f$.
Proof. Let $s_n = \varphi_n \circ f$. By the lemma, $\varphi_n$ is Borel measurable, so $s_n$ is measurable (a Borel measurable function after a measurable one, last page's composition rule). Its values are among the finitely many values of $\varphi_n$, so $s_n$ is simple. At each $x$, apply the lemma with $t = f(x)$: part (b) gives $0 \le s_n(x) \le s_{n+1}(x)$ and $s_n(x) \le f(x)$, and part (c) gives $s_n(x) \to f(x)$. $\blacksquare$
Here's one $s_n$ written out completely, so you can see what its level sets look like.
Let $f(x) = x$ on $X = [0, 3]$. Write $s_2 = \varphi_2 \circ f$ in canonical form.
For $x < 2$, $s_2(x) = \frac{\lfloor 4x \rfloor}{4}$, which is $\frac{k}{4}$ exactly when $\frac{k}{4} \le x < \frac{k+1}{4}$, for $k = 0, 1, \ldots, 7$. For $x \ge 2$, the cap applies and $s_2(x) = 2$. So
$$s_2 = \sum_{k=0}^{7} \frac{k}{4}\, \chi_{[k/4, \, (k+1)/4)} + 2\chi_{[2, 3]}.$$
Each level set is $f^{-1}$ of the stretch of values that rounds to that level: $s_2^{-1}(\{\frac{k}{4}\}) = f^{-1}\left([\frac{k}{4}, \frac{k+1}{4})\right)$ and $s_2^{-1}(\{2\}) = f^{-1}([2, \infty])$. Nine values, nine level sets, and the biggest gap below the cap is just under $\frac{1}{4}$.
So the staircase is built on the range and then pulled back to the domain: each level set of $s_n$ is $f^{-1}$ of an interval of values. That's exactly where measurability of $f$ gets used. Here it is on a function with a tall peak, so you can see the cap at $n$ rise.
Every nonnegative measurable function is secretly a staircase that hasn't finished being built.
Two things to notice. Below the cap, $s_n$ is never more than $2^{-n}$ under $f$. Above it, the gap can be huge, which matters when $f$ is unbounded. Try it with your own $f$.
The convergence in the theorem happens one point at a time. Pick a single point and follow the numbers $s_1(x), s_2(x), \ldots$ there, including at a point where $f = \infty$.
Your turn with the numbers. First check whether the cap applies; if not, multiply by $2^n$, round down, and divide back.
Loading practice engine...
The Staircase widget's readout hinted at this one: when $f$ is bounded, the cap stops mattering, and the convergence becomes uniform.
Show that if $f\colon X \to [0, \infty]$ is measurable and bounded, then $s_n = \varphi_n \circ f$ converges to $f$ uniformly on $X$. Then show that uniform convergence fails for $f(x) = x$ on $[0, \infty)$.
Proof. Say $f \le M$ with $M$ real. For every $n > M$ and every $x$, $f(x) < n$, so part (c) of the lemma gives $0 \le f(x) - s_n(x) < 2^{-n}$. So $\sup_x |f(x) - s_n(x)| \le 2^{-n} \to 0$.
For $f(x) = x$ on $[0, \infty)$: at $x = 2n$, $s_n(x) = n$, so $f(x) - s_n(x) = n$. So $\sup_x |f(x) - s_n(x)| \ge n$ for every $n$, which doesn't go to $0$. $\blacksquare$
On the Lebesgue Integral page, a simple measurable $s = \sum \alpha_i \chi_{A_i} \ge 0$ gets the obvious integral $\sum \alpha_i \, \mu(A_i)$: value times size, added up. Then $\int f \, d\mu$ for $f \ge 0$ is the sup of $\int s \, d\mu$ over simple $s$ with $0 \le s \le f$. This page's theorem promises that such $s$ can get as close to $f$ as we like, and the Monotone Convergence Theorem will say that $\int s_n \, d\mu \to \int f \, d\mu$.
That's the toolkit for building the integral: limits that always exist, measurability that survives them, and staircases that reach every nonnegative function from below.
Every question so far came right after its idea, which is a hint. Down here the hint is gone. First, true or false: a claim about anything on this page, some of them the kind that sounds right and isn't. Decide, then read why.
Loading practice engine...
Next, a proof from this page with one step missing.
Loading practice engine...
Next, the mixed set. Every question type on this page except true or false goes into one hat, and each click draws a new one at random. Flip the switch to type your answer; a few types need their answer choices, and they'll say so.
Loading practice engine...
Last, the Spicy Bonus. A sequence of measurable functions can converge at some points and not others. The set where it converges is measurable, and proving that takes everything on this page.
The last exercise on σ-Algebras & Measurable Functions showed that $\{f < g\}$ and $\{f = g\}$ are measurable for measurable $f$ and $g$. That's one way in.
Let $f_n\colon X \to \mathbb{R}$ be measurable for each $n \in \mathbb{N}$. Prove that the set of points $x$ at which $(f_n(x))$ converges to a finite limit is measurable.
Proof. Call the set $E$. A sequence of real numbers converges to a finite limit exactly when it's Cauchy: for every $k \in \mathbb{N}$ there is an $N$ with $|f_m(x) - f_n(x)| < \frac{1}{k}$ for all $m, n \ge N$. Translating each quantifier into a set operation ("for every" is an intersection, "there is" a union),
$$E = \bigcap_{k=1}^{\infty} \, \bigcup_{N=1}^{\infty} \, \bigcap_{m, n \ge N} \left\{x : |f_m(x) - f_n(x)| < \tfrac{1}{k}\right\}.$$
Each $f_m - f_n$ is real measurable (sums of measurable functions are measurable, by last page's corollary on complex measurable functions), so each set inside is $(f_m - f_n)^{-1}\left((-\tfrac{1}{k}, \tfrac{1}{k})\right) \in \mathcal{M}$. All three operations are over countable index sets, so $E \in \mathcal{M}$.
Another route. Let $g = \limsup f_n$ and $h = \liminf f_n$, measurable maps into $[-\infty, \infty]$ by this page's theorem. By the convergence theorem, $(f_n(x))$ converges to a finite limit exactly when $g(x) = h(x)$ and that common value is finite, so
$$E = \{g = h\} \cap g^{-1}([-\infty, \infty)) \cap h^{-1}((-\infty, \infty]).$$
The first set is measurable by the last exercise on the σ-Algebras page, and the other two are preimages of open sets. $\blacksquare$