Lectures onType Theory
Chapter 72
Chapter 72Core route

Dependent Products, Sums, and Unit

The structural rules can substitute an element into a family, but they cannot yet package a family of elements into one object. Suppose Γ,x:AB typeandΓ,x:Ab:B. We want a type whose elements are such dependent assignments xb, and a second type whose elements contain a:A together with b:B[a/x]. Dependent products and sums provide these two objects. A one-element type serves when no data is to be packaged.

Dependent products

The dependent product x:AB is the type of dependent functions: an element assigns to every a:A an element of the instance B[a/x].

Extend the raw syntax of definition 26.1 by x:AB, λ(x:A).b, and fa. The product former and dependent abstraction have arity (0,1) and bind x in their second argument; application has arity (0,0). The domain A in λ(x:A).b is a raw argument, so changing it changes the raw term. Alpha-equivalence and capture-avoiding substitution for these expressions are therefore the operations already defined in convention 26.8, definition 26.10.

Convention 27.1 — Formation, introduction, elimination, computation

A type former is specified by displayed rules in the following fixed order:

  1. formation: how the new type is formed from given data;

  2. introduction: how elements of the new type are constructed;

  3. elimination: how elements of the new type are used;

  4. computation: the β-rules, stating how elimination acts on introduced elements, followed — when present — by a uniqueness (η-) rule, stating that every element is determined by its behavior under elimination.

Each rule presupposes the formation judgments needed to type its premises, as specified by convention 26.14. Every constructor is congruent in its arguments; when an argument is dependent, the congruence rule includes the required context and type conversions. The dependent instances below make these conversions explicit.

A β-rule evaluates an elimination applied to an introduction. An η-rule applies where no β-rule can: it rebuilds an arbitrary element from its observable parts. The calculations after each rule display show both roles.

Definition 27.2 — Rules for Π

The dependent-product former is given by the following rules, in the order of convention 27.1.

Γ,x:AB type
Γx:AB type
Π-form
Γ,x:Ab:B
Γλ(x:A).b:x:AB
Π-intro
Γf:x:ABΓa:A
Γfa:B[a/x]
Π-elim
Γ,x:Ab:BΓa:A
Γ(λ(x:A).b)ab[a/x]:B[a/x]
Π-β
Γf:x:AB
Γfλ(x:A).fx:x:AB
Π-η

In Π-form and Π-intro the variable x becomes bound in B and in b. In Π-η, choose the displayed binder x to occur nowhere in f; this is possible by lemma 26.9. The premise ΓA type is presupposed throughout (convention 26.14).

Here are the two basic calculations. If Γ,x:Ab:B and Γa:A, then Γλ(x:A).b:x:AB,(λ(x:A).b)ab[a/x]:B[a/x]. The first expression introduces a dependent function; the second applies it and computes by β. Conversely, if Γf:x:AB, then fλ(x:A).fx:x:AB. This is η: even when f is a variable and no β-step is possible, its values determine it judgmentally.

Remark 27.3 — Notation

Family instances retain their binding information: if Γ,x:AB type, the instance at a is always B[a/x]. Functions of several arguments are iterated products x:Ay:BC, abbreviated x,y:AC when both binders range over the same type; iterated application is fab. Application associates to the left and binds more tightly than λ-abstraction.

Remark 27.4 — The congruence pattern

Each operator of definition 27.2 has a congruence rule. For the type former, abstraction, and application they read:

ΓAA typeΓ,x:ABB type
Γx:ABx:AB type
Π-form-eq
ΓAA typeΓ,x:ABB typeΓ,x:Abb:B
Γλ(x:A).bλ(x:A).b:x:AB
λ-eq
Γff:x:ABΓaa:A
Γfafa:B[a/x]
app-eq

In Π-form-eq, context conversion first types B in Γ,x:A. For λ-eq, context and type conversion give Γ,x:Ab:B,Γλ(x:A).b:x:AB,x:ABsymmetry of Π-form-eqx:AB. Rule Conv therefore places the right abstraction in the conclusion’s type. For application, equal substitution and conversion give the local chain fa:B[a/x],B[a/x]SubstEqTyB[a/x],fa:B[a/x]by Conv. Thus every conclusion compares terms in one context and one type.

Exercise 27.1

★★☆ In chapter 2 the clause A,BAB belongs to the grammar of simple types, while abstraction and application are typing rules. Place these three clauses in the formation, introduction, and elimination positions of convention 27.1. Add the usual β- and η-equations as a hypothetical fourth group, noting that chapter 2 itself has no judgmental equality and that λx.fx=f requires xFV(f). Compare the result with definition 27.2: which codomains and premises acquire a dependence on the argument?

Definition 27.5 — Ordinary functions

Let ΓA type and ΓB type. Weakening B by A (definition 26.21) and applying Π-form forms a constant dependent product. Choose xdom(Γ) occurring nowhere in B, and define the function type by AB:=x:AB. This notation associates to the right. The identity function is idA:=λ(x:A).x:AA. For Γf:AB and Γg:BC, define gf:=λ(x:A).g(fx):AC.

Example 27.6 — The generic evaluation

Let ΓA type and Γ,x:AB type. Form the context Γ,f:x:AB,a:A. The last occurrence of A is obtained by weakening it past f. Context formation and the general variable rule lemma 26.34 give f:x:AB and a:A in this context; Π-elim then gives the genuinely dependent evaluation fa:B[a/x].

Γ,f:x:AB,a:A ctx(f:x:AB)(Γ,f:x:AB,a:A)
Γ,f:x:AB,a:Af:x:AB
Assum
Γ,f:x:AB,a:A ctx(a:A)(Γ,f:x:AB,a:A)
Γ,f:x:AB,a:Aa:A
Assum
Γ,f:x:AB,a:Afa:B[a/x]
Π-elim

If f is a variable, this application is neutral: no β-rule applies. The η-rule nevertheless gives fλ(x:A).fx.

Lemma 27.7 — Category laws

Let Γf:AB, Γg:BC, and Γh:CD. Then Γ(hg)fh(gf):AD,ΓidBff:AB,ΓfidAf:AB.

Proof of Lemma 27.7 — Category laws

Proof. Associativity. Rule Π-β for the abstraction hg gives (hg)(fx)h(g(fx)) in context Γ,x:A, so (hg)f=definition27.5λ(x:A).(hg)(fx)λeqλ(x:A).h(g(fx)). Expanding the outer composite on the other side gives h(gf)=definition27.5λ(x:A).h((gf)x)Πβ,appeq,λeqλ(x:A).h(g(fx)). Let n:=λ(x:A).h(g(fx)). The first chain derives ((hg)f)n, and the second derives (h(gf))n. Apply symmetry to the second derivation to obtain nh(gf), then compose the two derivations by transitivity (definition 26.16).

Left unit: idBf=definition27.5λ(x:A).idB(fx)Πβ,λeqλ(x:A).fxΠηf. Right unit: fidA=definition27.5λ(x:A).f(idAx)Πβ,appeq,λeqλ(x:A).fxΠηf, using Π-β, app-eq, λ-eq, and finally Π-η. Thus the unit laws, unlike associativity, genuinely use the η-rule. ◻

Proposition 27.8 — Evaluation-style elimination

In the presence of weakening, the variable rule, and substitution, Π-elim is interderivable with the evaluation rule

Γf:x:AB
Γ,z:Afz:B[z/x]
Π-ev

where z is chosen fresh for Γ,f,A,B.

Proof of Proposition 27.8 — Evaluation-style elimination

Proof. Given Π-elim, derive Π-ev exactly as in example 27.6: weaken f to Γ,z:A, obtain Γ,z:Az:A by Var, and apply. Conversely, given Π-ev and a term Γa:A, the substitution rule of definition 26.20 applied to Γ,z:Afz:B[z/x] yields the required term at B[a/x]. Since z was chosen fresh for f, the defining clauses of definition 26.10 give (fz)[a/z]=fa. The corresponding translation of the computation rule substitutes a for the fresh generic variable in the generic β equation. Freshness gives ((λ(x:A).b)z)[a/z]=(λ(x:A).b)a, b[z/x][a/z]=b[a/x], and B[z/x][a/z]=B[a/x]. Thus both terms have the required type B[a/x], so Subst-Eq-Tm yields the ordinary Π-β rule. ◻

Exercise 27.2

★★☆ (η as judgmental extensionality.) Show that, given the other rules of definition 27.2, the rule Π-η is equivalent to the extensionality rule: from Γf:x:AB, Γg:x:AB, and Γ,x:Afxgx:B, infer Γfg:x:AB. (For the forward direction, rebuild f and g by η; for the converse, instantiate g:=λ(x:A).fx and compute with Π-β.)

Exercise 27.3

★☆☆ Rewrite the right-unit calculation in lemma 27.7 as a derivation of ΓfidAf:AB, displaying the uses of application congruence, abstraction congruence, and η.

Exercise 27.4

★★☆ Complete proposition 27.8: show that in the presence of the structural rules, the rule Π-β is interderivable with its generic instance Γ,x:A(λ(y:A).b[y/x])xb:B, where y occurs nowhere in b,B,Γ,A and is distinct from x. In the reverse direction substitute an arbitrary Γa:A for x and use the substitution-composition equation of proposition 26.11.

Exercise 27.5

★☆☆ Let ΓA type, ΓB type, and ΓC type. In context Γ,y:B, define constyAB:=λ(x:A).y:AB; the superscript records the domain and codomain of the constant map. If Γf:AB, prove in context Γ,z:C that constzBCfconstzAC:AC. If Γg:BC, prove in context Γ,y:B that gconstyABconstgyAC:AC.

Exercise 27.6

★★☆ Let ΓA type, ΓB type, and Γ,x:A,y:BC type. Construct a term σ:(x:Ay:BC)(y:Bx:AC) swapping the arguments, and show σσid, where σ is the swap in the other direction. Begin with λ(f:x:Ay:BC).λ(y:B).λ(x:A).fxy; use lemma 26.33 to form C in the swapped context, and use η twice in the round trip.

Dependent sums

The dependent sum x:AB is the type of dependent pairs: an element consists of an a:A together with an element of the instance B[a/x]. We present Σ negatively, with projections and an η-rule.

Extend the raw syntax by x:AB, (a,b), pr1(p), and pr2(p). The sum former has arity (0,1) and binds x in its second argument; pairing has arity (0,0) and each projection has arity (0).

Definition 27.9 — Rules for Σ

The dependent-sum former is given by the following rules; congruence rules are tacit (convention 27.1).

Γ,x:AB type
Γx:AB type
Σ-form
Γ,x:AB typeΓa:AΓb:B[a/x]
Γ(a,b):x:AB
Σ-intro
Γp:x:AB
Γpr1(p):A
Σ-elim_1
Γp:x:AB
Γpr2(p):B[pr1(p)/x]
Σ-elim_2
Γ,x:AB typeΓa:AΓb:B[a/x]
Γpr1((a,b))a:A
Σ-β_1
Γ,x:AB typeΓa:AΓb:B[a/x]
Γpr2((a,b))b:B[a/x]
Σ-β_2
Γp:x:AB
Γp(pr1(p),pr2(p)):x:AB
Σ-η

The premise Γ,x:AB type in Σ-intro and in both β-rules is not recoverable from the other premises (the family B is not determined by its instance B[a/x]) and is therefore displayed.

For Γa:A and Γb:B[a/x], the rules give Γ(a,b):x:AB,pr1((a,b))a:A,pr2((a,b))b:B[a/x]. If p:x:AB is a variable, neither projection computes by a β-rule. The uniqueness rule instead reconstructs the whole pair: p(pr1(p),pr2(p)):x:AB.

Remark 27.10 — Dependent congruence for pairs

The type-former congruence has the same shape as Π-form-eq. The remaining congruence rules are

Γ,x:AB typeΓaa:AΓbb:B[a/x]
Γ(a,b)(a,b):x:AB
pair-eq
Γpp:x:AB
Γpr1(p)pr1(p):A
1-eq
Γpp:x:AB
Γpr2(p)pr2(p):B[pr1(p)/x]
2-eq

For pair-eq, equal substitution gives B[a/x]B[a/x]; conversion along this equality moves b from the displayed common fiber B[a/x] to B[a/x], so the right-hand pair is well typed. For pr2-eq, rule pr1-eq gives Γpr1(p)pr1(p):A, whence B[pr1(p)/x]SubstEqTyB[pr1(p)/x]. After symmetry, this converts the second projection of p to the common type shown in the conclusion.

Exercise 27.7

★★☆ Restore every premise suppressed by convention 26.14 in the three rules of remark 27.10. For pr2-eq, display the Subst-Eq-Ty, Ty-Sym, and Conv steps that type the right-hand projection in the common fiber.

Exercise 27.8

★☆☆ Verify, citing Subst, that the premise Γb:B[a/x] of Σ-intro is meta-well-typed: from Γ,x:AB type and Γa:A, derive ΓB[a/x] type.

Remark 27.11 — Binary products

For ΓA type and ΓB type we define the product type A×B:=x:AB after choosing xdom(Γ) occurring nowhere in B. Its elements are ordinary pairs. Specializing the motive of Σ elimination to a constant type gives the binary-product recursor; the two projection computations and pair eta are the corresponding specializations of definition 27.9.

Exercise 27.9

★★☆ Let ΓA type, ΓB type, and ΓC type. Specialize definition 27.9 to A×B (remark 27.11): display the resulting rules, define the non-dependent recursor rec×(f;p):=f(pr1(p))(pr2(p)) for f:A(BC), and verify its computation rule on pairs.

Proposition 27.12 — Σ -elimination

Let Γ,z:x:ABC type and Γ,x:A,y:Bd:C[(x,y)/z]. For Γp:x:AB, define indΣ(d;p):=d[pr1(p)/x,pr2(p)/y]. Then ΓindΣ(d;p):C[p/z], and on pairs the eliminator computes judgmentally: ΓindΣ(d;(a,b))d[a/x,b/y]:C[(a,b)/z], for Γa:A and Γb:B[a/x].

[4]

Proof of Proposition 27.12 — Σ -elimination

Proof. By lemma 26.30, rename the two displayed context variables if necessary so that x and y occur nowhere in Γ, p, or C. This is possible because the variables are locally declared and distinct from the domain of Γ. The two projection rules give Γpr1(p):A,Γpr2(p):B[pr1(p)/x]. Thus (pr1(p),pr2(p)) is a context substitution Γ(x:A,y:B) in the sense of definition 26.45. Applying proposition 26.46 to the derivation of d gives Γd[pr1(p)/x,pr2(p)/y]:C[(pr1(p),pr2(p))/z]. The displayed type is obtained by the defining clauses of simultaneous substitution in definition 26.10. Moreover, the simultaneous substitution agrees with two successive applications of the structural substitution rule. This follows directly by induction on d: neither x nor y occurs in either projection of p, so the two single substitutions commute at variables and the binder cases use the same fresh openings. Now symmetry of Σ-η gives (pr1(p),pr2(p))p:x:AB. Apply Subst-Eq-Ty to the family C, and then Conv; this changes the last displayed type to C[p/z]. Explicitly, the classifier assembly is C[(pr1(p),pr2(p))/z]paireq,SubstEqTyC[p/z],d[pr1(p)/x,pr2(p)/y]: C[(pr1(p),pr2(p))/z]ConvC[p/z].

For the computation equation, put q1:=pr1((a,b)),q2:=pr2((a,b)). The two beta rules give q1a:A and q2b:B[a/x]; equal substitution along the first equality converts the original type B[q1/x] of q2 to B[a/x]. Apply Subst-Eq-Tm at x:A and then substitute q2 for y. Its common context is the one based on q1, and it gives d[q1/x,q2/y]d[a/x,q2/y]:C[(q1,q2)/z]. Separately, apply Subst-Eq-Tm at y:B[a/x] to the already substituted term d[a/x]: d[a/x,q2/y]d[a/x,b/y]:C[(a,q2)/z]. Rule pair-eq gives (q1,q2)(a,q2), using reflexivity for q2 in the common fiber. Equal substitution in C and Conv-Eq therefore type the two steps in one fiber: d[q1/x,q2/y]=SubstEqTm,ConvEqd[a/x,q2/y]=SubstEqTmd[a/x,b/y]:C[(a,q2)/z]. A second use of pair-eq, this time with q2b, gives (a,q2)(a,b). Equal substitution in C and Conv-Eq place the chain in C[(a,b)/z], as required. ◻

Proposition 27.13 — The positive presentation

The negative presentation of definition 27.9 derives the positive eliminator and computation rule of proposition 27.12. Conversely, the positive presentation consisting of formation, pairing, the primitive eliminator indΣ of arity (2,0), and its pair computation derives both projections and their beta rules. If Sigma eta is added to the positive presentation, the two presentations are interderivable.

Proof of Proposition 27.13 — The positive presentation

Proof. The negative-to-positive direction is proposition 27.12. For the converse, the first projection is the constant-motive instance pr1(p):=indΣ(x;p),C:=Ain context z:x:AB. After this definition, take the motive C:=B[pr1(z)/x] and the branch y. The branch has the required type because the first projection computes on (x,y). Equal substitution gives B[pr1((x,y))/x]B. After symmetry, conversion types y:B in the left-hand type. This defines pr2(p), and the primitive computation rule gives both projection beta rules.

Adding Sigma eta supplies the only remaining rule of the negative presentation. Thus every rule of either presentation is admissible in the other, although their primitive raw operators remain different. ◻

Remark 72.14

If p is a variable, indΣ(;p) has no computation step. Therefore the positive computation rule alone does not derive p(pr1(p),pr2(p)); this is exactly the additional eta equation assumed in the final clause of remark 27.13.

The terminology collides across the simple/dependent divide: Π-types generalize function types yet are called dependent products, while Σ-types generalize product types yet are called dependent sums. The set-theoretic reading resolves the puzzle: aABa is an A-indexed product of sets whose elements are (choice) functions, and aABa is an A-indexed sum (disjoint union) whose elements are pairs of an index with an inhabitant. Both specialize to the binary product: B1×B2 is the product indexed by {1,2} and also the sum of the constant family B2 indexed by B1.

Exercise 27.10

★★★ In the positive presentation of remark 27.13, write the complete derivation of the second projection. In context z:x:AB, use the motive C:=B[pr1(z)/x]; display the conversion that types the branch y, and verify the beta rule. Finally explain why the primitive computation rule has no computation step when the scrutinee is an arbitrary variable p, and hence does not derive p(pr1(p),pr2(p)).

The unit type

The unit type is the nullary product. Its constructor contains no components, and its η-rule gives a:1 for every a:1. Consequently a function f:1B is determined by f: for any a:1, congruence sends a to faf. Both 1 and are nullary raw operators.

Definition 27.14 — Rules for

The unit type is given by the following rules; congruence rules are tacit.

Γ ctx
Γ1 type
-form
Γ ctx
Γ:1
-intro
Γa:1
Γa:1

Lemma 27.15 — Scoping in the extended theory

For every expression judgment ΓJ derivable after adding the Π-, Σ-, and 1-rules, every free variable displayed in J belongs to dom(Γ). In a derivable context, the free variables of each declaration type belong to the preceding prefix.

Proof of Lemma 27.15 — Scoping in the extended theory

Proof. Proceed simultaneously over derivations of contexts and of the four expression judgments. In the structural cases, Var selects a declared name; Wk only enlarges the domain; and Subst replaces x by the substituend, whose free variables already lie in the prefix Γ. Context conversion and the equality rules change no free variables. For a representative new binder case, the premise of Π-introduction has FV(b)dom(Γ){x}; abstraction binds x, so FV(λ(x:A).b)dom(Γ), using also FV(A)dom(Γ). The formation rules for Π and Σ have the same binder calculation. For application, the representative non-binder equation is FV(fa)=FV(f)FV(a)dom(Γ). Pairing and projection take the same union of the free-variable sets of their premises, while the nullary 1 and retain none. Computation, uniqueness, and congruence compare expressions satisfying these same inclusions. ◻

By 1-intro, in every well-formed context the judgment Γ:1 is derivable. If a context also contains a variable u:1, no reduction rule acts on u, but uniqueness gives the immediate calculation Γ,u:1u:1.

Remark 27.16 — No elimination rule

Definition 27.14 contains no elimination rule and no β-rule. None is needed: every a:1 is judgmentally . Conversion along a therefore derives the dependent eliminator in proposition 27.17.

Proposition 27.17 — The dependent eliminator for

Let Γ,z:1C type, let Γc:C[/z], and let Γa:1. Define ind1(c;a):=c. Then Γind1(c;a):C[a/z], and Γind1(c;)c:C[/z].

Proof of Proposition 27.17 — The dependent eliminator for

Proof. By 1-η, a:1. Apply Tm-Sym first, so a:1. Then Subst-Eq-Ty for the family C gives C[/z]C[a/z] type. Rule Conv converts c:C[/z] to c:C[a/z], which is the typing claim. The computation equation is reflexivity. ◻

Remark 27.18 — The eta convention

In the calculus of definition 27.2, definition 27.9, definition 27.14, the three η-equations are primitive judgmental equalities. They do not follow from the corresponding β-rules. Unit eta converts the constant branch into the fiber over an arbitrary unit term in proposition 27.17. Sigma eta types the dependent uncurrying map and supplies the reassociation conversions. Pi eta closes the function round trips for currying and the categorical unit laws.

Exercise 27.11

★☆☆ Given Γf:11 and Γg:11, show fg and conclude fid1. Which η-rules does the argument use?

Exercise 27.12

★☆☆ Write out the proof of proposition 27.17 as a derivation tree, citing Tm-Sym, Subst-Eq-Ty, and Conv at the exact steps where they occur.

Internalizing judgmental structure

The introduction and elimination rules move in opposite directions. The eta rules say that, after quotienting by judgmental equality, these moves are inverse.

Definition 27.19 — Term sets

Let Γ ctx and ΓA type. Define Tm(Γ,A):={aΓa:A derivable}/ to be the set of terms of A in context Γ, taken modulo judgmental equality. If AA as types, Conv in both directions gives the same term representatives, and Conv-Eq in both directions gives the same equivalence relation. We therefore identify Tm(Γ,A) with Tm(Γ,A).

Here “set” has its metatheoretic meaning from convention 71.1. The raw expressions form a set, the displayed collection is a subset, and quotienting by derivable judgmental equality therefore produces a set. The symbol below denotes the corresponding metatheoretic disjoint union, not an object-language Σ-type.

Proposition 27.20 — term classes

If Γ ctx, then Tm(Γ,1) is a singleton.

Proof of Proposition 27.20 — term classes

Proof. It contains [] by 1-intro. If [a] is any other element, 1-η gives a, hence [a]=[]. ◻

Theorem 27.21 — Π internalizes the hypothetical judgment

Let ΓA type and Γ,x:AB type. Define Λ(b):=λ(x:A).bandE(f):=fx, where E first weakens f to Γ,x:A (definition 26.21) and applies it to the variable x. Then:

  1. Λ and E preserve judgmental equality, and induce mutually inverse bijections Tm((Γ,x:A),B)Tm(Γ,x:AB);

  2. both maps commute with substitution. More precisely, if Γ=Γ0,y:C,Γ1, if Γ0c:C, and if Γ[c/y] abbreviates Γ0,Γ1[c/y], then Λ(b)[c/y]=Λ(b[c/y]),E(f)[c/y]=E(f[c/y]) as equalities of expression classes. The first lies in Tm(Γ[c/y],x:A[c/y]B[c/y]), and the second is an equality of terms of B[c/y] in the context Γ[c/y],x:A[c/y].

Proof of Theorem 27.21 — Π internalizes the hypothetical judgment

Proof. (1) Preservation of is λ-eq and app-eq. For the round trips, let Γ,x:Ab:B and choose xx occurring nowhere in Γ,A,B,b. Choose the alpha-equivalent representative with binder x. Then, in Γ,x:A, E(Λ(b))=(λ(x:A).b[x/x])xb[x/x][x/x]=b. The beta rule gives the judgmental step. The final raw equality follows by structural induction on that representative of b: the second substitution reverses precisely the occurrences changed by the first. Conversely, for Γf:x:AB, Λ(E(f))=λ(x:A).fxf by Π-η. Hence the induced maps on -classes are mutually inverse.

(2) The context formation makes xy. By lemma 27.15, FV(c)dom(Γ0), hence xFV(c). Choose representatives whose other bound names avoid y and FV(c). The operator clauses of definition 26.10 then give (λ(x:A).b)[c/y]=λ(x:A[c/y]).b[c/y],(fx)[c/y]=f[c/y]x. Weakening does not change the raw representative of f, so these are the two asserted equations in the substituted contexts. ◻

Theorem 27.22 — Σ internalizes pairs of judgments

Let ΓA type and Γ,x:AB type. There is a bijection Tm(Γ,x:AB)aTm(Γ,A)Tm(Γ,B[a/x]), given on representatives by F(p)=(pr1(p),pr2(p)),G(a,b)=(a,b). The fiber on the right is independent of the representative of a via the identification in definition 27.19. The two maps also commute with substitution in the sense of theorem 27.21(2): under the hypotheses there, substitution acts componentwise and F([p])[c/y]=F([p[c/y]]),G([a],[b])[c/y]=G([a[c/y]],[b[c/y]]).

Proof of Theorem 27.22 — Σ internalizes pairs of judgments

Proof. We first make the dependent quotient precise. If aa:A, then Subst-Eq-Ty gives B[a/x]B[a/x] type. By Conv, the two fibers have the same term representatives; by Conv-Eq, they have the same equality classes. Hence the fiber Tm(Γ,B[a/x]) depends only on [a].

The forward map lands in this fiber because pr1(p):A,pr2(p):B[pr1(p)/x]. If pp, the rules pr1-eq and pr2-eq show that both resulting classes agree, with the second equality taken in the common fiber over [pr1(p)]. Thus F is well defined.

For G, suppose aa:A and that b and b determine the same class after identifying B[a/x] with B[a/x]. In the common fiber we have bb:B[a/x], so pair-eq gives (a,b)(a,b):x:AB. Thus G too is independent of representatives.

The two beta rules give F(G([a],[b]))=([a],[b]), and symmetry of Σ-η gives G(F([p]))=[(pr1(p),pr2(p))]=[p]. The maps are therefore inverse.

Finally, under the context-substitution hypotheses of theorem 27.21(2), the operator clauses of definition 26.10 give pri(p)[c/y]=pri(p[c/y])(i=1,2),(a,b)[c/y]=(a[c/y],b[c/y]). These are exactly the two naturality equations. For the dependent second component, the identification of the substituted fibers is the calculation (B[a/x])[c/y]=B[c/y][a[c/y]/x], which follows from xy, xFV(c), and proposition 26.11.4. Thus both sides really do lie in the same displayed fiber. ◻

Remark 27.23 — The slogan

These three results have one form: each type packages structure already expressible with judgments. Tm(Γ,x:AB)Tm(Γ,x:A;B),Tm(Γ,x:AB)[a]Tm(Γ,A)Tm(Γ,B[a/x]),Tm(Γ,1){}. Here Tm(Γ,x:A;B) abbreviates the term classes of B in the extended context; the semicolon prevents it from being mistaken for a two-argument term-set notation.

Exercise 27.13

★☆☆ Specialize theorem 27.22 to a constant family and obtain a bijection Tm(Γ,A×B)Tm(Γ,A)×Tm(Γ,B). Write the two maps and both round trips explicitly.

Exercise 27.14

★☆☆ Verify theorem 27.21(2) directly from the defining clauses of substitution in definition 26.10, indicating exactly where the freshness of x for y and c is used.

Exercise 27.15

★☆☆ Formulate and prove the analogue of theorem 27.21(2) for the unit type: the bijection of proposition 27.20 commutes with substitution. What do the two composite maps look like concretely?

Exercise 27.16

★★★ (Internalization reconstructs the term rules.) Fix ΓA type and Γ,x:AB type, and suppose ΓP type is a type equipped with alpha-respecting raw-term operations Λ and E. They are accompanied by derivation transformations sending each derivation of Γ,x:Ab:B to one of ΓΛ(b):P and each derivation of Γf:P to one of Γ,x:AE(f):B. Assume that the raw operations commute with substitution, their transformations send equality derivations to equality derivations, and they come with derivations E(Λ(b))b:B,Λ(E(f))f:P. Use Λ as introduction and define elimination by fa:=E(f)[a/x]. Derive the beta rule by substituting a into the first displayed equality, derive eta from the second, and derive the two congruence rules from equality preservation and Subst-Eq-Tm. The formation rule is the assumed judgment ΓP type.

Definitional isomorphisms

Two types can be carried into each other by maps whose round trips are judgmentally the identity. The η-rules make such round trips collapse; currying and the associativity of Σ are the two cases needed below.

Definition 27.24 — Definitional isomorphism

Let ΓA type and ΓB type. A definitional isomorphism AB consists of terms Γf:AB and Γg:BA such that {x,y}dom(Γ)= and xy, and Γ,x:Ag(fx)x:AandΓ,y:Bf(gy)y:B. Equivalently, gfidA and fgidB. Indeed, abstraction congruence turns the two displayed equations into these equations of functions. Conversely, apply the first functional equation to x and the second to y, use app-eq, and reduce both sides by β. Here relates two object-language types and requires judgmental round trips. The same printed glyph in theorem 27.21 relates metatheoretic sets of term classes by an ordinary bijection.

Proposition 27.25 — Currying

Let ΓA type, Γ,x:AB type, and Γ,p:x:ABC type. Choose the displayed binders x,p,y,f,g,w pairwise fresh, disjoint from dom(Γ), and put P:=p:x:ABC,Q:=x:Ay:BC[(x,y)/p]. There is a definitional isomorphism PQ given by Φ:=λ(f:P).λ(x:A).λ(y:B).f((x,y)), Ψ:=λ(g:Q).λ(w:x:AB).g(pr1(w))(pr2(w)).

Proof of Proposition 27.25 — Currying

Proof. First check the typing. For Φ, given f:P, x:A, and y:B, rule Σ-intro gives (x,y):x:AB. Hence f((x,y)):C[(x,y)/p], and three abstractions finish.

For Ψ, let g:Q and w:x:AB. Substitution in the product type gives g(pr1(w)):y:B[pr1(w)/x]C[(pr1(w),y)/p], by definition 26.10. Applying this term to pr2(w) gives g(pr1(w))(pr2(w)):C[(pr1(w),pr2(w))/p]. Symmetry of Σ-η gives (pr1(w),pr2(w))w, whence C[(pr1(w),pr2(w))/p]SubstEqTyC[w/p]. Rule Conv therefore gives the body the required type C[w/p] in the context Γ,w:x:AB.

Round trip on f: in context Γ,f:P, Ψ(Φf)Πβλ(p:x:AB).Φf(pr1(p))(pr2(p))Πβ,λeqλ(p:x:AB).f((pr1(p),pr2(p)))Ση,appeq,λeqλ(p:x:AB).fpΠηf. Round trip on g: in the corresponding context, Φ(Ψg)Πβλ(x:A).λ(y:B).Ψg((x,y))Πβ,λeqλ(x:A).λ(y:B).g(pr1((x,y)))(pr2((x,y)))Σβ,appeq,λeqλ(x:A).λ(y:B).gxyΠη,λeqg. The last step uses Π-η first under the inner abstraction and then under the outer one, both in the symmetric direction; λ-eq carries the inner equality through the outer binder. ◻

Proposition 27.26 — Associativity of Σ

Let ΓA type, Γ,x:AB type, and Γ,p:x:ABC type. There is a definitional isomorphism p:x:ABCx:Ay:BC[(x,y)/p]

Proof of Proposition 27.26 — Associativity of Σ

Proof. Take the comparison maps Θ:=λ(q:p:x:ABC).(pr1(pr1(q)),(pr2(pr1(q)),pr2(q))),Ξ:=λ(r:x:Ay:BC[(x,y)/p]).((pr1(r),pr1(pr2(r))),pr2(pr2(r))). For the typing of Θ: given q in the left-hand type, pr2(q):C[pr1(q)/p]. Put s:=pr1(q). Equal substitution applied to s(pr1(s),pr2(s)) gives the short conversion C[s/p]C[(pr1(s),pr2(s))/p]. This places pr2(q) in the type required for the inner pair; record the converted judgment as Γ,q:p:x:ABCpr2(q):C[(pr1(s),pr2(s))/p]. The typing of Ξ needs no conversion.

For the first round trip, beta-reduce the two maps and their projections: Ξ(Θq)Πβ,Σβ((pr1(s),pr2(s)),pr2(q))(72.1),paireq(s,pr2(q))Σηq. For the other, put t:=pr2(r). Then Θ(Ξr)Πβ,Σβ(pr1(r),(pr1(t),pr2(t)))Ση,paireq(pr1(r),t)Σηr. No corresponding fiber conversion is needed in this second chain: the two outer pairs have the identical first component pr1(r). Thus Θ and Ξ satisfy definition 27.24. ◻

Remark 27.27 — Strength of the notion

Judgmental equality of types is sufficient for a definitional isomorphism: if AB, conversion types the identity abstraction in both directions. The converse fails, however: inverse comparison maps and their equations do not constitute a judgmental equality of the two type expressions. The eta rules play different roles. Without Σ-eta, the uncurrying map Ψ of example 27.25 and the eliminator of proposition 27.12 are not well typed: their bodies lie over (pr1(p),pr2(p)) and must be converted to the fiber over p. Σ-eta is used again in both associativity round trips and in the third step of the currying round trip on f. By contrast, Π-eta is used in the round trips: at the final step of each currying composite and in the unit laws of lemma 27.7.

Lemma 27.28 — Calculus of definitional isomorphisms

The identity maps give AA; reversing the two maps gives an inverse isomorphism; and definitional isomorphisms compose. Composition is associative and has the identity isomorphisms as units, up to judgmental equality of the comparison maps.

Proof of Lemma 27.28 — Calculus of definitional isomorphisms

Proof. Only composition needs calculation. Let f:AB and g:BA be one inverse pair, and let f:BC and g:CB be another. The composite pair is ff:AC and gg:CA. For x:A, beta unfolds the two composites. Name the pointwise inverse equations (IA)g(fx)x,(IB)f(gy)y,(IB)g(fy)y,(IC)f(gz)z. Then (gg)((ff)x)Πβg(g(f(fx)))(IB),appeqg(fx)(IA)x. The middle step substitutes fx for y in the inverse hypothesis g(fy)y and then uses app-eq under g; the last step is the other inverse hypothesis g(fx)x. The calculation at z:C is the same in the other order: (ff)((gg)z)Πβ,(IB)f(gz)(IC)z. The identity and inverse pairs are immediate from definition 27.24; the associative and unit equations for their comparison maps are precisely lemma 27.7. ◻

Exercise 27.17

★★☆ Verify directly from definition 26.10 that the maps Θ and Ξ of example 27.26 commute with substitution in every variable of Γ.

Exercise 27.18

★★★ Assume ΓA type, and construct definitional isomorphisms x:A1Aandx:1BB[/x], the latter for any family Γ,x:1B type. For the second map, use x to convert an element of B[/x] to an element of B, then abstract over x. Identify precisely which eta rules the two round trips use.

Exercise 27.19

★☆☆ Specialize example 27.25 to constant families to obtain the definitional isomorphism (A×B)CA(BC), and check that the specialized maps agree with the classical λ combinators curry:=λ(f:(A×B)C).λ(x:A).λ(y:B).f((x,y)),uncurry:=λ(g:A(BC)).λ(p:A×B).g(pr1(p))(pr2(p)).

Suggested first pass.

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

Exercise 72.20

★★☆ Starting only from the positive Σ-eliminator and its computation rule, derive both projections and their two computation equations. Conversely, starting from projections, their computation equations, and judgmental Σ-eta, reconstruct the positive eliminator. Mark the exact step in the second direction at which Σ-eta is used.

Exercise 72.21

★★☆ Reconstruct the two maps of dependent currying and annotate every step of both round trips by the Π- or Σ-computation and uniqueness rule used. Give one family for which replacing judgmental Σ-eta by a propositional equality would weaken the conclusion.

Exercise 72.22

★★☆ Work in the freely generated Π-Σ theory with the beta rules but without judgmental Σ-eta. For a neutral variable p:x:AB, compare the beta-normal forms of p and (pr1(p),pr2(p)). Use this comparison to locate the stalled step in the uncurry–curry round trip. What conclusion remains if one adds only a propositional Σ-eta witness?

Exercise 72.23

★★★ Practical project.pisigma-rule-checker Implement in Agda or Kappa a checker for the Π, Σ, and 1 rules on explicitly annotated terms. Preserve the invariant that every returned type is well formed in the input context. It must accept the dependent curry/uncurry maps and reject a second projection whose family is indexed by a different first component; print the inferred type or the first failed premise. Before implementing the checker, run the same two tests as derivation trees: derive the type of dependent curry and mark the first ill-typed premise of the mismatched projection. These trees specify the checker’s accepted and rejected results.

Sources. Dependent products and sums, the fourfold rule order, and their meaning explanations are developed in [ML98, ML75, ML84, ML96]; textbook accounts include [NPS90, NPS00, Tho91]. Internalization is emphasized in [AG26, Hof97] and has the categorical form described in [Jac99, Dyb96]. The HoTT Book gives positive Σ-elimination without judgmental Σ-eta [Uni13].

Search the book

Type to search the local edition.