← All papers
First page of Verified Proof Refactoring with Codex and Qwen

Verified Proof Refactoring with Codex and Qwen

Lazar Milikic, Gordan Đurić, Viktor Kunčak

cs.AI Nov 24, 2026 · v1
An LLM agent refactors existing Lean 4 proofs to shorten them and cut checking cost; every replacement is accepted only if Lean verifies it on all required versions.
We refactor existing Lean 4 proofs to reduce source length and checking cost while preserving theorem statements and compatibility across Lean versions. A locally served Qwen model uses the open-source Codex CLI to inspect source, retrieve declarations, and test proof replacements. The host keeps a replacement only if it improves the objective and Lean accepts it on every required version. A deterministic CPU pass then refines the verified proofs. On the 60 problems in Lean Refactor Arena, model search achieves a local mean combined score of 82.07, and cleanup raises it to 82.18. The final proofs pass all 127 required proof–version checks. Our system placed first in the open-source LLM track of Lean Refactor Arena at VeriCodeGen.

Lean proofs of the same theorem can differ in source length, checking cost (heartbeats), and compatibility across Lean versions. Lean Refactor Arena poses 60 tasks that ask for improved replacement proofs with the theorem statements kept fixed.

A locally served Qwen3 model, used without fine-tuning, runs inside a lightly modified open-source Codex CLI to inspect source, retrieve declarations through a LeanExplore index, and test candidate proofs. The host keeps a candidate only if it improves a combined score of length, heartbeat and compatibility terms and Lean accepts it on every required version. A deterministic CPU cleanup pass then applies further transformations to the verified proofs.

Model search reaches a local mean combined score of 82.07 across the 60 problems, and cleanup improves 28 proofs to raise the mean to 82.18. All 127 required proof–version checks pass, and the system placed first in the open-source LLM track of Lean Refactor Arena.