Efficient Synthesis with Probabilistic Constraints

Samuel Drews, Aws Albarghouthi, Loris D'Antoni

Abstract

Probabilistic program synthesis often faces an exponential search space when checking specifications against input distributions. This paper provides a theoretical proof that the DIGITS algorithm for probabilistic program synthesis is polynomial—not exponential—in the number of samples used. We further introduce $\tau$-DIGITS, a property-directed optimization that uses Hamming distance to prune the search space, enabling significantly faster synthesis for complex tasks like algorithmic fairness and robotic controllers.

Introduction

Traditional program synthesis (like "FlashFill" in Excel) usually deals with Boolean constraints: "The program must produce output $Y$ for input $X$." However, many modern applications require probabilistic constraints. For example, a fair decision-making AI should return "True" for Group A as often as it does for Group B, or a thermostat controller should keep the room temperature safe with 99% probability.

The challenge is that probabilistic specifications are hard to "check" during synthesis. A recent framework called DIGITS (Distribution-Guided Inductive Synthesis) tries to solve this by sampling the input distribution and searching for programs that match specific output patterns on those samples. On the surface, this search looks exponential: if you have $m$ samples, there are $2^m$ possible ways to label them.

Methods: Trie-Based Search and $\tau$-Pruning

The authors refine and analyze the DIGITS framework, which uses a "synthesize-then-verify" loop.

Instead of brute-forcing all $2^m$ labelings, DIGITS uses a trie (prefix tree) to incrementally explore labelings. If a partial labeling cannot be satisfied by any program in the search space, the entire branch of the trie is pruned.

Incremental trie construction for sample sets of increasing size.

$\tau$-DIGITS and Hamming Distance

The authors introduce a "property-directed" optimization called $\tau$-DIGITS. They realize that we usually want a program that is "close" to some functional specification (a target behavior). $\tau$-DIGITS prunes the trie by skipping any labeling that differs from the target behavior by more than a threshold $\tau$ (measured by Hamming distance).

Since the optimal $\tau$ is not known upfront, the algorithm uses Adaptive Thresholding. It starts with a loose threshold and "tightens" it every time it finds a better program, ensuring the search focuses only on programs that have a chance of being better than the current best.

Theoretical Insights: The Sauer-Shelah Lemma

The most significant contribution is proving that DIGITS is $O(m^{d+1})$, where $m$ is the number of samples and $d$ is the VC Dimension of the program class. By invoking the Sauer-Shelah Lemma from computational learning theory, the authors show that the number of "realizable" ways a program can label samples is strictly limited. This transforms a seemingly exponential problem into a polynomial one. The paper reinforces that the complexity of synthesis isn't just about the number of lines of code, but about the "expressiveness" (VC dimension) of the program sketch being used.

Key Results

The approach was evaluated on synthetic hyperrectangles, fairness repair for machine-learned models, and thermostat controller synthesis.

  • Speed and Depth: Adaptive $\tau$-DIGITS reached significantly greater search depths (larger sample sets) than the original DIGITS. On fairness benchmarks, it achieved a 2.4x average increase in depth within the same time limit.
  • Better Solutions: In the fairness repair benchmarks, the adaptive approach found strictly better solutions (lower error) in 10 out of 18 cases.
  • Controller Synthesis: The tool successfully synthesized parameters for a thermostat controller. It found that for lenient safety constraints, the adaptive pruning was so effective it could skip almost the entire search space after finding an initial good solution.

Limitations and Future Work

While the number of synthesizer calls is now polynomially bounded, each individual call to an SMT solver (like Z3 or CVC4) can still be very expensive. For the thermostat benchmarks, as the loop unrolling increased, the SMT solver became the primary bottleneck. Additionally, the verification step relies on statistical sampling (Hoeffding’s inequality), meaning correctness is probabilistic. Future work may explore extensions to programs with unbounded recursion or more complex dynamic data structures where VC dimension is harder to bound.

Summary updated

BibTeX
@inproceedings{drews2019efficient,
  author = {Samuel Drews and Aws Albarghouthi and Loris D'Antoni},
  title = {{Efficient Synthesis with Probabilistic Constraints}},
  booktitle = {CAV},
  year = {2019},
  doi = {10.1007/978-3-030-25540-4\_15},
}
Figure