exercise 45.1.
After thread 1 succeeds, the physical value is 6 and the return multiset is {5}. Thread 2’s stale CAS fails, so neither quantity changes. It loads 6, successfully compares and swaps 6 for 7, and returns 6. The final physical value is 7, and the return multiset is {5,6}. The successful CAS steps, and only those steps, change the physical counter and may represent the abstract transitions 5 ⟶𝖺6 and 6 ⟶𝖺7.
exercise 45.2.
In the affine instance, every listed assertion is affine. The assertions 𝖳𝗋𝗎𝖾, ◻𝑃, and 𝗂𝗇𝗏𝑁(𝑃) are persistent. Exclusive points-to ℓ ↦𝗁𝑣 is not persistent: duplicating it would produce two full owners of the same physical cell and contradict (Pt-exclusive). The persistently modality makes its body duplicable by construction. A named invariant is duplicable as a controlled access capability; its body is not duplicated.
exercise 45.3.
The first opening begins at 𝐸 with ↑𝑁 ⊆𝐸 and leaves the mask 𝐸 ∖ ↑𝑁. A second use would require ↑𝑁 ⊆𝐸 ∖ ↑𝑁, which is false. The first closing continuation consumes ▹(ℓ ↦𝗁5) and changes the mask from 𝐸 ∖ ↑𝑁 back to 𝐸. The premise ↑𝑁 ⊆𝐸 then holds again, so a later opening is admissible. At no point are two copies of the points-to assertion available.
exercise 45.4.
A frame compatible with ∙𝑚 ⋅ ∘𝑛 cannot contain a second authority; write its largest fragment index as 𝑘. Validity gives 𝑘 ≤𝑚. After the simultaneous update, both 𝑘 ≤𝑚 +1 and 𝑛 +1 ≤𝑚 +1, so the maximum fragment index is compatible with the new authority. Hence the update preserves every frame.
For the rejected update, take 𝑚 =𝑛 and the empty additional frame. Its target is ∙𝑚 ⋅ ∘(𝑚 +1) =(𝑚,𝑚 +1), which is invalid because 𝑚 +1 ≰𝑚. Thus even the empty frame witnesses failure.
exercise 45.5.
At the load, opening supplies ℓ ↦𝗁𝑣; loading preserves it, so the abort continuation consumes the same assertion and restores the atomic update. At CAS, opening supplies the current ℓ ↦𝗁𝑤. When the comparison succeeds, CAS produces ℓ ↦𝗁(𝑤 +1), and the commit continuation produces the postcondition at return value 𝑤. When it fails, CAS preserves ℓ ↦𝗁𝑤, and abort restores the atomic update for the recursive call. Committing at load would select 𝑣 before the successful CAS; another thread could change the cell to 𝑤 ≠𝑣, so the eventual returned old value would be 𝑤, not the prematurely committed 𝑣.
exercise 45.6.
Absence of stuck reachable threads follows from the not-stuck clause of corollary 45.11. None of the other four claims follows. The weakest precondition is partial, so it gives no termination or fairness. Its postcondition is 𝖳𝗋𝗎𝖾, so it records neither the final cell nor the returned values. The semantics is HeapLang’s interleaving semantics, not a weak-memory or fairness model.
exercise 45.7.
Before load, the atomic update is available at the empty client mask and no points-to resource is owned by the loop proof. Opening it yields ℓ ↦𝗁𝑣, an abort continuation returning the same assertion, and a commit continuation expecting ℓ ↦𝗁(𝑣 +1). The load preserves the points-to assertion; abort closes the update, restores the empty mask, and no abstract transition has occurred.
Before CAS the update is opened afresh at current value 𝑤. Success yields ℓ ↦𝗁(𝑤 +1); commit closes the update, restores the mask, produces the client postcondition at return 𝑤, and records 𝑤 ⟶𝖺𝑤 +1. Failure yields ℓ ↦𝗁𝑤; abort closes the update and restores the mask for the Löb hypothesis, with no abstract transition.
exercise 45.8.
Opening the invariant yields an 𝑚 with ℓ ↦𝗁𝑚 ∗𝗈𝗐𝗇𝛾( ∙𝑚). Combining the authority with the client’s 𝗈𝗐𝗇𝛾( ∘𝑛) is valid, so (Auth-agree) gives 𝑛 ≤𝑚. A successful CAS changes the physical assertion to ℓ ↦𝗁(𝑚 +1); simultaneously use (Auth-inc) to obtain 𝗈𝗐𝗇𝛾( ∙(𝑚 +1)) ∗𝗈𝗐𝗇𝛾( ∘(𝑛 +1)). Return the new points-to assertion and authority to the invariant. The client retains the fragment 𝗈𝗐𝗇𝛾( ∘(𝑛 +1)).
exercise 45.9.
In the pinned increment.v, lines 22–23 state incr_phy_spec for incr_phy at the empty mask, with exclusive physical points-to 𝑣, post-state 𝑣 +1, and return 𝑣. Lines 104–108 state incr_spec for the atomic-heap incr at the atomic-heap namespace, conditional on heap_inv, with the corresponding abstract points-to contract. Lines 175–177 state incr_client_safe: heap_inv entails the default-mask weakest precondition for incr_client, whose postcondition is 𝖳𝗋𝗎𝖾. The client definition on lines 170–173 calls incr. Program equality or a refinement connecting that interface program to incr_phy is not among these theorem premises, so substituting the latter program is not licensed.
exercise 45.10.
The independent relation 𝑅(𝑎,𝑟) can contain every pair of values, so it permits 𝑎 to return any possible partner. Two independent memberships 𝑅(𝑎,𝑟1) and 𝑅(𝑏,𝑟2) do not imply 𝑟1 =𝑏 and 𝑟2 =𝑎; they may choose unrelated values. A useful specification must retain a shared matching relation whose one transition consumes the two pending offers and simultaneously establishes both cross-equalities. This is the paired transition in (Exchange), not two independent choices.