Growing an Agent/Prover Interface: Evolutionary Tool Design for Cost-Efficient Theorem Proving in Rocq and Lean
Organizations: IRIF, Universit´e Paris Cit´e, Inria, CNRS · DI ENS, PSL University, Inria
Abstract
Recent achievements in AI-assisted mathematics require intensive interaction of agents with proof assistants to generate machine-checked proof certificates. Agents interact with proof assistants such as Rocq or Lean through an interface that controls what the agent receives from the prover and the cost of these interactions. Today, these interfaces are adapted from tools designed for humans and not optimized for agents. We propose an evolutionary method where a frontier model incrementally proposes new features and only keeps the ones that improve the overall performance of smaller models. We demonstrate the effectiveness of our method by growing, on a curated set of mathematical problems, \rme, a new MCP server for the Rocq prover. On the held-out \texttt{test} split of miniF2F-Rocq, an agent equipped with \rme outperforms both the baseline that only exposes the Rocq compiler and an established MCP server, across four models from two families, in success rate, cost per solve, and time per solve. Although evolved for Rocq, the resulting server transfers to Lean, improving cost and time per solve on a subset of PutnamBench. We release \rme and its port to Lean.
Figures & tables
| Models | MCP servers | Accuracy | Cost ($) | Wall time (s) | |||
| control | .17 | (.28 / .05 / .01) | .07 | (.06 / .07 / .15) | 52 | (50 / 60 / 86) | |
| rocq-mcp | .33 | (.54 / .11 / .07) | .05 | (.05 / .05 / .06) | 32 | (32 / 30 / 48) | |
| Haiku (40 / 4 / 1) | rocq-mcp-evolve | .48 | ( .69 / .30 / .14 ) | .04 | ( .04 / .03 / .05 ) | 19 | ( 19 / 16 / 36 ) |
| control | .50 | (.68 / .35 / .17) | .24 | (.19 / .36 / .39) | 96 | (76 / 153 / 153) | |
| rocq-mcp | .72 | (.88 / .53 / .56) | .16 | (.12 / .28 / .23) | 44 | (30 / 86 / 64 ) | |
| Sonnet (90 / 28 / 7) | rocq-mcp-evolve | .80 | ( .91 / .68 / .67 ) | .11 | ( .08 / .18 / .22 ) | 35 | ( 23 / 62 / 77) |
| MCP servers | Calls | Input tokens | Output tokens | Output tokens per call |
| control | 5.9 | 79.0k | 6.6k | 1.12k |
| rocq-mcp | 7.2 | 148.4k | 2.7k | 0.38k |
| rocq-mcp-evolve | 5.6 | 59.9k | 1.6k | 0.29k |
| MCP servers | Accuracy | Cost ($) | Wall time (s) | ||||||
| control | .50 | .30 | .40 | 1.56 | 2.19 | 0.22 | 608 | 714 | 332 |
| rocq-mcp | .60 | .60 | .35 | 2.63 | 2.48 | 0.34 | 595 | 661 | 502 |
| rocq-mcp-evolve | .70 | .60 | .50 | 1.44 | 1.89 | 0.16 | 429 | 574 | 269 |
| MCP servers | Accuracy | Cost ($) | Wall time (s) | |||
| control | .33 | (.93 / .05 / .00) | .12 | (.11 / .28 / –) | 82 | (76 / 183 / –) |
| lean-lsp-mcp | .42 | ( .95 / .30 / .00) | .14 | (.11 / .40 / –) | 86 | (72 / 199 / –) |
| lean-mcp-evolve | .33 | (.83 / .18 / .00) | .11 | ( .09 / .35 / –) | 64 | ( 55 / 159 / –) |
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
| Task | Files | Description |
| frugal | 4 | bounded min-plus cost algebra on option nat with a matrix product; laws of the operations and associativity of the product |
| gauges | 4 | closed real intervals over an abstract realType with a sound interval arithmetic; three soundness lemmas and three width lemmas |
| ledger | 4 | append-only ledger of signed deltas with replay and checkpoints; replay/checkpoint equivalence and a bound on balances |
| prodauto | 6 | deterministic finite automata over a finite type; product and complement constructions, language intersection, emptiness by bounded reachability, a pigeonhole pumping lemma |
| triadic | 4 | a divisor-combinatorics dynamical system on natural numbers (from an IMO 2025 problem); a fixed-point theorem and a shrinking theorem |
| rocq-mcp-evolve | rocq-mcp | |
| implementation | OCaml | Python |
| first-party source | 3 527 lines (7 files) | 7 351 lines (8 files) |
| installed components | server + multi-agent daemon/shim | server |
| direct dependencies | 4 opam packages | 3 PyPI packages + coq-lsp toolchain |
| prover attachment | rocq-runtime linked in-process | petanque (coq-lsp) protocol |
| runtime topology | one OS process | server + petanque subprocess; coqc per compile |
| Models | MCP servers | Accuracy | Cost ($) | Wall time (s) | |||
| control | .17 | (.28 / .05 / .01) | .07 | ( .07 / .07 / .15 ) | 54 | (53 / 60 / 86 ) | |
| Haiku | rocq-mcp | .33 | (.54 / .11 / .07) | .10 | (.09 / .12 / .17) | 54 | (51 / 66 / 96) |
| rocq-mcp-evolve | .48 | ( .69 / .30 / .14 ) | .13 | (.10 / .24 / .23) | 67 | (51 / 116 / 136) | |
| control | .50 | (.68 / .35 / .17) | .25 | (.20 / .38 / .39) | 100 | (77 / 161 / 153) | |
| Sonnet | rocq-mcp | .72 | (.88 / .53 / .56) | .25 | (.17 / .36 / .46) | 73 | (47 / 114 / 142) |
| rocq-mcp-evolve | .80 | ( .91 / .68 / .67 ) | .21 | ( .13 / .33 / .37 ) | 72 | ( 41 / 115 / 127 ) | |
| Models | MCP servers | Run | Accuracy | Cost ($) | Wall time (s) | |||
| control | 1 | .17 | (.28 / .05 / .03) | .06 | (.06 / .07 / .15) | 51 | (49 / 64 / 86) | |
| 2 | .17 | (.29 / .05 / .00) | .07 | (.07 / .08 / –) | 52 | (52 / 56 / –) | ||
| rocq-mcp | 1 | .34 | (.55 / .10 / .09) | .05 | (.05 / .04 / .05) | 32 | (32 / 33 / 40) | |
| 2 | .33 | (.53 / .11 / .06) | .06 | (.06 / .05 / .07) | 33 | (32 / 28 / 56) | ||
| rocq-mcp-evolve | 1 | .48 | (.69 / .28 / .14) | .03 | (.03 / .03 / .04) | 19 | (19 / 17 / 28) | |
| Haiku | 2 | .49 | (.68 / .32 / .14) | .04 | (.04 / .03 / .06) | 20 | (19 / 15 / 43) | |
| Models | MCP servers | frugal | gauges | ledger | prodauto | triadic | Total |
| control | 4/4 | 3/4 | 3/4 | 0/4 | 0/4 | 10/20 | |
| Sonnet | rocq-mcp | 4/4 | 4/4 | 4/4 | 0/4 | 0/4 | 12/20 |
| rocq-mcp-evolve | 4/4 | 4/4 | 3/4 | 3/4 | 0/4 | 14/20 | |
| control | 0/2 | 1/2 | 2/2 | 0/2 | 0/2 | 3/10 | |
| Opus | rocq-mcp | 2/2 | 2/2 | 2/2 | 0/2 | 0/2 | 6/10 |
| rocq-mcp-evolve | 2/2 | 2/2 | 2/2 | 0/2 | 0/2 | 6/10 |
| Models | MCP servers | Accuracy | Cost ($) | Wall time (s) |
| control | .50 .12 | 1.56 0.25 | 608 74 | |
| Sonnet | rocq-mcp | .60 .00 | 2.63 1.05 | 595 181 |
| rocq-mcp-evolve | .70 .12 | 1.44 0.84 | 429 202 | |
| control | .30 .14 | 2.19 0.12 | 714 65 | |
| Opus | rocq-mcp | .60 .00 | 2.48 0.27 | 661 142 |
| rocq-mcp-evolve | .60 .00 | 1.89 0.74 | 574 209 |
| GPT-4o | o4-mini-high | Goedel-Prover-V2 |
| COPRA (GPT-4o) | DeepSeek-Prover-V2 | Ax-Prover (Axiomatic AI) |
| Deepseek R1 | DSP+ | GPT-5 (ReAct, 10 turns) |
| Goedel-Prover-SFT | Bourbaki | TIR Conjecturor |
| ABEL | gemini-2.0-flash-thinking | Enumerate-Conjecture-Prove |
| InternLM2.5-StepProver | gemini-2.5-pro-exp-0325 | Kimina-Prover-7B-Distill |
| MCP servers | Run | Accuracy | Cost ($) | Wall time (s) | |||
| control | 1 | .32 | (.90 / .05 / .00) | .12 | (.10 / .31 / –) | 80 | (73 / 197 / –) |
| 2 | .33 | (.95 / .05 / .00) | .11 | (.11 / – / –) | 75 | (75 / – / –) | |
| lean-lsp-mcp | 1 | .43 | (.95 / .35 / .00) | .14 | (.11 / .60 / –) | 88 | (75 / 298 / –) |
| 2 | .40 | (.95 / .25 / .00) | .11 | (.11 / – / –) | 68 | (68 / – / –) | |
| lean-mcp-evolve | 1 | .35 | (.85 / .20 / .00) | .11 | (.10 / .33 / –) | 62 | (57 / 151 / –) |
| 2 | .33 | (.80 / .20 / .00) | .08 | (.08 / – / –) | 51 | (51 / – / –) | |