Concurrent Separation Logic and Higher-Order Ghost State
Prerequisites. Direct starred prerequisites: Chapter 43, Chapter 44. No later core chapter depends on this route.
Suppose two threads execute the following compare-and-swap loop on one heap cell. Each load is locally safe, and each successful compare-and-swap changes only that cell.
The physical race
A HeapLang state is a finite map
Start with
Exercise 45.1 — The retrying schedule¶
Continue the displayed schedule until both calls return. Give the physical heap value and the multiset of return values after every successful CAS. Identify the only two physical steps that can represent abstract increments.
Referenced from 3 locations
Write
Proposition 45.1 — Disjoint parallel ownership is insufficient¶
Suppose a parallel-composition rule gives each thread a disjoint assertion and both calls require full ownership of the same cell. Its combined precondition is unsatisfiable.
Referenced from 3 locations
Proof of Proposition 45.1 — Disjoint parallel ownership is insufficient
Proof. Full ownership for the two premises requires
The disjoint-concurrency rule is useful when thread footprints are separate. For a shared counter, concurrent separation logic instead transfers the cell through a protected resource invariant. Iris makes the invariant itself a persistent assertion and controls each transfer by masks.
Assertions that may be forgotten or shared
The assertions below are Iris propositions. Separating conjunction retains its resource meaning from chapter 44; internal entailment is written
Definition 45.2 — Affine and persistent assertions¶
An assertion
Referenced from 2 locations
For example,
Exercise 45.2 — Classifying assertions¶
Classify
Referenced from 3 locations
Invariants and the selected update modality
An invariant is allocated in a namespace
Definition 45.3 — Fancy updates and invariant access¶
The fancy update from
Referenced from 2 locations
The missing namespace in the intermediate mask records that the invariant is open. Consequently the same invariant cannot be opened twice before its closing obligation is discharged. This side condition prevents the invalid calculation
Weakest preconditions connect the resource logic to HeapLang. The assertion
Exercise 45.3 — Why the mask shrinks¶
Let
Referenced from 3 locations
Ghost authority records an abstract counter
An invariant can hide the physical cell, but a client may need a stable fact about an abstract state. Ghost state supplies such facts without adding a runtime cell. We use a single authoritative-counter resource.
Definition 45.4 — Authoritative counter resource¶
Let
Referenced from 3 locations
Two calculations do the work. First,
A shared-counter invariant may now tie the physical and abstract states:
Proposition 45.5 — Fragment lower bound and successful update¶
Suppose an admissible atomic opening of
Referenced from 2 locations
Proof of Proposition 45.5 — Fragment lower bound and successful update
Proof. The opened invariant supplies
Exercise 45.4 — Simultaneous authority update¶
Prove (Auth-inc) from the compatibility definition. Then take
Referenced from 3 locations
Saving a proposition as ghost data
The counter algebra stores natural numbers. Higher-order protocols also need ghost names whose payload is itself an Iris proposition.
Definition 45.6 — Saved proposition¶
The assertion
Referenced from 2 locations
The later is not decorative. Without it, a proposition could inspect an unguarded ghost copy of itself and recreate the circularity that guarded recursion was introduced to prevent.
Proposition 45.7 — Saved-proposition agreement¶
saved_prop_unpersist can recover a fractional share from it.
Referenced from 2 locations
Proof of Proposition 45.7 — Saved-proposition agreement
Proof. The saved-proposition construction places saved_prop_agree, saved_prop_update, and persistence of discarded ownership. The exact source is iris/base_logic/lib/saved_prop.v:148–226 at the pinned artifact revision. ◻
One abstract increment inside a retry loop
The loop in (incr_ phy) is not one physical step. Its useful client interface is instead logically atomic. The quantifier in the precondition below binds
Definition 45.8 — Logically atomic increment contract¶
For a location
Referenced from 2 locations
Theorem 45.9 — The physical increment is logically atomic¶
For every HeapLang location
Referenced from 4 locations
Proof of Theorem 45.9 — The physical increment is logically atomic
Proof. This reconstructs incr_phy_spec from iris_heap_lang/lib/increment.v:22–41 at the pinned artifact revision. The proof uses Löb induction for the recursive retry. At each load it opens the client’s atomic update, obtains
After the pure arithmetic, bind the CAS as the next atomic expression and open the atomic update again at some current value
If the loaded value equals
, the success rule in (CAS) changes the physical cell from to . Use the commit continuation with ; it supplies the requested postcondition at return value . This CAS is the abstract transition .If the loaded value differs from
, the failure rule leaves unchanged. Use the abort continuation to reconstruct the atomic update, then apply the Löb hypothesis to the recursive call. This branch performs no abstract transition.
Every opening is closed around one physically atomic instruction. The two branches exhaust integer equality, so the contract is restored or committed at every CAS. ◻
The proof separates three clocks:
| level | event | established fact |
|---|---|---|
| physical | load or CAS in HeapLang | one reduction |
| abstract | successful CAS selected by the proof | exactly one transition |
| client | invariant allocation, two calls, parallel composition | a weakest precondition and, by adequacy, safety |
Logical atomicity therefore does not say that the entire call is one physical instruction. It says that a client may reason as if one abstract update occurred at the successful CAS.
Exercise 45.5 — Abort or commit¶
For each of load, successful CAS, and failed CAS, state the points-to assertion obtained when the atomic update is opened, the closing continuation used, and the atomic update returned to the proof. Explain why committing at the load would give the wrong return value after interference.
Referenced from 3 locations
The concrete client theorem
The pinned artifact next introduces an atomic-heap interface with an abstract load and CAS, defines a second value
Theorem 45.10 — Concrete two-call client safety¶
For every integer
Referenced from 5 locations
Proof of Theorem 45.10 — Concrete two-call client safety
Proof. The artifact proof is iris_heap_lang/lib/increment.v:178–196. It proceeds as follows. Consume incr_spec, establish the persistent assertion
The parallel-composition rule duplicates the persistent weakest precondition and assigns one copy to each thread. After both threads return, discard their results and prove
Corollary 45.11 — Adequacy boundary¶
In the pinned HeapLang instance, every thread in every reachable pool of the closed client is either a value or has a physical reduction. If the main thread returns, its return value satisfies
Proof of Corollary 45.11 — Adequacy boundary
Proof. Apply heap_adequacy from iris_heap_lang/adequacy.v:25–49 to theorem 45.10. For heap_adequacy. The resulting adequacy record supplies the postcondition for a completed main expression and the not-stuck clause for every thread in every reachable pool. ◻
The corollary is a safety statement. It does not prove that either retry loop terminates, that the scheduler is fair, that the final counter is
Exercise 45.6 — Read the exact client guarantee¶
For each of termination, absence of stuck reachable threads, final counter value
Referenced from 3 locations
A paired operation is a different shape
An exchanger waits for two offers and gives each caller the other’s value. A single matched pair has the abstract transition
Proposition 45.12 — No independent deterministic exchanger steps¶
Assume an offer has no hidden partner parameter and that each call is modeled by an independent deterministic unary function
Referenced from 3 locations
Proof of Proposition 45.12 — No independent deterministic exchanger steps
Proof. Fix
This contrast does not import a generalized linearizability theorem. The chapter has established the pinned Iris logically atomic specifications and their client-safety consequence only. It has not introduced module saturation, possibility sets, liveness, fairness, or a weak-memory model.
Exact source and evidence boundary
The invariant, fancy-update, weakest-precondition, and authoritative-counter rules used above follow the official Iris lecture notes: persistently in Section 7; invariants and the double-opening obstruction in Sections 8.1–8.2; the authoritative counter construction in Section 8.7; and weakest preconditions and fancy updates in Sections 14.1–14.3 [BB23]. The resource-algebra and invariant construction is proved semantically in Sections 3–8 of [JKJ^+18]; the earlier monoids-and-invariants paper gives the concurrent-separation-logic origin of the same separation of resources and protocols [JSS^+15]. O’Hearn’s Section 3 isolates disjoint concurrency and Sections 4–5 introduce resource-mediated interaction and its proof rules [O'H07]. Brookes gives the dynamic trace semantics in Section 4 and semantic equivalence in Section 5, presents the proof system in Section 8, proves soundness in Section 12, and derives absence of races in Section 13 [Bro07]. Those results explain proposition 45.1; their command language and trace-validity theorem are not substituted for HeapLang or Iris adequacy.
The program theorems are checked against the pinned Iris artifact at commit 832a5cd28048a8af53a7eddb1f4d4bb5c002efe0. The exact ledger is:
.-
Declaration
incr_phyis atiris_heap_lang/lib/increment.v:15–20. - Physical atomic contract.
-
Declaration
incr_phy_specand its complete proof are in the same file at lines 22–41. - Atomic-heap bridge.
-
Declarations
incrandincr_specare in the same file at lines 51–57 and 104–127. - Concrete client.
-
Declaration
incr_clientis in the same file at lines 170–173;incr_client_safeand its proof are at lines 175–196. - Invariant interface.
-
Persistence, allocation, allocation-and-opening, and access are in
iris/base_logic/lib/invariants.v:97–133; the displayed access rule isinv_accat lines 129–133. - Higher-order ghost payload.
-
Definition
saved_prop_own, persistence, allocation, agreement, and update are iniris/base_logic/lib/saved_prop.v:148–226; agreement is at lines 201–203 and full update at lines 216–218. - Adequacy.
-
Declarations
adequateandadequate_tp_safeare iniris/program_logic/, fileadequacy.v, lines 181–215. HeapLang’sheap_adequacyis iniris_heap_lang/adequacy.v:25–49.
The file iris_heap_lang/lib/increment.v has SHA-256 digest 6d18f23c064d67b8ceaf6241516f43287db3c6a181ae856d2b787003920d3276. The proof reconstructions preserve the exact program names, masks, preconditions, postconditions, and theorem boundaries. The Kappa supplement checks a finite operational abstraction of their branch structure; it is not a replacement for the Rocq proof.
Suggested first pass.
Begin with exercise 45.7, exercise 45.8, exercise 45.9; then use the exchanger problem and executable project to test the boundary. No problem in this optional seminar is a prerequisite for a later chapter.
Exercise 45.7 — Reconstructing the atomic proof¶
Write the proof state of theorem 45.9 immediately before the load, immediately after closing the load, and in both CAS branches. At each state record the current mask, the points-to assertion, the abort continuation, the commit continuation, and whether an abstract transition has occurred.
Referenced from 4 locations
Exercise 45.8 — A lower-bound client¶
Put (Counter-inv) under a namespace and give a client a fragment
Referenced from 4 locations
Exercise 45.9 — Checking the pinned boundary¶
Use the exact ledger to locate incr_phy_spec, incr_spec, and incr_client_safe. Record the program, mask, precondition, return value, and postcondition of each theorem. Explain why replacing incr by incr_phy in the client theorem is not justified by textual similarity of the two recursive values.
Referenced from 4 locations
Exercise 45.10 — The exchanger boundary¶
Extend proposition 45.12 to nondeterministic independent relations. Give a relation broad enough to contain every possible partner, then explain why membership alone no longer guarantees that two simultaneous returns are paired with one another. State the extra shared-state relation that a useful atomic specification must retain.
Referenced from 3 locations
Exercise 45.11 — Increment trace checker¶
Practical project.iris-increment-trace-checker Implement the finite physical machine from section 45.1 in Kappa. A thread is ready, has loaded an integer, or has returned an integer. A successful CAS must increment both the physical counter and an abstract commit count; a failed CAS must change neither and must return the thread to ready. Check an uncontended call, the two possible winning orders, a failed CAS followed by retry, a load without commit, rejection of an inconsistent authority fragment, rejection of a double-opened namespace, and the paired exchanger transition. Print the eight case results followed by
All 8 Chapter 45 corpus cases passed.