How to Compress Formal Proofs While Keeping Them Readable

    Once a machine-checkable proof of a large-scale conjecture is generated, the real engineering challenge is not whether it exists, but how to shrink it to a size that humans can still review and machines can still verify. This article explains why formal proofs balloon in size, the main compression techniques available, and how to balance proof size, correctness, and maintainability. It also outlines a practical workflow using snapshots, reproducible verification environments, and version trees so that compression—one-way information loss—never leaves you unable to roll back to a readable intermediate state.

    How to Compress Formal Proofs While Keeping Them Readable

    Once a machine-checkable proof of a large-scale conjecture has been generated, the first engineering problem is usually not “does it exist?” but “how do we compress it to a scale where humans can still review it and machines can still verify it?” Interactive theorem provers turn mathematical reasoning into type-checkable scripts, and dependencies, lemma splitting, and automation tactics all pile on the line count. Add the long-horizon output of generative coding tools, and a proof body can swell to tens of millions of lines—far beyond what any human can read. This has triggered a worldwide relay of compression efforts: deleting redundancy, merging lemmas, tightening tactics, and replacing point-by-point expansions with stronger abstractions. Cutting millions of lines in two days is not the impressive part. The real difficulty is: after compressing, the proof must remain maintainable, traceable to the literature, and must not hide critical steps inside black boxes.

    Why Formal Proofs Explode in Size

    Formal systems demand precise types and dependencies at every step. When a human writes “obviously” or “similarly” on paper, the machine-side equivalent is often hundreds or thousands of lines of expansion. Generative models, aiming to pass the checker on the first try, tend to replicate patterns, repeatedly introduce local definitions, and re-prove library theorems instead of reusing existing abstractions. The result: logical depth does not necessarily grow, but textual volume grows linearly or even super-linearly. Compression is therefore first and foremost a software engineering task: identify repeated sub-proofs, promote common lemmas, and cover the same goals with fewer tactic invocations.

    Readability does not decrease monotonically with line count. A moderately sized, clearly structured version is often easier to review than an extremely compressed one full of “magic tactics.” After compressing three hundred thousand lines down to tens of thousands, local naming disappears and proof intent gets folded into tactics; reviewers can see that “the goal was closed” but not “why it was closed this way.” A joke version that closes everything with a single call importing an entire library might pass verification, but from the standpoint of mathematical communication it amounts to giving up on explanation. So the compression target should be split into two layers: a minimal machine-checkable kernel, and a human-facing layer of structured annotations.

    Common Compression Techniques

    Syntax and engineering-level cleanup. Delete unused imports, merge duplicate definitions, unify namespaces, and remove generation artifacts such as repeated comments and leftover failed attempts. These operations carry low risk; the gains come from volume, not logical depth.

    Lemma refactoring. Extract recurring inequality, estimate, and analytic-continuation fragments into lemmas with clearly stated preconditions, leaving only instantiations at the call sites. Line count drops, the dependency graph becomes clearer, and later bug fixes become easier.

    Automation tactic upgrades. Replace hand-written expansions with stronger simplification, rewriting, linear arithmetic, or domain-specific tactics. This is the fastest route to fewer lines—and the fastest route to collapsed readability. Once tactic parameters and search depths are hard-coded, a library version bump can break everything.

    Managing the boundary of axioms and external results. Formal drafts often treat standard theorems from classical and complex analysis as already-verified library results. During compression, converting a “reference” into a “re-proof” increases volume; internalizing unverified propositions as assumptions decreases volume but weakens the correctness claim. Responsible compression must explicitly list what belongs to the proof kernel, what are external theorems anchored to the literature, and what remain internal assumptions in a working draft.

    The natural-language manuscript and the machine-readable script should evolve in parallel, not as substitutes. A several-hundred-page natural-language argument is good for explaining the main line, citing the literature, and stating conditions; the companion document maps each key lemma to a formal identifier. Once the page count enters the “barely human-readable” range, the focus should shift from cutting pages further to cross-validation: is the same proposition stated isomorphically in the natural language version, the formal version, and the literature? A draft with conditional restructuring or unaligned citations should not be presented as a complete proof, even if it is shorter.

    Balancing Size, Correctness, and Maintainability

    A practical evaluation framework has three dimensions. Size: line count, compile time, dependency closure. Correctness: the kernel passes verification, external theorems have literature correspondences, and there are no undeclared axioms. Maintainability: stable naming, clear module boundaries, and natural-language hooks for key steps. Optimizing only the first dimension produces the humorous outcome of “compressing everything down to a single meta-statement”—a parody of Fermat’s margin, not an engineering goal.

    Community experience suggests that going from tens of millions of lines to hundreds of thousands mostly removes duplication and generative redundancy; going from hundreds of thousands to tens of thousands starts consuming structure; below that, what gets sacrificed is visibility of intent. So “how small can it ultimately get” has no single numeric answer. The right question is: under the constraints of modularity, literature alignment, and non-magical tactics, where is the lower bound on size? If you relax the constraints to allow importing an entire library in one call, the lower bound can be tiny—but that is no longer a communicable proof of the conjecture.

    Cloud-based collaboration fits this kind of task well: object storage keeps snapshots of each stage, a container platform pins the verification environment, logs and monitoring record whether each slimmed-down version compiles, and message queues distribute parallel jobs for “delete redundancy / extract lemmas / run regression.” The key is rollback-capable snapshots—compression is an irreversible information-loss process, and without a version tree you cannot return to an intermediate state when readability collapses. AI coding tools can propose refactors, but before merging, every change must pass a dual gate of the checker plus human spot review, to prevent silently internalizing external propositions that were never aligned with the literature.

    Practical Recommendations

    Define “done” first: the kernel passes, the external theorem list is closed, and the natural-language main line reads independently. Then set a compression budget: for example, every merge must be accompanied by an intent comment, and tactic invocations must not exceed an agreed complexity bound. Visualize the dependency graph of the generated draft and cut high-fan-out duplication first. Shorten the natural-language and formal versions together, not just one side. For versions claiming completeness, check whether internal assumptions remain; for working drafts, keep the title honest.

    In conclusion, the worldwide compression effort has demonstrated that enormous formal texts can be drastically reduced by engineering means—and that extreme compression and human readability cannot be achieved simultaneously. The most valuable artifact is usually not the shortest script, but the version whose size is acceptable, whose structure is navigable, whose citations can be checked against the literature, and which humans can still keep modifying.