Skip to content

Formalization of exchangeability and three proofs of de Finetti's theorem in Lean 4, following Probabilistic Symmetries and Invariance Principles by Olav Kallenberg

License

Notifications You must be signed in to change notification settings

cameronfreer/exchangeability

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4,135 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exchangeability

Lean 4 Blueprint

Formalization of exchangeability and de Finetti's theorem in Lean 4.

Overview

This project formalizes the de Finetti-Ryll-Nardzewski theorem (Kallenberg's Theorem 1.1), which establishes a three-way equivalence for infinite sequences on standard Borel spaces:

(i) Contractable(ii) Exchangeable(iii) Conditionally i.i.d.

We implement all three proofs from Kallenberg (2005) of the key implication contractable → conditionally i.i.d.:

  1. Martingale Approach (Default)

  2. L² Approach

    • Kallenberg's "second proof" - Elementary L² contractability bounds
    • Lightest dependencies (no ergodic theory required)
    • Formalized for ℝ-valued sequences with L² integrability
    • Exchangeability/DeFinetti/ViaL2/ (12 files)
  3. Koopman Approach

Import Graph

Import Graph

Modules colored by proof: 🔵 Martingale   🟢 L²   🟠 Koopman
Interactive · All declarations · Blueprint only

Quick Start

Prerequisites

  • Lean 4 (this project uses lean-toolchain pinned to 4.27.0-rc1)
  • elan (Lean version manager)

Installation

# Install elan
curl -sSf https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | sh

# Clone and build
git clone https://github.com/cameronfreer/exchangeability.git
cd exchangeability
lake build

Using the Library

import Exchangeability

-- de Finetti's theorem (uses martingale proof by default)
example {Ω : Type*} [MeasurableSpace Ω] [StandardBorelSpace Ω]
    {α : Type*} [MeasurableSpace α] [StandardBorelSpace α] [Nonempty α]
    {μ : Measure Ω} [IsProbabilityMeasure μ]
    (X : ℕ → Ω → α) (hX_meas : ∀ i, Measurable (X i))
    (hX_exch : Exchangeable μ X) :
    ConditionallyIID μ X :=
  deFinetti X hX_meas hX_exch

Project Structure

Exchangeability/
├── Core.lean                    # Exchangeability definitions, π-systems
├── Contractability.lean         # Exchangeable → Contractable
├── ConditionallyIID.lean        # Conditionally i.i.d. sequences
├── Probability/                 # Probability infrastructure
│   ├── CondExp.lean            # Conditional expectation
│   ├── CondIndep/              # Conditional independence
│   ├── Martingale/             # Martingale convergence
│   └── ...
├── DeFinetti/                   # Three proofs of de Finetti
│   ├── Theorem.lean            # Public API (exports ViaMartingale)
│   ├── ViaMartingale/          # Martingale proof (13 files)
│   ├── ViaL2/                  # L² proof (12 files)
│   ├── ViaKoopman/             # Ergodic proof (18 files)
│   ├── CommonEnding.lean       # Shared final step
│   └── L2Helpers.lean          # L² contractability lemmas
├── Ergodic/                     # Ergodic theory (for Koopman)
│   ├── KoopmanMeanErgodic.lean
│   ├── InvariantSigma.lean
│   └── ProjectionLemmas.lean
├── Tail/                        # Tail σ-algebra machinery
├── PathSpace/                   # Shift operators, cylinders
└── Util/                        # Helper lemmas

Documentation

Main Results

Main API

  • deFinetti — Exchangeable → Conditionally i.i.d. (uses martingale proof)
  • conditionallyIID_of_contractable — Contractable → Conditionally i.i.d. (martingale/default)
  • conditionallyIID_of_contractable_viaL2 — L² proof variant
  • conditionallyIID_of_contractable_viaKoopman — Koopman proof variant

Core Theory

  • exchangeable_iff_fullyExchangeable — Finite and infinite exchangeability are equivalent
  • measure_eq_of_fin_marginals_eq — Measures determined by finite marginals

de Finetti's Theorem (Three-way Equivalence)

  • contractable_of_exchangeable — Exchangeability implies contractability
  • exchangeable_of_conditionallyIID — Conditionally i.i.d. implies exchangeability

References

Primary Source

Additional Sources

Related Work

License

Apache 2.0

Acknowledgments

This formalization was developed with assistance from:

  • Claude (Anthropic) - Sonnet 4, Sonnet 4.5, Opus 4.5
  • GPT (OpenAI) - GPT-5.*-Codex, GPT-5.* Pro

Built with Lean 4 and Mathlib.

About

Formalization of exchangeability and three proofs of de Finetti's theorem in Lean 4, following Probabilistic Symmetries and Invariance Principles by Olav Kallenberg

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •