Papers
Topics
Authors
Recent
Search
2000 character limit reached

S² Prover: A Second-Order SAT Solver

Updated 4 July 2026
  • S² Prover is a decision procedure for a decidable fragment of second-order logic (S²SAT) that formulates search as finite-state program synthesis.
  • It reduces S²SAT to program synthesis using a CEGIS loop, combining explicit enumeration, symbolic bounded-model checking, and genetic programming.
  • Empirical studies show effective solving of benchmarks in superoptimisation, termination, and QBF, while highlighting challenges in early UNSAT detection.

S² Prover is a decision procedure for the satisfiability problem of a decidable fragment of second-order logic called S²SAT, introduced in “Second-Order Propositional Satisfiability” (David et al., 2014). It is designed around the observation that static program analyses search for a second-order object—such as an invariant, countermodel, ranking function, or recurrence set—while traditional frameworks often conflate the search heuristic and the underlying SAT/SMT-based validation mechanism. S² Prover addresses this by reducing S²SAT to finite-state program synthesis and solving the resulting problem with Counterexample-Guided Inductive Synthesis (CEGIS), thereby separating problem description from search strategy.

1. Logical object: S²SAT

S²SAT is defined over the Boolean domain B={0,1}\mathbb{B}=\{0,1\} by formulas of the form

S1:Bk1,,Sm:Bkm.  Q1x1Qnxn.σ(S1,,Sm,x1,,xn),\exists S_1:\mathbb{B}^{k_1},\ldots,S_m:\mathbb{B}^{k_m}.\; Q_1 x_1 \ldots Q_n x_n.\,\sigma(S_1,\ldots,S_m,x_1,\ldots,x_n),

where each SiS_i is a predicate of arity kik_i, each Qj{,}Q_j\in\{\exists,\forall\} ranges over xjBx_j\in\mathbb{B}, and σ\sigma is a quantifier-free propositional formula whose atoms may be xjx_j or applications Si(t1,,tki)S_i(t_1,\ldots,t_{k_i}) with tj{x1,,xn}t_j\in\{x_1,\ldots,x_n\} (David et al., 2014).

The fragment is presented as expressive enough to capture numerous program analysis problems, including safety proving, bug finding, termination and non-termination proving, and superoptimisation. The example

S1:Bk1,,Sm:Bkm.  Q1x1Qnxn.σ(S1,,Sm,x1,,xn),\exists S_1:\mathbb{B}^{k_1},\ldots,S_m:\mathbb{B}^{k_m}.\; Q_1 x_1 \ldots Q_n x_n.\,\sigma(S_1,\ldots,S_m,x_1,\ldots,x_n),0

states that there exists a symmetric Boolean relation S1:Bk1,,Sm:Bkm.  Q1x1Qnxn.σ(S1,,Sm,x1,,xn),\exists S_1:\mathbb{B}^{k_1},\ldots,S_m:\mathbb{B}^{k_m}.\; Q_1 x_1 \ldots Q_n x_n.\,\sigma(S_1,\ldots,S_m,x_1,\ldots,x_n),1. In the intended program-analysis reading, the second-order existential block ranges over candidate proofs or witnesses, while the first-order quantification expresses the universal or existential conditions that those candidates must satisfy.

2. Complexity and expressive range

The central complexity result is that checking satisfiability of an S²SAT formula with S1:Bk1,,Sm:Bkm.  Q1x1Qnxn.σ(S1,,Sm,x1,,xn),\exists S_1:\mathbb{B}^{k_1},\ldots,S_m:\mathbb{B}^{k_m}.\; Q_1 x_1 \ldots Q_n x_n.\,\sigma(S_1,\ldots,S_m,x_1,\ldots,x_n),2 first-order variables is NEXPTIME-complete (David et al., 2014). The upper bound is obtained by interpreting the first-order fragment as a structure of size S1:Bk1,,Sm:Bkm.  Q1x1Qnxn.σ(S1,,Sm,x1,,xn),\exists S_1:\mathbb{B}^{k_1},\ldots,S_m:\mathbb{B}^{k_m}.\; Q_1 x_1 \ldots Q_n x_n.\,\sigma(S_1,\ldots,S_m,x_1,\ldots,x_n),3 and applying Fagin’s Theorem, under which existential second-order logic over finite structures captures exactly NEXPTIME. The lower bound is obtained by encoding the run of a nondeterministic exponential-time Turing machine on an input of length S1:Bk1,,Sm:Bkm.  Q1x1Qnxn.σ(S1,,Sm,x1,,xn),\exists S_1:\mathbb{B}^{k_1},\ldots,S_m:\mathbb{B}^{k_m}.\; Q_1 x_1 \ldots Q_n x_n.\,\sigma(S_1,\ldots,S_m,x_1,\ldots,x_n),4 as an S²SAT formula whose second-order variables encode the transition relation over configurations.

Within the paper’s framing, this complexity result justifies both the fragment’s generality and the need for a solver architecture that is not tied to a single first-order backend. The motivating claim is that traditional analyzers are monolithic because second-order solvers are scarce, whereas SAT/SMT technology is mature. S² Prover is positioned as an attempt to close that gap by providing a dedicated decision procedure for a second-order fragment while retaining a practical reduction path to propositional reasoning.

3. Reduction to finite-state program synthesis

The solver reduces every S²SAT instance S1:Bk1,,Sm:Bkm.  Q1x1Qnxn.σ(S1,,Sm,x1,,xn),\exists S_1:\mathbb{B}^{k_1},\ldots,S_m:\mathbb{B}^{k_m}.\; Q_1 x_1 \ldots Q_n x_n.\,\sigma(S_1,\ldots,S_m,x_1,\ldots,x_n),5 to a finite-state synthesis problem of the form

S1:Bk1,,Sm:Bkm.  Q1x1Qnxn.σ(S1,,Sm,x1,,xn),\exists S_1:\mathbb{B}^{k_1},\ldots,S_m:\mathbb{B}^{k_m}.\; Q_1 x_1 \ldots Q_n x_n.\,\sigma(S_1,\ldots,S_m,x_1,\ldots,x_n),6

where S1:Bk1,,Sm:Bkm.  Q1x1Qnxn.σ(S1,,Sm,x1,,xn),\exists S_1:\mathbb{B}^{k_1},\ldots,S_m:\mathbb{B}^{k_m}.\; Q_1 x_1 \ldots Q_n x_n.\,\sigma(S_1,\ldots,S_m,x_1,\ldots,x_n),7 is a loop-free program computing the candidate second-order functions, S1:Bk1,,Sm:Bkm.  Q1x1Qnxn.σ(S1,,Sm,x1,,xn),\exists S_1:\mathbb{B}^{k_1},\ldots,S_m:\mathbb{B}^{k_m}.\; Q_1 x_1 \ldots Q_n x_n.\,\sigma(S_1,\ldots,S_m,x_1,\ldots,x_n),8 is a finite domain, and S1:Bk1,,Sm:Bkm.  Q1x1Qnxn.σ(S1,,Sm,x1,,xn),\exists S_1:\mathbb{B}^{k_1},\ldots,S_m:\mathbb{B}^{k_m}.\; Q_1 x_1 \ldots Q_n x_n.\,\sigma(S_1,\ldots,S_m,x_1,\ldots,x_n),9 checks that SiS_i0 satisfies the original QBF-like constraint on all inputs (David et al., 2014).

The resulting synthesis problem is solved by a standard CEGIS refinement loop. The loop begins with an empty test set, synthesizes a candidate program consistent with the current test inputs, and then verifies that candidate by searching for a counterexample. If no such counterexample exists, the candidate is returned; otherwise, the counterexample is added to the test set and the process repeats. The paper states three key properties of this loop. First, it is sound: when a candidate SiS_i1 is returned, verification has proved SiS_i2. Second, it is semi-complete: if there exists some SiS_i3 such that SiS_i4, CEGIS eventually finds it, provided the search over programs is complete. Third, it terminates for UNSAT: since every total function SiS_i5 has a finite-size program encoding of length at most SiS_i6, the procedure can stop once the program-size bound exceeds this threshold and conclude UNSAT.

This reduction is the core abstraction behind S² Prover. It turns second-order search into finite-state program search, allowing the second-order unknowns to be represented as synthesized code rather than as uninterpreted relational objects.

4. Search architecture and implementation

S² Prover runs three candidate-generation strategies in parallel: explicit enumeration by increasing program length SiS_i7 in loop-free static single-assignment form, symbolic bounded-model checking using CBMC on the SiS_i8 encoding of SiS_i9, and genetic programming with incremental evolution over the current test set (David et al., 2014).

The language kik_i0 of candidate programs is parameterised by three quantities: kik_i1, the program length measured in number of instructions; kik_i2, the word width measured in bits per register; and kik_i3, the number of distinct constants allowed. The search traverses the lattice kik_i4 starting from kik_i5, increasing kik_i6 up to kik_i7, then increasing kik_i8, and, when verification fails on full-width kik_i9, trying smaller Qj{,}Q_j\in\{\exists,\forall\}0 for constant generalisation or increasing Qj{,}Q_j\in\{\exists,\forall\}1. This parameterisation gives the procedure an explicit mechanism for controlling search breadth while systematically enlarging the hypothesis space.

The background formalism is a Qj{,}Q_j\in\{\exists,\forall\}2 encoding. The implementation uses a Qj{,}Q_j\in\{\exists,\forall\}3 interpreter for Qj{,}Q_j\in\{\exists,\forall\}4, with Qj{,}Q_j\in\{\exists,\forall\}5 written in Qj{,}Q_j\in\{\exists,\forall\}6 by invoking that interpreter on candidate Qj{,}Q_j\in\{\exists,\forall\}7 and input Qj{,}Q_j\in\{\exists,\forall\}8 and then asserting the original QBF-style constraints. Because Qj{,}Q_j\in\{\exists,\forall\}9 is loop-free C with bounded loops and recursion, it is decidable via bounded model checking. The paper states that CBMC generates a propositional formula of size xjBx_j\in\mathbb{B}0 for each synthesis or verification check, and that this formula is solved by a SAT/SMT-BV solver.

The reported implementation size is approximately xjBx_j\in\mathbb{B}1 kLOC of OCaml plus a C/C++ harness. This implementation detail is significant because it situates S² Prover as a concrete system rather than only a reduction argument.

5. Formal guarantees

Several theoretical results are stated for the synthesis language and the overall solver construction (David et al., 2014). Theorem 1, the universality of xjBx_j\in\mathbb{B}2, states that every total function xjBx_j\in\mathbb{B}3 with xjBx_j\in\mathbb{B}4 is computed by some loop-free xjBx_j\in\mathbb{B}5-program. This is the basis for the claim that the reduction to finite-state synthesis does not lose expressiveness over finite domains.

Theorem 2, the optimality of the xjBx_j\in\mathbb{B}6 encoding, states that no alternative encoding scheme can assign strictly shorter representations to all functions, and that xjBx_j\in\mathbb{B}7’s xjBx_j\in\mathbb{B}8-bit encoding is asymptotically optimal. In the paper’s presentation, this gives an information-theoretic justification for the chosen representation of candidate solutions.

Theorem 3 states that CEGIS instantiated with xjBx_j\in\mathbb{B}9 background theory and the stopping criterion is a decision procedure for S²SAT. The paper also gives a proposition on Kolmogorov-bounded iterations: if the shortest program σ\sigma0 solving σ\sigma1 has size σ\sigma2, then the number of CEGIS iterations is at most σ\sigma3. This does not change the worst-case NEXPTIME classification, but it formalizes the dependence of the synthesis loop on proof length rather than only on input size. A plausible implication is that instances admitting short synthesized witnesses should be significantly easier than the ambient worst-case complexity suggests.

6. Empirical profile

The empirical evaluation uses three benchmark families: superoptimisation and deobfuscation (σ\sigma4), termination and non-termination from SVCOMP’15 (σ\sigma5), and QBF in simple and hard variants (σ\sigma6), with a timeout of σ\sigma7 seconds (David et al., 2014). The reported aggregate result is that S² Prover solved σ\sigma8 of σ\sigma9 benchmarks.

Category Solved / #bench Avg time (s)
Superoptimisation 22 / 29 7.9
Termination 33 / 78 11.8
QBF (simple) 4 / 4 1.8
QBF (hard) 1 / 7 1.5
Total/Overall 59 / 113 565.2

Additional per-category figures are also reported. For superoptimisation, the average specification size is xjx_j0 LOC, the average solution length is xjx_j1 instructions, and the average number of CEGIS iterations is xjx_j2. For termination, the corresponding values are xjx_j3 LOC, xjx_j4 instructions, and xjx_j5 iterations. For QBF (simple), they are xjx_j6 LOC, xjx_j7 instructions, and xjx_j8 iteration; for QBF (hard), xjx_j9 LOC, Si(t1,,tki)S_i(t_1,\ldots,t_{k_i})0 instructions, and Si(t1,,tki)S_i(t_1,\ldots,t_{k_i})1 iterations.

The breakdown of solver wins in candidate and CEGIS phases is given as Si(t1,,tki)S_i(t_1,\ldots,t_{k_i})2 for explicit enumeration, Si(t1,,tki)S_i(t_1,\ldots,t_{k_i})3 for genetic programming, and Si(t1,,tki)S_i(t_1,\ldots,t_{k_i})4 for CBMC proof-of-correctness. Time-distribution is reported as Si(t1,,tki)S_i(t_1,\ldots,t_{k_i})5 synthesis and Si(t1,,tki)S_i(t_1,\ldots,t_{k_i})6 verification. The accompanying discussion states that many real-world analysis tasks admit short second-order proofs, so CEGIS finds them quickly, whereas unsatisfiable instances, such as wrong-property termination queries, incur complete search up to the Si(t1,,tki)S_i(t_1,\ldots,t_{k_i})7 bound. Early UNSAT detection is identified as an open challenge.

7. Scope, future directions, and terminological distinction

The conclusion identifies four future directions: automated proof-length generalisation to detect UNSAT earlier, integration with abstract interpretation and interpolation for combined first-order and second-order reasoning, domain-specific search-space heuristics, and extension to richer background theories such as algebraic datatypes (David et al., 2014). These directions are consistent with the paper’s broader claim that S² Prover separates problem description from search strategy and thereby paves the way for modular second-order analysis engines.

The notation “S²” in S² Prover refers to “Second-Order” in S²SAT, not to a two-prover interactive setting. This distinction matters because adjacent literature uses superficially similar language for a different research area. “Multi-Prover Commitments Against Non-Signaling Attacks” studies two-prover and three-prover commitment schemes under classical, quantum, and non-signaling attack models, including an impossibility result for perfectly hiding single-round two-prover commitments and a positive three-prover construction (Fehr et al., 2015). “Oracularization and Two-Prover One-Round Interactive Proofs against Nonlocal Strategies” studies two-prover one-round games, oracularization, and soundness against entangled, commuting-operator, and no-signaling strategies (0810.0693). S² Prover is not a prover in that interactive-proof sense; it is an overview-based solver for a decidable second-order propositional satisfiability problem.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to S-two Prover.