Introduction
Termination analysis—the task of proving that a computer program will eventually stop for any valid input—remains a fundamental challenge in computer science. While theoretically undecidable, practical approaches rely on ranking functions. These functions map program states to a well-founded domain (typically non-negative integers or reals), ensuring that the value decreases with every loop iteration. If such a function exists, the program is guaranteed to terminate.
However, traditional symbolic reasoning tools often struggle with complex loop conditions involving disjunctions (e.g., while (x < y || x < z)) or nonlinear expressions (e.g., while (x*x < n)). This paper introduces $ν$Term, a tool that leverages the pattern-matching capabilities of neural networks to "guess" ranking functions, which are then rigorously "checked" by formal solvers.
The $ν$Term Framework
The authors propose a hybrid "guess-and-check" architecture that combines the flexibility of deep learning with the absolute certainty of formal verification. The process consists of three primary stages:
- Tracing: The target program is executed with sampled inputs to generate execution traces—snapshots of variable values at each loop header.
- Learning: A Neural Ranking Function (NRF) is trained on these traces. The NRF is a feed-forward neural network with ReLU activations. A specialized loss function penalizes the model if its output does not decrease by a minimum margin ($δ$) between consecutive steps in a trace. By using non-negative weights in the final layer, the network's output is naturally bounded from below by zero.
- Verification: Because a trained network is an approximation, it must be formally validated. The program logic and the neural network are encoded into a Satisfiability Modulo Theories (SMT) formula. An SMT solver (Z3) then attempts to prove that the ranking function holds for all possible program states. If successful, the NRF serves as a formal certificate of termination.
Key Insights: The Power of Small Networks
A surprising finding of this research is that termination proofs do not require massive models. The piecewise-linear nature of ReLU activations is a natural fit for the piecewise-linear ranking functions often found in code.
Experimental results demonstrate that "tiny" networks are remarkably effective. As shown in the evaluation, increasing the number of neurons beyond a small threshold yields diminishing returns. Networks with as few as 7 to 10 neurons were sufficient to solve over 75% of the standard benchmarks. This efficiency allows $ν$Term to find and verify proofs in less than a second for many nonlinear loops where traditional tools frequently time out.
Evaluation and Performance
$ν$Term was evaluated against state-of-the-art symbolic tools like AProVE and Ultimate across several benchmark sets, including a new nuTerm-advantage set designed to highlight traditional weaknesses.
- General Benchmarks: $ν$Term solved 78.4% of combined problems, performing on par with leading symbolic analyzers.
- Nonlinear and Disjunctive Logic: On the
nuTerm-advantageset, $ν$Term achieved a 92.9% success rate, vastly outperforming AProVE (21.4%) and Ultimate (7.8%).
Conclusion
By treating neural networks as generators of candidate proofs rather than black-box oracles, $ν$Term demonstrates a powerful synergy between machine learning and formal methods. While limitations remain—such as dependency on high-quality execution traces and difficulty with very large constants—the approach provides a scalable path forward for verifying complex, nonlinear software systems.
Summary updated