Lectures onType Theory
ch:linearizability-hoare-logic: ch:linearizability-hoare-logic
appendix sectionsolutions

ch:linearizability-hoare-logic: ch:linearizability-hoare-logic

Exercise 88.1.

For return 2, the target transition is [2,1]deq/2[1]. The state [1,2] has only a return-1 dequeue transition, so it is rejected. The inhabited successor predicate is therefore the singleton state [1].

Exercise 88.2.

For the empty predicate Q, the assertion “every σ satisfying Q has a predecessor” is true because there is no such σ. The assertion σ.Q(σ) is false. Deleting that existential would let an impossible concrete return update every precondition to Q and then discharge every later universal obligation by vacuity. The nonemptiness clause blocks exactly this derivation.

Exercise 88.3.

Let Pi(s,P) mean that the lock owner in s is none or i. Suppose an Ri step leaves owner i unchanged and may change none only to none. From owner none, the result is none and Pi holds; from owner i, the result is i and Pi holds. These two cases prove stability. If the rely restriction is deleted, another thread j may change owner i to owner j. The initial state satisfies Pi and the final state does not, so that step is a counterexample.

Exercise 88.4.

Choose σ0 with Y(σ0). For each σ satisfying Y, define τσ by (τσ)S:=σS,(τσ)C(j):={CallIdle,j=i,σC(j),ji,(τσ)R(j):={RetIdle,j=i,σR(j),ji. The hypotheses on σ give the two pre-consumption clauses of the consumption relation in definition 88.6; the definitions give its other five clauses. Hence ConsumeSeti,m,v(Y)(τσ0), which proves inhabitation. For any consumed τ, its witness σ and the seven conjuncts of Consumei,m,v give idle entries at i, equality τS=σS, and τC(j)=σC(j) and τR(j)=σR(j) for every ji. These are exactly the reset-map facts requested; no relational postcondition or guarantee has been postulated.

Exercise 88.5.

In state UCall(m,u,k), every retained possibility has the overlay call for m recorded and the call-commit postcondition for u. When the underlay returns v, the return-commit premise of LHL-Vis advances to an inhabited predicate in which thread i records the target return and every ji retains its call and return components. The concrete thread state becomes Cont(m,k(v)). Relational composition of the call and return postconditions supplies the precondition of the continuation judgment for k(v). Hence the resulting state satisfies the continuation case of the soundness invariant.

Exercise 88.6.

Clauses one and two of I permit a predicate containing only the reachable possibility [2,1] after the two enqueues: it has the correct concrete prefix and was reached by compatible updates. Without clause three, the equally compatible state [1,2] need not be retained. When the concrete dequeue returns 1, [2,1] has no matching target successor, so update nonemptiness fails. Clause three requires every compatible target continuation to have a represented prefix and therefore forces [1,2] to remain until the return is observed. The weakened invariant fails; the completeness theorem, which uses all three clauses, is unaffected.

Search the book

Type to search the local edition.