Markov Chains Monte Carlo and Perron–Frobenius in Lean 4
Formalization of:
- finite-state Markov chains (kernels, total variation, convergence),
- basic MCMC algorithms (Gibbs, Metropolis–Hastings),
- Perron–Frobenius theory and supporting spectral material,
- the Krein–Rutman theorem on real Banach spaces (
MCMC/ToMathlib, sorry-free), - groundwork for a general MCMC kernel interface (non-finite).
Build
Lean/Mathlib v4.34.1 (elan recommended):
lake exe cache get
lake build MCMC
Open the folder in VS Code for interactive proofs.
Directory overview
MCMC/Finite/Core.lean: finite Markov chains; states, transitions, stationary distributionstoKernel.lean: bridge to kernel transitionsTotalVariation.lean: total variation distance and Dobrushin coefficientConvergence.lean: convergence/mixing statements for finite chainsMetropolisHastings.lean: Metropolis–Hastings kernelGibbs.lean: Gibbs sampling
MCMC/PF/Auxiliary.lean: auxiliary lemmasLinearAlgebra/Matrix/PerronFrobenius/: PF and spectral/JNF files- core:
Defs,Irreducible,Primitive,Aperiodic,CollatzWielandt,Multiplicity,Dominance - stochastic/sampling:
Stochastic.lean
- core:
MCMC/Kernel/: WIP general-state kernel interfaceMCMC/ToMathlib/: Mathlib-ready additions at their Mathlib paths (below)
Krein–Rutman (MCMC/ToMathlib)
Spectral radius of a real operator is gelfandRadius T = lim ‖Tⁿ‖^{1/n} (backport of
mathlib #42607); cones are ProperCone ℝ E. Following Bourbaki, Théories spectrales III §6:
KreinRutman/Compact.lean: ifTpreserves a total salient cone and is quasi-compact (gelfandRadius (T ^ n - K) < gelfandRadius T ^ n,Kcompact; compactTwithr > 0is a special case),r = gelfandRadius Tis an isolated eigenvalue with an eigenvector in the cone and a positive dual eigenfunctional.KreinRutman/StronglyPositive.lean: strongly positive and primitive operators: interior eigenvector, algebraic simplicity, spectral gapgelfandRadius (T - r P) < r,(r⁻¹T)ⁿ → P, peripheral spectrum{r}; irreducible ones ((1 + T)ᵏstrongly positive): interior eigenvector and algebraic simplicity.KreinRutman/OrderBounded.lean: the same for cones with empty interior (Lᵖ, Jentzsch kernels) underu₀-positivityψ x • u₀ ≤ T x ≤ (β‖x‖) • u₀.KreinRutman/{FiniteDimensional,Order}.lean,CStarAlgebra/: finite dimension (Birkhoff–Vandergraft), ordered spaces and Banach lattices (C(K),Lᵖ), positive and completely positive maps of C⋆-algebras (Evans–Høegh-Krohn);Analysis/Matrix/: Perron–Frobenius and convergence of primitive stochastic matrices.- Supporting theory: Riesz–Schauder, a local analytic Fredholm theorem, poles beyond the essential
spectral radius (
Normed/Operator/Compact/), real-Banach complexification (TaylorComplexification).
Headline statements are checked against Mathlib-only specifications on branch
palomar-comparator.
Finite-state TV and Dobrushin (key results)
MCMC/Finite/TotalVariation.lean provides:
tvDist: total variation on finite distributions (L1/2 formulation).dobrushinCoeff: sup TV distance between rows of a stochastic matrix.- contraction:
tvDist_contract(TV contracts bydobrushinCoeffunder a kernel). - submultiplicativity:
dobrushinCoeff_mul, powers:dobrushinCoeff_pow. - primitive link:
dobrushinCoeff_lt_one_of_primitive(∃ k, δ(P^k) < 1 for primitive P).
Consequences (used in Convergence.lean and PF links):
- quantitative TV convergence for finite primitive chains,
- geometric decay along powers once some δ(P^k) < 1,
- bridge to PF primitivity results in
PF/…/PerronFrobenius.
Contributing
Feel free to open issues or PRs for discussion and suggestions.