Lectures onType Theory
ch:graded-modal-dtt: graded modal dependent type theory
appendix sectionsolutions

ch:graded-modal-dtt: graded modal dependent type theory

Exercise 100.1.

For subject y, the subject vector is (0,0,1) and the subject-type vector is (1,0,0). The triangular rows are (), (1), and (1,0): a forms the types of both x and y. Changing the subject to x changes only the subject-grade vector, now (0,1,0). The subject-type vector and every row of Δ remain fixed; inside the changed vector, the x and y coordinates exchange zero and one.

Exercise 100.2.

Box introduction at grade two scales the producer demand from Δ to 2Δ. Rule G-Box-E adds that boxed-scrutinee vector once; its body binds the unboxed value at grade two but does not rescale the scrutinee. Hence the producer contribution remains 2Δ, not 4Δ. At grade zero the boxed scrutinee contributes 0Δ. This equation is internal to the typing derivation. Without a defined erasure translation and an observational-soundness theorem it says nothing about whether a compiler evaluates or allocates the producer.

Exercise 100.3.

Invert box elimination and box introduction. If the body uses the unboxed variable at subject grade s and its result type depends on it at grade r, the eliminator contributes sτs to its subject vector and rτs to its subject-type vector, where τs is the producer’s subject vector. Apply graded substitution to the body with the producer as substituend. Its conclusion contains exactly σ^=σ1+sτs,σ2 and ρ^=ρ1+rτs,ρ2, together with the discard/choose update of the context triangle. The box beta-equality rule relates the redex to this typed contractum, and equality inversion supplies preservation.

Exercise 100.4.

The hypotheses are: the exact GrTT0,1 syntax, only Type0 and Type1, no context variable of type Type1, the paper’s grade structure and rules, and beta reduction for functions, tensors, and boxes. Eta normalization concerns a reduction absent from that signature. Full GrTT admits universe stages and contexts excluded by the saturated-set induction. Conversion decidability also needs a decidable one-step relation and the appropriate confluence/completeness argument. Erasure soundness needs an operational erasure map and a relation between source and target observations. None is a consequence of beta strong normalization alone.

Exercise 100.5.

For context A:Type0,B:Type0,p:Pair0(A,0B), take triangular rows (), (0), and (1,1). The term uses only the pair, so σs=(0,0,1); its result type is A, so σt=(1,0,0). The weak-product zero is the dependency grade of the first component in the second component’s type. The 0 zero instead scales the subject demand of the packaged B value. Thus one zero occupies a dependent-tensor type position and the other a modal subject-use position; neither is the ambient zero in σt for the unused declaration B.

Exercise 100.6.

Let the unboxed producer have subject vector τs and type vector τt. Box introduction gives the scrutinee subject vector sτs. If the elimination result classifier depends on the opened value at grade r, substitution changes the body vectors to σ1+sτs,σ2 and ρ1+rτs,ρ2; τt is already the row forming the removed declaration. For the zero-based column j of that declaration, the context triangle becomes Δ,Δ\j+(Δ/j)τs. Discard removes the old column for the bound value; choose collects each later use of that value; scaling and addition insert the producer’s dependencies. The box beta contractum has exactly these three components.

Exercise 100.7.

With natural grades, addition and multiplication count duplicated demand; for example 2(α+β)=2α+2β. With the Boolean lattice, take join as addition and meet as multiplication; distributivity is again the common semiring calculation. “Used exactly twice” is meaningful only in the natural interpretation, while a confidentiality bound is meaningful only in the information-flow interpretation. An order-based approximation rule would require an explicit premise transporting a derivation from grade vector σ to a larger vector σ. The frozen GrTT signature has no such rule, so the imported normalization theorem cannot be instantiated with that extension.

Search the book

Type to search the local edition.