Programmable Program Synthesis

Loris D'Antoni, Qinheping Hu, Jinwoo Kim, Thomas W. Reps

TL;DR

Program synthesis is transitioning from a research curiosity to an industrial reality, yet it remains "unprogrammable" for most engineers. This paper introduces SemGuS (Semantics-Guided Synthesis), a framework that uses logic to decouple a program's syntax and semantics from the underlying solver, aiming to become the "yacc" of the synthesis world.

The Usability Gap in Program Synthesis

Modern program synthesis faces a significant usability hurdle. Currently, developers attempting to automate code transformations encounter three primary obstacles:

  1. Domain Specificity: Most tools are "one-trick ponies" designed for narrow tasks (e.g., string manipulation) and struggle with general constructs like loops.
  2. Solver Coupling: Synthesis problems are often hard-coded into specific solver formats. If one solver fails, swapping it for another requires a complete rewrite of the problem specification.
  3. Lack of Intent: Synthesizers often return bloated, unreadable code that passes tests but ignores user preferences, such as code brevity or operator restrictions.
Current synthesis landscape: Problems are often tightly coupled to non-interchangeable solvers.

The paper addresses these issues by asking: Can we make synthesis more programmable, domain-agnostic, and solver-agnostic?

SemGuS: A Programmable Framework

The core contribution is SemGuS, a framework that formalizes synthesis as a search over a grammar equipped with formal semantics. Unlike previous frameworks like SyGuS, which rely on fixed background operations, SemGuS allows users to define custom language behavior using Constrained Horn Clauses (CHCs).

The SemGuS vision: A programmable synthesis framework that decouples problem specification from interchangeable solvers.

Key Methodologies

  • Semantics as Logic: By using CHCs, users can formally describe complex constructs like while loops or custom DSL operators through logical implications.
  • Weighted Grammars: To address the "lack of intent," the authors introduce weights on production rules. This allows users to "tax" specific operations, guiding the solver toward more elegant or efficient solutions.
  • Meta-Algorithms and Unrealizability: The framework supports "meta-solvers" that can iteratively refine grammars or prove "unrealizability"—formally demonstrating that no program in the given grammar satisfies the requirements, which serves as a vital sanity check for developers.

Key Insights

The "aha moment" of SemGuS is the realization that semantics do not have to be hard-coded. By treating behavior as an input via CHCs, the tool becomes truly domain-agnostic. This mirrors the impact of yacc on parsing: by separating the search space (syntax/semantics) from the search strategy (the solver), synthesis becomes a programmable utility rather than a specialized black box.

Results and Future Outlook

The authors demonstrate that SemGuS can model complex imperative programs and non-standard semantics (like Kleene stars in regular expressions) that were previously inaccessible to logic-based frameworks. Through weighted grammars, the framework successfully synthesized "ideal" solutions—such as a concise 7-line program—where standard tools produced redundant, bloated code.

While general-purpose CHC solvers currently face a "performance tax" compared to hand-tuned synthesizers, the SemGuS framework provides a path toward solver interoperability. Future work focuses on community standardization and developing sophisticated "compilers" to translate high-level SemGuS logic into the specialized input languages of existing engines like Sketch or Rosette.

Summary updated

BibTeX
@inproceedings{dantoni2021programmable,
  author = {Loris D'Antoni and Qinheping Hu and Jinwoo Kim and Thomas W. Reps},
  title = {{Programmable Program Synthesis}},
  booktitle = {CAV},
  year = {2021},
  doi = {10.1007/978-3-030-81685-8\_4},
}
Figure