Lectures onType Theory
Chapter 60
Chapter 60Core route

The Lambda Cube and Pure Type Systems

Three binders have appeared with three separate typing rules. In the simply typed calculus of chapter 2, λx:A.x abstracts a term variable. The uniform PTS syntax writes the same abstraction as λ(x:A).x. In System F (chapter 5), ΛX.λ(x:X).x:X.XX abstracts a type variable in a term. In Fω (chapter 9), the expression λX::Ty.XX abstracts a type variable in a type operator. The three rules differ only in the classes of the domain, the body, and the resulting product. A uniform product rule must therefore expose all three classes; one structural argument can then cover every admitted triple.

One product rule with three classifiers

Write for the class of ordinary types and for the class of kinds. These two symbols are sorts: primitive classifiers that may occur on the right of a typing judgment. A product whose domain has sort s1, whose codomain has sort s2, and which itself has sort s3 is controlled by the triple (s1,s2,s3).

Example 60.1 — The baseline and the optional directions

Let A: and Nat:. The following products separate the baseline from two optional directions. a:AA:uses (,,),X:X:uses (,,),F::uses (,,). The second product classifies polymorphic terms. The third classifies type operators. A fourth possibility, (,,), allows a type or kind to depend on a term. For example, the declaration Vec:n:Nat requires that fourth triple. The word direction records dependency: it does not assert that every well-sorted body mentions its bound variable.

The examples force a syntax in which terms, types, and kinds are not separate grammatical categories.

Definition 60.2 — Pure-type-system specification

Fix a set C of constants. A pure-type-system specification, abbreviated PTS specification, is a triple S=(S,A,R) consisting of:

  1. a set SC of sorts;

  2. a set AC×S of axioms, written c:s;

  3. a set RS×S×S of product triples.

For every sS, fix an infinite set Vs of variables. The sets C,Vs are pairwise disjoint, and V:=sSVs. Here R is the PTS product-triple set; it is unrelated to the rule sets and reducibility candidates denoted by the same calligraphic letter in earlier chapters. The pseudo-terms of S are generated by M,N,A,B::=xcMNλ(x:A).Mx:AB. Here xV and cC. The binder x binds in M or B, respectively. Expressions identify alpha-equivalent pseudo-terms. We write M[N/x] for capture-avoiding replacement of the free occurrences of x in M by N, renaming bound variables first when necessary. When xFV(B), write AB for x:AB. Compatible beta-reduction is the least relation closed under every pseudo-term constructor and containing X(λ(x:A).M)NβM[N/x]Beta. Write β for its reflexive-transitive closure and M=βN when M and N are related by the equivalence relation it generates.

Allowing c:s with cC is intentional. It is the general PTS schema of [Bar92], not a later signature extension, and permits a base-type constant such as Nat:. The common sort-only specialization has AS×S. The lambda-cube instances below use that specialization with the sole axiom :; adding a base-type constant changes the signature but not its cube vertex.

The typography of a name does not determine whether it is a constant or a variable. Thus a displayed family name such as Vec may denote a member of some Vs; its context declaration must then be justified by Var. It may occur in A only when its declared type is a sort. This distinction prevents a family declaration such as Vec:n:Nat from bypassing Prod.

In this chapter, the letter M ranges over arbitrary PTS expressions, not merely program terms.

Definition 60.3 — PTS typing

For a specification S=(S,A,R), the judgment ΓSM:A is generated by the following rules. Contexts are finite lists of declarations with distinct subjects. c:sASc:sAxΓSA:sxVsxdom(Γ)Γ,x:ASx:AVar ΓSM:AΓSB:sxVsxdom(Γ)Γ,x:BSM:AWeak ΓSA:s1Γ,x:ASB:s2(s1,s2,s3)RΓSx:AB:s3Prod Γ,x:ASM:BΓSx:AB:sΓSλ(x:A).M:x:ABLam ΓSF:x:ABΓSN:AΓSFN:B[N/x]App ΓSM:AΓSB:sA=βBΓSM:BConv The specification determines which instances of Prod exist; the other rules are fixed.

The sort premise in Conv prevents an unclassified expression from being installed as a type. Removing it leaves a well-formed rule, but destroys the presupposition that the right side of every typing judgment is a sort or has a sort.

Example 60.4 — The polymorphic identity

Let S={,},A={:},R={(,,),(,,)}. Write the short subderivations DX:=:AS:AxX:SX:Var,DX+x:=DXDXxXX:,x:XSX:Weak,DΠ:=DXDX+x(,,)RX:Sx:XX:Prod,Did:=DXX:,x:XSx:XVarDΠX:Sλ(x:X).x:x:XXLam,Did:=:AS:AxDΠ(,,)RSX:x:XX:Prod. Every leaf of the required derivation is now visible: DidDidSλ(X:).λ(x:X).x:X:x:XXLam. The outer product uses (,,); the inner product uses (,,). Thus the derivation records exactly which axis polymorphism requires.

The application rule can now be read on a closed constructor. Put I:=λ(X:).λ(x:X).x, and work in the legal context A:,a:A. Weakening the final judgment of example 60.4 into this context and applying App gives A:,a:ASI:X:x:XXA:,a:ASA:A:,a:ASIA:x:AAApp. A second use of App derives A:,a:ASIAa:A. The corresponding computation performs two compatible beta-steps: IAaβBeta(λ(x:A).x)aβBetaa. Conversion should do real work rather than rename an alpha-bound variable. In λ2ω, put F0:=λ(Y:).YY. The triple (,,) forms the outer product in the type of F0, while (,,) forms its body YY; hence F0:Y:. In the legal context A:,a:A,g:Y:F0Y, rule App first derives gA:F0A. Since F0AβAA, and AA:, rule Conv derives gA:AA; another application derives gAa:A. This is conversion at a type-level beta-redex.

By contrast, in a legal context containing f:y:AB and N:A, the application fN is neutral: App gives it type B[N/y], but no beta-step applies because its head is the variable f.

Exercise 60.1

★☆☆ Delete (,,) from the specification in example 60.4. Mark the first premise in its derivation that can no longer be discharged. Verify that the monomorphic term λ(x:X).x remains typable in the context X:. (Six lines.)

The eight vertices

For the lambda cube, fix S={,} and A={:}. Write r:=(,,),r2:=(,,),rω:=(,,),rP:=(,,). The baseline r forms ordinary function types. Adding r2 permits terms to depend on types, adding rω permits type operators to depend on types, and adding rP permits types to depend on terms. All four cube triples satisfy s3=s2; general PTS specifications need not have that property.

Definition 60.5 — Lambda-cube systems

For I{2,ω,P}, let λI be the PTS with product triples {r}{riiI}. We use the following compact subscripts throughout this chapter: IsystemRλr{2}λ2r,r2{ω}λωr,rω{P}λPr,rP{2,ω}λ2ωr,r2,rω{2,P}λP2r,r2,rP{ω,P}λPωr,rω,rP{2,ω,P}λCr,r2,rω,rP. The top system λC is the Calculus of Constructions. Barendregt’s conventional names distinguish the vertices by writing λω for our λω, λω for our λ2ω, λPω for our λPω, and λPω=λC for the top vertex [Bar92]. Thus our subscript Pω is a set-valued axis label, not Barendregt’s name λPω.

Lemma 60.6 — Monotonicity in product triples

Let S=(S,A,R) and S=(S,A,R), with RR. Then ΓSM:AΓSM:A.

Proof of Lemma 60.6 — Monotonicity in product triples

Proof. Induct on the displayed derivation. Rebuild every rule with the induction hypotheses. In the Prod case, its triple lies in R by the inclusion; no other rule inspects the product-triple set. ◻

The cube below records these inclusions. A solid edge labeled 2 or ω adds the indicated triple; a dashed edge labeled P adds rP. A crossing without a node is not a vertex. If IJK, write ιI,J for the inclusion proved by lemma 60.6; each square asserts ιJ,KιI,J=ιI,K. Both sides preserve the same derivation tree and merely regard every Prod membership witness in the larger set. Mathematical diagramDiagram

Proposition 60.7 — Recovery of the familiar systems

The syntax translations from Church-style STLC with type variables, System F, and Fω with term polymorphism into λ, λ2, and λ2ω, respectively, preserve typing and beta-reduction. Conversely, a derivation-directed decoding maps every derivable judgment in the image of one of these translations back to its source calculus, up to alpha-equivalence, and maps beta-steps between such image expressions to source beta-steps. The top vertex λC is exactly the PTS presentation of the Calculus of Constructions.

Proof of Proposition 60.7 — Recovery of the familiar systems

Proof. Map every arrow AB to x:AB with xFV(B), every term abstraction to the PTS abstraction, every System F type abstraction ΛX.M to λ(X:).M, and every kind abstraction to the same PTS constructor. Applications are unchanged; type application becomes ordinary application.

For preservation, rule induction on the source derivation replaces each source formation rule by the indicated product triple. The three non-structural cases are source rulePTS tripleAB typerX.B typer2KK kindrω The abstraction and application rules then coincide with Lam and App. Substitution is unchanged, so source beta-contraction maps to PTS beta-contraction.

For reflection, do not attempt to invert the translation on arbitrary pseudo-terms. Define the decoding simultaneously on PTS derivations and their premises. Its invariant assigns each decoded expression the source syntactic class determined by its typing derivation and returns a source derivation whose translation is alpha-equivalent to the PTS conclusion.

Rules Ax, Var, and Weak decode their premises and reconstruct the corresponding source rules. In a Prod derivation in the translated fragment, the final triple is one row of the table, so it determines whether the source constructor is an ordinary arrow, a universal type, or a kind arrow. In a Lam derivation, its product premise has fixed the class of the bound variable and the body. In an App derivation, the decoded product type of the function determines whether the source step is term application, type application, or kind application; this resolves the two applications present in λ2. Rule Conv reconstructs source conversion after decoding its sort premise. These clauses cover every rule whose conclusion is in the translated fragment and preserve the invariant.

A legal beta-redex is an application whose function derivation decodes to an abstraction with the same source class for its binder and argument. Decoding its contraction therefore gives source capture-avoiding substitution, and the source beta-rule translates back to the original PTS contraction. Congruence cases follow by decoding the derivation of the reduced subexpression. This proves reflection without claiming a syntactic inverse on untyped pseudo-terms. ◻

The qualification with type variables is necessary at the bottom vertex. The axiom : permits declarations X:. A fixed-base STLC is obtained by restricting contexts and adding named base-type constants; that restriction is not a different cube vertex.

The fourth clause is not an adequacy theorem for a separately defined surface language. Rather, λC is the PTS presentation called the Calculus of Constructions in [Bar92]. The primary presentation of the calculus, with dependent products and two classifier levels, is [CH88]. Relating either presentation to a different surface language would require a separate encoding theorem.

Example 60.8 — A term-indexed family at the P-vertex

Extend the constant axioms by Nat:, and work in λP. Choose nV. The family kind is derived by Nat:n:Nat:rP=(,,)n:Nat:Prod. The middle premise is Weak applied to :. Consequently a context declaration Vec:n:Nat, with VecV, is legal only when the P-axis is present. Choose a fresh vV, with Vec,n,v pairwise distinct, and put Γ0:=(Vec:n:Nat), n:Nat,Γ1:=Γ0,v:Vecn. Rules Var, App, Prod, and Lam derive Γ1v:Vecn,Γ0λ(v:Vecn).v:v:VecnVecn. The type depends on the neutral term n; no beta-step removes that dependency. Abstracting n once more gives the displayed dependent judgment Vec:n:Nat λ(n:Nat).λ(v:Vecn).v:n:Natv:VecnVecn. The inner and outer term abstractions use r, while formation of the family’s context declaration uses rP. The only constant added to the axiom set is Nat:; Vec enters the context through Var, not Ax.

Exercise 60.2

★★☆ For each of the following products, give the least vertex of the lambda cube in which it is formable and name the decisive product triple: X:XX,F:()X:FXFX,n:NatVecnVecn. A name may be added as an axiom only with a sort on its right. Every other declaration must have its type derived in the candidate vertex; in particular, derive Vec:n:Nat as in example 60.8. Prove minimality by deleting one triple in each case and use lemma 60.6 for the upward inclusions. (Half a page.)

Structural metatheory

The PTS rules are uniform enough that their structural proofs use only capture-avoiding substitution and the placement of declarations in a context. No normalization hypothesis is needed.

Lemma 60.10 — Context validity

If x1:A1,,xn:An is legal, then for every i there is a sort si such that x1:A1,,xi1:Ai1SAi:si.

Proof of Lemma 60.10 — Context validity

Proof. Choose a derivation in which the context occurs and induct on that derivation. Rules Ax, Prod, Lam, App, and Conv either have empty context or have a premise with the same context; apply the induction hypothesis to that premise. A final Var has context Θ,x:A and premise ΘA:s. A final Weak has context Θ,x:B, first premise in Θ, and declaration premise ΘB:s. In either case the induction hypothesis gives the claims for Θ, and the declaration premise gives the last claim. These are all possible final rules. ◻

Lemma 60.11 — Free variables

If Γ=x1:A1,,xn:An and ΓSM:B, then

  1. the variables x1,,xn are pairwise distinct;

  2. FV(M)FV(B){x1,,xn};

  3. FV(Ai){x1,,xi1} for every 1in.

Proof of Lemma 60.11 — Free variables

Proof. Proceed by rule induction on the typing derivation. Rule Ax has empty context. Rules Var and Weak append a name outside the context domain, and their sort premise gives the induction hypotheses for the new declaration. Rules Prod and Lam bind x in the second premise; removing x from that premise’s free-variable set gives the claimed set for the conclusion. Rule App takes the union of the two premise bounds and then substitutes N for x; the capture-avoiding substitution equation FV(B[N/x])(FV(B){x})FV(N) gives the result. Rule Conv uses the two premise bounds. These are all rule families. ◻

Lemma 60.12 — Composition of substitution

Capture-avoiding substitution on pseudo-terms satisfies D[N/x][P[N/x]/y]=D[P/y][N/x](yFV(N){x}).

Proof of Lemma 60.12 — Composition of substitution

Proof. This equation follows by structural induction on D; at either binder, first choose a representative whose bound name avoids FV(N)FV(P){x,y}. ◻

Lemma 60.13 — Beta-equivalence and substitution

Capture-avoiding substitution respects beta-equivalence in both inputs: M=βNM[P/x]=βN[P/x],P=βQM[P/x]=βM[Q/x].

Proof of Lemma 60.13 — Beta-equivalence and substitution

Proof. For the first implication, induct over the compatible beta reductions and their symmetric, transitive closure. A contracted redex is preserved after choosing its binder fresh; lemma 60.12 identifies the contractum. Congruence reconstructs every surrounding constructor. For the second implication, perform structural induction on M. Each free occurrence of x contributes the given beta-equivalence, while constructor congruence combines the induction hypotheses; at a binder, first choose its name fresh for P and Q. ◻

Lemma 60.14 — Weakening

Suppose Γ,ΔSM:A and ΓSB:s. If xdom(Γ,Δ), then Γ,x:B,ΔSM:A.

Proof of Lemma 60.14 — Weakening

Proof. Generalize over the split Γ,Δ and perform rule induction on the first derivation. Keep the declaration-legality derivation ΓB:s as an explicit second input.

Rules Prod, Lam, App, and Conv are reconstructed after applying the induction hypothesis to every premise with context Γ,Δ. In a product or lambda premise under y:C, choose yFV(B){x}dom(Γ,Δ) and apply the induction hypothesis at the enlarged suffix Δ,y:C. This inserts x:B before that binder, as required.

The two context-extending rules expose why the split was generalized. If a final Var concludes in Γ,Δ0,y:C with Δ=Δ0,y:C, apply the induction hypothesis to its premise Γ,Δ0C:sC and then reapply Var: Γ,x:B,Δ0C:sCydom(Γ,x:B,Δ0)Γ,x:B,Δ0,y:Cy:CVar. A final Weak with the same nonempty suffix is identical: apply the two induction hypotheses to its typing and declaration-sort premises and reapply Weak. If Δ is empty, either final rule already has conclusion in Γ; one application of Weak, justified by the fixed premise ΓB:s, appends x:B to that conclusion.

Finally, an Ax conclusion has empty context, so both parts of the split are empty. Reapply Weak to Ax using B:s. Every recursive call is on a proper premise of the original derivation, and the freshness condition follows from the theorem’s hypothesis. This exhausts the typing rules. ◻

Theorem 60.15 — Substitution

If Γ,x:A,ΔSM:BandΓSN:A, then Γ,Δ[N/x]SM[N/x]:B[N/x]. The simultaneous substitution Δ[N/x] acts on every declaration type.

Proof of Theorem 60.15 — Substitution

Proof. The proof is by rule induction on the first derivation. Keep the second derivation fixed.

Variable cases. If the conclusion selects x:A, substitution changes it to N:A, which is the fixed second premise: a final Var selecting x forces Δ=. Moreover, lemma 60.11 gives xFV(A), so A[N/x]=A. If the conclusion selects a different declaration y:C, the induction hypothesis for the derivation of C:s gives C[N/x]:s; Var derives y:C[N/x] in the substituted context.

Product case. The last rule has premises Γ,x:A,ΔC:s1,Γ,x:A,Δ,y:CD:s2, and (s1,s2,s3)R. Choose the representative with yFV(N){x}dom(Γ,Δ). The induction hypotheses give Γ,Δ[N/x]C[N/x]:s1,Γ,Δ[N/x],y:C[N/x]D[N/x]:s2. Rule Prod yields the required product. The fresh choice gives y:C[N/x]D[N/x]=(y:CD)[N/x].

Abstraction case. Use the same fresh choice for the bound variable y. The induction hypotheses derive the substituted body and the substituted product. Rule Lam then derives Γ,Δ[N/x]λ(y:C[N/x]).M0[N/x]:y:C[N/x]D[N/x].

Application case. Suppose the final premises type F:y:CD and P:C. The induction hypotheses type F[N/x] and P[N/x]. Rule App gives the type D[N/x][P[N/x]/y]=equation60.2D[P/y][N/x], where the representative has yFV(N){x}.

Weakening and conversion cases. A final Ax is impossible because the context of the first derivation contains the declaration x:A. Suppose a final Weak appends y:C. If yx, then the context has the form Γ,x:A,Δ0,y:C; the two induction hypotheses type the weakened judgment and C[N/x], and Weak reconstructs the conclusion. If the appended declaration is x:A, then Δ is empty and the premise of Weak is the required target judgment. Indeed, lemma 60.11 gives xFV(M)FV(B), so M[N/x]=M and B[N/x]=B. For Conv, the induction hypotheses give the substituted typing and sort premises; lemma 60.13 gives C[N/x]=βD[N/x], so Conv applies. These cases exhaust the typing rules. ◻

Exercise 60.3

★☆☆ Let Γ be legal and contain F:y:AD. Assume ΓA:s, ΓN:A, and xdom(Γ), choosing yFV(N){x}. Instantiate theorem 60.15 with M:=Fx. Write the complete derivation of FN:D[N/y], including the weakening needed to type F in the source context. Name the free-variable fact that simplifies the substituted result type. (Ten lines.)

Lemma 60.16 — Generation

Suppose the displayed judgment is derivable.

  1. If Γc:C, then c:sA and C=βs for some sS.

  2. If Γx:C, then x:AΓ and C=βA for some A with ΓA:s.

  3. If Γx:AB:C, then for some (s1,s2,s3)R, ΓA:s1,Γ,x:AB:s2,C=βs3.

  4. If Γλ(x:A).M:C, then for some B and s, Γ,x:AM:B,Γx:AB:s,C=βx:AB.

  5. If ΓFN:C, then for some A,B, ΓF:x:AB,ΓN:A,C=βB[N/x].

The subscripts S are suppressed in this statement.

Proof of Lemma 60.16 — Generation

Proof. Follow the derivation upward past every final Weak or Conv; neither rule changes the subject. The first rule that constructs the subject must be Ax, Var, Prod, Lam, or App, respectively. Its premises give the displayed judgments. Each skipped Conv contributes one beta-equality, whose composite gives the asserted equality. For each skipped Weak, the constructing rule’s premises hold in a prefix Γ0 of Γ; repeated applications of lemma 60.14 reinsert the declarations of ΓΓ0 in their original order. The required sort premises are the declaration premises of those skipped Weak rules, equivalently the corresponding instances of lemma 60.10. This proves all five clauses. ◻

Lemma 60.17 — Correctness of types

If ΓSM:A, then either AS or there is a sort sS such that ΓSA:s.

Proof of Lemma 60.17 — Correctness of types

Proof. Proceed by rule induction. Rule Ax concludes with the sort on the right, and Prod concludes with its result sort. The declaration-sort premise of Var gives the second alternative. In Weak, the induction hypothesis either says that the unchanged type is a sort or gives its sort derivation; in the second case, Weak extends that derivation.

The product premise of Lam gives the sort of its result type. In App, the function type is a product expression and therefore is not a sort constant. The induction hypothesis for the function premise must therefore give a sort derivation for that product. Generation applied to that derivation gives ΓA:s1,Γ,x:AB:s2. The argument premise and theorem 60.15 therefore give ΓB[N/x]:s2. Finally, the sort premise of Conv gives the second alternative directly. Notice that the Ax branch may end at a top sort with no classifier; this is why the statement has two alternatives. ◻

Lemma 60.18 — Confluence of beta-reduction on pseudo-terms

For the pseudo-terms of definition 60.2, if MβN1 and MβN2, then some pseudo-term P satisfies N1βPandN2βP. No typing hypothesis is required.

Proof of Lemma 60.18 — Confluence of beta-reduction on pseudo-terms

Proof. Define MparN, read as parallel reduction from M to N, by reflexivity on variables and constants, componentwise clauses for application, annotated abstraction, and product, and the contracting clause AparAMparMNparN(λ(x:A).M)NparM[N/x]. The only binder side condition is the choice of an alpha-representative whose bound variable avoids the free variables of the substituted argument. Structural induction proves the substitution property MparM  NparNM[N/x]parM[N/x]. The abstraction and product cases choose the same fresh representative on both sides; the variable, constant, and application cases are the defining clauses.

Define the complete development M recursively by developing every component and contracting every redex visible in M. Thus ((λ(x:A).M)N):=M[N/x], while a non-redex application develops its two components, and abstractions and products develop their annotations and bodies. Induction on a derivation of MparN, using the substitution property in the contracting case, gives the triangle property MparNNparM. Hence parallel reduction is diamond. One beta-step is a parallel step, and every parallel step is a finite compatible beta-reduction, as induction on its derivation shows. Replacing the two finite beta-reductions by their parallel factorizations and using the diamond property proves the stated confluence. ◻

Corollary 60.19 — Church–Rosser

If M=βN, then some P satisfies MβPandNβP.

Proof of Corollary 60.19 — Church–Rosser

Proof. Induct on the length of a reflexive, symmetric, transitive beta-conversion chain from M to N. The reflexive case chooses P=M. For one more forward or backward beta segment, apply lemma 60.18 to the common endpoint obtained by the induction hypothesis. This tiles the new segment with a common reduct. ◻

Lemma 60.20 — Product compatibility

If x:AB=βx:AB, then A=βA and B=βB.

Proof of Lemma 60.20 — Product compatibility

Proof. By corollary 60.19, the two products reduce to a common expression P. No beta-step removes an outer product constructor, so P=x:CD for some C,D. The left reductions give AβC and BβD; the right reductions give AβC and BβD. The two beta-equalities follow. ◻

Subject reduction must account for reduction in a context declaration as well as reduction in the subject. The mutual statement makes that dependency explicit.

Theorem 60.21 — Subject reduction

For every PTS specification S:

  1. if ΓSM:A and MβM, then ΓSM:A;

  2. if ΓSM:A and one declaration type in Γ takes a beta-step, producing a legal context Γ, then ΓSM:A.

Proof of Theorem 60.21 — Subject reduction

Proof. Prove the two clauses simultaneously by rule induction on the typing derivation. For every proper premise derivation, the first induction hypothesis preserves its type after one compatible step in its subject. The second preserves the judgment after one declaration type in its context steps, provided the resulting context is legal. We display computation, product, abstraction, application, conversion, and context-extension cases.

Beta-redex. Suppose the final App has premises Γλ(x:A0).M0:x:CD,ΓN:C, and its subject contracts to M0[N/x]. Generation for the abstraction gives a family B and a sort s such that Γ,x:A0M0:B,Γx:A0B:s,x:A0B=βx:CD. Product compatibility gives A0=βC and B=βD. Generation for the displayed product gives ΓA0:s0, so Conv derives ΓN:A0. Substitution gives ΓM0[N/x]:B[N/x]. The type x:CD is not a sort, so lemma 60.17 applied to the function premise gives Γx:CD:s. Generation and substitution with ΓN:C then give ΓD[N/x]:sD. By lemma 60.13, B[N/x]=βD[N/x](B=βD). Rule Conv, with the derived sort premise for D[N/x], restores the exact App result type.

Product formation. Suppose the final rule derives Γx:AB:s3. If AβA, the first induction hypothesis gives ΓA:s1. Rule Var establishes that Γ,x:A legal, so the second induction hypothesis changes the codomain premise to Γ,x:AB:s2. Reapplying Prod gives Γx:AB:s3. If the step is in B, the first induction hypothesis on the codomain premise followed by Prod gives the result. If a declaration in Γ steps, the second induction hypothesis repairs both formation premises before Prod is reapplied.

Lambda annotation. Suppose AβA inside λ(x:A).M. The first induction hypothesis on the product premise changes Γx:AB:stoΓx:AB:s. Generation of the latter judgment shows that Γ,x:A is legal. The second mutual induction hypothesis therefore changes the body premise from Γ,x:AM:B to Γ,x:AM:B. Rule Lam derives Γλ(x:A).M:x:AB. Because x:AB=βx:AB, Conv restores the original type, using the original product premise as its required sort premise. Reduction in the body uses the first induction hypothesis under the freshly chosen binder.

For App, a step in the function is handled by the first induction hypothesis and reapplication of App. If the argument changes from N to N, the first induction hypothesis and App derive ΓFN:B[N/x]. Correctness of types for F:x:AB, followed by generation and substitution with N:A, gives ΓB[N/x]:sB. Since B[N/x]=βB[N/x], Conv restores the stated type. Rules Ax and Var have no principal redex in the subject-reduction clause.

For the context-reduction clause, Var has one additional principal case. Suppose its selected declaration changes from x:C to x:C with CβC. Subject reduction on the declaration-sort premise gives ΘC:s. Hence Var gives Θ,x:Cx:C. Weakening the old sort derivation ΘC:s across x:C gives Θ,x:CC:s, and Conv, using C=βC, restores Θ,x:Cx:C. If the changed declaration is earlier than the selected one, the mutual induction hypothesis first repairs the selected declaration’s sort premise and Var is reapplied. For a final Weak, distinguish a change in its newly appended declaration from a change in its prefix. In the former case subject reduction repairs its declaration-sort premise; in the latter the mutual induction hypotheses repair both premises. Rule Ax has empty context. For clause 1, Weak applies the first induction hypothesis to its typing premise and reattaches the unchanged declaration. Rule Conv applies the first induction hypothesis to its typing premise and, if the step is in the chosen result type, to its sort premise before reapplying conversion. For clause 2, both rules use the second induction hypothesis on every premise with the changed context. These cases exhaust compatible beta-reduction in subjects and contexts. ◻

Corollary 60.22 — Legality under declaration reduction

Suppose Γ is legal and one declaration type in Γ takes a beta-step, producing Γ. Then Γ is legal. Moreover, ΓSM:AΓSM:A.

Proof of Corollary 60.22 — Legality under declaration reduction

Proof. Write Γ=Θ,x:C,Δ,Γ=Θ,x:C,Δ,CβC. Context validity gives ΘC:s, and the first clause of theorem 60.21 gives ΘC:s. Hence Θ,x:C is legal.

Proceed from left to right through the declarations of Δ. Suppose the target prefix constructed so far is legal. Context validity gives a sort derivation for the next declaration type in the corresponding source prefix. The second clause of theorem 60.21, applied to that derivation and the legal target prefix, gives the same declaration-sort judgment in the target prefix. Appending it preserves legality. Induction on the length of Δ proves that Γ is legal. The second clause of theorem 60.21 now gives the final implication. ◻

Exercise 60.4

★★☆ Complete the App argument-reduction case in the subject-reduction proof. If NβN, derive the type B[N/x] of FN and then derive the original type B[N/x]. Put the reason for the final conversion on the equality step. (Half a page.)

Normalization and decisions belong to instances

The rules of definition 60.3 also describe specifications with :. Structural uniformity therefore cannot imply normalization.

Theorem 60.23 — Strong normalization of the lambda cube

For each of the eight systems λI of definition 60.5, if ΓλIM:A, then every compatible beta-reduction sequence from M, A, or a declaration type in Γ is finite.

Proof of Theorem 60.23 — Strong normalization of the lambda cube

Proof. This is the exact strong-normalization theorem for the lambda cube proved by Barendregt, [Bar92]. Its proof interprets the strongest vertex λC in a marked calculus, proves normalization of the marked constructors and objects, and transfers the result to every subsystem. The import applies here because definition 60.5 has the same sorts, axiom, four product triples, compatible beta-reduction, and Church-style typing rules. No claim about an arbitrary triple (S,A,R) is imported. ◻

The schema itself admits the one-sort specification S={},A={:},R={(,,)}. It is not a lambda-cube vertex. Its circular axiom invalidates the reducibility construction used by the theorem.

Theorem 60.24 — Girard's boundary for the one-sort PTS

In the displayed one-sort specification there is a closed term G such that G:A:A. Consequently every type of sort is inhabited. In addition, some typable term has no beta-normal form. Thus the specification is logically inconsistent under propositions-as-types and is not strongly normalizing.

Proof of Theorem 60.24 — Girard's boundary for the one-sort PTS

Proof. This is the contraction to λ of Girard’s paradox, imported with the exact one-sort signature from [Bar92]. The contraction from Girard’s system λU to λ preserves the displayed inhabitation result; the same corollary separately states that λ has typable terms without normal form. We do not use Proposition 5.2.31, whose hypothesis requires an extension of λ2. No claim about a different : specification is imported. ◻

Definition 60.25 — Functional and lookup-effective specifications

A PTS specification is functional when each constant has at most one axiom sort and every pair (s1,s2) has at most one product-result sort s3. It is lookup-effective when equality of constants and sorts is decidable and there are total computable procedures isSort:CBool,axiomSort:COption(S),productSort:S×SOption(S) such that isSort(c) is true exactly when cS, axiomSort(c)=some(s) exactly when (c,s)A, and productSort(s1,s2)=some(s3) exactly when (s1,s2,s3)R. Every lookup-effective specification is functional: the last two biconditionals imply uniqueness because each procedure returns at most one option value.

The partition V=sVs and the side conditions on Var and Weak are exactly the naming convention of Barendregt’s Section 5.2 presentation. Consequently the uniqueness and decidability results cited below apply to the displayed rules directly; no erasure or renaming transfer is being assumed.

Lemma 60.26 — Uniqueness of types modulo beta

If S is functional, ΓSM:A, and ΓSM:B, then A=βB.

Proof of Lemma 60.26 — Uniqueness of types modulo beta

Proof. This is Barendregt’s uniqueness lemma for functional PTSs [Bar92]; our functionality and typing rules are its hypotheses. Its induction is on the structure of the common subject M, not on either derivation. Apply lemma 60.16 to both derivations. Constants and variables select the same axiom or context declaration; products use functionality after their domain and codomain sorts have been identified; applications use lemma 60.20 and lemma 60.13; abstractions use generation on both bodies. Final Weak and Conv steps have already been absorbed by generation. This yields A=βB without a context-condensing premise. ◻

Theorem 60.27 — Conditional decidable checking

Let S be lookup-effective and let S be finite. Assume every legal expression is strongly beta-normalizing. There is a total computable procedure that, on input finite encodings of Γ, M, and A, decides whether ΓSM:A is derivable. Consequently, type checking is decidable at every lambda-cube vertex.

Proof of Theorem 60.27 — Conditional decidable checking

Proof. The imported result is Corollary 5.2.18 of Barendregt’s treatment [Bar92]. Here is the decision procedure under our more explicit effectiveness hypotheses. First validate the context from left to right. For each declaration, recursively synthesize an actual sort for its type, then extend the already validated prefix; an untyped top sort cannot be a declaration type. On terms, synthesize by the outer constructor. Constants and variables use the two finite lookups. A product synthesizes sorts for its domain and codomain and consults productSort. An abstraction first classifies its annotation, synthesizes its body in the extended context, and consults the same product table for the type thereby assembled. An application synthesizes its function, normalizes that already legal type to product form, checks the argument against the domain, and returns the substituted codomain. Checking first synthesizes, validates the proposed type as either a sort itself or an expression having a synthesized sort, and then compares the two types modulo beta. The terminal “is a sort” alternative is needed here because a derivable right-hand side may be the untyped top sort; it is not used when validating context declarations or binder annotations.

This mutual synthesis-and-classification procedure recurses on proper raw subterms. Its only subsidiary computation is normalization of expressions already established to be legal, which terminates by hypothesis; beta confluence from lemma 60.18 makes comparison of their normal forms decisive. Soundness rebuilds the rules of definition 60.3. Generation proves completeness constructor by constructor, product compatibility handles the application case, and lemma 60.26 proves completeness of the final conversion test. Thus the paragraph supplies a syntax-directed reconstruction of the corollary, not an attribution of this algorithm to one of the source’s intermediate lemmas.

Barendregt attributes the unprinted proof of the corollary to van Benthem Jutting’s method for the preceding condensing lemma; the statement of that lemma is not an algorithm or a termination measure. The source also leaves effective access to A and R implicit. Our lookup-effective hypothesis makes those finite decisions explicit.

Each cube system has finite lookup tables, and theorem 60.23 discharges the normalization hypothesis. ◻

Functionality is used only in completeness of synthesis. Without it, one subject may have two non-convertible product sorts, so an algorithm returning a single inferred type need not find the requested derivation. A finite search algorithm can still decide some nonfunctional specifications, but that is a different theorem. The normalization hypothesis is essential: type checking for the one-sort system λ is undecidable [Bar92].

Exercise 60.5

★★☆ Construct a finite PTS with sorts s0,s1,s2,s3, decidable membership in its three specification sets, and two triples (s0,s1,s2) and (s0,s1,s3) such that one product receives both s2 and s3. Identify the exact step of lemma 60.26 that fails. Do not use s:s. (Half a page.)

The boundary of the classification

Proposition 60.28 — What a cube placement does not establish

For a PTS specification S, the data (S,A,R) and a derivation ΓSM:A establish only formation and typing by the PTS rules. They do not, without separate rules and proofs, establish:

  1. adequacy of an encoding of another syntax or logic;

  2. formation or elimination principles for inductive or indexed families;

  3. an intensional identity type and its path-induction eliminator;

  4. a cumulative hierarchy of Martin–Löf universes or large elimination;

  5. a particular judgmental computation discipline beyond beta-conversion;

  6. normalization, consistency, canonicity, or decidable checking for an arbitrary PTS specification.

Proof of Proposition 60.28 — What a cube placement does not establish

Proof. The conclusion is about what follows from the displayed signature, not about what can be encoded by its terms. For example, an impredicative vertex may form Church data or Leibniz equality, but the PTS rules give those encodings no primitive induction rule, large eliminator, or judgmental computation rule beyond beta. Establishing that an encoding represents exactly the intended objects and eliminations is a separate adequacy theorem.

Likewise, neither A nor R contains induction constructors, an identity eliminator, or universe levels. Such rules must be added to a larger signature and their metatheory proved there. Theorem 60.24 separates the arbitrary PTS schema from the normalizing cube instances of theorem 60.23. Hence the last group of properties also requires instance hypotheses rather than cube placement alone. ◻

Suggested first pass.

None of these problems is a prerequisite for a later chapter. Begin with exercise 60.6, then complete exercise 60.9.

Exercise 60.6

★★☆ Choose one term witnessing each of the three optional cube axes. Give its complete PTS derivation, then delete the corresponding product triple and prove by generation that the term is no longer typable at that vertex.

Exercise 60.7

★★☆ Reconstruct the beta-redex case of subject reduction without suppressing the types A0,A,B,C,D. Mark the uses of product compatibility, conversion, and substitution. Then give a malformed variant obtained by deleting the sort premise from Conv and identify the presupposition that fails.

Exercise 60.8

★★☆ Compare λC with the one-sort system : at the level of specifications. Exhibit the common product rule and the differing axiom, and explain why inclusion in the PTS schema transfers theorem 60.15 but not theorem 60.23.

Exercise 60.9

★★★ Practical project.pts-cube-checker Implement in Agda or Kappa two bounded entry points. The first checks the finite, beta-normal fragment of the lambda-cube specifications in definition 60.3; the second admits one declared conversion stage in which visible type redexes are developed once. Globally fresh numeric binder names may stand for alpha-classes; state and check that invariant on every input, and use alpha-aware structural comparison for the beta-normal entry point. Preserve the invariant that every synthesized right-hand side is either a sort or has a derived sort. The program must print a trace annotated by the product triple used at each binder. It must accept the polymorphic identity of example 60.4 in λ2, reject it in λ at the outer product, accept the second product of exercise 60.2 in λ2ω, and reject the family declaration Vec:n:Nat required by the third product when rP is absent. Finally, admit one redex in a type, develop it, and accept an application whose argument type agrees with its domain only after that conversion. These five outcomes are the decidable acceptance test.

Sources. The PTS specification, generation and substitution arguments, subject reduction, cube vertices, and instance normalization theorem follow the exact systems in [Bar92]. A modern derivational route through the cube is given by [NG14, Geu09]. These references provide provenance and the imported strong-normalization theorem; the structural proofs used in this chapter are printed above. Barendregt’s earlier generalized-type- system paper gives the historical three-part specification and cube classification [Bar91]; its displayed rule sheet is not substituted for the 1992 PTS rules fixed in definition 60.3.

A bounded strength comparison.

Setzer analyzes Martin–Löf type theory with one universe and W-types, not a PTS or the Calculus of Constructions. For MLJ, ML[TD], and their two auxiliary presentations, Theorem 4.41 proves transfinite induction below ψΩ1(ΩI+n) for every nN. Corollary 4.42 then includes the stated extensional extension and uses the separately cited upper bound to obtain the exact ordinal ψΩ1(ΩI+ω), where I belongs to the paper’s notation system. The theorem and corollary cover the named intensional and extensional presentations. Setzer’s abstract separately states the same strength for the Tarski- and Russell-style universe presentations [Set98]. The well-ordering construction is not reproduced here, and no book result depends on it.

Search the book

Type to search the local edition.