exercise 23.1.
Rule C-UnkR gives 𝟐 ∼𝖼?, and C-UnkL gives ? ∼𝖼ℕ. In a derivation of 𝟐 ∼𝖼ℕ, the last rule cannot be an unknown rule because neither endpoint is ?; it cannot be a base rule because the two base constructors differ; and it cannot be C-Arr. Hence no such derivation exists. An attempted proof of transitivity has no case combining C-UnkR with C-UnkL: their middle unknown supplies no equality between the two outside constructors.
exercise 23.2.
For the inner application, 𝑔 :? matches ? →? and 0 :ℕ is consistent with ?. Thus 𝑔:?⊢(𝑔0)ℓ1:?,⋅⊢𝜆𝑔:?.(𝑔0)ℓ1:?→?. The argument has type ℕ →ℕ, which is consistent with the outer domain ?, so the complete term has type ? by G-App. Replacing 𝑛 :ℕ by 𝑛 :𝟐 changes the argument type to 𝟐 →𝟐 but does not reject the program: C-UnkR still gives 𝟐 →𝟐 ∼𝖼?. That application-consistency premise is where the comparison is postponed.
exercise 23.3.
The first elaboration is ⋅⊢((𝜆𝑥:?.𝑥)0)ℓ1⇝(⟨?→?⇐?→?⟩ℓ1,𝑓(𝜆𝑥:?.𝑥))(⟨?⇐ℕ⟩ℓ1,𝑎0):?. For the second term put 𝑢:=(⟨?→?⇐?→?⟩ℓ2,𝑓(𝜆𝑦:?.𝑦))(⟨?⇐ℕ⟩ℓ2,𝑎0). The inner instance of I-App gives 𝑢 :?. The outer instance gives the complete target (⟨𝟐→𝟐⇐𝟐→𝟐⟩ℓ3,𝑓(𝜆𝑥:𝟐.𝑥))(⟨𝟐⇐?⟩ℓ3,𝑎𝑢):𝟐. All four casts remain present; the two arrow identities are not optimized away.
exercise 23.4.
Since 𝗀𝗇𝖽(ℕ →ℕ) =? →?, E-Ground gives ⟨?⇐ℕ→ℕ⟩𝑝𝑣⟼⟨?⇐?→?⟩𝑝(⟨?→?⇐ℕ→ℕ⟩𝑝𝑣). The outer term is an injection tagged ? →?, and its payload is the displayed function wrapper. Both forms occur in the value grammar, so no further reduction is required to obtain a value.
exercise 23.5.
Direct injection of every non-unknown 𝐴 would require the value clause ⟨? ⇐𝐴⟩𝑝𝑣 rather than the clause restricted to 𝐺. Projection would likewise compare arbitrary stored and demanded type expressions: ⟨𝐵⇐?⟩𝑞(⟨?⇐𝐴⟩𝑝𝑣) would return 𝑣 when 𝐴 =𝐵 and blame otherwise. Canonical forms at ? would then expose an arbitrary syntactic type tag 𝐴, not one of the three ground tags. In particular, the present proof that all dynamic functions carry the single tag ? →? would no longer apply; this mutation changes both the value invariant and the reduction table.
exercise 23.10.
Inversion of the redex typing supplies 𝑣 :𝐴1 →𝐵1, 𝑤 :𝐴2, 𝐴1 ∼𝖼𝐴2, and 𝐵1 ∼𝖼𝐵2. The reduct has the tree Put 𝑢=𝑣(⟨𝐴1⇐𝐴2⟩¯𝑝𝑤). The two stages are 𝑣:𝐴1→𝐵1𝑤:𝐴2𝐴2∼𝖼𝐴1⟨𝐴1⇐𝐴2⟩¯𝑝𝑤:𝐴1T−Cast𝑢:𝐵1T−App. Then 𝑢:𝐵1𝐵1∼𝖼𝐵2⟨𝐵2⇐𝐵1⟩𝑝𝑢:𝐵2T−Cast. If the domain cast is reversed to ⟨𝐴2 ⇐𝐴1⟩¯𝑝, its operand would have to have type 𝐴1, but the available premise is 𝑤 :𝐴2. Thus the inner T-Cast instance, and consequently the application, cannot be formed.
exercise 23.6.
For positive safety, P-Arr requires the opposite-polarity domain premise ? ⪯−ℕ, which is N-Unk, and the codomain premise ℕ ⪯+?, which is P-Unk. Hence ℕ →ℕ ⪯+? →?. For negative safety, N-Arr requires ℕ ⪯+? in the domain and ? ⪯−ℕ in the codomain. The same two unknown rules give ? →? ⪯−ℕ →ℕ.
exercise 23.13.
With the mutated wrapper rule, the first application in example 23.25 becomes ⟨?⇐ℕ⟩𝑝(𝑖(⟨ℕ⇐?⟩𝑝𝑑)). The stored tag of 𝑑 is 𝟐, so E-Mismatch produces 𝖻𝗅𝖺𝗆𝖾𝑝, which then propagates. The false line in the label-preservation proof is the wrapper case: inversion of 𝐴1 →𝐵1 ⪯+𝐴2 →𝐵2 supplies 𝐴2 ⪯−𝐴1 for a cast labeled ¯𝑝. Relabelling that cast by 𝑝 would instead require the unsupported positive premise 𝐴2 ⪯+𝐴1.
exercise 23.7.
Write the precise function type as 𝐵 →𝐶 and its less precise type as ?. Matching changes from 𝖿𝗎𝗇(𝐵 →𝐶) =𝐵 →𝐶 to 𝖿𝗎𝗇(?)=?→?. The component precision goals are 𝐵 ⊑𝗍𝗒? and 𝐶 ⊑𝗍𝗒?, both instances of Pr-Unk. If the precise argument has type 𝐷 with 𝐷 ∼𝖼𝐵, its less precise mate has a type 𝐷′ with 𝐷 ⊑𝗍𝗒𝐷′. The less precise application requires only 𝐷′ ∼𝖼?, supplied by C-UnkR. Thus G-App gives result type ?, and Pr-Unk relates 𝐶 to that result.
exercise 23.8.
The lambda in 𝑟′ has type ? →?, matching returns the same arrow, and ⋅ ⊢𝗍𝗋𝗎𝖾 :𝟐 with 𝟐 ∼𝖼? by C-UnkR. Therefore G-App derives ⋅ ⊢𝑟′ :?.
A derivation for 𝑟 would type its lambda as ℕ →ℕ and matching would return ℕ →ℕ. Inverting its final G-App would therefore require 𝟐 ∼𝖼ℕ. Inversion of consistency rules shows that no rule has these two distinct base endpoints. Only the direction from a typed precise term to its less precise mate remains valid; typing 𝑟′ cannot be used to infer typing of 𝑟.
exercise 23.12.
The common inner call elaborates completely to 𝑢𝐶:=(⟨?→?⇐?→?⟩ℓ𝑖,𝑓(𝜆𝑥:?.𝑥))(⟨?⇐ℕ⟩ℓ𝑖,𝑎0):?. Keeping the two fresh labels at the outer source position, the two complete elaborations are 𝑎=(⟨𝟐→𝟐⇐𝟐→𝟐⟩ℓ𝑜,𝑓(𝜆𝑦:𝟐.𝑦))(⟨𝟐⇐?⟩ℓ𝑜,𝑎𝑢𝐶):𝟐,𝑎′=(⟨?→?⇐?→?⟩ℓ𝑜,𝑓(𝜆𝑦:?.𝑦))(⟨?⇐?⟩ℓ𝑜,𝑎𝑢𝐶):?. Thus every one of the six inserted casts is shown: the common inner pair and the two outer pairs. Reducing the common subterm gives 𝑢𝐶 ⟼∗𝑧, where 𝑧 =⟨? ⇐ℕ⟩ℓ𝑖,𝑎0. The precise outer argument cast then gives ⟨𝟐⇐?⟩ℓ𝑜,𝑎𝑧⟼𝖻𝗅𝖺𝗆𝖾ℓ𝑜,𝑎. The surrounding application propagates this blame, so 𝑎 ⟼∗𝖻𝗅𝖺𝗆𝖾ℓ𝑜,𝑎 :𝟐. On the other side, the unknown identity casts and arrow wrapper all contract without changing the payload, so 𝑎′ ⟼∗𝑧 :?. The final results are related by ⋅⊢𝐶𝑧:?𝟐⊑𝗍𝗒?⋅⊢𝖻𝗅𝖺𝗆𝖾ℓ𝑜,𝑎:𝟐⊑𝖢𝑧:?CPr−Blame. Thus equality of observations would fail, while error approximation holds.
exercise 23.9.
By lemma 23.32, 𝑖 :ℕ →ℕ ⊑𝖢𝑖 :ℕ →ℕ. Apply CPr-CastR using ℕ →ℕ ∼𝖼? →? and ℕ →ℕ ⊑𝗍𝗒? →? to obtain the required 𝑖 ⊑𝖢𝑤. For the argument, instantiate CPr-CastR with 𝑆 =𝑈 =ℕ and 𝑉 =?: its term premise is reflexive numeral precision, while its remaining premises are ℕ ∼𝖼? and ℕ ⊑𝗍𝗒?. Hence 0 :ℕ ⊑𝖢𝑧 :?.
The applications are related by CPr-App. Their right reduction is 𝑤𝑧⟼⟨?⇐ℕ⟩𝑝(𝑖(⟨ℕ⇐?⟩¯𝑝𝑧))𝐸−𝑊𝑟𝑎𝑝𝐴𝑝𝑝,⟼⟨?⇐ℕ⟩𝑝(𝑖0)𝐸−𝑃𝑟𝑜𝑗𝑒𝑐𝑡,⟼⟨?⇐ℕ⟩𝑝0𝐸−𝐵𝑒𝑡𝑎. The left application 𝑖 0 reduces to 0. Reflexive numeral precision and CPr-CastR relate this 0 :ℕ to the final injection at ?.
exercise 23.11.
Clause 1 begins with successful evaluation of the more precise program. Finite simulation and value catch-up cannot introduce left blame, so the less precise program must reach a related value. Clause 2 begins with success of the less precise program. The more precise program may contain a check removed on the right, so its permitted additional outcome is blame.
The false reverse clause would assert that right success always implies left success. In the displayed 𝑒 ⊑𝗌𝗋𝖼𝑒′, the right elaboration returns the tagged natural 𝑧, while the left outer Boolean projection reaches 𝖻𝗅𝖺𝗆𝖾ℓ𝑜,𝑎. Hence the blame alternative is necessary. In the actual proof, operational trichotomy also presents the possible case 𝑎 ⟼𝜔. Infinite simulation would then force 𝑎′ ⟼𝜔, contradicting the assumed finite reduction of 𝑎′ to a value. This is the exact step that replaces the false normalization claim.
exercise 23.14.
Let 𝑖 =𝜆𝑛 :ℕ.𝑛 and 𝑔 =𝜆𝑓 :ℕ →ℕ.(𝑓 0)ℓ𝑖. The inner application in 𝑔 elaborates to (⟨ℕ→ℕ⇐ℕ→ℕ⟩ℓ𝑖,𝑓𝑓)(⟨ℕ⇐ℕ⟩ℓ𝑖,𝑎0). The complete outer elaboration is (⟨(ℕ→ℕ)→ℕ⇐(ℕ→ℕ)→ℕ⟩ℓ𝑜,𝑓𝑔𝐶)(⟨ℕ→ℕ⇐ℕ→ℕ⟩ℓ𝑜,𝑎𝑖), where 𝑔𝐶 is 𝑔 with the displayed inner target body.
Each arrow identity is a wrapper. Applying the outer wrapper first inserts an identity arrow cast on its argument and an identity base cast on its result. Erasure removes all of these casts, so that step leaves the erased term 𝑔 𝑖 unchanged. The ensuing beta step erases to (𝑖 0); applying the inner arrow wrapper and reducing its two base identity casts again leave that erasure unchanged; the inner beta step erases to 0. Finally the surrounding result identity casts reduce to 0 and erase to 0 throughout. Thus the only non-stuttering erasure steps are 𝑔𝑖⟼𝑖0⟼0, exactly the ordinary call-by-value reduction of the static source term.