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

Recursive Program Synthesis

Aws Albarghouthi, Sumit Gulwani, Zachary Kincaid

TL;DR

This paper introduces ESCHER, a novel algorithm for synthesizing recursive programs from input-output examples. ESCHER uses a unique "goal graph" to efficiently handle conditional logic and a search strategy that balances exploring new program components with inferring necessary conditions, outperforming existing SAT-based methods.

What Problem Does This Paper Address?

The dream of empowering non-programmers to create software by simply showing examples of desired behavior is a long-standing goal in computer science. While synthesizing programs from logical specifications has been around for a while, making this accessible to everyday users requires a more intuitive input method. Input-output examples, like those used in spreadsheet formulas (e.g., Excel's Flash Fill), offer a promising avenue. However, synthesizing recursive programs, which are fundamental to many complex computations, from such examples presents a significant challenge. Existing methods often struggle with efficiently generating conditional logic and scaling to a wide range of problems, especially when dealing with complex data structures like lists and trees.

Methods

ESCHER tackles recursive program synthesis with a two-pronged approach:

  • Generic, Parameterized Algorithm: ESCHER is designed to be flexible. It takes a set of "components" (basic operations, API calls, or even recursive calls to itself) as input, allowing it to be instantiated for various domains (integers, lists, trees, etc.) without needing to be rewritten.
  • Novel Search Strategy: ESCHER employs an iterative process alternating between:
  • Forward Search: This phase systematically builds programs by combining existing components.
  • Conditional Inference (Goal Graph): This is ESCHER's key innovation. Instead of relying on a pre-defined "if-then-else" component, ESCHER uses a "goal graph" to dynamically infer when conditional logic is needed. This graph represents the sub-problems that need to be solved to achieve the overall goal, allowing ESCHER to construct conditionals "on demand."
  • Observational Equivalence Reduction: To prune the search space, ESCHER discards programs that behave identically on the given examples, ensuring that only unique program behaviors are explored.
  • Termination Argument: For recursive programs, ESCHER incorporates a mechanism to ensure termination, preventing infinite loops by checking for decreasing arguments in recursive calls.

Datasets

The paper does not explicitly mention pre-existing datasets for training or evaluation. Instead, the authors created their own benchmarks for evaluating ESCHER. These benchmarks consist of a set of recursive programs manipulating integers, lists, and trees, drawn from functional programming assignments and classic examples.

Key Insights and Ideas

  • Conditional Inference without Explicit Components: The "goal graph" is a significant departure from previous methods. By inferring the need for conditionals based on sub-goal satisfaction, ESCHER avoids the limitations of pre-defined conditional components and allows for more flexible program structures.
  • Genericity is Key: Parameterizing ESCHER by its component set makes it a powerful tool applicable to diverse domains, rather than being tied to a specific problem type.
  • Observational Equivalence as a Powerful Pruning Technique: Discarding programs that are indistinguishable based on input-output examples drastically reduces the search space, making the synthesis process more efficient.
  • Heuristic Search Outperforms Naive Approaches: The paper demonstrates that a well-guided search, particularly one that prioritizes smaller programs (size heuristic), is crucial for practical synthesis.

Key Results

ESCHER demonstrated impressive performance in synthesizing a wide range of recursive programs:

  • Efficiency: ESCHER synthesized many programs in under a second, significantly outperforming a state-of-the-art SAT-based tool (SKETCH) which often timed out or required substantial memory.
  • Scalability: ESCHER remained efficient even when provided with a large set of superfluous components, whereas SKETCH's performance degraded significantly with extra components.
  • Effectiveness of Goal Graph: Configurations of ESCHER that disabled the goal graph (using a simpler if-then-else component) performed much worse, often timing out, highlighting the importance of ESCHER's novel conditional inference mechanism.
  • Completeness: The paper formally proves that ESCHER is "relatively complete," meaning if a solution exists within the defined search space, ESCHER will eventually find it.

Limitations and Future Work

The authors acknowledge a few limitations and suggest future directions:

  • Synthesizing Loops: ESCHER currently focuses on recursion. Extending it to synthesize iterative loops is a natural next step.
  • Constant Synthesis: While ESCHER synthesizes program structure, integrating SMT solvers could enhance its ability to synthesize specific constant values within programs.
  • Intelligent Tutoring System: The authors envision ESCHER as a potential tool for teaching recursion, allowing students to interact with the synthesizer to learn programming concepts.
  • Heuristic Design: Developing more sophisticated heuristic functions for guiding the search is an ongoing area of interest.

Summary updated

BibTeX
@inproceedings{albarghouthi2013recursive,
  author = {Aws Albarghouthi and Sumit Gulwani and Zachary Kincaid},
  title = {{Recursive Program Synthesis}},
  booktitle = {CAV},
  year = {2013},
  doi = {10.1007/978-3-642-39799-8\_67},
}
Figure