Par for the Proof: Agentic Compression of Lean 4 Proofs under Exact Compiler Feedback
Organizations: Emergence AI · Student at the Indian Institute of Science
Abstract
We describe our closed-track entry to the Lean Refactor Arena, where Lean 4 proofs must be rewritten to be shorter (fewer tokens) and cheaper to check (fewer heartbeats) while still compiling on every listed toolchain, for at most $3 of API spend per problem. We treat the task as a search against an exact, compiler-defined cost. A frontier model (gpt-6.1-sol) proposes proofs. A Lean metaprogram inserted into the target file measures each candidate as the competition does, at the cost of elaborating one declaration, and the best candidate so far is replaced only by one with a strictly higher three-axis score. A deterministic Lean optimizer then polishes the winner with verified local rewrites, and a reproduction of the competition scorer judges it. On the 60-problem final benchmark, our submission scores a combined 87.88 on the arena (length -80.2%, heartbeats -83.4%, all 67 cross-toolchain checks passed), at $2.83 per problem on average and $2.97 at most. The score tracked the number of verified evaluations the budget bought: a cheaper model per turn, a session policy that spends the whole allowance, and half-price Flex tokens each raised it, while more information, more structure, or forced diversity did not.
Figures & tables
| Corpus | Toolchains | Len.% | HB% | Score | Cost $ | |
|---|---|---|---|---|---|---|
| Strata | 4.26–4.31 | 7066 1525 | 80.00 | 84.71 | 88.24 | 28.92 |
| PhysLib | 4.34.0–4.34.1 | 6057 807 | 68.77 | 53.66 | 74.14 | 26.52 |
| CSLib | 4.30–4.34.1 | 4076 1210 | 70.96 | 88.77 | 86.58 | 28.71 |
| ArkLib | 4.30–4.34 | 23027 2818 | 87.80 | 93.41 | 93.74 | 28.80 |
| LeanPool | 4.34–4.35-rc3 | 17903 4122 | 78.99 | 83.20 | 87.40 | 28.79 |
| PutnamBench | 4.26–4.27 | 27324 874 | 96.38 | 97.21 | 97.86 | 28.15 |
| Run | Change | Comb. | Len. % | HB % | Total $ |
|---|---|---|---|---|---|
| 1 | warm-up configuration, standard tier, no optimizer | 84.70 | 75.09 | 79.01 | 163.94 |
| 2 | + deterministic optimizer; infrastructure fixes | 85.74 | 76.54 | 80.68 | 161.43 |
| 3 | + heaviest problem searched (previously lost to a profiling failure) | 86.96 | 78.85 | 82.02 | 169.45 |
| 4 | + Flex tier (submitted) | 87.99 | 80.48 | 83.49 | 169.89 |
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
| Problem | Len.% | HB% | Score | S | Evals | St.2 | sol $ | luna $ | Total $ | ||||
| Strata (v4.26–4.31) | |||||||||||||
| InitsUpdatesComm | 224 | 62 | 4180 | 177 | 72.32 | 95.77 | 89.36 | 19 | 191 | 2.79 | 0.035 | 2.82 | |
| denote_suffix_irrel | 904 | 176 | 4183 | 441 | 80.53 | 89.46 | 90.00 | 8 | 179 | 2.88 | 0.017 | 2.90 | |
| denote_Denotes | 931 | 127 | 10925 | 1316 | 86.36 | 87.95 | 91.44 | 7 | 221 | ✓ | 2.90 | 0.011 | 2.91 |
| callOfLFunc_eraseMetad… | 291 | 39 | 21294 | 1564 | 86.60 | 92.66 | 93.09 | 8 | 215 | 2.75 | 0.034 | 2.78 | |
| liftBVars_typeCheck | 209 | 22 | 17630 | 1677 | 89.47 | 90.49 | 93.32 | 12 | 331 | 2.90 | 0.017 | 2.92 | |
| Seed | Optimizer version | Seed score | Gain |
|---|---|---|---|
| Original proofs | lint, ablate, minlemmas, trybotup | 33.33 | +10.35 |
| agent output, first harness | same | 86.90 (farm) | +0.15 (farm) |
| agent output, row 4 harness | + InfoTree phases (slim, share, inline) | 88.58 | +0.10 |
| agent output, row 6 harness | same | 91.07 | +0.03 |
| agent output, row 6 harness | + golf, clean | 91.07 | +0.21 |
| row 6 incumbent at 2 | + golf, clean | 88.62 / 90.48 | +0.43 / +0.20 |
| Run | Change | Comb. | Len. % | HB % | Total $ |
|---|---|---|---|---|---|
| 1 | gpt-6-astra (high); first harness; flat $2.50 finalize; optimizer | 86.99 | 76.7 | 84.3 | 39.79 † |
| 2 | proof-body interface, located errors, librarian, break-even caps | 87.74 | 77.8 | 85.4 | 40.37 † |
| 3 | adaptive finalize; effort xhigh | 88.17 | 79.8 | 84.7 | 38.57 † |
| 4 | cache-write metering; tool fixes | 88.58 | 80.0 | 85.8 | 39.68 |
| 5 | gpt-6.1-sol (max) | 90.57 | 83.4 | 88.3 | 37.89 |
| 6 | bullet token rule ‡ ; refreshed images | 91.07 | 84.4 | 88.9 | 35.89 |
| Change | Base | With | Reading |
| More information for the agent (warm-up) | |||
| Lemma suggestions in goals ; persistent librarian | 88.01/88.17 | 88.06 | noise |
| Offline Loogle-style pattern search | 88.58 | 88.26 | noise |
| Larger prompts and tool outputs | 88.20 | 87.56/87.07 | to |
| Heartbeat profiles on every new best (12) | 91.94/92.03 | 91.98 | null |
| More structure in the search (warm-up) | |||
| Tool | Purpose | Calls |
|---|---|---|
| Patch evaluation | exact replacements on an archived candidate, batched variants | 3,396 |
| Name search | paginated name search with namespace and kind filters | 2,584 |
| Name lookup | signatures and sources of named constants | 2,467 |
| Proof evaluation | compile and measure 1–4 whole proof bodies | 2,366 |
| Candidate archive | archive listing and retrieval by ID | 2,144 |
| Goal states | goal state per tactic and branch; paged retrieval | 1,291 |
Lean Theorem Proving
Lean theorem proving uses the Lean proof assistant to construct machine-checked mathematical proofs, often with automated search and language models.
See all 141 papers