Lectures onType Theory
ch:quantitative-dependent-types: quantitative dependent type theory
appendix sectionsolutions

ch:quantitative-dependent-types: quantitative dependent type theory

exercise 99.1.

Use the field F2: addition is exclusive-or and multiplication is conjunction. It is a two-element commutative semiring, but 1+1=0 while neither summand is zero. In the application and pair cases of the zero-needs-nothing induction, a zero conclusion can therefore no longer be inverted to zero premise demands. For N, a sum of naturals is zero only when both summands are zero, and a product is zero only when at least one factor is zero. Thus both positivity and the zero-product property hold.

exercise 99.2.

Rule QTT-App scales the argument context by the binder quantity: Γ1+3(2Δ)=Γ1+6Δ. With binder quantity zero, the original argument premise is unavailable: the side condition requires the argument’s output quantity σ to be zero exactly when the binder quantity or the application output quantity is zero. Here the application output is one, so π=0 forces σ=0. Replace 2Δu:1A by an erased derivation 0Δu:0A. Rule QTT-App then gives Γ1+0(0Δ)=Γ1; an argument advertised at output quantity one cannot be silently discarded by this rule.

exercise 99.3.

Alpha-rename the lambda-bound y away from the free variables of the substituend. If the outer substituted variable has demand ρ, the body premise assigns it a demand that splits through the abstraction scalar. The induction hypothesis scales the substituend context by that body demand. Rebuilding QTT-Lam is licensed by ρ(σπ)=(ρσ)π, an instance of associativity and commutativity of semiring multiplication. The alpha-renaming is performed before applying the induction hypothesis so that capture-avoiding substitution commutes with the remaining binder.

exercise 99.4.

In the empty-vector branch, the index declarations have demand zero and the input spine is inspected once to choose the constructor. In the cons branch, write the context as n:0Nat,m:0Nat,x:1A,xs:1Vec(A,n),ys:1Vec(A,m); the recursive call consumes the positive-demand tail and the constructor consumes the head. Type formation may use n,m arbitrarily while their run-time demand remains zero. Changing n to demand one retains its representation at run time. It does not alter the formation or proof rules for natural-number equality, so it neither proves nor refutes n+m=m+n.

exercise 99.5.

For application, split the substituted variable’s demand as ρ1+πρ2. The two induction conclusions combine as (Δ1+ρ1Γ)+π(Δ2+ρ2Γ)=Δ1+πΔ2+(ρ1+πρ2)Γ, using distributivity and then associativity/commutativity of addition. For tensor elimination, distribute the body’s two bound demands through the scrutinee context, reassociate the three context sums, and use substitution composition in the dependent result. In each rule, check separately that a zero output forces exactly the zero argument/scrutinee quantity required by its printed biconditional; positivity and zero-product are what permit that inversion.

exercise 99.6.

In the zero–one–many algebra, 1+ω=ω. An arbitrary-output substitution derivation at output ω can therefore present a premise whose variable demand is ω and try to split it as one use in one branch plus ω in another. Reconstructing the substitution needs to recover a subderivation at demand 1 from the premise at demand ω. The calculus has no subusage rule 1ω that changes a derivation’s annotation, so the required premise cannot be obtained. Restricting output quantities to 0 and 1 removes the ambiguous ω-output branch: zero uses the zero lemma, and one forces the unique resource-sensitive split used by the repaired substitution proof.

Search the book

Type to search the local edition.