Lectures onType Theory
ch:compositional-linearizability: ch:compositional-linearizability
appendix sectionsolutions

ch:compositional-linearizability: ch:compositional-linearizability

Exercise 87.1.

After 0:call(inc), the active map records thread 0’s operation. Since the frozen counter has one thread and no internal visible operation, the only visible length-two prefix is 0:call(inc);0:ret(inc,1). The proposed return-2 prefix passes CL-Seq-ret’s active-map premises but fails the counter state relation: from state 0, the increment response is 1, not 2. Thus the rejecting premise is 0StepVctr(0:ret(inc,2))s.

Exercise 87.2.

For the left unit, expand substidM(Vis(m,k)). The visible substitution clause and local bind equations give bind(Vis(m,Return),λx.substidM(k(x)))PVis(m,λx.substidM(k(x))). Pointwise coinduction on k(x) identifies this with Vis(m,k). For the right unit, substM(Vis(m,Return)) expands to bind(M(m),Return), and coinduction on M(m) proves the right-unit law.

These module laws do not imply VidM=V. With two threads, K(V) may expose overlay calls 0:call(m0);1:call(m1) before either underlay return is reflected to the overlay. Those open brackets are precisely the additional states used by linearizability; an atomic V need not contain that overlay trace.

Exercise 87.3.

There are two total orders. If thread 0’s operation comes first, a deterministic atomic exchange must choose thread 0’s return before thread 1’s offer is present, so it cannot return 4. If thread 1 comes first, its operation must choose its return before thread 0’s offer is present, so it cannot return 2. Both orders contradict the four-event history. The paired set class containing both operations sees offers 2 and 4 together and returns (4,2), so the obstruction is atomic ordering rather than sequential consistency of either thread.

Exercise 87.4.

The exchanger class C={0:exch(2)/4,1:exch(4)/2} becomes two overlay calls, one underlay transition labelled by C, and two overlay returns. Each thread state holds one active operation, and the paired transition fixes both return values. Conversely, grouping the identity-module brackets around that one underlay transition recovers exactly C.

If C also contains a second operation of thread 0, the forward construction would have to store two active operations at q(0). The thread state grammar in definition 87.3 stores at most one Cont or UCall package. Hence the at-most-one-operation premise of theorem 87.9 is necessary for this construction.

Exercise 87.5.

Project a tensor trace twice. Retain left-tagged events in one projection and right-tagged events in the other. Each projection deletes only events carrying the other register tag. It therefore preserves retained call/return order and the completion decision for pending calls. The shared active map supplies the missing cross-tag fact: one thread cannot have simultaneous left and right operations.

Linearize the two projections in K(V1) and K(V2). Shuffle those traces subject to the original cross-tag order of every thread. The component orders and the cross-tag per-thread orders are compatible because each linearization preserves the corresponding projected thread order. Left events change only the first state, and right events only the second, so the shuffle lies in K(V1V2).

Conversely, tensor an arbitrary left trace with the empty right trace over the same thread set and project its assumed tensor linearization. Exchanging the tagged projections gives the right result.

Exercise 87.6.

Let thread 0 invoke ws(3), then let threads 1 and 2 invoke ws(5) and ws(2) while thread 0 remains active. Let thread 0 return {3,5} before thread 2 returns {3,5,2}. No single atomic point for thread 0 sees exactly its reported overlap while also ordering all three complete operations. An interval presentation uses the classes I0={inv0(3)},I1={inv1(5),resp0({3,5})},I2={inv2(2),resp1,resp2}. Thread 0 spans I0 and I1; the exercise therefore lacks the premise that each operation is represented by one set class. The restricted set theorem does not apply.

Search the book

Type to search the local edition.