Lectures onType Theory
Chapter 73
Chapter 73Core route

Inductive Types

No type introduced so far represents an impossible result. Such a type must have no constructors, yet it must still eliminate into any family once an impossible inhabitant is given. The empty type is the first instance of an inductive family: its constructors generate the elements, and its eliminator defines a section by giving one case for each constructor.

The empty type

The simplest inductive type has no constructors at all.

Extend the raw syntax of definition 26.1 by the nullary operator 0 and the eliminator ind0(x.C;a) of arity (1,0), binding x only in the motive C. Capture-avoiding substitution in C is the binder clause of definition 26.10.

Convention 28.1 — Notation for families and eliminators

Throughout this chapter, premises are compressed according to convention 26.14. Moreover:

  1. If Γ,x:AB type, we write B(a) for the substitution instance B[a/x] when the displayed type judgment determines the binder x uniquely; likewise b(a) for b[a/x] when Γ,x:Ab:B.

  2. Every eliminator carries the motive family displayed in its formation rule. Raw rule displays retain it. In derived terms we suppress the annotation only when the expected result type fixes it uniquely; the schematic token rec0 denotes abortC only after that target C has been fixed.

  3. The printed abbreviation λx.b suppresses the domain argument of the raw abstraction λ(x:A).b only when typing fixes A uniquely.

Definition 28.2 — Rules for

The empty type 0 is given by a formation rule and an elimination rule:

Γ ctx
Γ0 type
-form
Γ,x:0C typeΓa:0
Γind0(x.C;a):C(a)
-elim

There are no introduction rules, and consequently no computation rules: a computation rule describes the action of the eliminator on a constructor, and 0 has none. Its congruence rule is the instance of the scheme in appendix A for the annotated eliminator.

Definition 28.3 — Recursor for

For ΓC type, instantiating 0-elim at the weakened (constant) motive Γ,x:0C type and λ-abstracting the scrutinee yields the recursor, the nondependent instance of the eliminator, abortC:=λa.ind0(x.C;a):0C. The subscript is load-bearing raw information: empty elimination has no constructor from which its motive could be recovered. We omit it only when the expected result type fixes C uniquely.

Definition 28.4 — Negation

For ΓA type we define ¬A:=A0.

Remark 28.5

The judgment Γa:0 is derivable for many nonempty Γ: the variable rule alone gives x:0x:0. What the rules assert locally is not “there is no term of 0,” but that every family treats 0 as empty: any family over 0 has a section, by 0-elim. A claim that no closed term exists is instead a metatheoretic soundness statement, not an elimination rule.

Example 28.6 — Contraposition

For types A and B in context Γ there is a term Γλf.λg.λa.g(fa):(AB)(¬B¬A). Indeed, given f:AB, g:¬B, and a:A we have fa:B and hence g(fa):0, so the displayed λ-term is well-typed by the rules of definition 27.2. No elimination out of 0 is needed; ¬A is itself a Π-type.

Exercise 28.1

★☆☆ Construct a term of type ¬¬¬A¬A, for any type A.

Exercise 28.2

★☆☆ Construct terms of the types (A¬B)(B¬A) and A¬¬A.

Exercise 28.3

★☆☆ Suppose Γh:C0. Construct, for every type D in context Γ, a term of type CD.

Exercise 28.4

★☆☆ Write out the definition of rec0 from definition 28.3 with the motive annotation of convention 28.1 restored, and display the instance of 0-elim used, with all premises.

Booleans

The booleans are the simplest type with more than one constructor; case analysis appears here in its purest form.

Extend the raw syntax by the nullary operators 2,tt,ff, and by ind2(x.C;ct,cf;b) of arity (1,0,0,0), binding x only in the motive C.

Definition 28.7 — Rules for

The type 2 of booleans is given by the rules

Γ ctx
Γ2 type
-form
Γ ctx
Γtt:2
-intro_1
Γ ctx
Γff:2
-intro_2
Γ,x:2C typeΓct:C(tt)Γcf:C(ff)Γb:2
Γind2(x.C;ct,cf,b):C(b)
-elim
Γ,x:2C typeΓct:C(tt)Γcf:C(ff)
Γind2(x.C;ct,cf,tt)ct:C(tt)
-comp_1
Γ,x:2C typeΓct:C(tt)Γcf:C(ff)
Γind2(x.C;ct,cf,ff)cf:C(ff)
-comp_2

Definition 28.8 — Recursor for

For ΓC type, the recursor is the instance of 2-elim at the weakened motive: rec2(ct,cf,b):=ind2(ct,cf,b)(ct,cf:C,b:2), of type C, with computation rules rec2(ct,cf,tt)ct and rec2(ct,cf,ff)cf inherited from 2-comp1,2. We write if b then ct else cf for rec2(ct,cf,b).

Example 73.9 — A dependent Boolean instance

For a family Γ,x:2C type, abstraction packages 2-elim as boolIndC:C(tt)C(ff)b:2C(b), where boolIndC:=λct.λcf.λb.ind2(x.C;ct,cf,b). Beta followed by Boolean computation gives boolIndCctcfttct,boolIndCctcfffcf. The two results inhabit the distinct fibers C(tt) and C(ff); the recursor of definition 28.8 is the constant-family case.

Example 28.9 — Negation on , with derivation

Put neg:=λb.rec2(ff,tt,b). The body of neg is derived by the following tree. We write Var for the variable rule of definition 26.22; the first premise displays the constant motive required by 2-elim.

b:2,x:22 type
-form
b:2ff:2
-intro_2
b:2tt:2
-intro_1
b:2b:2
Var
b:2rec2(ff,tt,b):2
-elim

One use of Π-intro now gives neg:22. By 2-comp1,2 and the β-rule of Π, negttff and negfftt.

Example 28.10 — Conjunction

Define and:=λa.λb.rec2(b,ff,a) of type 222. Then andttbb and andffbff for every b:2 — in particular for a variable b, where no case analysis on b has been performed.

Remark 28.11 — No η -rule for inductive types

One may contemplate a uniqueness rule for 2, asserting that a term depending on a boolean is determined by its values at the constructors:

Γ,x:2C typeΓ,x:2c:CΓb:2
Γind2(c(tt),c(ff),b)c(b):C(b)

This rule is not part of the theory. More generally, none of the inductive types in this chapter has a judgmental η-rule. The local consequence is visible without a metatheorem: when b is a variable, the term ind2(ct,cf,b) is neutral with respect to the Boolean computation rules, because those two rules apply only to tt and ff. Other equality rules may still identify its result—for example, every term of 1 equals by unit η—but no Boolean branch has fired. This contrasts with the primitive η-rules for Π, Σ, and 1 in definition 27.2, definition 27.9, definition 27.14. Thus the design boundary is fixed by the selected judgmental equality, not by the informal description “inductive type.”

A set model through booleans

To separate tt from ff and rule out a closed inhabitant of 0, an interpretation must assign one denotation to each raw expression, independently of its typing derivation. One might instead define the interpretation by induction on a typing derivation. That attempt fails at conversion: the same raw expression may arrive through different type equalities, so the induction produces a value only after a choice of derivation, while soundness needs one value shared by both routes. The domain annotation on raw abstraction nodes permits the stronger remedy: interpret raw syntax first, then prove that every derivation lands in that single partial interpretation.

Definition 28.12 — The partial set interpretation

Interpret raw contexts and official raw expressions before asking whether they are derivable. The recursion is partial: an ill-typed application, for example, need not denote. The kernel domain annotation on λ(x:A).b from convention 27.1 is essential here. It fixes the set-theoretic domain of the function without consulting a typing derivation; the usual printed abbreviation λx.b merely suppresses this raw argument. Put [[]]={},[[Γ,x:A]]={(ρ,a)ρ[[Γ]],a[[A]]ρΓ}. For a raw expression in a raw context, choose a representative of its alpha-class whose binders are fresh for the environment, and define [[e]]ρΓ by structural recursion on its raw binding tree. A variable denotes its coordinate of ρ. The binding clauses and the two dependent type formers are [[x:AB]]ρΓ=u[[A]]ρΓ[[B]](ρ,u)Γ,x:A,[[x:AB]]ρΓ=u[[A]]ρΓ[[B]](ρ,u)Γ,x:A, [[λ(x:A).b]]ρΓ=(u[[A]]ρΓ[[b]](ρ,u)Γ,x:A). Application is evaluation, pairing is the dependent ordered pair, and the projections are its coordinate maps. Interpret 1 by {} and by . Interpret 0 by and its eliminator by the unique section out of the empty set. Interpret 2 by {0,1}, with tt denoting 1 and ff denoting 0; Boolean elimination sends 1 to the true branch and 0 to the false branch. A context judgment is valid when its environment set is defined. A type judgment ΓA type is valid when ρ[[A]]ρΓ is a defined family of sets on [[Γ]]. A term judgment is valid when [[a]]ρΓ[[A]]ρΓ for every environment. Type equality means equality of families, and term equality means pointwise equality of sections. Structural induction on raw binding trees shows that renaming a bound variable merely renames the corresponding environment coordinate. Hence the definition is independent of the representative and descends to the alpha-classes of convention 26.8.

The structural rules can remove a declaration followed by an arbitrary telescope, or insert one before such a telescope. The semantic equations must therefore have the same generality.

Lemma 28.13 — Semantic substitution and weakening

Let F be any raw type or term expression in the indicated context.

  1. Suppose that [[a]]ρΓ is defined at every environment ρ under consideration. Define on raw environment tuples sa,(ρ):=(ρ,[[a]]ρΓ),sa,Δ,y:D(δ,d):=(sa,Δ(δ),d). If F is displayed in Γ,x:A,Δ and sa,Δ(δ) is defined, then the two sides below are defined simultaneously and, when defined, [[F[a/x]]]δΓ,Δ[a/x]=[[F]]sa,Δ(δ)Γ,x:A,Δ.

  2. Define the deletion map on raw tuples by wA,(ρ,a):=ρ,wA,Δ,y:D(δ,d):=(wA,Δ(δ),d). If F is displayed in Γ,Δ and wA,Δ(δ) is defined, its weakening to Γ,x:A,Δ satisfies, whenever either side is defined, [[F]]δΓ,x:A,Δ=[[F]]wA,Δ(δ)Γ,Δ.

If Γa:A is semantically valid, then sa,Δ sends every valid environment of Γ,Δ[a/x] to one of Γ,x:A,Δ. If ΓA type is semantically valid, then wA,Δ sends every valid environment of Γ,x:A,Δ to one of Γ,Δ.

Proof of Lemma 28.13 — Semantic substitution and weakening

Proof. For substitution, use structural induction on a representative of F whose binders are fresh for a, with Δ universally quantified. A variable case replaces precisely the x-coordinate by [[a]]ρ, and a nonbinding operator follows from the induction hypotheses for its arguments. For a binder y and a fixed d, the body induction hypothesis is [[F]](sa,Δ(δ),d)Γ,x:A,Δ,y:D=[[F[a/x]]](δ,d)Γ,Δ[a/x],y:D[a/x]. For the binder clause, the two functions have the same domain and the same value at every d, hence are equal as sets of ordered pairs. This includes the two dependent type formers.

For weakening, structural induction on a representative with a fresh binder y gives, for every fixed d, [[F]](δ,d)Γ,x:A,Δ,y:D=[[F]](wA,Δ(δ),d)Γ,Δ,y:D. The same equality of set-theoretic functions proves the binder clause. Finally, apply the appropriate equation to each successive declaration type of Δ; it shows that the unchanged last coordinate belongs to the required fiber. At the base of the substitution map, semantic validity of a:A puts the inserted coordinate in [[A]]ρ; at the base of weakening, semantic validity of A makes that fiber a set. Induction along Δ proves the two final landing assertions. ◻

Lemma 73.15 — Soundness through booleans

Every derivable judgment in the fragment consisting of the structural rules and Π, Σ, 1, 0, and 2 is valid in definition 28.12.

Proof of Lemma 73.15 — Soundness through booleans

Proof. Proceed simultaneously over derivations of contexts and of the four expression judgments. The interpretation is a structural operation on the official raw subject; in particular, the domain of every abstraction is its raw A-annotation. Thus two occurrences of the common middle subject in a transitivity rule have literally the same interpretation. The context rules are the two defining clauses for [[]] and [[Γ,x:A]], and each presupposition rule selects a valid premise. Rule Var is a coordinate projection. Rules Wk and Subst are (28.2) and (28.1). If aa:A, the smaller-height equality premise gives equal sections; induction along Δ gives sa,Δ=sa,Δ and proves both equal-substitution rules. Equal declaration families give literally equal environment extensions, proving context conversion.

Reflexivity and symmetry are the corresponding laws of set-theoretic equality, and transitivity is set-theoretic transitivity on the one structurally interpreted middle expression. Congruence applies one defined set operation to equal arguments. If an equality premise interprets A and B as the same family, a section of [[A]] is literally a section of [[B]]; this proves conversion.

The added formers now follow from the clauses of definition 28.12. Pi-beta is evaluation and Pi-eta is equality of functions, with the weakened f identified by (28.2). Sigma-beta is projection and Sigma-eta reconstructs an ordered pair. Unit-eta is equality in a singleton. The Void eliminator is the unique section out of the empty set; Boolean elimination evaluates at 1 or 0. This treats every primitive final-rule family in the stated fragment. ◻

Proposition 28.15 — A separating set interpretation

In ZFC, the fragment through 2 has the set interpretation of definition 28.12. In that model 0 is empty and 2 has two elements. Consequently:

  1. the empty context has no term of 0;

  2. there is no derivation of ttff:2; and

  3. in context b:2, the variable b is judgmentally equal to neither constructor.

Proof of Proposition 28.15 — A separating set interpretation

Proof. Soundness is lemma 73.15. A closed term of 0 would denote an element of , while the displayed closed Boolean equality would force 1=0. In context b:2, the environment set is {0,1}; the variable denotes the identity function and the constructors denote the two constant functions. Pointwise equality separates the variable from each. ◻

Remark 28.16 — Generic booleans

A variable b:2 is judgmentally equal to neither tt nor ff, by proposition 28.15. Thus “two constructors” does not mean “two raw open terms”: variables and neutral eliminations remain. What 2-elim says is instead that every family may define a value by treating the two constructors. The same proposition also proves that the closed judgment ttff:2 is not derivable; no internal type expressing disequality is being used here.

Exercise 28.5

★★☆ Define or, implies, and xor of type 222 using rec2. Orient the operations by the first argument and derive all six equations orttbtt,orffbb,impliesttbb,impliesffbtt,xorttbnegb,xorffbb.

Exercise 28.6

★★☆ For Γ,x:2C type, 2-elim constructs the function Γλct.λcf.λb.ind2(x.C;ct,cf,b):C(tt)C(ff)b:2C(b). Derive this typing and its two computation equations, displaying the necessary weakening and Π-rules. Conversely, suppose a principle supplies, for every such C, a function of the displayed type with those two equations. Apply it successively to ct, cf, and b to obtain a term of C(b) and recover the two Boolean computations. Thus the two principles yield one another; no literal equality with the primitive eliminator subject is claimed.

Coproducts

The coproduct A+B is the disjoint union of two types; its constructors are unary, and its eliminator is case analysis with parameters.

Extend the raw syntax by A+B, inl(a), inr(b), and ind+(z.C;f,g;s) of arities (0,0), (0), (0), and (1,0,0,0). Only the first eliminator argument binds, and it binds z in C.

Definition 28.17 — Rules for coproducts

For types A and B, the coproduct A+B is given by:

ΓA typeΓB type
ΓA+B type
+-form
Γa:AΓB type
Γinl(a):A+B
+-intro_1
ΓA typeΓb:B
Γinr(b):A+B
+-intro_2
Γ,z:A+BC typeΓf:x:AC(inl(x))Γg:y:BC(inr(y))Γs:A+B
Γind+(z.C;f,g,s):C(s)
+-elim
Γ,z:A+BC typeΓf:x:AC(inl(x))Γg:y:BC(inr(y))Γa:A
Γind+(z.C;f,g,inl(a))fa:C(inl(a))
+-comp_1
Γ,z:A+BC typeΓf:x:AC(inl(x))Γg:y:BC(inr(y))Γb:B
Γind+(z.C;f,g,inr(b))gb:C(inr(b))
+-comp_2

The left branch has type x:AC(inl(x)), and the right branch has type y:BC(inr(y)). Using ordinary functions for these branches keeps the coproduct eliminator itself nonbinding (cf. exercise 28.6).

Definition 28.18 — Case analysis

For ΓC type and f:AC, g:BC, the recursor is the instance of +-elim at the weakened motive; we write [f,g]:=λs.ind+(f,g,s):A+BC, so that [f,g](inl(a))fa and [f,g](inr(b))gb.

The nondependent branch types do not suffice for a dependent motive. The tempting rule

Γ,z:A+BC typeΓf:ACΓg:BCΓs:A+B
Γind+(z.C;f,g,s):C(s)
failed

is not even well formed: C is a type only in context Γ,z:A+B. After substituting inl(a) for z, the left branch must produce C(inl(a)), not an element of one fixed type.

Example 73.20 — Dependent case analysis

Given Γ,z:A+BC type, package the eliminator as caseC:=λf.λg.λs.ind+(z.C;f,g;s):(x:AC(inl(x)))(y:BC(inr(y)))s:A+BC(s). For branch terms f and g of the displayed types, beta followed by the coproduct computations gives caseCfg(inl(a))fa,caseCfg(inr(b))gb. The result fibers are C(inl(a)) and C(inr(b)), so this is a genuinely dependent instance even when those fibers happen to be judgmentally equal.

Example 28.19 — Functoriality

Given f:AA and g:BB, define f+g:=[λa.inl(fa),λb.inr(gb)]:A+BA+B, so that (f+g)(inl(a))inl(fa) and (f+g)(inr(b))inr(gb).

Example 28.20 — Symmetry

The term swap:=[λa.inr(a),λb.inl(b)]:A+BB+A satisfies swap(inl(a))inr(a) and swap(inr(b))inl(b). Consequently swap(swap(inl(a)))inl(a), and likewise on inr. For a variable s:A+B, however, neither of the two coproduct computation rules applies to the outer case analysis. Thus the rules directly establish the displayed constructor calculations; no coproduct η-rule is assumed (remark 28.11).

Exercise 28.7

★★☆ Define 2:=1+1, tt:=inl(), ff:=inr(). Derive the elimination and computation rules of definition 28.7 for 2, with the computation rules holding judgmentally. (Use ind+ followed by the eliminator of 1 in each branch, as derived in proposition 27.17.)

Exercise 28.8

★★☆ Construct terms α:(A+B)+CA+(B+C) and β:A+(B+C)(A+B)+C and verify by computation that β(αs)s for s each of the three constructor forms inl(inl(a)), inl(inr(b)), inr(c).

Exercise 28.9

★★☆ Construct terms F:(A+BC)(AC)×(BC),G:(AC)×(BC)(A+BC), where × is the non-dependent Σ of remark 27.11. Verify the three constructor equations F(G((f,g)))(f,g),G(Fh)(inl(a))h(inl(a)),G(Fh)(inr(b))h(inr(b)).

Natural numbers

With N a recursive constructor appears for the first time: the successor takes a natural number and returns one.

Extend the raw syntax by the nullary operators N,0, the unary operator suc(n), and indN(x.C;c0,cs;m) of arity (1,0,0,0). The variable x is bound only in the motive C.

Definition 28.21 — Rules for

The type N of natural numbers is given by: for a family x:NC, write StepN(C):=n:NC(n)C(suc(n)). To keep the two computation rules readable, abbreviate the raw eliminator by IC(c0,cs;m):=indN(x.C;c0,cs,m).

Γ ctx
ΓN type
-form
Γ ctx
Γ0:N
-intro_1
Γn:N
Γsuc(n):N
-intro_2
Γ,x:NC typeΓc0:C(0)Γcs:StepN(C)Γm:N
ΓIC(c0,cs;m):C(m)
-elim
Γ,x:NC typeΓc0:C(0)Γcs:StepN(C)
ΓIC(c0,cs;0)c0:C(0)
-comp_1
Γ,x:NC typeΓc0:C(0)Γcs:StepN(C)Γm:N
ΓIC(c0,cs;suc(m))csm(IC(c0,cs;m)):C(suc(m))
-comp_2

The step cs receives the predecessor n and the inductive hypothesis C(n), and produces C(suc(n)). Thus N-elim is the type-theoretic principle of mathematical induction.

Definition 28.22 — Recursor for

Let ΓC type, c0:C, cs:NCC, and m:N. The recursor recN(c0,cs,m):C is the instance of N-elim at the weakened motive. Its computation rules read recN(c0,cs,0)c0,recN(c0,cs,suc(m))csm(recN(c0,cs,m)). This is exactly the primitive recursion scheme.

Construction 28.23 — Addition

We construct add:NNN satisfying the judgmental specification addm0m,addm(suc(n))suc(addmn), and write m+n for addmn. Working in context m:N, we recur on the second argument at the constant motive N: the base case is m itself, and the step ignores the predecessor and applies suc to the inductive hypothesis. That is, add:=λm.λn.recN(m,λk.λr.suc(r),n). The specification holds by N-comp1,2 and β-reduction for Π: for the second clause, addm(suc(n))(λk.λr.suc(r))n(addmn)suc(addmn).

Construction 73.26 — Multiplication

Using addition in the step, define mul:=λm.λn.recN(0,λk.λr.r+m,n):NNN. The predecessor k is unused and the recursive result r has type N. The two recursor computations therefore give mulm00,mulm(suc(n))mulmn+m.

Example 28.24 — A closed computation

Write k for the numeral obtained by applying suc exactly k times to 0. Then 2+2Ncomp2suc(2+1)Ncomp2suc(suc(2+0))Ncomp1suc(suc(2))numeral notation4. This calculation uses only that both arguments are constructors.

Remark 28.25 — Judgmental vs. provable equations

The defining equations unfold along the second argument only. Thus m+0m and m+suc(n)suc(m+n) compute immediately, even when m is a variable. By contrast, if n is a variable, neither 0+n nor suc(m)+n matches a recursor computation rule, so both are stuck. This is a statement about the displayed recursor’s root rules.

Exercise 28.10

★★☆ Using mul from construction 73.26, construct exp:NNN with expm01, and expm(suc(n))mul(expmn)m.

Exercise 28.11

★★☆ Construct the predecessor pred:NN with pred00 and pred(suc(n))n, and truncated subtraction ˙:NNN satisfying m˙0m,m˙suc(n)pred(m˙n).

Exercise 28.12

★☆☆ Assume ΓC type, c0:C, f:CC, and n:N. Define the iterator iterc0fn:C satisfying iterc0f0c0 and iterc0f(suc(n))f(iterc0fn), as a special case of recN. Then define add using iter alone.

Exercise 28.13

★★☆ Let Γ,n:NC type. Use the dependent natural-number eliminator to construct indC:C(0)(k:NC(k)C(suc(k)))n:NC(n). Begin with λc0.λcs.λn.indN(n.C;c0,λk.λr.cskr;n). Display the weakenings that place c0 and cs in the eliminator premises, and derive the judgmental equations at 0 and suc(k). This is the binder form of dependent induction, not the constant-motive recursor.

Exercise 28.14

★★★ Construct the Ackermann–Péter function ack:NNN with ack0nsuc(n),ack(suc(m))0ackm1,ack(suc(m))(suc(n))ackm(ack(suc(m))n), by recursion at the type NN. Use the N-recursor with constant motive NN; unlike addition, its recursive results are themselves functions.

Exercise 28.15

★★★ Construct eq:NN2 by recursion such that eqmn computes to tt if m=n and to ff otherwise, and verify eq22tt. Let the outer recursion return a function N2; in the successor branch use the predecessor result to compare the two predecessors.

The logical reading of induction

Under propositions-as-types, the eliminators of this chapter are exactly the proof principles of intuitionistic logic and arithmetic.

Theorem 28.26 — Logical reading

Let Γ be a well-formed context and let A, B, C be types in Γ, with Γ,x:NP type a family over N. The following types have inhabitants in context Γ, uniformly in the given data:

  1. (ex falso quodlibet) 0C;

  2. (proof by cases) (AC)(BC)(A+B)C;

  3. (mathematical induction) P(0)(n:N(P(n)P(suc(n))))n:NP(n).

Proof of Theorem 28.26 — Logical reading

Proof. For the first clause, the term is rec0 (definition 28.3). For the second, λf.λg.[f,g] (definition 28.18). For the third, λc0.λcs.λn.indN(c0,cs,n), using N-elim under the three λ-abstractions. Weakening places c0 and cs in the eliminator context; its zero and successor computations become the two induction equations after the three Π-β steps. ◻

Example 73.30 — A proposition proved by induction

Read 1 as truth. Natural-number induction proves n:N1 from the base proof and the step λk.λu.: p:=λn.indN(n.1;,λk.λu.;n):n:N1. The zero computation gives p0; the successor computation gives p(suc(n))(λk.λu.)n(pn). Thus the proof term, its induction hypothesis, and both constructor calculations are visible rather than supplied only by the dictionary.

The dictionary so far, combining definition 27.2, definition 27.9 with this chapter:

Former Logical reading Eliminator Proof principle
0 falsehood ind0 ex falso quodlibet
1 truth
A+B disjunction AB ind+ proof by cases
x:AB existential pr1,pr2 witness, evidence
x:AB universal , implication application modus ponens
N domain of individuals indN mathematical induction

Remark 28.27 — Proof relevance

The reading is proof-relevant: a term of A+B carries the tag of the case that holds, and a term of x:AB carries an explicit witness. Consequently a term of A+¬A supplies more than an unlabeled truth value: it is a decision procedure, returning either an element of A or a function A0. In this chapter, “A or B” therefore means the tagged data A+B.

Exercise 28.16

★☆☆ Construct a term of type ¬¬(A+¬A) for any type A; thus the classical case split is stable under double negation. (Given h:¬(A+¬A), first obtain k:¬A by ka:=h(inl(a)), and then apply h to inr(k).)

Exercise 28.17

★☆☆ Construct terms of the types ¬(A+B)¬A׬B and ¬A׬B¬(A+B).

Well-founded trees: W-types

Each inductive type so far required its own rules. W-types capture their common tree shape: a W-type is determined by a type of constructor symbols and a family of arities. Under explicit hypotheses on such an arity family, theorem 28.32 constructs the recursors of the encoded natural numbers, lists, and binary trees.

Extend the raw syntax by Wx:AB of arity (0,1), sup(a,f) of arity (0,0), and indW(w.C;h,t) of arity (1,0,0). The W-former binds x in B, and the eliminator binds w only in C.

Definition 28.28 — Rules for W-types

For ΓA type and Γ,x:AB type, the type Wx:AB of well-founded trees is given by the rules below; we abbreviate W:=Wx:AB. For a family w:WC, also write StepW(C):=a:Aα:B(a)W(y:B(a)C(αy))C(sup(a,α)). For h:StepW(C) and f:B(a)W, abbreviate the family of recursive results by RC,h(f):=λy.indW(w.C;h,fy).

ΓA typeΓ,x:AB type
ΓWx:AB type
W-form
Γa:AΓf:B(a)W
Γsup(a,f):W
W-intro
Γ,w:WC typeΓh:StepW(C)Γt:W
ΓindW(w.C;h,t):C(t)
W-elim
Γ,w:WC typeΓh:StepW(C)Γa:AΓf:B(a)W
ΓindW(w.C;h,sup(a,f))haf(RC,h(f)):C(sup(a,f))
W-comp

In W-elim, B(a) means the substitution instance B[a/x] of the arity family fixed in the formation premise. A tree sup(a,f) has root labeled by the symbol a and a B(a)-indexed family of immediate subtrees f; the step h receives the label, the subtrees, and the inductive hypotheses for all subtrees.

Construction 28.29 — The dependent W-section

Let W:=Wx:AB and suppose Γ,w:WC type. Given the explicitly typed step h:a:Aα:B(a)W(y:B(a)C(αy))C(sup(a,α)), W-elimination constructs the section indWh:=λt.indW(w.C;h,t):t:WC(t). Its value on a constructed tree exposes exactly the inductive hypotheses: indWh(sup(a,f))ΠβindW(w.C;h,sup(a,f))Wcomphaf(λy.indW(w.C;h,fy))Πβhaf(λy.indWh(fy)):C(sup(a,f)). Thus W-elimination constructs the whole dependent section; recursion below is its constant-family instance.

Definition 28.30 — Recursor for W

For ΓC type, weaken C to the constant family over W. The resulting step has type h:a:Aα:B(a)W((B(a)C)C). Define recW(h,t):=indW(h,t):C. Its computation rule is recW(h,sup(a,f))haf(λy.recW(h,fy)):C. Here f:B(a)W is the family of immediate subtrees, while the last argument sends each index y:B(a) to the recursively computed value of the subtree fy. If t:W is a variable, recW(h,t) is neutral: W-comp fires only when its target is displayed as sup(a,f).

Example 28.31 — A W-type available immediately

Let ΓA type and take the constant arity family B(x):=0. Then LA:=Wx:A0 has a leaf leafa:=sup(a,rec0) for every a:A. Given k:AC, the W-recursor with h:=λa.λα.λq.ka satisfies recW(h,leafa)ka. The unused arguments α:0LA and q:0C record that a leaf has no subtrees and hence no recursive results.

The more familiar encodings require arity families whose values depend on a Boolean or a coproduct. The fixed signature cannot construct such families, so the arity families in the theorem are explicit hypotheses.

For example, the tempting definition BN(b):=?rec2(0,1,b) does not type-check. The Boolean recursor consumes two terms of one result type C, whereas 0 and 1 are types: Γ0 typeΓ1 typeΓ,b:2rec2(0,1,b):Cfailed has no possible term-typing premises for its two branches. With a universe closed under 0 and 1, one could derive Γ0:Ui and Γ1:Ui and eliminate b:2 into Ui. Without that former, the arity families must remain explicit hypotheses.

Theorem 28.32 — Encodings via W-types

Assume ΓA type and three arity families Γ,b:2BN type,Γ,s:1+ABL type,Γ,b:2BT type, with the following equalities of types in the displayed contexts: ΓBN(ff)0 type,ΓBN(tt)1 type,Γ,u:1BL(inl(u))0 type,Γ,a:ABL(inr(a))1 type,ΓBT(ff)0 type,ΓBT(tt)2 type. No universe term is meant here: these are ordinary type families given as judgment-level hypotheses. Define N:=Wx:2BN(x),L:=Wx:1+ABL(x),T:=Wx:2BT(x). For every ΓC type, the following recursion principles hold:

  1. Put z:=sup(ff,rec0) in Γ, and in Γ,n:N put sn:=sup(tt,λu.n). For every c0:C and cs:NCC, there is recN:NC with recNzc0,recN(sn)csn(recNn).

  2. Put nil:=sup(inl(),rec0) in Γ, and in Γ,a:A,:L put consa:=sup(inr(a),λu.). For every cn:C and cc:ALCC, there is recL:LC with recLnilcn,recL(consa)cca(recL).

  3. Put leaf:=sup(ff,rec0) in Γ. In Γ,:T,r:T, write br,r:=λb.rec2(,r,b), put noder:=sup(tt,br,r). For every cl:C and cn:TTCCC, there is recT:TC with recTleafcl, recT(noder)cnr(recT)(recTr).

Proof of Theorem 28.32 — Encodings via W-types

Proof. First verify how the arity equalities type the displayed constructors. For example, rec0:0N. Symmetry of BN(ff)0, followed by dependent-product congruence, gives 0NBN(ff)N. Rule Conv therefore types rec0 at BN(ff)N, and W-intro gives z=sup(ff,rec0):N.

For the list constructor, substitute the given a:A into the arity equality to obtain BL(inr(a))1. Symmetry and function-type congruence give 1LBL(inr(a))L. Thus Conv types λu. at BL(inr(a))L, and W-intro derives consa:L. The typings of s, nil, leaf, and node use the same conversion along their corresponding arity equalities. The same conversion changes α,q to functions with the familiar domain 1 or 2 before the applications at , tt, and ff below. This is the mechanism by which the judgment-level arity hypotheses enter every construction.

For the first encoding, let C, c0, cs be given. Write MN for the family x:2(BN(x)N)(BN(x)C)C, and note the judgmental equalities MN(tt)(1N)(1C)C and MN(ff)(0N)(0C)C, by the assumed values of BN and congruence. Define et:=λα.λg.cs(α)(g):MN(tt),ef:=λα.λg.c0:MN(ff), and h:=λx.ind2(et,ef,x), a term of the step type of definition 28.30 for the constant motive C. Put recN:=λt.recW(h,t). Then recNzWcomphffrec0(λy.recN(rec0y))2comp2efrec0(λy.recN(rec0y))Πβc0, and recN(sn)Wcomphtt(λy.n)(λy.recNn)2comp1cs((λy.n))((λy.recNn))Πβcsn(recNn). Both computation rules are judgmental, as claimed.

For the second encoding, put ML(v):=(BL(v)L)(BL(v)C)C. The two coproduct branches of a step v:1+AML(v) are enil:=λu.λα.λq.cn:u:1ML(inl(u)), econs:=λa.λα.λq.cca(α)(q):a:AML(inr(a)). Let hL:=λv.ind+(enil,econs,v) and recL:=λt.recW(hL,t). For nil, W-computation, left coproduct computation, and beta give recLnilWcomp,+comp1enil(,rec0,λy.recL(rec0y))Πβcn. For a cons cell the same three rules, now in the right branch, give recL(consa)Wcomp,+comp2econsa(λu.)(λu.recL)Πβcca(recL).

For the third encoding, write br,r:=λb.rec2(,r,b):2T, so that br,rtt and br,rffr. Put MT(b):=(BT(b)T)(BT(b)C)C and define eleaf:=λα.λq.cl:MT(ff), enode:=λα.λq.cn(αtt)(αff)(qtt)(qff):MT(tt). Let hT:=λb.ind2(enode,eleaf,b) and recT:=λt.recW(hT,t). The false branch gives recTleafcl. For a node, W-computation gives enode the subtree family br,r and the recursive-results family λb.recT(br,rb). Evaluating each at the two Boolean constructors therefore yields recT(noder)Wcomp,2comp1,2,Πβcnr(recT)(recTr), by W-computation, Boolean computation, and beta. This proves all three recursion principles in the stated fragment. ◻

Example 73.37 — A program on the W-encoded naturals

Use the first recursion principle of theorem 28.32 at result type N, base z, and step λn.λr.s(sr). The resulting doubleN:NN satisfies doubleNzz,doubleN(sn)s(s(doubleNn)). The first equation is the encoded-nullary computation in the proof above; the second is W-computation at the unit-indexed subtree followed by Π-β.

Remark 28.33

The word recursion in theorem 28.32 is deliberate. The W-type itself has the dependent eliminator of definition 28.28, but an encoded nullary constructor may be displayed as sup(ff,α) for an arbitrary α:0N, not only as z=sup(ff,rec0). The constant motives above ignore this difference, so their computation equations are judgmental. A Nat-style dependent motive would have to compare its fibers at those two displayed trees. No such comparison rule is part of the Nat induction data established here, and the theorem makes no claim about dependent elimination for this encoding.

Exercise 28.18

★☆☆ Use clause 2 of theorem 28.32 to define length:LN with lengthnil0,length(consa)suc(length).

Exercise 28.19

★☆☆ Use clause 3 of theorem 28.32 to define leaves:TN with leavesleaf1,leaves(noder)leaves+leavesr. State the four arguments passed to the node step before writing the term.

Exercise 28.20

★★☆ Suppose Γk:x:AB, i.e. every arity is pointed. Construct a term of type ¬Wx:AB. (Use W-elim with the constant motive 0: the inductive hypothesis at kx yields the contradiction.)

Extending the set model

The syntax and rules for coproducts, natural numbers, and W-types are now in scope, so their semantic clauses can be checked against the displays they interpret.

Definition 73.39 — Set interpretation of coproducts, naturals, and W-types

Extend definition 28.12 as follows. A coproduct is the tagged union {0}×[[A]]ρΓ{1}×[[B]]ρΓ, with the two injections inserting their tags and elimination selecting the tagged branch. Interpret N by the metatheoretic natural numbers, with zero, successor, and dependent recursion.

For Wx:AB at ρ, put Aρ:=[[A]]ρΓ and Bρ,a:=[[B]](ρ,a)Γ,x:A. Choose an infinite regular cardinal κ strictly larger than every |Bρ,a|. Define an increasing family by transfinite recursion: Wρ0=,Wρα+1=aAρ(Bρ,aWρα),Wρλ=α<λWρα(λ limit). where an element of the successor stage is written sup(a,f). Set Wρ=α<κWρα. If f:Bρ,aWρ, regularity of κ bounds the ranks of all f(y) below one α<κ; hence sup(a,f)Wρ. Conversely, induction on α shows that every set closed under sup contains Wρα, so Wρ is the least closed set.

Declare f(y)sup(a,f). The least stage containing f(y) is smaller than the least stage containing sup(a,f), so is well founded. The W-eliminator is well-founded recursion on this relation; at sup(a,f) it applies the step to a, f, and yrec(f(y)).

Lemma 28.14 — Soundness of the partial interpretation

Every derivable judgment formed from the structural rules, Π, Σ, 1, 0, 2, coproducts, N, and W is valid in the extended set interpretation.

Proof of Lemma 28.14 — Soundness of the partial interpretation

Proof. The cases through booleans are lemma 73.15. Structural induction on raw expressions adds the three clauses of lemma 28.13: tagged union and ordinary recursion commute with reindexing, while the transfinite construction of Wρ is determined only by the reindexed families Aρ and Bρ,a.

It remains to inspect the new final rules. Coproduct introduction inserts a tag, elimination selects that tag, and the two computation rules are literal case equations. The natural-number rules are the formation, zero, successor, and dependent-recursion clauses of N. W-formation uses the set Wρ just constructed; W-introduction is closure under sup; and the elimination and computation rules are the defining equations of well-founded recursion on . Congruence applies the same set operation to equal arguments. These are all new rule families. ◻

Corollary 73.41 — Relative consistency of the inductive fragment

ZFC proves that the theory through W-types has no closed term of 0 and does not derive ttff:2. Hence consistency of ZFC implies consistency of this displayed type theory.

Proof of Corollary 73.41 — Relative consistency of the inductive fragment

Proof. By lemma 28.14, a closed term of 0 would denote an element of , and the Boolean equation would force 1=0. ◻

The general pattern

Every type of this chapter is an instance of one schema. For each constructor ci, the eliminator has one branch whose arguments are the constructor’s nonrecursive data, recursive subtrees, and an induction hypothesis for each subtree. The following schema covers the nonindexed signatures used in this chapter and keeps each induction hypothesis visible. Recursive occurrences are restricted to outputs of the displayed arity functions. It does not cover indexed families such as identity types or vectors, mutual blocks, nested recursive occurrences such as List(X), or induction–recursion such as a Tarski universe. Those require strictly stronger declaration disciplines than the polynomial signature defined here.

Definition 28.34 — A polynomial inductive signature

A polynomial inductive signature specifies finitely many constructors by nonrecursive parameter telescopes and recursive arity telescopes. For each constructor index i, choose:

  1. a telescope Δi of non-recursive parameters, whose types are formed over Γ and earlier entries of Δi; and

  2. finitely many recursive arity telescopes Θi1,,Θiri, formed over Γ,Δi.

None of these telescope types mentions the fresh symbol X. If u:Δi and z:Θij, the ith constructor has the scheme (Ci)ci:u:Δif1:z:Θi1Xfri:z:ΘiriXX. The dots denote the displayed finite telescope in increasing order; they are not a function product over a finite index type. The formation judgment is ΓInd type. The primitive introduction rule says that well-typed arguments u:Δi,fj:z:ΘijInd(1jri) produce ci(u,f1,,fri):Ind. Display (Ci) is the Pi-coded telescope of those premises, not a change from the primitive operator syntax. The product over an empty arity telescope is X itself, so direct recursive arguments are included.

For a motive Γ,w:IndC type, the corresponding case has one inductive-hypothesis family immediately after each recursive argument: write Fij:=z:ΘijInd,Qij(f):=z:ΘijC(f(z)). Then its case telescope is (Ei)u:Δif1:Fi1q1:Qi1(f1)fri:Firiqri:Qiri(fri)C(ci(u,f1,,fri)). If di has this case type for every i and t:Ind, the full elimination judgment is Γind(w.C;d1,,dk;t):C(t). Its ith computation rule is obtained by writing Ij(fj):=λz.ind(w.C;d;fj(z)). It is the equation ind(w.C;d;ci(u,f))di(u,f1,I1(f1),,fri,Iri(fri)):C(ci(u,f)). Thus the ith case is applied to u, to every fj, and to the recursively computed family for every j. In (Ci), the symbol X occurs only as the final result of an arity product. This restriction is strict positivity: no constructor argument places X to the left of an arrow.

Equivalently for this polynomial fragment, the admissible constructor result types are generated by the following predicate, decidable by structural recursion on the finite type expression: SPX(X) XFV(C)SPX(T)SPX(z:CT)ArX(F)SPX(T)fFV(T)SPX(f:FT), where recursive arities are generated separately by ArX(X)XFV(C)ArX(T)ArX(z:CT). Thus the last SP clause admits a recursive-argument domain such as X or ΘX, while Ar rejects XX: the recursive type may occur only as the arity’s final result. The telescope display above is a normal form for these clauses after permuting independent Π-binders. This checker still rejects nested occurrences under a previously declared positive constructor. A larger checker may admit them by recording, for each parameter of that earlier constructor, whether the parameter occurs only positively, only negatively, or in both polarities.

The ordering in (Ei) is interleaved only to keep each recursive argument adjacent to its induction hypothesis. Permuting independent Π-binders gives the grouped convention used by many implementations: all recursive arguments first, then all induction hypotheses.

When the universe hierarchy is installed, the schema has an accompanying closure obligation: if every type in Δi and Θij is coded at the same external level, then the generated Ind is coded at that level. This is a rule schema, not a consequence of formation in type; large or indexed inductives require additional level constraints.

Example 28.35 — Generating the natural-number rules

For 0, take Δ0 empty and r0=0. Its case is c0:C(0). For suc, again take Δs empty, but take one recursive argument with empty arity telescope. Formula (Ci) becomes suc:NN, and (Ei) becomes cs:n:N(C(n)C(suc(n))). The generated computation equations are exactly indN(c0,cs,0)c0,indN(c0,cs,suc(n))csn(indN(c0,cs,n)). Thus the recursive argument n generates the inductive hypothesis C(n)—the characteristic extra premise of induction.

The remaining rule displays fit the same template. 0 has no constructors; 2 has two constructors with empty Δ and no recursive arguments; the two coproduct constructors have parameter telescopes a:A and b:B; and W has one constructor with parameter a:A and one recursive arity telescope y:B(a). These give precisely definition 28.2, definition 28.7, definition 28.17, definition 28.28.

Proposition 73.44 — Set soundness of the polynomial schema

Every polynomial signature admitted by definition 28.34 extends the set interpretation by a set [[Ind]]ρΓ validating its formation, introduction, elimination, and computation rules.

Proof of Proposition 73.44 — Set soundness of the polynomial schema

Proof. Fix an environment ρ. Interpreting a nonrecursive parameter telescope gives the set [[Δi]]ρ of its assignments. For an arity telescope define its factor recursively, retaining the curried dependent product represented by the syntax: R()ρ,u(X):=X,R(z:C,Θ)ρ,u(X):=z[[C]]ρ,uRΘρ,u,z(X). The constructors therefore determine the polynomial operator Fρ(X)=iu[[Δi]]ρj=1riRΘijρ,u(X). In particular the empty telescope denotes X itself, while (z:C,w:D(z)) denotes z[[C]]w[[D(z)]]X on the nose, rather than the merely isomorphic set of functions from uncurried assignment tuples. Choose an infinite regular cardinal larger than every domain set occurring in the displayed arity telescopes and iterate Fρ from exactly as in definition 73.39. Regularity makes the union stage closed under Fρ, and transfinite induction makes it the least closed set. The immediate-subtree relation decreases the construction rank, so it is well founded. Well-founded recursion supplies the eliminator and gives the displayed computation equation at each constructor. Reindexing commutes with the polynomial operator because every Δi and Θij is a telescope of previously interpreted types. The derivation-induction proof of lemma 28.14 therefore gains precisely the advertised rule cases. ◻

Remark 28.36 — Strict positivity

The requirement that the recursive type occur only in the codomains displayed in definition 28.34 is the strict-positivity condition. It is a genuine restriction. Suppose we admitted a type D with the single constructor fold:(D0)D(X occurs negatively), together with the case-analysis recursor the schema would prescribe: for every C and e:(D0)C a map recD(e):DC with recD(e,fold(u))eu. Taking C:=D0 and e:=λu.u yields unfold:D(D0) with unfold(fold(u))u. Now set δ:=λd.unfolddd:D0,ω:=δ(fold(δ)):0. The typing is worth checking before the reduction. In context d:D, unfoldd:D0, hence unfolddd:0; abstraction gives δ:D0, so fold(δ):D and finally ω:0 in the empty context. Orient beta and recursor computation from left to right, allow either rule to act in any subterm position, and write tt for one such contextual step. A normal form has no outgoing step; a term is strongly normalizing when no infinite sequence of steps starts from it. Put d0:=fold(δ). Beta and the bad recursor equation give the nonempty cycle ωunfoldd0d0((λu.u)δ)d0δd0=ω. Repeating it produces an infinite reduction sequence, while the typed term ω makes the theory extended by D syntactically inconsistent: it derives a closed term of 0. It also shows that the separating set interpretation cannot be extended to this D. The strict-positivity condition excludes this simultaneous failure of consistency and normalization; it is not a bureaucratic side condition.

The same schema makes the indexed boundary visible. A vector family would need constructor conclusions vnil:Vec(A,0),vcons:n:NAVec(A,n)Vec(A,suc(n)). But every constructor generated by (Ci) must end in the one fixed type Ind: (Ci) requires conclusion Indvcons(n,a,v):Ind(sucn)failed. The application Ind(sucn) is not even formed, since Ind is a type rather than a family. Replacing it by the single type n:NVec(A,n) would make a constructor return an entire family, not the required fiber. Indexed constructor conclusions are therefore genuinely outside this unindexed schema.

Exercise 28.21

★★☆ Instantiate definition 28.34 for primitive lists over A (constructors nil:List(A) and cons:AList(A)List(A)): display all formation, introduction, elimination, and computation rules in the format of definition 28.21. For the cons case, the generated branch type must contain, in order, a:A, :List(A), and the inductive hypothesis for .

Exercise 28.22

★☆☆ Using the rules just generated, define length:List(A)N and derive its two judgmental computation equations.

Exercise 28.23

★★★ Carry out the computation of remark 28.36 in detail: exhibit the typing derivations of δ and ω in the extended theory. Exhibit the nonempty reduction cycle displayed there and conclude that an infinite reduction sequence starts at ω, so ω is not strongly normalizing. Finally show that no reduct on this cycle is a normal form. (Intermediate one-step reducts need not be syntactically ω.)

Optional route.

Dybjer’s rule sets and W-representation

The polynomial schema above and W-types both organize recursive data as a constructor label together with immediate subtrees. Turning that observation into an initial-algebra theorem requires more equality than the intensional core supplies. The distinction matters already for an encoded nullary constructor: remark 28.33 exhibited many terms α:0N that the core cannot identify with rec0. We therefore reconstruct the external theorem in a separate source calculus and state its equality assumptions before using them.

Convention 73.46 — The extensional source calculus

Write TD for extensional Martin-Löf type theory with dependent products and sums, empty and unit types N0,N1, binary sums and products, W-types, identity types, and a first Russell universe U0 closed under these formers. Thus a family over a closed type A may be given by a term B:AU0, and elimination into U0 is available.

Identity types have reflexivity and J, and the calculus validates equality reflection: Γp:IdA(a,b)Γab:AEqreflect. Identity proofs are unique. Function extensionality is available in the typed form funextf,g:(x:AIdB(x)(fx,gx))Idx:AB(x)(f,g). The usual uniqueness laws for N0, N1, sums, products, and W-recursion are also available. In particular, for maps y:N0C and y:N1C, respectively, there are terms ϵ0y:IdN0C(y,λ(x:N0).rec0x),ϵ1y:IdN1C(y,λ(x:N1).y). Functions out of a coproduct are equal when their two restrictions are equal. The W-equation and W-induction rule are those of definition 28.28, read in this extensional equality. Unadorned equality in this starred section denotes the judgmental equality obtained by reflection. Objects below are closed types of TD, and arrows are functions modulo that equality.

The two displayed uniqueness equations are not derived in the intensional theory of this chapter. They are among the extensional equalities used in Dybjer’s normalization of strictly positive operators. Naming TD prevents the following theorem from being silently transferred to the core theory T0.

Definition 73.47 — Dybjer's unindexed constructor schema

Fix a new type symbol P. Constructor i consists of a nonrecursive telescope Γi and finitely many recursive arity telescopes Δi1(γ),,Δiri(γ), none containing P. It has the form introi:γ:Γi(Δi1(γ)P)(Δiri(γ)P)P. Here a displayed arrow from a telescope abbreviates its iterated dependent product. Equality of the parameters and all recursive maps, after transport along the parameter equality, gives introi(γ,b1,,bri)=introi(γ,b1,,bri):P.

Given a family z:PM(z) type and steps di:γ:Γib1:Δi1(γ)Pbri:Δiri(γ)P(u1:Δi1(γ)M(b1u1))(uri:Δiri(γ)M(briuri))M(introi(γ,b1,,bri)), the schema supplies elimP(d1,,dn):z:PM(z) and the equations elimP(d,introi(γ,b1,,bri))=di(γ,b1,,bri,λu1.elimP(d,b1u1),,λuri.elimP(d,briuri)). This is an external dependent-elimination schema for one unindexed type in TD. It is not an indexed family schema, and no rule in the display is imported into the intensional core T0.

For a set U, an Aczel rule set on U is a set of pairs (u,v) with uU and vU, displayed u/v. A subset of U is closed under the rule set when it contains v whenever it contains every member of u. The rule set is deterministic when two rules with the same conclusion have the same premise set [Acz77].

Proposition 73.48 — Rule-set interpretation

Fix a signature of definition 73.47 whose parameter and arity telescopes have set interpretations. Choose an infinite regular cardinal κ such that every parameter and arity interpretation lies in Vκ and every interpreted arity has cardinality smaller than κ. Then the signature determines a deterministic Aczel rule set on Vκ. Its least closed subset interprets P and the dependent elimination equations.

Proof of Proposition 73.48 — Rule-set interpretation

Proof. Interpret a parameter tuple γ:Γi and recursive maps bk:Δik(γ)Vκ. Form the rule 1krirng(bk)i,γ,b1,,bri. The numerator denotes the set of premises, not one premise containing their union. The cardinal bound and regularity put every map bk and every premise set in Vκ; infinitude and closure under finite tupling put the finite tag and tuple forming the conclusion there as well. Hence these pairs form a rule set on Vκ. Its conclusion records i, γ, and all the bk, so equal conclusions determine equal premise sets: the rule set is deterministic.

Let I be the intersection of all subsets of Vκ closed under these rules. Closure makes every tagged conclusion an element of I when all values of its bk lie in I, which interprets introi. Conversely, the definition of I gives induction on rule generation.

Interpret M as a family of sets over I. For steps di, deterministic rule recursion defines a section at a tagged conclusion by applying di to γ, the maps bk, and the already-defined sections at every value bku. Rule induction proves that the section is defined on all of I; determinism makes the defining clause independent of a choice of generating rule, and induction gives uniqueness. Evaluating it at one rule conclusion is exactly the elimination equation in definition 73.47. ◻

The second result starts from operators rather than constructor lists.

Definition 73.49 — Strictly positive operators in the source calculus

For closed types K of TD, define Φ(X)::=XKΦ0(X)+Φ1(X)Φ0(X)×Φ1(X)KΦ0(X). The variable X is forbidden to the left of an arrow. Each expression acts on functions by identity, constant, sum, product, and postcomposition, respectively, and hence defines an endofunctor on the extensional category of closed types.

Lemma 73.50 — Bridge from constant-telescope signatures

Suppose a signature of definition 73.47 has finitely many constructors and, for each i,j, the recursive arity telescope has a closed total type Dij independent of the parameter γ. If Gi is the closed total type of the parameter telescope Γi, then its constructor endofunctor Φ(X):=i(Gi×j=1ri(DijX)) is generated by the grammar of definition 73.49.

Proof of Lemma 73.50 — Bridge from constant-telescope signatures

Proof. Each factor DijX is an exponential clause applied to the identity operator. Finite products combine the factors, with N1 for the empty product; product with the constant Gi adds the nonrecursive parameters. Finite sums then combine the constructor cases. These are exactly the five clauses of the operator grammar. ◻

When an arity Δij(γ) genuinely depends on γ, the displayed endofunctor contains a dependent family of exponentials and need not belong to the 1997 grammar. The rule-set interpretation above covers that dependent case; the W-representation theorem below applies to the constant-telescope fragment isolated by lemma 73.50 and to every other operator generated directly by the grammar.

Lemma 73.51 — Container normal form

For every operator Φ of definition 73.49, there are a closed type A, a family B:AU0, and a natural isomorphism νX:Φ(X)a:A(B(a)X). Writing mapA,B(r)((a,q)):=(a,rq), naturality means that, for every r:XY and x:Φ(X), νY(Φ(r)(x))=mapA,B(r)(νXx).

Proof of Lemma 73.51 — Container normal form

Proof. Induct on the grammar of Φ. For X, take A=N1 and B()=N1; evaluation at and constant abstraction are inverse. For a constant K, take A=K and B(k)=N0; the unique map N0X carries no data.

Suppose the induction hypothesis gives (Aj,Bj,νj) for Φj. For a sum take A=A0+A1 and use coproduct elimination into U0 to choose B by cases from B0 and B1. The two tagged summands give the required inverse maps. For a product take A=A0×A1,B(a0,a1)=B0(a0)+B1(a1). A function out of the displayed coproduct is the same as a pair of functions, one from each summand. Combining that equality with νX0×νX1 gives the product isomorphism.

For KΦ0(X), take A=KA0,B(f)=k:KB0(f(k)). Pointwise use of νX0 sends h:KΦ0(X) to (λk.pr1(νX0(hk)),λp.pr2(νX0(h(pr1(p))))(pr2(p))). The inverse sends (f,q) to λk.(νX0)1((fk,λb.q((k,b)))). Dependent beta and eta, function extensionality, and the induction-hypothesis inverse laws prove that the two composites are identities. Each construction commutes with postcomposition in X. For identity and constants this is a beta calculation; for sums it is the calculation in the selected summand; and for products it is componentwise. In the exponential case, for r:XY, the second component along either composite is (k,b)r(q((k,b))), while the first component is unchanged. These five calculations prove the displayed naturality equation. ◻

Theorem 73.52 — Dybjer's W-representation theorem

Every strictly positive endofunctor generated by definition 73.49 has an initial algebra in the extensional category of closed types of TD.

Proof of Theorem 73.52 — Dybjer's W-representation theorem

Proof. Choose A,B,ν from lemma 73.51, and put W:=Wa:AB(a). Its algebra structure is ιΦ:=λx.sup(pr1(νWx),pr2(νWx)):Φ(W)W. Let e:Φ(C)C be any algebra. W-recursion defines folde:WC using the step deabh:=e(νC1((a,h))),h:B(a)C. For x:Φ(W), write νWx=(a,b). W-computation and the naturality equation in lemma 73.51 give folde(ιΦx)=e(νC1((a,foldeb)))=e(Φ(folde)(x)), so folde is an algebra morphism.

For uniqueness, let h:WC be another algebra morphism. Apply W-induction to the motive w:WIdC(hw,foldew). At sup(a,b) its induction hypotheses are h(by)=folde(by) for every y:B(a). Function extensionality identifies hb with foldeb. Since sup(a,b)=ιΦ(νW1((a,b))), the algebra-morphism law for h, naturality of ν, and the induction hypotheses calculate h(sup(a,b))=e(νC1((a,hb)))=e(νC1((a,foldeb)))=folde(sup(a,b)). W-induction followed by function extensionality gives h=folde. Thus (W,ιΦ) is initial. ◻

Remark 73.53 — No transfer to the intensional core

The proof used extensional uniqueness in the constant, product, and exponential cases and again when proving uniqueness of the algebra morphism. Dybjer explicitly notes that the representation does not work directly in intensional type theory. Setoids provide an indirect interpretation [Hof95], but that construction is not a theorem that the encoded W-types of theorem 28.32 possess judgmental dependent eliminators. Neither lemma 73.51 nor theorem 73.52 is asserted for T0.

Exercise 73.24

★★☆ For Φ(X)=(K×X)×(L+X), carry out the container-normal-form construction. Give A and B, and write both directions of νX on elements.

Exercise 73.25

★★☆ Verify the naturality equation of lemma 73.51 for the product constructor Φ0(X)×Φ1(X). Then specialize the proved equation to r=folde and νW(x)=(a,b), obtaining νC(Φ(folde)(x))=(a,foldeb), and recalculate the algebra-morphism square as a check.

Exercise 73.26

★★★ Explain why beta alone does not make an arbitrary y:N0C definitionally equal to λ(x:N0).rec0(x), or an arbitrary y:N1C definitionally equal to λ(x:N1).y. Identify the two base cases of lemma 73.51 that need these equalities. Then state the pointwise empty- and unit-type uniqueness principles which, together with function extensionality, establish the two function equalities in TD.

Source boundary. The constructor telescope and rule-set reconstruction follow [Dyb91]; the dependent eliminator and its set interpretation follow [Dyb91]. The operator grammar, container normal form, initial-algebra theorem, and warning about the intensional setting follow [Dyb97]. The displayed TD signature records the extensional equalities used on those pages; it is not an attribution of the theorem to the intensional signature fixed earlier in this chapter. The name T0 in this book denotes that local intensional core; it is not Dybjer’s separately numbered base calculus T0 in the 1991 source.

Suggested first pass.

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

Exercise 73.27

★★☆ Derive the W-recursor from W-elimination by taking a constant motive C. Write the branch type and calculate the constructor equation. Then explain why the same specialization cannot recover an eliminator whose motive depends on the particular tree.

Exercise 73.28

★★★ Instantiate the polynomial-signature eliminator for binary trees with leaves labelled in A. Define leaf count and mirror, calculate both constructor cases, and prove that mirroring twice is judgmentally the identity by tree induction.

Exercise 73.29

★★★ Suppose, contrary to strict positivity, that one admitted a type D with constructor roll:(DD)D and a pattern equation unroll(roll(f))f. Define δ:DD by δx:=unrollxx and calculate the reduction of δ(roll(δ)). Explain which occurrence of D in the constructor argument is negative and which metatheoretic property the resulting loop refutes.

Exercise 73.30

★★★ Practical project.inductive-positivity-checker Implement in Agda or Kappa the strict-positivity traversal of definition 28.34. The maintained sign records whether the current position is positive. Accept natural numbers, lists, and W-trees; reject DD when that whole function type occurs as a constructor argument, that is, reject (DD)D and report the path to its negative occurrence. By contrast, accept DD as the whole type of a constructor with one recursive argument. Mutation test: preserving instead of reversing the sign at a Π-domain must make the negative example fail the acceptance suite. Before implementing the traversal, classify the natural-number, W-tree, and negative D signatures on paper and record the path and sign at every Π-domain. This finite trace is the checker’s specification.

Sources. Natural numbers and finite types occur in Martin-Löf’s early systems [ML98]; W-types and their tree reading are developed in [ML82, ML84]. Textbook treatments include [NPS90, NPS00, Tho91, Pal14]. The higher-type natural-number recursor is Gödel’s System T [GLT89]. The polynomial-signature viewpoint and the role of strict positivity are treated in [AG26] and [Har16].

Search the book

Type to search the local edition.