Module contents
Lesson 3 of 24Core 100 min

Measure theory I: σ-algebras and measures

Why probability cannot be assigned to every subset of [0,1] and the minimum structure required of events. Construct generated σ-algebras, the Borel σ-algebra, measures and Lebesgue measure via Carathéodory extension, using Dynkin’s π-λ theorem for uniqueness. Interpret a σ-algebra as available information from the outset.

After this lesson you can

  • Use the Vitali set to explain why no translation-invariant measure exists on every subset of [0, 1).
  • Determine whether a family of sets is an algebra, σ-algebra, π-system or λ-system, and describe the σ-algebra generated by a partition.
  • Use the π-λ theorem to show measures agreeing on intervals agree on every Borel set.
  • Describe the Carathéodory construction of Lebesgue measure and its null sets.
  • Interpret nested σ-algebras as increasing information.

Before you start

Motivation: “choose at random” is incomplete

In the lesson on probability spaces you wrote (Ω,F,P)(\Omega, \mathcal{F}, \Pr) and called F\mathcal{F} “the family of events”. This lesson explains where that family comes from, why it cannot always be all of P(Ω)\mathcal{P}(\Omega) and the minimum structure it needs for the Kolmogorov axioms to make sense. There are three reasons, each illustrated by a concrete result.

First: without a measure there is no question. Draw a chord “at random” in a circle. What is the probability it exceeds the side of the inscribed equilateral triangle? Three perfectly reasonable chord-selection recipes give three different answers.

InteractiveBertrand's paradox
Two circumference points. Choose two uniform points on the circumference and join them.
d = 1/2
0.000.250.500.751.001101001000number of chords n (log scale)1/31/21/4
  • long chord (d<1/2d < 1/2): 113 of 316
  • short chord
  • inscribed triangle
Chord selection recipe
View
316
endpoints: long-chord frequency0.358 (exact 1/3)
radius: long-chord frequency0.481 (exact 1/2)
midpoint: long-chord frequency0.231 (exact 1/4)
Same question, three answers: 1/31/3, 1/21/2 and 1/41/4. “At random” has no meaning until a probability measure on chords is fixed.
Three recipes for a random chord. Change recipe and compare the frequency of chords longer than the side of the inscribed triangle with its exact value. Switch to midpoint view: a chord is long if and only if its midpoint lies inside the dashed circle of radius 1/21/2, and each recipe distributes midpoints differently. Which puts more mass near the center? Which near the edge? Select ‘New sample’: frequencies change, limiting values do not.

All three values are calculated by hand. A chord is long if its midpoint is d<1/2d < 1/2 from the center (the chord has length 21−d2>32\sqrt{1 - d^2} > \sqrt 3 exactly when d<1/2d < 1/2). For the first recipe symmetry lets you fix one endpoint at a triangle vertex: the chord is long if the other falls in the opposite arc, one third of the circumference, giving 1/31/3. For the second, dd is uniform on [0,1][0, 1] and P(d<1/2)=1/2\Pr(d < 1/2) = 1/2. In the third, the midpoint is uniform in the disk and probability is the area ratio π(1/2)2/π=1/4\pi (1/2)^2 / \pi = 1/4. None of the calculations is wrong: these are three different probability measures on the same set of chords. The question has an answer only once the measure is fixed. (E. T. Jaynes argued in 1973 that if the answer must not depend on circle position or size, the radius recipe is uniquely consistent. This argues which measure is reasonable, not which is “the” correct one.)

Second: not every subset can have length. Assigning probability to every subset of [0,1][0, 1] in a way that makes “choose a uniform point” meaningful is impossible, as shown next.

Third: information. A system observing only part of the world can answer some questions and not others. That structure of “answerable questions” is exactly a σ-algebra, and increasing versions (filtrations) are the language of martingales, partially observable reinforcement learning and much of stochastic calculus.

An obstacle: the Vitali set

We want a “length” function μ\mu defined on all subsets of [0,1)[0, 1) with three properties one would accept for uniform sampling: countable additivity, translation invariance (addition modulo 1, to remain in the interval) and μ([0,1))=1\mu([0, 1)) = 1.

Proof

On [0,1)[0, 1) define relation x∼y  ⟺  x−y∈Qx \sim y \iff x - y \in \Q. It is an equivalence relation, and by the axiom of choice a set V⊂[0,1)V \subset [0, 1) exists containing exactly one representative per class. For each rational q∈Q∩[0,1)q \in \Q \cap [0, 1) let Vq=V⊕qV_q = V \oplus q.

The VqV_q are disjoint: if x∈Vq∩Vrx \in V_q \cap V_r, then x=v+q=v′+r(mod1)x = v + q = v' + r \pmod 1 with v,v′∈Vv, v' \in V, hence v−v′∈Qv - v' \in \Q, i.e. v∼v′v \sim v', and since VV has one representative per class, v=v′v = v' and then q=rq = r. They cover everything: given x∈[0,1)x \in [0, 1), its representative v∈Vv \in V satisfies x−v∈Qx - v \in \Q, so x∈Vqx \in V_{q} with q=(x−v) mod 1q = (x - v) \bmod 1.

Since Q∩[0,1)\Q \cap [0, 1) is countable (countability), (i), (ii) and (iii) give

1=μ([0,1))=∑q∈Q∩[0,1)μ(Vq)=∑q∈Q∩[0,1)μ(V).1 = \mu([0, 1)) = \sum_{q \in \Q \cap [0, 1)} \mu(V_q) = \sum_{q \in \Q \cap [0, 1)} \mu(V).

A countable sum of copies of the same number is 00 if that number is 00, and ∞\infty if positive. It is never 11. ■\blacksquare

∎

Something must give. Measure theory gives up the one nonessential thing: domain. It retains countable additivity (without it limits do not work) and invariance, but abandons measurement of every subset, restricting to a family F\mathcal{F} large enough for everything we will do and small enough that a measure exists. (Relax countable to finite additivity and invariant extensions to every subset of R\R and R2\R^2 do exist, but lose passage to limits; on R3\R^3 even finite additivity and rigid-motion invariance clash: the Banach–Tarski paradox.)

QuizWhat is given up?
Vitali's argument shows four things cannot hold together. Which does measure theory abandon?

σ-algebras

What must the family F\mathcal{F} of sets we will measure satisfy? If AA is an event, “AA does not occur” must also be one. If A1,A2,…A_1, A_2, \dots are events, “at least one occurs” must be one too, not just for finitely many, because we need “ever” and “for every nn”. Those three requirements define it.

Immediate consequences: ∅=Ωc∈F\emptyset = \Omega^c \in \mathcal{F}; F\mathcal{F} is closed under finite unions (pad with ∅\emptyset), countable intersections (⋂nAn=(⋃nAnc)c\bigcap_n A_n = (\bigcup_n A_n^c)^c, by De Morgan) and differences (A∖B=A∩BcA \setminus B = A \cap B^c). In particular sets

lim sup⁡nAn=⋂m≥1⋃n≥mAn(«ocurren infinitos An»),lim inf⁡nAn=⋃m≥1⋂n≥mAn\limsup_n A_n = \bigcap_{m \ge 1} \bigcup_{n \ge m} A_n \quad(\text{«ocurren infinitos } A_n\text{»}), \qquad \liminf_n A_n = \bigcup_{m \ge 1} \bigcap_{n \ge m} A_n

are measurable if the AnA_n are. This is the reason for “σ”: countable operations express “infinitely often”, “always from some point on” and “converges”.

Useful examples:

  • {∅,Ω}\{\emptyset, \Omega\}, the trivial σ-algebra, and P(Ω)\mathcal{P}(\Omega), the discrete one. Everything else lies between.
  • {∅,A,Ac,Ω}\{\emptyset, A, A^c, \Omega\} for an A⊂ΩA \subset \Omega: the smallest containing AA.
  • With uncountable Ω\Omega, countable sets or those with countable complement.
  • With Ω=N\Omega = \N, finite or cofinite sets form an algebra but not a σ-algebra: singletons {2},{4},{6},…\{2\}, \{4\}, \{6\}, \dots are finite and their countable union, the evens, is neither finite nor cofinite. This canonical counterexample shows why finite versus countable matters, and appears as an exercise.
QuizFinite or cofinite
Let A\mathcal{A} be the family of subsets of N\N that are finite or have finite complement. What is A\mathcal{A}?

Generated σ-algebra

A σ-algebra is rarely described element by element: give a family of “important” sets and take the smallest σ-algebra containing them. An elementary fact makes this work.

The proof is the first guided exercise. The intersected family is nonempty because P(Ω)\mathcal{P}(\Omega) always contains C\mathcal{C}, and the definition is nonconstructive: it does not say how to obtain elements of σ(C)\sigma(\mathcal{C}). Adding complements and countable unions to C\mathcal{C} once is not generally sufficient, nor even twice: iteration must continue transfinitely to the first uncountable ordinal. In practice one therefore reasons via the universal property (“smallest containing C\mathcal{C}”), never enumeration.

Finite partitions: the simplest σ-algebra

If Ω\Omega is finite (or, more generally, the σ-algebra has finitely many elements), everything reduces to combinatorics. A partition of Ω\Omega is a collection of nonempty pairwise disjoint subsets whose union is Ω\Omega.

Proof

(a) Subfamily unions are 2k2^k distinct sets (because BiB_i are disjoint and nonempty). They are closed under complements (the complement of a union of SS is the union of the others) and unions. (b) For ω∈Ω\omega \in \Omega let B(ω)=⋂{A∈F:ω∈A}B(\omega) = \bigcap \{A \in \mathcal{F} : \omega \in A\}, a finite intersection, hence in F\mathcal{F}. If ω′∈B(ω)\omega' \in B(\omega) then B(ω′)⊂B(ω)B(\omega') \subset B(\omega); and since ω∈B(ω′)\omega \in B(\omega') for the same reason (if ω∉B(ω′)\omega \notin B(\omega'), B(ω)∖B(ω′)B(\omega) \setminus B(\omega') would be an element of F\mathcal{F} containing ω\omega and smaller than B(ω)B(\omega)), B(ω)=B(ω′)B(\omega) = B(\omega'). Thus the B(ω)B(\omega) form a partition, and each A∈FA \in \mathcal{F} is the union of B(ω)B(\omega) with ω∈A\omega \in A. ■\blacksquare

∎

Two points in one atom cannot be distinguished using events in F\mathcal{F}: every event contains both or neither. This gives our course-wide interpretation.

σ-algebra as information

Imagine outcome ω∈Ω\omega \in \Omega has already occurred, but you observe only a function of it (first toss, number of heads, a sensor summary). After observation you know which atom contains ω\omega, nothing more. Events for which you can say “occurred” or “did not occur” are exactly unions of atoms. A σ-algebra is the set of yes/no questions answered by the observation. Observing more splits atoms into finer pieces, enlarging the σ-algebra.

Interactiveσ-algebra as information
Sample space Ω\Omega for three tosses (C = heads, X = tails). Each color is an atom of the σ-algebra generated by the observation.
If the actual outcome is XCX, which events can you affirm or deny from the observation alone?
first is headsno
second is headsyes
third is heads¿?
first 2 matchno
first and third match¿?
at least 2 heads¿?
exactly 1 heads¿?
even number of heads¿?
no heads¿?
all three equal¿?
The filtration “first tt tosses”: each σ-algebra contains the previous one.
What you observe
Compare with
partition atoms kk4
events in F=2k\mathcal{F} = 2^k16
outcomes still possible2 of 8: XCC, XCX
listed events decided3 of 10
σ\sigma of “first” ⊆\subseteq σ\sigma of “first 2”: the current observation is finer.
Three coin tosses. Choose what you observe: cells of the same color are indistinguishable and form an atom. Select an outcome as truth and see which listed events are decided (yes or no) and which remain uncertain. Compare ‘number of heads’ with ‘first two’: which contains which? And with ‘third only’? Select the Ft\mathcal{F}_t below to traverse the filtration of the first tt tosses.

In the figure Ω={C,X}3\Omega = \{\mathtt{C}, \mathtt{X}\}^3 has 8 points. Observing the first toss generates a σ-algebra with 2 atoms and 22=42^2 = 4 events; the first two, 4 atoms and 24=162^4 = 16 events; all three, 8 atoms and 28=2562^8 = 256 events, all of P(Ω)\mathcal{P}(\Omega). Observing only head count also gives 4 atoms (0, 1, 2 or 3 heads, with 1, 3, 3 and 1 outcomes) and 16 events, but not the same 16 as the first two tosses: “second is heads” belongs to one and not the other. The σ-algebras are incomparable. In contrast, those of the first tt tosses are comparable:

F0⊂F1⊂F2⊂F3.\mathcal{F}_0 \subset \mathcal{F}_1 \subset \mathcal{F}_2 \subset \mathcal{F}_3.

An increasing sequence of σ-algebras like this is a filtration: information that accumulates over time and is never forgotten. When studying filtrations, martingales and stopping times, use this picture; in a POMDP the policy can depend only on what fits in the observed-information σ-algebra.

For functions from Ω\Omega to other spaces, “the σ-algebra generated by what I observe” is the concept of measurable function in the next lesson: a function is measurable with respect to a σ-algebra when knowing which events occurred suffices to determine its value (in the finite case, when it is constant on each atom).

The Borel σ-algebra

In R\R we will not work with finite partitions. The desired σ-algebra must at least contain intervals (to discuss length) and everything obtained from them through countable operations.

It contains open sets, closed sets (open complements), countable sets (unions of points), GδG_\delta (countable intersections of open sets, such as the irrational set R∖Q\R \setminus \Q) and FσF_\sigma (countable unions of closed sets). Every naturally encountered set is Borel. The next result says we need not start from all open sets.

Proof

We show B(R)=σ(C)\mathcal{B}(\R) = \sigma(\mathcal{C}) for C={(−∞,b]:b∈R}\mathcal{C} = \{(-\infty, b] : b \in \R\}; the rest uses the same argument. (⊇\supseteq) Each (−∞,b](-\infty, b] is closed, hence Borel. (⊆\subseteq) Show every open set belongs to σ(C)\sigma(\mathcal{C}). First (a,b]=(−∞,b]∖(−∞,a]∈σ(C)(a, b] = (-\infty, b] \setminus (-\infty, a] \in \sigma(\mathcal{C}) and (a,b)=⋃n(a,b−1/n]∈σ(C)(a, b) = \bigcup_n (a, b - 1/n] \in \sigma(\mathcal{C}). Now let U⊂RU \subset \R be open. For every x∈Ux \in U there is an interval (r,s)(r, s) with r,s∈Qr, s \in \Q such that x∈(r,s)⊂Ux \in (r, s) \subset U. Rational-endpoint intervals form a countable family (as many as rational pairs, countable), so UU is the countable union of rational intervals contained in UU and belongs to σ(C)\sigma(\mathcal{C}). ■\blacksquare

∎

The proof rests on Q\Q being countable and dense in R\R, so every open set is a countable union of basic intervals. In topological language R\R is separable (has a countable dense subset), and its topology therefore has a countable base; likewise in Rn\R^n with rational-vertex boxes, which makes Borel σ-algebras on Rn\R^n manageable. For Rn\R^n the analogous result uses boxes ∏i(ai,bi]\prod_i (a_i, b_i], and B(Rn)\mathcal{B}(\R^n) equals product σ-algebra B(R)⊗n\mathcal{B}(\R)^{\otimes n}, encountered when constructing product measure.

A matter of size. B(R)\mathcal{B}(\R) has continuum cardinality c=2ℵ0\mathfrak{c} = 2^{\aleph_0} (shown by the transfinite iteration above), while P(R)\mathcal{P}(\R) has 2c2^{\mathfrak{c}} elements. By Cantor’s diagonal, 2c>c2^{\mathfrak{c}} > \mathfrak{c}: almost all subsets of R\R are not Borel, though none can be written explicitly. B(R)\mathcal{B}(\R) itself is too large to enumerate, so it is handled through generators.

Measures

With a σ-algebra we can discuss “size of a measurable set”.

In other words Kolmogorov’s axioms are the definition of measure plus μ(Ω)=1\mu(\Omega) = 1. Examples: counting measure μ(A)=∣A∣\mu(A) = \abs{A} on any set (σ-finite if and only if Ω\Omega is countable); Dirac delta δω0(A)=1[ω0∈A]\delta_{\omega_0}(A) = \ind[\omega_0 \in A]; combinations ∑ipiδωi\sum_i p_i \delta_{\omega_i} with pi≥0p_i \ge 0, the discrete distributions; and Lebesgue measure in the next section, σ-finite but not finite on R\R.

Proof

(1) B=A⊔(B∖A)B = A \sqcup (B \setminus A) and additivity. (3) Write A=⨆nDnA = \bigsqcup_n D_n with D1=A1D_1 = A_1 and Dn=An∖An−1D_n = A_n \setminus A_{n-1}: they are disjoint and An=D1⊔⋯⊔DnA_n = D_1 \sqcup \dots \sqcup D_n, hence μ(A)=∑nμ(Dn)=lim⁡n∑k≤nμ(Dk)=lim⁡nμ(An)\mu(A) = \sum_n \mu(D_n) = \lim_n \sum_{k \le n} \mu(D_k) = \lim_n \mu(A_n). (2) Apply (3) to Bn=A1∪⋯∪An↑⋃nAnB_n = A_1 \cup \dots \cup A_n \uparrow \bigcup_n A_n, with finite subadditivity from (1) and μ(A∪B)=μ(A)+μ(B∖A)≤μ(A)+μ(B)\mu(A \cup B) = \mu(A) + \mu(B \setminus A) \le \mu(A) + \mu(B). (4) The A1∖AnA_1 \setminus A_n increase to A1∖AA_1 \setminus A; by (3), μ(A1∖An)↑μ(A1∖A)\mu(A_1 \setminus A_n) \uparrow \mu(A_1 \setminus A), and by (1) this is μ(A1)−μ(An)↑μ(A1)−μ(A)\mu(A_1) - \mu(A_n) \uparrow \mu(A_1) - \mu(A) (using finiteness of μ(A1)\mu(A_1)). ■\blacksquare

∎

Finiteness in (4) is not a technicality. With Lebesgue measure λ\lambda on R\R and An=[n,∞)A_n = [n, \infty), An↓∅A_n \downarrow \emptyset yet λ(An)=∞\lambda(A_n) = \infty for every nn: limit of measures is ∞\infty and measure of limit is 00. For probabilities, always finite, continuity holds both ways. The probability continuity lesson proved this for P\Pr; now it is a general fact. For finite measures a useful converse holds: a finitely additive set function continuous at ∅\emptyset (if An↓∅A_n \downarrow \emptyset, then μ(An)→0\mu(A_n) \to 0) is countably additive. If BkB_k are disjoint and Cn=⋃k>nBk↓∅C_n = \bigcup_{k > n} B_k \downarrow \emptyset, then μ(⋃kBk)=∑k≤nμ(Bk)+μ(Cn)→∑kμ(Bk)\mu\big(\bigcup_k B_k\big) = \sum_{k \le n} \mu(B_k) + \mu(C_n) \to \sum_k \mu(B_k). The Kolmogorov axioms lesson showed this equivalence’s role, and it returns when constructing measures from distribution functions.

When two measures are the same: π-systems and λ-systems

Measures are rarely defined by values on every Borel set. Values are given on a small manageable family (intervals), and two questions arise: do those values determine the measure (uniqueness), and does a measure with those values exist (existence)? This section treats uniqueness using a set-theoretic lemma due to Dynkin.

A λ-system requires less than a σ-algebra: countable union only for increasing sequences and difference only for nested sets. It does not require intersections, the gap filled by a π-system.

Lemma. A family that is both a π-system and λ-system is a σ-algebra. Complements follow from (1) and (2) (Ac=Ω∖AA^c = \Omega \setminus A); π-system intersections and De Morgan yield finite unions A∪B=(Ac∩Bc)cA \cup B = (A^c \cap B^c)^c; a countable union is the increasing limit of finite unions Bn=A1∪⋯∪AnB_n = A_1 \cup \dots \cup A_n, in the family by (3).

The smallest example shows why intersection closure is key. Take Ω={1,2,3,4}\Omega = \{1, 2, 3, 4\} and events A={1,2}A = \{1, 2\} and B={2,3}B = \{2, 3\}. A probability with P(A)=P(B)=1/2\Pr(A) = \Pr(B) = 1/2 is not determined: the uniform one and the one assigning mass 1/21/2 to 22 and 44 agree on AA and BB but differ on {1}\{1\}, which is in σ(A,B)\sigma(A, B). Adding intersection {2}\{2\} determines probability completely.

InteractiveWhen does a family determine a measure?
Ω={1,2,3,4}\Omega = \{1,2,3,4\} with reference probability p∗=(0.4,0.1,0.3,0.2)p^* = (0.4, 0.1, 0.3, 0.2). An event in the family fixes p∗(B)p^*(B); what else is fixed?
Three probabilities agree on P\mathcal{P} and differ on {1,3} (inside σ(P)\sigma(\mathcal{P})). The dashed line marks p∗p^*.
0.4010.1020.3030.204
p∗({1,3})=0.70p^*(\{1,3\}) = 0.70
0.1010.4020.0030.504
q1({1,3})=0.10q_1(\{1,3\}) = 0.10
0.5010.0020.4030.104
q2({1,3})=0.90q_2(\{1,3\}) = 0.90
Example families
Is P\mathcal{P} a π\pi-system?no
atoms of σ(P)\sigma(\mathcal{P})4
vertices of measure polytope2
events with free probability10 of 14
P\mathcal{P} is not a π\pi-system and fails: distinct measures agree on P\mathcal{P} but differ on {1,3}, which lies in σ(P)\sigma(\mathcal{P}). Close under intersections.
A reference probability p∗p^* on {1,2,3,4}\{1, 2, 3, 4\} and a family P\mathcal{P} of events you choose (select events). The diagram computes all probabilities agreeing with p∗p^* on P\mathcal{P} and marks each event: determined (green) or free, with its possible-value interval (orange); σ\sigma marks those in σ(P)\sigma(\mathcal{P}). Start with {1,2}\{1,2\} and {2,3}\{2,3\}: distinct measures agree on P\mathcal{P}. Select ‘Close under intersections’. Then try ‘three pairs’, which is not a π-system: does it determine the measure? Does that contradict the theorem?

This is the π-λ theorem, a course-wide uniqueness tool: to prove a property throughout a σ-algebra, establish it on a generating π-system and show sets satisfying it form a λ-system.

Proof

Let ℓ(P)\ell(\mathcal{P}) be the intersection of all λ-systems containing P\mathcal{P}; it is a λ-system (the three properties pass to intersections, as for σ-algebras) and ℓ(P)⊂L\ell(\mathcal{P}) \subset \mathcal{L}. It suffices to show ℓ(P)\ell(\mathcal{P}) is a π-system: by the lemma it is then a σ-algebra containing P\mathcal{P}, so σ(P)⊂ℓ(P)⊂L\sigma(\mathcal{P}) \subset \ell(\mathcal{P}) \subset \mathcal{L}.

Step 1. Fix A∈PA \in \mathcal{P} and let LA={B:A∩B∈ℓ(P)}\mathcal{L}_A = \{B : A \cap B \in \ell(\mathcal{P})\}. It is a λ-system: Ω∈LA\Omega \in \mathcal{L}_A because A∩Ω=A∈PA \cap \Omega = A \in \mathcal{P}; if B⊂CB \subset C belong to LA\mathcal{L}_A, A∩(C∖B)=(A∩C)∖(A∩B)A \cap (C \setminus B) = (A \cap C) \setminus (A \cap B) is a difference of nested elements of ℓ(P)\ell(\mathcal{P}); and Bn↑BB_n \uparrow B gives A∩Bn↑A∩BA \cap B_n \uparrow A \cap B. Also P⊂LA\mathcal{P} \subset \mathcal{L}_A because P\mathcal{P} is a π-system. Therefore ℓ(P)⊂LA\ell(\mathcal{P}) \subset \mathcal{L}_A: A∩B∈ℓ(P)A \cap B \in \ell(\mathcal{P}) for A∈PA \in \mathcal{P} and B∈ℓ(P)B \in \ell(\mathcal{P}).

Step 2. Fix B∈ℓ(P)B \in \ell(\mathcal{P}) and let LB′={C:B∩C∈ℓ(P)}\mathcal{L}'_B = \{C : B \cap C \in \ell(\mathcal{P})\}. The same argument gives a λ-system, which contains P\mathcal{P} by step 1. It therefore contains ℓ(P)\ell(\mathcal{P}): the family is closed under intersections. ■\blacksquare

∎
Proof

For each nn, let Ln={A∈F:μ(A∩En)=ν(A∩En)}\mathcal{L}_n = \{A \in \mathcal{F} : \mu(A \cap E_n) = \nu(A \cap E_n)\}. It contains P\mathcal{P} (because A∩En∈PA \cap E_n \in \mathcal{P} and they agree there), Ω\Omega (because μ(En)=ν(En)\mu(E_n) = \nu(E_n)), and is closed under differences of nested sets because measures of A∩EnA \cap E_n are finite and subtractable, and under increasing unions by continuity from below. It is a λ-system and by the π-λ theorem contains σ(P)=F\sigma(\mathcal{P}) = \mathcal{F}. For each A∈FA \in \mathcal{F}, μ(A∩En)=ν(A∩En)\mu(A \cap E_n) = \nu(A \cap E_n) and, letting n→∞n \to \infty using continuity from below, μ(A)=ν(A)\mu(A) = \nu(A). ■\blacksquare

∎

The most-used consequence: a probability on (R,B(R))(\R, \mathcal{B}(\R)) is determined by its distribution function x↦P((−∞,x])x \mapsto \Pr((-\infty, x]), since rays form a π-system ((−∞,x]∩(−∞,y]=(−∞,min⁡(x,y)](-\infty, x] \cap (-\infty, y] = (-\infty, \min(x, y)]) generating B(R)\mathcal{B}(\R) by the generator theorem. A guided exercise proves it step by step. For Lebesgue measure, intervals (a,b](a, b] form a generating π-system and En=(−n,n]E_n = (-n, n] have finite length.

Existence: from length to Lebesgue measure

The inverse problem is construction: we want a measure λ\lambda on B(R)\mathcal{B}(\R) with λ((a,b])=b−a\lambda((a, b]) = b - a. Uniqueness is established. For existence, assign values consistently to every Borel set; Carathéodory’s recipe measures “from outside”: approximate each set by interval covers, then find sets for which that approximation behaves additively.

Outer measure

Outer measure is defined on all subsets of R\R, without contradicting Vitali because λ∗\lambda^* is not additive on all of them. What it does satisfy is summarized in three properties.

Proof

(a) is immediate. (b) If any λ∗(An)=∞\lambda^*(A_n) = \infty there is nothing to prove. Otherwise fix ε>0\varepsilon > 0 and cover each AnA_n with open intervals of total length below λ∗(An)+ε/2n\lambda^*(A_n) + \varepsilon/2^n. Together they form a countable cover of ⋃nAn\bigcup_n A_n of total length below ∑nλ∗(An)+∑nε/2n=∑nλ∗(An)+ε\sum_n \lambda^*(A_n) + \sum_n \varepsilon/2^n = \sum_n \lambda^*(A_n) + \varepsilon. Since ε\varepsilon is arbitrary, (b) follows. This “geometric tip” ε/2n\varepsilon/2^n is the most-used trick in the theory.

(c) Bound λ∗(I)≤b−a\lambda^*(I) \le b - a is immediate by covering with (a−ε,b+ε)(a - \varepsilon, b + \varepsilon). For the other, it suffices to show that if [a,b]⊂⋃n(an,bn)[a, b] \subset \bigcup_n (a_n, b_n) then b−a≤∑n(bn−an)b - a \le \sum_n (b_n - a_n), then apply monotonicity to [a+δ,b−δ]⊂I[a + \delta, b - \delta] \subset I. By compactness (compactness of [a,b][a, b]), a finite subcover suffices. Order it as follows: take an interval (c1,d1)(c_1, d_1) containing aa; if d1≤bd_1 \le b, d1∈[a,b]d_1 \in [a, b] is covered by another (c2,d2)(c_2, d_2) with c2<d1<d2c_2 < d_1 < d_2; continue until some dk>bd_k > b. Since ci+1<dic_{i+1} < d_i, ∑i≤k(di−ci)≥dk−c1>b−a\sum_{i \le k} (d_i - c_i) \ge d_k - c_1 > b - a. ■\blacksquare

∎

Proof (b) contains nearly everything needed to see a surprising property of measure with your own eyes: a dense set can have outer measure zero.

InteractiveCovering rationals with length ε
intervals of length ε/2ⁿ centered on each rational (points)their unionuncovered (46 gaps in the window)0.000.501.00
Full view of [0,1][0, 1]. Initial intervals are large; each subsequent one halves.
  • interval InI_n of length ε/2n\varepsilon/2^n
  • rational rnr_n
  • uncovered points
0.200
12 (47 rationals)
×1
0.5000
rationals covered47
sum of lengths ∑ε/2n\sum \varepsilon/2^n0.20000 (≤ ε)
union measure in [0,1][0,1]0.12500
uncovered part of [0,1][0,1]≥ 0.800 (real: 0.87500)
in window: uncovered87.50 % in 46 gaps
Rationals are dense yet fit in a union of intervals of total length ≤ε\le \varepsilon. As ε\varepsilon is arbitrary, λ∗(Q∩[0,1])=0\lambda^*(\mathbb{Q} \cap [0,1]) = 0.
Rationals in [0,1][0, 1], ordered by denominator, are covered by intervals of lengths ε/2\varepsilon/2, ε/4\varepsilon/4, ε/8\varepsilon/8, ... (top), whose union (middle) cannot measure more than ε\varepsilon. Below in green is the uncovered remainder. Lower ε\varepsilon, increase the maximum denominator and zoom in (you can also drag): green never disappears, and small intervals appear near every rational. Select ‘Zoom to largest gap’ repeatedly at high magnification: are there gaps inside gaps?

Each rational rnr_n is one point and fits in an arbitrarily short interval. Enumeration r1,r2,r3,…r_1, r_2, r_3, \dots (available because Q∩[0,1]\Q \cap [0, 1] is countable, here by increasing denominator: 0,1,12,13,23,…0, 1, \tfrac12, \tfrac13, \tfrac23, \dots) lets us reserve for rnr_n an interval of length ε/2n\varepsilon/2^n. Intervals are dense in the sense that every rational lies in one, but total length is ∑n≥1ε/2n=ε\sum_{n \ge 1} \varepsilon/2^n = \varepsilon. Thus λ∗(Q∩[0,1])≤ε\lambda^*(\Q \cap [0, 1]) \le \varepsilon for every ε>0\varepsilon > 0, i.e. λ∗(Q∩[0,1])=0\lambda^*(\Q \cap [0, 1]) = 0. An often surprising corollary: the complement of that open dense union is a closed set containing no rationals and having measure at least 1−ε1 - \varepsilon. It is a closed set without intervals (topologists call it nowhere dense) with almost full measure: topology and measure measure different things.

This differs from the length underlying the Riemann integral (Jordan content), which permits only finite covers. If finitely many intervals cover Q∩[0,1]\Q \cap [0, 1], the union of their closures is closed and contains a dense subset of [0,1][0, 1], hence all [0,1][0, 1], and total length is at least 11. With finite covers rationals “measure” 11 from outside and 00 from inside: they have no Jordan content, so the rational indicator (Dirichlet function) is not Riemann integrable. Moving from finite to countable covers is exactly Lebesgue’s addition, making that function’s integral 00.

Carathéodory’s theorem

λ∗\lambda^* is not generally additive; Carathéodory’s solution keeps sets on which it is.

Subadditivity already gives ≤\le. The requirement is ≥\ge.

Proof

This is the Carathéodory extension theorem in outer-measure form; the full proof follows. ∅,Ω∈M\emptyset, \Omega \in \mathcal{M} and complement closure of M\mathcal{M} are clear because the definition is symmetric in AA and AcA^c.

Algebra. If A,B∈MA, B \in \mathcal{M} and EE is arbitrary, use AA and then BB:

μ∗(E)=μ∗(E∩A)+μ∗(E∖A)=μ∗(E∩A)+μ∗((E∖A)∩B)+μ∗(E∖(A∪B)).\mu^*(E) = \mu^*(E \cap A) + \mu^*(E \setminus A) = \mu^*(E \cap A) + \mu^*((E \setminus A) \cap B) + \mu^*(E \setminus (A \cup B)).

Since E∩(A∪B)=(E∩A)∪((E∖A)∩B)E \cap (A \cup B) = (E \cap A) \cup ((E \setminus A) \cap B), subadditivity gives μ∗(E∩A)+μ∗((E∖A)∩B)≥μ∗(E∩(A∪B))\mu^*(E \cap A) + \mu^*((E \setminus A) \cap B) \ge \mu^*(E \cap (A \cup B)). Thus μ∗(E)≥μ∗(E∩(A∪B))+μ∗(E∖(A∪B))\mu^*(E) \ge \mu^*(E \cap (A \cup B)) + \mu^*(E \setminus (A \cup B)) and A∪B∈MA \cup B \in \mathcal{M}. Also, if A,B∈MA, B \in \mathcal{M} are disjoint, applying the definition of AA to set E∩(A∪B)E \cap (A \cup B) gives μ∗(E∩(A∪B))=μ∗(E∩A)+μ∗(E∩B)\mu^*(E \cap (A \cup B)) = \mu^*(E \cap A) + \mu^*(E \cap B), and induction gives the same for nn disjoint sets.

Countable unions. Let Ak∈MA_k \in \mathcal{M} be disjoint and A=⨆kAkA = \bigsqcup_k A_k. With Bn=A1⊔⋯⊔An∈MB_n = A_1 \sqcup \dots \sqcup A_n \in \mathcal{M}, and since E∖Bn⊃E∖AE \setminus B_n \supset E \setminus A,

μ∗(E)=μ∗(E∩Bn)+μ∗(E∖Bn)≥∑k≤nμ∗(E∩Ak)+μ∗(E∖A).\mu^*(E) = \mu^*(E \cap B_n) + \mu^*(E \setminus B_n) \ge \sum_{k \le n} \mu^*(E \cap A_k) + \mu^*(E \setminus A).

Let n→∞n \to \infty and use countable subadditivity: μ∗(E)≥∑kμ∗(E∩Ak)+μ∗(E∖A)≥μ∗(E∩A)+μ∗(E∖A)\mu^*(E) \ge \sum_k \mu^*(E \cap A_k) + \mu^*(E \setminus A) \ge \mu^*(E \cap A) + \mu^*(E \setminus A). Thus A∈MA \in \mathcal{M}, and E=AE = A yields μ∗(A)=∑kμ∗(Ak)\mu^*(A) = \sum_k \mu^*(A_k): countable additivity. Any countable union becomes disjoint using Ak′=Ak∖(A1∪⋯∪Ak−1)A_k' = A_k \setminus (A_1 \cup \dots \cup A_{k-1}), and M\mathcal{M} is a σ-algebra.

Null sets. If μ∗(N)=0\mu^*(N) = 0, then μ∗(E∩N)+μ∗(E∖N)≤0+μ∗(E)\mu^*(E \cap N) + \mu^*(E \setminus N) \le 0 + \mu^*(E) by monotonicity. ■\blacksquare

∎

For length we must check that M\mathcal{M} contains Borel sets. It suffices to show rays (−∞,b](-\infty, b] are λ∗\lambda^*-measurable. Let EE with λ∗(E)<∞\lambda^*(E) < \infty and cover it by open intervals JnJ_n of total length below λ∗(E)+ε\lambda^*(E) + \varepsilon. Intervals Jn∩(−∞,b]J_n \cap (-\infty, b] cover E∩(−∞,b]E \cap (-\infty, b], Jn∩(b,∞)J_n \cap (b, \infty) cover E∖(−∞,b]E \setminus (-\infty, b], and lengths of the two pieces of JnJ_n sum to that of JnJ_n. By outer-measure property (c) for an interval (even if not open) and subadditivity, λ∗(E∩(−∞,b])+λ∗(E∖(−∞,b])≤λ∗(E)+ε\lambda^*(E \cap (-\infty, b]) + \lambda^*(E \setminus (-\infty, b]) \le \lambda^*(E) + \varepsilon. Since ε\varepsilon is arbitrary, the condition holds. Thus M⊃σ(semirrectas)=B(R)\mathcal{M} \supset \sigma(\text{semirrectas}) = \mathcal{B}(\R).

Uniqueness has free consequences. Measure A↦λ(A+x)A \mapsto \lambda(A + x) also equals b−ab - a on (a,b](a, b], so agrees with λ\lambda: Lebesgue measure is translation invariant. Likewise, for c≠0c \ne 0, measure A↦λ(cA)/∣c∣A \mapsto \lambda(cA)/\abs{c} agrees with λ\lambda on intervals, hence λ(cA)=∣c∣ λ(A)\lambda(cA) = \abs{c}\,\lambda(A). By Vitali the earlier set VV is not measurable: M≠P(R)\mathcal{M} \ne \mathcal{P}(\R). On Rn\R^n proceed likewise with boxes ∏i(ai,bi]\prod_i (a_i, b_i] and volume ∏i(bi−ai)\prod_i (b_i - a_i).

The general mechanism uses nothing specific to R\R except that length, measured on finite unions of intervals (a,b](a, b], is countably additive (exactly what the compactness argument in (c) guarantees). This is the usual statement.

Existence is built with μ∗(E)=inf⁡{∑nμ0(An):E⊂⋃nAn, An∈A}\mu^*(E) = \inf\{\sum_n \mu_0(A_n) : E \subset \bigcup_n A_n,\ A_n \in \mathcal{A}\} and the proof above; uniqueness follows from the π-λ theorem (an algebra is a π-system). This constructs Lebesgue–Stieltjes measure associated with a distribution function and, in the product-measure lesson, measure on Rn\R^n and the law of infinite sequences of random variables. Tao (2011, chapter 1, linked in sources) develops the construction fully.

Null sets and “almost surely”

A countable union of null sets is null by subadditivity. Every countable set is Lebesgue-null because each point fits in an interval of length ε/2n\varepsilon/2^n, as just seen with rationals. Thus if you choose X∼Unif⁡[0,1]X \sim \Unif[0, 1], almost surely XX is irrational. But null does not mean impossible: P(X=1/2)=0\Pr(X = 1/2) = 0 and XX can take value 1/21/2 (a continuous variable takes some value, all having probability zero). Functions differing only on a null set are indistinguishable for integration, as the Lebesgue integral will show.

A final technical detail. Subsets of a null set need not be measurable in F\mathcal{F}. A measure is complete if they are. Every measure space has a completion (add subsets of null sets to F\mathcal{F}), and the Lebesgue σ-algebra M\mathcal{M} from Carathéodory’s theorem is the completion of B(R)\mathcal{B}(\R). Probability usually works with uncompleted F\mathcal{F} and writes “a.s.” to avoid dependence on that.

The Cantor set: null and uncountable

Some null sets are far larger than countable ones. The most famous is built by removing thirds.

Let C0=[0,1]C_0 = [0, 1] and CnC_n be what remains of Cn−1C_{n-1} after removing the open middle third of each interval. CnC_n is a union of 2n2^n intervals of length 3−n3^{-n}, and the Cantor set is C=⋂nCnC = \bigcap_n C_n.

InteractiveConstructing the Cantor set
step 0: [0, 1]step 1step 2step 3step 4step 5
Ternary expansion of x=0.2500x = 0.2500 (Cantor rule: 00 or 22 if possible):
0.02020202020202…3
x∈Cx \in C. Its 0/20/2 digits read as 0/10/1 in base 2 give y=0.333333y = 0.333333. This map x↦yx \mapsto y covers [0,1][0, 1], so CC is uncountable.
  • middle third: (2/3)ⁿ
  • fat Cantor: 1/2 + 2⁻⁽ⁿ⁺¹⁾
  • remaining intervals
  • point xx
  • removed point
What is removed
5
0.2500
Named points:
intervals at step nn2^5 = 32
length of each3^−5 = 0.0041
total remaining length(2/3)^5 = 0.1317
Does xx survive step 55?yes
Length (2/3)n→0(2/3)^n \to 0: Cantor set C=⋂nCnC = \bigcap_n C_n has measure 00 by continuity from above, yet is uncountable.
Increase step nn: middle thirds are removed and remaining length falls as (2/3)n(2/3)^n. Drag point xx (or choose a named one) and read its ternary expansion: it survives every step exactly when it can be written with no digit 11. Try 1/41/4, 1/31/3 and 1/21/2. The 0/20/2 digits of a point in CC, read as 0/10/1 in base 2, give a number in [0,1][0, 1]: this shows CC is uncountable. Switch to ‘fat Cantor’: if step kk removes a gap of length 4−k4^{-k} from each interval, where does remaining length tend?

It is null. λ(Cn)=2n⋅3−n=(2/3)n→0\lambda(C_n) = 2^n \cdot 3^{-n} = (2/3)^n \to 0, and since Cn↓CC_n \downarrow C with λ(C0)=1<∞\lambda(C_0) = 1 < \infty, continuity from above gives λ(C)=0\lambda(C) = 0.

It is uncountable. Each x∈[0,1]x \in [0, 1] has a ternary expansion x=∑k≥1dk3−kx = \sum_{k \ge 1} d_k 3^{-k} with dk∈{0,1,2}d_k \in \{0, 1, 2\}. A point belongs to CnC_n if and only if it admits an expansion whose first nn digits are not 11 (the first step removes exactly xx whose first digit must be 11; the next acts likewise within each remaining third). Thus CC is the set of xx admitting an expansion using only digits 00 and 22. Map φ:{0,2}N→C\varphi : \{0, 2\}^{\N} \to C, φ(d)=∑kdk3−k\varphi(d) = \sum_k d_k 3^{-k} is injective: if two sequences first differ at mm, with dm=2d_m = 2 and dm′=0d'_m = 0, the difference of their images is at least 2⋅3−m−∑k>m2⋅3−k=3−m>02 \cdot 3^{-m} - \sum_{k > m} 2 \cdot 3^{-k} = 3^{-m} > 0. Map d↦∑k(dk/2) 2−kd \mapsto \sum_k (d_k/2)\, 2^{-k} from {0,2}N\{0, 2\}^{\N} to [0,1][0, 1] is surjective, because every number in [0,1][0, 1] has a binary expansion. Therefore CC has at least as many points as [0,1][0, 1] (in cardinality terms: {0,2}N\{0, 2\}^{\N} injects into CC and maps onto [0,1][0, 1]), is uncountable (Cantor diagonal) and ∣C∣=c\abs{C} = \mathfrak{c}.

Four consequences:

  • Null does not mean countable or empty. CC has the cardinality of R\R and measure 00. “Negligible for measure” and “small as a set” are different ideas.
  • Some Lebesgue sets are not Borel. By completeness, all 2c2^{\mathfrak{c}} subsets of CC are λ\lambda-measurable (null). Since B(R)\mathcal{B}(\R) has only c\mathfrak{c} elements, the Lebesgue σ-algebra is strictly larger than Borel’s.
  • Null is not the same as topologically small. In the figure’s “fat Cantor” set, step kk removes a gap of length 4−k4^{-k} from each of 2k−12^{k-1} intervals; removed length is ∑k2k−14−k=1/2\sum_k 2^{k-1} 4^{-k} = 1/2, leaving a closed, interval-free, uncountable set of measure 1/21/2.
  • Digits matter. Numbers in [0,1)[0, 1) whose first nn decimal digits contain no 7 have measure 0.9n0.9^n; those with no 7 in any position have measure lim⁡0.9n=0\lim 0.9^n = 0 but are uncountable by the same argument as CC. Almost every real contains every digit, in a sense the strong law will make precise.

Implementation from scratch

The whole lesson can be explored on finite sets with exact arithmetic. First, finite σ-algebras: compute the generated one by closure under complements and unions (iterating until unchanged), extract atoms with the rule “two points are indistinguishable if they belong to the same family sets”, and verify ∣σ∣=2#aˊtomos|\sigma| = 2^{\#\text{átomos}}, the finite-σ-algebra theorem. Examples are from the information figure.

[ ]Finite σ-algebras: closure, atoms and filtrationBrowser
from itertools import combinations, product

def cierre_sigma(omega, familia):
    """σ-álgebra generada por `familia` sobre un Ω finito: cierre por complemento y unión."""
    omega = frozenset(omega)
    S = {frozenset(), omega} | {frozenset(A) for A in familia}
    cambio = True
    while cambio:
        cambio = False
        for A in list(S):
            if omega - A not in S:
                S.add(omega - A)
                cambio = True
        for A, B in combinations(list(S), 2):
            if A | B not in S:
                S.add(A | B)
                cambio = True
    return S

def atomos(omega, familia):
    """Clases de puntos con la misma pertenencia a todos los conjuntos de la familia."""
    grupos = {}
    for w in omega:
        grupos.setdefault(tuple(w in A for A in familia), set()).add(w)
    return [frozenset(g) for g in grupos.values()]

omega = ["".join(t) for t in product("CX", repeat=3)]         # CCC, CCX, ..., XXX
caras = lambda w: w.count("C")
observaciones = {
    "nada":            [],
    "1.er lanzamiento": [{w for w in omega if w[0] == "C"}],
    "2 primeros":      [{w for w in omega if w[0] == "C"}, {w for w in omega if w[1] == "C"}],
    "los 3":           [{w for w in omega if w[i] == "C"} for i in range(3)],
    "nº de caras":     [{w for w in omega if caras(w) == k} for k in range(4)],
}
sigmas = {}
for nombre, fam in observaciones.items():
    S = cierre_sigma(omega, fam)
    at = atomos(omega, fam)
    sigmas[nombre] = S
    print(f"{nombre:17s} átomos = {len(at)}   |σ| = {len(S):3d}   2^átomos = {2 ** len(at):3d}")
    assert len(S) == 2 ** len(at)

# Cada elemento de σ es una unión de átomos, y la filtración crece
F = sigmas
print("\nF0 ⊂ F1 ⊂ F2 ⊂ F3:", F["nada"] <= F["1.er lanzamiento"] <= F["2 primeros"] <= F["los 3"])
print("σ(nº de caras) ⊂ σ(2 primeros)?", F["nº de caras"] <= F["2 primeros"],
      "   σ(2 primeros) ⊂ σ(nº de caras)?", F["2 primeros"] <= F["nº de caras"])

The last two print answer the figure’s question: observing head count is neither more nor less informative than the first two tosses, and σ-algebras are incomparable.

Second, π-λ in the finite world. “Determine a measure” is a linear-algebra problem: probabilities qq of {1,2,3,4}\{1, 2, 3, 4\} agreeing with pp on the family are affine solutions of a system, determined when its rank is 44. Code computes degrees of freedom and constructs two different measures agreeing on the family.

[ ]Does a family determine the measure? Rank and degrees of freedomBrowser
import numpy as np

omega = [1, 2, 3, 4]
p = np.array([0.4, 0.1, 0.3, 0.2])
indicadora = lambda A: np.array([1.0 if w in A else 0.0 for w in omega])

def sistema(familia):
    """Filas: Ω (suma 1) y un suceso por conjunto de la familia."""
    return np.array([np.ones(4)] + [indicadora(B) for B in familia])

def es_pi_sistema(familia):
    fam = [frozenset(B) for B in familia]
    return all((A & B) == frozenset() or (A & B) in fam for A in fam for B in fam)

familias = {
    "{1,2}, {2,3}":            [{1, 2}, {2, 3}],
    "{1,2}, {2,3}, {2}":       [{1, 2}, {2, 3}, {2}],
    "{1,2}, {2,3}, {1,3}":     [{1, 2}, {2, 3}, {1, 3}],
    "{1,2}":                   [{1, 2}],
    "{1}, {2}, {3}":           [{1}, {2}, {3}],
}
for nombre, fam in familias.items():
    M = sistema(fam)
    libres = 4 - np.linalg.matrix_rank(M)
    print(f"{nombre:22s} π-sistema: {str(es_pi_sistema(fam)):5s}  grados de libertad: {libres}")

# Dos medidas distintas que coinciden en {1,2} y {2,3}
M = sistema(familias["{1,2}, {2,3}"])
v = np.linalg.svd(M)[2][-1]              # dirección del núcleo de M
v = v / np.abs(v).max()
q = p + 0.1 * v
print("\ndirección:", np.round(v, 3))
print("p =", p, "  q =", np.round(q, 3))
print("coinciden en {1,2}:", np.isclose(p[[0, 1]].sum(), q[[0, 1]].sum()), "  en {2,3}:", np.isclose(p[[1, 2]].sum(), q[[1, 2]].sum()))
print("pero p({1}) =", p[0], " y q({1}) =", round(q[0], 3))

Notice row three: family {1,2},{2,3},{1,3}\{1,2\}, \{2,3\}, \{1,3\} is not a π-system, yet determines the measure. The theorem says a generating π-system suffices, not that it is necessary. Without that assumption there is no guarantee, as row one shows.

Third, remaining length of Cantor-type sets using exact fractions, and checking that 1/41/4 belongs to CC (its ternary digits alternate 00 and 22) while 1/21/2 does not. Then how many steps make classical length fall below 0.0010.001 (n=18n = 18). Finally a digit-exercise simulation: the fraction of uniform [0,1)[0, 1) numbers whose first ten decimal digits contain no 7 should be near 0.9100.9^{10}.

[ ]The Cantor set with exact arithmeticBrowser
from fractions import Fraction as Fr
import numpy as np

def paso(intervalos, k, tipo):
    """Un paso: se elimina un hueco abierto centrado de cada intervalo."""
    nuevos = []
    for a, b in intervalos:
        hueco = (b - a) / 3 if tipo == "clásico" else Fr(1, 4 ** k)
        m = (a + b) / 2
        nuevos += [(a, m - hueco / 2), (m + hueco / 2, b)]
    return nuevos

for tipo in ("clásico", "gordo"):
    I = [(Fr(0), Fr(1))]
    for k in range(1, 11):
        I = paso(I, k, tipo)
        if k in (1, 2, 5, 10):
            L = sum(b - a for a, b in I)
            esperado = Fr(2, 3) ** k if tipo == "clásico" else Fr(1, 2) + Fr(1, 2 ** (k + 1))
            print(f"{tipo:8s} paso {k:2d}: {len(I):4d} intervalos, longitud = {float(L):.6f}   fórmula: {float(esperado):.6f}   iguales: {L == esperado}")
    print()

def ternario(x, n=12):
    """Dígitos ternarios con la regla de Cantor (0 o 2 si se puede) y posición del primer 1."""
    digitos, vivo, primero = [], True, None
    for k in range(n):
        t = 3 * x
        if vivo and t <= 1:
            d, x = 0, t
        elif vivo and t >= 2:
            d, x = 2, t - 2
        elif vivo:
            d, x, vivo, primero = 1, t - 1, False, k + 1
        else:
            d = min(2, int(t)); x = t - d
        digitos.append(d)
    return digitos, primero

for x in (Fr(1, 4), Fr(1, 3), Fr(1, 10), Fr(1, 2), Fr(1, 20)):
    d, primero = ternario(x)
    print(f"{str(x):5s} dígitos {''.join(map(str, d))}   primer 1 en la posición {primero}   {'está en C' if primero is None else 'no está en C'}")

n = 18
print(f"\n(2/3)^{n} = {(2 / 3) ** n:.6f} < 0.001; con n = {n - 1}: {(2 / 3) ** (n - 1):.6f} > 0.001")

rng = np.random.default_rng(0)
x = rng.random(200_000)
decimales = (np.floor(x[:, None] * 10.0 ** np.arange(1, 11)) % 10).astype(int)
sin_siete = ~(decimales == 7).any(axis=1)
print(f"fracción sin ningún 7 en los 10 primeros decimales: {sin_siete.mean():.4f}   0.9^10 = {0.9 ** 10:.4f}")

Fourth, covering rationals. Enumerate them by denominator, give each an interval of length ε/2n\varepsilon/2^n and calculate the union measure exactly (merging intervals). Total length never exceeds ε\varepsilon and uncovered fraction is at least 1−ε1 - \varepsilon, though each rational is covered.

[ ]Covering rationals with length εBrowser
from math import gcd

def racionales(Q):
    r = [(0, 1), (1, 1)]
    for q in range(2, Q + 1):
        r += [(p, q) for p in range(1, q) if gcd(p, q) == 1]
    return r

def union_y_huecos(intervalos):
    """Fusiona intervalos [a, b] recortados a [0, 1]; devuelve la medida de la unión y la lista de huecos."""
    iv = sorted((max(0.0, a), min(1.0, b)) for a, b in intervalos)
    fusion = [list(iv[0])]
    for a, b in iv[1:]:
        if a <= fusion[-1][1]:
            fusion[-1][1] = max(fusion[-1][1], b)
        else:
            fusion.append([a, b])
    huecos = [(fusion[i][1], fusion[i + 1][0]) for i in range(len(fusion) - 1)]
    if fusion[0][0] > 0: huecos.insert(0, (0.0, fusion[0][0]))
    if fusion[-1][1] < 1: huecos.append((fusion[-1][1], 1.0))
    return sum(b - a for a, b in fusion), huecos

for eps in (0.5, 0.1, 0.01):
    for Q in (5, 12, 30):
        R = racionales(Q)
        L = [eps / 2 ** n for n in range(1, len(R) + 1)]
        medida, huecos = union_y_huecos([(p / q - l / 2, p / q + l / 2) for (p, q), l in zip(R, L)])
        mayor = max(b - a for a, b in huecos)
        print(f"eps = {eps:<5}  q <= {Q:2d}: {len(R):3d} racionales, suma de longitudes = {sum(L):.5f}, "
              f"unión = {medida:.5f}, sin cubrir = {1 - medida:.5f} (>= {1 - eps:.2f}), huecos = {len(huecos)}, mayor = {mayor:.4f}")

The library version

NumPy simulates Bertrand’s paradox vectorially: three recipes, half a million chords per recipe. SymPy calculates Lebesgue measure of sets built from interval set operations (Interval, Union) without manually writing any length formula: real Lebesgue measure restricted to the algebra of finite interval unions (the following note explains why it cannot go further).

[ ]Bertrand with NumPy and Lebesgue measure with SymPyBrowser
import numpy as np
from sympy import Interval, Union, Rational, S

rng = np.random.default_rng(1)
N = 500_000
lado = np.sqrt(3)

# 1) dos extremos uniformes en la circunferencia
a, b = rng.uniform(0, 2 * np.pi, (2, N))
largo1 = 2 * np.abs(np.sin((a - b) / 2)) > lado
# 2) distancia uniforme sobre un radio: la cuerda mide 2*sqrt(1 - d^2)
d = rng.uniform(0, 1, N)
largo2 = 2 * np.sqrt(1 - d ** 2) > lado
# 3) punto medio uniforme en el disco: la distancia al centro es sqrt(U)
r = np.sqrt(rng.uniform(0, 1, N))
largo3 = 2 * np.sqrt(1 - r ** 2) > lado
print("frecuencias:", largo1.mean().round(4), largo2.mean().round(4), largo3.mean().round(4), "  exactas: 1/3, 1/2, 1/4")

# Medida de Lebesgue de borelianos construidos con operaciones de conjuntos
cantor = [Interval(0, 1)]
for n in range(1, 5):
    nuevos = []
    for I in cantor:
        a_, b_ = I.start, I.end
        h = (b_ - a_) / 3
        nuevos += [Interval(a_, a_ + h), Interval(b_ - h, b_)]
    cantor = nuevos
    if n in (1, 2, 4):
        C_n = Union(*cantor)
        print(f"C_{n}: {len(cantor)} intervalos, medida = {C_n.measure} = {float(C_n.measure):.6f}")

U = Union(Interval(0, Rational(1, 2)), Interval(Rational(1, 4), 1))
print("medida de [0,1/2] U [1/4,1] =", U.measure, "  (solapan: no se suman)")
print("medida del complemento de [0,1] en [-1,2]:", Interval(-1, 2).measure - Interval(0, 1).measure)
print("un punto:", Interval(Rational(1, 3), Rational(1, 3)).measure, "  (Q ∩ [0,1] no es una unión finita de intervalos: SymPy no lo mide; su medida 0 sale del argumento ε/2^n)")

Common errors

Exercises

ProofThe generated σ-algebra exists
Prove: If {Fi}i∈I\{\mathcal{F}_i\}_{i \in I} is a nonempty family of σ-algebras on Ω\Omega, then F=⋂i∈IFi\mathcal{F} = \bigcap_{i \in I} \mathcal{F}_i is a σ-algebra. Therefore for every C⊂P(Ω)\mathcal{C} \subset \mathcal{P}(\Omega) there is a smallest σ-algebra containing C\mathcal{C}.
0
Check the three defining properties for F\mathcal{F}, then construct σ(C)\sigma(\mathcal{C}).

Step 1 of 4. How do you check Ω∈F\Omega \in \mathcal{F}?

ProofSame distribution function, same probability
Prove: Let P\Pr and P′\Pr' be probabilities on (R,B(R))(\R, \mathcal{B}(\R)) with P((−∞,x])=P′((−∞,x])\Pr((-\infty, x]) = \Pr'((-\infty, x]) for every x∈Rx \in \R. Then P=P′\Pr = \Pr' on all B(R)\mathcal{B}(\R).
0
Apply π-λ: select a generating π-system and show agreement sets form a λ-system.

Step 1 of 3. Which π-system P\mathcal{P} do you choose?

QuizWhich are π-systems?
Which of these families of subsets of R\R are π-systems (closed under finite intersections)?

More than one answer may be correct.

QuizA counterexample to continuity from above
Let λ\lambda be Lebesgue measure and An=[n,∞)A_n = [n, \infty). We have An↓∅A_n \downarrow \emptyset yet λ(An)=∞\lambda(A_n) = \infty for every nn. Which assumption of continuity from above fails?
NumericDecimals without a seven
Calculate Lebesgue measure of the set of x∈[0,1)x \in [0, 1) whose first ten decimal digits contain no digit 77.
NumericSize of a generated σ-algebra
Let Ω={1,2,3,4,5,6}\Omega = \{1, 2, 3, 4, 5, 6\}, A={1,2,3}A = \{1, 2, 3\} and B={2,3,4}B = \{2, 3, 4\}. How many elements does σ({A,B})\sigma(\{A, B\}) have?
NumericA different fat Cantor set
A Cantor-like set is built by removing at step kk (k=1,2,…k = 1, 2, \dots) an open central interval of length 5−k5^{-k} from each of 2k−12^{k-1} remaining intervals. What is the Lebesgue measure of the limiting set?
CodeAtoms of the generated σ-algebra
Implement atoms(sets, omega), taking a list sets of subsets of omega (a finite iterable) and returning the list of atoms of the σ-algebra they generate: the partition of omega into classes of points belonging to exactly the same sets in sets. Each atom must be a frozenset. List order does not matter. With empty sets the only atom is all of omega. Tests check it is a partition and generated σ-algebra cardinality is 2k2^k with kk the atom count.
def atoms(sets, omega):
  """Devuelve la lista de átomos (frozensets) de la σ-álgebra generada por sets sobre omega."""
  omega = list(omega)
  # tu código: agrupa los puntos por su "firma" de pertenencia a cada conjunto de sets
  return [frozenset(omega)]
Shift+Enter to run

Summary

Key idea
A σ-algebra is the family of answerable yes/no questions, closed under what limits require: complements and countable unions. Vitali proves we must give up measuring every subset, and measure theory constructs measures on σ-algebras generated by simple families: π-λ guarantees uniqueness and Carathéodory extension existence.
  • “Choose at random” requires a measure. Bertrand’s paradox has three answers, 1/31/3, 1/21/2 and 1/41/4, because there are three measures on chords.
  • No countably additive, translation-invariant normalized measure exists on every subset of [0,1)[0, 1) (Vitali). The domain is restricted to a σ-algebra F\mathcal{F}.
  • A σ-algebra contains Ω\Omega and is closed under complements and countable unions. That generated by a family is the intersection of all containing it. On finite Ω\Omega it corresponds to a partition into atoms and has 2k2^k elements. Observing more refines the partition, and a filtration is an increasing σ-algebra sequence.
  • B(R)\mathcal{B}(\R) is generated by open sets and also by rays (−∞,b](-\infty, b], because rationals are countable and dense. It is too large to enumerate.
  • A measure is countably additive, yielding monotonicity, subadditivity and continuity from below (always) and above (when some set has finite measure).
  • π-λ. If two measures agree on a generating π-system and finite-measure sets increase to Ω\Omega, they agree everywhere. In particular, a probability on R\R is determined by its distribution function.
  • Carathéodory. Outer measure λ∗\lambda^* restricted to sets that split every set additively is a measure and contains the Borel sets: Lebesgue measure, unique with λ((a,b])=b−a\lambda((a, b]) = b - a and translation invariant.
  • Null sets have measure zero, and “almost surely” means outside a null set. Countable sets are null, and the Cantor set is null and uncountable. Fat versions have positive measure.