NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Proof Flow: Preliminary Study on Generative Flow Network Language Model Tuning for Formal Reasoning

Matthew Ho, Vincent Zhu, Xiaoyin Chen, Moksh Jain, Nikolay Malkin, Edwin Zhang

TL;DR

This paper explores using Generative Flow Networks (GFlowNets) to fine-tune language models for formal theorem proving in Lean 4. By training the policy to generate proof steps with probability proportional to a reward rather than strictly maximizing it, GFlowNets encourage exploration of diverse reasoning paths and help amortize search costs into training.

What Problem Does This Paper Address?

Automated reasoning in formal languages like Lean provides an ideal testbed for complex problem-solving because proof checkers guarantee ground-truth correctness. However, current neural theorem proving (NTP) approaches face notable bottlenecks:

  • Mode collapse in standard RL: Classical reward-maximizing reinforcement learning (e.g., PPO, GRPO) tends to prematurely converge on a narrow set of tactics, failing to discover alternative valid proof trajectories.
  • Costly inference search: Exploring broad reasoning branches at test time ("System 2 thinking") requires heavy compute budgets.
  • Supervised Fine-Tuning (SFT) limitations: SFT simply mimics demonstration trajectories without learning how to explore or recover from dead ends.

The authors propose GFlowNet fine-tuning as a principled framework to generate diverse candidate tactics, mitigating mode collapse while shifting the burden of exploratory search from inference to training time.

Methods

The authors frame interactive theorem proving as generating a sequence of tactics guided by GFlowNets:

  • Tree-Structured State Representation: In Lean, distinct tactic sequences can lead to identical proof states (a directed acyclic graph). Learning a backward policy on DAGs is unstable and difficult. To bypass this, the authors augment the state encoding with the full history of prior tactics and the initial theorem state. This turns the state graph into a tree, making backward transitions unique and deterministic ($P_B = 1$).
  • Trajectory Balance (TB) Loss: The policy is trained using Trajectory Balance, simultaneously learning the forward tactic policy $P_F$ and estimating the log partition function $\log Z$ via a learned linear head.
  • Composite Reward Formulation: To combat extreme reward sparsity, the terminal reward combines:
  • Exact verifier verification (highest reward for complete proofs),
  • A penalty for Lean syntax errors based on tactic length,
  • Intermediate partial credit assigned by a reward model (RM) using token likelihood from ReProver for non-terminal, valid states.
  • Base Architecture & Optimization: The tactic generator is initialized from ReProver (a 350M-parameter ByT5-small model). Training incorporates an experience replay buffer and injects ground-truth trajectories to stabilize optimization.
       [ Initial Proof State ]
                  │
        (Tactic Selection: PF)
                  ▼
         [ Augmented State ]  ──►  Lean Verifier / RM
                  │
         (TB Loss Updates)
                  ▼
      [ Diverse Proof Paths ]

Datasets

  • LeanDojo / mathlib Benchmark: Experiments use theorems extracted from the standard Lean 4 mathematics library (mathlib).
  • Filtered Splits: The authors filter for:
  • Tactic-only proofs (no term-mode proofs),
  • Ground-truth proof lengths of $\le 3$ steps,
  • Bounded token lengths ($<900$ state tokens, $<90$ tactic tokens),
  • Fast environment initialization ($\le 5$ seconds).
  • Scale: The curated dataset contains 1,000 training theorems and an evaluation set of 20 validation theorems (balanced across proof depths 1, 2, and 3).

Key Insights and Ideas

  • Amortizing System 2 Compute: Fine-tuning with GFlowNets effectively teaches the model to approximate posterior sampling proportional to reward, shifting the computational cost of wide candidate generation from inference time to training time.
  • Replay Buffers Trade Stability for Speed: Using an off-policy replay buffer completed 2,000 gradient steps in 0.86× the time of purely on-policy runs, though it introduced training loss volatility around step 1,000.
  • SFT Remains a Strong Baseline in Low-Compute Regimes: Under constrained search budgets and small model sizes, the high sample efficiency of standard SFT matched or slightly exceeded GFlowNet performance, suggesting that the diversity benefits of GFlowNets require higher compute and larger base models to fully materialize.

Key Results

Evaluated under a constrained search budget (30 seconds per theorem, branching factor of 8) using Best-First Search on the 20-theorem hold-out set:

  • Base Model (ReProver): Solved 4/20 theorems (20%).
  • SFT Baseline: Solved 9/20 theorems (45%).
  • Full GFlowNet: Solved 9/20 theorems (45%), peaking at 9 before showing some late-training regression.
  • Ablations:
  • Binary Reward + Online Only (GFN-BR-OO): 9/20 (45%).
  • Online Only with Partial Reward (GFN-OO): 8/20 (40%).

Limitations and Future Work

  • Small Benchmark Scale: The validation set is tiny (20 theorems), and proof depths were restricted to $\le 3$ steps, limiting broad statistical claims.
  • Reward Model Bottleneck: The GFlowNet objective depends directly on reward quality; the auxiliary reward model struggled to reliably annotate intermediate tactics without extensive search.
  • Future Directions:
  • Scaling up model parameter size and theorem complexity,
  • Implementing PPO baselines for direct comparisons against traditional RL,
  • Integrating Monte-Carlo Tree Search (MCTS) during training,
  • Exploring Direct Preference Optimization (DPO) to train more accurate process reward models on "hard" negative tactics.

Summary updated

BibTeX
@inproceedings{ho2024proof,
  author = {Matthew Ho and Vincent Zhu and Xiaoyin Chen and Moksh Jain and Nikolay Malkin and Edwin Zhang},
  title = {{Proof Flow: Preliminary Study on Generative Flow Network Language Model Tuning for Formal Reasoning}},
  booktitle = {Sys2-Reasoning @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=gYzgA0EnRs},
}
Figure