Overview
Automated theorem proving is traditionally bottlenecked by a severe lack of training data. While imitation learning excels in tasks with abundant data, human-produced formal mathematical proofs are conspicuously scarce. This paper introduces a novel AlphaZero-style reinforcement learning (RL) approach that completely eliminates the need for human-provided training data. By co-training a "teacher" agent to generate relevant mathematical problems and a "solver" agent to prove them, the system achieves state-of-the-art results. Applied to the notoriously difficult task of loop invariant synthesis, the trained solver successfully cracks all problems in a standard benchmark, often without needing any search backtracking.
The Challenge of Automated Theorem Proving
Reinforcement learning via self-play (like AlphaZero) seems like a natural alternative to supervised learning, but it faces two massive hurdles in theorem proving:
- Infinite Action Spaces: Unlike board games such as chess or Go, theorem provers have infinite action spaces that cannot be effectively explored at random.
- Lack of Training Tasks: Board games feature symmetric self-play, providing an infinite curriculum of tasks. In theorem proving, an agent requires a constant supply of relevant, diverse, and appropriately difficult theorem statements to practice on.
To tackle these gaps, the authors focus on a specific, highly challenging domain: loop invariant synthesis for imperative programs. This is widely considered the most crucial and difficult step in automated program verification.
Methodology: Co-Training Teacher and Solver Agents
The authors propose a framework where expert knowledge is encoded as nondeterministic programs. These act as high-level search strategies containing a choose operator, leaving the actual decision-making up to a neural network guided by Monte Carlo Tree Search (MCTS).
To solve the data scarcity problem, they introduce a dual-agent setup:
- The Teacher Agent: Uses a conditional generative strategy to create synthetic training problems. To balance the conflicting goals of generating valid problems and diverse problems, the teacher first samples random constraints, generates a problem that fits them, and then applies validity-preserving transformations to maximize diversity.
- The Solver Agent: Learns to solve the generated problems using abductive reasoning (working backward by inferring missing assumptions). Abduction is usually computationally explosive, but the neural network learns to guide it efficiently.
Both agents are trained using the AlphaZero algorithm. Furthermore, instead of just predicting a final scalar reward (pass/fail), the network is trained to predict strategy events (e.g., specific constraint violations or proof steps). This provides much richer feedback to the network, solves the credit assignment problem for early mistakes, and improves sample efficiency.
To make this practical, the authors built Looprl, a new domain-specific language embedded in OCaml that compiles nondeterministic strategies into RL environments.
Experimental Setup and Results
Remarkably, 100% of the training problems used in this study were generated on-the-fly by the teacher agent. No human-written code or proofs were used for training. For evaluation, the authors used the standard Code2Inv benchmark, which consists of 132 C programs requiring loop invariants.
The system demonstrated exceptional performance:
- 100% Benchmark Success: The solver agent successfully solved all 132 problems in the Code2Inv benchmark using MCTS, a feat previously only achieved by highly specialized, non-learning numerical solvers.
- Zero-Search Generalization: To prove the network actually learned deep heuristics rather than just relying on brute-force MCTS, the authors tested it without any search or backtracking (greedily taking the top predicted action). The fully trained solver solved 61.5% of the benchmark zero-shot.
- The Importance of the Teacher: When the solver was trained using problems generated by an untrained (random) teacher, its zero-search success rate plummeted to 39.7%. A random baseline solver achieved only 18.4%. This proves the co-trained teacher is vital for creating a robust learning curriculum.
Key Insights and Future Work
This research demonstrates that you can bypass the lack of human data in mathematics by making problem generation a learnable strategy itself. The teacher learns to build a curriculum of increasingly interesting problems, while the solver uses neural-guided abduction to navigate massive search spaces scalably.
The primary limitation of the current approach is the engineering effort required to write the teacher strategies. Currently, the diversity of generated problems is enforced extrinsically via manually defined constraints, requiring domain expertise.
For future work, the authors suggest integrating intrinsic reward signals—such as curiosity mechanisms or having the solver directly reward the teacher for producing problems in the "sweet spot" of difficulty. They also plan to expand this nondeterministic programming framework to broader domains of mathematics and software verification.
Summary updated