Lectures onType Theory
ch:type-theory-modulo: the λΠ-calculus modulo rewriting
appendix sectionsolutions

ch:type-theory-modulo: the λΠ-calculus modulo rewriting

exercise 97.1.

Declare doublezz,double(sn)s(s(doublen)). Both sides have type Nat in the displayed rule telescope. Then double(s(sz))Σs(s(double(sz)))Σs4(doublez)Σs4z. For neutral x, doublex is stuck: x matches neither z nor sn.

exercise 97.2.

Write the matching substitution as θ=(u/x,v/y). First substitute u in the derivations x:A,y:B(x):T and x:A,y:B(x)r:T. Typed substitution requires Γu:A and yields derivations in Γ,y:B(u). The second component must therefore satisfy Γv:B(u), not v:B(x). Substituting v gives Γθ:Tθ and Γrθ:Tθ, as required.

exercise 97.3.

The new right-zero rule overlaps the zero-left rule at pluszz; both roots contract to z. It overlaps the successor-left rule at plus(sm)z. Right-zero contracts directly to sm, while successor-left gives s(plusmz), which contracts internally by right-zero to sm. The two original roots do not unify, and each self-overlap is trivial. Joinability checks only local peaks. It supplies no well-founded measure on rewrite sequences, so termination remains a separate obligation.

exercise 97.4.

Take one constant a and the rule aa. Every pair of finite reductions from a term has a common descendant, so the relation is confluent, but aΣaΣ is infinite and a has no normal form. An algorithm that converts by normalizing both inputs therefore does not terminate even on (a,a). Confluence gives uniqueness of normal forms when they exist; it neither produces them nor proves that normalization terminates.

exercise 97.5.

The normal derivation assumes f:AB and a:A, eliminates f at a to obtain B, and introduces twice. Its term is λf:prf(imp A B).λa:prf(A).fa. Rule (Imp) converts the type of f to prf(A)prf(B) and converts the two lambda types back to prf((AB)AB).

Conversely, a beta-eta-long normal inhabitant of that type converts to a function type, so canonical-form inversion exposes the outer lambda; applying the same inversion to its codomain exposes the inner lambda. Invert the remaining normal form recursively. A lambda reconstructs implication introduction. A neutral form has an assumption as head and a spine of normal arguments; typing inversion reconstructs one implication elimination for each argument. For the displayed inhabitant the head is f and its one argument is the assumption derivation for a. These inversions reconstruct every normal derivation of the formula, including additional ones when A or B has implicational structure.

Search the book

Type to search the local edition.