exercise 46.1.
The complete state trace is commandL𝑏’s stateinitial𝜖𝖮(𝐴)𝖻𝖾𝗀𝗂𝗇𝖲𝛼𝑏𝛼𝖲{𝛼}(𝐴)𝖻𝖾𝗀𝗂𝗇𝖲𝛽𝑏𝛼𝛽𝖲{𝛼,𝛽}(𝐴)𝗋𝖾𝖺𝖽𝑏𝛼𝛽𝖲{𝛼,𝛽}(𝐴)𝖾𝗇𝖽𝖲𝛽𝑏𝛼𝖲{𝛼}(𝐴)𝗋𝖾𝖺𝖽𝑏𝛼𝖲{𝛼}(𝐴)𝖾𝗇𝖽𝖲𝛼𝑏𝜖𝖮(𝐴). The steps use Share-begin, Share-nest, Read, Share-end, Read, and Share-return, in that order. Freshness holds because 𝛼 ≠𝛽, and each end command names the top lifetime.
exercise 46.2.
Use Ex-begin at fresh 𝛼, Ex-reborrow at fresh 𝛽, Write with any closed 𝑣 :𝐴, Ex-pop at 𝛽, and Ex-return at 𝛼. This derives (𝜖,𝖮(𝐴))⇒(𝛼,𝖷𝛼(𝐴))⇒(𝛼𝛽,𝖷𝛼𝛽(𝐴))⇒(𝛼𝛽,𝖷𝛼𝛽(𝐴))⇒(𝛼,𝖷𝛼(𝐴))⇒(𝜖,𝖮(𝐴)). No sharing rule has an exclusive state in its premise. Ending 𝛼 while 𝛽 is active matches neither Ex-pop, whose conclusion must remove the top suffix 𝛽, nor Ex-return, whose premise has a singleton exclusive stack.
exercise 46.3.
With fresh 𝑘, Move concludes L;Ω,ℎ:𝖮(𝐴)⊢𝗆𝗈𝗏𝖾 ℎ 𝖺𝗌 𝑘⇒L;Ω,ℎ:𝖣,𝑘:𝖮(𝐴). Inverting Read and Write requires the named state to belong to their displayed live-state sets; 𝖣 belongs to neither. Inverting Drop requires ℎ :𝖮(𝐴), also absent. The destination has exactly that owned state, so Read applies to 𝑘.
exercise 46.4.
Activating [𝑏 :𝜎]𝑛𝖲 gives the borrow a kind at region level 𝑛. Returning that borrow would therefore require both 𝖫𝑛 ≤kind(𝜏) and the Region premise kind(𝜏) ≤𝖫𝑛−1. The stratified kind order does not have 𝖫𝑛 ≤𝖫𝑛−1, so the premises cannot be solved. A closure containing the borrow has a kind at least as restrictive as the captured binding; it produces the same incompatible inequalities. The argument uses the Affe kind level, not lexical scope inspection of result syntax.
exercise 46.5.
First take Γ =𝑎 :𝖠𝗋𝗋𝖺𝗒 𝐴, with 𝑎 unique and consumed by the update. There is no other root for the array, so overwriting its representation is observationally equivalent to the pure replacement. Second take Γ =𝑎 :𝖠𝗋𝗋𝖺𝗒 𝐴,𝑏 :𝖠𝗋𝗋𝖺𝗒 𝐴, allow 𝑎 and 𝑏 to denote the same array, consume 𝑎, and leave 𝑏 unused. The path is affine because neither handle is used twice. It does not establish absence of the alias 𝑏; a surrounding context or later lazy evaluation could still observe that value. In-place replacement needs the first environment’s uniqueness fact, not only a use count.
exercise 46.6.
Borrow 𝑚 :𝖬𝗎𝗍𝛼𝑎 at 𝛽 to obtain 𝑚′:𝖬𝗎𝗍𝛼∧𝛽𝑎⊗ℓ𝛽:𝖫𝖾𝗇𝖽𝛽(𝖬𝗎𝗍𝛼𝑎). Ending 𝛽 consumes 𝖭𝗈𝗐𝛽 and returns the persistent evidence 𝑒𝛽 :𝖤𝗇𝖽𝛽. Reclamation consumes the linear lender ℓ𝛽, uses 𝑒𝛽, and recovers 𝑚. Ending 𝛼 similarly consumes 𝖭𝗈𝗐𝛼. The outer reclamation consumes the outer linear lender and uses 𝖤𝗇𝖽𝛼 to recover the original owner. The two mutable borrowers have already been consumed by their respective scope computations, so no borrower survives either reclamation.
exercise 46.7.
Denotational strong confluence and leak freedom of a safe final mutative configuration are proved. Progress of safe mutative configurations is conjectured. Preservation of safety and behavior uniqueness are conditional on the association-bisimulation conjecture; the latter also uses the proved denotational diamond. Strong confluence of the mutative semantics is unsupported: neither the published theorem nor the stated conditional corollary has that conclusion.
exercise 46.8.
The observer can see every deque empty after the delayed worker has removed a task but before it publishes the two children. An emptiness test then reports termination although two tasks will shortly become available. With an outstanding-task counter, removing the parent does not make the count zero: the parent remains outstanding until publication accounts for its children, so the observer cannot finish during the gap. The repair does not prove that the core borrowing API is pure, and it does not establish the association bisimulation conjecture.
exercise 46.9.
Let the initial states be 𝑏1 :𝖮(𝐴),𝑏2 :𝖮(𝐵). The command sequence 𝖻𝖾𝗀𝗂𝗇𝖲𝛼𝑏1;𝖻𝖾𝗀𝗂𝗇𝖲𝛽𝑏1;𝗆𝗈𝗏𝖾 𝑏2 𝖺𝗌 𝑘;𝖾𝗇𝖽𝖲𝛽𝑏1;𝖾𝗇𝖽𝖲𝛼𝑏1;𝖻𝖾𝗀𝗂𝗇𝖷𝛾𝑏1;𝖾𝗇𝖽𝖷𝛾𝑏1;𝖽𝗋𝗈𝗉 𝑏1. produces lifetime stacks 𝜖,𝛼,𝛼𝛽,𝛼𝛽,𝛼,𝜖,𝛾,𝜖,𝜖. The states of 𝑏1 are respectively 𝖮,𝖲{𝛼},𝖲{𝛼,𝛽},𝖲{𝛼,𝛽},𝖲{𝛼},𝖮,𝖷𝛾,𝖮,𝖣; 𝑏2 changes from 𝖮(𝐵) to 𝖣 at the move and fresh 𝑘 receives 𝖮(𝐵). The runtime makes exactly the same mode changes and moves the 𝐵-payload, so agreement holds after each command. Replacing 𝖾𝗇𝖽𝖲𝛽𝑏1 by 𝖾𝗇𝖽𝖲𝛼𝑏1 fails because 𝛼 is not the top lifetime.
exercise 46.10.
Without destination freshness, move into an existing owned 𝑘 has two candidate payloads for one target entry; the unique-result clause of lemma 46.4 fails. Without the top condition, ending the outer lifetime of 𝖷𝛼𝛽(𝐴) can leave a runtime inner view whose static stack no longer has its enclosing scope, breaking agreement and the final no-dangling argument. Without Affe’s result-kind premise, {|&𝖲𝑥|}𝑛𝑥,𝖲 may return the region-level borrow; the owner can then resume while the escaped borrow remains reachable, so the source containment step used in the nonescape argument fails.
exercise 46.11.
Suppose 𝑀 ⋈𝐴𝐷 and 𝑀 ⟼𝗆𝑀′. The forward half of the conjectured bisimulation supplies 𝐷′ with 𝐷 ⟼𝖽∗𝐷′ and 𝑀′ ⋈𝐴𝐷′. The last judgment is the definition of safety for 𝑀′, so safety is preserved conditionally.
For behavior uniqueness, mere existence of associations permits one mutative state to associate with unrelated denotational states, or two mutative outcomes to associate with one state without being equal. The diamond joins denotational reductions only. Bisimulation is needed to transport each mutative execution into that diagram and transport the joined observations back; the result remains conditional because that bisimulation is conjectural.
exercise 46.12.
One possible five-row separation is invariantrepresentative judgmentaffine use𝑎:𝐴⊢𝑒:𝐵 with no contraction on 𝑎uniquenessΓ⊢𝑎:𝐴∙ownershipΩ(𝑎)=𝖮(𝐴)exclusive borrowΩ(𝑎)=𝖷¯𝛼𝛽(𝐴)separation𝜎,ℎ⊧𝑎↦𝑣∗𝑅. Affine use separates a one-use program from one that duplicates 𝑎. Uniqueness separates an in-place pure update from the same update with a live alias. Ownership separates transfer/drop authority from a read-only handle. An exclusive borrow separates mutation through the top view from an attempted simultaneous shared view. The points-to assertion separates a command with the owned heap cell in its footprint from a command whose precondition lacks that cell. These judgments are not translations of one another.
exercise 47.1.
The sharing let has nodes 𝑐 =𝐶 and 𝑝 =𝑃(𝑐,𝑐), rooted at 𝑝. Counting the root edge, 𝑝 has one incoming reference and 𝑐 has two. The copied expression has 𝑐1 =𝐶, 𝑐2 =𝐶, and 𝑝 =𝑃(𝑐1,𝑐2). Each of the three nodes has one incoming reference. Node renaming cannot turn one two-referenced node into two nodes, so the rooted graphs are not isomorphic.
exercise 47.2.
Give 𝑎 type 𝛿. The 𝐶-equation gives 𝛼 =𝛿 and the bound root type 𝑇𝛿. The two argument positions of 𝑃 give 𝛽 =𝑇𝛿 twice; the sharing interface is the equation equating the type of each occurrence of 𝑥 with that single bound-root type. The result is 𝑈(𝑇𝛿). Up to renaming 𝛿, this solution is most general.
exercise 47.3.
Correcting a unique list of unique elements changes only the outer spine attribute, giving a shared list whose element attribute remains unique. Such a type need not be the result of any constructor scheme; it is the temporary shared view used at contraction. Correcting a unique list of already shared elements likewise changes only the spine and leaves the elements shared.
exercise 47.4.
Type 𝐶(𝑎) at 𝜎, bind 𝑥 :𝜎, and present the body first with two variables 𝑦 :[𝜎],𝑧 :[𝜎]. The 𝑃-scheme types 𝑃(𝑦,𝑧); Contr substitutes 𝑥 for both variables, and Share joins the binding. In the denotation, the 𝐶-root has two incoming 𝑃-edges, so definition 47.10 checks its corrected type. Assigning both edges the uncorrected unique type would assert one incoming reference while displaying two.
exercise 47.5.
For a unique spine and shared elements take 𝑏 =𝗎, 𝑎 =𝗆. The scheme condition is the allowed edge 𝗎 ≤𝗆. For a shared spine and unique elements it becomes 𝗆 ≤𝗎, the unique forbidden edge. Reflexive-transitive closure therefore accepts the first problem and rejects the second.
exercise 47.6.
Consume the cells headed by 3,1,4,2 in order. Once the pivot cell is removed, the tail reference is the sole incoming reference to the next spine cell. Start with empty accumulators. Relink the 1-cell onto the low accumulator, the 4-cell onto the high accumulator, and the 2-cell onto the low accumulator. The accumulators are then 2 ::1 ::[] and 4 ::[]; reversing the low accumulator gives 1 ::2 ::[]. Each relink has one incoming spine reference and retains a tail edge at the list-tail type. With a shared input spine, the first matched cell already lacks the unique outer attribute, so condition 2 of definition 47.18 blocks the first relink.
exercise 47.7.
Let 𝜂 send each pattern-interface node to its matched host node. Rule typing gives the same attributed root type on the left and right interfaces under 𝜂. For an interface node whose reference count remains one, its original local inequality is unchanged. If the right side introduces a second reference, its rule derivation uses contraction, so both outgoing positions demand [𝑇𝐺(𝑛)]. Internal replacement equations are typed by the right-side rule derivation; host equations are unchanged. Reconstructing a source expression may choose different lets or a different presentation of a cycle, so completeness yields an expression with the same graph denotation as the parser’s reduct, not necessarily the same syntax.
exercise 47.8.
Enumerate first-order instances of the principal conventional solution in increasing substitution size. For each instance, generate the finite attribute graph, compute its transitive closure, and report the symbolic attribution exactly when the forbidden edge is absent. Exact conventional generation proves the first phase sound; lemma 47.15 and theorem 47.16 prove every reported attribution sound. The conventional principal theorem factors known typings through one solution, but it supplies neither a finite bound on instances nor a decision that no attributable instance exists. Unrestricted enumeration is therefore only semidecidable.
exercise 48.1.
𝑥 overlaps each of 𝑥.0,𝑥.1,𝑥.0.1, with 𝑥 the shorter prefix. 𝑥.0 overlaps 𝑥.0.1, with 𝑥.0 the shorter prefix. 𝑥.0 is separated from 𝑥.1, and 𝑥.1 is separated from 𝑥.0.1. These are all six unordered pairs.
exercise 48.2.
After moving 𝑥.0.1, the overlapping paths 𝑥, 𝑥.0, and 𝑥.0.1 are unreadable. The separated siblings 𝑥.0.0 and 𝑥.1 remain readable. Assigning a fresh box to 𝑥.0.1 removes the only partial marker, so all five listed paths are readable again.
exercise 48.3.
At block exit the local binding 𝑦 is removed, so the ordinary output environment can be empty and hence vacuously well formed. The result type is nevertheless &𝑦. Adding fresh 𝛾 :⟨&𝑦⟩ℓ makes well-formedness inspect that borrow; its referent is absent after the block, so the judgment fails.
exercise 48.4.
For 𝜏1, the dependency graph is 𝑥 →𝑦 →𝑧. One ranking is 𝜙(𝑥) =2,𝜙(𝑦) =1,𝜙(𝑧) =0. For 𝜏2, the graph contains 𝑥 →𝑦 →𝑥, so the inequalities would require both 𝜙(𝑥) >𝜙(𝑦) and 𝜙(𝑦) >𝜙(𝑥). Lookup beginning at ∗𝑥 follows the borrow to 𝑦, then the borrow back to 𝑥; the obligation rooted at 𝑥 repeats.
exercise 48.5.
The whole place 𝑥 overlaps both loans. Its shared use conflicts with the unique 𝑥.1-loan; its unique use conflicts with both. At 𝑥.0, a shared use is permitted because the only overlapping loan is shared, while a unique use is rejected. At 𝑥.1, both shared and unique uses conflict with the overlapping unique loan.
exercise 48.6.
With empty Θ, 𝑟 occurs in no stored type, so collection replaces its loan set by ∅. When Θ contains a component type mentioning 𝑟, collection retains {𝗎𝗇𝗂𝗊 𝑥}. Tuple construction needs the latter result: the already evaluated first component still holds the unique borrow, so the attempted second unique borrow must be rejected.
exercise 48.7.
For move, safe abstraction locates a uniquely owned value; runtime destructive read writes undefined and typing strikes the same owner type. For mutable borrow, ownership safety establishes absence of an overlapping loan before the runtime creates a location value; the anonymous result binding records its referent. For block exit, runtime recursively drops the latest frame and typing removes the same lexical bindings; borrow invariance rules out a returned reference to any removed local. None of these frozen-core cases has a projection rule, so they do not prove the named-field extension.
exercise 48.8.
Type the first sequence component from Γ to Γ1. The second component is typed from 𝗀𝖼-𝗅𝗈𝖺𝗇𝗌Θ(Γ1), not directly from Γ1. A reduction inside the first component preserves the same continuation Θ, so a region mentioned by an already evaluated component cannot be cleared. Oxide’s value-preservation-under-drop/collection lemma re-establishes the typing of those temporaries after collection. Apply the induction hypothesis to the stepping component, then rebuild the sequence rule with the preserved Θ, rewritten result type, and residual output union.