Leaf: Modularity for Temporary Sharing in Separation Logic

Travis Hance, Jon Howell, Oded Padon, Bryan Parno

TL;DR

This paper introduces "Leaf," a new logic for reasoning about concurrent programs that temporarily share mutable state. Leaf provides a modular way to verify complex sharing strategies, enabling developers to write and reason about code that efficiently shares data without sacrificing correctness.

What Problem Does This Paper Address?

Concurrent programming is notoriously difficult, especially when dealing with shared mutable state. While existing tools like separation logic excel at reasoning about exclusive ownership and persistent sharing, they struggle with the common and performance-critical pattern of temporary sharing. This is where multiple threads might read shared data, but only one thread can write at a time, and this sharing is eventually relinquished. Existing approaches often require complex, ad-hoc solutions for each sharing pattern, hindering modularity and making verification challenging. Leaf aims to provide a unified, modular framework to handle these temporary sharing scenarios gracefully.

Methods

Leaf introduces a novel operator, denoted by "guards" ($\rightsquigarrow$), which allows a proposition to represent a shared version of another. This operator enables users to define "storage protocols" – custom mechanisms for managing shared state. These protocols abstract away the underlying sharing implementation, allowing developers to reason about shared resources in a uniform way. Leaf provides rules for deducing these guard relationships and for using them in program logic, enabling modular specifications. The authors demonstrate Leaf's effectiveness through case studies, including a reader-writer lock and a hash table, showing how it can verify complex sharing patterns and compose them modularly.

Datasets

Not discussed in the paper.

Key Insights and Ideas

  • The $\rightsquigarrow$ Operator: This is the core innovation. It allows a proposition (the "guard") to stand in for another proposition (the "guarded"), enabling temporary, shared access. This is crucial for reasoning about read-sharing.
  • Storage Protocols: Leaf formalizes custom ghost state mechanisms as "storage protocols." These protocols define how to construct shared resources and derive their $\rightsquigarrow$ relationships, making sharing mechanisms reusable and composable.
  • Modularity: By abstracting away the specifics of sharing mechanisms, Leaf allows for modular specifications. This means you can verify a component (like a reader-writer lock) independently and then use it in larger programs without re-verifying its internal sharing logic.
  • Bridging Ghost State and Sharing: Leaf elegantly connects custom ghost state techniques with the need for shared resources. Ghost state can be used to implement sharing protocols, and Leaf's $\rightsquigarrow$ operator makes these protocols usable in program logic.

Key Results

The paper demonstrates Leaf's capabilities through detailed case studies:

  • Reader-Writer Lock: Leaf is used to verify a reader-writer lock implementation, showcasing how to manage exclusive and shared read access to underlying resources. This includes verifying a multi-counter version for improved performance.
  • Hash Table: A concurrent linear probing hash table is verified using Leaf. This example highlights Leaf's ability to handle fine-grained concurrency, where operations might require acquiring multiple shared locks and composing shared state.

The authors also provide formal proofs of Leaf's soundness within the Iris separation logic framework, implemented in Coq.

Limitations and Future Work

The authors acknowledge that their current implementation focuses on a simplified version of Iris's ghost state and that incorporating Iris's full machinery for persistent state and step-indexed equality could further enhance Leaf. They also suggest future work in adapting Leaf's storage protocols to more advanced scenarios like relaxed memory models and exploring its application to other complex concurrent data structures. The paper also mentions that while their hash table implementation handles fixed-size tables, a full implementation would need to address resizing.

Summary updated

Abstract

In concurrent verification, separation logic provides a strong story for handling both resources that are owned exclusively and resources that are shared persistently (i.e., forever). However, the situation is more complicated for temporarily shared state, where state might be shared and then later reclaimed as exclusive. We believe that a framework for temporarily-shared state should meet two key goals not adequately met by existing techniques. One, it should allow and encourage users to verify new sharing strategies. Two, it should provide an abstraction where users manipulate shared state in a way agnostic to the means with which it is shared. We present Leaf, a library in the Iris separation logic which accomplishes both of these goals by introducing a novel operator, which we call guarding, that allows one proposition to represent a shared version of another. We demonstrate that Leaf meets these two goals through a modular case study: we verify a reader-writer lock that supports shared state, and a hash table built on top of it that uses shared state.
BibTeX
@article{hance2023leaf,
  author = {Travis Hance and Jon Howell and Oded Padon and Bryan Parno},
  title = {{Leaf: Modularity for Temporary Sharing in Separation Logic}},
  journal = {Proc. ACM Program. Lang.},
  year = {2023},
  doi = {10.1145/3622798},
}
Figure