Efficient Synthesis with Probabilistic Constraints

Samuel Drews, Aws Albarghouthi, Loris D'Antoni

Abstract: We consider the problem of synthesizing a program given a probabilistic specification of its desired behavior. Specifically, we study the recent paradigm of distribution-guided inductive synthesis (DIGITS), which iteratively calls a synthesizer on finite sample sets from a given distribution. We make theoretical and algorithmic contributions: (i) We prove the surprising result that DIGITS only requires a polynomial number of synthesizer calls in the size of the sample set, despite its ostensibly exponential behavior. (ii) We present a property-directed version of DIGITS that further reduces the number of synthesizer calls, drastically improving synthesis performance on a range of benchmarks.

Introduction

Traditional program synthesis focuses on Boolean constraints: a program either satisfies a specification for all inputs or it fails. However, real-world systems—from autonomous vehicle controllers to data-processing algorithms—often require probabilistic specifications. For instance, a controller might need to maintain safety with 95% probability, or a classifier might need to ensure algorithmic fairness by treating different demographic groups similarly on average.

The Distribution-Guided Inductive Synthesis (DIGITS) framework addresses this by approximating a probability distribution with a finite set of samples. It then searches for a program that matches a desired output for those samples. Historically, this approach appeared to face an exponential "search explosion," as there are $2^m$ ways to assign binary labels to $m$ samples. This paper shatters that assumption with new theoretical bounds and an optimized search algorithm.

The DIGITS Framework

The core of the DIGITS approach is an iterative loop that samples from a distribution and queries an underlying synthesizer (like an SMT solver) to find programs matching specific labelings of those samples.

Algorithm 1: The naive DIGITS procedure for distribution-guided synthesis.

As shown in Algorithm 1, the naive approach iterates through possible labelings $f: S \to \{0, 1\}$. While this suggests an exponential number of calls to the synthesis oracle $\mathcal{O}_{\text{syn}}$, the authors demonstrate that the actual complexity is far lower.

Theoretical Breakthrough: The Polynomial Bound

A major contribution of this work is the proof that DIGITS requires only a polynomial number of synthesizer calls. By applying tools from computational learning theory—specifically the VC dimension of the program class and the Sauer-Shelah Lemma—the authors prove that the number of "meaningful" ways a program can label a set of samples is polynomial in the sample size $m$. This explains why DIGITS is effective in practice: the complexity is tied to the inherent complexity of the program "sketch" (template) rather than the raw number of samples.

Building on this theoretical insight, the authors introduce $\tau$-DIGITS, an optimized version that uses property-directed pruning to accelerate the search. In probabilistic synthesis, the goal is often to find a program that minimizes error relative to a target specification. By using the Hamming distance (the number of differing outputs) as a metric, the algorithm can prune branches of the search tree that deviate too far from the target.

Inference rules for the optimized $ au$-DIGITS algorithm, highlighting the 'unblocked' pruning condition.

The "unblocked" condition shown in the inference rules ensures that the search only explores labelings within a threshold $\tau$ of the target specification. The authors also developed an adaptive version of this thresholding that "zooms in" on the optimal solution as better programs are discovered.

Experimental Evaluation

The approach was evaluated across three benchmark suites: synthetic hyperrectangles, 18 algorithmic fairness benchmarks, and a thermostat controller simulation.

Key results include:

  • Increased Search Depth: Adaptive $\tau$-DIGITS achieved a 2.4× average increase in search depth (sample size) compared to the original framework within the same time limits.
  • Improved Accuracy: By processing more samples, the algorithm found programs with lower error rates in 10 out of 18 fairness benchmarks.
  • Convergence: The authors proved that while $\tau$-DIGITS prunes the search space, it remains exponentially unlikely to discard the optimal solution as the sample size grows.

Conclusion and Future Work

This work bridges the gap between PAC learning theory and SMT-based synthesis. While $\tau$-DIGITS significantly improves performance, challenges remain regarding deep loops, where SMT solvers struggle with the resulting large formulas. Future research may also extend this framework from probability thresholds to optimizing expected values, further broadening its applicability to control and reinforcement learning tasks.

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