Lectures onType Theory
ch:evaluation-strategy-translations: ch:evaluation-strategy-translations
appendix sectionsolutions

ch:evaluation-strategy-translations: ch:evaluation-strategy-translations

exercise 37.1.

Name reduction may contract the outer redex first: (λx.fxx)RfRRfaRfaa. The first arrow creates the two copies of the unreduced argument. Value reduction must first use R=(λu.u)aa. Compatibility then gives (λx.fxx)R(λx.fxx)afaa. Only the second arrow substitutes twice, and it copies the value a, not the redex R.

exercise 37.2.

Put F=λx.fxx. The application clause gives (FR)n=(λy.let !x=y in fnxx)!Rn. The principal trace is LinBetalet !x=!Rn in fnxxLinBangfnRnRn. The single promotion !Rn licenses exponential elimination; the resulting exponential assumption for x licenses both occurrences. No other box is introduced around the argument.

exercise 37.3.

Expansion and the first two administrative target contractions give ((λx.M)N)vlinlet !x=Nv inMv. For an arbitrary N, the right-hand side need not expose a bang, so Lin-Bang need not apply. If N=V, then Vv=!V+, and the trace continues to Mv[x:=V+]. Replacing the application argument by !Nv would expose a bang even when N is an application; the target could then enter the body before the source value-beta premise was satisfied.

exercise 37.4.

The translation is let !x=Rv in !a. Because x is absent from the body, Aff-Weak reduces it to !a. Suppose Rv uses a linear assumption r:C. The redex is typed in context r:C, but the reduct !a uses no r. The linear target has no weakening rule for r:C, so the same-context subject-reduction conclusion is unavailable. Affine weakening derives it, which is why the call-by-need target is not lin.

exercise 37.5.

For name erasure, a Lin-Beta/Lin-Bang principal pair maps to one source beta step. A Lin-App or Lin-Assoc step maps to zero source steps: erasure performs the same substitution on both sides. Under call-by-let erasure, Lin-Beta, Lin-Bang, Lin-App, and Lin-Assoc correspond respectively to the source families Let-I, Let-V, Let-C, and Let-A, allowing a short nonempty sequence when the target exposes two principal rules at once. The last two source rules are required because the target can commute an exponential let through application or another let before a value is exposed.

exercise 37.6.

Use the grammar in the proof of theorem 37.6. Variables have themselves as erasure; translated abstractions erase to source abstractions; (S!T)=ST; and (let !x=!S inT)=T[x:=S]. Structural induction proves (Mn)=M. For closure, Lin-Beta creates the fourth grammar form, Lin-Bang removes it, and the two commuting rules only reassociate the third and fourth forms. Case analysis gives one source beta step for the principal pair and reflexivity for each commuting image. Induction on target sequence length yields reflection.

exercise 37.7.

Rule Let-I exposes the operator box with Lin-Bang, contracts the linear application with Lin-Beta, and leaves the translated source let. Rule Let-V is Lin-Bang. Rule Let-C is Lin-Assoc followed by Lin-App; Let-A is Lin-Assoc. Fresh binders are chosen before every trace.

The reachable-value erasure maps a boxed value image to a source value, the administrative operator let to its source application, and a general exponential let to source let. Thus each target rule maps to zero or more call-by-let steps and the erasure is a right inverse. This proves exactness for let. Proposition 5.4 of [MOTW99] is used only after both endpoints are let-free; it converts that call-by-let reduction to call-by-value reduction.

Search the book

Type to search the local edition.