Reinforcement Learning for Syntax-Guided Synthesis

Julian Parsert, Elizabeth Polgreen

Abstract

Syntax-Guided Synthesis (SyGuS) is a challenging domain for machine learning due to the chronic scarcity of high-quality training data. We present a reinforcement learning (RL) framework that combines Monte-Carlo Tree Search (MCTS) with a novel data-generation technique based on the anti-unification of logic problems. Our approach achieves a 26% performance boost over baselines and successfully solves 182 problems that the current state-of-the-art solver, cvc5, cannot.

Introduction

Program synthesis—the automated generation of code from logical specifications—is often considered the "holy grail" of computer science. In Syntax-Guided Synthesis (SyGuS), users provide a logical specification of the desired behavior and a syntactic template defining the allowed grammar. While machine learning has revolutionized "Programming-by-Example," it has struggled with SyGuS due to data scarcity. Generating complex logical specifications paired with correct code solutions is inherently difficult, limiting the training of neural models or boosted trees needed to guide the search for a solution.

Methodology

MCTS-Guided Synthesis

The search for a program is modeled as a single-player game within a grammar tree. The system utilizes Monte-Carlo Tree Search (MCTS), guided by two learned components:

  • Policy Function: Identifies the most promising grammar rules to apply at any given node.
  • Value Function: Estimates the quality of a partial program and the likelihood of reaching a solution.

These functions are trained using XGBoost (gradient-boosted trees) within an RL loop. The solver begins with no prior knowledge, attempts problems, and uses successful solutions to refine its heuristics for subsequent iterations. XGBoost was selected over deep neural networks to minimize prediction latency, which is critical when the solver must make thousands of decisions per second during tree search.

Data Generation via Anti-Unification

To address the lack of training data, the authors developed a method to harvest logic from existing Satisfiability Modulo Theories (SMT) problems. By using anti-unification—a process that identifies the most specific general pattern between two logical terms—they create new SyGuS benchmarks. This ensures that solutions are guaranteed to exist while presenting non-trivial challenges that reflect real-world logical structures.

Datasets

The study evaluated the framework using three primary datasets:

  1. SyGuS-comp (Old): 957 standard competition benchmarks.
  2. Generated (New): 8,168 problems created via anti-unification.
  3. Filtered (New): A curated subset of 944 high-quality, non-trivial problems.

Results and Discussion

The RL loop demonstrated a clear learning trajectory, significantly improving the solver's success rate over time as it bootstrapped knowledge from its own successes.

Learning curve showing the increase in solved problems over iterations.

In experimental evaluations, the RL-guided solver improved its success rate from a 34.3% baseline to a mean of 60.7% (peaking at 60.9%). Notably, the tool outperformed cvc5 on the training set and solved 182 problems that cvc5 failed to solve entirely, highlighting the power of learned heuristics over traditional hand-coded rules.

Comparative performance of the RL solver against baselines and cvc5.

A key insight was the effectiveness of the anti-unification method in generating "control-flow" benchmarks. The method increased the number of solvable problems requiring if-then-else logic by 10x compared to previous datasets. This suggests that "harvesting" logic from existing SMT solvers is a viable path for training synthesis models without manual data labeling.

Conclusion

This work demonstrates that learned heuristics can rival or exceed the performance of massive, hand-tuned systems like cvc5 (which contains over 400k lines of code). While the "cold start" problem remains a challenge for entirely new domains, the combination of MCTS and anti-unification-based data generation provides a robust framework for advancing syntax-guided synthesis. Future work will explore applying these datasets to algorithm selection and run-time prediction tasks.

Summary updated

BibTeX
@inproceedings{parsert2024reinforcement,
  author = {Julian Parsert and Elizabeth Polgreen},
  title = {{Reinforcement Learning for Syntax-Guided Synthesis}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i9.28938},
}
Figure