Lectures onType Theory
ch:dependent-copattern-elaboration: ch:dependent-copattern-elaboration
appendix sectionsolutions

ch:dependent-copattern-elaboration: ch:dependent-copattern-elaboration

Exercise 125.1.

Writing z:Orbit(q,a), the frontiers and leaf types are z:Orbit(q,a)next(z):A,u1=q(a):A. Put Γ2:=z:Orbit(q,a), next(z)=q(a). Then Γ2step(z):IdA(q(a),q(a)),u2=reflq(a). For the final field the frontier and leaf are Γ3:=Γ2,step(z)=reflq(a), with Γ3tail(z):Orbit(q,q(a)),u3=iterate(q,q(a)). The tail leaf applies the state substitution [q(a)/a] to the record index. The step leaf instead substitutes the stored next term for the earlier projection in its identity type.

Exercise 125.2.

Here N={2}. The first method has A1[]=2. The recursive-field clause gives A2[h1]=S, actual output v2=h2s:S, and v¯2=corecR(h2s):R. Substitution of that decoded field into the third declaration gives A3[h1,h2]=Id2(label(corecR(h2s)),tt). If the state h2s replaces v¯2, the required application judgment is h2s:Slabel(h2s):2, but the earlier generated projection has type label:R2 and requires h2s:R. Since the corecursor card assumes no conversion SR, that judgment is not derivable.

Exercise 125.3.

The Tcop-tree is the coprojection spine next, step, tail, with the three frontiers displayed in the preceding solution and leaves q(a), reflq(a), and iterate(q,q(a)). Translation generates the indexed family and tagged constructor StateG:(b:A)Ui,initerate:(b:A)StateG(b), where i=lev(b:A) is the maximum prescribed by the generated state-block rule. The sequential methods are h1(a,s)=q(a),h2(a,s)=reflq(a),h3(a,s)=initerate(q(a)). After h1 has checked, the second codomain is IdA(h1(a,s),q(a))IdA(q(a),q(a)) by ordinary reduction of the previously checked method term. Thus h2 checks before the corecursor and its coprojection equations are committed. The third method checks at StateG(q(a)). The source leaf iterate(q,q(a)) is recovered as corec(q(a))initerate(q(a)). The recursive field carries only the tagged state at the moved index, never a record. The empty declaration fiber contributes no extra constructor argument; the generated index b:A remains explicit.

Two tail observations change the index from a to q(a) and then to q(q(a)). The final next observation returns q(q(q(a))); for successor at zero this is three.

Exercise 125.4.

With step declared first, its result type still contains next(z), but the record telescope has not introduced the projection next. That occurrence is the first ill-scoped term. The dependency graph has the edge nextstep. Every dependency-preserving field order is a topological order of this graph, so next must precede step. Consequently no such permutation can put step first.

Search the book

Type to search the local edition.