Abstract: We present a new approach to proving non-termination of non-deterministic integer programs. Our technique is rather simple but efficient. It relies on a purely syntactic reversal of the program's transition system followed by a constraint-based invariant synthesis with constraints coming from both the original and the reversed transition system. The latter task is performed by a simple call to an off-the-shelf SMT-solver, which allows us to leverage the latest advances in SMT-solving. Moreover, our method offers a combination of features not present (as a whole) in previous approaches: it handles programs with non-determinism, provides relative completeness guarantees and supports programs with polynomial arithmetic. The experiments performed with our prototype tool RevTerm show that our approach, despite its simplicity and stronger theoretical guarantees, is at least on par with the state-of-the-art tools, often achieving a non-trivial improvement under a proper configuration of its parameters.
Introduction
Presented at PLDI 2021, this research introduces a clever and surprisingly simple technique for a notoriously difficult problem in formal verification: proving that a computer program might run forever. By "reversing" the program’s logic, the authors transform the search for infinite loops into a more manageable search for program invariants. This approach, implemented in the tool RevTerm, provides a robust framework for handling non-determinism and complex polynomial arithmetic while offering stronger theoretical completeness guarantees than previous state-of-the-art tools.
The Challenge of Non-termination
Proving that a program terminates is a classic "liveness" problem. Proving the opposite—non-termination—is essentially bug-finding. If you can prove a program doesn't terminate, you've found a critical flaw, such as a hang in a user interface or an infinite loop in a server process.
However, proving non-termination is significantly harder than proving safety properties for several reasons:
- Infinite Witnesses: Unlike safety properties (where a bug is a finite trace ending in an error), a non-termination witness is an infinite execution trace.
- Non-determinism: Many programs involve "choices" (like
x := ndet()). A program might terminate for some choices but not others, requiring a tool to find the specific path that leads to divergence. - Aperiodic Behavior: Many existing tools look for "lassos" (a path that leads into a repeating cycle). However, some programs run forever without ever repeating the same state twice, a phenomenon known as aperiodic behavior.
- Complex Math: Handling polynomial arithmetic (e.g.,
y := x * x) often breaks traditional linear analysis tools that rely on simpler polyhedral abstractions.
The RevTerm Approach: Program Reversal
The core innovation of this work is Program Reversal. Instead of looking forward to see if a program can run forever, the method looks backward from the exit to see what states cannot reach it.
As illustrated in the figure above, the process involves several key steps:
- The Reversal: The authors take the program's transition system—the graph of how states move from one to another—and flip all the arrows. In this reversed world, the "exit" of the original program ($\ell_{out}$) becomes the "starting point."
- Backward Invariants (BI): They use an off-the-shelf SMT (Satisfiability Modulo Theories) solver to find an invariant in this reversed system. This "Backward Invariant" represents the set of all states from which the program could eventually terminate.
- The Divergence Test: If the tool finds a state that is reachable in the original program but is not in the Backward Invariant, it has found a "diverging" state. Because this state cannot reach the exit (by definition of the BI), any execution starting there must run forever.
- Constraint-Based Synthesis: To find these invariants, they use "templates"—mathematical skeletons of possible invariants—and ask the SMT solver to fill in the coefficients based on constraints derived from both the forward and backward systems.
This method effectively turns a liveness problem (will it run forever?) into a safety/reachability problem (can we reach a state that has no path to the exit?).
Experimental Evaluation
The authors evaluated RevTerm using the TermComp '19 (Termination and Complexity Competition) benchmark suite, which includes 335 C-integer programs with non-determinism. This suite is composed of 111 known non-terminating programs and 223 terminating ones. They compared RevTerm against top-tier tools like AProVE, Ultimate, VeryMax, and LoAT.
Key Results
- Superior Performance: RevTerm proved non-termination for 107 benchmarks, outperforming the previous best tools, Ultimate (97) and VeryMax (103).
- Efficiency: The tool was remarkably fast, with an average successful proof time of just 1.2 seconds.
- Unique Wins: RevTerm found non-termination proofs for several benchmarks that no other tool could solve, particularly those involving aperiodic behavior or complex non-deterministic branching.
Conclusion and Future Work
RevTerm demonstrates that syntactic simplicity can lead to powerful results. By leveraging standard, highly-optimized invariant generation techniques through program reversal, the authors have bridged the gap between safety and liveness analysis.
While the tool's success currently depends on user-provided templates and the underlying SMT solver's capacity for non-linear constraints, it provides a strong foundation for future research. The authors suggest extending this reversal technique to other program properties, such as analyzing heap-based operations or programs with complex data structures, potentially opening new avenues for automated program verification.
Summary updated