Abstract This paper presents a novel approach to program verification by framing the discovery of Craig interpolants as a binary classification problem. By leveraging Support Vector Machines (SVMs), the authors develop a data-driven method for finding program invariants. This approach overcomes limitations of traditional symbolic solvers, particularly in handling non-linear arithmetic and generating generalizable predicates. Experimental results demonstrate that the SVM-based approach is efficient and robust, successfully finding invariants where traditional tools fail.
1. Introduction
In formal program verification, discovering loop invariants—properties that remain true throughout a loop's execution—is a critical challenge. A common technique for invariant discovery is Craig interpolation. Given two sets of logic formulas, $A$ (representing reachable states) and $B$ (representing error states), an interpolant $I$ is a formula such that $A \implies I$ and $I \land B$ is unsatisfiable. Essentially, $I$ acts as a separator between safe and unsafe states.
Traditional interpolation methods are "proof-based," extracting interpolants from formal proofs generated by SMT solvers. However, these methods are often computationally expensive, struggle with non-linear arithmetic, and produce complex, non-generalizable predicates. This paper proposes a "sampling-based" alternative that treats interpolation as a supervised machine learning task.
2. Methodology
The proposed framework shifts from symbolic reasoning to data-driven classification. The process involves four key stages:
2.1 Sampling and Classification
Instead of analyzing formulas directly, the authors use an SMT solver (e.g., Z3) to generate concrete "positive" samples from $A$ and "negative" samples from $B$. These points are fed into a Support Vector Machine (SVM), which identifies a maximum-margin hyperplane to separate the two sets. The maximum-margin property is crucial as it favors "simple" boundaries that are more likely to generalize as valid program invariants.
2.2 Handling Non-Linear Separability (SVM-I)
In cases where a single linear hyperplane cannot separate the samples (e.g., the XOR-like problem), the authors introduce the SVM-I algorithm. SVM-I constructs a more complex separator by finding an intersection of multiple half-spaces, effectively creating a convex hull around the safe states.
2.3 The Soundness Loop
Because SVMs operate on a finite set of samples, the resulting classifier is initially only a candidate interpolant. To ensure mathematical soundness, the candidate is formally checked against the original formulas $A$ and $B$. If the check fails, the resulting counterexample is added to the training set, and the SVM is retrained. This iterative refinement continues until a valid interpolant is found.
3. Experimental Evaluation
The approach was evaluated on benchmarks from NECLA research labs and various verification tool projects (e.g., Yogi).
- Performance: The tool demonstrated high efficiency, solving most benchmarks in under 0.02 seconds and typically requiring fewer than 20 samples.
- Robustness to Non-linearity: A key advantage is the ability to bypass "superficial" non-linearity. While symbolic solvers may struggle with complex functions like $x = 4 \sin^2(z)$, the SVM-based approach only considers the generated points. If these points are linearly separable in the state space, the SVM finds the boundary regardless of the complexity of the generating function.
- Comparison: In head-to-head tests, the SVM-based tool succeeded on several benchmarks where the traditional tool OpenSMT failed, particularly those involving non-linear multiplications.
4. Discussion and Conclusion
By reframing interpolation as classification, this work bridges formal methods and machine learning. The use of SVMs provides a natural mechanism for generalization, leading to simpler and more robust invariants.
Future work includes extending the framework to handle complex data structures like arrays and pointers. Additionally, the authors suggest that "kernel tricks" could be used to discover truly non-linear interpolants (e.g., circular or ellipsoidal boundaries) when linear separators are insufficient.
Summary updated