Exercise 61.1.
The eta-long form is 𝜆(𝑥:𝐴).𝜆(𝑦:𝐵).𝑓𝑥𝑦. Here 𝐵 and 𝐶 are read in the context extended by 𝑥 :𝐴. For canonical 𝑀 :𝐴 and 𝑁 :𝐵[𝑀/𝑥], the two contractions, with the dependent annotation made visible, are (𝜆(𝑥:𝐴).𝜆(𝑦:𝐵).𝑓𝑥𝑦)𝑀𝑁⟶beta(𝜆(𝑦:𝐵[𝑀/𝑥]).𝑓𝑀𝑦)𝑁⟶beta𝑓𝑀𝑁. The final type is 𝐶[𝑀/𝑥][𝑁/𝑦].
Exercise 61.2.
For the specialized redex, the unreduced proof has representation 𝗌𝗎𝗉𝖤⌜𝑃⌝⌜𝑃⌝(𝗌𝗎𝗉𝖨⌜𝑃⌝⌜𝑃⌝(𝜆(𝑢:𝖽𝖾𝖽⌜𝑃⌝).𝑢))𝑒. It is LF beta-normal because its head is the constant 𝗌𝗎𝗉𝖤; LF has no rewrite rule relating 𝗌𝗎𝗉𝖤 and 𝗌𝗎𝗉𝖨. The reduct is represented by the assumption 𝑒. These two canonical LF objects are not beta-eta equal: their heads are respectively 𝗌𝗎𝗉𝖤 and the context variable 𝑒. In general, compositionality gives ⌜𝐷[𝐸/𝑢]⌝ =𝛽𝜂⌜𝐷⌝[⌜𝐸⌝/𝑢]; its right side is the beta-result of applying the represented hypothetical body to ⌜𝐸⌝. That calculation proves compositionality of substitution, not completeness; completeness still requires canonical-head inversion.
Exercise 61.3.
For canonical 𝑀 :𝗍𝗆 ⌜𝐴⌝, the extension creates the canonical atomic object 𝗂𝗇𝗌𝗉𝖾𝖼𝗍⌜𝐴⌝𝑀:𝗍𝗆⌜𝐴⌝. It is fully applied and its LF type is sound, but its head is neither a represented variable nor 𝗅𝖺𝗆 nor 𝖺𝗉𝗉. The inverse in the adequacy proof has no object constructor to return, so the encoding is not surjective onto canonical LF inhabitants.
Exercise 61.4.
With newest de Bruijn declarations at the left, the redex is (𝜆𝐴𝜆𝐵1) 𝑢. The outer substitution maps 0 to 𝑢. Its lift under the 𝐵-binder maps 0 to 0 and 𝑖 +1 to the weakening of the old component; therefore (𝜆𝐴𝜆𝐵1)𝑢⟶beta𝜆𝐵(1[𝜎↑])=𝜆𝐵(𝗋𝖾𝗇𝖺𝗆𝖾(+1)𝑢).
Locally nameless syntax gives (𝜆𝐴𝜆𝐵1――)𝑢. Choose 𝑧 ∉FV(𝑢). Opening the outer binder under the inner one leaves the inner index 0―― fixed and inserts the free term 𝑢; closing again gives 𝜆𝐵𝑢. Translation under the new binder weakens the free context, yielding the displayed de Bruijn result.
In open PHOAS, let 𝑈 :𝖯𝖳𝖾𝗋𝗆(Γ,𝐴) represent 𝑢 and evaluate the redex at 𝑉 and 𝛾 :𝖤𝗇𝗏(𝑉,Γ). The substitution environment maps the outer binder to 𝑈(𝑉)(𝛾). Flattening returns 𝖺𝖻𝗌(𝑦.𝑈(𝑉)(𝛾)). For related environments 𝛾,𝛿, parametricity of 𝑈 relates 𝑈(𝑉)(𝛾) and 𝑈(𝑊)(𝛿); beneath the second binder, extend that relation by the fresh pair (𝑦𝑉,𝑦𝑊). The relation-extension clause prevents the body from inspecting 𝑦 and choosing a different result.
For contextual syntax, let 𝜎 :[Γ ⊢𝑥 :𝐴] map 𝑥 to 𝑢 :[Γ ⊢𝐴]. Under 𝑦 :𝐵, its lift is 𝜎↑ =(𝑦 ↦𝑦,𝑥 ↦𝗐𝖾𝖺𝗄(𝑢)). Hence the body 𝑥 becomes 𝗐𝖾𝖺𝗄(𝑢) and the result is [Γ ⊢𝜆𝐵𝗐𝖾𝖺𝗄(𝑢) :𝐵 →𝐴]. Erasure of all four results is 𝜆𝐵(𝗋𝖾𝗇𝖺𝗆𝖾(+1)𝑢).
Exercise 61.5.
Take 𝑀=𝗌𝗎𝗉𝖨⌜𝑃⊃𝑄⌝⌜𝑃⊃𝑄⌝(𝜆(ℎ:𝖽𝖾𝖽⌜𝑃⊃𝑄⌝).ℎ). Canonical-head inversion first selects 𝗌𝗎𝗉𝖨 and decodes its two proposition arguments as 𝑃 ⊃𝑄. Eta-long inversion exposes the LF lambda, extends the represented context by ℎ :𝑃 ⊃𝑄, and decodes its body ℎ by the assumption case. The result is 𝗌𝗎𝗉𝖨(ℎ.ℎ) :(𝑃 ⊃𝑄) ⊃(𝑃 ⊃𝑄). Re-encoding applies the same constructor and returns the displayed LF lambda; only its bound name may differ, so the result is alpha-equivalent to 𝑀.
Exercise 61.6.
The new 𝑘 is a closed canonical atomic LF object of family 𝗍𝗆(𝖺𝗋𝗋 𝗂 𝗂). Checking and canonicalization stop successfully at that declared head, but the inverse has only variable, 𝗅𝖺𝗆, and 𝖺𝗉𝗉 cases. The weakest object extension adds one constant constructor 𝜅 :𝜄 →𝜄 with typing axiom ⋅ ⊢𝗌𝗍𝜅 :𝜄 →𝜄 and sets ⌜𝜅⌝ =𝑘. The new head case decodes 𝑘 to 𝜅; its inverse equation is definitional. No other adequacy case changes.
Exercise 61.7.
Let the target context contain one free variable 𝑞 :𝐶, and substitute the de Bruijn variable 0 :𝐶 for the outer free variable of 𝜆𝐴𝜆𝐵2. Without lifting under either binder, the result is 𝜆𝐴𝜆𝐵0; index 0 denotes the 𝐵-bound variable, so the free 𝐶-variable was captured. Two lifts give 𝜆𝐴𝜆𝐵2, which denotes 𝑞 and has the required type.
For locally nameless syntax, take the body 𝜆𝐵𝑝 and substitute the free atom 𝑦 for 𝑝. If the cofinite proof opens the binder at the same atom 𝑦, opening and free substitution collide. Enlarging the exclusion set by {𝑝,𝑦} chooses an atom 𝑧 ≠𝑝,𝑦 and gives 𝜆𝐵𝑦 with 𝑦 free.
For PHOAS, omit relation extension beneath 𝖺𝖻𝗌 and use a body that tests its host argument, returning a variable at one related input and an abstraction at the other. The two outputs have different heads and therefore violate 𝖳𝖾𝗋𝗆𝖱𝖾𝗅(𝑅′). Quantifying over every extension 𝑅′ that contains the bound pair forces equal heads and restores the abstraction case.
For contextual syntax, package the closed identity once as [ ⋅ ⊢𝐴 →𝐴] and once as [𝑥 :𝐵 ⊢𝐴 →𝐴]. Erasing the domain would admit the second package where the first is required. Retaining the exact domain rejects that substitution; weakening first gives a contextual substitution from the larger domain and restores the typing judgment. These four repairs yield the two-binder results computed in exercise 61.4.
Practical route.
The canonical-head checker of exercise 61.8 is developed in appendix F; its run is recorded in appendix E.