Compositional Verification of Procedural Programs using Horn Clauses over Integers and Arrays

Anvesh Komuravelli, Nikolaj S. Bjørner, Arie Gurfinkel, Kenneth L. McMillan

Introduction

Verifying the safety of procedural programs, particularly those written in C, presents a significant challenge due to the complex nature of the heap (memory). Traditional automated verifiers often rely on "inlining"—the process of expanding function calls into the caller's code. While effective for small programs, inlining leads to exponential state-space explosion and fails to handle recursion, making it unsuitable for large-scale systems. This paper presents a novel approach to compositional verification that treats memory as a first-class citizen using the theory of arrays, enabling the verification of programs function-by-function.

The Challenge of Heap Modeling

The standard mathematical framework for modeling computer memory is the Theory of Arrays (ARR). However, SMT-based (Satisfiability Modulo Theories) solvers often struggle with ARR because they lack efficient mechanisms for "projections." Projection is the process of simplifying logical formulas while preserving the essential information needed for a proof. Without efficient projection, solvers cannot generate the procedure summaries required for modular reasoning, forcing them back into the inefficient paradigm of inlining.

Methodology: Model-Based Projection for Arrays

The authors address this by developing a polynomial-time Model-Based Projection (MBP) algorithm for arrays and integrating it into the SPACER framework. The approach follows these key steps:

  1. CHC Representation: Program verification conditions are encoded as Constrained Horn Clauses (CHCs), a logic-based format ideal for program safety.
  2. Model-Based Simplification: Unlike traditional Quantifier Elimination, which is exponentially slow, MBP uses a concrete model of a program state to guide the simplification process. This transforms an exponential problem into a polynomial one.
  3. Compositional Reasoning: By implementing MBP within SPACER, the tool can generate "must" and "may" summaries for procedures. This allows the solver to reason about functions in isolation and reuse proofs, preventing the explosion of the state space.

Experimental Results

The researchers evaluated their tool, SPACER with ARRAYMBP, using 215 challenging benchmarks from the Device Drivers category of SV-COMP'15.

The Advantage of Compositionality

A key finding was that modularity directly translates to scalability. By avoiding inlining, the solver can prove programs safe much faster. In many instances where inlining caused standard tools to time out or exhaust memory, the compositional approach succeeded in seconds.

Advantage of inter-procedural encoding (non-inlining) using SPACER.

Performance Comparison

SPACER with ARRAYMBP significantly outperformed state-of-the-art solvers like Z3-PDR. Even when compared on inlined benchmarks, SPACER demonstrated superior performance, but its true strength lies in its ability to handle non-inlined, modular representations.

Performance comparison between SPACER and Z3-PDR on inlined benchmarks.

Conclusion

The introduction of a finite MBP for array-valued variables marks a significant step forward in automated program verification. By enabling efficient, compositional reasoning over the theory of arrays, the authors have provided a path toward verifying large, complex C programs that were previously out of reach for SMT-based tools. Future work will focus on extending these techniques to handle universal quantifiers, which are necessary for verifying complex data structure invariants.

Summary updated

BibTeX
@inproceedings{komuravelli2015compositional,
  author = {Anvesh Komuravelli and Nikolaj S. Bjørner and Arie Gurfinkel and Kenneth L. McMillan},
  title = {{Compositional Verification of Procedural Programs using Horn Clauses over Integers and Arrays}},
  booktitle = {FMCAD},
  year = {2015},
  url = {https://openreview.net/forum?id=gJaolscTch0},
}
Figure