Math 2.0

Computer science Definition

Separation logic

Builds on Hoare logicFunction

Definition

Fix a set Var\mathit{Var} of variables and a set Loc⊆ℤ\mathit{Loc} \subseteq \Z of locations. A store is a function s ⁣:Var→ℤs \colon \mathit{Var} \to \Z, and a heap is a function h ⁣:dom(h)→ℤh \colon \mathrm{dom}(h) \to \Z with finite domain dom(h)⊆Loc\mathrm{dom}(h) \subseteq \mathit{Loc}. Two heaps h1,h2h_1, h_2 are disjoint if their domains are disjoint, and then h1⋅h2h_1 \cdot h_2 is the heap on dom(h1)∪dom(h2)\mathrm{dom}(h_1) \cup \mathrm{dom}(h_2) that agrees with each. The assertions of separation logic extend first-order formulas over the store with the following, and their meaning is a relation s,h⊨Ps, h \models P.

  1. s,h⊨𝖾𝗆𝗉s, h \models \mathsf{emp} if dom(h)\mathrm{dom}(h) is empty.
  2. s,h⊨E↦Fs, h \models E \mapsto F if dom(h)={s(E)}\mathrm{dom}(h) = \set{s(E)} and h(s(E))=s(F)h(s(E)) = s(F), where s(E)s(E) is the value of the expression EE in ss.
  3. s,h⊨P∗Qs, h \models P * Q if h=h1⋅h2h = h_1 \cdot h_2 for some disjoint heaps with s,h1⊨Ps, h_1 \models P and s,h2⊨Qs, h_2 \models Q.
  4. s,h⊨P− ⁣ ⁣∗Qs, h \models P \mathrel{-\!\!*} Q if for every heap h′h' disjoint from hh with s,h′⊨Ps, h' \models P, also s,h⋅h′⊨Qs, h \cdot h' \models Q.

Separation logic is the Hoare logic for a language with heap commands, with triples {P} C {Q}\set{P}\, C\, \set{Q} over these assertions. Triples are read with fault avoidance. From any state satisfying PP, the command CC never accesses a location outside the heap, and if it terminates, the final state satisfies QQ. Its central rule is the frame rule: from {P} C {Q}\set{P}\, C\, \set{Q} derive {P∗R} C {Q∗R}\set{P * R}\, C\, \set{Q * R}, provided CC assigns no variable that occurs free in RR.

Remarks

Example: let s(x)=10s(x) = 10, s(y)=20s(y) = 20 and let hh have domain {10,20}\set{10, 20} with h(10)=3h(10) = 3 and h(20)=4h(20) = 4. Then s,h⊨x↦3∗y↦4s, h \models x \mapsto 3 * y \mapsto 4: split hh into the heap {10↦3}\set{10 \mapsto 3}, which satisfies x↦3x \mapsto 3, and the disjoint heap {20↦4}\set{20 \mapsto 4}, which satisfies y↦4y \mapsto 4.

Non-example: x↦3∗x↦3x \mapsto 3 * x \mapsto 3 holds in no state. Both parts would need the location s(x)s(x) in their domains, so they are not disjoint, and clause 3 fails. By contrast, the ordinary conjunction x↦3∧x↦3x \mapsto 3 \land x \mapsto 3 holds in the one-cell heap {s(x)↦3}\set{s(x) \mapsto 3}.

The frame rule is sound because of fault avoidance: a command that runs safely in a heap satisfying PP cannot touch the cells of a disjoint part satisfying RR. The connective − ⁣ ⁣∗\mathrel{-\!\!*} is the separating implication, or magic wand, and it is the right adjoint of ∗*.

Reading path

To understand this page from the ground up, read these 14 pages in order. The foundations come first.

Show the path as a graph
Each page uses the pages above it. The colour of the bar on a box shows how strong the evidence is, and the box also gives it as text. The list has the same pages.
  • no evidence level
  1. Binary relation concept
  2. Function concept
  3. Proposition concept
  4. Operational semantics concept
  5. Conjunction definition
  6. Disjunction definition
  7. Implication definition
  8. Negation definition
  9. Predicate definition
  10. Biconditional definition
  11. Propositional logic concept
  12. Predicate logic concept
  13. Hoare logic concept
  14. Separation logic definition

Further reading

  1. Web https://en.wikipedia.org/wiki/Separation_logic
About this page
Tag4ANY45YJG8
URIm2://4ANY45YJG8
Kinddefinition
WritingW0 stub
MSC68Q60, 03B70, 03B47
DefinesSeparation logic
UsesHoare logic, Function
Changed3 November 2026

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • a source with a locator (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

No page links to this page yet.