Table of contents
Writes
Formal definition
Writing is a relation :
holding when modifies an instance in place — exists before and after , but its value has changed from some pre-state to a post-state .
Two invariants. iff:
-
Persistence with change: exists both before and after — writing is not destruction (which would remove ) and not creation (which would bring into existence from nothing). The resource’s identity persists; its content changes.
-
Exclusive access: requires exclusive control of during execution — no other concurrent operation may read or write during ’s write. This is the separation condition: a write to requires full ownership of , not merely a fractional read share.
Separation logic: exclusive write
Peter O’Hearn, John Reynolds, Hongseok Yang (Local Reasoning about Programs that Alter Data Structures, 2001): in separation logic, writing to location requires full ownership (the heap points-to assertion with no sharing):
After the write, points to instead of . The full-ownership requirement (, not for fractional ) is the formal content of exclusive write access: no other holder of a fractional share can permit concurrent modification.
The frame rule ensures locality: writing to does not affect any in the frame :
Effect types: write effects
Lucassen and Gifford (Polymorphic Effect Systems, 1988): an operation type writes to region . Operations with write effects are not idempotent — calling twice from the same initial state may produce different results (if the first write changed the state the second call reads).
Talpin and Jouvelot (Polymorphic Type, Region and Effect Inference, JFP 2(3), 1992) give the explicit write typing rule. For a reference and new value :
The effect accumulates in the caller’s effect set. Effect sets propagate upward: if calls and writes to , then ’s type records unless is locally allocated and not observable from outside .
Linear logic formulation: writing is — the old resource is consumed and the new resource (with updated content) is produced. This captures the destructive nature of writing precisely: the old value ceases to exist; the new value is a fresh linear resource. The separation logic mutation rule is the heap-model realization of this: the old resource is consumed and is produced.
The effect lattice orders effects: — writing implies reading (one must read before modifying). A function with only write effects still implicitly reads; effect type systems typically treat writes as subsuming reads.
Open questions
- Whether writing (exclusive modification) is the categorical dual of reading (shared observation) in some category of resource interactions — whether the categories of “operations with read effects” and “operations with write effects” are dual categories in a formal sense.
- Whether writes in the relational history correspond to updating the transfer nucleus — whether writing to a resource at history is the event that moves the resource from into at some later history .