Lectures onType Theory
Chapter 164
Chapter 164Core route

Dependent Parametricity

Let g be a closed term of type A:UAA. Nothing in the typing rules forbids g from behaving differently at different instances: the rules say that gA has type AA for every A, and they say nothing about the relation between g2 and gN. Consider the informal specification gAx:={ttif A is 2,xotherwise, which is well typed at every instance considered separately. It is not a term of the calculus, because there is no elimination form for U that could decide the case split. But that is a statement about which terms exist, and it is proved by inspecting the syntax; what we want is a statement about what every term does, proved once for all terms.

Reynolds’ answer is to interpret a type not as a set of values but as a relation, and to prove that every term is related to itself. In a dependent theory that answer needs revision twice over. The relation for x:AB must relate f1 and f2 at arguments x1 and x2 that are themselves only related, and the codomain B is then instantiated at two different arguments, so the relation for B must be allowed to depend on a proof that x1 and x2 are related. And types are terms, so the relational interpretation must itself be a term of the theory.

The simply typed case, and one free theorem

We begin where the difficulty is absent. Fix a finite set of type variables Θ=α1,,αk and let types be generated by σ,τ::=αiστ. A relation environment ϱ assigns to each αi a triple (Xi,Yi,Ri) of two sets and a relation RiXi×Yi.

Definition 164.1 — Relational interpretation of simple types

For a type τ over Θ and a relation environment ϱ define a relation Rτ[ϱ] between the two sets A1(τ) and A2(τ) given by A1(αi):=Xi, A2(αi):=Yi, and Aj(στ):= the set of functions Aj(σ)Aj(τ). A term x:σe:τ denotes, in the copy j, a function Aj(e) from tuples in Aj(σ1)× to Aj(τ), by the usual clauses for variables, abstraction and application. Set Rαi[ϱ]:=Ri,Rστ[ϱ]:={(f1,f2) | (a1,a2)Rσ[ϱ]. (f1a1,f2a2)Rτ[ϱ]}.

Proposition 164.2 — Abstraction for simple types

Let x1:σ1,,xm:σme:τ over Θ and let ϱ be a relation environment. If (aj,bj)Rσj[ϱ] for every j, then (A1(e)(a),A2(e)(b))Rτ[ϱ].

Proof of Proposition 164.2 — Abstraction for simple types

Proof. By induction on the derivation. Variable case. A1(xj)(a)=aj and A2(xj)(b)=bj, and the pair is related by hypothesis. Abstraction case. Let e=λy.e0 with y:σ0. To show the pair of functions is in Rσ0τ0[ϱ], take (c1,c2)Rσ0[ϱ]; the induction hypothesis for e0 with the extended environments gives (A1(e0)(a,c1),A2(e0)(b,c2))Rτ0[ϱ], which is the required condition by definition 164.1. Application case. As in the abstraction case with the two quantifiers exchanged: the induction hypothesis for the operator gives membership in Rσ0τ[ϱ], and the induction hypothesis for the operand supplies the pair at which that membership is instantiated. ◻

Now add one quantifier. Suppose a term g has, at every set X, an element gXXX, and suppose these are related in the sense that (gX,gY)Rαα[α(X,Y,R)] for every relation R.

Proposition 164.3 — The identity free theorem

Under that hypothesis, gX(a)=a for every set X and every aX.

Proof of Proposition 164.3 — The identity free theorem

Proof. Take Y:=X and R:={(a,a)}, the one-element relation at the given a. Then (a,a)R, so by definition 164.1 the pair (gX(a),gX(a)) lies in R; the only pair in R is (a,a), so gX(a)=a. ◻

The proof used a relation that is not a function and not the identity: it is the graph of nothing at all. That freedom is the entire content of parametricity, and the reason (164.1) is impossible is that the relation R can be chosen to separate tt from the intended answer.

The dependent case will repeat this argument at a signature in which the relation itself is a term. Two things must change. The environment ϱ, an external object, becomes part of the context. And the clause for becomes a clause for x:AB in which B is instantiated at both x1 and x2, so its relation depends on the proof relating them.

The dependent signature

Definition 164.4 — The signature S

S is Martin-Löf type theory with the following formers, presented in the order formation, introduction, elimination, computation.

  • A cumulative hierarchy of universes U0:U1:, with types as terms of a universe (the Russell presentation), so that ΓA:Ui and ΓA type are interchangeable at level i.

  • Dependent products x:AB, with λx.b, application fa, the computation rule (λx.b)ab[a/x] and the uniqueness rule λx.fxf.

  • Dependent sums x:AB, with (a,b), projections pr1 and pr2, the computation rules pr1(a,b)a and pr2(a,b)b, and the uniqueness rule (pr1p,pr2p)p.

  • The unit type 1 with and the uniqueness rule u.

  • The natural numbers N with 0, suc and the dependent recursor indN.

  • Identity types IdA(a,b) with refl and the eliminator J, with J computing on refl.

We write U for an unspecified level when the level plays no role.

Convention 164.5 — Two copies and a relation

Every judgment of S will be translated into a judgment of S itself, in which each variable x of the source is replaced by three variables x1,x2,xR. Write e1 and e2 for the two copies of a source expression e obtained by subscripting all its free variables with 1 and with 2 respectively.

The relational translation

Definition 164.6 — Translation of types and terms

For a raw expression e of S write eR for its relational translation, the expression defined by the following clauses; for a type A it is a relation between the two copies A1 and A2, and for a term a it is a proof that a1 and a2 are related by the translation of a’s type. UiR:=λX1.λX2.X1X2Ui,xR:=xR,x:ABR:=λf1.λf2.x1:A1x2:A2xR:ARx1x2BR(f1x1)(f2x2),λx.bR:=λx1.λx2.λxR.bR,faR:=fRa1a2aR. On contexts, R:=,Γ,x:AR:=ΓR,x1:A1,x2:A2,xR:ARx1x2.

Read the clause for Ui as the decision that fixes everything else: a type is translated to a relation, so the translation of the universe is the type of relations. Read the clause for x:AB as the dependent form of definition 164.1: two functions are related when they send related arguments to related results, and the relation at the result is BR instantiated at both arguments, in a context that also holds the proof xR.

Definition 164.7 — Translation of the remaining formers

x:ABR:=λp1.λp2.xR:AR(pr1p1)(pr1p2)BR(pr2p1)(pr2p2),(a,b)R:=(aR,bR),pr1pR:=pr1pR,pr2pR:=pr2pR,1R:=λu1.λu2.1,R:=,NR:=N,0R:=zR,sucnR:=sRnR,IdA(a,b)R:=λp1.λp2.IARaRbRp1p2,reflR:=rR, where N is the inductive relation on N×N generated by zR:N00 and sR:n1:Nn2:NNn1n2N(sucn1)(sucn2), and IARaRbR is the inductive family on IdA1(a1,b1)×IdA2(a2,b2) generated by rR:IARaRaRreflrefl.

Lemma 164.8 — Translation commutes with substitution

For all raw expressions b and a and every variable x, b[a/x]R=bR[a1/x1][a2/x2][aR/xR]. Consequently AβA implies ARβAR.

Proof of Lemma 164.8 — Translation commutes with substitution

Proof. By induction on b. Variable case. If b=x then the left side is aR and the right side is xR[aR/xR]=aR. If b=y with y distinct from x, both sides are yR. Binder case. If b=λy.b0 with yFV(a){x}, then both sides are λy1.λy2.λyR. applied to the two sides of the induction hypothesis for b0, and the three fresh variables y1,y2,yR avoid FV(aR) by the same freshness condition. Remaining cases. Each clause of definition 164.6, definition 164.7 builds its output from the outputs at the immediate subterms and from the two copies e1,e2, and both operations commute with substitution.

For the consequence, a one-step β-reduction (λx.b)aβb[a/x] translates to (λx.b)aR=definition164.6(λx1.λx2.λxR.bR)a1a2aRβbR[a1/x1][a2/x2][aR/xR], which is b[a/x]R by the displayed equation; the compatible closure follows because every clause is a congruence. ◻

Theorem 164.9 — Abstraction

If Γa:A in S, then ΓRaR:ARa1a2 in S.

Proof of Theorem 164.9 — Abstraction

Proof. By induction on the derivation of Γa:A. Throughout, the induction hypothesis at a subterm b of type B is ΓRbR:BRb1b2, and we use that each of the two copies Γ1,Γ2 is a sub-context of ΓR, so every source judgment can be reused in each copy.

Variable. For x:A in Γ, definition 164.6 puts xR:ARx1x2 in ΓR, and xR=xR.

Universe. For ΓA:Ui the required conclusion is ΓRAR:UiRA1A2, and UiRA1A2βA1A2Ui, so the conclusion says that AR is a relation between the two copies of A. This is what the induction hypothesis at A delivers in every clause below, and the two statements are therefore proved simultaneously: types and terms are the same syntactic class in definition 164.4.

Product formation. Assume ΓA:Ui and Γ,x:AB:Uj. The induction hypotheses give AR:A1A2Ui over ΓR and BR:B1B2Uj over ΓR,x1:A1,x2:A2,xR:ARx1x2. The displayed body of x:ABR in definition 164.6 is then a well-formed type of the universe at the level of the source product, formed by three nested products over those three variables.

Abstraction. Assume Γ,x:Ab:B, so that Γλx.b:x:AB. The induction hypothesis gives bR:BRb1b2 over the extended translated context. Abstracting the three variables gives λx.bR:x1:A1x2:A2xR:ARx1x2BRb1b2, and the type x:ABR(λx1.b1)(λx2.b2) β-reduces to the same one, because (λxj.bj)xjbj by the computation rule of definition 164.4.

Application. Assume Γf:x:AB and Γa:A. The induction hypotheses give fR:x:ABRf1f2 and aR:ARa1a2. Instantiating the three products of x:ABR at a1,a2,aR yields fRa1a2aR:BR[a1,a2,aR/x1,x2,xR](f1a1)(f2a2), and lemma 164.8 identifies the displayed type with B[a/x]R(f1a1)(f2a2), which is the required conclusion.

Sum, unit, natural numbers, identity. Each is a copy of the product case with the clause of definition 164.7 in place of the clause for x:AB: the introduction form translates to the introduction form of the translated type, and the elimination form is typed by instantiating the translated family. For N and IdA(a,b) the eliminator case additionally uses that the translated inductive family has one constructor for each source constructor and the same recursive structure, so the translated motive is eliminated by the translated eliminator.

Conversion. If ΓAA type is derived from AβC and AβC, then ARβCR and ARβCR by lemma 164.8, so the two translated types are convertible and the conversion rule of S applies. ◻

Corollary 164.10 — Closed terms are self-related

If a:A then aR:ARaa.

Proof of Corollary 164.10 — Closed terms are self-related

Proof. Both copies of a closed expression are the expression itself, and R= by definition 164.6. ◻

The translation computed on an abstract data type

Definition 164.11 — The counter interface

Fix Client:=S:U0S(SS)(SN)N, the type of programs that use a state type S through an initial state, a step function and a readout, and return a number. Two implementations of the interface are first:S:=N,i:=0,s:=suc,r:=λn.n;second:S:=N×N,i:=(0,suc0),s:=λp.(suc(pr1p),pr2p),r:=λp.pr1p. The second carries an extra component that no operation reads.

Example 164.12 — The translation of Client

Apply definition 164.6 clause by clause. The outer product is over S:U0, so by the universe clause the translation introduces three variables S1,S2:U0 and SR:S1S2U0. Each of the three remaining arguments is a non-dependent product, so its clause introduces two arguments and a relatedness hypothesis. The codomain is N, whose translation is N. Writing c1,c2 for the two copies, ClientRc1c2 S1:U0S2:U0SR:S1S2U0i1:S1i2:S2iR:SRi1i2s1:S1S1s2:S2S2sR:x1:S1x2:S2SRx1x2SR(s1x1)(s2x2)r1:S1Nr2:S2NrR:x1:S1x2:S2SRx1x2N(r1x1)(r2x2)N(c1S1i1s1r1)(c2S2i2s2r2). Every hypothesis is forced: the clause for a product supplies exactly one relatedness argument for each argument of the source type, and no clause is free to omit one.

Lemma 164.13 — Identity extension at

For all m,n:N the types Nmn and IdN(m,n) are logically equivalent: there are terms in each direction.

Proof of Lemma 164.13 — Identity extension at

Proof. From N to IdN(,): eliminate the inductive relation with motive λm.λn.λ_.IdN(m,n). The case zR requires IdN(0,0), discharged by refl; the case sRmnq has an induction hypothesis p:IdN(m,n) and requires IdN(sucm,sucn), discharged by apsuc(p).

From IdN(,) to N: it suffices, by J with motive λm.λn.λ_.Nmn, to give Nmm for every m, and that is obtained by induction on m with indN: the base case is zR and the step case is sRmm applied to the induction hypothesis. ◻

Lemma 164.13 is what makes a relational conclusion at N usable: the abstraction theorem produces N, and the statement we want is an identity. The same question at an arbitrary type is the identity extension property, and remark 164.18 records exactly what is and is not available.

Theorem 164.14 — Representation independence for the counter

Let c:Client. Then IdN(cN0suc(λn.n),c(N×N)(0,suc0)(λp.(suc(pr1p),pr2p))(λp.pr1p)) is inhabited.

Proof of Theorem 164.14 — Representation independence for the counter

Proof. Proof idea. Instantiate the relation variable of example 164.12 at the relation “the first state is the first component of the second”, check the three relatedness hypotheses, and convert the relational conclusion at N into an identity by lemma 164.13. The extra component of the second implementation is never mentioned by the relation, which is why it cannot be observed.

By corollary 164.10 we have cR:ClientRcc. Instantiate the first three arguments with S1:=N,S2:=N×N,SR:=λn.λp.IdN(n,pr1p).

Initial states. The required type is SR0(0,suc0), which computes as SR0(0,suc0)βIdN(0,pr1(0,suc0))pr1comp.IdN(0,0), inhabited by refl.

Step functions. The required type is n:Np:N×NSRnpSR(sucn)((λp.(suc(pr1p),pr2p))p). Given q:IdN(n,pr1p), the target computes as SR(sucn)(suc(pr1p),pr2p)β, pr1comp.IdN(sucn,suc(pr1p)), inhabited by apsuc(q).

Readouts. The required type is n:Np:N×NSRnpNn(pr1p), and given q:IdN(n,pr1p) the conclusion follows from lemma 164.13 in the direction from identities to N.

Conclusion. Instantiating cR at these twelve arguments gives a term of type N(cN0suc(λn.n))(c(N×N)(0,suc0)(λp.(suc(pr1p),pr2p))(λp.pr1p)), and lemma 164.13 in the direction from N to identities gives the displayed inhabitant. ◻

Example 164.15 — The failure of eq:dp-bad-id, made exact

Let g:A:U0AA. Fix A:U0 and a:A, and instantiate gR at A1:=A,A2:=A,AR:=λx.λy.IdA(y,a),x1:=a,x2:=a,xR:=refl. The hypothesis ARaa computes to IdA(a,a) and is inhabited by refl, and the conclusion is AR(gAa)(gAa), which computes to IdA(gAa,a). Hence gAa=a for every A and a: no closed term of that type can behave as (164.1) describes. The relation AR used here is not the graph of a function and is not symmetric; the universe clause of definition 164.6 permits it because it quantifies over all relations.

Exercise 164.1

★☆☆ Let k:A:U0B:U0ABA. Choose relations and arguments as in example 164.15 and derive IdA(kABab,a). State which of the two relation variables must be instantiated at a singleton relation and why the other may be arbitrary.

Exercise 164.2

★★☆ Compute (A:U0A×(AA))R p1p2 in full by definition 164.7, and show that its inhabitants are exactly the triples consisting of a relation between the two carriers together with proofs that the two chosen elements and the two chosen functions are related. Then exhibit two closed elements of that sum whose relatedness fails for every relation, and name the component at which it fails.

Exercise 164.3

★★☆ Theorem 164.9 concludes ΓRaR:ARa1a2, not ΓRaR:ARaa.

  1. Explain, using definition 164.6 for contexts, why the two statements differ for an open term, and give a term for which the second is not even well typed.

  2. Show that they coincide for a closed term, and identify the clause of definition 164.6 that makes this work.

Identity types, universes, and what is not derivable

Lemma 164.13 converted a relational conclusion at N into an identity. The general question is whether AR, instantiated at the reflexive relations, is the identity type of A.

Definition 164.16 — Identity extension

The closed type A of S satisfies identity extension when for all a1,a2:A the types ARa1a2 and IdA(a1,a2) are logically equivalent.

Proposition 164.17 — Identity extension is at least function extensionality

If NN satisfies identity extension, then for all f1,f2:NN, (n:NIdN(f1n,f2n))  IdNN(f1,f2) is inhabited.

Proof of Proposition 164.17 — Identity extension is at least function extensionality

Proof. Unfolding definition 164.6 at the non-dependent product, (NN)Rf1f2n1:Nn2:NNn1n2N(f1n1)(f2n2). Assume H of type n:NIdN(f1n,f2n), and let n1,n2 and q:Nn1n2 be given. By lemma 164.13, q yields IdN(n1,n2), and transporting Hn1 along it gives IdN(f1n1,f2n2); the same lemma turns that back into N(f1n1)(f2n2). Hence H yields an element of (NN)Rf1f2, and identity extension converts it into IdNN(f1,f2). ◻

Remark 164.18 — What the abstraction theorem does and does not give

Theorem 164.9 is a statement about the syntax: it produces, for each term, a proof in S. It does not produce identity extension, and by proposition 164.17 it cannot, since function extensionality is not among the rules of definition 164.4. The reason is visible in the universe clause of definition 164.6: the translation of Ui is the type of all relations, so a relation variable AR standing in a translated context is an arbitrary relation, and nothing in the syntax connects it to IdA(,).

Identity extension is available in a model. Atkey, Ghani and Johann interpret types as reflexive graphs, in which each object carries a distinguished reflexivity edge, and build from them a category with families; their Theorem 1 states that the category of reflexive graphs supports dependent products and natural numbers, and, assuming a universe U of small sets, a predicative universe closed under both, with an impredicative universe when U is closed under large products. Their interpretation of the type-theoretic universe is designed so that identity extension holds, which is why they call the model relationally parametric. Their Theorem 2 gives the dependent naturality statement: if ΓM:a:UTaTa then for ΓX,Y:U, Γf:TXTY and Γx:TX, the equation Γf(MXx)=MY(fx):TY is sound in their model; and their Theorem 3 states that in the impredicative variant every X-indexed functor has an initial algebra. Those three statements hold at their signature, in their model, and are not consequences of theorem 164.9.

Exercise 164.4

★☆☆ Show that N and 1 satisfy identity extension, and that N×N does provided N does. Then state what would have to be proved for A:U0A, and identify the clause of definition 164.6 that makes the question depend on the universe.

External and internal relational structure

Theorem 164.9 is a function on derivations, defined in the metatheory. Its instances are terms of S, but the function itself is not. A program of S that receives a term as input cannot apply the abstraction theorem to it, because the input is a value of a type, not a derivation.

The natural repair is to add the conclusion as an axiom.

Definition 164.19 — The parametricity axiom

Let Sp be S extended, for every closed type B, with a constant paramB:x:BBRxx and no computation rule.

Proposition 164.20 — The axiom has no local interpretation

The assignment paramBaaR does not define a translation from Sp to S.

Proof of Proposition 164.20 — The axiom has no local interpretation

Proof. Take B:=N and the open term a:=x in the context x:N. Then paramNx is well typed over x:N, whereas xR=xR by definition 164.6, and xR is not declared in the context x:N. The proposed image is therefore not a term over the context of its source. ◻

Proposition 164.21 — The axiom breaks canonicity

Sp has closed normal forms of type N that are not numerals.

Proof of Proposition 164.21 — The axiom breaks canonicity

Proof. Let B:=A:U0AA and let id:=λA.λx.x. By example 164.15 the term paramBid, instantiated as there, has type IdN(idN0,0); call that term p. Now consider J(λu.λv.λ_.N; λu.sucu; p). Its type is N. It is closed. It has no reduction: the computation rule for J in definition 164.4 fires only on refl, and p is headed by paramB, which has no computation rule by definition 164.19. ◻

The two propositions say what an internal account must supply that an axiom does not: a term former for relational structure must come with binders that place the relational variables in the context where they are needed, and with computation rules that let a proof built from it reduce. Both are changes to the syntax of S, not additions to its constants. A calculus that makes those changes replaces the metatheoretic operation R by an operator of the object theory with its own formation, introduction, elimination and computation rules; the interval-free span calculus of Altenkirch, Kaposi and Shulman is one such system, and it is developed separately because its judgments and its metatheory are not those of definition 164.4.

Boundary

Proved here. The relational translation (definition 164.6, definition 164.7), its substitution lemma (lemma 164.8), the abstraction theorem (theorem 164.9) and its closed-term corollary, identity extension at N (lemma 164.13), the free theorem for the polymorphic identity type (example 164.15), representation independence for the counter interface (theorem 164.14), and the two obstructions to internalizing the translation (proposition 164.20, proposition 164.21).

Owned elsewhere. The reflexive-graph model and its three theorems belong to Atkey, Ghani and Johann and hold at their signature, as recorded in remark 164.18. Proof-relevant relational structure — where a relation carries not a proposition but a type of witnesses — is a separate development; nothing above is generalized to it by analogy. Cubical paths and their bridge and Gel formers belong to the calculi that define them.

Inductive families. Definition 164.7 gives the clauses for N and for the identity type by the same schema: a source inductive family with constructors c1,,ck translates to an inductive family with one constructor ciR for each ci, whose arguments are the translations of the arguments of ci. The general statement for arbitrary inductive families, together with the argument that the translation preserves strict positivity and hence well-foundedness, is due to Bernardy, Jansson and Paterson; only the two instances used above are proved here.

Size indices. Uniformity can be used to control an index rather than a type: a quantifier that is parametric rather than continuous makes a function’s behaviour independent of the index it is instantiated at, and that is what allows an index to be treated as a size. The parametric quantifiers of Nuyts, Vezzosi and Devriese are the standard calculus for this, and their rules differ from those of definition 164.4: they distinguish a parametric from a continuous function type, with separate formation, introduction and elimination rules. This chapter defines no sized recursion calculus and proves no theorem about one.

Suggested first pass.

Problems exercise 164.6, exercise 164.5, and exercise 164.8 form the suggested first pass. None of these problems is a prerequisite for a later chapter.

Exercise 164.5

★★★ Theorem 164.9 displayed the cases for variables, universes, products, abstraction, application and conversion, and delegated the sum, unit, natural-number and identity cases as copies of the product case. Write them.

  1. Give the sum case in full: the formation, introduction and both elimination rules, checking at each step which clause of definition 164.7 is used and that the computation rules of definition 164.4 make the translated equations hold.

  2. Give the case of indN: state the translated motive, the two translated methods, and the type of the translated eliminator, and check that the translated computation rules follow from the source ones.

  3. Give the case of J, and state exactly where the argument would fail if the identity type had the eliminator K in addition.

Exercise 164.6

★★★ Replace the counter of definition 164.11 by a queue interface QClient:=S:U0S(NSS)(S1+(N×S))N, with the two standard implementations: a single list, and a pair of lists holding the front in order and the back reversed.

  1. Write both implementations, using N-indexed lists encoded with Σ and N if no list former is available, and state the relation SR that relates them.

  2. Compute QClientR as in example 164.12.

  3. Prove the three relatedness hypotheses. The one for the dequeue operation requires a case analysis; display both cases and say which one needs the reversal.

  4. Conclude representation independence, and state which step used lemma 164.13.

Exercise 164.7

★★☆ Investigate the boundary of theorem 164.14.

  1. Add to Client a fourth argument of type SS2 testing states for equality, and exhibit two implementations of the extended interface, together with a client, for which the two runs differ. Identify the relatedness hypothesis that fails.

  2. Show that if instead the fourth argument has type NN2 the hypothesis is satisfied, and explain the difference in one sentence.

Exercise 164.8

★★★ Practical project.dependent-parametricity-translator Implement, in Agda, the relational translation of definition 164.6, definition 164.7 and use it to produce free theorems.

Calculus to implement. Represent the raw syntax of S restricted to U0, U1, dependent products, dependent sums, 1, N and identity types, with de Bruijn indices. Implement a bidirectional type checker for it and the translation R as a function on raw terms, with the context translation of definition 164.6. Capture-avoiding substitution and the tripling of variables must both be handled explicitly: a source variable at de Bruijn index i becomes three variables, and every index in a translated term must be recomputed.

Invariant. For every input derivation Γa:A the program must produce a term aR that its own checker accepts at type ARa1a2 in the context ΓR. This is the executable form of theorem 164.9; the checker, not the translator, is the judge.

Concrete result. A report that, for each named input, prints the translated context, the translated type, the translated term, and the checker’s verdict.

Acceptance test. The following must be accepted, with the printed translated type equal to the one computed by hand in the chapter: the identity λA.λx.x at A:U0AA, whose translation must be λA1.λA2.λAR.λx1.λx2.λxR.xR; the term λA.λB.λx.λy.x at the type of exercise 164.1; the counter clients of definition 164.11, whose translated type must match example 164.12 up to renaming; and λn.sucn at NN, whose translation must use sR. The following must be rejected by the checker: the term λA.λx.xR, in which a relational variable is used where a source variable is required; and a hand-written “translation” of id that omits the argument xR. Produce three mutations that still run — drop xR from the context translation, translate U0 to λX1.λX2.U0, and translate a product without the relatedness argument — and confirm that each makes the checker reject at least one accepted case. State explicitly that the program illustrates theorem 164.9 on finitely many derivations and does not prove it.

Search the book

Type to search the local edition.