The Compression Limits of Large-Scale Formal Proofs
This article examines what it really means to compress a large formal proof, using a recently compressed proof development related to the Riemann hypothesis as the case study. It explains why source line count is not the same as verification cost, why lines that look redundant are needed for maintainability, and where the true compression ceiling lies once a proof is reduced to explicit assumptions. It also outlines four criteria for measuring compression rigorously and explains why a two-day reduction cannot be extrapolated. The intended takeaway is practical: treat proof compression as a measurable, rollback-capable engineering process rather than a line-count contest.
1. A Relay Compression Effort Exposes the Real Question
An AI-assisted formal proof development covering several theorems related to the Riemann hypothesis originally contained roughly 175,187 files and about 17 million lines. The community then compressed it in a relay: a published compact version is about 76,000 lines, and a human-readable version is about 300,000 lines. Both versions cover the five target theorems listed in the original. Cutting more than two million lines in two days sounds like the start of an approach to some limit, but it does not tell you how many lines would remain a few days later.
The reason is that “how large is the proof” maps to at least three non-equivalent questions:
- What is the shortest source that a machine checker will accept?
- How much structure must a formalization project retain to stay maintainable by researchers over time?
- How much detail must an argument expose for mathematicians to read, review, and reproduce it?
The answers have already diverged: 76,000, 300,000, and 17 million. The order-of-magnitude gaps come from measuring different objects, not from differences in compression strength.
2. Source Lines Are Not Verification Cost
A formal system’s checker does not read the source itself; it checks the proof terms produced after the source is elaborated. A single short automation tactic in the source can make the system generate thousands of intermediate steps. So “fewer lines” and “less data handed to the checker” are not necessarily connected.
A public independent verification run gives a concrete comparison: the compact version exported about 5.17 GB of proof data, while the readable version exported about 4.49 GB. The version with shorter source produced the larger expanded artifact. This is not a contradiction—compact style typically relies on stronger automated search and deeper nested unfolding, moving complexity from “characters” to “computation.”
In engineering terms, three cost categories must be accounted for separately:
| Cost type | Main drivers | Typical change after compression |
|---|---|---|
| Source size | Number of declarations, wrapper layers, naming and comments | Drops significantly |
| Verification overhead | Proof term size, dependency graph depth, cache hit rate | May increase |
| Maintenance overhead | Module boundaries, interface stability, traceability | Increases after over-compression |
3. Why the Lines That Look Redundant Must Stay
In a maintainable formalization project, import statements, repeated wrappers, automatically generated helper lemmas, and styles that help the system locate intermediate steps all take up a lot of lines. They are not redundancy; they are carriers of navigability:
- Module boundaries determine the blast radius of a change.
- Stable naming keeps search and references from breaking.
- Layered lemmas make local replacement possible.
- Local comments record “why this reduction was done,” not just “what was done.”
If someone later needs to replace an estimate, check a boundary condition, or port the whole development to a different base library, they must know which dependencies a change will touch. Keeping a few extra lines often saves several times that amount in search and rework.
Schematically, over-compression folds maintainable structure into a mass that is hard to take apart:
# Over-compressed: short, but the change radius is uncontrollabletheorem main (h1 h2 h3 h4 h5 : Prop) : P := bysimp_all [defs]; nlinarith [h1, h2, h3, h4, h5]
# Maintainable style: longer, but each layer can be replaced on its ownlemma step_estimate : A -> B := by-- Relies on the bound estimate from classical analysis; the replacement point is hereexact classical_bound_estimatelemma step_boundary : B -> C := by-- Boundary conditions form their own layer, making point-by-point checking easierexact boundary_case_analysistheorem main : P := step_boundary (step_estimate h_input)
Both snippets may be equally valid to the machine, but the second one allows “estimate” and “boundary” to be replaced and verified separately.
4. Reduction to Assumptions: Where the Real Compression Ceiling Is
The readable version reduces the main inequality to thirteen assumptions stated in the language of classical mathematics, and marks which inputs come from the formal development and which remain external inputs. This is the key to judging the compression limit: what the formal part can compress is only the reasoning chain “from assumptions to conclusion.” If the assumptions themselves are not formalized, the line count cannot drop further—the volume is merely moved into explanatory documentation. The related notes are still being organized, which is itself a reminder to readers: any claim of a “minimum line count” is incomplete without an accompanying list of assumptions.
5. How to Rigorously Measure “How Much Smaller It Can Get”
To produce a credible number, fix four things first:
- Object of measurement: source lines, or bytes of the elaborated proof terms.
- Scope: whether library lemmas already merged in and dependency libraries are counted.
- Coverage target: all five theorems, or only the core inequality.
- Resource constraints: verification time and memory limits, and whether more aggressive automated search is allowed.
Until these four are settled, “cut it in half again” is a narrative, not a conclusion. A reusable practice is to use expanded artifact size and verification time as the primary metrics, source line count as a secondary metric, and to record dependency graph depth and cache hit changes for every compression pass.
6. Why a Two-Day Compression Cannot Be Extrapolated
If a batch of duplicated code happens to share one lemma, the line count drops a step instantly; but whether the next site can be handled the same way depends on whether it involves a few lines of style or the definitions, lemma interfaces, and downstream reasoning. Once the thing to change is the proof route itself, you must redo that piece of mathematics before deleting a few lines. This is also why the payoff curve of relay-style compression is necessarily stepwise and gradually converges.
For teams that want to borrow this experience, the actionable advice is: run parallel verification on a container platform in the cloud, store exported artifacts in object storage, and use logging and monitoring with alerting to track the time and failure points of each compression pass—turning “compression” into a measurable, rollback-capable engineering process rather than a one-off line-count race.
