Automating Pruning in Top-Down Enumeration for Program Synthesis Problems with Monotonic Semantics

Keith J. C. Johnson, Rahul Krishnan, Thomas W. Reps, Loris D'Antoni · OpenReview

Introduction

Program synthesis is the process of automatically generating executable code that satisfies a given specification, such as input-output examples or logical constraints. A prevalent approach to this problem is top-down enumeration, where a synthesizer starts with a placeholder (a "hole") and iteratively expands it using the constructs of a target programming language. However, the search space for programs grows exponentially with the size of the target code, a phenomenon known as the state-space explosion.

To navigate this complexity, synthesizers employ pruning strategies to identify and discard partial programs that cannot possibly lead to a valid solution. Historically, these pruning rules have been manually engineered for specific domains, such as regular expressions or SQL queries. This paper introduces Moito, a framework designed to automate the generation of these pruning strategies by leveraging the inherent monotonic properties of programming language semantics.

The Moito Framework

Moito operates within the Semantics-Guided Synthesis (SemGuS) framework, which represents language semantics using logical constraints in the form of Horn Clauses. The core objective of Moito is to derive precise interval-based abstractions—traditionally the work of human experts—automatically.

1. Monotonicity and the Endpoint Recipe

The fundamental insight behind Moito is that many programming operations exhibit monotonicity. For instance, in regular expressions, adding characters to a pattern typically expands the set of strings it can match. When a function is monotonic relative to a specific partial order, its output for any range of inputs can be bounded by evaluating the function at its extreme points (the "endpoints"). Moito uses this "endpoint recipe" to automatically generate abstract interval transformers, allowing the synthesizer to estimate the potential output of a partial program without exhaustive search.

2. Grammar Flow Analysis (GFA)

Pruning is most effective when the synthesizer can reason about "holes"—unfilled parts of a syntax tree. Moito employs Grammar Flow Analysis to determine the potential output range of any program that could be derived from a specific non-terminal in the grammar. By solving a system of constraints over the grammar, Moito calculates tight bounds for these holes, enabling the synthesizer to reject partial programs that, even when completed, could never satisfy the specification.

3. Automated Order Synthesis

The effectiveness of monotonicity-based pruning depends on the choice of a partial order (e.g., determining whether true > false or vice versa). Moito includes an order synthesis component that automatically tests different partial orders to identify the one that maximizes the number of monotonic operators in the language, thereby maximizing the pruning potential.

Experimental Evaluation

The authors evaluated Moito across a diverse set of 430 benchmarks, spanning five distinct domains:

  • Regular Expressions (82): Including complex problems from existing tools like AlphaRegex.
  • Bitvectors (100): Testing both traditional and saturated semantics.
  • Boolean Formulas (238): Synthesizing cubes, CNF, and DNF formulas.
  • Imperative Programs (10): Basic logic involving variable swaps and loops.
  • Data Classification (5): Quantitative synthesis tasks focused on accuracy.

Results and Insights

Moito demonstrated significant improvements over baseline naive enumerators. It solved 241 benchmarks within a 2000-second timeout, compared to 217 for the baseline. More importantly, the pruning efficiency was substantial: in 75% of the benchmarks, Moito explored less than half of the search space required by the baseline. In specific domains like CSV schema synthesis, the use of precise hole abstractions via GFA allowed Moito to explore only 0.1% of the search space, resulting in a 2.6x speedup.

A key conceptual contribution is the "rational reconstruction" of existing domain-specific synthesizers. The authors show that the hand-tuned pruning rules used in specialized tools like AlphaRegex are essentially specific instances of the interval-based abstract interpretation that Moito derives automatically. This suggests that monotonicity is a ubiquitous and powerful property that can be generalized across many synthesis tasks.

Limitations and Future Work

While Moito is highly effective for monotonic operators, it faces challenges with non-monotonic constructs, such as the conditional guards in if-then-else statements. Additionally, the framework relies on SMT solvers (Z3 and CVC5) to prove monotonicity and solve GFA constraints; for complex theories like regular expressions with negation, these solvers can become a bottleneck. Finally, reasoning about the monotonicity of complex recursive structures and loops remains a difficult frontier. Future research may focus on integrating Moito with techniques that synthesize abstract transformers for non-monotonic operators to further broaden the scope of automated pruning.

Summary updated

BibTeX
@inproceedings{johnson2024automating,
  author = {Keith J. C. Johnson and Rahul Krishnan and Thomas W. Reps and Loris D'Antoni},
  title = {{Automating Pruning in Top-Down Enumeration for Program Synthesis Problems with Monotonic Semantics}},
  booktitle = {Proc. ACM Program. Lang},
  year = {2024},
  url = {https://openreview.net/forum?id=ooHXjG3F8J},
}
Figure