Lectures onType Theory
ch:dependent-object-types: variable-path DOT
appendix sectionsolutions

ch:dependent-object-types: variable-path DOT

Exercise 107.1.

Binding the implementation gives n:μ(c:{A:N..N}{value:c.A}). Rule DOT-Rec-E exposes n:{A:N..N}{value:n.A}. Intersection elimination gives n:{value:n.A}, and DOT-Fld-E gives n.value:n.A. The other intersection projection gives n:{A:N..N}, so DOT-Sel-U derives n.A<:N (and DOT-Sel-L derives the reverse bound). Replacing the member declaration by {A:..} changes the DOT-Sel-U conclusion to n.A<:. The step that formerly supplied n.A<:N is therefore absent.

Exercise 107.2.

Interpret types in the lattice 0<1, with =0 and =1. After deleting DOT-Sel-L, interpret x.A=0. The remaining upper premise x.A<: is 00, while <: is the false statement 10. After restoring DOT-Sel-L and deleting DOT-Sel-U, interpret x.A=1. The lower premise <:x.A is 11, while the collapsed conclusion remains false. Each selection rule supplies a different half of the path from top to bottom; neither half alone collapses the lattice.

Exercise 107.3.

Let the inert context extracted from E bind x=λ(z:S)t. Clause 1 of theorem 107.9 locates the dependent-function declaration bound to x and supplies its domain comparison; clause 2 identifies the value as that lambda and supplies the comparison needed to obtain Γy:S. Inversion of lambda typing supplies Γ,z:St:T. The required source substitution lemma is exactly Γ,z:St:TΓy:SΓt[y/z]:T[y/z]. The canonical-form codomain comparison and subsumption then recover the original application result T[y/z], and the typing reconstruction for E places the reduct at the original whole-term type. Without inertness, general typing cannot be converted to tight and precise typing: a bad-bound selection may fabricate the function type of x, so canonical forms cannot recover a lambda and the proof stops before the displayed substitution premise.

Exercise 107.4.

The type (x:S)T is inert by the function clause. The type μ(x:{A:S..S}{a:x.A}) is inert by the recursive-record clause: its type member has equal bounds, its field has a well-formed type, and its labels are distinct. The type μ(x:{A:S..U}) with SU is not inert because its sole member violates the equal-bounds condition.

Exercise 107.5.

Rule DOT-Rec-E gives x:{A:T..T}{a:x.A}. The field intersection projection followed by DOT-Fld-E yields x.a:x.A. The member projection is the precise judgment Γ!x:{A:T..T}; therefore DOT-T-Sel-L and DOT-T-Sel-U give Γ#T<:x.A,Γ#x.A<:T. The field result is retained between these equal tight bounds.

Exercise 107.6.

Choose distinct closed record types S={a:} and U={b:}. In x:{A:..}, selection and transitivity give S<:<:x.A<:<:U, hence S<:U; the symmetric outer top/bottom chain also gives U<:S. However, DOT-Def-Type types a concrete definition {A=T} only as {A:T..T}. Definition intersection preserves that equality and DOT-Obj-I installs precisely those member declarations. Consequently an object value placed in the runtime context can contribute only equal bounds; it cannot contribute {A:..}, since .

Exercise 107.7.

Suppose E binds x=ν(z:T)d and the redex is E[x.a]. Canonical forms recover the precise recursive type μ(z:T); DOT-Rec-E exposes T[x/z]. Precise intersection decomposition locates the declaration {a:S}. Pairwise label disjointness makes this occurrence unique, so inversion of definition typing locates the corresponding definition {a=t} and gives t:S after receiver substitution. The projection root therefore replaces x.a by a term of the same field type. Rebuild the surrounding let bindings of E from the innermost one outward; each unchanged value retains its inert declaration and each let rule retains the original result type. Thus the whole reduct has the type of the original projection context.

Search the book

Type to search the local edition.