Why Large Formal Proofs Get Shorter Under Compression

    This article explains why claims about shrinking a massive formal proof to a few thousand lines are misleading without a clear measurement basis. It separates three distinct notions of length—source code size, expanded proof term size, and human-reviewable mathematical argument—and shows how each is measured and optimized differently. Readers will learn where proof bloat comes from, which compression techniques apply, and how to balance compactness, maintainability, and reviewability with practical team recommendations.

    1. The Recurring Question: How Small Can a Proof Actually Get?

    When a massive formal proof generated with the help of AI coding tools entered public view, the first number people discussed was “lines of code.” The original version contained roughly 175,187 files and about 17 million lines; the compact version released later was around 76,000 lines, and the human-readable version was about 300,000 lines. The claim that roughly 2.4 million lines were removed in two days spread quickly because “line count” is the easiest metric to compare and the easiest to misread.

    The real question is not “what is the minimum number of lines,” but three independent questions:

    • How short can the source code that passes machine verification be written?
    • How much structure must a formal engineering project retain to remain maintainable by a research group over the long term?
    • How much detail must an argument provide for mathematicians to independently read and review it?

    The answers to these three questions differ by orders of magnitude. Mixing them together inevitably produces contradictory conclusions.

    2. Three Kinds of “Length” Are Not the Same Thing

    2.1 Code Volume: Source Lines Are Only the Surface

    Formal proof source code contains a large amount of seemingly redundant content: module and namespace boundaries, duplicated wrapper definitions, automatically generated helper lemmas, and guiding statements written to help automation tactics find intermediate steps. This content is not logically necessary for the proof’s validity, but it greatly affects engineering usability. Rewriting and reusing these parts is the main source of the rapid drop in line count.

    2.2 Expanded Proof Terms: Longer Source Can Be Smaller

    What the machine actually checks is the proof term obtained after the source code is elaborated. A very short instruction in the source can make the proof assistant generate thousands of intermediate steps. A public independent verification showed that the compact version exported about 5.17 GB of proof data, while the readable version exported about 4.49 GB. In other words, the version with fewer source lines produced larger data for the checker.

    This highlights an important principle: a measurement must state its object.

    1. Source lines of code → cost of human writing and reading
    2. Expanded proof term size → input size and memory/time cost for the checker
    3. Checked-in dependencies → whether they are counted directly changes the conclusion

    Without stating whether you are measuring source or expanded output, and whether the existing base library is included, any number for “the minimum possible lines” is not comparable.

    2.3 Human-Reviewable Argument: A Third Kind of Length

    The reading-oriented version solves “how to read the source,” but for mathematicians to independently verify along a conventional mathematical argument, another kind of material is needed. Public materials show that a short outline breaks the overall route into fifteen steps, with three core theorems given as statements and proof sketches, while the complete argument relies on the formal version; a longer explanatory document reduces the main inequality to thirteen assumptions expressed in classical mathematical language and marks which inputs come from the formal development. Such documents are often still being organized, and their length depends on the comprehension threshold reviewers must cross, not on coding style.

    3. Where Bloat Comes From: A Reusable Engineering View

    Line-count bloat in large-scale formal development usually comes from four optimizable categories:

    1. Import and dependency expansion: base libraries, type class instances, and notation declarations amplify quickly along the reference chain.
    2. Duplicated wrappers: the same structure gets a thin wrapper written separately in each module.
    3. Auto-generated content: helper lemmas and intermediate assertions produced in bulk.
    4. Automation guidance: hints and decompositions added manually to make tactic search converge.

    The corresponding compression techniques are relatively mature: extract a shared abstraction layer, replace duplicated wrappers with unified notation and type classes, turn auto-generated content into build-time artifacts rather than checked-in source, and replace point-by-point guidance with more stable tactic configurations.

    It is worth emphasizing that compression is not free. Over-abstraction enlarges the blast radius of local changes, lengthens debugging chains, and raises onboarding costs for new members.

    4. Maintainability: Those “Extra” Lines Are for the Future

    Module boundaries, stable naming, local comments, and lemmas split by layer together form the navigability of the project. When someone needs to replace an estimate, check a boundary condition, or port the entire development to another base library, the truly time-consuming part is locating the scope of impact. Keeping a few more structured lines often saves a great deal of searching and rework.

    In practice, layered measurement works well: the core layer pursues compactness and stable interfaces, the application layer keeps readable names and comments, and the generated layer is fully automated and clearly marked as not hand-editable. This controls overall volume without sacrificing maintainability.

    5. Practical Recommendations for Teams

    • Define the measurement basis first, then discuss compression ratios; report source lines, expanded size, and how dependencies are counted together.
    • Treat compression as a refactoring task with regression verification, avoiding “smaller but more fragile.”
    • Evolve review materials alongside the code, using a step-by-step outline plus an assumptions list to lower the review threshold.
    • Use continuous integration and monitoring alerts to track verification time and resource usage, and include size changes in daily metrics.
    • Archive large proof data with object storage and logging services to ensure results are reproducible and traceable.

    The conclusion is straightforward: there is currently no reliable “final minimum line count,” because the question itself lacks a unified basis. The more pragmatic approach is to measure the three kinds of length separately and optimize them individually, striking an engineering balance among volume, maintainability, and reviewability.