Compressing Machine-Generated Proofs Without Losing Readability
Machine-assisted proofs of large theorems often grow to millions of lines before a long slimming phase. This article explains why that bulk appears, how structural cleanup, lemma refactoring, dependency replacement, and narrative compression reduce it, and why fewer lines can make a proof harder to review. It also covers how formal and natural-language drafts should divide work, what relay collaboration needs to stay auditable, and when further shrinking stops being useful.
Large machine-assisted proofs are often written first to pass a checker, then enter a long slimming phase. In public discussion, first drafts commonly run to millions or even tens of millions of lines, then fall to hundreds of thousands or tens of thousands after successive rounds of deletion. A human-facing natural-language account can shrink in parallel from hundreds of pages to tens. Line counts and page counts are only proxies. The real questions are how small a proof can become while remaining logically closed, and how small it can become before someone is still willing and able to review it.
Why proofs become abnormally large
Intelligent programming tools are good at local completion: given a target statement, they retrieve similar lemmas and generate many intermediate steps. A formal checker only cares whether each step is accepted by the rules. It does not care whether the narrative repeats itself, whether names are stable, or whether the structure is easy to read. First drafts therefore tend to swell in three ways.
First, search traces are left in place. Failed branches, overly broad auxiliary assumptions, and proof fragments copied only to pass a small subgoal accumulate into blocks that are almost never reused. Second, library results and handwritten steps overlap. Theorems already available in standard analysis, complex analysis, or number theory are re-expanded into long elementary derivations. Third, granularity is unbalanced. A pattern that could be one lemma is expanded into thousands of nearly identical lines. Size is then driven mainly by the generation strategy, not by the information content of the mathematics.
Treating compression as merely deleting comments or shortening identifiers underestimates the difficulty. Effective compression is an equivalence transformation on the dependency graph: remove dead code, merge isomorphic proofs, lift shared assumptions, and replace expansions with stronger but already trusted library theorems, while keeping the checker passing throughout.
Main technical paths for compression
Relay-style slimming can be divided into four layers, with risk increasing from the outside inward.
1. Structural cleanup. Count unreferenced definitions, duplicate imports, and intermediate goals that exist only for debugging, and start with reachability analysis. This layer usually produces a large reduction and does not change the mathematical statements. A schematic process is: traverse dependencies backward from the final theorem, mark reachable declarations, isolate the rest for review, and then delete them. After cleanup, rerun a full check rather than checking only the final file.
2. Lemma refactoring. Identify repeated proof patterns and extract parameterized lemmas. Estimates that differ only in an interval, a function, or an error term should converge to a general statement with explicit side conditions. The gain comes from reuse, not from shorter identifiers. Record the correspondence from old declarations to new ones; otherwise later reviewers cannot confirm that assumptions were not quietly strengthened.
3. Dependency replacement. Replace handwritten expansions with theorems from a foundational library that has already been formalized and checked by the community over a long period. Before replacement, verify that the premises are strictly weaker or equivalent. Do not introduce a stronger condition merely to write fewer lines. An external result that exists only in natural language and is not yet closed inside the same system should not be treated as “invoked, therefore proved.” State the trust boundary explicitly: which theorems are closed in this repository, and which remain assumptions awaiting verification.
4. Presentation compression. Outside the formal text, maintain a natural-language spine, a symbol table, and a proof map. Human readers follow the spine first, then use the map to enter formal fragments. This step does not reduce the amount of logic the checker must verify, but it can sharply reduce cognitive load. Collapsing a complete proof into “one line that calls an external library” only moves the bulk into a dependency. It does not reduce what must be trusted.
Why readability can fall after the line count falls
In practice, moving from an enormous version to a medium one removes repetition, clarifies structure, and improves readability. Pushing further to an extremely compact version often reverses that gain. The mathematics has not usually become harder. Information has been encoded in a more opaque form.
Names lose their meaning and become short symbols. Proof steps collapse into huge tactic combinations, intermediate assertions disappear, and failures become hard to locate. Critical estimates are buried inside automatic proof search, so a reader cannot see where an inequality tightens. The file is short, but the jump depth increases: the reader must expand back and forth among many higher-order lemmas. “Fewer lines” and “one person can understand this in a reasonable time” no longer move together.
Track at least three indicators, not a single line count: whether the final check passes; whether the hypothesis list of the core theorem is stable; and how long an independent reader needs to review one critical lemma. Page count is likewise not evidence of correctness by itself. A few hundred pages entering a “barely discussable” range only means the narrative is close to a size human working memory can organize. It does not mean every step is uncontested.
How natural-language and formal drafts divide the work
The two carriers answer different questions. The formal draft answers whether the argument can be checked mechanically under agreed foundational rules. The natural-language draft answers what the main line is, where the novel steps are, and which literature is used. The useful collaboration is not substitution but correspondence:
- Each natural-language section corresponds to a group of formal declarations.
- Each critical estimate is marked as a library theorem, a lemma of this paper, or an external assumption.
- The bibliography keeps only items that are actually used, and states whether the statement itself or its method of proof is used.
If an external theorem has not yet been aligned item by item with the literature, label it as a conditional reconstruction, not a complete proof.
When compressing natural language, delete repeated motivation and synonymous rewrites first. Keep definitions, the main theorem, the proof skeleton, and discussion of counterexamples or boundary cases. Further shortening usually comes from citing standard background instead of restating it, moving computational detail to an appendix, and turning repeated error control into one uniform lemma. Once those anchors disappear, the manuscript becomes a text with conclusions but no surface that can be attacked, and its value for review drops quickly.
Engineering discipline for relay collaboration
Global or cross-team relays can remove a large amount of redundancy in a short time because different people notice different repetition. For that collaboration to be auditable rather than an untraceable series of deletions, a few disciplines are required.
Freeze the mathematical statement. Before a compression round begins, lock the type and assumptions of the final theorem with a hash or version tag. Any change that weakens or strengthens the conclusion, or that changes quantifier structure, must be reviewed separately. It must not be mixed into a “cleanup commit.”
Commit in small steps and recheck in full. Each batch of deletions should be independently reversible. If an automatically generated diff is larger than a reviewer can read, split it. A line-count curve can show progress, but it cannot replace diff review.
Separate generation from acceptance. It is reasonable to keep using intelligent programming tools for merging, renaming, and tactic-based rewriting. Acceptance must be done by someone who understands the field, with at least spot checks of the tightest estimates, the deepest dependencies, and every external assumption. A tool may propose that two proof segments are isomorphic. A person must confirm that the conditions preserved by that isomorphism were not quietly dropped.
Keep a proof map. Even as the code gets shorter, maintain a page-scale directory: main theorems, dependency layers, unclosed assumptions, and known readability risks. The map itself should be compressed and updated so that it does not become more confused than the proof.
How small can it get?
There is no fixed lower bound in lines. It is set by three things.
Inherent complexity of the mathematics. If the argument depends on a sequence of new estimates that cannot be merged, and each step changes later constants or regions, those steps need checkable interfaces. Handing all of them to opaque automation only hides the complexity.
Coverage of the foundational library. The more analysis and arithmetic tools the library already contains, the shorter the handwritten part. Trust in “calling the library” cannot exceed the extent to which the library itself has been reviewed. Wrapping the whole proof in one external result can drive the size toward zero. The information has not disappeared.
Audience constraints. If the goal is machine rechecking, a compact tactic-heavy version can be acceptable, provided the build is reproducible and logs can locate failures. If the goal is for a human to judge correctness in a short time, stop on the plateau where critical steps remain visible, even if that means keeping tens of thousands of lines or tens of pages of explanation. Public estimates that “a readable version will appear fairly soon” are bets on the speed of second-stage refactoring, not guarantees of correctness.
A practical stopping rule is: deleting any further large block either makes the check fail, requires a stronger external assumption, or makes a critical step impossible for another skilled reader to restate within an agreed time. Meeting any one of these means the compression boundary of the current system is near. Before that, the line count may still fall. After that, chasing a smaller file usually sacrifices reviewability.
A practical order of work
Lock the statement and the trust boundary first. Then remove dead code and duplicate proofs, extract parameterized lemmas, and only afterward consider more aggressive merging of tactics. At every step, keep reproducible check commands, a dependency list, and a natural-language counterpart, not merely a smaller file. For a company or research team, object storage is suitable for immutable snapshots, version control for recording correspondences, and continuous checking for preventing a “compression commit” from breaking closure. These are general engineering capabilities. They do not need to be tied to one particular generative tool.
The conclusion is direct. Machine-generated long proofs can be compressed substantially, and public cases already show that redundancy is often far larger than the core argument. The final size should be set jointly by verifiability and readability. Tens of thousands of lines of formal text, or a natural-language spine of tens of pages, may be a stage result and may still contain assumptions that have not been aligned. Treating “can it be smaller?” as the only goal produces an unreadable claim of victory. Treating “can another expert follow the map and review this?” as a constraint turns compression into part of mathematical communication rather than a contest scored only by line count.
