Logical Characterizations of Heap Abstractions

Greta Yorsh, Thomas W. Reps, Shmuel Sagiv, Reinhard Wilhelm

Abstract

This paper bridges the gap between Abstract Interpretation and Automated Theorem Proving by providing a logical characterization of heap abstractions. By translating the 3-valued logic structures used in shape analysis into standard first-order logic formulas, the authors enable the use of off-the-shelf theorem provers to extract precise information about program data structures. This approach addresses the inherent imprecision of compositional logic in tools like TVLA and paves the way for more robust automated verification.

Introduction

Verifying programs that manipulate complex data structures—such as linked lists or trees—requires an accurate understanding of the "heap." Shape analysis is the task of automatically determining these structural properties. Historically, the state-of-the-art tool TVLA (Three-Valued-Logic Analyzer) represented heaps using "3-valued structures," where properties could be True, False, or Unknown (1/2).

The Challenge of Heap Abstraction

While powerful, TVLA's internal logic was compositional, evaluating complex queries by looking at small parts. This often led to "Unknown" results even when a global view would show a property was definitely True or False. Furthermore, its specialized logic prevented integration with standard 2-valued theorem provers.

Figure 1: Examples of 3-valued structures (a, b, c) and a summary abstraction (d) representing multiple heap configurations.

As illustrated in Figure 1, concrete heap configurations are abstracted into summary structures. The authors address this by asking: Can we characterize these 3-valued heap abstractions using standard logical formulas?

Methodology: The $\hat{\gamma}$ Operator

The paper introduces a symbolic operator called $\hat{\gamma}$ (gamma-hat). This operator takes a 3-valued abstract structure and produces a first-order logic formula that describes exactly which concrete heaps that abstraction represents.

Logical Predicates

To construct these formulas, the authors define a set of core predicates that capture the essential properties of heap nodes and their relationships.

Figure 2: Core predicates and their intended meanings for describing heap properties.

As shown in Figure 2, predicates like $n(v_1, v_2)$ for pointer fields and $r_q(v)$ for reachability allow the logic to express complex structural invariants.

Key Technical Components

  • FO-Identifiability: The authors identify a class of structures where every node in the abstract graph can be uniquely "named" by a formula. They prove that for these structures, a characteristic formula always exists in first-order logic with transitive closure.
  • Supervaluational Semantics: This "gold standard" for precision asks if a query is true for every concrete heap represented by an abstraction, rather than evaluating it locally.
  • Theorem Prover Integration: By converting the abstraction into a formula ($\hat{\gamma}(S)$) and the query into a formula ($\phi$), they use theorem provers like SPASS to check if $\hat{\gamma}(S) \Rightarrow \phi$ is valid.

Key Results and Insights

The most significant insight is that an abstract state is a predicate that can be written as a standard formula, connecting abstract interpretation to the broader world of logic.

Evaluation on a running example of a C program performing linked-list insertion demonstrated that this method can resolve "Unknown" values into "True" or "False." For instance, in Example 10 of the paper, standard TVLA returns "Unknown" (1/2) for a pointer property, but the proposed method using the SPASS theorem prover correctly identifies it as "True" (1).

Limitations and Future Work

Despite the precision gains, several challenges remain:

  • Transitive Closure: Standard FOL provers struggle with reachability, often requiring manual axioms to handle transitive closure.
  • Infinite Models: Provers may find "counter-examples" in infinite structures that are physically impossible in finite computer memory, leading to spurious results.
  • Complexity: The generated formulas can be large, making scaling to massive programs computationally expensive.

Future directions include using this work for Assume-Guarantee reasoning, allowing modular analysis of program components that are later linked via these logical characterizations.

Summary updated

BibTeX
@article{yorsh2003logical,
  author = {Greta Yorsh and Thomas W. Reps and Shmuel Sagiv and Reinhard Wilhelm},
  title = {{Logical Characterizations of Heap Abstractions}},
  journal = {ACM Trans. Comput. Log.},
  year = {2003},
  doi = {10.1145/1182613.1182618},
}
Figure