Lectures onType Theory
ch:subject-dependent-self: subject-dependent self
appendix sectionsolutions

ch:subject-dependent-self: subject-dependent self

exercise 94.1.

From t:T[t/x], S-Self-Gen yields t:ιx.T; then S-Self-Inst yields t:T[t/x] again. Both steps retain the Curry subject, so every erasure is erase(t). The instantiation rule substitutes the subject actually classified, namely t. It supplies neither a conversion with T[u/x] nor an equality t=u, so no equation involving an unrelated u follows.

exercise 94.2.

In context A:U0, the nil constructor has type Vec(A,0) and erases to λz.λs.z. Indeed, for C:k:NatVec(A,k)U0,z:C(0,vnil), it returns z.

For k:Nat, a:A, and xs:Vec(A,k), the cons constructor has type Vec(A,S(k)) and erases to λz.λs.skaxs(xszs). Self instantiation at xs gives xszs:C(k,xs), so the step premise gives skaxs(xszs):C(S(k),vcons(k,a,xs)). Rule S-Self-Gen closes both constructor typings.

Finally fix n:Nat and v:Vec(A,n). Rule S-Self-Inst substitutes the classified subject v for the self variable and yields vzs:C(n,v). Abstracting over v and then n gives n:Natv:Vec(A,n)C(n,v). The binder n is explicit in the context and in the result; no free length variable remains. Erasure is the ordinary Church-vector fold.

exercise 94.3.

Fix C,s,z,n. From n:Nat, S-Self-Inst gives n:C.(k.C(k)C(Sk))C(0)C(n). Implicit elimination at C, then application to s and z, yields nsz:C(n). The occurrence of n in this result is exactly the subject substituted by self instantiation. Abstracting supplies the theorem’s type. If C is constant at D, the erasure is λs.λz.λn.nsz:(DD)DD, the Church iterator.

exercise 94.4.

In 1+X×X, both occurrences are positive, so the closure admits it. In XN, the occurrence is in an arrow domain and is negative, so it is rejected. In (XN)N, the two domain crossings restore positive polarity, so it is admitted. For the rejected body, candidate monotonicity would require RS(RN)(SN). Function-space variance gives the reverse inclusion instead, so the fixed point construction cannot use it as a monotone operator.

Search the book

Type to search the local edition.