exercise 52.1.
The branch derivations have the common output ∅: 𝖽𝗋𝖺𝗂𝗇:(𝑥:𝖥𝗂𝗅𝖾[𝗈𝗉𝖾𝗇])⊸∅=𝑃𝐷∈Ω𝑓:𝖥𝗂𝗅𝖾[𝗈𝗉𝖾𝗇]⊢𝖽𝗋𝖺𝗂𝗇(𝑓)⊣∅TS−Call and 𝖾𝗈𝖿∈{𝗈𝗉𝖾𝗇,𝖾𝗈𝖿}𝑋∅⊢𝗋𝖾𝗍𝗎𝗋𝗇⊣∅TS−Return𝑓:𝖥𝗂𝗅𝖾[𝖾𝗈𝖿]⊢𝖼𝗅𝗈𝗌𝖾 𝑓;𝗋𝖾𝗍𝗎𝗋𝗇⊣∅TS−Close Rule TS-Read places these two derivations over the displayed body 𝑃𝐷, deriving the declared input state and common empty output.
exercise 52.2.
After the first close the context is empty. The second command would require a decomposition containing 𝑓 :𝖥𝗂𝗅𝖾[𝑞] for 𝑞 ∈{𝗈𝗉𝖾𝗇,𝖾𝗈𝖿}. No such binding exists, so TS-Close cannot apply.
exercise 52.3.
Let 𝜂(𝑓) =𝜂(𝑔) =ℓ, 𝐻(ℓ) =𝗈𝗉𝖾𝗇, and give both variables type 𝖥𝗂𝗅𝖾[𝗈𝗉𝖾𝗇]. Closing 𝑓 removes 𝐻(ℓ), while a noninjective static account could retain 𝑔 :𝖥𝗂𝗅𝖾[𝗈𝗉𝖾𝗇]. The successor maps fail agreement at 𝑔; therefore the first conclusion of lemma 52.2 is false.
exercise 52.4.
Add Δ,𝑓:𝖥𝗂𝗅𝖾[𝗌𝗎𝗌𝗉𝖾𝗇𝖽𝖾𝖽]⊢𝑃⊣Δ′Δ,𝑓:𝖥𝗂𝗅𝖾[𝗈𝗉𝖾𝗇]⊢𝗌𝗎𝗌𝗉𝖾𝗇𝖽 𝑓;𝑃⊣Δ′TS−Suspend and the corresponding rule from suspended to open for resume. The dynamic rules update 𝐻(𝜂(𝑓)) to the target state. In each preservation case, agreement gives the source state, the heap update establishes the target state, and the typing premise supplies the continuation derivation.
exercise 52.5.
The only rule concluding a term headed by read is TS-Read. Its input context contains 𝑓 :𝖥𝗂𝗅𝖾[𝗈𝗉𝖾𝗇]. Finite-map equality cannot identify this binding with 𝑓 :𝖥𝗂𝗅𝖾[𝖾𝗈𝖿], so inversion yields no premise and no derivation.
exercise 52.6.
Read returns 𝖥𝗂𝗅𝖾[𝗈𝗉𝖾𝗇] ⊕𝖥𝗂𝗅𝖾[𝖾𝗈𝖿]. Sum elimination checks the left branch under the first summand and the right branch under the second, requiring both to produce the same output context Δ′. The scrutinee and each branch must consume its file component affinely; otherwise one branch can retain a stale copy. No term introduces a dual endpoint or a blocking communication, so session fidelity and deadlock freedom are absent.