Lectures onType Theory
ch:formalized-graded-erasure: graded erasure and extraction
appendix sectionsolutions

ch:formalized-graded-erasure: graded erasure and extraction

Exercise 101.1.

Use ambient coordinates (x,u,v). The simultaneous substitution keeps x and sends y to a term with demand (3,1), so its row matrix is Ψ=(100031). Consequently (1,2)Ψ=(1,0,0)+2(0,3,1)=(1,6,2). Replacing the application scalar by one changes the result to (1,3,1). It under-counts the u-coordinate by three and the v-coordinate by one; those are exactly the missing second copy of the substituend’s free-variable demand.

Exercise 101.2.

Let the open declaration x0:Σ0AB supply the scrutinee, assume Prodrec(0), and choose the constant motive N and constant branch zero. The weak-product elimination rule derives x0:Σ0ABprodrec00(N;x0;zero):N. The scrutinee is a neutral variable, so no weak-head reduction rule applies. Extraction at grade zero discards the match and gives zero, which is already a target numeral. The first side condition of theorem 101.11 requires either ¬Prodrec(0) or an empty context. Both disjuncts fail here; that condition, rather than consistency for empty elimination, rejects the example.

Exercise 101.3.

Suppose the last usage rule is U-App. The induction hypotheses give γΨt[σ] and δΨu[σ]. Rebuilding the rule is justified on its conclusion by (γ+pδ)Ψ=matrix distributivityγΨ+p(δΨ). For the successor reduction natrec(A;z;s;sucn)spnrnatrec(A;z;s;n), the characteristic successor law has the pointwise orientation nrp,r(qz,qs,qn)qs+pqn+rnrp,r(qz,qs,qn). The rebuilt application rules give the right demand, and U-Sub transports it down along this inequality to the redex demand on the left. Thus the contractum has the same advertised usage context. The exact placement of p and r is the one fixed by the source successor clause; exchanging them would prove a claim for a different recursion rule.

Exercise 101.4.

Usage preservation has inputs γt and a typed step Γtu:A; it concludes only γu. Operational erasure soundness has a well-behaved zero, its two match restrictions, a natural-number typing, and 0t; it concludes that source and extracted target reach one numeral. Resource correctness instead assumes the recursion calculus, a closed grade-one natural-number term, and its heap/stack invariant; it concludes numeral evaluation, zero-bounded residual heap grades, and, in the linearity instance, exactly one lookup of each allocated linear entry.

On the retained-argument term, preservation tracks the annotation through each source step but supplies no target run. Erasure soundness relates the source and target numerals but does not count target or heap accesses. Resource correctness counts linear heap lookup but concerns a different recursion rule and machine. Hence erasure soundness does not imply resource correctness, and resource correctness does not imply erasure soundness: their signatures use different calculi, while their conclusions respectively omit access counts and omit the extraction relation.

Search the book

Type to search the local edition.