Languages & Software / PAPER 09

Programs from Counterexamples: Synthesis, Specifications, and Oracle Limits

A synthesis result is only as strong as its grammar, semantics and verification oracle.

الاستشهاد بالمقال

النص الأصلي باللغة الإنجليزية. ترجمات هذه المراجعة الجديدة غير متاحة بعد.

Abstract

Program synthesis is often described as generating an implementation from examples or counterexamples, but the force of its result depends on the candidate language, semantics, and oracle. This analytical review uses six primary sources on syntax-guided synthesis, finite sketching, oracle-guided learning, SyGuS, and semantics-guided verification to separate search progress from justified correctness. The central argument is that a generated program should carry a contract identifying its grammar, input domain, specification, verification scope, and unresolved assumptions. Two reproducible finite models illustrate the distinction. Active queries identify threshold functions with fewer queries than sequential testing for many targets, while an exact decision-tree recurrence establishes the worst-case bound. A separate maximum-function experiment shows that exhaustive satisfaction of weak lower-bound constraints still admits unintended programs. These results are constructed enumerations, not measurements of a synthesis engine or language model. The manuscript proposes an evaluation protocol that includes unrealizable, inconsistent, and underconstrained problems, preserves timeout status, and separates candidate generation from validation. It also identifies limits arising from custom semantics, finite bounds, hidden oracle state, and the gap between a formal contract and user intent.

In this paper
  1. The promise is conditional on a specification
  2. Finite completeness has a finite boundary
  3. Examples and equivalence queries are different resources
  4. An interchange format does not settle intent
  5. Custom semantics enlarges the trusted argument
  6. Verification has its own expressive limits
  7. A finite version-space contract
  8. Threshold identification as a worked example
  9. A perfect solver can satisfy the wrong problem
  10. A reproducible evaluation beyond pass rates
  11. What the models leave unresolved
  12. From generated program to justified result

The promise is conditional on a specification

A synthesizer returns a program only after a collection of choices has defined what counts as success. The grammar determines which implementations are candidates, the semantics determines what those candidates mean, and the specification determines which behaviors are acceptable. A counterexample can improve the search while leaving an incorrect specification untouched. The central question is therefore not whether generated code passes some tests, but which statement the oracle was capable of establishing.

Alur and colleagues formulate syntax-guided synthesis using a background theory, a logical correctness specification, and a grammar of candidate expressions. Their paper also presents variants of counterexample-guided inductive synthesis. This separation supplies the framework for our analysis. We argue that synthesis results should carry a compact contract recording the candidate language, input domain, oracle semantics, and termination status. Two finite constructed models make the need concrete: active queries identify a threshold efficiently, while a deliberately incomplete specification admits programs that violate an unstated requirement. These examples are not measurements of an SMT solver or a code-generation model. They are exact enumerations that isolate information supplied by examples from information supplied by the specification. The distinction becomes especially important when a powerful search procedure makes a weak contract look convincingly solved.

Sources [1]

Finite completeness has a finite boundary

The original combinatorial sketching paper defines a partial implementation with holes and a separate specification, using combinatorial search to complete finite programs. Its stated completeness claim is scoped to that finite class. The inspected introduction identifies bounded inputs and bounded terminating computation as central conditions. It does not establish a decision procedure for arbitrary programs with unbounded behavior.

In an engineering use, a bit width, array bound, loop-unrolling bound, or grammar-depth bound is part of the result rather than an incidental solver option. A program correct for eight-bit modular arithmetic may fail as an integer algorithm, and a bounded loop may hide a failure that appears only after the bound. Conversely, rejecting a bounded synthesis result because it is not universally unbounded would miss a valuable assurance when the real deployment is finite. The right question is whether the finite model matches the operational domain. A report should distinguish semantic bounds required by the application from search bounds imposed for convenience. If the search exhausts a grammar of depth five, it can establish unrealizability within that grammar; it cannot establish that no implementation exists in a richer language. This scope discipline allows completeness claims to remain useful without expanding beyond what their quantifiers actually cover.

Sources [2]

Examples and equivalence queries are different resources

Jha and colleagues study component-based synthesis guided by an input/output oracle. Their introduction describes choosing inputs that distinguish remaining candidates and using a validation oracle to address whether the available components suffice. An oracle returning an output for one chosen input has a different informational role from an oracle deciding whether a candidate is correct on the whole domain. These capabilities should not be conflated under the label testing.

Suppose two candidates agree on every observed input. An additional arbitrary test may add no information, while a distinguishing input can eliminate at least one candidate. Yet even perfect discrimination within the current candidate class cannot establish that the true desired behavior belongs to that class. A learner may converge to a unique wrong abstraction if the oracle is incomplete or the environment has unmodeled state. The appropriate record includes the queries, their answers, the surviving hypotheses, and the final validation scope. This makes the evidence inspectable without exposing any private model reasoning. It also helps diagnose failure: inconsistent answers point toward the oracle or its environment; an empty version space points toward an inadequate grammar, inconsistent examples, or a mistaken semantics; a timeout leaves the question unresolved. These outcomes require different engineering responses and should remain distinct in an API.

Sources [3]

An interchange format does not settle intent

The official SyGuS language page describes version 2.1 as extending the input format with oracle specifications, weighted synthesis, tables, and constrained Horn-clause support. Its example specifies a maximum function with both lower-bound constraints and a condition that the result equals one of the inputs. That final constraint is particularly instructive: being at least both inputs does not alone characterize their maximum.

A standard format makes a problem portable and syntactically checkable, but it cannot tell whether the written constraints express the user's intention. In a build pipeline, the specification should therefore be reviewed as a first-class artifact with a version and provenance. A successful solver result should bind the exact specification bytes, grammar, theory, and options. If any of those change, an older proof or test receipt should not silently authorize the new program. We treat this as an assurance design derived from the source's separation of syntax and constraints, not as a feature promised by every SyGuS implementation. The specification reviewer should actively search for cheap but unintended solutions. Constants, always-true predicates, oversized outputs, and behaviors outside the training domain are useful probes. Finding such a program is evidence that the contract is too weak, even if the synthesis engine has behaved perfectly.

Sources [4]

Custom semantics enlarges the trusted argument

Semantics-Guided Synthesis allows the problem author to provide both syntax and semantics, including recursively defined big-step semantics. The inspected author abstract discusses imperative languages with unbounded loops and an encoding through constrained Horn clauses that can support synthesis and unrealizability reasoning. We do not interpret this as a universal termination guarantee for every possible SemGuS problem.

Custom semantics is powerful because it can describe a domain-specific language precisely, but the semantic definition becomes part of the trusted argument. If an integer operation is modeled without overflow while the emitted program uses fixed-width arithmetic, a valid synthesis result may not transfer. If a loop semantics describes only terminating runs, a safety specification may be satisfied while termination remains open. The solution is not necessarily to forbid custom semantics; it is to relate that semantics to the execution environment with a separate adequacy argument. Differential interpreters, translation validation, and small exhaustive cases can provide complementary evidence. The review should also distinguish a proof about the formal candidate from a proof about the compiler that produces the executable. Synthesis can close one gap while leaving another untouched. The more customizable the framework becomes, the more explicit these translation and semantic boundaries need to be in the delivered result.

Sources [5]

Verification has its own expressive limits

Murphy and colleagues analyze verification of SemGuS solutions through reductions to a fixed-point logic and identify distinctions among first-order, constrained-Horn, co-constrained-Horn, and more general cases. The inspected version-two abstract also discusses expressiveness limitations and a modification of the framework. This supports a narrow but consequential point: verifying a proposed solution is itself a structured problem whose difficulty and expressiveness depend on the chosen semantics.

A synthesis interface should accordingly preserve at least four outcomes: a verified candidate, a counterexample, established unrealizability within a declared class, and unresolved search or verification. Returning a best-effort candidate after a timeout can be useful, but it must not carry the same status as a verified result. A verification result may also be conditional on assumptions that the deployed caller must enforce. For example, a function proved correct only for nonnegative inputs requires that precondition at the actual interface, not merely in a hidden test generator. Our finite experiments use exhaustive oracles so their outcomes are decidable and reproducible. That convenience is part of their scope, not evidence that industrial synthesis shares the same ease. The experimental protocol below explicitly records unresolved cases so stronger problem formulations cannot appear worse merely because their failures are reported honestly.

Sources [6]

A finite version-space contract

Let the candidate class be a finite set of programs, and retain those consistent with all queried examples. Each new example intersects the current version space with a constraint. A sound deterministic oracle never eliminates the true candidate when that candidate is present and the examples use the same semantics. This observation yields a simple audit trail: after every query, the retained set should shrink or remain unchanged, and the eventual candidate should satisfy every recorded answer.

There are several ways this invariant can fail in practice. The oracle may depend on time, hidden state, locale, or an external service. The candidate evaluator may use a different arithmetic convention. An optimization may reuse an equivalence class formed on old examples after a new counterexample distinguishes its members. These failures are not repaired by asking for more code samples unless the inconsistency is first understood. The accompanying model stores explicit finite candidate sets, making each elimination inspectable. It checks all target thresholds, not only a favorable one. This is a deliberately small laboratory for reasoning about information gain. Its lesson is that search progress can be measured by eliminated alternatives, but progress within an inadequate hypothesis class is not progress toward an unstated external requirement. A final validation step must therefore name both its domain and its relation to the real task.

Threshold identification as a worked example

The first model contains seventeen hypotheses indexed by thresholds zero through sixteen. Inputs are integers zero through fifteen, and a hypothesis returns one exactly when the input is at least its threshold. Thus the endpoint hypotheses are the constant-one and constant-zero functions. An active strategy chooses an input that minimizes the larger of the two possible surviving partitions, breaking ties by the smallest input. A sequential strategy queries inputs in increasing order and stops when only one hypothesis remains.

For target threshold eleven, the active strategy uses four queries, whereas the sequential strategy uses twelve. The active version-space sizes are seventeen, nine, four, two, and one. These counts follow from exhaustive evaluation of candidate answers; they are not solver timings. The first figure compares query counts for every possible target threshold, exposing both favorable and unfavorable positions for sequential querying. The supplement verifies that each strategy recovers every target and that its candidate sets never discard the target. It also independently computes the optimal worst-case decision-tree depth by recurrence, giving five queries for seventeen ordered thresholds. This check prevents the appealing four-query worked example from being mistaken for a universal four-query guarantee. Query quality matters, but the information-theoretic boundary remains visible.

A perfect solver can satisfy the wrong problem

The second model uses ordered pairs of integers from zero through seven and candidates that return the mathematical maximum plus an offset. Offsets range from zero through four. Under the weak specification that the result be at least each input, every candidate passes on all sixty-four input pairs. Under the strengthened specification that the result also equal one of the inputs, only offset zero passes. A candidate adding one is therefore an exhaustive counterexample to the claim that the weak constraints characterize maximum, even though it satisfies those constraints perfectly.

The second figure plots weak and strong passing-case counts for the five offsets. The true maximum has sixty-four passes under both contracts; positive offsets have sixty-four weak passes and zero strong passes. The model uses unbounded mathematical integers, so no overflow complicates this example. A fixed-width version would need a separate arithmetic specification. The general lesson is that more exhaustive testing against the same incomplete oracle cannot discover an unstated requirement. A reviewer must ask what behaviors remain permitted, not merely how thoroughly the permitted behaviors were checked. This is also why human preference feedback and formal constraints serve different roles: one may help articulate the intended contract, while the other checks a precise contract once chosen. Neither role should be silently presented as the other.

A reproducible evaluation beyond pass rates

A proposed evaluation should publish the specification, candidate grammar, semantics, input bounds, and cost objective before comparing synthesis strategies. For each run, record every query and answer, candidate size, solver status, verification status, and elapsed resources. Separate time spent finding a candidate from time spent validating it. A fast generator paired with expensive verification may still be useful, but a combined success rate obscures which stage limits the process.

The benchmark suite should contain satisfiable, unrealizable, underconstrained, and inconsistent problems. Include deliberate specification mutants, such as removing the maximum selector constraint, so the review process is tested rather than only the search engine. Use a second evaluator for finite domains and translation validation for emitted code where feasible. Report search bounds and timeouts as outcomes; do not relabel exhausted resources as proof of unrealizability. To study query selection, hold the candidate class fixed and compare active, sequential, and reproducibly randomized strategies across all finite targets. To study generalization, reserve specification families or semantic features rather than merely withholding a few inputs from a familiar finite table. This protocol has not been run on a production synthesizer here. The delivered supplement checks the finite examples and the exact arithmetic claims on which the analytical argument depends.

What the models leave unresolved

Thresholds form a highly structured class with binary outputs and cheap evaluation. Real program grammars can contain many syntactically different but semantically equivalent expressions, while distinguishing two candidates may itself require difficult theorem proving. A reduction in query count therefore need not reduce wall-clock cost. The best query can be expensive to compute, expensive for a human to answer, or awkward to express in the actual interface. Cost-sensitive querying needs a model of these resources rather than a pure count.

The maximum example likewise isolates specification weakness but omits state, exceptions, concurrency, effects, and resource bounds. A function can compute the correct answer while leaking a secret through timing or exhausting memory on a permitted input. Those requirements must enter the specification or a separate assurance layer. Language-model proposals can be valuable candidates, yet their plausibility does not strengthen the verification oracle. Conversely, a solver certificate does not establish that the specification reflects legitimate user intent. These boundaries motivate a layered acceptance record: candidate provenance, exact contract, verification evidence, unresolved assumptions, and deployment preconditions. Such a record makes uncertainty actionable without demanding that every useful synthesis task become a universal formal-verification project. The claim can remain narrow, provided the narrowness is explicit and preserved when the program is reused.

From generated program to justified result

Counterexamples are valuable because they turn failure into information, but their authority comes from the oracle that produced them. A synthesis loop can eliminate candidates, prove a bounded property, or establish unrealizability in a grammar only under the stated semantics and assumptions. It cannot derive missing user intent from the fact that its current tests pass. The distinction is visible even in a seventeen-hypothesis threshold problem and a five-candidate maximum problem, where every computation can be inspected directly.

The practical conclusion is to deliver the program together with the contract and evidence that justify its status. A verified finite solution should retain its bounds; a heuristic candidate should retain its unresolved status; an unrealizability result should retain its grammar; and a counterexample should retain the precise failed requirement. This discipline makes stronger synthesis methods easier to compare because it prevents weak contracts from masquerading as superior solvers. The next substantive research question is how to help users repair specifications while preserving a clear distinction between proposing a requirement and proving it. A system that exposes unintended but satisfying programs may contribute as much to trustworthy automation as one that searches faster. The goal is not merely to produce code from examples, but to make clear what the examples, semantics, and oracle have actually established about that code.

Mathematical model

∃p∈G  ∀x∈X: φ(p,x)\exists p\in\mathcal{G}\;\forall x\in X:\ \varphi(p,x)

(1) G is the allowed candidate class, X the specified domain, and phi the correctness relation. Bounds and semantics are part of the statement.

Vt+1={p∈Vt∣p(xt)=yt}V_{t+1}=\{p\in V_t\mid p(x_t)=y_t\}

(2) Finite version-space update under a deterministic I/O oracle with consistent semantics.

x∗=arg⁡min⁡xmax⁡y∣{p∈Vt:p(x)=y}∣x^*=\arg\min_x\max_y|\{p\in V_t:p(x)=y\}|

(3) Balanced-query heuristic used in the finite threshold model; smallest x breaks ties. Query-generation cost is omitted.

d(n)=1+min⁡1≤k<nmax⁡(d(k),d(n−k)),d(1)=0d(n)=1+\min_{1\le k<n}\max(d(k),d(n-k)),\quad d(1)=0

(4) Exact worst-case binary decision-tree recurrence for n ordered threshold hypotheses.

max⁡(x,y)+c≥x,y(c≥0)\max(x,y)+c\ge x,y\quad(c\ge0)

(5) Weak lower-bound constraints admit all nonnegative offsets; requiring output in {x,y} selects c=0 over the modeled domain.

Reproducible analytical figures

Queries required to identify each threshold: Seventeen exact hypotheses; target 11 needs 4 versus 12 queries. Worst-case active depth is 5.
Figure 1. Seventeen exact hypotheses; target 11 needs 4 versus 12 queries. Worst-case active depth is 5.

Assumptions: Deterministic exact I/O oracle; Cheap finite candidate evaluation; No query-generation cost

CSV data · Vector figure

An incomplete maximum specification admits unintended offsets: Every nonnegative offset satisfies the weak specification; only offset zero equals one input on the modeled domain.
Figure 2. Every nonnegative offset satisfies the weak specification; only offset zero equals one input on the modeled domain.

Assumptions: x,y in 0..7; Mathematical integer arithmetic; Candidate family max(x,y)+c

CSV data · Vector figure

Executed finite checks

6 check groups passed. The listed cases validate this model; they are not independent experiments or system benchmarks.

  • Both query strategies identify every finite target · 17 cases. All 17 thresholds over inputs 0..15, including constant endpoint hypotheses.
  • Version spaces shrink and retain the target · 34 cases. Target preservation asserted at every update; each query strictly reduces this class.
  • Decision-tree recurrence equals logarithmic lower bound · 64 cases. Dynamic recurrence independently considers every ordered split.
  • Balanced strategy meets optimal worst case · 17 cases. The worked target needs four queries, but worst case is five.
  • Weak maximum specification permits every offset · 320 cases. Exhaustive 64 input pairs for each of five offsets; mathematical integers.
  • Worked example query counts · 1 cases. Target threshold 11; ties resolved by smallest input.

Comparison

ResultRequired scopeNot established
Example consistencyRecorded input/output pairsUniversal correctness
Verified candidateExact semantics and domainCorrect user intent
UnrealizableDeclared grammar and specificationNo program exists in any language
TimeoutResource and search limitsFalsehood of the specification

Proposed validation protocol

  • Version the grammar, theory, semantics and exact specification.
  • Distinguish application bounds from search bounds.
  • Record every oracle query and answer.
  • Check oracle determinism and evaluation consistency.
  • Separate candidate-generation time from verification time.
  • Include satisfiable, unrealizable, inconsistent and weak specifications.
  • Retain deliberately satisfying but unintended candidates for review.
  • Use an independent finite evaluator where exhaustive checking is feasible.
  • Preserve unknown and timeout results without converting them to proofs.
  • Bind emitted code to validation evidence and deployment preconditions.

Limitations

  • Threshold hypotheses are unusually structured and cheaply evaluated.
  • Query counts omit solver and human-answer cost.
  • The maximum model uses mathematical integers, not fixed-width arithmetic.
  • No synthesis engine or language-model benchmark was measured.
  • Custom semantic adequacy and compiler correctness are outside the finite checks.
  • Source theorem claims are reported with inspected-scope limits.

Open research questions

  • How should query cost combine information gain, solver effort and human answerability?
  • Can specification review systematically expose unintended satisfying programs?
  • Which acceptance record best preserves bounds and unresolved assumptions when synthesized code is reused?

Evidence and its boundaries

[1] SyGuS separates background theory, semantic specification and candidate grammar.
Does not guarantee intended requirements were written correctly. Inspected: Abstract and section II.
[2] Combinatorial sketching states completeness for finite programs.
Not a universal result for unbounded programs. Inspected: Abstract and introduction.
[3] I/O and validation oracles serve different roles in component synthesis.
A unique candidate need not capture an external unstated requirement. Inspected: Introduction.
[4] SyGuS 2.1 adds oracle and weighted-synthesis features; the maximum example includes a selector constraint.
Interchange syntax does not settle user intent. Inspected: Official language page and linked 2.1 specification.
[5] SemGuS permits user-defined syntax and semantics.
No general termination or semantic-adequacy claim inferred. Inspected: Version-2 abstract.
[6] SemGuS solution verification has distinct logical reductions and expressive limits.
Detailed proofs and solver evaluation not independently repeated. Inspected: Version-2 abstract.

References

  1. Syntax-Guided Synthesis
    Rajeev Alur, Rastislav Bodik, Garvit Juniwal, Milo M. K. Martin, Mukund Raghothaman, Sanjit A. Seshia, Rishabh Singh, Armando Solar-Lezama, Emina Torlak, Abhishek Udupa. FMCAD (2013). https://www.cis.upenn.edu/~alur/SyGuS13.pdf
    Source access and scope

    Abstract, introduction and problem formulation; selected CEGIS architecture text.

  2. Combinatorial Sketching for Finite Programs
    Armando Solar-Lezama, Liviu Tancau, Rastislav Bodik, Vijay Saraswat, Sanjit Seshia. ASPLOS (2006). https://people.eecs.berkeley.edu/~sseshia/pubdir/asplos06-final.pdf
    Source access and scope

    Abstract and finite-program scope in introduction; original author PDF order used.

  3. Oracle-Guided Component-Based Program Synthesis
    Susmit Jha, Sumit Gulwani, Sanjit A. Seshia, Ashish Tiwari. ICSE (2010). https://www.csl.sri.com/users/tiwari/papers/icse2010.pdf
    Source access and scope

    Abstract and introduction distinguishing I/O and validation oracles.

  4. The SyGuS Language Standard Version 2.1
    Saswat Padhi, Elizabeth Polgreen, Mukund Raghothaman, Andrew Reynolds, Abhishek Udupa. SyGuS language specification (2021). https://sygus-org.github.io/assets/pdf/SyGuS-IF_2.1.pdf
    Source access and scope

    Official landing page; PDF title page (15 August 2021), section 1 formulation and version differences; oracle/weighted-synthesis feature description.

  5. Semantics-Guided Synthesis
    Jinwoo Kim, Qinheping Hu, Loris D'Antoni, Thomas Reps. arXiv, version 2 (2020). https://arxiv.org/abs/2008.09836
    DOI: 10.48550/arXiv.2008.09836
    Source access and scope

    Abstract and version/publication metadata; theorem proof not reconstructed.

  6. Verifying Solutions to Semantics-Guided Synthesis Problems
    Charlie Murphy, Keith Johnson, Thomas Reps, Loris D'Antoni. arXiv, version 2 (2025). https://arxiv.org/abs/2408.15475
    DOI: 10.48550/arXiv.2408.15475
    Source access and scope

    Version-2 abstract and update history; no solver experiments reproduced.

Commissioned research review · v1. Cite this review · Original source record · Publication record