---
title: "Proof-Refactor Turns Ugly AI Math Proofs Into Human-Readable Code"
subtitle: "Proof-Refactor is a four-phase agentic system that turns monolithic LLM-generated Lean proofs into readable, modular, library-quality artifacts"
url: "https://alphasignal.ai/news/proof-refactor-turns-ugly-ai-math-proofs-into-human-readable-code"
author: "AlphaSignal Newsroom"
author_url: "https://alphasignal.ai/editorial-team"
company: "AlphaSignal"
company_url: "https://alphasignal.ai/company/alphasignal"
published: "2026-06-02T00:00:00.000Z"
updated: "2026-06-10T13:12:41.674Z"
type: "Paper"
topics:
  - "Reasoning"
  - "Development"
subtopics:
  - "Math Reasoning"
  - "Code Agents"
upvotes: 2097
source_url: "https://arxiv.org/abs/2606.03743"
comments: 0
truncated: true
---

# Proof-Refactor Turns Ugly AI Math Proofs Into Human-Readable Code

> Proof-Refactor is a four-phase agentic system that turns monolithic LLM-generated Lean proofs into readable, modular, library-quality artifacts

LLMs have gotten surprisingly good at generating formal proofs in proof assistants like [Lean](https://lean-lang.org/). But there is a catch: the proofs they produce tend to compile and nothing more. They are tangled, monolithic scripts that a human mathematician would never write, let alone want to maintain or reuse. A new paper from researchers at Southern University of Science and Technology and Peking University proposes [Proof-Refactor](https://arxiv.org/abs/2606.03743), an agentic framework that takes those working-but-ugly proofs and restructures them into something closer to what you would find in a mature math library.

## The compile-first trap

Formal theorem proving with proof assistants such as Lean produces machine-verifiable mathematical proofs. This is useful for verified mathematics and for training LLMs, since proof checking provides a precise reward signal for reinforcement learning. The problem is that this same reward signal creates a perverse incentive.

Proof-assistant verification induces a narrow objective: a generated proof is rewarded primarily for compiling. This binary feedback ensures correctness, but it does not by itself encourage readability, modularity, maintainability, or library integration. The result is what the authors call the "compile-first" trap: the compile-first objective implicit in most proof-generation pipelines encourages monolithic or ad hoc proof scripts rather than library-quality artifacts.

In practice, LLMs trained with reinforcement learning often produce Lean proofs that are correct but notoriously long and hard to read. Prior work tried to fix this, but ran into a measurement problem: the most tractable and experimentally validated objectives are largely length-based, while higher-level qualities such as readability, modularity, maintainability, and reusability are difficult to reduce to reliable automatic metrics.

## A process-guided answer

Instead of chasing a single proxy metric, the Proof-Refactor team took a different angle: they take a process-guided approach inspired by human proof-refactoring workflows. The idea is that the right way to improve a proof is not to optimize a score, but to follow the same steps a skilled mathematician would take when cleaning up someone else's draft.

_Preview only. Full text requires an AlphaSignal Pro account._

## Sources

- [Proof-Refactor: Refactoring Generated Formal Proofs into Modular Artifacts](https://arxiv.org/abs/2606.03743)
- [Proof-Refactor HTML paper](https://arxiv.org/html/2606.03743)
- [PutnamBench: A Multilingual Mathematics Benchmark for Formal Theorem-Proving](https://trishullab.github.io/PutnamBench/)
- [Lean Refactor: Multi-Objective Controllable Proof Optimization via Agentic Strategy Search](https://arxiv.org/abs/2605.20244)
- [Making Written Theorems Explorable by Grounding Them in Formal Representations](https://arxiv.org/pdf/2604.02598)
