Separation Logic
Separation logic reasons about disjoint ownership of memory. The frame rule turns one local heap proof into a proof valid in a larger context.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 3
- Reading time
- 2 min
In this article3 chapters
The separating conjunction has heap semantics
Model a heap as a finite partial map from addresses to values. A points-to assertion describes a cell the proof owns. For \(P*R\) to hold, split the current heap into disjoint heaps satisfying the two assertions. Ordinary conjunction checks both on the same heap. With exact one-cell assertions, \(x\mapsto v*y\mapsto w\) entails that the addresses differ, because a cell cannot belong to both parts of the split.
A Hoare triple describes the local update. Separating conjunction adds the information that other required memory belongs to a disjoint fragment.
Updating one cell and preserving another
A command storing a new value in a location can be proved locally. If it accesses only the specified resources and modifies no program variable free in the framed assertion, the frame rule gives
\[ \frac{\{P\}\ C\ \{Q\}}{\{P*R\}\ C\ \{Q*R\}}. \]
Use the local triple that a store at the owned cell replaces its old value. Framing the cell at the other address then says its value is unchanged. The rule relies on locality of the language semantics, including the treatment of faults and allocation. Sharing through aliases must be represented explicitly in the resource assertions before applying it.
Inductive predicates describe a changing heap shape
A list predicate can unfold to an owned node separated from the tail predicate, or to the empty heap at the terminator. A traversal may use a list-segment predicate together with the remaining tail. Joining the segments re-establishes the full shape after a step. Shape analysis approximates such predicates automatically, while a deductive proof can state richer invariants. Concurrent sharing adds the need for protocols and permissions, developed in concurrent separation logic. For the underlying triples and approximation techniques, compare deductive verification and abstract interpretation.[1]