← All papers
First page of Markov kernels in Mathlib's probability library

Markov kernels in Mathlib's probability library

Rémy Degenne

cs.DL Oct 5, 2025 · v1
Describes the formalization of Markov kernels and the disintegration theorem in Mathlib's probability library in Lean.
The probability folder of Mathlib, Lean's mathematical library, makes a heavy use of Markov kernels. We present their definition and properties and describe the formalization of the disintegration theorem for Markov kernels. That theorem is used to define conditional probability distributions of random variables as well as posterior distributions. We then explain how Markov kernels are used in a more unusual way to get a common definition of independence and conditional independence and, following the same principles, to define sub-Gaussian random variables. Finally, we also discuss the role of kernels in our formalization of entropy and Kullback-Leibler divergence.

Probability theory in formal mathematics requires careful handling of Markov kernels for conditional distributions, independence, and related constructions. Prior to this work, the Mathlib probability library lacked a unified kernel-based framework for these concepts.

The authors describe the formalization of Markov kernels in Mathlib, Lean's mathematical library. They present the definition and composition operations for kernels, formalize the disintegration theorem (which enables defining conditional probability distributions and posterior distributions), and show how kernels provide a common definition for both independence and conditional independence. The same kernel-based approach is used to define sub-Gaussian random variables.

The disintegration theorem for Markov kernels is fully formalized in Lean and integrated into Mathlib. The kernel framework unifies the definitions of independence and conditional independence under a single abstraction and enables the definition of conditional probability distributions of random variables and posterior distributions.