Compressing and Reviewing Large-Scale Formal Proofs: A Readability Engineering Guide
This article examines how massive machine-verifiable proof artifacts can be reduced from millions of lines to a maintainable size without losing verifiability. It explains why formal proofs bloat, breaks compression into four layers (syntax, structure, semantics, and representation), and shows how to balance machine metrics against human readability. It also outlines a rollback-safe verification loop, the interface conventions that make distributed collaboration work, and the role of natural-language proofs alongside formal ones.
1. A Global Relay-Style Proof Compression
A recent case drew wide attention: a formal proof of a mathematical conjecture, generated with the help of an AI coding tool, started at roughly ten million lines. Through a relay of optimization work by developers around the world, it was cut by about 2.4 million lines in two days, then compressed further to around 52,000 lines, with intermediate versions of 76,000 and 300,000 lines along the way. Meanwhile, a natural-language version of the same result was reduced to a few dozen pages.
Setting aside the specific tools and people involved, this is fundamentally a problem of large-scale machine-verifiable artifact governance. The artifact is produced by automated pipelines, is far larger than any human can read, and must go through layered compression, deduplication, abstraction, and re-verification before it becomes a maintainable, reviewable engineering asset. The reusable methods are broken down below.
2. Why Formal Proofs Balloon to Millions of Lines
Line count does not reflect mathematical difficulty; it reflects how far the proof is expanded at the low level. There are six common sources of bloat:
- Tactic expansion: every automated step leaves intermediate goals and states behind, producing large amounts of repeated context.
- Type class and instance search traces: the same lemma is instantiated repeatedly under different instances.
- Missing intermediate abstractions: reasoning goes straight from axioms to the conclusion, with no reusable lemma layer.
- Messy naming and structure: multiple equivalent copies of the same proposition exist.
- Redundancy from generative completion: models tend to “write extra for safety,” producing code that a single line could replace.
- Unconverged dependencies: external theorems are not aligned to a unified interface, causing duplicate proofs.
Illustrative code (pseudocode, conveying the idea only):
# Bloated style: expand every stephave h1 := lemmaA xhave h2 := lemmaB h1have h3 := lemmaC h2...# Compressed style: abstract into a reusable lemmalemma key (x) : P x := byapply chain [lemmaA, lemmaB, lemmaC]
3. Four Layers of Compression
1) Syntax-layer compression: merge consecutive tactics, delete unused have statements, and replace linear expansion with combinators. Gains are fast, but readability drops.
2) Structure-layer compression: extract intermediate lemmas and build a three-tier “theorem–lemma–helper lemma” structure, collapsing repeated fragments into a single entry point.
3) Semantic-layer compression: unify type classes and instances, eliminate equivalent copies, and align external theorem interfaces so the same fact is not proved multiple times.
4) Representation-layer compression: separate the machine proof from the documentation, keeping a minimal verifiable core on the machine side and maintaining natural-language explanations and a mapping table on the human side.
The empirical rule is that the higher the layer you compress at, the more visibly line count drops, but every step must pass the verifier again. Otherwise the compression only “looks smaller.”
4. The Trade-off Between Readability and Line Count
The case explicitly notes that the 52,000-line and 76,000-line versions were actually less readable than the 300,000-line version. The reason is straightforward: compression often sacrifices explicit structure, packing information humans need into longer single tactic chains.
Engineering practice suggests setting dual metrics:
- Machine metrics: line count, verification time, number of dependencies.
- Human metrics: average lemma length, maximum nesting depth, proportion of files understandable on their own.
An actionable constraint example:
limits:max_lines: 60000max_lemma_depth: 3max_tactic_chain: 12human_readable_ratio: 0.7
When line count meets the target but human metrics do not, fall back to the structure layer and re-abstract rather than continuing syntax-layer trimming.
5. A Verification Loop: Compression Must Be Rollback-Safe
Treat the compression pipeline as refactoring, not rewriting. The recommended loop:
- Baseline freeze: record the hash and verification log of the current verifiable version.
- Small-step compression: change only one layer at a time, keeping each change within reviewable scope.
- Automated verification: run verification jobs with no network access and fixed dependencies in a container platform.
- Metrics dashboard: track line count, time, and failure rate with monitoring and alerting.
- Rollback mechanism: store artifacts and logs in object storage, traceable by version.
Pseudocode:
for layer in [syntax, structure, semantic, representation]:snapshot = verify(current)candidate = compress(current, layer)if verify(candidate) and metrics(candidate) better:current = candidateelse:rollback(snapshot)
6. Team Collaboration and Relay Mechanisms
What allowed a global relay to cut a million lines in two days was not manpower but interface conventions:
- A unified verification command and dependency versions, avoiding “it passes on my machine but not yours.”
- Tasks split along file and lemma boundaries to reduce conflicts.
- Every commit accompanied by “compression type + metric changes + verification log.”
- A message queue to distribute tasks and a log service to aggregate failure causes.
7. The Value and Limits of the Natural-Language Version
A natural-language proof of a few dozen pages shows that human readability does not necessarily depend on machine line count. Engineering practice should maintain a bidirectional mapping: natural-language theorem numbers ↔ formal lemma names. This lets reviewers locate things quickly while enabling minimal-core verification on the machine side. Note that drafts not aligned with external literature or containing internal assumptions cannot claim to be complete proofs and must explicitly state their conditions and dependencies.
8. Conclusion: The Goal of Compression Is Not the Minimum Line Count
Going from ten million lines to 52,000, and then to a joking version that is “a single line calling an external library,” shows that line count has a theoretical lower bound, but the engineering goal should be a balance point of “verifiable + reviewable + maintainable.” Practical advice for developers: first build the verification loop, then apply layered compression, and finally close out with dual-metric constraints. Building the pipeline on general cloud capabilities (container platform, object storage, log service, monitoring and alerting) can significantly lower the collaboration cost of this kind of large-scale refactoring.
