Probability, Measure, Kernels, and Computable Sampling
Run the program 𝗑𝗈𝗋𝟤=𝑏1←𝖼𝗈𝗂𝗇;𝑏2←𝖼𝗈𝗂𝗇;𝗋𝖾𝗍𝗎𝗋𝗇(𝑏1⊕𝑏2) in two different ways. Enumerate: there are four equiprobable assignments to (𝑏1,𝑏2), of which two make 𝑏1⊕𝑏2 true, so the program denotes the table {𝖿𝖿↦1/2,𝗍𝗍↦1/2}. Execute: feed the program a stream of fair bits, let the first 𝖼𝗈𝗂𝗇 consume the first bit and the second 𝖼𝗈𝗂𝗇 the second; on the stream beginning 0,1 the run performs 𝚍𝚛𝚊𝚠0, 𝚍𝚛𝚊𝚠1, 𝚛𝚎𝚝𝚞𝚛𝚗𝗍𝗍. The two answers agree, and for this program the agreement can be checked by inspecting four cases.
Now replace 𝖼𝗈𝗂𝗇 by a draw from the uniform distribution on [0,1]. The enumeration has no finite table to produce, and the two descriptions come apart: on one side a measure on an uncountable space, on the other a program that turns a bit stream into a real number. Neither side is automatically the other. A measure is a set function with no computational content; a sampler is a partial function on bit streams whose output distribution must be proved to be the intended measure.
This chapter builds the measure-theoretic vocabulary that the rest of the volume uses — measurable spaces, measures, integration, products, and kernels, each law calculated on finite distributions before it is proved at the general signature — and then proves the exact correspondence between the two descriptions for the class of spaces where both make sense. The organizing object is the kernel: it is what a probabilistic program of one argument denotes, its bind operation is what sequencing denotes, and every law exported by this chapter is a law of kernels or of the integrals that define them. Conditioning is not in this chapter. Conditioning asks for a family of measures indexed by an observed value, determined only up to a null set of those values, and neither its construction nor its computability is settled by anything proved here.
Let 𝐴 be a set. A finite subdistribution on 𝐴 is a function 𝑚:𝐴→ℚ∩[0,1] with finite support supp(𝑚)={𝑎∣𝑚(𝑎)>0} and |𝑚|=∑𝑎𝑚(𝑎)≤1; it is a distribution when |𝑚|=1. Write 𝛿𝑎 for the distribution with 𝛿𝑎(𝑎)=1, and for a family (𝑚𝑎)𝑎∈𝐴 of subdistributions on 𝐵 write (𝑚≫=𝑘)(𝑏)=∑𝑎∈supp(𝑚)𝑚(𝑎)𝑘(𝑎)(𝑏).
The fragment used throughout this section has terms 𝑡::=𝖼𝗈𝗂𝗇∣𝗋𝖾𝗍𝗎𝗋𝗇𝑣∣𝑥←𝑡;𝑡, where 𝑣 ranges over Boolean expressions in the bound variables. Its exact denotation is the finite subdistribution E(𝑡) defined by E(𝖼𝗈𝗂𝗇)={𝖿𝖿↦12,𝗍𝗍↦12},E(𝗋𝖾𝗍𝗎𝗋𝗇𝑣)=𝛿𝑣,E(𝑥←𝑡1;𝑡2)=E(𝑡1)≫=(𝑎↦E(𝑡2[𝑎/𝑥])).
For 𝗑𝗈𝗋𝟤, E(𝗑𝗈𝗋𝟤)𝑏𝑖𝑛𝑑=∑𝑏112(∑𝑏212𝛿𝑏1⊕𝑏2)=14(𝛿𝖿𝖿+𝛿𝗍𝗍+𝛿𝗍𝗍+𝛿𝖿𝖿)={𝖿𝖿↦12,𝗍𝗍↦12}. Every step is an exact rational computation; no approximation and no sampling occurs.
Let 𝑢∈2𝜔. Define S(𝑡)(𝑢), a pair of a value and the unconsumed suffix of 𝑢, by S(𝖼𝗈𝗂𝗇)(𝑏𝑢′)=(𝑏,𝑢′),S(𝗋𝖾𝗍𝗎𝗋𝗇𝑣)(𝑢)=(𝑣,𝑢),S(𝑥←𝑡1;𝑡2)(𝑢)=S(𝑡2[𝑎/𝑥])(𝑢′)where(𝑎,𝑢′)=S(𝑡1)(𝑢). The trace of a run is the sequence of events 𝚍𝚛𝚊𝚠𝑏, one per consumed bit, followed by 𝚛𝚎𝚝𝚞𝚛𝚗𝑣.
On the stream beginning 0,1 the run of 𝗑𝗈𝗋𝟤 is 𝚍𝚛𝚊𝚠0; 𝚍𝚛𝚊𝚠1; 𝚛𝚎𝚝𝚞𝚛𝚗𝗍𝗍, because S(𝖼𝗈𝗂𝗇)(01𝑢″)=(0,1𝑢″), then S(𝖼𝗈𝗂𝗇)(1𝑢″)=(1,𝑢″), and 0⊕1=𝗍𝗍. On the stream beginning 1,1 the trace is 𝚍𝚛𝚊𝚠1; 𝚍𝚛𝚊𝚠1; 𝚛𝚎𝚝𝚞𝚛𝚗𝖿𝖿.
For every term 𝑡 of the fragment there is 𝑛∈ℕ such that S(𝑡)(𝑢) depends only on the first 𝑛 bits of 𝑢, and for every value 𝑣, E(𝑡)(𝑣)=#{𝑤∈2𝑛∣S(𝑡)(𝑤𝑢′)returns𝑣}2𝑛, the right-hand side being independent of the suffix 𝑢′.
Proof of Proposition 172.5 — The two executions agree on the fragment
Proof. Induction on 𝑡. For 𝖼𝗈𝗂𝗇, take 𝑛=1; the two words 0 and 1 return 𝖿𝖿 and 𝗍𝗍, giving 1/2 each. For 𝗋𝖾𝗍𝗎𝗋𝗇𝑣, take 𝑛=0. For 𝑥←𝑡1;𝑡2, let 𝑛1 work for 𝑡1 and, for each value 𝑎 in the finite range of 𝑡1, let 𝑛2(𝑎) work for 𝑡2[𝑎/𝑥]; take 𝑛=𝑛1+max𝑎𝑛2(𝑎). Splitting a word 𝑤∈2𝑛 as 𝑤1𝑤2 with |𝑤1|=𝑛1, the run of the bind on 𝑤 first runs 𝑡1 on 𝑤1, producing some 𝑎, and then runs 𝑡2[𝑎/𝑥] on 𝑤2. Counting words by this decomposition, #{𝑤∣bindreturns𝑣}2𝑛=∑𝑎#{𝑤1∣𝑡1returns𝑎}2𝑛1⋅#{𝑤2∣𝑡2[𝑎/𝑥]returns𝑣}2𝑛−𝑛1𝐼𝐻=(E(𝑡1)≫=E(𝑡2[⋅/𝑥]))(𝑣). The decomposition is legitimate because the run of 𝑡2[𝑎/𝑥] begins at the suffix left by 𝑡1, which is exactly 𝑤2𝑢′, and because E(𝑡1) is a distribution supported on the finitely many values 𝑎. ◻
Proposition 172.5 is the whole sampler/measure correspondence in the one case where counting works. It fails to be a definition of anything beyond the fragment for two reasons: the count 2𝑛 presupposes that a fixed finite number of bits suffices, and the sum over values presupposes countably many outcomes. A draw from the uniform distribution on [0,1] violates both. The rest of the chapter replaces counting by measure and integration, and only then returns to samplers.
★★☆ Give a term of a fragment extended by 𝗐𝗁𝗂𝗅𝖾 whose sampler consumes an unbounded number of bits with positive probability, and explain which step of the proof of proposition 172.5 fails for it.
A 𝜎-algebra on a set 𝑋 is a family Σ𝑋⊆P(𝑋) containing 𝑋 and closed under complement and countable union. A measurable space is a pair (𝑋,Σ𝑋), written 𝑋 when the 𝜎-algebra is clear. A map 𝑔:𝑋→𝑌 is measurable when 𝑔−1(𝐵)∈Σ𝑋 for every 𝐵∈Σ𝑌.
Let G⊆P(𝑌) and let 𝜎(G) be the least 𝜎-algebra containing G, which exists because the intersection of any family of 𝜎-algebras is one. If 𝑔−1(𝐵)∈Σ𝑋 for every 𝐵∈G, then 𝑔 is measurable with respect to 𝜎(G).
Proof of Lemma 172.8 — Measurability from a generating family
Proof. The family {𝐵⊆𝑌∣𝑔−1(𝐵)∈Σ𝑋} contains G and is a 𝜎-algebra, because preimage commutes with complement and countable union. Hence it contains 𝜎(G). ◻
Three examples are used throughout. A countable set 𝐴 carries the discrete 𝜎-algebra P(𝐴), and every map out of it is measurable. The real line carries the Borel 𝜎-algebra generated by the open intervals. Given 𝑋 and 𝑌, the product 𝑋×𝑌 carries Σ𝑋⊗Σ𝑌=𝜎({𝐴×𝐵∣𝐴∈Σ𝑋,𝐵∈Σ𝑌}); the two projections are measurable, and by lemma 172.8 a map ⟨𝑔,ℎ⟩ into a product is measurable as soon as 𝑔 and ℎ are.
A measure on 𝑋 is a function 𝜇:Σ𝑋→[0,∞] with 𝜇(∅)=0 that is countably additive: 𝜇(⋃𝑛𝐴𝑛)=∑𝑛𝜇(𝐴𝑛) for pairwise disjoint 𝐴𝑛. It is a subprobability measure when 𝜇(𝑋)≤1 and a probability measure when 𝜇(𝑋)=1. For 𝑥∈𝑋 the Dirac measure is 𝛿𝑥(𝐴)=1𝐴(𝑥), which is a probability measure.
Proof.𝑔−1 preserves ∅, disjointness, and countable unions, so countable additivity transfers; 𝑔∗𝜇(𝑌)=𝜇(𝑔−1𝑌)=𝜇(𝑋). The two equations are id−1(𝐴)=𝐴 and (ℎ∘𝑔)−1(𝐶)=𝑔−1(ℎ−1(𝐶)). ◻
For a measurable 𝑓:𝑋→[0,∞] and a measure 𝜇, the integral is ∫𝑓𝑑𝜇=sup{∑𝑘𝑖=1𝑐𝑖𝜇(𝐴𝑖)∣𝑘∈ℕ,𝑐𝑖∈[0,∞),𝐴𝑖∈Σ𝑋disjoint,∑𝑖𝑐𝑖1𝐴𝑖≤𝑓}. The following four facts about this integral are imported from Tao, An Introduction to Measure Theory, at the stated signatures, and are used with no further appeal to the construction of the integral: additivity ∫(𝑓+𝑔)𝑑𝜇=∫𝑓𝑑𝜇+∫𝑔𝑑𝜇 and homogeneity ∫𝑎𝑓𝑑𝜇=𝑎∫𝑓𝑑𝜇 for measurable 𝑓,𝑔:𝑋→[0,∞] and 𝑎∈[0,∞) (Tao, §1.4); the monotone convergence theorem, that ∫lim𝑛𝑓𝑛𝑑𝜇=lim𝑛∫𝑓𝑛𝑑𝜇 for a pointwise nondecreasing sequence of measurable 𝑓𝑛:𝑋→[0,∞] (Tao, Theorem 1.4.44); the existence and uniqueness of the product measure 𝜇⊗𝜈 on Σ𝑋⊗Σ𝑌 with (𝜇⊗𝜈)(𝐴×𝐵)=𝜇(𝐴)𝜈(𝐵) for 𝜎-finite 𝜇,𝜈 (Tao, §1.7); and Tonelli’s theorem, that for 𝜎-finite 𝜇,𝜈 and measurable 𝑓:𝑋×𝑌→[0,∞] the functions 𝑥↦∫𝑓(𝑥,𝑦)𝑑𝜈(𝑦) and 𝑦↦∫𝑓(𝑥,𝑦)𝑑𝜇(𝑥) are measurable and ∫𝑓𝑑(𝜇⊗𝜈)=∫∫𝑓(𝑥,𝑦)𝑑𝜈(𝑦)𝑑𝜇(𝑥)=∫∫𝑓(𝑥,𝑦)𝑑𝜇(𝑥)𝑑𝜈(𝑦) (Tao, Theorem 1.7.15). Every subprobability measure is finite, hence 𝜎-finite, so the last two apply to all measures exported by this chapter. Monotonicity of the integral and the identity ∫1𝐴𝑑𝜇=𝜇(𝐴) are immediate from the displayed definition and are proved below rather than imported.
Proof of Lemma 172.13 — Monotonicity and indicators
Proof. Every competitor ∑𝑖𝑐𝑖1𝐴𝑖≤𝑓 in the supremum defining ∫𝑓𝑑𝜇 also satisfies ∑𝑖𝑐𝑖1𝐴𝑖≤𝑔, so the supremum for 𝑓 is over a subset of the competitors for 𝑔. For the indicator, the competitor 1⋅1𝐴 gives 𝜇(𝐴)≤∫1𝐴𝑑𝜇; conversely any competitor ∑𝑖𝑐𝑖1𝐴𝑖≤1𝐴 has 𝑐𝑖≤1 and 𝐴𝑖⊆𝐴 whenever 𝑐𝑖>0, so ∑𝑖𝑐𝑖𝜇(𝐴𝑖)≤𝜇(𝐴) by additivity and monotonicity of 𝜇. ◻
Simple functions. For 𝑓=∑𝑘𝑖=1𝑐𝑖1𝐵𝑖, apply additivity and homogeneity (convention 172.12) on both sides and the indicator case to each summand.
General 𝑓. Every measurable 𝑓:𝑌→[0,∞] is the pointwise limit of the nondecreasing sequence of simple functions 𝑓𝑛=𝑛2𝑛∑𝑗=1𝑗−12𝑛1𝑓−1[𝑗−12𝑛,𝑗2𝑛)+𝑛1𝑓−1[𝑛,∞], and 𝑓𝑛∘𝑔 is then a nondecreasing sequence of simple functions with pointwise limit 𝑓∘𝑔. Monotone convergence applied on each side gives the claim from the simple case. ◻
For 𝑥∈𝑋 and measurable 𝑓:𝑋→[0,∞], ∫𝑓𝑑𝛿𝑥=𝑓(𝑥); for 𝑥∈𝑋, 𝑦∈𝑌, 𝛿𝑥⊗𝛿𝑦=𝛿(𝑥,𝑦); and for a subprobability 𝜇 on 𝑋 and the one-point probability space 1=({∗},{∅,{∗}}), the projection 𝜋𝑋 satisfies (𝜋𝑋)∗(𝜇⊗𝛿∗)=𝜇.
Proof. For the first claim, ∫1𝐴𝑑𝛿𝑥=𝛿𝑥(𝐴)=1𝐴(𝑥), and the ascent of theorem 172.14 carries this to simple and then to all measurable 𝑓. For the second, the two measures agree on the generating rectangles, (𝛿𝑥⊗𝛿𝑦)(𝐴×𝐵)=1𝐴(𝑥)1𝐵(𝑦)=1𝐴×𝐵(𝑥,𝑦)=𝛿(𝑥,𝑦)(𝐴×𝐵), and by the uniqueness clause of convention 172.12 agreement on rectangles determines the product measure. For the third, (𝜋𝑋)∗(𝜇⊗𝛿∗)(𝐴)=(𝜇⊗𝛿∗)(𝐴×{∗})=𝜇(𝐴)⋅1. ◻
★★☆ Exhibit a set map 𝑔:𝑋→𝑌 that is not measurable and a measure 𝜇 for which the formula of theorem 172.14 has an undefined left-hand side. State precisely which stage of the proof uses measurability of 𝑔.
A closed probabilistic program of type 𝜏 denotes a measure on [[𝜏]]. A program with one free variable denotes a family of measures indexed by the value of that variable, and sequencing composes two such families. The composition is an integral, so the family must be measurable in its index; that requirement is the definition of a kernel.
Let 𝑋,𝑌 be measurable spaces. A kernel𝑘:𝑋⇝𝑌 is a function assigning to each 𝑥∈𝑋 a subprobability measure 𝑘(𝑥) on 𝑌 such that 𝑥↦𝑘(𝑥)(𝐵) is measurable for every 𝐵∈Σ𝑌. The return kernel is ret𝑋(𝑥)=𝛿𝑥, and for a subprobability measure 𝜇 on 𝑋 and a kernel 𝑘:𝑋⇝𝑌 the bind is (𝜇≫=𝑘)(𝐵)=∫𝑘(𝑥)(𝐵)𝑑𝜇(𝑥)(𝐵∈Σ𝑌). For kernels 𝑘:𝑋⇝𝑌 and 𝑙:𝑌⇝𝑍, the composite is (𝑘≫=𝑙)(𝑥)=𝑘(𝑥)≫=𝑙.
Let 𝜇 be a subprobability measure on 𝑋 and 𝑘:𝑋⇝𝑌 a kernel. Then 𝜇≫=𝑘 is a subprobability measure on 𝑌, with (𝜇≫=𝑘)(𝑌)≤𝜇(𝑋)≤1. If moreover 𝑙:𝑊⇝𝑋 is a kernel then 𝑤↦(𝑙(𝑤)≫=𝑘)(𝐵) is measurable, so 𝑙≫=𝑘 is a kernel.
Proof of Proposition 172.18 — Bind is well defined
Proof.Measure.(𝜇≫=𝑘)(∅)=∫0𝑑𝜇=0. For pairwise disjoint (𝐵𝑛)𝑛, countable additivity of each 𝑘(𝑥) gives 𝑘(𝑥)(⋃𝑛𝐵𝑛)=∑𝑛𝑘(𝑥)(𝐵𝑛)=lim𝑁∑𝑛≤𝑁𝑘(𝑥)(𝐵𝑛), a pointwise nondecreasing limit of measurable functions of 𝑥; so (𝜇≫=𝑘)(⋃𝑛𝐵𝑛)𝑚𝑜𝑛𝑜𝑡𝑜𝑛𝑒𝑐𝑜𝑛𝑣𝑒𝑟𝑔𝑒𝑛𝑐𝑒=lim𝑁∫∑𝑛≤𝑁𝑘(𝑥)(𝐵𝑛)𝑑𝜇(𝑥)𝑎𝑑𝑑𝑖𝑡𝑖𝑣𝑖𝑡𝑦=lim𝑁∑𝑛≤𝑁(𝜇≫=𝑘)(𝐵𝑛)=∑𝑛(𝜇≫=𝑘)(𝐵𝑛).Mass.𝑘(𝑥)(𝑌)≤1 pointwise, so (𝜇≫=𝑘)(𝑌)≤∫1𝑑𝜇=𝜇(𝑋) by lemma 172.13.
Measurability of the composite. Fix 𝐵. The function (𝑤,𝑥)↦𝑘(𝑥)(𝐵) is measurable in 𝑥 by assumption, and 𝑤↦∫𝑘(𝑥)(𝐵)𝑑𝑙(𝑤)(𝑥) is measurable by the following instance of the three-stage ascent: for 𝑘(⋅)(𝐵)=1𝐴 it is 𝑤↦𝑙(𝑤)(𝐴), measurable because 𝑙 is a kernel; for a simple function it is a finite nonnegative combination of such maps; and in general it is the pointwise limit of a nondecreasing sequence of those, hence measurable. ◻
Proof of Lemma 172.19 — Integration against a bind
Proof. For 𝑓=1𝐵 both sides are ∫𝑘(𝑥)(𝐵)𝑑𝜇(𝑥), by lemma 172.13 on the left and inside the outer integral on the right. Additivity and homogeneity extend this to simple 𝑓. For general 𝑓, take the nondecreasing simple approximants 𝑓𝑛 of theorem 172.14; monotone convergence applies to the outer integral on the left, and on the right the inner integrals ∫𝑓𝑛𝑑𝑘(𝑥) form a nondecreasing sequence in 𝑛 for each 𝑥, so monotone convergence applies twice. ◻
Proof. Each equation is an equality of measures, so it suffices to evaluate both sides at an arbitrary measurable set.
Left unit.(𝛿𝑥≫=𝑘)(𝐵)=∫𝑘(⋅)(𝐵)𝑑𝛿𝑥𝑙𝑒𝑚𝑚𝑎172.15=𝑘(𝑥)(𝐵).
Right unit.(𝜇≫=ret𝑋)(𝐴)=∫𝛿𝑥(𝐴)𝑑𝜇(𝑥)=∫1𝐴𝑑𝜇𝑙𝑒𝑚𝑚𝑎172.13=𝜇(𝐴).
Associativity. For 𝐶∈Σ𝑍, ((𝜇≫=𝑘)≫=𝑙)(𝐶)𝑑𝑒𝑓𝑖𝑛𝑖𝑡𝑖𝑜𝑛172.16=∫𝑙(𝑦)(𝐶)𝑑(𝜇≫=𝑘)(𝑦)𝑙𝑒𝑚𝑚𝑎172.19=∫(∫𝑙(𝑦)(𝐶)𝑑𝑘(𝑥)(𝑦))𝑑𝜇(𝑥)𝑑𝑒𝑓𝑖𝑛𝑖𝑡𝑖𝑜𝑛172.16=∫(𝑘(𝑥)≫=𝑙)(𝐶)𝑑𝜇(𝑥), and the last expression is (𝜇≫=(𝑥↦𝑘(𝑥)≫=𝑙))(𝐶); the family 𝑥↦𝑘(𝑥)≫=𝑙 is a kernel by proposition 172.18, so the outer integral is defined. ◻
On a countable space with the discrete 𝜎-algebra, a subprobability measure is a family (𝜇({𝑎}))𝑎 summing to at most 1, the integral is the sum ∫𝑓𝑑𝜇=∑𝑎𝑓(𝑎)𝜇({𝑎}), and bind is the operation of definition 172.1. Associativity becomes the interchange ∑𝑦(∑𝑥𝜇(𝑥)𝑘(𝑥)(𝑦))𝑙(𝑦)(𝑧)=∑𝑥𝜇(𝑥)(∑𝑦𝑘(𝑥)(𝑦)𝑙(𝑦)(𝑧)), which is Tonelli’s theorem for counting measure. The general proof above is the same computation with sums replaced by integrals; the finite case is where the reader should first check the bracketing.
For measurable 𝑔:𝑋→𝑌 and a subprobability 𝜇 on 𝑋, 𝑔∗𝜇=𝜇≫=(𝑥↦𝛿𝑔(𝑥)). Consequently (𝜇≫=𝑘)(𝑌)=𝜇(𝑋) whenever every 𝑘(𝑥) is a probability measure, and the total mass of a bind is otherwise strictly smaller.
Proof of Lemma 172.22 — Pushforward as a bind, and the mass bound
Proof.(𝜇≫=(𝑥↦𝛿𝑔(𝑥)))(𝐵)=∫1𝑔−1(𝐵)𝑑𝜇=𝜇(𝑔−1𝐵)=𝑔∗𝜇(𝐵). For the mass, if 𝑘(𝑥)(𝑌)=1 for all 𝑥 then ∫𝑘(𝑥)(𝑌)𝑑𝜇(𝑥)=𝜇(𝑋); and if 𝑘(𝑥)(𝑌)<1 on a set of positive 𝜇-measure then monotonicity of the integral makes the value strictly smaller. ◻
Limits of subprobability measures
Recursive programs are interpreted as suprema of the finite unfoldings of their bodies, so the exported interface must say that such suprema exist and that sequencing preserves them.
Let 𝜇0≤𝜇1≤⋯ be subprobability measures on 𝑋. Then 𝐴↦sup𝑛𝜇𝑛(𝐴) is a subprobability measure, written sup𝑛𝜇𝑛, it is the least upper bound of the chain in the order of definition 172.23, and for every measurable 𝑓:𝑋→[0,∞], ∫𝑓𝑑(sup𝑛𝜇𝑛)=sup𝑛∫𝑓𝑑𝜇𝑛.
Proof. Write 𝜇(𝐴)=sup𝑛𝜇𝑛(𝐴)≤1. Then 𝜇(∅)=0, and for pairwise disjoint (𝐴𝑘)𝑘, 𝜇(⋃𝑘𝐴𝑘)=sup𝑛∑𝑘𝜇𝑛(𝐴𝑘)𝑚𝑜𝑛𝑜𝑡𝑜𝑛𝑒𝑐𝑜𝑛𝑣𝑒𝑟𝑔𝑒𝑛𝑐𝑒𝑓𝑜𝑟𝑠𝑒𝑟𝑖𝑒𝑠=∑𝑘sup𝑛𝜇𝑛(𝐴𝑘)=∑𝑘𝜇(𝐴𝑘), the middle step because the double family 𝜇𝑛(𝐴𝑘) is nondecreasing in 𝑛 for each 𝑘, so the supremum over 𝑛 of the sums equals the sum of the suprema. That 𝜇 is the least upper bound is immediate from the pointwise definition. For the integral, both sides are suprema of the same set of numbers when 𝑓 is an indicator, additivity extends this to simple functions, and the approximants of theorem 172.14 together with monotone convergence give the general case. ◻
Let 𝜇0≤𝜇1≤⋯ be subprobability measures on 𝑋, let 𝑘:𝑋⇝𝑌 be a kernel, and let 𝑘0≤𝑘1≤⋯ be kernels with 𝑘𝑚(𝑥) increasing in 𝑚 for each 𝑥. Then (sup𝑛𝜇𝑛)≫=𝑘=sup𝑛(𝜇𝑛≫=𝑘),𝜇≫=(sup𝑚𝑘𝑚)=sup𝑚(𝜇≫=𝑘𝑚).
Proof of Proposition 172.25 — Bind preserves increasing suprema
Proof. For the first, evaluate at 𝐵 and apply proposition 172.24 to the function 𝑥↦𝑘(𝑥)(𝐵). For the second, evaluate at 𝐵; the integrands 𝑥↦𝑘𝑚(𝑥)(𝐵) form a pointwise nondecreasing sequence whose supremum is a subprobability measure in 𝐵 by proposition 172.24 and is measurable in 𝑥 as a pointwise supremum of measurable functions; monotone convergence gives the equality. ◻
Let 𝜇=∑𝑘𝑖=1𝑝𝑖𝜇𝑖 with rational 𝑝𝑖≥0, ∑𝑖𝑝𝑖≤1, and subprobability measures 𝜇𝑖. Then 𝜇 is a subprobability measure and ∫𝑓𝑑𝜇=∑𝑖𝑝𝑖∫𝑓𝑑𝜇𝑖 for measurable 𝑓≥0: both claims hold for indicators by definition, and extend by additivity, homogeneity and monotone convergence. For E(𝗑𝗈𝗋𝟤) of example 172.2 and 𝑓=1{𝗍𝗍} this reads ∫𝑓𝑑E(𝗑𝗈𝗋𝟤)=1/2.
Nothing else is exported. In particular the export contains no conditioning or disintegration theorem, no computable metric space structure, no effective topology, no density or Radon–Nikodym statement, no s-finite kernel, no quasi-Borel exponential, and no domain-theoretic fixed point. The sampler-and-valuation development of section 172.5 is a separate system card and is not part of 𝖯𝖬𝖪.
★★☆ Give a family (𝑘(𝑥))𝑥∈ℝ of probability measures on {0,1} that is not a kernel, and show that 𝜇≫=𝑘 is then undefined for Lebesgue measure restricted to [0,1]. (Use a non-measurable subset of [0,1] as the set on which 𝑘(𝑥)=𝛿1.)
★☆☆ Verify the associativity law of theorem 172.20 by direct computation on the three-point discrete example 𝜇={𝑎↦1/3,𝑏↦2/3}, 𝑘(𝑎)={𝑐↦1}, 𝑘(𝑏)={𝑐↦1/2,𝑑↦1/2}, 𝑙(𝑐)=𝛿0, 𝑙(𝑑)=𝛿1.
★★☆ Give an increasing chain of subprobability measures on ℕ whose supremum has total mass 1/2 although each member has mass strictly less than 1/2, and compute ∫𝑓𝑑(sup𝑛𝜇𝑛) for 𝑓(𝑛)=𝑛. State which hypothesis of proposition 172.24 would fail for a chain that is not nondecreasing.
Samplers, valuations, and computable distributions
The finite fragment of section 172.1 had two descriptions and one proof relating them. For distributions on a complete separable metric space the two descriptions are a point of a space of measures and a program that consumes fair bits. This section states both precisely, proves the correspondence that the chapter owns, and marks exactly where the imported computability result is used.
Let 2𝜔 carry the 𝜎-algebra generated by the cylinders [𝑤]={𝑢∣𝑢beginswith𝑤} for 𝑤∈2∗. The fair-bit measure 𝜇iid is the unique measure with 𝜇iid([𝑤])=2−|𝑤|. Define split:2𝜔→2𝜔×2𝜔 by split(𝑢)=(𝑢e,𝑢o), the subsequences of even and odd indices.
Proof of Lemma 172.29 — Uniqueness on a generating algebra
Proof. Let C={𝐴∈Σ𝑋∣𝜇(𝐴)=𝜈(𝐴)}. It contains A. It is closed under increasing unions, because 𝜇(⋃𝑛𝐴𝑛)=sup𝑛𝜇(𝐴𝑛) for an increasing sequence, by countable additivity applied to the disjoint differences; and under decreasing intersections, because 𝜇(𝑋)<∞ allows the same computation on complements. So C is a monotone class containing A, and by the monotone class lemma (Tao, Lemma 1.7.14) it contains 𝜎(A)=Σ𝑋. ◻
Proof of Lemma 172.30 — Splitting produces an independent pair
Proof. Both sides are probability measures on 2𝜔×2𝜔. On a rectangle of cylinders, split−1([𝑤1]×[𝑤2]) is the set of streams whose even positions begin with 𝑤1 and whose odd positions begin with 𝑤2; this is the disjoint union of the cylinders [𝑤] of length 2max(|𝑤1|,|𝑤2|) that meet those constraints, and counting them gives 𝜇iid(split−1([𝑤1]×[𝑤2]))=2−|𝑤1|2−|𝑤2|=(𝜇iid⊗𝜇iid)([𝑤1]×[𝑤2]). Finite unions of such rectangles form a Boolean algebra generating the product 𝜎-algebra, and the two measures agree on it by finite additivity, so lemma 172.29 applies. ◻
Let 𝑋 be a measurable space. A sampler for 𝑋 is a measurable partial function 𝑠:2𝜔⇀𝑋 whose domain has 𝜇iid-measure 1. Its pushforward measure is psh(𝑠)=𝑠∗𝜇iid, a probability measure on 𝑋. The constant sampler is det(𝑥)(𝑢)=𝑥, and for a sampler 𝑠 for 𝑋 and a family 𝑓 assigning to each 𝑥∈𝑋 a sampler 𝑓(𝑥) for 𝑌, the sequenced sampler is samp(𝑠,𝑓)(𝑢)=𝑓(𝑠(𝑢e))(𝑢o).
Let 𝑠 be a sampler for 𝑋 and let 𝑓 assign to each 𝑥∈𝑋 a sampler 𝑓(𝑥) for 𝑌 such that (𝑥,𝑢)↦𝑓(𝑥)(𝑢) is measurable on its domain and 𝑥↦psh(𝑓(𝑥))(𝐵) is measurable for every 𝐵∈Σ𝑌. Then psh(det(𝑥))=𝛿𝑥,psh(samp(𝑠,𝑓))=psh(𝑠)≫=(𝑥↦psh(𝑓(𝑥))).
Proof of Theorem 172.32 — Pushforward correspondence
Proof. For the first equation, psh(det(𝑥))(𝐴)=𝜇iid({𝑢∣𝑥∈𝐴})=1𝐴(𝑥)=𝛿𝑥(𝐴).
For the second, fix 𝐵∈Σ𝑌 and compute psh(samp(𝑠,𝑓))(𝐵)𝑑𝑒𝑓𝑖𝑛𝑖𝑡𝑖𝑜𝑛172.31=𝜇iid({𝑢∣𝑓(𝑠(𝑢e))(𝑢o)∈𝐵})𝑙𝑒𝑚𝑚𝑎172.30=(𝜇iid⊗𝜇iid)({(𝑢1,𝑢2)∣𝑓(𝑠(𝑢1))(𝑢2)∈𝐵})𝑇𝑜𝑛𝑒𝑙𝑙𝑖=∫∫1𝐵(𝑓(𝑠(𝑢1))(𝑢2))𝑑𝜇iid(𝑢2)𝑑𝜇iid(𝑢1)𝑑𝑒𝑓𝑖𝑛𝑖𝑡𝑖𝑜𝑛172.31=∫psh(𝑓(𝑠(𝑢1)))(𝐵)𝑑𝜇iid(𝑢1)𝑡ℎ𝑒𝑜𝑟𝑒𝑚172.14=∫psh(𝑓(𝑥))(𝐵)𝑑psh(𝑠)(𝑥)𝑑𝑒𝑓𝑖𝑛𝑖𝑡𝑖𝑜𝑛172.16=(psh(𝑠)≫=(𝑥↦psh(𝑓(𝑥))))(𝐵). The second step uses lemma 172.30 through theorem 172.14 applied to the measurable map split; Tonelli applies because both measures are probability measures, hence 𝜎-finite, and because the displayed set is measurable by the hypothesis on 𝑓. The last change of variables is theorem 172.14 for the measurable 𝑠 and the function 𝑥↦psh(𝑓(𝑥))(𝐵), measurable by hypothesis. Both sides are defined off a 𝜇iid-null set, which does not affect any of the integrals. ◻
Theorem 172.32 is the measure-theoretic content of Huang–Morrisett–Spitters’ Proposition 5.1, restated in the vocabulary of convention 172.27 and proved here: the pushforward of a constant sampler is a Dirac measure, and the pushforward of a sequenced sampler is the bind of the pushforwards. Their statement is about topological domains — for countably based topological predomains 𝐷,𝐸, psh𝐷 is a continuous map 𝑆(𝐷)⇒𝑃(𝐷) into valuations, and the second clause is proved for their samp, whose splitting must produce an independent stream — and the independence requirement is exactly lemma 172.30. It is a correspondence between two representations of the same distribution. It is not an operational adequacy theorem: it compares two denotations, and says nothing about the traces of a running implementation. A statement about traces belongs to proposition 172.5 and to the practical project below, both of which are confined to the finite fragment.
The following interface is frozen and is not part of 𝖯𝖬𝖪. A computable metric space is a triple (𝑋,𝑑,𝑆) with (𝑋,𝑑) a complete metric space, 𝑆⊆𝑋 countable, enumerable and dense, and 𝑑(𝑠𝑖,𝑠𝑗) a computable real uniformly in 𝑖,𝑗. The space 𝑀(𝑋) of Borel probability measures on 𝑋, equipped with the Prokhorov metric 𝑑𝜌(𝜇,𝜈)=inf{𝜀>0∣𝜇(𝐴)≤𝜈(𝐴𝜀)+𝜀forallBorel𝐴} and the ideal points 𝐷(𝑆) of finitely supported rational-mass distributions on 𝑆, is again a computable metric space; 𝜇 is a computable distribution when it is a computable point of it. A distribution 𝜇∈𝑀(𝑋) is samplable when there is a computable 𝑠:(2𝜔,𝜇iid)⇀(𝑋,𝜇), computable on a domain of full measure, with 𝜇=𝑠∗𝜇iid. The language 𝜆𝐶𝐷 has types 𝜏::=𝖭𝖺𝗍∣𝖱𝖾𝖺𝗅∣𝜏⟶𝜏∣𝜏×𝜏∣𝖣𝗂𝗌𝗍𝜏, a judgment ⊢𝐷𝜏 admitting 𝖭𝖺𝗍, 𝖱𝖾𝖺𝗅 and products of admissible types, PCF terms with pairs, real constants and primitive real operations, primitive distributions dist, 𝗋𝖾𝗍𝗎𝗋𝗇𝑀 and 𝑥←𝑀1;𝑀2, and the typing rules
Ψ(dist)=𝖣𝗂𝗌𝗍𝜏⊢𝐷𝜏
Γ⊢dist:𝖣𝗂𝗌𝗍𝜏
Dist
Γ⊢𝑀:𝜏⊢𝐷𝜏
Γ⊢𝗋𝖾𝗍𝗎𝗋𝗇𝑀:𝖣𝗂𝗌𝗍𝜏
Ret
Γ⊢𝑀1:𝖣𝗂𝗌𝗍𝜏1Γ,𝑥:𝜏1⊢𝑀2:𝖣𝗂𝗌𝗍𝜏2⊢𝐷𝜏1,𝜏2
Γ⊢𝑥←𝑀1;𝑀2:𝖣𝗂𝗌𝗍𝜏2
Bind
Types denote topological domains, with [[𝖣𝗂𝗌𝗍𝜏]]={(𝑠,psh[[𝜏]](𝑠))∣𝑠∈𝑆([[𝜏]])} for the sampler functor 𝑆(𝐷)=2𝜔⇒𝐷⟂; a valuation on a topological space is a strict, monotone and modular map O(𝑋)→[0,1], it is 𝜔-continuous when it preserves suprema of increasing sequences of opens, and 𝑃 is the resulting probability monad with 𝜂(𝑥)(𝑈)=1𝑈(𝑥) and (𝜇⪰♭𝑓)(𝑈)=∫𝑓𝑈𝑑𝜇.
Two statements of convention 172.34 are imported at exactly their source signatures and are used nowhere else in this book without being restated.
First, Huang–Morrisett–Spitters’ Proposition 2.11, attributed there to Freer and Roy (2010, Lemmas 2 and 3): a distribution 𝜇∈𝑀(𝑋) on a computable metric space (𝑋,𝑑,𝑆) is computable if and only if it is samplable. What it supplies is the passage between the two descriptions of a distribution on a complete separable metric space, in both directions, and nothing about conditioning.
Second, their Proposition 5.2: for every well-typed Γ⊢𝑀:𝜏 of 𝜆𝐶𝐷 and every global environment with Ψ⊢Υ, the expression denotation [[𝑀]]Γ is a well-defined morphism [[Γ]]⇒[[𝜏]] of topological domains. Its interesting cases are 𝗋𝖾𝗍𝗎𝗋𝗇 and bind, where the sampler component must be shown to realize the valuation component; that is exactly the content of theorem 172.32, transported to their setting.
The bisection sampler unif(𝑢)=lim𝑛bisect(𝑢,𝑛), which maintains an interval and halves it according to the next bit, is a sampler for [0,1] in the sense of definition 172.31, and psh(unif) is Lebesgue measure on [0,1]: on a dyadic interval [𝑗2−𝑛,(𝑗+1)2−𝑛] the preimage is a single cylinder of length 𝑛, of measure 2−𝑛, and lemma 172.29 extends the agreement from the algebra generated by dyadic intervals to all Borel sets. By convention 172.35 the same distribution is a computable point of (𝑀([0,1]),𝑑𝜌,𝐷(ℚ)). Neither description follows from the other by unfolding definitions: the first is a statement about a measurable map on 2𝜔, the second about a computable Cauchy sequence in the Prokhorov metric, and Proposition 2.11 is the theorem that they coincide.
Three descriptions of a distribution have appeared: a subprobability measure (definition 172.9), an 𝜔-continuous valuation (convention 172.34), and a sampler (definition 172.31). They are related by explicit translations and are not identified: a Borel measure restricts to an 𝜔-continuous valuation on the open sets, and is determined by that restriction when the space is countably based, by lemma 172.29 applied to the algebra generated by a countable base; a sampler maps to a measure by psh; and convention 172.35 maps a computable distribution back to a sampler. Each translation has hypotheses — countable base, completeness, computability of the metric — and a claim proved for one representation transfers to another only through a translation whose hypotheses have been checked. Park’s typed language for probabilistic computation is used in this book only as a pedagogical comparison for the sampling view; it owns no theorem here, and no statement crosses from its syntax to convention 172.34 without a proved translation.
Nothing above conditions on an observation. Conditioning asks for a family 𝑥↦𝜇(⋅∣𝑌=𝑥) satisfying an integral equation, and such a family is determined only up to a null set of 𝑥; both its existence and its computability are outside this chapter, and neither follows from the exported interface. Densities and Radon–Nikodym derivatives are likewise absent: no statement above produces a density for a measure, and the export contains none. Finally, definition 172.6 provides no function space: there is no measurable structure here on the maps between two measurable spaces, and the chapter proves nothing about higher-order probabilistic programs.
★★☆ Replace samp(𝑠,𝑓)(𝑢)=𝑓(𝑠(𝑢e))(𝑢o) by 𝑓(𝑠(𝑢))(𝑢), which feeds the same stream to both stages. Exhibit a sampler 𝑠 and a family 𝑓 for which the conclusion of theorem 172.32 then fails, and identify the step of the proof that breaks.
★★☆ Let 𝑋 be a countable discrete space. Show that every 𝜔-continuous valuation on 𝑋 with 𝜈(𝑋)≤1 is the restriction of a unique subprobability measure, and give the two directions of the translation explicitly.
★☆☆ Verify the three laws of theorem 172.20 on the discrete two-point space by direct rational computation, and then locate in the general proof the exact step that replaces each finite sum.
★★☆ Write out the proof of theorem 172.32 for 𝑋=𝑌={0,1} with 𝑠 reading one bit and 𝑓(𝑥) reading one bit, replacing every integral by a finite sum, and check the result against example 172.2.
★★☆ Give two subprobability measures and a nonnegative function for which the iterated integrals of convention 172.12 differ when the 𝜎-finiteness hypothesis is dropped, and state where theorem 172.32 would use the hypothesis.
★★☆ Let 𝑘𝑚 be the kernel on ℕ that halts within 𝑚 steps in the geometric program of exercise 172.9 and returns the empty measure otherwise. Prove that (𝑘𝑚)𝑚 is an increasing chain of kernels, compute sup𝑚𝑘𝑚, and check proposition 172.25 on this chain with 𝑘(𝑛)=𝛿𝑛+1.
★★★Practical project.pmk-enumerator-sampler Build an interpreter with two back ends for the fragment of section 172.1 extended with 𝗑𝗈𝗋, 𝗂𝖿, and biased 𝖼𝗈𝗂𝗇(𝑝) for reduced rational 𝑝. The first back end is the exact enumerator E of definition 172.1: it returns a finite map from values to reduced rationals, computed by the bind of that definition. The second is the bit-stream sampler S of definition 172.3: it consumes an explicit finite list of bits and emits one trace line per event, 𝚍𝚛𝚊𝚠𝑏 or 𝚛𝚎𝚝𝚞𝚛𝚗𝑣, reporting exhaustion of the list as a distinct outcome from a returned value.
The invariant to maintain is that the enumerator’s table has total mass exactly 1 for every term of the fragment and that every rational is kept in reduced form with no floating-point arithmetic anywhere; the sampler must consume exactly one bit per 𝖼𝗈𝗂𝗇, in evaluation order.
The concrete result is the pair of outputs for the fixture 𝗑𝗈𝗋𝟤=𝑏1←𝖼𝗈𝗂𝗇;𝑏2←𝖼𝗈𝗂𝗇;𝗋𝖾𝗍𝗎𝗋𝗇(𝑏1⊕𝑏2). The acceptance test is decidable: the enumerator must print the table {𝖿𝖿↦1/2,𝗍𝗍↦1/2}; the sampler on the bit list 0,1 must print exactly 𝚍𝚛𝚊𝚠0; 𝚍𝚛𝚊𝚠1; 𝚛𝚎𝚝𝚞𝚛𝚗𝗍𝗍, and on 1,1 exactly 𝚍𝚛𝚊𝚠1; 𝚍𝚛𝚊𝚠1; 𝚛𝚎𝚝𝚞𝚛𝚗𝖿𝖿; the enumerator must print {𝖿𝖿↦2/3,𝗍𝗍↦1/3} for 𝑏←𝖼𝗈𝗂𝗇(1/3);𝗋𝖾𝗍𝗎𝗋𝗇𝑏 with 𝗍𝗍 the outcome of probability 1/3; and the checker must confirm, by exhausting the four bit lists of length two, the equality of proposition 172.5 for 𝗑𝗈𝗋𝟤. Observed frequencies from repeated sampling may be displayed but are not an accepted answer, and the finite agreement checked here illustrates theorem 172.32 without proving it.