Lectures onType Theory
Chapter 95
Chapter 95Optional

Very Dependent Functions

Prerequisites. Direct starred prerequisites: none. No later core chapter depends on this route.

Encode a record as a function on labels. In the record {T:U0,get:TZ,set:TZT}, the range at label get mentions the value returned at the earlier label T. An ordinary dependent function may let its codomain depend on the label, but not on values returned by the function at other labels. A function type for this record must therefore let its range inspect a restricted part of the function being classified.

The cycle that must be excluded

The notation {fx:AB[f,x]} suggests that the range may inspect f. Unrestricted use is circular. In {fn:N(f(n)f(n))}, the type of f(n) depends on f(n) itself. No smaller semantic object is available from which to decide the range PER.

By contrast, a finite record has an order on labels: the type field precedes the methods that mention it. At a label a, the range may inspect only fA<a, where A<a:={z:Az<a}. Well-founded induction on < then constructs the range PERs.

Convention 95.1 — Hickey's frozen meaning explanation

The chapter’s very-dependent function is Hickey’s extensional Nuprl/MetaPRL type {fx:AB[f,x]} with a membership witness consisting of a strict well-founded relation < on A. The relation is not printed inside the type expression, but every formation and membership derivation records it. Types are interpreted by PERs on untyped programs. Type inference is undecidable; the source does not supply a general algorithm for choosing < and does not derive the desired binary-method rule.

A well-founded family of PERs

Let RA be the PER interpreting A, and assume < respects its equivalence classes. For adom(RA), write Pa for the PER assigned to the predecessor-function type {gz:A<aB[g,z]}. The definition of Pa uses only Pz with z<a. Once Pa is fixed, each gdom(Pa) determines a range PER RBg,a interpreting B[g,a/f,x].

Definition 95.2 — Very-dependent function PER

For a well-founded witness (A,<), define Rvdf(f,f)a,a. RA(a,a)RBfA<a,a(f(a),f(a)). The family RB is functional in related choices of a,a and predecessor functions. Membership is Rvdf(f,f) together with the displayed well-founded witness.

At a minimal element a0, the predecessor domain is empty. A range expression may not evaluate g(z) because no z:A<a0 exists. Thus the first PER is determined without recursion. If PERs have been constructed for all z<a, the predecessor-function PER Pa and then RBg,a are determined. This is well-founded recursion on a.

If the cycle above were admitted, the construction at n would ask for the PER of f(n) while defining that very PER. The predecessor restriction does not contain n, so the expression f(n) is out of scope and the range fails formation before any fixed point is attempted.

Exercise 95.1

★★☆ Let A={0,1,2} with the usual strict order. Suppose B[f,0]=N, B[f,1]=Fin(f(0)+1), and B[f,2]=Fin(f(0)+f(1)+1). Construct the three range PERs in order. State the predecessor restriction available at each stage and explain why the definition is well founded.

Rules extracted from the semantics

The rule premises below keep the well-founded witness visible. Write g:Pred(y) for g:{gz:A<yB[g,z]}.

Definition 95.3 — Very-dependent function rules

The formation, introduction, elimination, computation, and extensional uniqueness rules are

ΓA typeΓ⊢<:AAUiWellFoundedi(A,<)Γ,y:A,g:Pred(y)B[g,y/f,x] type
Γ{fx:AB[f,x]} type
VDF-F
WellFoundedi(A,<)Γ,x:A,g:Pred(x)b:B[g,x/f,x]ExtA,B(b)
Γλx.b:{fx:AB[f,x]}
VDF-I
Γf:{fx:AB[f,x]}Γa:AWellFoundedi(A,<)
Γf(a):B[f,a/f,x]
VDF-E
Γa:A
(λx.b)(a)b[a/x][(λx.b)A<a/g]
VDF-β
Γf1:{fx:AB[f,x]}Γf2:{fx:AB[f,x]}a:A.Γf1(a)f2(a):B[f1,a/f,x]
Γf1f2:{fx:AB[f,x]}
VDF-Ext

The predicate ExtA,B(b) requires equal arguments and equal predecessor functions to produce equal results in the corresponding equal range PER. It is the annotation-level form of the source’s lambda equality premise.

The constructor derivation begins at minimal inputs. Let A={0,1} and take 0<1. Define f(0)=3,f(1)=true,B[f,0]=N,B[f,1]=if f(0)>0 then Bool else 0. At 0, the predecessor function has empty domain and 3:N. At 1, the restriction contains f(0)=3, so the range computes to Bool and true inhabits it. Rule VDF-I therefore classifies f. Application at 1 gives f(1):B[f,1]definitionBool. Application to a neutral a:A remains stuck: the range B[f,a] is known to be a type, but neither the branch nor the value f(a) computes.

Exercise 95.2

★★☆ Reverse the order on {0,1} in the preceding example. Show that the range at 1 is then ill formed because it reads f(0) at a nonpredecessor. Give a different range family whose dependency is accepted by the reversed order.

Substitution and semantic soundness

The well-founded witness is proof data, although it is absent from the printed type. Substitution must therefore transform the witness and every predecessor restriction.

Lemma 95.4 — Restriction commutes with substitution

Let θ:ΔΓ be a context substitution. If < is a strict well-founded relation on A in Γ, then <[θ] is a strict well-founded relation on A[θ], and (fA<a)[θ]=f[θ]A[θ]<[θ]a[θ].

Proof of Lemma 95.4 — Restriction commutes with substitution

Proof. The substituted relation has the same relation tree with every label and term acted on by θ. An infinite descending chain after substitution would map to a descending chain in the original derivation, contradicting its well-foundedness witness. Both restrictions have domain predicate z:A[θ] with z<[θ]a[θ], and both apply f[θ] to that z, so function extensionality in the PER model gives the equation. ◻

Theorem 95.5 — Substitution for very-dependent functions

Every derivable formation, membership, or equality judgment remains derivable after a well-formed context substitution.

Proof of Theorem 95.5 — Substitution for very-dependent functions

Proof. Induct on the derivation. In VDF-F, substitute into A, <, and B. Lemma 95.4 supplies the predecessor type used by the fourth premise, and the induction hypothesis gives formation of the substituted range. In VDF-I, the same lemma transports the body typing and ExtA,B pointwise. In VDF-E, substitute into the membership witness and argument; the result type is B[θ][f[θ],a[θ]/f,x] by capture avoidance. The extensional case applies the equality induction hypothesis at each substituted argument. ◻

Theorem 95.6 — Soundness of the extracted rules

Assume the predicative PER hierarchy used by convention 95.1. The rules in definition 95.3 preserve typehood and PER membership. The semantic construction is well founded at exactly the displayed witness (A,<).

Proof of Theorem 95.6 — Soundness of the extracted rules

Proof. Use well-founded induction on a:A. The induction hypothesis supplies the PERs for every strict predecessor, hence the PER Pa of predecessor functions. The fourth premise of VDF-F then supplies a functional range PER RBg,a. Equation (95.1) is symmetric because the domain, predecessor-function, and range PERs are symmetric. For transitivity, use functionality to replace the middle predecessor representative before applying transitivity of the range PER. The premise of VDF-I places each result in its range PER. Rule VDF-E selects that membership fact. The beta equation is ordinary function computation with the predecessor restriction substituted for g, and VDF-Ext is the definition of Rvdf. ◻

Removing well-foundedness leaves the rule statement syntactically meaningful but invalidates the induction that constructs Pa. Removing functionality of RB makes transitivity depend on the chosen representative. These are the two substantive hypotheses of the theorem.

Dependent records as ordered functions

Fix a finite list of labels l0<<ln. A dependent record type {l0:M0; l1:M1(l0);;ln:Mn(l0,,ln1)} is translated to {f | l:Labelcase l of liMi(f(l0),,f(li1))_}. The label order is well founded, and the ith range reads only strict predecessors. Record selection is function application.

For a point object, take PointMethods(R):={get:RZ;set:RZR;law:r:R.i:Z. get(set(r,i))=i}. The range for law may read the earlier values at get and set. It may not read the value at law itself. With representation R=Z, define get(r)=r and set(r,i)=i; reflexivity proves the law.

The corresponding abstract object type is Object(M):=R:Uis:RM(R). An object implementation chooses R, a state, and a dependent method record. Conversely, opening this Sigma supplies exactly those three pieces. This gives the source’s ADT/object correspondence: implementations of a signature are proofs of the existential specification, while method wrappers hide R again.

Proposition 95.7 — Width subtyping

Let R extend the ordered record R by labels placed after every label of R, and suppose the shared range types agree extensionally. Then every member of R is a member of R by restriction to the labels of R.

Proof of Proposition 95.7 — Width subtyping

Proof. Let f:R. For each label l of R, the predecessor restriction required by R is the restriction of the one already validated for R. The shared range type is equal by hypothesis, so VDF-E gives f(l):BR[f,l]. Equation (95.1) then proves membership of the restricted function in R. No premise mentions a new label, so deleting all new branches preserves every old range judgment. ◻

Insertion of a field before an old label requires a new proof: an old range may inspect all predecessors and may therefore change. Updating one field can likewise invalidate later fields. The Point law, for example, is not preserved by changing set without changing its proof field.

What the constructor does not provide

An ordinary Π-type permits B(x) but not B(f,x). Dependent intersection adds a view of one existing subject but performs no recursion over a domain. System S substitutes a term into its own assigned type but does not define a function range by predecessor recursion. Very-dependent formation uses the fourth premise of VDF-F; none of the other formers has that premise.

The source leaves general type checking undecidable: the well-founded relation may be implicit and type equality is extensional. It also withholds the desired binary-method rule. A method whose argument has the hidden representation type of a different object cannot be typed merely from the receiver’s existential package. Well-founded label dependency does not reveal that other representation.

Exercise 95.3

★★☆ Give a binary method type RRBool inside Object(M). Open two independently packed objects and show that their representation types are R1 and R2. Identify the ill-typed application that would require R1R2.

Suggested first pass.

Begin with exercise 95.4, then complete exercise 95.6.

Exercise 95.4

★★☆ Translate the Point record into a VDF type. List the predecessor labels used by each range. Then swap the order of set and law and locate the failed range formation judgment.

Exercise 95.5

★★★ Extend Point with a color field and color-changing method. Prove width subtyping by proposition 95.7, and calculate a wrapper that updates the position while preserving the color fields. Give a counterexample to the same calculation when a new field is inserted before an old dependent law.

Exercise 95.6

★★★ Practical project.very-dependent-order-checker Implement in Kappa a checker for finite VDF record declarations. Represent each field by its label and the list of fields read by its range. Maintain the invariant that every dependency is a strict predecessor in the numeric order. The checker must accept the Point declaration and the three-stage numeric example, reject a self-dependent field, reject a two-field cycle, and check the predecessor set visible at a named field. Changing the strict comparison to a non-strict one must make the test fail.

Sources. Hickey introduces the record obstruction on page 4 and the exact very-dependent meaning explanation on pages 5–6 of the FOOL paper. The record translation and Point object occupy pages 7–9; the binary-method boundary is stated on page 10. The 2001 thesis’s dedicated development gives the longer MetaPRL development. The public 2026 MetaPRL checkout preserves a later itt_dfun theory, not the exact 1996 proof state. The Kappa artifact therefore checks finite dependency orders; it neither decides extensional Nuprl typehood nor proves the PER theorem [Hic96].

Search the book

Type to search the local edition.