Why the Riemann integral is not enough
The Riemann integral is built for continuous functions on intervals, and it behaves badly under limits. Enumerate the rationals of as and let be the indicator of . Each is Riemann integrable with integral , the sequence increases, and its pointwise limit is the Dirichlet function , whose upper Riemann sums are all and lower sums all . A monotone limit of integrable functions with integrals has no Riemann integral.
This is not a curiosity. Fourier series, solutions of differential equations and probability all produce functions as limits, and analysis needs a space of integrable functions that is complete: Cauchy sequences should converge to something integrable. Henri Lebesgue's thesis (1902) supplied it. His idea, in his own later image, is the shopkeeper's: to count the takings, do not add coins in the order they arrived (the Riemann sum over the domain); sort them by value and multiply each value by how many coins have it. For a function, that means slicing the range and asking for the size of each set . That requires a notion of size — a measure — for sets far wilder than intervals.
Slicing the range
For a hump-shaped function the two pictures give the same number. They part ways for wild functions. For the Dirichlet function, the vertical strips never settle down, but the horizontal picture is easy: the set where is for , a countable set, and a countable set ought to have size . So the Lebesgue integral of the Dirichlet function is .
Three questions organise the subject. Which sets get a size? Not all of them: Vitali's construction below produces a subset of that cannot be given any translation-invariant, countably additive length. How do we build the size function? By approximating from outside with countably many intervals (outer measure) and keeping the sets that split every other set additively (Carathéodory). What do we gain? Countable additivity of the measure becomes, for integrals, the convergence theorems: under monotonicity or domination, .
σ-algebras, measures and the integral
Definition— σ-algebra and measure
A σ-algebra on a set is a collection of subsets of containing and closed under complements and countable unions (hence also countable intersections). A measure on is a function with that is countably additive: for pairwise disjoint . The triple is a measure space; it is finite if , a probability space if , and σ-finite if is a countable union of sets of finite measure.
From countable additivity: is monotone, countably subadditive ( for any ), continuous from below ( implies ), and continuous from above when . The Borel σ-algebra of a topological space is the smallest σ-algebra containing the open sets. A property holds almost everywhere (a.e.) if it fails only on a set of measure , a null set.
Definition— outer measure and Carathéodory measurability
An outer measure on is a function with , monotone, and countably subadditive. A set is -measurable if it splits every set additively:
Lebesgue outer measure on is , the infimum over countable covers by open intervals.
Definition— measurable function and the integral
A function is measurable if for every . A simple function is a finite combination with ; for (with the disjoint), , with . For measurable ,
A real measurable is integrable, , if , and then where .
Every measurable is the increasing limit of the simple functions
which round down to the dyadic grid of mesh and cap it at . This is the "slice the range" picture made precise.
Definition— Lᵖ spaces
For let , and let (the essential supremum). Then is the space of measurable with , with functions equal almost everywhere identified. Without the identification, is only a seminorm: .
Hölder's inequality for , and Minkowski's inequality , follow from Young's inequality (Folland, §6.1); Minkowski makes a norm on .
Constructing Lebesgue measure
Theorem— Carathéodory's theorem
Let be an outer measure on . The -measurable sets form a σ-algebra , and the restriction of to is a measure. Moreover every set with is in (the measure is complete).
Proof
By subadditivity always, so is measurable as soon as for all . The definition is symmetric in and , so is closed under complements. If then and , so .
Finite unions. Let and . Splitting by and then both pieces by ,
The first three sets have union , so by subadditivity their measures sum to at least ; the last set is . Hence , and is an algebra.
Countable disjoint unions. Let be disjoint, and . Splitting by gives , so by induction . Since and ,
Let and use subadditivity once more:
All are equalities. So , and taking gives : countable additivity. An arbitrary countable union in equals the disjoint union of , which lie in the algebra ; so is a σ-algebra.
∎
Theorem— Theorem (outer measure of an interval)
for all . Consequently is the length of every bounded interval .
Proof
The cover by the single interval gives for every . Conversely let . By the Heine–Borel theorem finitely many of these intervals already cover . Choose one, , containing . If , then lies in another chosen interval , with . Continue. The right endpoints strictly increase, so the chosen intervals are distinct members of the finite subcover, and after some steps . Then
because each . Taking the infimum over covers, . A bounded interval with endpoints lies between and , so by monotonicity its outer measure is its length.
∎
Theorem— Theorem (Borel sets are Lebesgue measurable)
Every half-line is -measurable. Hence every Borel set is, and Lebesgue measure , the restriction of to the Carathéodory σ-algebra , satisfies for every interval.
Proof
Let with and , and cover by open intervals with . Each splits into the intervals and , whose lengths add up to and which equal their outer measures by the previous theorem. By monotonicity and subadditivity,
So is measurable. The half-lines generate : writing , an open interval is the countable union , and every open set is a countable union of open intervals. Since is a σ-algebra containing the half-lines, .
∎
The same recipe — a premeasure on an algebra of simple sets, extended by outer measure and Carathéodory — builds Lebesgue measure on (from boxes), Lebesgue–Stieltjes measures for increasing right-continuous (the distributions of probability), product measures, and Hausdorff measures. Lebesgue measure is translation invariant, and up to a constant factor it is the only translation-invariant measure on that is finite on bounded sets.
Null sets, a non-measurable set, and escaping mass
Example— Countable sets are null; so is the Cantor set
A singleton lies in , so , and by countable subadditivity every countable set is null. In particular , so .
The converse fails. The Cantor set , where is obtained from by removing open middle thirds times, is a union of intervals of length at stage ; so for every , and . Yet consists of the numbers with a ternary expansion using only the digits and , and the map from to is injective, so . Since every subset of is null, hence Lebesgue measurable, has elements while has only : there are Lebesgue measurable sets that are not Borel.
Example— Small open dense sets
Enumerate and let . Then is open and dense, and . Topologically is "large" (its complement is nowhere dense), measure-theoretically it is small. Intersecting such sets for gives a dense set of measure zero: is the union of a meagre set and a null set.
Example— Vitali's non-measurable set (uses the axiom of choice)
Call equivalent if . Using the axiom of choice, pick one point from each equivalence class to form . For rationals the translates are pairwise disjoint and cover . If were measurable, each would be measurable with (translation invariance, applied piecewise), and countable additivity would give , which is or . Contradiction. So no measure on all of can be translation invariant, countably additive and give measure : σ-algebras are a necessity, not a fussiness.
Example— Mass that escapes
Three sequences on with Lebesgue measure, each converging to at every point:
- (mass escapes upwards): for all ;
- (mass escapes to infinity): ;
- (mass spreads out): , even though uniformly.
In each case . None is monotone, and none has an integrable dominating function: near , and for large are not integrable. Fatou's lemma, proved below, says that the inequality is all that survives in general: mass can be lost in the limit, never created.
The convergence theorems
Throughout, is a measure space. Two facts follow at once from the definitions: the integral is monotone ( implies ), and for a simple the map is a measure on , hence continuous from below.
Theorem— Monotone convergence theorem (Beppo Levi, 1906)
If are measurable and pointwise, with , then .
Proof
The limit is measurable, since . By monotonicity increases to some . For the reverse inequality, fix a simple and , and let . These sets are measurable and increasing, and their union is : if then , and if then , so for large . Hence
by continuity from below of . So . Let and take the supremum over : .
∎
Applied to the partial sums, monotone convergence gives for measurable — termwise integration of non-negative series with no further hypothesis. With the dyadic approximations it also shows that the integral is additive, , because it is additive on simple functions.
Theorem— Fatou's lemma (1906)
For measurable , .
Proof
Let . Then is measurable, , and . Since for every , we have . By monotone convergence, .
∎
Theorem— Dominated convergence theorem (Lebesgue)
Let be real measurable functions with almost everywhere, and suppose there is with a.e. for all . Then and ; in fact .
Proof
Changing the functions on a null set changes no integral, so we may assume and everywhere. Then , so is integrable. The functions and are non-negative, so Fatou's lemma gives
Since we may cancel it: . For the stronger statement apply what was just proved to , which is dominated by .
∎
In the examples above no integrable dominates, and the conclusion fails. Dominated convergence also justifies differentiation under the integral sign: if exists and with integrable, then (apply dominated convergence to difference quotients, bounded by via the mean value theorem).
Products, Lᵖ and the Riemann integral
Theorem— Fubini–Tonelli theorem (Fubini 1907, Tonelli 1909)
Let and be σ-finite and the product measure on , determined by .
- (Tonelli) If is -measurable, then and are measurable and
- (Fubini) If , then for a.e. , for a.e. , the a.e.-defined iterated integrals are integrable, and the same equalities hold.
About the proof. The product measure comes from the premeasure on finite unions of rectangles via Carathéodory. One proves the formula for indicators of rectangles, extends it to all of with the monotone class lemma (this is where σ-finiteness enters, through continuity from above), then to simple functions by linearity, to non-negative functions by monotone convergence, and to integrable functions by splitting . Details: Folland, §2.5, or Stein–Shakarchi, Ch. 2 §3. In practice one uses Tonelli on to check integrability and then Fubini to compute.
Both hypotheses are needed:
- Integrability. On with counting measure let if , if , and otherwise. Every column sums to and every row except the first sums to , so while . Here . (A continuous version: on has iterated integrals .)
- σ-finiteness. Let be Lebesgue measure and counting measure on , and . Then but .
Theorem— Riesz–Fischer theorem (1907)
For , is a Banach space. Moreover every sequence converging in has a subsequence converging almost everywhere.
Proof
Step 1: a criterion. A normed space is complete if every absolutely convergent series converges. Indeed, given a Cauchy sequence choose with for . The series is absolutely convergent, so its partial sums converge; and a Cauchy sequence with a convergent subsequence converges.
Step 2: . Let . Put and . By Minkowski , and by monotone convergence . So a.e., and on that set converges absolutely to some (set elsewhere). Then , so , and . By dominated convergence . The same argument applied to the series of Step 1 shows that the subsequence converges a.e.
Step 3: . If is Cauchy in , the sets are null; off their (countable, hence null) union, is uniformly Cauchy and converges uniformly to a bounded , and .
∎
The subsequence cannot be avoided. The typewriter sequence — indicators of , then , then the four quarters, and so on — tends to in (the integrals are the interval lengths), but at every it takes the value infinitely often. When , is a Hilbert space with ; it is the stage for Fourier analysis and quantum mechanics.
Theorem— Theorem (Riemann integrable functions are Lebesgue integrable)
If is Riemann integrable, then is Lebesgue measurable and integrable, and its Lebesgue integral equals its Riemann integral.
Proof
Take partitions , each refining the last, whose lower and upper Riemann sums both converge to the Riemann integral . Let be the corresponding lower and upper step functions (on each subinterval, the infimum and supremum of ), so and . Refinement makes increase and decrease; their limits are Borel measurable and bounded by . By dominated convergence , so with , and therefore a.e. (Markov's inequality: for every ). Thus except on a null set, so is measurable for the complete σ-algebra , and .
∎
Lebesgue's criterion sharpens this: a bounded function on is Riemann integrable exactly when its set of discontinuities is null. Improper Riemann integrals are another matter: exists as an improper Riemann integral, but because . The Lebesgue integral is an absolute integral.
Measure theory in Lean and Mathlib
Mathlib's measure theory is one of its largest and most used libraries: probability theory, the Fourier transform and the integration on manifolds are all built on it. Its volume on ℝ is Lebesgue measure, constructed from outer measure with Carathéodory's criterion via Stieltjes functions, exactly as above. It extends length:
/-- Lebesgue measure extends length: `λ([a, b]) = b − a` (as an extended non-negative real;
`ENNReal.ofReal` sends negative numbers to `0`, so the formula also covers `b < a`). Mathlib
constructs `volume` on `ℝ` by Carathéodory's criterion and proves this as `Real.volume_Icc`. -/
theorem volume_Icc (a b : ℝ) : volume (Icc a b) = ENNReal.ofReal (b - a) :=
Real.volume_IccThe lesson's proof that is null — a countable union of null singletons — and Mathlib's general statement for countable sets:
/-- **The rationals form a Lebesgue-null set.** `ℚ ⊂ ℝ` is the countable union of the
singletons `{q}`, each of measure `0`; by countable subadditivity the union has measure `0`.
This is the lesson's proof, using Mathlib's `measure_iUnion_null` (a countable union of null
sets is null) and `Real.volume_singleton`. -/
theorem volume_rat_eq_zero : volume (range ((↑) : ℚ → ℝ)) = 0 := by
rw [← iUnion_singleton_eq_range]
exact measure_iUnion_null fun q => Real.volume_singleton/-- More generally, every countable subset of `ℝ` is Lebesgue-null (`Set.Countable.measure_zero`;
the hypothesis Mathlib needs is that singletons are null). The converse is false: the Cantor
set is uncountable and null. -/
theorem countable_null {s : Set ℝ} (hs : s.Countable) : volume s = 0 :=
hs.measure_zero volumeMathlib writes ∫⁻ x, f x ∂μ for the integral of a function into (the "lintegral", defined as the supremum over simple functions below ) and ∫ x, f x ∂μ for the Bochner integral of integrable functions into a Banach space. Markov's inequality, proved here by comparing with the simple function (the step used in the Riemann–Lebesgue comparison above):
/-- **Markov's inequality.** For a measurable `f : α → [0, ∞]` and `ε ∈ [0, ∞]`,
`ε · μ{f ≥ ε} ≤ ∫ f dμ`. Proof: the simple function `ε · 1_{f ≥ ε}` lies below `f`, and its
integral is `ε · μ{f ≥ ε}`; integrals are monotone. (Mathlib: `mul_meas_ge_le_lintegral`.) -/
theorem markov {α : Type*} [MeasurableSpace α] (μ : Measure α) {f : α → ℝ≥0∞}
(hf : Measurable f) (ε : ℝ≥0∞) : ε * μ {x | ε ≤ f x} ≤ ∫⁻ x, f x ∂μ := by
have hs : MeasurableSet {x | ε ≤ f x} := measurableSet_le measurable_const hf
calc ε * μ {x | ε ≤ f x} = ∫⁻ x, {x | ε ≤ f x}.indicator (fun _ => ε) x ∂μ :=
(lintegral_indicator_const hs ε).symm
_ ≤ ∫⁻ x, f x ∂μ := by
apply lintegral_mono
intro x
by_cases hx : ε ≤ f x
· simpa [indicator_of_mem (show x ∈ {x | ε ≤ f x} from hx)] using hx
· simp [indicator_of_notMem (show x ∉ {x | ε ≤ f x} from hx)]The convergence theorems are library theorems. Note the different hypotheses: monotone convergence needs no integrability, dominated convergence needs one integrable bound for all .
/-- **Monotone convergence theorem** (Beppo Levi). If `0 ≤ f₀ ≤ f₁ ≤ ⋯` are measurable, then
`∫ sup fₙ = sup ∫ fₙ`. No integrability hypothesis is needed for non-negative functions. This is
Mathlib's `lintegral_iSup`. -/
theorem monotone_convergence {α : Type*} [MeasurableSpace α] (μ : Measure α)
{f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n)) (hmono : Monotone f) :
∫⁻ x, ⨆ n, f n x ∂μ = ⨆ n, ∫⁻ x, f n x ∂μ :=
lintegral_iSup hf hmono/-- **Dominated convergence theorem** (Lebesgue). If `Fₙ → f` almost everywhere and
`‖Fₙ‖ ≤ g` almost everywhere for one integrable `g`, then `∫ Fₙ → ∫ f`. This is Mathlib's
`tendsto_integral_of_dominated_convergence`. -/
theorem dominated_convergence {α : Type*} [MeasurableSpace α] (μ : Measure α)
{F : ℕ → α → ℝ} {f g : α → ℝ} (hF : ∀ n, AEStronglyMeasurable (F n) μ)
(hg : Integrable g μ) (hbound : ∀ n, ∀ᵐ x ∂μ, ‖F n x‖ ≤ g x)
(hlim : ∀ᵐ x ∂μ, Tendsto (fun n => F n x) atTop (𝓝 (f x))) :
Tendsto (fun n => ∫ x, F n x ∂μ) atTop (𝓝 (∫ x, f x ∂μ)) :=
tendsto_integral_of_dominated_convergence g hF hg hbound hlimThe escaping-mass sequence , formalised and analysed from scratch: every integral is , every pointwise limit is . Together these two theorems show formally that the hypotheses of the convergence theorems cannot simply be dropped.
/-- The "escaping mass" sequence `fₙ = n · 1_(0, 1/n)`: a tower of height `n` over an interval
of length `1/n`. -/
noncomputable def escapingMass (n : ℕ) : ℝ → ℝ≥0∞ :=
(Ioo (0 : ℝ) (1 / n)).indicator fun _ => (n : ℝ≥0∞)/-- Every `fₙ` (with `n ≥ 1`) has integral exactly `1`: the integral of `c · 1_A` is
`c · λ(A)`, and here `n · (1/n) = 1`. -/
theorem escapingMass_lintegral {n : ℕ} (hn : 1 ≤ n) : ∫⁻ x, escapingMass n x = 1 := by
have hn' : (n : ℝ) ≠ 0 := by positivity
rw [escapingMass, lintegral_indicator_const measurableSet_Ioo, Real.volume_Ioo, sub_zero,
← ENNReal.ofReal_natCast, ← ENNReal.ofReal_mul (Nat.cast_nonneg n), mul_one_div_cancel hn',
ENNReal.ofReal_one]/-- …yet `fₙ(x) → 0` for **every** `x ∈ ℝ`: if `x ≤ 0` every term is `0`; if `x > 0`, then as
soon as `n > 1/x` we have `x ∉ (0, 1/n)`, so `fₙ(x) = 0`. Hence `∫ lim fₙ = 0 ≠ 1 = lim ∫ fₙ`:
there is no integrable dominating function and the sequence is not monotone. -/
theorem escapingMass_tendsto_zero (x : ℝ) :
Tendsto (fun n => escapingMass n x) atTop (𝓝 0) := by
-- It suffices that `fₙ(x) = 0` for all large `n`.
apply tendsto_const_nhds.congr'
rcases le_or_gt x 0 with hx | hx
· -- `x ≤ 0`: `x` is never in `(0, 1/n)`.
refine Eventually.of_forall fun n => ?_
have hmem : x ∉ Ioo (0 : ℝ) (1 / n) := fun h => (not_lt.2 hx) h.1
show (0 : ℝ≥0∞) = escapingMass n x
rw [escapingMass, indicator_of_notMem hmem]
· -- `x > 0`: choose `N > 1/x`; for `n ≥ N` we have `1/n ≤ x`.
obtain ⟨N, hN⟩ := exists_nat_gt (1 / x)
filter_upwards [eventually_ge_atTop N] with n hn
have hNpos : (0 : ℝ) < N := lt_trans (by positivity) hN
have hnpos : (0 : ℝ) < n := lt_of_lt_of_le hNpos (by exact_mod_cast hn)
have hle : 1 / (n : ℝ) ≤ x := by
rw [div_le_iff₀ hnpos]
have h1 : 1 < N * x := by rwa [div_lt_iff₀ hx] at hN
nlinarith [show (N : ℝ) ≤ n by exact_mod_cast hn]
have hmem : x ∉ Ioo (0 : ℝ) (1 / n) := fun h => (not_lt.2 hle) h.2
show (0 : ℝ≥0∞) = escapingMass n x
rw [escapingMass, indicator_of_notMem hmem]Tonelli's theorem (Mathlib states it for s-finite measures, a class containing the σ-finite ones), the Riesz–Fischer theorem as a CompleteSpace instance on Mathlib's Lp (a type of a.e.-equivalence classes), and the first Borel–Cantelli lemma:
/-- **Tonelli's theorem.** For a measurable `f : α × β → [0, ∞]` and σ-finite (in Mathlib:
s-finite) measures, the integral over the product equals either iterated integral. This is
Mathlib's `lintegral_prod`. -/
theorem tonelli {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] (μ : Measure α)
(ν : Measure β) [SFinite ν] (f : α × β → ℝ≥0∞) (hf : AEMeasurable f (μ.prod ν)) :
∫⁻ z, f z ∂μ.prod ν = ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ :=
lintegral_prod f hf/-- **Riesz–Fischer.** For `1 ≤ p ≤ ∞`, the space `Lᵖ(μ)` (functions modulo equality almost
everywhere) is complete, hence a Banach space. Mathlib provides the instance
`MeasureTheory.Lp.instCompleteSpace`. -/
theorem lp_complete {α : Type*} [MeasurableSpace α] (μ : Measure α) (p : ℝ≥0∞)
[Fact (1 ≤ p)] : CompleteSpace (Lp ℝ p μ) :=
inferInstance/-- **First Borel–Cantelli lemma.** If `∑ μ(Aₙ) < ∞`, then almost every point lies in only
finitely many `Aₙ`: `μ(limsup Aₙ) = 0`. This is Mathlib's `measure_limsup_atTop_eq_zero`. -/
theorem borel_cantelli {α : Type*} [MeasurableSpace α] (μ : Measure α) {A : ℕ → Set α}
(hA : ∑' n, μ (A n) ≠ ∞) : μ (limsup A atTop) = 0 :=
measure_limsup_atTop_eq_zero hANot formalised here: the Carathéodory construction and the Heine–Borel argument for (Mathlib has both, as MeasureTheory.OuterMeasure.caratheodory and StieltjesFunction.outer_Ioc), the proofs of the convergence theorems and of Riesz–Fischer (we cite Mathlib's), and the comparison with the Riemann integral (Mathlib relates intervalIntegral to antiderivatives through the fundamental theorem of calculus rather than through Riemann sums).
Computing with null sets and escaping mass
The first experiment builds the stages of the Cantor set with exact fractions. It confirms the lengths , checks that survives every stage computed without ever being an endpoint (so the Cantor set is more than its endpoints), and exhibits the injection from -strings that drives the uncountability proof.
"""The Cantor set: uncountably many points, total length zero.
Builds the stages C_n of the middle-thirds Cantor set with exact rational
arithmetic: C_n is a union of 2^n closed intervals of total length (2/3)^n.
It then checks that 1/4 survives every stage computed although it is never an
endpoint, and shows the injection from 0/1-sequences into the Cantor set
(binary digit b -> ternary digit 2b) that makes it uncountable. Exact
arithmetic for finitely many stages; the limits are the lesson's proofs.
"""
from fractions import Fraction
def cantor_stage(n):
"""The 2^n closed intervals (a, b) of the n-th stage C_n, as Fractions."""
if n < 0:
raise ValueError("n must be non-negative")
intervals = [(Fraction(0), Fraction(1))]
for _ in range(n):
new = []
for a, b in intervals:
third = (b - a) / 3
new.append((a, a + third))
new.append((b - third, b))
intervals = new
return intervals
def total_length(intervals):
"""Sum of the lengths of disjoint intervals."""
return sum((b - a for a, b in intervals), Fraction(0))
def in_stage(x, n):
"""True if the rational x lies in C_n (checked by the ternary rule)."""
x = Fraction(x)
if not 0 <= x <= 1:
return False
for _ in range(n):
if Fraction(1, 3) < x < Fraction(2, 3):
return False
x = 3 * x if x <= Fraction(1, 3) else 3 * x - 2
return True
def ternary_digits(x, k):
"""The first k ternary digits of a rational x in [0, 1)."""
x = Fraction(x)
digits = []
for _ in range(k):
x *= 3
d = int(x)
digits.append(d)
x -= d
return digits
def endpoints(n):
"""All endpoints of the intervals of C_n."""
return {e for interval in cantor_stage(n) for e in interval}
def bits_to_cantor_point(bits):
"""The point sum 2*b_i / 3^i of the Cantor set coded by the bits b_i."""
return sum((Fraction(2 * b, 3 ** (i + 1)) for i, b in enumerate(bits)),
Fraction(0))
def first_stage_below(threshold):
"""Least n with (2/3)^n < threshold."""
n, length = 0, Fraction(1)
while length >= threshold:
n, length = n + 1, length * Fraction(2, 3)
return n
def main():
print("Stages of the Cantor set (exact arithmetic)")
print(f"{'n':>3} {'intervals':>10} {'total length':>20} {'decimal':>10}")
for n in [0, 1, 2, 3, 5, 10, 20]:
stage = cantor_stage(n) if n <= 12 else None
length = total_length(stage) if stage else Fraction(2, 3) ** n
count = len(stage) if stage else 2 ** n
print(f"{n:>3} {count:>10} {str(length):>20} {float(length):>10.6f}")
print(f"Length below 1/1000 from stage n = {first_stage_below(Fraction(1, 1000))}.")
print()
quarter = Fraction(1, 4)
print("Is 1/4 in the Cantor set?")
print(" ternary digits of 1/4:", "".join(map(str, ternary_digits(quarter, 12))),
"...")
print(f" in every stage C_n for n <= 40: {all(in_stage(quarter, n) for n in range(41))}")
print(f" an endpoint of some C_n, n <= 12: {quarter in endpoints(12)}")
print(" (endpoints have denominators 3^n, and 4 is not a power of 3)")
print()
strings = [[(m >> i) & 1 for i in range(10)] for m in range(2 ** 10)]
points = {bits_to_cantor_point(s) for s in strings}
print("0/1 strings -> Cantor points by b -> ternary digit 2b:")
print(f" {len(strings)} strings of length 10 give {len(points)} distinct points,")
print(f" all in C_10: {all(in_stage(p, 10) for p in points)}")
print()
print("Epistemic status: exact rational arithmetic for finitely many stages")
print("and strings. It shows that C is covered by intervals of total length")
print("(2/3)^n for the n computed. That C is null (it lies in every C_n) and")
print("that the injection on infinite sequences makes it uncountable are the")
print("lesson's proofs, not consequences of this finite check.")
if __name__ == "__main__":
main()The second computes, exactly, the integrals and point values of four sequences: escaping mass, a travelling bump, the dominated sequence on , and the typewriter sequence. Watch the value at return to once in every dyadic block, although the integrals shrink to ; along the subsequence it converges, as Riesz–Fischer predicts.
"""When may a limit pass through an integral? Four sequences, exactly.
For four classic sequences of functions we compute the integrals exactly
(fractions) and follow the values at a fixed point: escaping mass
n * 1_(0, 1/n), a travelling bump 1_[n, n+1], the dominated sequence x^n on
[0, 1], and the "typewriter" sequence of shrinking dyadic intervals. The first
two converge pointwise to 0 while their integrals stay 1; the third obeys the
dominated convergence theorem; the fourth converges in L^1 but at no point.
"""
from fractions import Fraction
def escaping(n, x):
"""f_n(x) = n on the open interval (0, 1/n), else 0."""
x = Fraction(x)
return n if 0 < x < Fraction(1, n) else 0
def escaping_integral(n):
"""The integral of f_n: height n times length 1/n."""
return n * Fraction(1, n)
def bump(n, x):
"""g_n(x) = 1 on [n, n + 1], else 0."""
return 1 if n <= Fraction(x) <= n + 1 else 0
def power_integral(n):
"""The integral of x^n over [0, 1]."""
return Fraction(1, n + 1)
def typewriter_interval(k):
"""For k >= 1 write k = 2^m + j with 0 <= j < 2^m: the interval
[j / 2^m, (j + 1) / 2^m]."""
if k < 1:
raise ValueError("k must be at least 1")
m = k.bit_length() - 1
j = k - 2 ** m
return Fraction(j, 2 ** m), Fraction(j + 1, 2 ** m)
def typewriter(k, x):
"""T_k(x) = indicator of the k-th typewriter interval."""
a, b = typewriter_interval(k)
return 1 if a <= Fraction(x) <= b else 0
def typewriter_integral(k):
"""The integral of T_k is the length of its interval."""
a, b = typewriter_interval(k)
return b - a
def hits(k_max, x):
"""The k <= k_max with T_k(x) = 1."""
return [k for k in range(1, k_max + 1) if typewriter(k, x) == 1]
def main():
ns = [1, 2, 10, 100, 1000]
print("integrals for n =", ns)
print(" escaping mass n*1_(0,1/n):",
[str(escaping_integral(n)) for n in ns])
print(" x^n on [0, 1] :", [str(power_integral(n)) for n in ns])
print("values at x = 1/10 for n = 1..12 (escaping mass):")
print(" ", [escaping(n, Fraction(1, 10)) for n in range(1, 13)])
print("values at x = 5/2 for n = 0..6 (travelling bump, integral 1):")
print(" ", [bump(n, Fraction(5, 2)) for n in range(7)])
print()
print("Typewriter T_k, k = 2^m + j: the indicator of [j/2^m, (j+1)/2^m]")
for k in [1, 2, 3, 4, 7, 8, 100, 1000]:
a, b = typewriter_interval(k)
print(f" k = {k:>4}: [{a}, {b}], integral {typewriter_integral(k)}")
third = Fraction(1, 3)
h = hits(1023, third)
print(f" T_k(1/3) = 1 for {len(h)} values of k <= 1023, one per block:")
print(" ", h)
print(" so T_k(1/3) is 1 infinitely often and 0 infinitely often,")
print(" but along k = 2^m:", [typewriter(2 ** m, third) for m in range(8)])
print()
print("Epistemic status: exact arithmetic on finitely many terms. The")
print("escaping mass and travelling bump are genuine counterexamples (each")
print("integral is exactly 1, and each point value is eventually 0, as the")
print("lesson proves). The typewriter output illustrates, but does not prove,")
print("that L^1 convergence implies only a.e. convergence of a subsequence.")
if __name__ == "__main__":
main()Both are finite computations: they display the phenomena and supply counterexamples, but the limiting statements are the theorems above.
Watch the mass escape
The shaded area is for every . Move the slider: the tower grows taller and thinner, and any fixed is eventually outside it. Where does the mass go, and why does no single integrable function lie above every tower?
Escaping mass: integral 1, pointwise limit 0
Move the sliders and trace along the curves to read off values.
- f_n = n · 1_(0, 1/n)
- Signed area: above the axis counts as positive, below (hatched) as negative
- f_n = n · 1_(0, 1/n): y = 0
- Signed area from −0.25 to 1.25 ≈ 1 (numerical integration)
Exercises
1. Measure theory and integration
Warm-upHumanLet be the collection of subsets such that is finite or is finite. Which statement is true?
2. Measure theory and integration
Warm-upHumanLet on . Compute the Lebesgue integral .
3. Measure theory and integration
CoreHumanLet on with Lebesgue measure. Then pointwise, but for all . Which hypothesis of the dominated convergence theorem fails?
4. Measure theory and integration
CoreHumanThe proof of Fatou's lemma sets and concludes . Which result justifies this equality?
5. Measure theory and integration
CoreHumanFor let if , if , and otherwise. Compute .
6. Measure theory and integration
CoreFormalWhich Lean statement correctly formalises Markov's inequality for measurable ? (Here ℝ≥0∞ is and ∫⁻ is the integral of such functions.)
7. Measure theory and integration
CoreHumanSelect all true statements.
8. Measure theory and integration
StretchHumanIn the proof that is complete, given a Cauchy sequence we choose with . Why is this subsequence needed?
9. Measure theory and integration
CoreComputationalWrite union_length(intervals) that returns the Lebesgue measure of a finite union of closed intervals, given as a list of pairs (a, b) with a <= b. The intervals may overlap. (Countable subadditivity says the answer is at most the sum of the lengths; overlaps make it smaller.)
Common misconceptions
Misconception
"A set of measure zero must be countable." Countable sets are null, but the Cantor set is uncountable — it has the cardinality of — and null. Null sets can be topologically large too: there are dense null sets.
Misconception
"If pointwise, then ." Not without a hypothesis. Mass can escape upwards (), to infinity () or by spreading (, even with uniform convergence on an infinite measure space). Check monotonicity (MCT) or find one integrable dominating function (DCT); otherwise only Fatou's inequality survives.
Misconception
"Every subset of is Lebesgue measurable." Vitali's set is not. Its construction uses the axiom of choice, and Solovay (1970) showed that some choice is necessary: in ZF with dependent choice it is consistent (relative to an inaccessible cardinal) that every set of reals is measurable. No explicitly definable Borel or even analytic set is non-measurable.
Misconception
"Lebesgue integrable is the same as improperly Riemann integrable." The Lebesgue integral is absolute: is integrable only if is. So has an improper Riemann integral on but is not Lebesgue integrable there; conversely is Lebesgue but not Riemann integrable on .
Misconception
"Convergence in means convergence almost everywhere" (or the reverse). The typewriter sequence converges to in and at no point; converges everywhere and not in . What is true: convergence gives an a.e.-convergent subsequence, and a.e. convergence plus domination gives convergence.
Many ways of seeing
Topology— Measures as functionals, and measure versus category
On a locally compact Hausdorff space , the Riesz–Markov–Kakutani theorem identifies the positive linear functionals on with the Radon measures: for a unique regular Borel measure . So a measure is determined by how it integrates continuous functions — a topological object. Regularity ties the two worlds together: for Lebesgue measure, , and Lusin's theorem says a measurable function is continuous once a set of arbitrarily small measure is removed.
Yet "small" means different things to the topologist and the measure theorist. The example of small open dense sets shows with meagre and null: the σ-ideals of meagre sets and of null sets are "orthogonal". Oxtoby's Measure and Category (1971) develops this duality, where many theorems have a twin with "null" replaced by "meagre" and the proofs differ.
Geometry— Invariance, Haar measure and Hausdorff dimension
Lebesgue measure on is characterised geometrically: it is the unique translation-invariant Borel measure giving the unit cube measure , and it transforms under a linear map by — the determinant is the volume scaling factor, and rotations preserve volume. Haar (1933) generalised this: every locally compact group carries a left-invariant Radon measure, unique up to scaling — the starting point of harmonic analysis on groups. In the Banach–Tarski paradox (1924) decomposes a ball into finitely many pieces that can be rigidly reassembled into two balls; the pieces are non-measurable, which is why volume cannot be defined for all sets even with only finite additivity in dimension .
Hausdorff (1918) built measures for every real from covers by small sets of diameter , weighting each by . Each set has a critical exponent, its Hausdorff dimension, where jumps from to . The Cantor set has dimension : it is null for length but has positive finite -measure. Geometric measure theory measures curves, surfaces and fractals this way.
Probability— Kolmogorov's axioms
In 1933 Kolmogorov founded probability on measure theory: a probability space is a measure space of total mass , an event is a measurable set, a random variable is a measurable function, and expectation is the integral, . The dictionary turns theorems into theorems: Markov's inequality is ; dominated convergence justifies exchanging limits and expectations; Fubini says for independent integrable variables, because independence means the joint law is a product measure; the first Borel–Cantelli lemma (formalised above) says that if , almost surely only finitely many occur.
Infinite products of probability spaces — infinitely many coin tosses — exist by the Kolmogorov extension theorem, itself a Carathéodory argument. The flip of a fair coin infinitely often, read as binary digits, is Lebesgue measure on ; the strong law of large numbers then becomes Borel's theorem (1909) that almost every real number is normal in base . See measure-theoretic probability.
Logic— How much choice does measure need?
Vitali's set uses the axiom of choice, and this is unavoidable. Solovay (1970) constructed, from a model of ZFC with an inaccessible cardinal, a model of ZF plus dependent choice (enough for all of classical analysis, including the convergence theorems) in which every subset of is Lebesgue measurable; Shelah (1984) showed the inaccessible cannot be removed from that statement. Positively, sets that can be defined simply are measurable: analytic sets (projections of Borel sets) are universally measurable, a theorem of Lusin. So the non-measurable sets of analysis are those produced by choice, never those written down by a formula of low complexity — a theme of descriptive set theory.
History and context
- Bernhard Riemann defined his integral in his 1854 Habilitation (published 1868); Giuseppe Peano (1887) and Camille Jordan (1892) defined content using finite covers, which cannot measure .
- Émile Borel (1898) introduced countably additive measure on the sets now called Borel sets. Henri Lebesgue's thesis Intégrale, longueur, aire (1902) defined the measure and the integral and proved the dominated convergence theorem for bounded functions; Giuseppe Vitali (1905) constructed a non-measurable set.
- In 1906–1907 came Beppo Levi (monotone convergence), Pierre Fatou (his lemma, in a thesis on Fourier series and analytic functions), Frigyes Riesz and Ernst Fischer (completeness of , in connection with Fourier series), and Guido Fubini (iterated integrals); Leonida Tonelli (1909) treated non-negative functions.
- Johann Radon (1913) integrated with respect to general measures on ; Constantin Carathéodory (1914) introduced outer measure and his criterion; Maurice Fréchet (1915) defined integrals on abstract sets; Felix Hausdorff (1918) defined the measures and dimension named after him.
- Andrey Kolmogorov's Grundbegriffe der Wahrscheinlichkeitsrechnung (1933) made measure theory the foundation of probability; Alfréd Haar (1933) proved the existence of invariant measures on separable locally compact groups, with John von Neumann (uniqueness) and André Weil (all locally compact groups) completing the theory. Frigyes Riesz (1909, for ), Andrey Markov Jr. (1938) and Shizuo Kakutani (1941) proved the representation theorem for functionals.
Further reading
- Gerald B. Folland, Real Analysis: Modern Techniques and Their Applications (2nd ed., 1999), Chapters 1–3 and 6 — the proofs above follow its route.
- Elias M. Stein and Rami Shakarchi, Real Analysis: Measure Theory, Integration, and Hilbert Spaces (2005) — Lebesgue measure on first, with many applications.
- Terence Tao, An Introduction to Measure Theory (2011) — a careful, example-rich development, with the "escape of mass" taxonomy.
- Walter Rudin, Real and Complex Analysis (3rd ed., 1987) — the Riesz representation theorem and spaces, concisely.
- John C. Oxtoby, Measure and Category (2nd ed., 1980) — the parallel between null and meagre sets.
- Vladimir I. Bogachev, Measure Theory (2007), 2 volumes — comprehensive reference with extensive historical notes.