Engineering Practice: Compressing Formal Proofs from Tens of Millions of Lines to Tens of Thousands
Large formal proofs are moving from “can it be finished” to “how to organize, compress, and audit it.” Using public discussion of a formal proof of the generalized Riemann hypothesis, this article explains what line-count reduction actually changes: abstraction, automation, and reuse. It compares readability and auditability across versions of roughly 300,000, 76,000, and 52,000 lines, distinguishes independent proofs from one-line citations, and outlines a layered delivery and quality process so compression does not hide proof obligations.
Formal proofs of large mathematical statements are moving from the question of whether they can be completed to the engineering questions of how to organize, compress, and audit them. Public discussion of a formal proof of the generalized Riemann hypothesis illustrates the pattern: proof code was gradually reduced from about 17 million lines to 300,000, then 76,000, and finally about 52,000 lines. Natural-language proofs appeared in versions of more than 300 pages, a little more than 40 pages, and a little more than 30 pages, together with correspondence documents linking the formal and natural-language texts. The rapid drop in line count is striking, but the more useful questions for developers and researchers are what is being compressed, what is lost, and how small the proof can ultimately become.
Compression Is a Change of Abstraction, Not Simple Line Deletion
A reduction from tens of millions of lines to tens of thousands looks like fewer lines of code. In substance, it is a reconstruction of abstraction levels. Early versions often contain many expanded lemmas, repeated intermediate steps, branches for special cases, and redundant structure kept only so that verification will pass. Compression typically means merging duplicate lemmas, extracting common patterns, wrapping proof tactics in higher-order combinators, moving general results into a trusted library, handing mechanical derivation to automation, and redrawing module boundaries. None of these steps is merely “deleting a few lines.” Each changes how the proof is organized without breaking proof closure.
Compression falls into three kinds.
- Structural compression removes duplicate definitions, merges isomorphic lemmas, and stabilizes interfaces so the proof behaves more like maintainable software.
- Tactical compression replaces manual expansion with automation, macros, combinators, or proof search, hiding large amounts of detail inside tactics.
- Reuse compression places already verified general results in external libraries and shortens the current proof by citation rather than reproof.
The effects and risks differ. Structural compression usually improves maintainability. Tactical compression can cut line count sharply but reduces readability. Reuse compression is the most aggressive: it can make a proof extremely short, while shifting audit responsibility onto dependency libraries and the axiom boundary.
From 300,000 to 52,000 Lines: Readability Versus Auditability
A 300,000-line version is often closer to a human-readable proof draft. Lemma names are clear, steps are expanded, special cases have explicit branches, and a reader can follow the argument through the file structure. At 76,000 lines, encapsulation and automation become much heavier, and many intermediate steps are folded into tactics or combinators. By about 52,000 lines, the savings are obvious, but readability is usually worse. Readers see high-level calls and short tactics. Reconstructing the full argument requires expanding macros, tracing dependencies, and understanding the search space of automated tactics. Fewer lines mean higher information density per line, so reading cost does not necessarily fall with the line count.
Line count alone is therefore a poor measure of compression quality. More reasonable metrics include the size of the dependency closure, the number of core lemmas, the share of automated tactics, macro-expansion depth, the proportion of external-library references, build time, regression-verification coverage, and the length of the human audit path from statement to proof. A 50,000-line proof that depends on a small set of stable core libraries may be easier to maintain than a 300,000-line proof with a chaotic structure. Conversely, a very short proof that calls many unexpanded external results can be more expensive to audit. In engineering terms, line count should be an entry metric, not the only metric.
The Extreme One-Line Version: Reuse Versus an Independent Proof
A joking “one-line version” often appears online: call an external library or an already packaged theorem and present that call as the complete proof. In a formal language this is not mysterious. It reduces the current proof to a single reference. It also shows an important fact: if reuse of verified results is allowed, proof length can approach a constant. That is not the same as compressing a complex proof into one line. The real argument still lives in the cited library, the axioms, and the dependency closure. If the audit goal is independent review, those dependencies must be expanded. Reviewers must check whether external results are trustworthy, whether the axioms are acceptable, and whether versions are locked.
Pseudocode shows the difference:
Independent proof path:Statement P-> decompose into lemmas L1, L2, ..., Ln-> construct each proof-> combine them into a proof of PMinimal reuse path:Statement P-> if a trusted library already contains P-> cite that result directly-> keep only the citation and interface declaration in the current file
The two paths differ enormously in the line count of the current file, but the proof obligation does not disappear. Engineering practice should distinguish three deliverables: executable verification, an auditable proof, and a text suitable for teaching. A minimal version fits automated pipelines and fast checks. An expanded version fits audit and teaching. A layered version between them fits long-term maintenance.
Correspondence Between Natural-Language and Formal Proofs
Once a formal proof is down to tens of thousands of lines, human readers often prefer to start with the natural-language proof. In recent public material, a natural-language proof of more than 300 pages was further compressed to versions of several dozen pages, with correspondence documents between the formal and natural-language texts. That split has clear engineering value. The natural-language proof supplies mathematical intuition, the main line of argument, and the motivation for key lemmas. The formal proof supplies machine-checkable detail. The correspondence document traces natural-language passages to formal modules and key lemmas. The three layers complement each other; none replaces the others.
The correspondence document matters especially after compression. Formal code becomes harder to read, so intent is difficult to recover from code alone. A natural-language proof may omit technical detail and cannot by itself support machine verification. Stable names, module mappings, lemma indexes, and proof-obligation lists connect the two. A correspondence document should at least record differences between the mathematical statement and its formal declaration, a dependency graph of key lemmas, a list of external libraries and axioms, the scope of automated tactics, and bidirectional links between natural-language passages and formal files. With that record, cutting lines does not directly erase knowledge.
An Engineering Workflow for Collaborative Compression
Multi-party compression of a large proof needs a process similar to a large software refactoring.
- Establish a baseline: fix a reproducible build environment, lock dependency versions, and record the full dependency closure and build time.
- Split modules by mathematical topic and dependency direction, and stabilize interfaces so modules are not expanded arbitrarily across boundaries.
- Choose compression candidates, preferring duplicate lemmas, mechanical branches, results that can move into a general library, and manual steps that automation can replace.
- Merge in small steps. Each change should alter only one abstraction level, then run full verification and a differential check.
- Keep multiple releases: a fully expanded version, an audit version, a compressed version, and a minimal citation version, with metadata stating the purpose of each.
Review should not ask only “how many lines were removed.” It should also ask whether the dependency closure grew, which external references were added, whether automated tactics are reproducible, whether the correspondence document was updated, and whether key lemmas can still be located. Large compression merges should include the dependency-graph diff, build logs, verification-coverage notes, and an audit expansion path. That turns compression from a personal technique into a reusable engineering capability.
Quality Assurance: Keeping a Compressed Proof Trustworthy
A compressed proof needs stronger quality controls. Reproducible builds are the baseline: the same source, dependencies, and toolchain should yield the same verification result. Dependency locking is required: uses of external libraries and axioms must be versioned and reviewed when they change. Differential verification can compare proof obligations before and after compression, checking not only the final statement but also whether key lemma interfaces remain stable. Audit expansion is equally important. A minimal citation version should expand to an auditable level in one step, or at least produce a dependency-closure report. Complexity metrics should enter the pipeline. Beyond line count, track module coupling, macro-expansion depth, automated-tactic hit rate, build time, and the blast radius of proof-file changes.
How Small Can It Ultimately Get?
There is no single answer. It depends on the delivery goal. If the goal is the shortest current file, and trusted external libraries and axioms may be cited, the one-line version already shows a theoretical lower bound: length approaches a single reference. If the goal is an independently auditable proof, the room to compress is limited by the number of core lemmas, the dependency closure, and the axiom boundary; tens of thousands of lines may still be a reasonable size. If the goal is a human-readable exposition, the 300,000-line expanded version can be more valuable. A practical judgment is that further merging of repeated structure, sinking of general results, and tighter automation wrappers could cut the roughly 52,000-line version by half or more. Each further step, however, should add correspondence documents, audit expansion, and dependency governance. Otherwise complexity merely moves from explicit code into implicit dependencies.
The better route is not a single minimum line count, but layered delivery: a minimal citation version for fast verification, a compressed version for continuous integration, an audit version for independent review, a natural-language version for human understanding, and a correspondence document for bidirectional tracing. Line count can keep falling, but trustworthiness, maintainability, and readability have to be restored by engineering means. For large formal proofs, the end of compression is not “the fewest lines.” It is the smallest maintainable proof system for a stated audit goal.
