Sound and Complete Invariant-Based Heap Encodings (Technical Report)
Zafer Esen, Philipp Rümmer, Tjark Weber
TL;DR
This work tackles the verification of programs that manipulate mutable, heap-allocated data by introducing a relational heap encoding that eliminates the heap and reduces verification to integer-based constrained Horn clauses with uninterpreted predicates and prophecy variables. It presents two complete, sound encodings, Enc_R and Enc_RW, along with formal proofs and extensions for scalability, and demonstrates their effectiveness on SV-COMP-like benchmarks using CHC back-ends such as Sea-Horn and Tri-Cera. The approach enables automatic verification of previously unreachable heap-manipulating programs, without manual heap annotations, by translating heap behavior into logical relations over program inputs and read/write indices. The framework supports refinements (meta-information, scope variables) and property-tailored variants, offering a flexible, equi-safe foundation for advancing heap verification and guiding future extensions to arrays, concurrency, and more complex data structures.
Abstract
Verification of programs operating on mutable, heap-allocated data structures poses significant challenges due to potentially unbounded structures like linked lists and trees. In this paper, we present a novel relational heap encoding leveraging uninterpreted predicates and prophecy variables, reducing heap verification tasks to satisfiability checks over integers in constrained Horn clauses (CHCs). To the best of our knowledge, our approach is the first invariant-based method that achieves both soundness and completeness for heap-manipulating programs. We provide formal proofs establishing the correctness of our encodings. Through an experimental evaluation we demonstrate that our method significantly extends the capability of existing CHC-based verification tools, allowing automatic verification of programs with heap previously unreachable by state-of-the-art tools.
