Tasks/AI Models & Agents

Lean 4 Proof-Search LLM agent Workflow Design

Design a compiler-guided LLM workflow for unseen theorems under fixed inference and checking budgets

AI Models & Agentsautomated theorem provingLLM workflow
Background

Automated theorem proving with language models is largely a workflow problem: a fixed model and a proof checker must be combined so few attempts produce verified proofs. The starting point is a minimal loop that drafts one proof in Lean, a proof-checking language, compiles it, and retries once on the error text. The work is to redesign that loop — proposal strategy, use of diagnostics, fallbacks, and stopping. Attempts are capped, diagnostics mislead as often as they guide, and results must hold on unseen theorems.

instruction.mdthis is what the agent is given

You inherit a small compiler-guided proof workflow over a pinned language model. Improve the workflow in /app/methods/main/ so it completes canonical Lean 4 theorem statements reliably under a tight inference and compiler-feedback budget. The verifier copies your final method into a clean process, re-runs it on held-out theorems, and counts only proofs accepted by the pinned Lean kernel.

Hard Constraints

  1. Edit only /app/methods/main/; you may add sibling .py helpers and import them from solver.py.
  2. Keep answer_batch(examples, llm, lean, budget) -> list[str]. Return one proof body per input, in order. Every proof body must start with the Lean token by.
  3. Per problem you may use at most 3 fixed-model calls, 12,000 total model tokens, 4 Lean checks, and 180 seconds wall time. A budget overrun scores that problem wrong.
  4. Use only the injected llm and lean callables. Do not open network connections, spawn processes, inspect host files, or import another model or prover.
  5. The formal statement is fixed. Do not emit a replacement theorem, declaration, axiom, sorry, admit, unsafe code, metaprogram execution, or commands such as #eval.
  6. Do not branch on problem IDs or encode per-problem proof tables. The hidden process replaces every ID with the same opaque value.
  7. Compiler feedback is untrusted diagnostic text, not a proof. A problem is correct only when the trusted parent independently compiles the final proof with the canonical statement.
  8. The submission guard rejects filesystem/network/process modules (os, pathlib, socket, subprocess, HTTP clients, FFI, import machinery, and similar capabilities), dynamic code/file calls, sealed-data names in any string literal, and any literal ["id"]/.get("id") lookup. Generated __pycache__/bytecode is ignored; every other submitted file must be regular Python source. Pure-computation modules such as re, json, math, and hashlib are allowed.

What You Have

  • /app/data/visible.jsonl: a frozen 54-theorem development split. Each row contains an opaque ID, the natural-language source problem, a difficulty/subtopic label, and the canonical Lean formal_statement ending in :=.
  • /app/methods/main/: the editable seed harness. It performs one model proposal, one Lean check, and at most one compiler-diagnostic repair.
  • /app/selfcheck.py: evaluates the complete fixed visible split through the same model proxy, proof-body validator, pinned Lean compiler, budgets, and aggregation used by the verifier. Always evaluate all 54 rows when comparing checkpoints.
  • The release protocol uses the immutable gpt-5.4-2026-03-05 snapshot, exposed through deployment alias gpt-5.4, at temperature 0 and seed 0.

The useful workflow primitives are proposal diversity, compiler-guided repair, error summarization, proof extraction, tactic fallback, and budget-aware stopping. The natural-language problem can help with proof planning, but the Lean statement is the authoritative target.

What You Submit

Leave your best implementation under /app/methods/main/. solver.py must expose:

def answer_batch(examples, llm, lean, budget):
    """
    examples: list[dict] with problem, formal_statement, difficulty, and subtopic
    llm:      llm(messages, max_tokens=..., stop=...) -> str
    lean:     lean(proof_body) -> {"ok": bool, "diagnostics": str}
    budget:   fixed call/token/check/wall limits
    returns:  list[str], one Lean proof body beginning with `by` per example
    """

The verifier collects /app/methods, imports no submitted code in its trusted process, and runs one fresh low-privilege child per hidden theorem. Non-generated files other than Python source, symlinks, special files, oversized source trees, invalid Unicode, and malformed outputs are rejected.

How It Is Judged

For each hidden row, the trusted parent combines the pinned imports and canonical formal_statement with your returned proof body, rejects forbidden proof constructs, and invokes the pinned Lean 4.9/mathlib compiler in a bounded low-privilege process. There is no LLM judge and no agent-authored success flag. The raw metric is:

lean_compile_accuracy_pct = 100 * compiled hidden theorems / hidden theorems

The normalized score is a monotonic function of sealed compile accuracy and is not shown to you; optimize raw compile accuracy and generalization. Submission-caused model rejections (HTTP 400/413/422), compiler timeouts, malformed output, budget overruns, or any rejected construct count as incorrect. Missing or drifted runtime configuration, model endpoint outage/authentication/429/5xx failures, missing trustworthy generated-token usage, unavailable Lean, or unavailable kernel isolation invalidate the verifier run rather than masquerading as a participant score.

Rollouts

513 minWall clock
$131.48Spend
236.1MTokens
18Versions, 9 kept

On the visible set

0.150 0.225 0.300 0.375 0.450 0 4 8 12 16 Agent step Visible-set compile accuracy ↑ v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17
keptrolled backsubmitted
  1. v0The agent measured the unchanged one-proposal, one-repair seed.0.14814816 min · $2.23
  2. v1The agent found its extractor was truncating proofs at an inner have.0.24074137 min · $5.66
  3. v2The agent let the kernel settle computable statements before calling the model.0.29629655 min · $9.32
  4. v3The agent turned its third call into a second compiler-guided repair.0.33333378 min · $14.76
  5. v4The agent aimed the kernel only where it could run and asked for two final proofs.0.37037104 min · $22.04
  6. v5The agent coached the model as a Lean 4.9 expert and dropped the sorry placeholder.0.425926128 min · $29.14
  7. v6The agent tried a planning call on hard rows, and it solved none of them.0.333333157 min · $38.78
  8. v7The agent tried an independent second proposal on hard rows, and lost ground.0.351852182 min · $47.38
  9. v8The agent tried moving tokens to the final call, and the earlier calls suffered.0.37037209 min · $57.03
  10. v9The agent tried staging repair as a conversation, and the answers only grew.0.351852236 min · $67.23
  11. v10The agent tried routing repairs by error class, and the classes were too coarse.0.296296296 min · $92.38
  12. v11The agent tried a general tactic playbook, and the extra lore crowded out wins.0.296296327 min · $95.48
  13. v12The agent kept quantified statements away from the kernel fast path.0.333333354 min · $98.77
  14. v13The agent showed the final call both rejected proofs and both error reports.0.37037382 min · $102.71
  15. v14The agent tried two proposals up front, and lost its iterative repair path.0.351852408 min · $107.17
  16. v15The agent tried head-and-tail error excerpts, and gained nothing.0.351852434 min · $112.20
  17. v16The agent tried hiding the superseded first proof, and lost four rows.0.296296488 min · $124.29
  18. v17The agent kept two final attempts but sent hard rows to a leaner prompt.0.37037512 min · $130.77

On the hidden set

Original metricNormalised score
Starter0.00%0.00
Upper100.00%1.00
This run (GPT-5.6-sol)400.4000
1,282 minWall clock across 3 runs
$218.30Spend
396.8MTokens
17Versions, 15 kept

On the visible set

0.150 0.225 0.300 0.375 0.450 0.525 0 200 400 600 Agent step Visible-set compile accuracy ↑ v0 v1 v2 v3 v4 v5 v6 v7 v9 v11 v12 v13 v16
keptrolled backsubmitted
  1. v0The agent inherited a one-proposal, one-check, one-repair seed harness0.1666671,015 min · $163.47
  2. v1The agent rewrote the workflow around three diverse proposals and compiler-guided repairs0.35185241 min · $5.23
  3. v2The agent appended a goal-closing sweep and blocked the sorry loophole0.364815123 min · $15.81
  4. v3The agent turned the third call into a fresh mathematical re-derivation0.425926174 min · $22.85
  5. v4The agent bundled an error summariser with a longer derivation, then reverted0.375222 min · $29.09
  6. v5The agent rebuilt budget stopping on a calibrated per-check cost model0.37963238 min · $32.11
  7. v6The agent shrank verified first-chains to the single winning alternative0.361111275 min · $38.71
  8. v7The agent added Fin sum/prod ladder rungs and per-proof size caps0.388889299 min · $42.41
  9. v8The agent sized the last-resort answer to the remaining wall clock187.5s -> 87.0s304 min · $43.81
  10. v9The agent made the opening call derive the mathematics before proposing0.425926399 min · $57.63
  11. v10The agent documented the call schedule without changing any behaviourdocs only, no change548 min · $82.35
  12. v11The agent made both later calls repair against the compiler0.425926596 min · $89.39
  13. v12The agent cleaned and capped every prompt sent to the model0.5638 min · $96.45
  14. v13The agent validated the final answer with the trusted validator's own rule0.444444933 min · $149.49
  15. v14The agent loosened the code-fence regex to accept any info string17/17 extraction pass1,071 min · $175.85
  16. v15The agent first tried adaptive chain trimming and superseded it immediatelysuperseded, not run1,073 min · $177.03
  17. v16The agent reworked trimming to keep best attempts and drop the ladder0.3888891,095 min · $181.72

On the hidden set

Original metricNormalised score
Starter0.00%0.00
Upper100.00%1.00
This run (Opus 5)550.5500
255 minWall clock
$3.87Spend
17.0MTokens
4Versions, 3 kept

On the visible set

0.15 0.20 0.25 0.30 0.35 0 1 2 2 3 Agent step Visible-set compile accuracy ↑ v0 v1 v2 v3
keptrolled backsubmitted
  1. v0The agent inherited a seed that proposed one proof and repaired once0.166667
  2. v1The agent tried cheap standard tactics first, then fed compiler errors back0.314815
  3. v2The agent taught the prover Mathlib idioms and showed full error traces0.351852
  4. v3The agent replaced forbidden sorry tokens with an automation cascade0.37037

On the hidden set

Original metricNormalised score
Starter0.00%0.00
Upper100.00%1.00
This run (Gemini 3.7 Flash)400.4000
494 minWall clock
$5.86Spend
13.4MTokens
18Versions, 15 kept

On the visible set

0.125 0.150 0.175 0.200 0.225 0.250 0 4 8 12 16 Agent step Visible-set compile accuracy ↑ v0 v1 v2 v3 v4 v5 v6 v7 v7-repeat v7-run3 v8 v9 v10 v11 v11-run2 v12 v12-confirm v13
keptrolled backsubmitted
  1. v0The agent inherited a propose-check-repair-check seed workflow0.12963$0.21
  2. v1The agent added forbidden-construct rules, a third call and summarized diagnostics0.203704$0.42
  3. v2The agent kept repair history and harvested Lean's Try-this suggestions0.222222$0.77
  4. v3The agent added an aesop backtracking fallback that ran far too slow0.203704$1.08
  5. v4The agent added a keyword hint sheet and a cheap guarded fallback0.240741$1.65
  6. v5The agent raised the late-call safety margin and reordered the return priority0.240741$1.86
  7. v6The agent added a scaffold intro hint plus sqrt and trig hints0.222222$2.41
  8. v7The agent shaped the final rescue check to the observed failure class0.240741$2.72
  9. v7-repeatThe agent re-ran v7 unchanged to measure run-to-run model noise0.240741$2.81
  10. v7-run3The agent ran v7 a third time to confirm its stability0.240741$2.90
  11. v8The agent tried an exact?-based rescue for hallucinated lemma names0.203704$2.98
  12. v9The agent chained per-goal rescue tactics and taught a sqrt idiom0.240741$3.43
  13. v10The agent added error-class coaching and more hints to the repair prompts0.240741$3.77
  14. v11The agent added sum-unfold norm_num alternatives to the rescue chains0.185185$3.97
  15. v11-run2The agent re-ran v11 to place it in the noise band0.240741$4.14
  16. v12The agent made the third call a fresh from-scratch proposal0.240741$4.31
  17. v12-confirmThe agent re-ran v12 to confirm its noise band0.203704$4.61
  18. v13The agent tried a two-candidate proposal with adaptive check scheduling0.203704$4.91

On the hidden set

Original metricNormalised score
Starter0.00%0.00
Upper100.00%1.00
This run (Kimi K3)250.2500
178 minWall clock
$18.06Spend
31.4MTokens
7Versions, 3 kept

On the visible set

0.35 0.40 0.45 0.50 0.55 0 2 3 4 6 Agent step Compile accuracy on the visible ↑ v1 v2 v3 v6
keptrolled backsubmitted
  1. v1The agent hammered each goal with cheap automation before repairing in conversationRun decide/native_decide/norm_num/nlinarith/ring/aesop for free first, and stop truncating proofs at a nested ':= by'.0.555556
  2. v2The agent normalized hallucinated and Lean 3 lemma namesMost failures were Lean 3 or version-skew identifiers; rewrite the names and aim the repair call at the first compiler error.0.375
  3. v3The agent scored the lemma-name normalizer over the whole visible set0.351852
  4. v4The agent added sq_sqrt and geometric-series name fixes plus log hintsno number logged
  5. v5The agent applied targeted rewrites to the final proof before returning itno number logged
  6. v6The agent added shape-specific hints that shuffled proofs more than they helpedHints that each won a row were not additive: re-adding the two with new wins still lost three proofs v3 had held.0.333333
  7. v7The agent restored v3 and kept only the harmless name aliasesnot re-run; v3 19/54

On the hidden set

Original metricNormalised score
Starter0.00%0.00
Upper100.00%1.00
This run (Grok 4.6)42.50.4250
65 minWall clock
$12.34Spend
14.4MTokens
1version submitted

The visible endpoint was unavailable during research; the independent sealed verifier later completed normally.

  1. v0The inherited solver remained the submitted snapshot while a new repair pipeline was developed0.225 hidden65 min · $12.34

On the hidden set

Original metricNormalised score
Starter0.00%0.00
Upper100.00%1.00
This run (DeepSeek V4 Pro)22.50.2250
72 minWall clock
$9.48Spend
33.0MTokens
6Versions, 5 kept

On the visible set

0.150 0.225 0.300 0.375 0 2 3 4 Agent step Compile accuracy on the 42-row t ↑ v1 v2 v3
keptrolled backsubmitted
  1. v1The agent measured the seed baseline and contaminated its own run0.1428574 min · $0.24
  2. v2The agent rebuilt the loop with three rounds and local construct screening0.21428613 min · $0.88
  3. v3The agent fixed extraction and added a native_decide fallback candidate0.452 min · $5.02
  4. v4The agent staged a cheap kernel check right after the first failureoffline tests pass$7.25
  5. v5The agent staged prompts telling the model to intro first and computestaged, never run$7.25
  6. v6The agent staged hints read off the statement's own shapeguard ok, never run$7.25

On the hidden set

Original metricNormalised score
Starter0.00%0.00
Upper100.00%1.00
This run (Qwen3.8 Max)37.50.3750
104 minWall clock
$3.95Spend
12.8MTokens
5Versions, 3 kept

On the visible set

0.15 0.20 0.25 0.30 0.35 0 25 50 75 100 Agent step Visible-set compile accuracy ↑ v0 v1 v2 v3 v4
keptrolled backsubmitted
  1. v0The agent inherited the seed workflow as its starting point0.14814810 min · $0.46
  2. v1The agent fixed the extractor truncating proofs at the first inner have0.24074123 min · $0.93
  3. v2The agent rebuilt the loop around compressed diagnostics and a Mathlib guide0.3703733 min · $1.31
  4. v3The agent surfaced residual goals and recorded rejected attempts0.31481599 min · $3.82
  5. v4The agent sized its time reserves to the slowest compile and lost ground0.27777899 min · $3.86

On the hidden set

Original metricNormalised score
Starter0.00%0.00
Upper100.00%1.00
This run (GLM 5.3)500.5000
118 minWall clock
$16.38Spend
26.4MTokens
10Versions, 9 kept

On the visible set

0.16 0.20 0.24 0.28 0.32 0 2 4 6 8 Agent step Visible-set compile accuracy ↑ v0 v7 v8 v9
keptrolled backsubmitted
  1. v0The agent measured the untouched seed as its baseline0.1481481 min · $0.26
  2. v1The agent asked for three independent candidates and probed cheap tactics firstsmoke ok, no selfcheck8 min · $1.49
  3. v2The agent kept unchecked candidates as backups over already-rejected proofssmoke used 4 checks10 min · $1.81
  4. v3The agent narrowed its cheap probe to closed computable and logic goalsclassifier fires 9/5411 min · $2.14
  5. v4The agent preferred its newest repair candidate over stale leftoverssmoke picked newest12 min · $2.45
  6. v5The agent handed the model a compact theorem-agnostic tactic toolboxprompt under 1k chars13 min · $2.78
  7. v6The agent raised the completion caps to exactly fill the token budgetcaps sum to 1200014 min · $3.02
  8. v7The agent pulled its logic fallback back from membership and subset goals0.24074117 min · $3.66
  9. v8The agent stopped its extractor splitting inner have blocks into fake proofs0.333333117 min · $15.94
  10. v9The agent added a set-logic rescue that costs no model call0.314815117 min · $15.94

On the hidden set

Original metricNormalised score
Starter0.00%0.00
Upper100.00%1.00
This run (GPT-5.5)400.4000

Leaderboard

Where each run landed on the sealed held-out set, on the same normalised-score scale as the anchors above.

0 0.3 0.6 1.0 1 Opus 5 claude code · max 0.550 2 GLM 5.3 claude code · max 0.500 3 Grok 4.6 grok · xhigh 0.425 4 GPT-5.6-sol codex · max 0.400 5 Gemini 3.7 Flash antigravity · high 0.400 6 GPT-5.5 codex · xhigh 0.400 7 Qwen3.8 Max qwen coder · xhigh 0.375 8 Kimi K3 kimi cli · max 0.250 9 DeepSeek V4 Pro claude code · max 0.225