LeanInfoTheory: A Lean 4 Library for Information Theory
Serhat Emre Coban
cs.IT
Dec 2, 2026 · v1
cs.LO math.LO
TL;DR
Builds a Lean 4 library of finite discrete information theory on Mathlib's PMFs and uses it to formalize Shannon's 1948 results and a recent paper.
Abstract
We present LeanInfoTheory, a Lean 4 library providing a reusable information-theoretic layer above mathlib, with current coverage of finite discrete information theory. Checking a formal proof does not by itself establish that its statement and definitions express the intended mathematics. Once the mathematical meaning of shared definitions and theorem statements has been reviewed, subsequent papers can reuse that review. This can reduce repeated checking of shared foundations. We explain the library's interfaces for joint distributions and random variables, semantic bridges between equivalent formulations, support-sensitive theorem statements, and interoperability with other information-theory formalizations through worked examples. We present case studies of Shannon's "A Mathematical Theory of Communication" and the recent paper "On Perfect Functional Representations" to show how library results are reused and how downstream needs can guide library development. Our longer-term goal is to help establish a community-maintained information-theory library (not necessarily LeanInfoTheory) whose coverage and interfaces develop through use, with LeanInfoTheory serving as a starting point.
Problem
Checking a formal proof does not confirm that its definitions and statements capture the intended mathematics. When each information-theory formalization defines its own foundations, that semantic review must be repeated for every project. No shared Lean layer for information theory sits above Mathlib.
Approach
LeanInfoTheory provides definitions of entropy, mutual information, KL divergence and related quantities over Mathlib PMFs. It offers two API levels: one for joint distributions and one for random variables. It also includes semantic bridge theorems linking equivalent characterizations and support-sensitive statements that avoid conditions on zero-probability values. Interoperability is shown by relating the library's mutual information to the definitions in the independent Courtade–Kumar and rate-distortion Lean formalizations.
Results
Selected results from Shannon's 'A Mathematical Theory of Communication' were formalized by reusing library lemmas (typical sets, prefix coding, Fano's inequality, capacity), as was 'On Perfect Functional Representations'. Lessons from these case studies fed back into the library, for example a general independence-under-composition theorem added in v0.2.0.
| Kind | Distinct declarations | Explicit references |
|---|
| Definitions | 23 | 850 |
| Abbreviations | 6 | 194 |
| Theorems | 76 | 341 |
| Total | 105 | 1,385 |
Declarations and references (as extracted; context not specified)