Nested Hoare Triples and Frame Rules for Higher-Order Store

Jan Schwinghammer, Lars Birkedal, Bernhard Reus, Hongseok Yang

TL;DR

This paper introduces a novel program logic that extends separation logic to reason about programs with higher-order store (like code stored on the heap). They propose a sound combination of nested Hoare triples and frame rules, enabling modular verification of programs with complex recursive structures and code manipulation, which was previously challenging.

What Problem Does This Paper Address?

Traditional separation logic excels at reasoning about programs with heap-allocated data structures, particularly in low-level languages. However, many modern languages allow for "higher-order store," where the heap can store not just data but also code itself (e.g., function pointers in C, or closures in ML-like languages). Reasoning about such programs requires a logic that can handle code stored on the heap and interact effectively with modular reasoning principles like frame rules. Previous attempts to extend separation logic to higher-order store struggled with unsoundness when combining nested Hoare triples (specifying code behavior) with frame rules, or lacked the expressiveness to abstractly specify code behavior, hindering modular verification of mutually recursive procedures.

Methods

The core contribution is a new program logic that integrates nested Hoare triples into separation logic's assertion language. This allows programs to specify the behavior of stored code using Hoare triples themselves. The authors tackle the challenge of combining these nested triples with frame rules by carefully designing a set of rules. They demonstrate that certain "deep" frame rules, when naively combined with nested triples, lead to unsoundness. Their solution involves a specific, sound combination of nested triples and frame rules.

To prove the soundness of their logic, they develop a novel Kripke-style model. This model features "worlds" that live in a recursively defined ultrametric space. This sophisticated semantic framework allows for recursively defined assertions, which are crucial for specifying and reasoning about recursive code stored on the heap. The model's structure, particularly its use of ultrametric spaces and contractive operators, is key to handling the recursive nature of both the program logic and the higher-order store.

Datasets

Not discussed in the paper.

Key Insights and Ideas

  • Nested Triples are Tricky: Simply allowing Hoare triples within assertions (nested triples) and combining them with standard frame rules can lead to unsoundness. The interaction is subtle and requires careful design.
  • Deep Frame Rules Can Be Unsound: The paper highlights that certain powerful frame rules, intended to propagate invariants deeply into nested structures, can become unsound when dealing with higher-order store and nested triples.
  • Recursive Worlds for Recursive Code: The soundness proof relies on a novel semantic model where "worlds" are recursively defined. This recursive structure mirrors the recursive nature of code stored on the heap and is essential for proving properties of such programs.
  • Recursive Assertions are Powerful: The logic supports recursively defined assertions, which are crucial for specifying and reasoning about code that refers to itself (or other code) through the store. This enables elegant proofs of invariants for recursive procedures.
  • Fault-Avoiding Semantics: The logic employs a fault-avoiding semantics for triples, ensuring that verified programs do not crash. This is achieved by carefully defining the interpretation of assertions and commands.

Key Results

  • Sound Logic for Higher-Order Store: The paper presents a sound program logic that combines nested Hoare triples and frame rules for reasoning about programs with higher-order store.
  • Counterexamples to Naive Approaches: They provide concrete counterexamples demonstrating the unsoundness of certain natural combinations of deep frame rules and nested triples, as well as the unsoundness of using classical assertion logic with their frame rules.
  • Model Construction: A novel Kripke model based on recursively defined ultrametric spaces is developed to prove the soundness of the proposed logic.
  • Proof Rules for Recursion: The logic includes specific proof rules for handling recursion through the store, particularly for the eval command, which executes stored code.

Limitations and Future Work

  • No Spatial Implication: The denotational model developed does not support spatial implication (the "magic wand" operator), which is important for reasoning about shared memory. The authors suggest that a step-indexed model might address this.
  • Pseudo-Pure Assertions: Triples are only "pseudo-pure" in their model, meaning their interpretation can depend on the rank of the heap. This limits the validity of certain invariance rules.
  • Rule (IN-T) Unsoundness: The paper shows that a rule called (IN-T), which attempts to move global assumptions of triples into pre-conditions, is unsound in their model.
  • Future Work: The authors suggest exploring step-indexed models for better handling of shared memory and investigating the implications of their findings for other logics and programming language features. They also note that their model is well-suited for combining equational reasoning with Hoare-style logics.

Summary updated

BibTeX
@inproceedings{schwinghammer2009nested,
  author = {Jan Schwinghammer and Lars Birkedal and Bernhard Reus and Hongseok Yang},
  title = {{Nested Hoare Triples and Frame Rules for Higher-Order Store}},
  booktitle = {Log. Methods Comput. Sci},
  year = {2009},
  url = {https://openreview.net/forum?id=I4nEICOr_m},
}

Loading related content...

Figure