How to Compress Formalized Proofs Without Sacrificing Rigor
Large-scale formal proofs routinely balloon into hundreds of thousands or even millions of lines once they enter machine-checkable verification pipelines. This article takes an engineering perspective on why formalized proofs grow so quickly, how to shrink them without breaking correctness, and how natural-language documentation should be paired with formal scripts. It covers layered abstraction across theorem, estimate, and infrastructure levels, the trade-offs between line count and readability, and safe practices for iteratively reducing proof size. Readers will learn practical principles for keeping formal proofs verifiable, reviewable, and maintainable.
When large mathematical claims enter a machine-checkable formalization pipeline, the proof scripts often balloon to hundreds of thousands or even millions of lines. Line count itself is not a quality metric: what really determines whether the proof can later be reviewed, reused, and further compressed is whether the structure is layered, dependencies are clear, and human readers can grasp the main argument in limited time. This article takes an engineering perspective on why proofs grow long, how to shrink them without breaking correctness, and how to divide responsibility between natural-language documentation and formal scripts.
Why Formalized Proofs Bloat
Interactive theorem provers require every reasoning step to be grounded in verifiable primitives or registered lemmas. Human mathematicians are used to phrases like “obvious,” “similar to the argument above,” or “by standard estimates”—the machine side must fill in every omission. This produces three kinds of bloat:
First, repeated expansion of basic analysis and number theory toolchains. Results involving inequalities, contour integrals, functional equations, or zero density, if not extracted into reusable libraries, get copied many times inside the main proof.
Second, intermediate assertions introduced just to pass verification. To keep type checking or tactic search stable, authors often insert a large number of “scaffolding” lemmas that contribute little to human reading but significantly increase line count.
Third, redundancy from automation-generated tactics. Intelligent coding tools or tactic search can produce compilable scripts quickly, but the resulting paths are often not the shortest proofs. Local expansion, repeated rewriting, and overly fine namespaces all push up the size.
So the first version that “passes verification” is usually a starting point, not a final draft.
The Goal Is Not Minimal Lines, but a Maintainable Shortest Path
Occasionally people joke about collapsing an entire proof into “a one-line call to an external library.” From an engineering standpoint this is meaningless: if the dependency cannot be audited, compression just hides complexity inside a black box. A more sensible goal is:
- Acceptable verification time;
- Clear module boundaries, with key lemmas documented in natural language;
- Controlled depth for the main theorem’s proof tree, so readers can reconstruct the argument’s skeleton from the table of contents;
- Further simplification possible without breaking existing verification.
Typical sizes across stages look like this: a very early auto-generated draft may reach tens of millions of lines; after dependency pruning and lemma extraction, it can drop to hundreds of thousands; after further abstraction and tactic rewriting, it may reach tens of thousands. Fewer lines do not automatically mean better readability. Premature inlining, excessive macro expansion, or replacing explanatory names with meaningless short identifiers can make the shorter version harder to review.
Compression should prioritize “semantic compression” over “character compression”: merge isomorphic lemmas, unify parameter conventions, and turn recurring analytical patterns into tactics or small libraries—rather than simply deleting blank lines.
Layered Abstraction: From Main Line to Tool Library
A formalization project that can keep shrinking usually has four layers.
The proposition layer. Keep only statements directly relevant to the target conjecture: functional equations, zero distribution, explicit formulas, error terms, and so on. This layer should be short, stable, and rarely changed.
The estimates layer. Extract the bounds, averaged estimates, and large sieve–style estimates that recur in analytic number theory into independent modules, with clearly stated hypotheses and constant dependencies. The main proof cites conclusions only, without expanding the derivations.
The analytic infrastructure layer. General facts from complex analysis, Fourier analysis, and special functions should be reused from mature libraries as much as possible, avoiding reinventing them inside the project. Additional lemmas, if needed, should be stored in one place with notes mapping them to classical textbooks (the mapping can be described with literature references; it need not be tied to a specific repository).
The tactics and automation layer. Package “rewrite—simplify—close” as configurable tactics to reduce hand-written procedural steps. Note that tactics must be predictable: if each run generates different scripts, later compression becomes impossible to reproduce.
After each round of compression, keep the verification logs and a module inventory, confirming that what was removed is redundant expansion rather than a load-bearing assumption.
The Trade-off Between Readability and Line Count
Shorter versions tend to be denser: each line carries more reasoning, local variables get inlined, and proof terms sit closer to the checker’s internal representation. This is friendly to machines but not to humans. Longer versions may be full of explanatory lemmas, better suited to teaching and cross-review.
It’s better to maintain two views in parallel rather than force a single “short yet readable” illusion:
- The verification view: optimized for passing checks, minimal dependencies, and reproducible builds.
- The review view: keeps natural-language commentary on key lemmas, proof outlines, and correspondence tables with classical steps.
When the review view still runs to hundreds of pages, that does not necessarily mean failure. What matters is whether each section corresponds to a module in the formalization, and whether conditions, exceptions, and external facts not yet fully formalized are explicitly flagged. Any “conditionally refactored” or “working draft” should put its list of internal assumptions up front, to avoid being mistaken for a complete verification.
How Natural-Language Documents and Machine Scripts Should Correspond
Human readers typically read the natural-language argument first, then spot-check the formalization. A usable natural-language document should:
- Map theorem numbers one-to-one to formalized modules, so no “spoken theorem” is missing from the code.
- List the precise statements of external results cited, rather than vague book-level references.
- Mark which steps are machine-verified, which remain commonly accepted facts, and which are additional assumptions by the author.
- Use page count to serve structure, not as evidence of correctness. Unreadably long text is as useless for confirmation as unauditable ultra-short text.
Cloud object storage, containerized builds, and logging services are well suited to holding script versions, verification logs, and correspondence tables, making differences traceable during global collaboration. Compute resources cannot substitute for mathematical review; they can only reduce the cost of repeated builds.
Safe Practices for Further Compression
When cutting size again, fix the process: lock in a verified baseline; extract common lemmas; replace local automated paths; run regression verification at every step. Never batch-delete “seemingly useless” auxiliary definitions without verification. Treat intelligently generated snippets as drafts awaiting refactoring: wrap them in a carefully designed interface, then remove the generation artifacts.
If the goal is to halve a tens-of-thousands-line proof, the savings usually come from stronger library reuse, coarser tactics, and merging parallel cases into parameterized theorems—not from squeezing whitespace.
Conclusion
Compressing formalized proofs is, at its core, the same deduplication, layering, and interface design used in software engineering. Line count can serve as a stage-level gauge, but the final standard remains: the machine can verify it, humans can grasp the main line, and no assumptions are hidden. Facing a massive auto-generated draft, first establish reproducible builds and a module map, then talk about “how small it can still get.” Weighing correctness, readability, and maintainability on the same scorecard is the only sustainable approach.
