FormalSLT is a Lean 4 library for statistical learning theory and modern finite-sample inference.
It develops reusable results in VC and Rademacher theory, metric entropy and chaining, PAC-Bayes bounds, confidence sequences and e-processes, and learning from adaptive or dependent trajectories. The goal is a coherent Lean foundation in which classical learning theory and newer sequential methods can be composed and extended.
Worked applications show how these parts of the library combine.
Documentation · Theorem map · Search declarations · Install
Fixed-time guarantees can fail under repeated monitoring; one checked event can cover repeated looks. The repo-wide film starts there, then maps reusable proof infrastructure across VC and Rademacher theory, chaining, PAC-Bayes, e-processes, and dependent-data inference. It establishes the platform and its current interfaces; it does not claim end-to-end verification of an ML system.
Play the responsive film · Transcript · Manim source · Pinned v0.2.0 film receipt
FormalSLT includes Sauer-Shelah bounds for finite set families, VC-based uniform-deviation and ERM excess-risk bounds for binary zero-one loss, finite-sample Rademacher symmetrization, Massart bounds, contraction, linear-predictor bounds, and metric-entropy estimates. Its chaining results reach total-bounded spaces and continuous entropy-integral bounds while keeping the required boundary, separability, and modulus assumptions explicit.
VC source · Rademacher source · chaining source · theorem map
For an infinite IID sequence, one event controls every sample size n ≥ 2 and
every admissible posterior. The bound uses Bessel sample variance and
measure-theoretic KL divergence. A separate forward construction handles
predictable residuals for sequential use. On current main, one countable
master e-process can also cover a fixed catalog of history-dependent,
predictable tilt strategies. A finite product-catalog theorem goes further:
both the model and strategy posterior may be chosen after observing the path,
with separate KL costs, and a shared-strategy corollary returns ordinary
posterior conditional risk. A second countable master mixes a fixed positive
catalog of scalar tilts over arbitrary measurable hypothesis spaces and
eligible continuous posterior measures. The all-sample IID result is uniform
over sample size, but it is not an optional-stopping theorem.
The sequential layer also has exact executable wealth-weighted masters. A finite master adapts among supplied predictable betting strategies, while a countable sleeping-expert construction evaluates only the active prefix and a closed-form tail. Both compete with every active declared expert; neither is a parameter-free continuum coin-betting result.
Lean source · checker · positive-KL example · model--strategy posterior · predictable-strategy master · measurable countable master · computable betting master
One event can allow the posterior and tilt to depend on the observed prefix and time. The growing-prefix oracle now supports arbitrary measurable state and hypothesis spaces: it minimizes the exact observable boundary over the declared geometric tilts available at the reporting time and bounds it by an explicit LIL-order envelope. Its width tends to zero under the displayed pathwise posterior-KL rate. The trajectory result starts from a deterministic initial state and bounds monitored conditional risk, not stationary or future deployment risk.
finite-state source · observable oracle · measurable-space oracle · trajectory oracle receipt · measurable oracle checker
Prequential bounds combine with finite-depth Poisson corrections to control stationary risk. One route uses a known contracting kernel. The empirical route uses a finite catalog of contracting candidates and requires every source row to be visited. A selected empirical contraction bound below one additionally proves uniqueness of the true invariant law.
known-kernel source · candidate-family source · worked checker
For a 24-state controlled queue, the generic transition bound allocates
confidence across 48 × 48 × 2 = 4,608 coordinates. Under a specified
one-parameter refresh model, a single destination-hit statistic has a
row-independent conditional mean, and Lean proves that its parameter
discrepancy equals physical-row total variation. This example is retrospective
and conditional on the refresh model; it does not test family membership.
application · design · Lean receipt
FormalSLT currently uses Lean 4.32.2 and Mathlib 4.32.2. The stable topic imports are:
import FormalSLT.PACBayes
import FormalSLT.Sequential
import FormalSLT.StochasticDynamics
import FormalSLT.VCAdd the latest tagged release to a Lake project:
require «formal-slt» from git
"https://github.com/Robby955/FormalSLT.git" @ "v0.2.0"For unreleased work, pin a full commit SHA that you have reviewed rather than the moving branch.
Then run:
lake update
lake exe cache get
lake buildFormalSLT/PACBayes: PAC-Bayes inequalities and change-of-measure toolsFormalSLT/Rademacher: symmetrization, contraction, and generalization boundsFormalSLT/Covering: metric entropy and chainingFormalSLT/Sequential: confidence sequences, e-processes, and Ville boundsFormalSLT/StochasticDynamics: adaptive paths, kernels, and stationary riskFormalSLT/VC: VC dimension, growth functions, and uniform convergenceexamples: small checker files for public resultsapplications: end-to-end worked examples
lake exe cache get
lake build FormalSLT
make examples
make tutorials
make api
make downstream- A Machine-Checked Anytime-Valid Confidence Sequence by the Method of Mixtures, accepted poster at COPA 2026; forthcoming in PMLR 329 (artifact and reproduction)
- From Agents to Axioms: Verifier-Gated Lean Formalization for Statistical Learning Theory, ICML 2026 AI for Math workshop
- Literature notes
- Source map
- Citation metadata
See CONTRIBUTING.md and the good first issues.
MIT. See LICENSE.