TL;DR
Program synthesis tools often struggle to generate code requiring non-trivial "magic" constants without human-provided templates. This paper introduces CEGIS($\mathcal{T}$), a novel architecture that pairs a standard inductive synthesizer with a first-order theory solver to analytically deduce these constants. By automating constant discovery, it successfully synthesizes complex programs and loop invariants from scratch, solving nearly twice as many benchmark problems as state-of-the-art tools like CVC4.
The Problem: The Limits of Standard CEGIS
Program synthesis aims to automatically generate code from a logical specification. The standard approach is Counterexample-Guided Inductive Synthesis (CEGIS). In this loop, a synthesizer guesses a program, a verifier checks it, and if it fails, the verifier returns a concrete counterexample (e.g., "your program fails when $x=0$"). The synthesizer then uses this specific point to refine its next guess.
However, this loop fails when a solution requires a specific, large constant (e.g., if (x < 334455)). A standard synthesizer might blindly enumerate thousands of integers, guessing $x < 0$, then $x < 1$, and so on. To bypass this, modern tools rely on Syntax-Guided Synthesis (SyGuS), where a human provides a template containing the necessary constants. The authors of this paper aim to remove this reliance on human intuition and fully automate the discovery of complex constants.
The Solution: CEGIS($\mathcal{T}$)
Inspired by how DPLL($\mathcal{T}$) revolutionized SAT solving by combining Boolean logic with theory solvers, the authors propose CEGIS($\mathcal{T}$). This framework creates a sophisticated feedback loop between a synthesizer and a theory solver to handle the "magic numbers" analytically.
Instead of guessing exact programs, the synthesizer generates a candidate skeleton—a program structure where constants are replaced by symbolic variables or "holes" (e.g., f(x) = ite(x < v1) v2 v3). This skeleton is passed to a theory solver, which uses techniques like Fourier-Motzkin Variable Elimination or off-the-shelf SMT solvers (like Z3) to find valid assignments for the holes.
If valid constants exist for the skeleton, the problem is solved. If not, the theory solver returns a generalized constraint that permanently blocks that entire skeleton. This allows the system to prune massive swaths of the search space at once, rather than eliminating programs one-by-one based on single counterexamples.
Evaluation and Benchmarks
The authors evaluated CEGIS($\mathcal{T}$) on 80 bitvector benchmarks sourced from the SyGuS competition and C program invariant datasets. Crucially, the authors removed all syntactic templates (grammars) from these benchmarks. This forced the tools to synthesize constants entirely from scratch, a significantly harder task than standard SyGuS.
Key Results and Trade-offs
- Higher Success Rate: In a multi-core configuration, CEGIS($\mathcal{T}$) solved 57 out of 80 benchmarks, whereas the state-of-the-art tool CVC4 solved only 30.
- Dominance in Invariants: On the 48 invariant generation benchmarks—which rely heavily on arbitrary constants—CEGIS($\mathcal{T}$) solved 33, while CVC4 solved only 6.
- Speed vs. Generality: While CEGIS($\mathcal{T}$) solved more problems, CVC4 was faster on the problems it could solve (averaging 1.3 seconds vs. 34 seconds). CVC4 excels at long programs with many comparisons, while CEGIS($\mathcal{T}$) is optimized for finding the shortest possible program with the correct deduced constants.
Conclusion
CEGIS($\mathcal{T}$) shifts the burden of finding "magic numbers" from naive enumeration to optimized mathematical deduction. By separating the search for program structure from the search for constants, it enables the synthesis of complex logic without requiring human-designed templates. While it currently struggles with very long program structures, it represents a major step toward fully autonomous program synthesis.
Summary updated