BDD library: Exchangeability ConditionallyIID
DefinitionExchangeability_ConditionallyIIDprobability
Core definitions and structural lemmas of the binary decision diagram library (Exchangeability_ConditionallyIID), machine-checked in Lean 4 against Mathlib. See the linked source module.
Definition code
import Mathlib.MeasureTheory.Measure.ProbabilityMeasure
import Mathlib.MeasureTheory.Measure.Typeclasses.Probability
import Mathlib.MeasureTheory.Measure.GiryMonad
import Mathlib.MeasureTheory.Constructions.Pi
import Definitions.Def_Exchangeability_Contractability
import Definitions.Def_Exchangeability_Probability_InfiniteProduct
import Definitions.Def_Exchangeability_Util_StrictMono
set_option autoImplicit true
namespace MeasureTheory
end MeasureTheory
namespace ProbabilityTheory
end ProbabilityTheory
/-
Copyright (c) 2025 Cameron Freer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Cameron Freer
-/
/-!
# Conditionally i.i.d. Sequences and de Finetti's Theorem
This file defines **conditionally i.i.d. sequences** and proves that they are
exchangeable. This establishes one direction of de Finetti's representation theorem:
**conditionally i.i.d. ⇒ exchangeable**.
## Main definitions
* `ConditionallyIID μ X`: A sequence `X` is conditionally i.i.d. under measure `μ` if
there exists a probability kernel `ν : Ω → Measure α` such that coordinates are
independent given `ν(ω)`, with each coordinate distributed as `ν(ω)`.
## Main results
* `pi_comp_perm`: Product measures are invariant under permutations of indices.
* `bind_map_comm`: Giry monad functoriality - mapping after bind equals binding mapped measures.
* `exchangeable_of_conditionallyIID`: **Conditionally i.i.d. ⇒ exchangeable**.
## The de Finetti-Ryll-Nardzewski theorem
The complete equivalence for infinite sequences is:
**contractable ↔ exchangeable ↔ conditionally i.i.d.**
This file proves: **conditionally i.i.d. ⇒ exchangeable**
### The complete picture
- **Conditionally i.i.d. ⇒ exchangeable** (this file): Direct from definition using
permutation invariance of product measures.
- **Exchangeable ⇒ contractable** (`Contractability.lean`): Via permutation extension.
- **Contractable ⇒ exchangeable** (`DeFinetti/Theorem.lean`): Deep result using ergodic theory.
- **Exchangeable ⇒ conditionally i.i.d.** (de Finetti's theorem): The hard direction,
requiring the existence of a random measure (the de Finetti measure).
## Mathematical intuition
**Conditionally i.i.d.** means: "There exists a random probability measure `ν`, and
given the value of `ν`, the sequence is i.i.d. with distribution `ν`."
**Why this is exchangeable:** If we permute the indices, we're still sampling i.i.d.
from the same random distribution `ν`, so the joint distribution is unchanged.
**Example:** Pólya's urn - drawing balls with replacement where the replacement
probability depends on the urn composition. Conditionally on the limiting proportion,
the draws are i.i.d. Bernoulli.
## Implementation notes
This file uses the Giry monad structure (`Measure.bind`) to express conditioning.
The key technical ingredient is showing that permuting coordinates of a product
measure gives the same measure, which follows from `measurePreserving_piCongrLeft`.
## References
* Kallenberg, "Probabilistic Symmetries and Invariance Principles" (2005), Theorem 1.1
* Kallenberg, "Foundations of Modern Probability" (2002), Theorem 11.10 (de Finetti)
* Diaconis & Freedman, "Finite Exchangeable Sequences" (1980)
-/
open MeasureTheory ProbabilityTheory
variable {Ω α : Type*} [MeasurableSpace Ω] [MeasurableSpace α]
-- Re-export Measure.pi from mathlib for discoverability
namespace MeasureTheory.Measure
-- Measure.pi is already defined in Mathlib.MeasureTheory.Constructions.Pi
-- We just need to prove that the product of probability measures is a probability measure
/--
The product of probability measures is a probability measure.
This is a basic fact about product measures: if each marginal `μ i` has total mass 1,
then the product measure `∏ᵢ μ i` also has total mass 1.
**Proof:** The measure of the whole space `∏ᵢ αᵢ` equals the product of the measures
of the marginal spaces, which is `∏ᵢ 1 = 1`.
-/
instance pi_isProbabilityMeasure {ι : Type*} [Fintype ι] {α : ι → Type*}
[∀ i, MeasurableSpace (α i)] (μ : ∀ i, Measure (α i))
[∀ i, IsProbabilityMeasure (μ i)] [∀ i, SigmaFinite (μ i)] :
IsProbabilityMeasure (Measure.pi μ) := by
constructor
simp [measure_univ]
end MeasureTheory.Measure
namespace Exchangeability
/--
A sequence is **conditionally i.i.d.** if there exists a random probability measure
making the coordinates independent.
**Definition:** `X` is conditionally i.i.d. if there exists a probability kernel
`ν : Ω → Measure α` such that for every finite selection of **distinct** indices
`k : Fin m → ℕ` (i.e., strictly monotone), the joint law of `(X_{k(0)}, ..., X_{k(m-1)})`
equals `𝔼[ν^m]`, where `ν^m` is the m-fold product of `ν`.
**Intuition:** There exists a random distribution `ν`, and conditionally on `ν`, the
sequence is i.i.d. with marginal distribution `ν`. Different sample paths may have
different `ν` values, but for each fixed `ν`, the coordinates are independent with
that distribution.
**Example:** Pólya's urn - drawing colored balls with replacement where we add a ball
of the drawn color each time. The limiting proportion of colors is random, and
conditionally on this proportion, the draws are i.i.d. Bernoulli.
**Mathematical formulation:** For each finite selection of distinct indices, we have:
`P{(X_{k(0)}, ..., X_{k(m-1)}) ∈ ·} = ∫ ν(ω)^m μ(dω)`
**Implementation:** Uses mathlib's `Measure.bind` (Giry monad) and `Measure.pi`
(product measure) to express the mixture of i.i.d. distributions.
**Note on repeated indices:** This definition only requires the product formula for
strictly monotone index functions (distinct coordinates). For non-strictly-monotone
functions (e.g., `k = (0,0,1)`), the correct law involves a duplication map, which
follows trivially from the distinct-indices case. This matches Kallenberg (2005),
Theorem 1.1.
**Reference:** Kallenberg (2005), "Probabilistic Symmetries and Invariance Principles",
Theorem 1.1 (page 27-28).
-/
def ConditionallyIID (μ : Measure Ω) (X : ℕ → Ω → α) : Prop :=
∃ ν : Ω → Measure α,
(∀ ω, IsProbabilityMeasure (ν ω)) ∧
(∀ B, MeasurableSet B → Measurable (fun ω => ν ω B)) ∧
∀ (m : ℕ) (k : Fin m → ℕ), StrictMono k →
Measure.map (fun ω => fun i : Fin m => X (k i) ω) μ
= μ.bind (fun ω => Measure.pi fun _ : Fin m => ν ω)
end Exchangeability
Source