---
title: 'S² Prover: A Second-Order SAT Solver'
url: https://www.emergentmind.com/topics/s-two-prover
type: topic
---

# S² Prover: A Second-Order SAT Solver

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” [1409.4925]. 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 $\mathbb{B}=\{0,1\}$ by formulas of the form
$$
\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 $S_i$ is a predicate of arity $k_i$, each $Q_j\in\{\exists,\forall\}$ ranges over $x_j\in\mathbb{B}$, and $\sigma$ is a quantifier-free propositional formula whose atoms may be $x_j$ or applications $S_i(t_1,\ldots,t_{k_i})$ with $t_j\in\{x_1,\ldots,x_n\}$ [1409.4925].

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
$$
\exists R:\mathbb{B}^2.\; \forall x,y\in\mathbb{B}.\; R(x,y)\rightarrow R(y,x)
$$
states that there exists a symmetric Boolean relation $R$. 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 $n$ first-order variables is NEXPTIME-complete [1409.4925]. The upper bound is obtained by interpreting the first-order fragment as a structure of size $|\mathbb{B}^n|=2^n$ 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 $n$ 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 $\Phi$ to a finite-state synthesis problem of the form
$$
\exists P.\;\forall x\in D.\; \hat{\sigma}(P,x),
$$
where $P$ is a loop-free program computing the candidate second-order functions, $D\cong\mathbb{B}^n$ is a finite domain, and $\hat{\sigma}$ checks that $P$ satisfies the original QBF-like constraint on all inputs [1409.4925].

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 $P_0$ is returned, verification has proved $\forall x.\hat{\sigma}(P_0,x)$. Second, it is semi-complete: if there exists some $P^*$ such that $\forall x.\hat{\sigma}(P^*,x)$, CEGIS eventually finds it, provided the search over programs is complete. Third, it terminates for UNSAT: since every total function $D\to D$ has a finite-size program encoding of length at most $2^{|x|}$, 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 $\ell$ in loop-free static single-assignment form, symbolic bounded-model checking using CBMC on the $C^-$ encoding of $\exists P.\bigwedge_{x\in\text{inputs}}\hat{\sigma}(P,x)$, and genetic programming with incremental evolution over the current test set [1409.4925].

The language $\mathcal{L}$ of candidate programs is parameterised by three quantities: $\ell$, the program length measured in number of instructions; $w$, the word width measured in bits per register; and $c$, the number of distinct constants allowed. The search traverses the lattice $(\ell,w,c)$ starting from $(1,4,0)$, increasing $c$ up to $\ell$, then increasing $\ell$, and, when verification fails on full-width $w$, trying smaller $w$ for constant generalisation or increasing $w$. This parameterisation gives the procedure an explicit mechanism for controlling search breadth while systematically enlarging the hypothesis space.

The background formalism is a $C^-$ encoding. The implementation uses a $C^-$ interpreter for $\mathcal{L}$, with $\hat{\sigma}(P,x)$ written in $C^-$ by invoking that interpreter on candidate $P$ and input $x$ and then asserting the original QBF-style constraints. Because $C^-$ 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 $O(\ell\cdot w)$ for each synthesis or verification check, and that this formula is solved by a SAT/SMT-BV solver.

The reported implementation size is approximately $20$ 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 [1409.4925]. Theorem 1, the universality of $\mathcal{L}$, states that every total function $D\to D$ with $|D|<\infty$ is computed by some loop-free $\mathcal{L}$-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 $\mathcal{L}$ encoding, states that no alternative encoding scheme can assign strictly shorter representations to all functions, and that $\mathcal{L}$’s $O(|D|\cdot\log |D|)$-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 $C^-$ 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 $P^*$ solving $\hat{\sigma}$ has size $K$, then the number of CEGIS iterations is at most $O(2^K)$. 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 ($n=29$), termination and non-termination from SVCOMP’15 ($n=78$), and QBF in simple and hard variants ($n=11$), with a timeout of $180$ seconds [1409.4925]. The reported aggregate result is that S² Prover solved $59$ of $113$ 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 $19.0$ LOC, the average solution length is $4.1$ instructions, and the average number of CEGIS iterations is $2.7$. For termination, the corresponding values are $93.5$ LOC, $5.7$ instructions, and $14.4$ iterations. For QBF (simple), they are $12.2$ LOC, $9.0$ instructions, and $1.0$ iteration; for QBF (hard), $5889.0$ LOC, $11.0$ instructions, and $2.0$ iterations.

The breakdown of solver wins in candidate and CEGIS phases is given as $46\%$ for explicit enumeration, $42\%$ for genetic programming, and $12\%$ for CBMC proof-of-correctness. Time-distribution is reported as $69\%$ synthesis and $31\%$ 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 $2^n$ 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 [1409.4925]. 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 [1505.03040]. “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 a synthesis-based solver for a decidable second-order propositional satisfiability problem.

Source: https://www.emergentmind.com/topics/s-two-prover