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

Guiding Enumerative Program Synthesis with Large Language Models

Yixuan Li, Julian Parsert, Elizabeth Polgreen

Program synthesis—the automated generation of code that satisfies a rigorous logical specification—has long been considered a "holy grail" of software engineering. Historically, the field has been divided into two distinct paradigms. On one hand, Large Language Models (LLMs) demonstrate remarkable intuition in generating procedural code from natural language but are prone to "hallucinations" and struggle with the precise syntax of formal logic (such as SMT-LIB). On the other hand, traditional enumerative synthesizers are mathematically sound and exhaustive but suffer from "state-space explosion," where the number of possible programs to check grows exponentially with program length.

This research introduces a novel framework to bridge this gap, using the syntactic intuition of LLMs to guide and prune the search space of formal enumerative synthesizers. By treating LLM outputs—even incorrect ones—as a map for prioritization, the authors' tool, pCFG-synth, significantly outperforms state-of-the-art solvers on standard logic-heavy benchmarks.

Methodology: Integrating Intuition and Rigor

The authors propose two primary strategies to integrate LLMs into the synthesis loop, moving from offline guidance to a more dynamic, online interaction.

Offline Guidance: pCFG-synth

In the offline approach, the LLM acts as a "syntactic oracle." It generates several candidate solutions based on the initial prompt. While these candidates are often logically incorrect, they frequently contain the correct "ingredients" (functions, variables, and constants) needed for the solution.

The architecture of the pCFG-synth system, showing how LLM outputs are used to weight the enumerative search.

As shown in Figure 1, the system extracts the grammar rules used in these LLM attempts to construct a Probabilistic Context-Free Grammar (pCFG). This pCFG weights the enumerative search to prioritize the specific "neighborhood" of the search space that the LLM identified as relevant. The search is then executed using either a probabilistic top-down enumerator or a weighted A* search algorithm.

Online Guidance: iLLM-synth

For more complex problems, the authors developed iLLM-synth, an online approach where the synthesizer calls the LLM mid-search. This creates a tighter feedback loop between the formal tool and the neural model.

The architecture of the iLLM-synth system, illustrating the dynamic interaction between the enumerator and the LLM during the search process.

In this configuration (Figure 2), the enumerator provides the LLM with a partial program and a counterexample (a specific input where the current program fails). The LLM is then asked to provide "helper functions" or completions to bridge the gap. This allows the search weights to be updated dynamically based on the LLM's real-time feedback.

Key Insights: The Neighborhood Hypothesis

A central finding of this work is the Neighborhood Hypothesis: when an LLM fails to solve a formal logic problem, the correct solution is often syntactically "nearby." By weighting the synthesizer to explore the vicinity of the LLM’s mistakes, the system finds correct programs much faster than a blind search.

Furthermore, the researchers discovered that LLMs provide a significant "length advantage." Traditional enumerators are biased toward short programs because longer ones take exponentially more time to reach. However, LLMs are capable of jumping directly to complex, multi-line solutions. The average solution found uniquely by the LLM-guided approach was 4.7x longer than those found by the baseline solver, cvc5.

Evaluation and Results

The researchers evaluated their methods on 609 benchmarks from the Syntax-Guided Synthesis (SyGuS) competition, covering Bit-Vector (BV) manipulation, Linear Integer Arithmetic (LIA), and Invariants (INV).

The results demonstrate a clear synergistic effect:

  • LLM (GPT-3.5) alone: Solved 49.8% of benchmarks.
  • cvc5 (State-of-the-art baseline): Solved 68.1% of benchmarks.
  • LLM ∪ A*-pCFG-synth: Solved 80.1% (488/609) of benchmarks.

The hybrid approach proved particularly dominant in the Bit-Vector and Invariant categories, where the search space is traditionally most difficult to navigate.

Limitations and Future Work

While promising, the approach faces several hurdles. The cost and latency of calling LLM APIs are significantly higher than local enumerative search. Additionally, the non-deterministic nature of LLMs means that synthesis performance can vary between runs. The authors also noted that LLMs struggle with Programming-by-Example (PBE) tasks, where they tend to overfit to specific examples using if-else chains rather than discovering generalizable logic.

Future research will focus on using smaller, locally hosted models fine-tuned specifically for synthesis guidance to reduce costs and improve the consistency of the "syntactic oracle."

Summary updated

BibTeX
@inproceedings{li2024guiding,
  author = {Yixuan Li and Julian Parsert and Elizabeth Polgreen},
  title = {{Guiding Enumerative Program Synthesis with Large Language Models}},
  booktitle = {CAV},
  year = {2024},
  doi = {10.1007/978-3-031-65630-9\_15},
}
Figure