Inductive Reachability Witnesses

Ali Asadi, Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, Mohammad MahdaviarXiv 2020

Abstract

In this work, we consider the fundamental problem of reachability analysis over imperative programs with real variables. The reachability property requires that a program can reach certain target states during its execution. Previous works that tackle reachability analysis are either unable to handle programs consisting of general loops (e.g. symbolic execution), or lack completeness guarantees (e.g. abstract interpretation), or are not automated (e.g. incorrectness logic/reverse Hoare logic). In contrast, we propose a novel approach for reachability analysis that can handle general programs, is (semi-)complete, and can be entirely automated for a wide family of programs. Our approach extends techniques from both invariant generation and ranking-function synthesis to reachability analysis through the notion of (Universal) Inductive Reachability Witnesses (IRWs/UIRWs). While traditional invariant generation uses over-approximations of reachable states, we consider the natural dual problem of under-approximating the set of program states that can reach a target state. We then apply an argument similar to ranking functions to ensure that all states in our under-approximation can indeed reach the target set in finitely many steps.

Introduction

Reachability analysis—determining if a program can ever enter a specific state, such as a bug or a successful termination—is a cornerstone of computer science. However, it is notoriously difficult for imperative programs with real-valued variables and complex loops. Existing tools generally fall into three categories, each with significant drawbacks:

  1. Symbolic Execution: Effective for straight-line code but struggles with "unrolling" loops an unknown number of times.
  2. Abstract Interpretation: Excellent for proving safety via over-approximation, but often fails to prove reachability because its approximations are too "loose."
  3. Manual Logic: Frameworks like Incorrectness Logic are powerful but require human experts to write complex assertions.

This work fills this gap with an automated approach that handles general loops and provides strong theoretical guarantees of soundness and (semi-)completeness.

Methodology: Inductive Reachability Witnesses

The core innovation is the Inductive Reachability Witness (IRW). An IRW is the "mirror image" of a loop invariant. While invariants define a set that reachable states cannot leave (an over-approximation), IRWs define a set of states $T^\diamond$ from which the target must be reachable (an under-approximation).

To ensure a program eventually reaches the target and does not spin infinitely within $T^\diamond$, the framework incorporates a ranking function $f$. This function acts as a countdown; every program step within the witness set must decrease the value of $f$, guaranteeing termination at the target in finite steps.

An example program and its corresponding control flow graph (CFG) used for reachability analysis.

To automate witness discovery, we use template-based synthesis:

  • Linear Programs: Farkas’ Lemma transforms the search into a quadratic programming problem.
  • Polynomial Programs: Theorems from algebraic geometry—Handelman’s Theorem, Hilbert’s Nullstellensatz, and Putinar’s Positivstellensatz—are combined to synthesize witnesses. This application of algebraic geometry to program witnesses is a significant novel contribution.
A synthesized Inductive Reachability Witness (IRW) for the example program, showing the under-approximating sets $A_\ell$ and ranking functions $f_\ell$ for each location.

Experimental Evaluation

The approach was evaluated using two main sources: the SV-COMP 2020 linear benchmarks and a set of Custom Polynomial Benchmarks involving non-linear updates and non-deterministic choices.

Key Results

  • Performance on Linear Benchmarks: On SV-COMP benchmarks, our tool handled every instance, outperforming top model checkers like VeriAbs and CPAchecker.
  • The "Deep Nested" Challenge: In the deep_nested benchmark, where the target is reached only after $>10^9$ iterations, our tool succeeded in under 100 seconds. Other tools timed out because they attempted to simulate the path, whereas IRWs provide a mathematical proof independent of path length.
  • Polynomial Success: On custom polynomial benchmarks, the tool successfully proved reachability where existing tools returned "unknown" or failed to provide a proof.

Discussion and Conclusion

The most profound insight of this work is that reachability is the natural dual of safety. By applying under-approximations—a relatively under-explored area compared to safety over-approximations—we can leverage powerful algebraic tools like the Positivstellensatz for practical software engineering.

Limitations and Future Work

While the linear case is fully complete, the polynomial case is "semi-complete," meaning success depends on choosing a sufficiently high degree for polynomial templates. Future work includes extending the framework to handle lexicographic ranking functions for more complex termination arguments and integrating these techniques into automated proofs for Incorrectness Logic.

Summary updated

BibTeX
@misc{asadi2020inductive,
  author = {Ali Asadi and Krishnendu Chatterjee and Hongfei Fu and Amir Kafshdar Goharshady and Mohammad Mahdavi},
  title = {{Inductive Reachability Witnesses}},
  year = {2020},
  eprint = {2007.14259},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2007.14259},
}
Figure