Lectures onType Theory
ch:dependent-effects: dependent effects
appendix sectionsolutions

ch:dependent-effects: dependent effects

Exercise 103.1.

Without C[t]false, substitution still yields :C[t]=Btrue. The next proof line can no longer convert that judgment to :false=Btrue. A diverging Boolean term supplies no judgmental equation with false: divergence is the absence of a terminating computation, whereas conversion requires a finite equality derivation. Thus it does not restore the missing observability premise.

Exercise 103.2.

Let M=return2:FNat, let z:UFNat, and put B(z)=F(ResultVec(z)). Before the beta step the rule conclusion is ΓcMtoxinreturn(replicatextrue):F(ResultVec(thunkM)). The continuation premise is formed under x:Nat and has classifier F(ResultVec(trx)). Beta reduction substitutes two and gives return(replicate2true):F(ResultVec(tr2))F(VecB2). Replacing thunkM by M is ill sorted because ResultVec accepts a value of type UFNat, while M is a computation of type FNat.

Exercise 103.3.

Let IdB(b,c) have constructor reflb:IdB(b,b) and eliminator J. Dependent Boolean elimination on x constructs x:Bq(x):IdB(C[x],true), because both branch classifiers reduce to IdB(true,true). Substitute the effectful term t, then use C[t]false to convert q(t) to an identity e:IdB(false,true). Take the family D(false)= and D(true)=1. Identity elimination transports unit:D(true) along the symmetry of e, producing an inhabitant of D(false)=. The only conversion using observability is the conversion of q(t)’s left endpoint from C[t] to false.

Exercise 103.4.

Use the classifier from the chapter, B(z):=F(ResultVec(z)),ResultVec(trn)Vec(B,n). It stays stuck on the thunk of an effect operation but computes after a selected branch returns a numeral.

The computation errorFNate is thunkable for every well-formed family. There is no transition errorFNateM, so the required implication errorFNateMB[thunk(errorFNate)/z]B[thunkM/z] has no instances. This is the vacuous positive case.

The other three machine operations are negative. Set W:=write1.(return0). The step from store zero to store one has successor return0. Its two classifiers have normal forms F(ResultVec(thunkW))andF(Vec(B,0)), so they are not judgmentally equal. For R:=readtos(returns), stores zero and one select successors whose classifiers are respectively F(Vec(B,0)) and F(Vec(B,1)), while the source classifier remains the stuck form F(ResultVec(thunkR)). Finally, for C:=choosei(return0,return1), the two branches again yield the distinct vector classifiers at lengths zero and one; neither is judgmentally equal to the stuck source classifier. Thus write, readto, and choose are not thunkable for this family.

A fixed-environment reader is not an operation of definition 103.8, so thunkability has no reader transition to classify. With e:E in the value context, reading is represented directly by returne, and a classifier may mention e; no machine step observes or changes an environment.

The first claim of theorem 103.10 therefore admits error, whose terminal configuration cannot violate preservation, and the fixed-environment reader, because it contributes no effect rule. The state operations write and readto require Incl-Write and Incl-Read; erratic choice requires Incl-Choose. The reader lies on the admitted side because it is a value parameter, not because a read transition satisfies a thunkability equation.

Search the book

Type to search the local edition.