Lectures onType Theory
Chapter 166
Chapter 166Optional

Parametric Large Sizes and Realizability Consistency

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

A size index bounds the depth of a construction, and a construction of unbounded depth needs a size that bounds every other. The first move to try is to adjoin a largest size with . The following proposition shows what that costs.

Proposition 166.1 — A largest size destroys well-founded induction

Suppose a type Size carries a relation <, a term :Size with a proof p:<, and, for every family A over Size, a fixed-point operator taking f:i.((j<i.Aj)Ai) to fixf:i.Ai. Then the empty type is inhabited.

Proof of Proposition 166.1 — A largest size destroys well-founded induction

Proof. Take A:=λi.0 and f:=λi.λg.gp. For this to type-check we need p:<i, which the hypothesis supplies only at i:=; so restrict attention to that instance. There g:(j<.0) and gp:0, so f:(j<.0)0. The fixed point at is a term x:0 satisfying x=f(λj<.x), and its mere existence inhabits 0. ◻

The proof isolates the offending datum: the proof p:<, which makes < non-well-founded exactly at . The repair developed here does not add a largest size at all. It makes Size a large type, adds impredicative quantifiers over it whose elimination cannot inspect the size, and adds axioms saying that those quantifiers commute with the small type formers. Unbounded constructions are then obtained by quantifying over sizes rather than by naming a largest one.

The theory

Convention 166.2 — Base theory

Work in intensional Martin-Löf type theory with 0, 1, 2, dependent sums and products with definitional η, propositional identity types, and a Tarski universe U with decoder El() containing codes for the base types and closed under x:AB, x:AB and IdA(a,a) when A and B have codes. A type with a code in U is small; a type without one is large. Function extensionality is assumed as an axiom: the canonical map Id(f,g)x:AId(fx,gx) is an equivalence, with inverse funext. Here f:AB means that f has a quasi-inverse together with the coherence datum that makes “f is an equivalence” a mere proposition. A type is contractible when it has exactly one element up to the identity type.

Definition 166.3 — Sizes and their order

Adjoin a large type Size with the rules

ΓSize type
Size-F
Γ0:Size
Size-Z
Γi:Size
Γ⊢↑i:Size
Size-S
Γi:SizeΓj:Size
Γij type
Le-F
Γi:Size
Γle0i:0i
Le-Z
Γi:Size
Γlei:i≤↑i
Le-S
Γi:Size
Γleri:ii
Le-Refl
Γp:ijΓq:jk
Γletpq:ik
Le-Trans

The type ij is small and is a mere proposition: any two of its elements are propositionally equal. Write i<j for ij.

There is no rule giving a size and no rule ii. Proposition 166.1 is what the absence buys.

Definition 166.4 — Parametric quantifiers

For Γ,i:SizeA(i):U adjoin

Γ,i:SizeA(i):U
Γi.A(i):U
Ex-F
Γ,i:SizeA(i):U
Γi.A(i):U
All-F
Γs:SizeΓa:A(s)
Γs,a:i.A(i)
Ex-I
Γ,z:i.A(i)P(z):UΓ,i:Size,x:A(i)p(i,x):P(i,x)
Γ,z:i.A(i)ind(z,p):P(z)
Ex-E
Γ,i:Sizea(i):A(i)
Γλ.i.a(i):i.A(i)
All-I
Γf:i.A(i)Γs:Size
Γfs:A(s)
All-E

with the computation rules ind(s,a,p)p(s,a), (λ.i.a(i))sa(s) and λ.i.fif. Both quantifiers are impredicative: the quantified type is small although Size is large. Write j<i.A(j) for j.(j<i)A(j) and j<i.A(j) for j.((j<i)×A(j)).

The elimination rule Ex-E is where the parametricity lives. Its motive P must be small, and Size is not; hence there is no first projection out of i.A(i), and the size stored in a pair is inaccessible. For the rules are those of a product, and indeed i:SizeA(i)i.A(i) by the two evident maps. The dual equivalence i.A(i)i:SizeA(i) is not available and is false in the model of section 166.5.

Definition 166.5 — Well-founded induction on sizes

Γ,i:SizeA(i) typeΓf:i.((j<i.A(j))A(i))
Γfixf:i.A(i)
Fix
Γf:i.((j<i.A(j))A(i))
Γfixβf:i. Id(fixfi,fi(λj<i.fixfj))
Fix-β

The unfolding is a propositional equality. A definitional one is validated by the model of section 166.5, which is extensional, but it would unfold indefinitely and so is not adopted in the theory.

Lemma 166.6 — Uniqueness of fixed points

For every f:i.((j<i.A(j))A(i)) the type h:i.A(i)i. Id(hi,fi(λj<i.hj)) is contractible.

Proof of Lemma 166.6 — Uniqueness of fixed points

Proof. The pair (fixf,fixβf) inhabits the type. Let (g,gβ) be another inhabitant. It suffices to give a pointwise identity e:i. Id(fixfi,gi) and an identity eβ transporting fixβf to gβ along funext(e).

For e, apply Fix to λi.λe.pi,e, where pi,e is the concatenation fixfi=fixβfifi(λj<i.fixfj)=apfi(funext(λj<i.ej))fi(λj<i.gj)=gβigi. Here e:j<i. Id(fixfj,gj) is the argument supplied by Fix at i.

For eβ, it suffices that the square whose two horizontal sides are fixβfi and gβi and whose two vertical sides are ei and apfi(funext(λj<i.ej)) commutes. That is exactly fixβ applied to the term λi.λe.pi,e just constructed. ◻

The commuting equivalences

Proposition 166.7 — Two equivalences that are already derivable

For a small type A and x:A,i:SizeB(x,i):U, x:Ai.B(x,i)i.x:AB(x,i),x:Ai.B(x,i)i.x:AB(x,i).

Proof of Proposition 166.7 — Two equivalences that are already derivable

Proof. Both are argument exchange. For the first, send h to λ.i.λx.hxi and k to λx.λ.i.kix; the two round trips are the β- and η-rules of definition 166.4 together with those of Π. For the second, send (x,s,b) to s,(x,b) and back; both directions are definable by Ex-E, since the motive in each case is small, and the round trips are the computation rule of Ex-E together with the η-rule for Σ. ◻

Definition 166.8 — The four commuting axioms

For small A, x:A,i:SizeB(x,i):U and i:SizeC(i):U, assume that the canonical maps below are equivalences: x:Ai.B(x,i)i.x:Aj<i.B(x,j),ExPix:Ai.B(x,i)i.x:AB(x,i),AllSgi.C(i)i.j<i.C(j),ExLti.C(i)i.j<i.C(j),AllLt The canonical map is the right-to-left one for and the left-to-right one for ; each is definable from definition 166.4 alone, and the axiom asserts that it has a quasi-inverse.

Ex-Pi is not an exact commutation. Passing from right to left needs a size bounding every size in the range of the dependent function, and no monotonicity of B in i is available; replacing B(x,j) by j<i.B(x,j) restores monotonicity. The axiom therefore asserts, in disguise, that limits of families of sizes indexed by a small type exist — without adding a limit operator to the syntax. Section 166.5 interprets Size by an ordinal large enough for that assertion to hold.

Proposition 166.9 — Quantification over a size-free type is trivial

For a small type A with iFV(A),  i.AA and i.AA.

Proof of Proposition 166.9 — Quantification over a size-free type is trivial

Proof. The case A:=1. For , i.1=0B1i.(0j<i.0)=ExPi0i.0=0B11, the middle step reading Ex-Pi from right to left with A:=0. For , i.11 by function extensionality, since both sides are contractible.

The general case. Using x:A1A and proposition 166.7, i.A=Σ1i.x:A1=proposition166.7x:Ai.1=firstcasex:A1=Σ1A, and the same chain with in place of , using All-Sg at the second step. ◻

Exercise 166.1

★★☆ Show that the left-to-right map of Ex-Pi is definable from definition 166.4 alone, and that the right-to-left map is not, by identifying the datum it would need and the rule of definition 166.4 that withholds it. Then show that the variant x:Ai.B(x,i)i.x:AB(x,i) with j<i deleted is false whenever B is not monotone in i, by taking A:=2 and a B with B(tt,i) inhabited exactly at even i and B(ff,i) inhabited exactly at odd i.

Initial algebras

Definition 166.10 — Functors and size-indexed functors

An endofunctor on small types is a pair of a map F:UU and, for all A,B:U, a map FA,B:(AB)(FAFB). A size-indexed small type is a map A:SizeU, and a morphism AB of such is a term f:i.(Ai)(Bi). For an endofunctor F define F[]Ai:=F(j<i.Aj),F[]Ai:=F(j<i.Aj), with the evident actions on morphisms.

Definition 166.11 — Algebras

An F-algebra is a pair (A,kA) with A:U and kA:FAA; a morphism (A,kA)(B,kB) is a pair of h:AB and an identity sh:Id(hkA,kBFh). An algebra (μF,in) is initial when for every algebra (A,kA) the type h:μFAId(hin,kAFh) is contractible. A size-indexed F-algebra is an algebra for F[].

Lemma 166.12 — Size-indexed initial algebra

Let F be an endofunctor on small types. The size-indexed functor F[] has an initial algebra (μF,in) with μFi:=fix(λi.λX.F(j<i.Xj))i.

Proof of Lemma 166.12 — Size-indexed initial algebra

Proof. The carrier is a fixed point. By Fix-β, μFi=def.fix(λi.λX.F(j<i.Xj))i=FixβF(j<i.fix()j)=def.F[](μF)i.

The structure map. Transporting along the displayed identity pointwise in i gives in:F[](μF)μF.

Initiality. Given a size-indexed algebra (A,kA), define foldAkA by Fix with the step that sends i and a family of maps at smaller sizes to kAiF[](that family)i, precomposed with the transport above. That it is an algebra morphism is the β-identity of Fix-β; that it is unique is lemma 166.6 together with function extensionality, since a competing morphism is a competing solution of the same unfolding equation. ◻

Lemma 166.13 — Constant size-indexed algebras

Every F-algebra (A,kA) induces a size-indexed F-algebra (TA,kTA) with TA:=λi.A, and T is functorial.

Proof of Lemma 166.13 — Constant size-indexed algebras

Proof. Since i does not occur in A, the term extract:A:Ui. (j<i.TAj)TAi,extractAij,a:=a is well defined by Ex-E, because its motive TAiA is small and does not mention the bound size. Set kTAi:=kAF(extractAi), using F(extractAi):F[](TA)iFA. For an algebra map f, put Tf:=λi.f; it is a morphism because extractA is natural in A. ◻

Definition 166.14 — Weak commutation with the existential

An endofunctor F on small types weakly commutes with the existential when for every A:SizeU the canonical map canA:i.F[]AiF(i.Ai),canAi,a:=F(φAi)a, is an equivalence, where φA:i. (j<i.Aj)j.Aj is φAij,a:=j,a.

Proposition 166.15 — Quantifying an algebra

Let F weakly commute with the existential. Every size-indexed F-algebra (A,kA) gives an F-algebra (i.Ai, kA) with kA:=(kA)canA1, where fi,a:=i,fia; and this operation is functorial.

Proof of Proposition 166.15 — Quantifying an algebra

Proof. The map f is definable by Ex-E with the small motive i.Bi. Composing it with the quasi-inverse supplied by definition 166.14 gives kA of the stated type. Functoriality follows from naturality of canA in A, which holds because φA is natural in A and F is a functor. ◻

Theorem 166.16 — Initial algebras from large sizes

Let F be an endofunctor on small types that weakly commutes with the existential. Then F has an initial algebra with carrier μF:=i.(μF)i and structure map in:=(in)canμF1.

Proof of Theorem 166.16 — Initial algebras from large sizes

Proof. Proof idea. The functor of proposition 166.15 is left adjoint to the functor T of lemma 166.13, and a left adjoint preserves initial objects; the initial size-indexed algebra of lemma 166.12 therefore maps to an initial F-algebra.

Spelling out the adjunction: for A:SizeU and B:U, the currying equivalence identifies morphisms ATB of size-indexed types with maps i.AiB, because a morphism ATB is a term of i.(Ai)B and Ex-E turns such a term into a map out of i.Ai, with Ex-I giving the converse and the computation rule giving the two round trips. The identification carries algebra morphisms to algebra morphisms, since kTB was defined through extract and kA through canA1, which are the two components of the same currying.

Hence giving an algebra morphism (μF,in)(B,kB) is the same as giving a size-indexed algebra morphism (μF,in)(TB,kTB), and the latter type is contractible by lemma 166.12. ◻

Proposition 166.17 — Polynomial functors weakly commute

Let A:U and B:AU, and let PA,BX:=a:A(B(a)X). Then PA,B weakly commutes with the existential.

Proof of Proposition 166.17 — Polynomial functors weakly commute

Proof. Compute, using that i is free in neither A nor B(a): i.PA,B[]Xi=def.i.a:A(B(a)j<i.Xj)=proposition166.7a:Ai.(B(a)j<i.Xj)=ExPia:A(B(a)i.j<i.Xj)=ExLta:A(B(a)i.Xi)=def.PA,B(i.Xi). The composite is the canonical map of definition 166.14, so that map is an equivalence. ◻

Proposition 166.17 covers infinitely branching B, and that is the improvement the large size buys: with Size interpreted by the natural numbers, Ex-Pi is available only for finite A, and the displayed chain breaks at its third step.

Corollary 166.18 — W-types

For every A:U and B:AU, the functor PA,B has an initial algebra, namely i.(μPA,B)i.

Proof of Corollary 166.18 — W-types

Final coalgebras

Definition 166.19 — Coalgebras and weak commutation with the universal

An F-coalgebra is a pair (A,cA) with cA:AFA, and (νF,out) is terminal when for every coalgebra the type of coalgebra morphisms into it is contractible. A size-indexed F-coalgebra is a coalgebra for F[]. The functor F weakly commutes with the universal when for every A:SizeU the canonical map F(i.Ai)i.F[]Ai is an equivalence.

Theorem 166.20 — Final coalgebras from large sizes

Let F weakly commute with the universal. Then F has a terminal coalgebra with carrier νF:=i.(νF)i, where νFi:=fix(λi.λX.F(j<i.Xj))i carries the terminal F[]-coalgebra. Every polynomial functor PA,B weakly commutes with the universal.

Proof of Theorem 166.20 — Final coalgebras from large sizes

Proof. Each step is the dual of the corresponding step in lemma 166.12proposition 166.17, with the following substitutions: fix is applied to λi.λX.F(j<i.Xj) in place of the existential body, giving νFi=F[](νF)i by Fix-β; the functor T of lemma 166.13 becomes the inclusion of coalgebras into size-indexed coalgebras, with extract replaced by the map i. TAi(j<i.TAj) that ignores the bound; the functor of proposition 166.15 becomes , right adjoint rather than left; and the chain of proposition 166.17 becomes PA,B(i.Xi)=def.a:A(B(a)i.Xi)=proposition166.7a:Ai.(B(a)Xi)=AllSg, AllLti.PA,B[]Xi. A right adjoint preserves terminal objects, which replaces the use of preservation of initial objects in theorem 166.16. Laarakker, Otten and van den Berg state the dual development and refer its details to the full version of their paper; the steps just listed are the ones that differ from the initial case, and no step of section 166.1section 166.3 is reused outside its stated hypotheses. ◻

Example 166.21 — One inductive type, computed

Let FX:=1+X, the polynomial functor PA,B with A:=2, B(tt):=0 and B(ff):=1. Compute the approximations by lemma 166.12: μF0=FixβF(j<0.μFj)=j<0emptyF(0)1,μF(0)=FixβF(j<↑0.μFj)F(1)1+1,μF(↑↑0)F(1+1)1+1+1. So the nth approximation has n+1 elements: it is the type of numerals below n. At the outer quantifier, theorem 166.16 gives μF=i.μFi, and Ex-Lt is what makes this a fixed point rather than a strict colimit: a numeral carries a size, and no elimination can read it.

The limit behaviour is where the large size is used. A term of μF built from a family of terms indexed by a small type — for instance the image of a map AμF under Ex-Pi — needs a size above every size appearing in the family. In the model of section 166.5 that size exists because a countable supremum of countable ordinals is countable.

Example 166.22 — One coinductive type, computed

Let GX:=A×X for a small A, the polynomial functor with index A and constant branching 1. By theorem 166.20, νG0A×1A,νG(0)A×A,νG(↑↑0)A×A×A, since j<0.Xj is contractible and each successor adds one factor; and νG=i.νGi is the type of streams. Reading a component of a stream is instantiating the universal at a size, and All-Lt is what makes the reading independent of which size is chosen.

Exercise 166.2

★★☆ Let HX:=1+X as in example 166.21.

  1. Compute νHi at 0, 0 and ↑↑0, and identify the resulting type of νH.

  2. Give the terms zero and succ for νH, and state which of the four axioms of definition 166.8 each uses.

  3. Show that μH and νH are not equivalent, by exhibiting an element of one that has no counterpart in the other, and name the quantifier responsible.

The realizability model

Nothing so far shows that the theory of definition 166.3definition 166.8 has no proof of 0. The four axioms of definition 166.8 are strong, and proposition 166.1 shows that a nearby extension is inconsistent. This section builds a model.

Definition 166.23 — Assemblies

Let N enumerate the partial recursive functions φn, and define a partial operation mn:=φm(n), writing mn when it is defined. An assembly is a pair (X,X) of a set X and a relation XN×X such that every xX has some n with nXx; such an n realizes x. A morphism (X,X)(Y,Y) is a function f for which some eN satisfies n,x. nXx implies en and enYf(x); we say e tracks f. Write Asm for the resulting category, and X:=(X,N×X) for the assembly with the full realizability relation.

The construction is what carries parametricity into the model. An assembly X gives every element every realizer, so a tracked map out of X cannot distinguish elements by their realizers; it must treat them uniformly.

Definition 166.24 — Modest sets and partial equivalence relations

An assembly (X,X) is modest when each n realizes at most one element. A partial equivalence relation is a symmetric transitive relation on N. Write Mod and PER for the two categories.

Lemma 166.25 — Modest sets are partial equivalence relations

PER and Mod are equivalent, by sending a modest set (X,X) to the relation n1Xn2 defined as xX. (n1Xx)(n2Xx).

Proof of Lemma 166.25 — Modest sets are partial equivalence relations

Proof. The displayed relation is symmetric and transitive by construction, and modesty makes the witness x unique, so the equivalence classes of X correspond to the elements of X that have a realizer, which is all of them. Conversely a partial equivalence relation gives the modest set whose carrier is the set of -classes with n[n]. A morphism of modest sets is tracked, hence induces a map of classes, and conversely. ◻

Definition 166.26 — The model

Interpret the theory in the category with families whose contexts are assemblies, whose types over Γ are Γ-indexed families (Aγ)γΓ of assemblies, and whose terms are dependent functions a tracked by some e: nΓγ implies enAγa(γ). Substitution is precomposition and context extension is dependent pairing. Interpret U:=PER,Size:=ω1,El():=the inclusion of partial equivalence relations, where ω1 is the set of countable ordinals. Interpret ij by the terminal assembly when the ordinals are so ordered and by the empty assembly otherwise; interpret i.A(i) by the dependent product over ω1; and interpret i.A(i) by the modest reflection of the semantic Σ-type, using lemma 166.27.

Lemma 166.27 — Modest reflection

The inclusion ModAsm has a left adjoint M, with M(A):=(A/M,M(A)) where M is the least equivalence relation identifying a1 and a2 whenever some n realizes both, and nM(A)[a] when n realizes some member of the class.

Proof of Lemma 166.27 — Modest reflection

Proof. M(A) is modest: if n realizes [a1] and [a2] then it realizes members a1Ma1 and a2Ma2, so a1Ma2 by the generating clause, and the classes coincide. The unit AM(A) sends a to [a] and is tracked by the identity. For the universal property, a morphism AI(B) into a modest set identifies any two elements sharing a realizer, hence factors through M, and the factorization is tracked by the same realizer. ◻

Proof of Theorem 166.28 — Validation of the added rules

Proof. We treat the five groups separately.

Sizes and their order. Size=ω1 has the required terms: 0 and the ordinal successor. The order is interpreted by a subterminal assembly, so ij is a mere proposition, and the four constructors of definition 166.3 are the corresponding facts about ordinals. There is no interpretation of a largest size: ω1 has no greatest element, so the hypothesis of proposition 166.1 is not met.

The universal quantifier. Assemblies support impredicative dependent products: a tracked dependent function out of ω1 into a family of modest sets is itself tracked by a single realizer, so the product is modest and hence small. This is the clause that makes impredicative.

The existential quantifier. By lemma 166.27, lemma 166.25, the modest reflection of the semantic Σ-type is a partial equivalence relation, hence an element of U. Its introduction is the unit of the reflection; its elimination is the universal property, whose motive must be modest, which is exactly the smallness side condition of Ex-E. Since the reflection quotients by shared realizers and every element of ω1 has every realizer, two pairs with the same second component and different sizes are identified, which is why no first projection exists.

The fixed-point operator. Given f, define the underlying function of fixf by well-founded induction on ω1; that definition satisfies the unfolding identity of Fix-β on the nose, which is a propositional identity in the theory because the model is extensional. For fixf to be a morphism it must be tracked, and a partial combinatory algebra contains a term fix with fixe and fixeae(fixe)a; that term tracks it, uniformly in the ordinal, because the ordinal carries no realizer information.

The four axioms. All-Sg and All-Lt hold because is a product over ω1 and makes every map out of it uniform, so the product commutes with Σ and the bound may be weakened. Ex-Lt holds because the reflection identifies a pair with any pair over a larger size. Ex-Pi is the clause that fixes the choice of ω1: reading it from left to right, a dependent function from a small type A into i.B(a,i) assigns to each a a size, and a size bounding all of them is required. A small type is a partial equivalence relation on N, so it has at most countably many classes; a countable supremum of countable ordinals is countable, hence lies in ω1. ◻

Theorem 166.29 — Consistency

There is no closed term of type 0 in the theory of convention 166.2definition 166.8.

Proof of Theorem 166.29 — Consistency

Proof. By theorem 166.28 every closed term of a closed type denotes a global element of the interpretation of that type in definition 166.26. The empty type is interpreted by the assembly with empty carrier, which has no global element. Hence no closed term of type 0 exists. ◻

Remark 166.30 — Where the choice of ω _1 is forced

Interpreting Size by N instead of ω1 still validates definition 166.3definition 166.5 and three of the four axioms. It fails for Ex-Pi at an infinite A: a function Ai.B may assign unboundedly large natural numbers, and no natural number bounds them. Restricting Ex-Pi to finite A restores soundness over N, and then proposition 166.17 holds only for finitely branching B, so corollary 166.18 covers only finitely branching W-types. The large size is exactly what removes that restriction.

Comparison and boundary

Remark 166.31 — This chapter and the sized copattern calculus

Chapter 165 also indexes types by sizes, and the two theories share no rule. Comparing them requires both signatures to be in view.

  1. There, sizes are type-level expressions i+n and +n with a syntactic order, erasable before execution. Here, Size is a type of the theory with 0, and a proof-irrelevant order, and it is large.

  2. There, a largest size exists and is essential: it is the stationary point of definition 165.25 and lemma 165.10 depends on =. Here, no largest size exists, and proposition 166.1 says why one may not be added to this theory. The two are compatible because there is not the index of a well-founded induction principle over an internal type of sizes; it is an annotation whose meaning is fixed by the semantic stationarity of definition 165.25.

  3. There, the theorem is strong normalization of typed programs. Here, the theorem is consistency of a type theory. Neither implies the other, and the shared notation μa, νa names different objects: a syntactic type former there, a fixed point of a size-indexed functor here.

No operational semantics. Definition 166.5 gives fix a propositional unfolding, not a reduction rule. Nothing above defines a reduction relation on the terms of definition 166.3definition 166.8, proves subject reduction, or normalizes anything; the four axioms of definition 166.8 are asserted equivalences with no computational content.

No decision procedure. Because the axioms are inhabitants of equivalence types rather than rules, type checking in the theory is not reduced to any decidable relation here, and no size-inference algorithm is given.

No program checker. Theorem 166.16, Theorem 166.20 construct initial algebras and terminal coalgebras as types. They do not certify that a particular recursive definition terminates: the definition must be written as an algebra morphism, and producing one is the user’s task.

Suggested first pass.

Problems exercise 166.3, exercise 166.4, and exercise 166.6 form the suggested first pass. None of these problems is a prerequisite for a later chapter.

Exercise 166.3

★★★ Verify the four axioms of definition 166.8 in the model of definition 166.26, one at a time.

  1. For All-Sg and All-Lt, write the two semantic maps and check that each is tracked, saying where is used.

  2. For Ex-Lt, compute the two modest reflections and exhibit the bijection between their classes.

  3. For Ex-Pi, give the semantic left-to-right map explicitly, state the supremum it forms, and check that it lies in ω1. Then show that the same map fails to land in N when Size is interpreted by N and A is infinite, exhibiting a concrete unbounded family.

Exercise 166.4

★★★ Theorem 166.20 was proved by listing the substitutions that turn the initial construction into the terminal one. Carry them out.

  1. State and prove the dual of lemma 166.12: the size-indexed functor F[] has a terminal coalgebra with carrier νF, displaying the use of lemma 166.6.

  2. State and prove the duals of lemma 166.13 and proposition 166.15, giving the replacement for extract and saying why it needs no elimination rule.

  3. Assemble the adjunction and conclude theorem 166.20, marking the step at which right adjoints preserving terminal objects replaces left adjoints preserving initial ones.

Exercise 166.5

★★☆ Proposition 166.1 assumed a proof of <.

  1. Show that the weaker assumption already yields <, using definition 166.3.

  2. Show that adding a size with i for every i, but without , does not yield the contradiction, and say which step of the proof of proposition 166.1 fails.

  3. Determine whether such an can be interpreted in definition 166.26, and say what it would have to be in ω1.

Exercise 166.6

★★★ Practical project.large-size-approximation-calculator Implement, in Agda, a finite calculator for the approximation sequences of lemma 166.12, theorem 166.20 and use it to reproduce the computations of this chapter.

Calculus to implement. Represent a polynomial functor PA,B by a finite type A with a branching function B into finite types, and represent an ordinal below a fixed bound by a well-founded tree so that successors and countable suprema of the represented ordinals are again represented. Implement μPA,B and νPA,B as functions from a represented ordinal to a finite type, following the unfolding of Fix-β, and implement the four canonical maps of definition 166.8 at the finite instances where they are computable.

Invariant. The approximation at a successor must be computed only from the approximations at strictly smaller ordinals, and the program must check that invariant at every call, reporting a failure otherwise; this is the executable form of the well-foundedness that proposition 166.1 shows to be indispensable. The representation of a supremum must record the family it was taken over, so that Ex-Pi can be checked on it.

Concrete result. For a functor and an ordinal, the cardinality and an enumeration of the approximation; and for a family indexed by a finite type, the supremum computed by the Ex-Pi map.

Acceptance test. For FX=1+X the enumeration must reproduce example 166.21: cardinalities 1,2,3 at 0,0,↑↑0, and n+1 at the nth successor. For GX=2×X the enumeration must reproduce example 166.22: cardinalities 2,4,8. For the conatural functor of exercise 166.2 the two sequences must differ at the limit, and the program must print the element of the terminal coalgebra that has no counterpart in the initial algebra. Feeding a family indexed by a two-element type must produce the maximum of the two sizes, and feeding a family indexed by an n-element type must produce their supremum; the program must reject an attempt to take a supremum over a type it cannot enumerate, which is the finite stand-in for the countability side condition of theorem 166.28. Produce three mutations that still typecheck — compute the successor approximation from the approximation at the same ordinal, drop the j<i from the initial unfolding, and take the maximum instead of the supremum — and confirm that each makes a named case disagree. State explicitly that the program illustrates lemma 166.12, theorem 166.20 at finitely many finite instances and proves neither, and that it says nothing about theorem 166.29, whose content is a model and not a computation.

Search the book

Type to search the local edition.