TL;DR
This paper tackles the challenge of synthesizing programs from non-linear real arithmetic (NRA) specifications that might be unrealizable (i.e., containing inputs for which no valid output exists). By restricting inputs and outputs to rational numbers to eliminate floating-point rounding errors, the authors present a novel synthesis framework (NQSynth) that either finds a valid output or correctly reports that none exists, significantly outperforming state-of-the-art syntax-guided synthesis (SyGuS) tools.
What Problem Does This Paper Address?
Automated program synthesis typically assumes a specification is realizable—meaning a valid output exists for every possible input. Standard Syntax-Guided Synthesis (SyGuS) tools fail completely if this assumption is broken. In practice, however, many natural specifications are unrealizable for certain inputs. For example, the specification $0.9 \le x^2 + y^2 \le 1$ has no real solution for the output $y$ if the input $x = 2$.
Ideally, a synthesized program should calculate a valid output when it exists and gracefully report "no output" ($\bot$) otherwise. Furthermore, executing these programs using standard floating-point arithmetic introduces dangerous rounding errors. The authors address both challenges by focusing on real program synthesis with rational inputs and outputs ($RPS_\mathbb{Q}$), ensuring zero rounding errors while handling unrealizable specifications.
Methods
The authors first establish that the general $RPS_\mathbb{Q}$ problem is exceptionally difficult: it is inter-reducible with Hilbert's tenth problem over rationals (a famous, long-standing open problem in number theory), meaning a universally complete algorithm for multiple outputs is currently impossible. They also prove that loop-free programs are fundamentally insufficient to solve the problem in general.
To make practical headway, they propose a two-pronged algorithmic approach based on a simple imperative grammar:
- Single-Output Specifications ($|Y|=1$): They design a sound and complete algorithm. It separates the problem into strict inequalities (solved via Real Root Isolation to find valid intervals where the polynomial sign is invariant) and non-strict boundaries (solved via the Rational Root Theorem to find precise rational roots).
- Multiple-Output Specifications ($|Y|>1$): They develop a sound but incomplete incremental algorithm. It uses an NRA solver (like Z3) to find an initial rational point, fixes all but one output variable, and uses the single-output method to synthesize a program branch. It then uses quantifier elimination (via QEPCAD) to find the weakest pre-condition for that branch, subtracts it from the specification, and repeats the process until no more rational solutions are found.
Datasets
The authors evaluated their prototype tool, NQSynth, on two distinct benchmark sets:
- NRA Benchmarks: 83 non-linear benchmarks adapted from the
meti-tarskiandzanklfamilies in the SMT-LIB 2024 QF_NRA suite. These were modified to ensure that non-linear constraints directly involved the designated output variables. - Geometric Benchmarks: 51 newly introduced specifications modeling 2D and 3D geometric problems (e.g., intersecting circles, annular regions, and spheres) with polynomial boundaries ranging up to degree-100.
Key Insights and Ideas
- The Rational Advantage: Restricting the domain to rational numbers isn't just about avoiding floating-point bugs; it unlocks powerful number-theoretic tools like the Rational Root Theorem and Real Root Isolation that allow exact boundary checks.
- Bypassing the Realizability Trap: Instead of forcing the user to manually compute complex weakest pre-conditions to make a specification realizable beforehand,
NQSynthbuilds the pre-condition checking directly into the synthesized program's control flow. - Partial Completeness: Even when the multiple-output algorithm times out, it still outputs a sound program that works perfectly for the subset of input spaces it managed to cover.
Key Results
NQSynth was compared against two baselines: an improvised SyGuS baseline (QEPCAD + CVC5) and a model-enumeration baseline (ModEnum), with a 120-second timeout.
- NRA Suite:
NQSynthsuccessfully solved 59 out of 83 benchmarks, compared to 26 for QEPCAD+CVC5 and 23 for ModEnum. - Geometric Suite:
NQSynthsolved 33 out of 51 benchmarks, while QEPCAD+CVC5 solved 16 and ModEnum solved 11. - Efficiency:
NQSynthachieved significantly lower PAR2 (Penalized Average Runtime) scores across both datasets (75.8 for NRA, 91.4 for Geometric) compared to the baselines, which all scored above 166.
Limitations and Future Work
- Quantifier Elimination Bottleneck: The primary performance bottleneck is the heavy reliance on QEPCAD for real quantifier elimination during the synthesis phase. When QEPCAD timed out,
NQSynthcould only generate a partially complete program. - Future Directions: The authors plan to explore alternative algebraic backends (like MAPLE or Mathematica) to optimize or replace the QEPCAD dependency. They also want to investigate theoretical criteria to determine exactly when a given non-linear specification can be successfully synthesized using only loop-free code.
Summary updated