Lectures onType Theory
Chapter 161
Chapter 161Optional

Synthetic Phase Distinctions and Synthetic Tait Computability

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

A dependent theory with Booleans and dependent products has a question attached to it that its rules do not answer: is every closed term of Boolean type judgmentally equal to one of the two constructors? Tait’s method answers such questions by defining, for each type, a predicate on terms of that type, and then proving that every term satisfies the predicate of its type. The definition is by recursion on the type, and that is where the difficulty lies in a dependent theory, because the type of the result of an application is computed from the argument.

This chapter carries out that argument once, in a metalanguage where the recursion, the contexts, and the naturality conditions are all performed by a single modality. The object to be built is a glue type: a type former that fastens a semantic predicate onto a syntactic type so tightly that the composite is judgmentally the syntactic type again in one phase, and is the predicate in the other. Every construction below exists to make that former available and to use it.

The object theory as a signature

Definition 161.1 — The Boolean–product signature

Let Σ be the following list of constants, each declared in a metalanguage with dependent products and a universe U. A signature in this sense is a finite list of typed constants together with a finite list of equations between terms built from them; the object theory is the theory freely generated by that list. tp:U,tm:tpU,bool:tp,true, false:tm(bool),if:(C:tm(bool)tp)(b:tm(bool)):tm(Ctrue)tm(Cfalse)tm(Cb),pi:(A:tp)(tm(A)tp)tp,lam:((x:tm(A))tm(Bx))tm(piAB),app:tm(piAB)(x:tm(A))tm(Bx). The equations are ifβ1:ifCtruetf=t,ifβ2:ifCfalsetf=f,piβ:app(lamf)a=fa,piη:lam(appe)=e.

Three features of this presentation are used throughout and are worth naming before any calculation. Binding is carried by the metalanguage: the second argument of pi is a function tm(A)tp, so there is no separate account of variables, capture, or substitution for the object theory. Typing is carried by indexing: tm is a family over tp, so an ill-typed object term cannot be written down. Equality is carried by equations between constants, so the object theory’s judgmental equality is the least congruence generated by the four displayed equations.

The motive C of if is an arbitrary function tm(bool)tp of the metalanguage. This is what makes the eliminator dependent, and it is the exact feature that the next section will show to obstruct a recursion on type structure.

Example 161.2 — A closed Boolean term that is neither constructor

Write neg:=lam(λx.if(λ_.bool)xfalsetrue) and b0:=appnegtrue. Then b0 is a closed term of tm(bool) whose head constant is app, not true or false. Its value is computed by the two equations: b0=piβif(λ_.bool)truefalsetrue=ifβ1false.

Definition 161.3 — Canonicity for Σ

The signature Σ satisfies canonicity when every closed term b of type tm(bool) — that is, every global element of tm(bool) in the theory freely generated by Σ — satisfies b=true or b=false.

Example 161.2 verifies one instance by hand. A proof must cover every closed term at once, and every closed term arises by applying the constants of Σ to arguments that are themselves not closed: the body of a lam has a free variable, and the motive of an if is a function.

What the external computability predicate must carry

Tait’s construction assigns to each type a predicate on its terms. For the signature Σ the intended clauses are the following two, in which CA denotes a predicate on closed terms of type tm(A): Cbool(b)iffb=true  or  b=false,CpiAB(e)ifffor every closed a with CA(a), CBa(appea). Clause (161.2) refers to CBa. In definition 161.1 the second argument of pi is a function B:tm(A)tp, so Ba is the value of a function at an argument. It is therefore not a subterm of piAB, and the pair of clauses is not a definition by structural recursion on the first index.

The failure is not repaired by choosing a different measure. Take A:=bool and let B be any function tm(bool)tp of the metalanguage. Nothing in Σ constrains the values of B beyond their type, so the family of types {Ba} appearing in clause (161.2) is not generated by a smaller instance of the same grammar. In this presentation tp is a constant of the signature and carries no induction principle at all: there is no case analysis on a type, and hence no recursion on one.

Remark 161.4 — Where the induction has gone

A recursion is still available, but not on types: it is the recursion that constructs the theory freely generated by Σ, and it lives outside the theory. Section 161.8 performs exactly that outside step once, for all signatures at once, by asking for a structure-preserving functor out of the syntactic category. Everything between here and there is carried out inside a metalanguage, where no such recursion is needed.

A second obligation appears as soon as open terms are admitted, and they must be admitted, because clause (161.2) is used to type the body of a lam. Indexing the predicate by a context Δ turns each clause into a family CAΔ, and each family must be stable under renaming: for every renaming ρ from Δ to Δ, CAΔ(a)  implies  CA[ρ]Δ(a[ρ]). Obligation (161.3) is discharged separately for every clause of the definition, and again for every lemma proved about the clauses. It is bookkeeping in the exact sense that it never selects between two mathematical possibilities; it only records that a construction was uniform in the context.

Both obligations are removed by the same change of ambient setting. Work in a category whose objects already are context-indexed families and whose maps already are the natural ones, so that (161.3) holds by construction; and describe the predicate not by recursion on syntax but as a type in the internal language of that category, so that the missing recursion in (161.2) is never attempted. The rest of the chapter constructs that category and that internal language.

The gluing category and its two phases

Definition 161.5 — Syntactic category, presheaves, points

Let T be the category freely generated by Σ in the sense of definition 161.1: its objects are the closed types built from the constants, its maps are equivalence classes of terms modulo the four equations, and it has finite limits and dependent products. Write y:T[Top,Set] for the Yoneda embedding and pt:[Top,Set]Set,pt(X):=Nat(y(1T),X) for the global-sections functor, which sends a presheaf to the set of its maps out of the presheaf represented by the terminal object. Since Yoneda preserves limits, y(1T) is the terminal presheaf, so pt(X) is the set X(1T) of elements of X at the empty context.

Contexts of the object theory index the presheaves, and a map of presheaves is a family of functions commuting with reindexing. Obligation (161.3) is the commutation requirement, and it is part of what it means to be a map in [Top,Set].

Definition 161.6 — Artin gluing

The gluing category G has as objects the triples (S,X,f) with S a set, X a presheaf on T, and f:Spt(X) a function; a map (S,X,f)(S,X,f) is a pair (h,t) with h:SS and t:XX such that pt(t)f=fh. The syntactic projection is π:G[Top,Set],π(S,X,f):=X,π(h,t):=t.

An object (S,y(B),f) is to be read as a proof-relevant predicate on the closed terms of type B: the set S is the collection of witnesses and f records, for each witness, the term it is a witness for. The set Sb:=f1(b) is the set of witnesses at the closed term b.

Example 161.7 — The Boolean predicate as an object of G

Let B:=bool and consider BOOLG:=({0,1}, y(bool), f),f(0)=y(false),f(1)=y(true). Its witness set at a closed term b is a singleton when b=true or b=false and is empty otherwise. A map 1GBOOLG whose presheaf component is y(b) therefore exists exactly when b is one of the two constructors.

Example 161.7 already contains the shape of the canonicity argument: if every closed term b receives such a map, canonicity follows. The work is to produce those maps uniformly, and that is done by interpreting the whole signature in G so that the interpretation of a term is a map whose presheaf component is that very term.

Definition 161.8 — Phase-separated interpretation

An interpretation of Σ in G is phase separated when it assigns to each constant an element of G whose image under π is the corresponding presheaf built from y, and to each equation of Σ an equation in G. In this situation π maps the interpretation of a term back to that term.

The condition “π of the semantic object is the syntactic object” is a strict equation between objects, not an isomorphism. Keeping it strict is the single hardest requirement in the construction, and section 161.5 is devoted to the axiom that makes it available.

The synthetic phase distinction

The internal language of G is a dependent type theory with extensional equality types, dependent sums and products, coproducts, quotients, and a hierarchy of universes. All constructions below are written in that language; what makes them into gluing constructions is one additional constant.

Convention 161.9 — The ambient metalanguage

Throughout section 161.4section 161.7 we reason in an extensional dependent type theory with a cumulative hierarchy of universes U0,U1,, in which propositional and judgmental equality coincide, so that an inhabitant of a=b licenses the replacement of a by b in any type. We write U for an unspecified member of the hierarchy. A type P is a proposition when any two of its elements are equal.

Definition 161.10 — The syntactic phase

Fix a proposition syn:U. The open modality and closed modality associated with syn are #A:=synA,A:=synA, where the join synA is the quotient inductive type with constructors η:AA,:synA,law:(a:A)(z:syn)ηa=z. Their units are η#:=λa.λz.a:A#A and η:AA. The symbol # marks the syntactic part throughout, and the filled dot marks the semantic part.

The three constructors say exactly this: A contains a copy of A, it contains a point supplied by the syntactic phase, and under the syntactic phase these two are identified. The third clause is the whole content of the definition and is used in every proof below.

Lemma 161.11 — The modalities are idempotent monads

Both # and carry the structure of a monad, and both are idempotent: the units η#:#A##A and η:AA are isomorphisms.

Proof of Lemma 161.11 — The modalities are idempotent monads

Proof. For #: the action on maps is #g:=λu.λz.g(uz), and the double application unfolds to ##A=synsynA. Define μ:=λw.λz.wzz. The two round trips are μ(η#u)=def.λz.uz=funextu,η#(μw)=def.λz.λz.wzz=z=zw, the second because syn is a proposition, so its two proofs z and z are equal. The monad laws are the corresponding two calculations.

For : the functorial action is defined on constructors by g(ηa):=η(ga) and g(z):=z, which respects law because both sides are identified under syn. For idempotence, define ν:AA by ν(ηx):=x and ν(z):=z; this respects law because lawxz maps to x=z, which is an instance of law in A when x=ηa and is law-reflexivity when x=z, using that syn is a proposition. Then νη=id by the first clause, and ην=id by the eliminator’s uniqueness clause on the two constructors. ◻

Definition 161.12 — Modal types

A type A is open-modal when η#:A#A is an isomorphism, and closed-modal when η:AA is an isomorphism.

Lemma 161.13 — Closed-modality criterion

A type B is closed-modal if and only if #B is contractible, that is, if and only if #B has an element and any two of its elements are equal.

Proof of Lemma 161.13 — Closed-modality criterion

Proof. Suppose #B is contractible with centre c. Define r:BB by r(ηb):=b and r(z):=cz; the clause for law requires b=cz for z:syn, and under z the two elements η#b and c of #B are equal by contractibility, so their values at z agree. Then rη=id by the first clause and ηr=id by the eliminator’s uniqueness clause.

Conversely, suppose η is an isomorphism with inverse r. Under z:syn every element of B equals z by law, so B is contractible under z; transporting along the isomorphism, B is contractible under z, which is the statement that #B is contractible. ◻

Example 161.14 — Two closed-modal types and one that is not

For every A the type A is closed-modal, by lemma 161.11. The unit type 1 is closed-modal, since #1 is contractible. The type tm(bool) of the signature is not closed-modal: under syn it retains true and false as distinct elements, so # of it is not contractible. That failure is what the closed modality repairs in section 161.7.

Lemma 161.15 — Computation of the modalities in G

Interpret syn in G as the subterminal object (,y(1T),!). Then for every object T=(S,X,f), #T=(pt(X),X,id),T=(S,y(1T),!). Moreover η#:T#T is the map (f,idX) and η:TT is the map (idS,!).

Proof of Lemma 161.15 — Computation of the modalities in G

Proof. The open modality is the exponential syn() in G. In a comma category over a limit-preserving functor, the exponential by a subterminal object with empty set component has set component pt(X): a map (S,X,f)#T is a map (S,X,f)×synT, and (S,X,f)×syn=(,X,!), so such a map is just a presheaf map XX; that is exactly a map into (pt(X),X,id). Its unit is the identity on presheaves and f on sets.

For the closed modality, T is the pushout of the two projections of syn×T=(,X,!). Colimits in G are computed by taking the colimit of the set components and the colimit of the presheaf components and inducing the structure map, so the set component is the pushout of S, namely S, and the presheaf component is the pushout of y(1T)Xy(1T) along the two terminal maps, namely y(1T). The structure map is the unique one into pt(y(1T))=1. ◻

Theorem 161.16 — Fracture

For every type T the square T η# #T η ηT η# #T commutes and is a pullback; equivalently Tx:#T{y:T  η#(y)=η(x)}.

Proof of Theorem 161.16 — Fracture

Proof. Commutation is the naturality of η at η#. For the pullback property, compute both sides in G using lemma 161.15 at T=(S,X,f): #T=(pt(X),X,id),T=(S,y(1T),!),#T=(pt(X),y(1T),!). The map η:#T#T has set component the identity on pt(X), and the map η#:T#T has set component f:Spt(X), because leaves set components unchanged and η# has set component f. Limits in G are computed componentwise, since pt preserves them. The set component of the pullback is therefore pt(X)×pt(X)S=S along (id,f), and the presheaf component is X×y(1T)y(1T)=X. The induced structure map is f. Hence the pullback is (S,X,f)=T, and the comparison map is the identity. ◻

The fracture theorem is the exact sense in which nothing is lost by working with the two modalities instead of with the triples: a type is determined by its syntactic part, its semantic part, and the way the second sits over the first. Every definition in section 161.7 is given by specifying those three data.

Exercise 161.1

★☆☆ Show that open-modal types are closed under dependent products and dependent sums, and that closed-modal types are closed under dependent products. For each closure, name the clause of definition 161.10 used. Then give a closed-modal type whose dependent sum with a non-closed-modal family is not closed-modal.

Exercise 161.2

★★☆ Take T:=tm(bool) in G, interpreted as (,y(bool),!). Compute #T, T and #T by lemma 161.15, verify the pullback of theorem 161.16 in this instance by exhibiting the two projections, and state which of the three objects is the proof-relevant predicate of example 161.7.

Partial elements, extents, and realignment

Definition 161.17 — Partial elements and extents

Let A:U and let φ be a proposition. The partial element type is {φ}A:=φA, and for a:{φ}A the extent type is {Aφa}:={a:Az:φ. a=az}, the subtype of A spanned by the elements that agree with a under φ. The inclusion {Aφa}A is left implicit: if a:{Aφa} then a:A, and conversely an element a:A with #(a=a) inhabits the extent type.

For φ:=syn the extent type is the internal form of the strictness condition of definition 161.8: an element of {Asyna} is a semantic object that is, under the syntactic phase, the prescribed syntactic object.

Lemma 161.18 — Extents are closed-modal

For every A and every a:{syn}A, the type {Asyna} is closed-modal.

Proof of Lemma 161.18 — Extents are closed-modal

Proof. By lemma 161.13 it suffices to show that #{Asyna} is contractible. Assume z:syn. Then every element a of the extent type satisfies a=az by definition 161.17, so the type has the element az and all its elements are equal to az. Hence under syn it is contractible, which is the required statement. ◻

The strictness required in definition 161.8 does not follow from the constructions so far. Given a syntactic type A and a semantic predicate on it, dependent sums produce a type that is isomorphic to A under syn, not equal to it. The next definition is the axiom that converts such an isomorphism into an equation.

Definition 161.19 — Isomorphs and realignment

For A:U write Iso(A):=B:U(BA) for the type of U-small types equipped with an isomorphism to A. Let P be a collection of propositions. A realignment structure for U with respect to P is an element of A:Uφ:PB:[φ]Iso(A)A0:Iso(A)(z:φ. A0=Bz), where [φ] is the type of proofs of φ. A universe carrying such a structure is called strong.

Read the type in definition 161.19 as an instruction: given a type A, a proposition φ, and a partially defined isomorph B of A available under φ, produce a single isomorph A0 of A that is equal to B wherever B is defined. The conclusion is an equality of elements of Iso(A), so both the type and its isomorphism are pinned down.

Convention 161.20 — Realignment notation

For A:U, φ:P and B:[φ]Iso(A) we write realign[AφB]:U for the first component produced by definition 161.19, so that z:[φ]  realign[AφB]=pr1(Bz):U, and we treat the accompanying isomorphism realign[AφB]A as an implicit coercion in both directions.

Remark 161.21 — Why an isomorphism is not enough

Definition 161.8 requires π of the interpretation of bool to be y(bool) on the nose. Suppose only an isomorphism π(BOOL)y(bool) were available. The interpretation of if has the type tm(Cb), in which b occurs inside the motive; replacing BOOL by an isomorphic copy changes the type of the eliminator, and the two copies must then be related by a coercion at every use. Composing those coercions across the piβ and ifβ equations produces coherence obligations of exactly the kind that (161.3) produced externally. Realignment removes them by making one representative of the isomorphism class equal to the prescribed syntactic object.

Lemma 161.22 — Open and closed subuniverses

Assume U is strong with respect to a collection containing syn. Then there are universes Usyn:=realign[{syn}Usyn(U,λA.λz.A)],U:=realign[{Usyn1}syn(1,λ_.)] whose elements are exactly the open-modal and the closed-modal types respectively, and for which z:synUsyn=U and z:synU=1.

Proof of Lemma 161.22 — Open and closed subuniverses

Proof. Both displayed expressions are instances of convention 161.20, so the two equations under syn hold by the defining equation of realign. For the characterization of elements: an element of {syn}U is a type defined only under syn, and composing with the realignment isomorphism sends A:U to λz.A, whose image is open-modal because #A=synA and the unit is inverted by evaluation; conversely an open-modal A equals #A, which is in the image. For the closed subuniverse, an element of {Usyn1} is a type equal to 1 under syn, and by lemma 161.13 that is exactly the condition to be closed-modal. ◻

Exercise 161.3

★★☆ Let A:U, let φ be a proposition, and let B:[φ]Iso(A). Prove that realign[AB] is isomorphic to A and that realign[AB] equals pr1(B). State which clause of definition 161.19 each half uses, and explain in one sentence why the second is an equation while the first is only an isomorphism.

Strict glue types

Realignment is a statement about universes. The construction it is used for is always the same, and it is worth isolating as a type former so that it need not be re-derived at each constant of the signature.

Definition 161.23 — Strict glue type

Let A:synU be a syntactic type family defined under the syntactic phase, and let B:((z:syn)Az)U be a family of closed-modal types, so that #B(x) is contractible for every x. The strict glue type (x:A)B(x) is the type with the rules displayed below, in which π projects the syntactic component and π the semantic one.

A:synUB:((z:syn)Az)U(x:(z:syn)Az)(#B(x)1)
(x:A)B(x):U
Glue-F
z:syn(x:A)B(x)=Az:U
Glue-Syn
a:(z:syn)Azb:B(a)
[synab]:(x:A)B(x)
Glue-I
g:(x:A)B(x)
πg:(z:syn)Azπg:B(πg)
Glue-E
a:(z:syn)Azb:B(a)
π[synab]=aπ[synab]=b
Glue-C
g:(x:A)B(x)
g=[synπgπg]
Glue-U
g:(x:A)B(x)
z:syn(πg)z=g:Az
Glue-Elt-Syn

The two rules Glue-Syn and Glue-Elt-Syn are the reason for the whole construction: under the syntactic phase the glue type collapses to its syntactic component and a glued element collapses to its syntactic part. In the notation of definition 161.17 these say #((x:A)B(x)=A)and#([synab]=a).

Proposition 161.24 — Glue types from realignment

Assume U is strong with respect to a collection containing syn. Then the rules of definition 161.23 are derivable, with (x:A)B(x):=realign[Σsyn(A,ι)],Σ:=x:(z:syn)AzB(x), where ι is the isomorphism ΣAz available under z:syn.

Proof of Proposition 161.24 — Glue types from realignment

Proof. The only step needing an argument is the existence of ι; the rest is the reading of convention 161.20.

Assume z:syn. Then (z:syn)Az is isomorphic to Az by evaluation at z, with inverse λa.λz.a; these are mutually inverse because syn is a proposition, so z=z and the two round trips are the identity. For the second component, the hypothesis of Glue-F gives #B(x)1, and evaluating that isomorphism at z shows that B(x) is contractible; hence the projection Σ(z:syn)Az is an isomorphism under z. Composing the two gives ι:ΣAz.

Now convention 161.20 supplies a type equal to Az under syn and isomorphic to Σ; that equation is Glue-Syn. Transporting the introduction, projections, computation, and uniqueness rules of Σ across the realignment isomorphism gives Glue-I, Glue-E, Glue-C, and Glue-U. Finally, under z:syn the isomorphism ι sends a pair to the evaluation of its first component, so (πg)z=g, which is Glue-Elt-Syn. ◻

Lemma 161.25 — Interpretation of the glue type in G

Let A be open-modal with interpretation (pt(X),X,id) and let B be a closed-modal family whose value at apt(X) has set component Ba. Then (x:A)B(x)  is interpreted by  (apt(X)Ba, X, pr1).

Proof of Lemma 161.25 — Interpretation of the glue type in G

Proof. By proposition 161.24 the glue type is a realignment of Σ, and realignment changes an object only within its isomorphism class, so it suffices to compute Σ. A closed-modal family has presheaf component y(1T) at each index by lemma 161.15, so the dependent sum has presheaf component X and set component the disjoint union of the fibres, with the first projection as structure map. ◻

Exercise 161.4

★★☆ The formation rule Glue-F has two hypotheses beyond well-formedness: A is defined only under syn, and B takes closed-modal values.

  1. Drop the second hypothesis and take A:=λz.tm(bool) and B(x):=(x=true)+(x=false). Exhibit a term x for which #B(x) is empty, and conclude that Glue-Syn fails.

  2. Drop the first hypothesis by taking A to be a type defined outright rather than only under syn, and show that #((x:A)B(x)=A) then asserts an equation between a dependent sum and its first component that has no proof.

The canonicity model

The interpretation is now written as a list of definitions, one per constant of Σ. Each carries an extent type recording which syntactic constant it must restrict to under syn; that extent condition is the internal form of definition 161.8. Constants of the signature are written in lower case and their semantic counterparts in capitals.

Construction 161.26 — Semantics of the judgments

Define TP:{Usyntp},TP:=(A:tp){Usyntm(A)},TM:{TPUsyntm},TMA:=πA.

Read TP as follows: a semantic type is a syntactic type together with a semantic collection of its terms, and that collection must restrict to the syntactic term collection under syn. Three checks make the definition well formed, and each uses one rule of definition 161.23.

  1. The semantic component {Usyntm(A)} is closed-modal by lemma 161.18, so Glue-F applies.

  2. The extent condition #(TP=tp) holds by Glue-Syn.

  3. The definition of TM is well typed because πA inhabits the semantic component of TP by Glue-E, and the extent condition #(TM=tm) holds because that component is an extent type over tm(A) and #(A=πA) by Glue-Elt-Syn.

Construction 161.27 — Semantics of Booleans

Define BOOL:{TPsynbool},BOOL:=[synbool(b:tm(bool))((b=true)+(b=false))],TRUE:{TM(BOOL)syntrue},TRUE:=[syntrueη(inl(refl))],FALSE:{TM(BOOL)synfalse},FALSE:=[synfalseη(inr(refl))].

The inner glue type in BOOL is the semantic component supplied to the outer one. Its syntactic part is tm(bool) and its semantic part is the closed modality applied to the disjunction that names a constructor. Three conditions must hold, and the third is the reason the closed modality appears.

  1. #(BOOL=bool), which is Glue-Elt-Syn for the outer glue type.

  2. The semantic component of BOOL restricts to tm(bool) under syn, as construction 161.26 demands. This is Glue-Syn for the inner glue type.

  3. The family b((b=true)+(b=false)) takes closed-modal values, so that Glue-F applies to the inner glue type. This holds by lemma 161.11, since every type of the form C is closed-modal.

Remark 161.28 — The closed modality is not decoration

Delete from construction 161.27 and the third condition fails. Under syn the variable b ranges over all syntactic terms of type tm(bool), including a term that is neither constructor: the free variable x of the body of neg in example 161.2. For that b the type (b=true)+(b=false) has no element, so #((b=true)+(b=false)) is empty rather than contractible, and Glue-F does not apply. Wrapping the disjunction in adds the point z under syn and identifies it with every other element, restoring contractibility without weakening the predicate outside the syntactic phase.

Construction 161.29 — Semantics of the eliminator

Define IF:{(C:TM(BOOL)TP)(b:TM(BOOL))TM(CTRUE)TM(CFALSE)TM(Cb)synif},IFCbtf:=case πb of {η(inl(p))t,η(inr(p))f,zifCbtf.

Proposition 161.30 — The eliminator is well defined

The three branches of construction 161.29 agree on the identifications imposed by law, so IF is a well-defined map out of the quotient inductive type ((b=true)+(b=false)), and it satisfies the stated extent condition.

Proof of Proposition 161.30 — The eliminator is well defined

Proof. By definition 161.10 the eliminator of C requires, for each c:C and each z:syn, that the value at ηc equal the value at z.

First branch. Take c=inl(p) with p:b=true. Under z:syn the equality p holds, so b=true, and by equality reflection this is a judgmental equality. Therefore ifCbtf=pifCtruetf=ifβ1t, which is the value assigned at η(inl(p)).

Second branch. As in the first branch, with inr for inl, false for true, ifβ2 for ifβ1, and f for t.

Extent condition. Under syn the element πb equals z by law, so the third branch is selected and IFCbtf=ifCbtf, using Glue-Elt-Syn to identify C, b, t, f with their syntactic parts. ◻

Construction 161.31 — Semantics of dependent products

Define PI:{(A:TP)(TM(A)TP)TPsynpi},PIAB:=[synpiAB(e:tm(piAB)){(a:TM(A))TM(Ba)synappe}],LAM:{((x:TM(A))TM(Bx))TM(PIAB)synlam},LAMf:=[synlamff],APP:{TM(PIAB)(x:TM(A))TM(Bx)synapp},APPea:=(πe)a.

Proposition 161.32 — The product clauses are well typed

The three definitions of construction 161.31 satisfy their extent conditions, and APP(LAMf)a=fa,LAM(APPe)=e.

Proof of Proposition 161.32 — The product clauses are well typed

Proof. Formation. The semantic component of PIAB is an extent type, hence closed-modal by lemma 161.18, so Glue-F applies to the inner glue type. Its Glue-Syn equation gives #(PIAB=piAB), which is the extent condition on PI.

Introduction. For LAMf to be an application of Glue-I to the inner glue type, the second component f must inhabit {(a:TM(A))TM(Ba)synapp(lamf)}, that is, f must equal app(lamf) under syn. Under z:syn we compute, for every a, app(lamf)a=piβfa, and function extensionality gives app(lamf)=f. The equation piβ of definition 161.1 is used exactly here, and by equality reflection it is available as a judgmental equality during type checking.

Elimination. πe inhabits the extent type displayed above by Glue-E, hence is a function (a:TM(A))TM(Ba); applying it to a gives the required type. Under syn it equals appe by the extent condition, which is the extent condition on APP.

Computation. APP(LAMf)a=GlueC(π[synlamff])a=GlueCfa.

Uniqueness. LAM(APPe)=def.[synlam(appe)πe]=piη[synπeπe]=GlueUe, where the middle step uses piη together with #(e=πe) from Glue-Elt-Syn. ◻

Exercise 161.5

★★☆ Write out the type of LAMf with every extent condition expanded, and mark the two places where the equation piβ is used. Then state what goes wrong if piβ is removed from definition 161.1: name the rule of definition 161.23 whose premise fails and give the type of the term that can no longer be formed.

Exercise 161.6

★☆☆ Extend Σ with a constant unit:tp, a constant triv:tm(unit), and the equation a=triv for every a:tm(unit). Give the semantic clauses UNIT and TRIV in the style of construction 161.27, and verify the three conditions. State which choice of semantic component makes the closed-modality hypothesis of Glue-F hold without an application of .

From the internal model to closed terms

The constructions of section 161.7 are definitions in the internal language of G. Canonicity is a statement about closed terms of T. One step joins the two, and it is the step named in remark 161.4: the recursion that builds T out of Σ.

Theorem 161.33 — Fundamental theorem for the gluing model; imported

Let T be the category freely generated by Σ as in definition 161.5, let G be its Artin gluing as in definition 161.6, and suppose an interpretation of every constant of Σ is given in the internal language of G such that π of each interpreted constant is the presheaf generated by the corresponding constant of Σ, and every equation of Σ is validated. Then there is a functor ι:TG preserving finite limits and dependent products, sending each constant of Σ to its interpretation, and satisfying pt(π(ι(b)))=bfor every global element b of T.

The statement imported is the categorical fundamental theorem of logical relations for Artin gluing, in the form used by Li, Yao and Harper, Mechanizing Synthetic Tait Computability in Istari, §1.1, together with the adequacy of the logical-framework presentation of a type theory by a free locally cartesian closed category, due to Gratzer and Sterling [LH26, Ste21]. What it supplies here is the single passage from internal definitions to closed terms. Everything else in this chapter is proved locally: the modal lemmas lemma 161.11, lemma 161.13, the fracture theorem theorem 161.16, the computation of the modalities and of the glue type inside G lemma 161.15, lemma 161.25, the derivation of the glue rules from realignment proposition 161.24, the well-typing of every clause of construction 161.26construction 161.31, and the extraction below.

Theorem 161.34 — Canonicity

Every closed term b of type tm(bool) in T satisfies b=true or b=false.

Proof of Theorem 161.34 — Canonicity

Proof. Let ι be the functor of theorem 161.33 for the interpretation of construction 161.26construction 161.31.

The interpreted Boolean type. By construction 161.27 the semantic component of BOOL is the glue type (c:tm(bool))((c=true)+(c=false)). Its base is open-modal, and leaves set components unchanged by lemma 161.15, so lemma 161.25 computes the interpretation of BOOL in G as ( cpt(y(bool))Sc, y(bool), pr1 ),Sc:=(c=true)+(c=false), where pt(y(bool)) is the set Nat(y(1T),y(bool)) of closed terms of type tm(bool) modulo the equations of Σ, by definition 161.5. Thus Sc has an element exactly when c=true or c=false.

Extraction. Apply ι to the global element b:1Tbool. The result is a map ι(b):1Gι(bool) in G; write it as a pair (h,t) as in definition 161.6. The set component h:1cSc selects an element of Sc0 for exactly one index c0. The commutation condition of definition 161.6 applied to (h,t) gives c0=pr1hpt(t)=theorem161.33b. Hence Sb has an element, so b=true or b=false. ◻

Example 161.35 — The theorem on the running term

For b0=appnegtrue of example 161.2, the extraction unfolds to the calculation already performed there. Applying ι to b0 uses APP and LAM from construction 161.31 and IF, TRUE from construction 161.29, construction 161.27: π(ι(b0))=proposition161.32π(IF(λ_.BOOL)TRUEFALSETRUE)=construction161.29πFALSE=construction161.27η(inr(refl)). The witness produced is the right injection, which names false.

What this proof does and does not establish

Theorem 161.34 is a canonicity theorem for the signature Σ. Four nearby statements are not consequences of it, and each fails for a different reason.

Normalization. Canonicity concerns closed terms of one base type. Normalization concerns open terms of every type and requires an interpretation in which types carry normal and neutral forms, not merely a predicate on closed terms. A normalization theorem proved by the method of this chapter, at a signature that includes modalities, is available: Gratzer, Normalization for multimodal type theory, proves in Theorem 6.4 that there is a function nfΓ(,A) from terms to normal forms with Γ|nfΓ(M,A)|=M:A and with ΓM=N:A implying nfΓ(M,A)=nfΓ(N,A); Corollary 6.6 derives decidability of conversion from decidability of the mode theory, and Corollary 6.11 recovers Boolean canonicity. That theorem is stated for multimodal type theory at its own signature, and is not proved here.

Other phase distinctions. The proposition syn of definition 161.10 separates syntax from semantics. It is not the strict/fibrant distinction of two-level type theory, whose two layers are two notions of equality on the same terms; it is not a parameter/state distinction, whose two layers are two run-times; it is not an erasure annotation, whose content is a usage discipline on variables; and it is not a stage separation, whose content is a temporal order on evaluation. What distinguishes syn from all four is that it is an ordinary proposition of the ambient theory, so that the two “layers” are the two subtopoi it cuts out, and the fracture theorem theorem 161.16 reassembles them.

Mechanization. Li, Yao and Harper check the constructions of construction 161.26construction 161.31 in Istari, an extensional proof assistant with equality reflection; their development also treats a cost-aware framework. A successful check establishes the archived theories at their recorded signatures. It does not establish theorem 161.33, which is the step performed outside the internal language, and it is not a verified kernel.

Arbitrary signatures. Nothing above depends on the particular constants of Σ except construction 161.27construction 161.31. Section 161.4Section 161.6 are stated for an arbitrary proposition and an arbitrary strong universe. But a new type former requires a new semantic clause and a new verification of the three conditions, and a former whose semantic component cannot be made closed-modal has no clause of this shape at all. Exercise 161.4 is the smallest instance of that failure.

Remark 161.36 — The external proof, line by line

Set the external Kripke argument of section 161.2 beside the construction just completed.

  1. The context index Δ of CAΔ becomes the presheaf structure of an object of G (definition 161.6); nothing in the internal language mentions it.

  2. The renaming obligation (161.3) becomes the requirement that a definition be written in the internal language at all, since every such definition denotes a map of G.

  3. The clause (161.1) becomes the semantic component of construction 161.27; the closed modality that appears there has no external counterpart, because externally the predicate is stated only for closed terms, where the missing case of remark 161.28 does not arise.

  4. The clause (161.2) becomes the semantic component of construction 161.31. Its self-reference at Ba, which blocked the external recursion, is now an ordinary dependent function type over TP, and TP is a glue type rather than an inductively generated set of codes.

  5. The external requirement that the predicate be preserved by the eliminators becomes the extent conditions, and each is discharged by one rule of definition 161.23.

  6. The external step that concludes canonicity from the fundamental lemma becomes theorem 161.33 together with the extraction in theorem 161.34.

The one item with no external counterpart is realignment definition 161.19: externally, the predicate is defined at a syntactic type, so strictness is automatic; internally, the predicate is a type in its own right, and strictness must be asserted.

Suggested first pass.

Problems exercise 161.7, exercise 161.8, and exercise 161.11 form the suggested first pass. None of these problems is a prerequisite for a later chapter.

Exercise 161.7

★★☆ Extend Σ with nat:tp, zero:tm(nat), succ:tm(nat)tm(nat), and the dependent recursor with its two computation equations. Give the semantic clauses NAT, ZERO, SUCC, REC in the style of construction 161.27construction 161.29, taking as semantic component of NAT the closed modality applied to the type of witnesses that a term equals a numeral. Verify the three conditions of construction 161.27 for NAT, and verify that the branches of REC agree on law in the manner of proposition 161.30. State precisely where the semantic component requires an inductively defined witness type and why the closed modality does not remove that requirement.

Exercise 161.8

★★★ Theorem 161.16 was proved by computing in G. Give a second proof entirely in the internal language, as follows.

  1. Construct the comparison map Tx:#T{y:Tη#(y)=η(x)} from the two units.

  2. Construct an inverse using the eliminator of from definition 161.10, and state the exact instance of law needed to see that the two branches agree.

  3. Check both round trips, naming at each step whether the equation used is law, function extensionality, or the fact that syn is a proposition.

  4. Show that the statement fails if syn is not assumed to be a proposition, by exhibiting a two-element syn and a type T for which the comparison map is not injective.

Exercise 161.9

★★★ Replace realignment by the weaker assumption that (x:A)B(x) is merely isomorphic to A under syn, and attempt to repeat section 161.7.

  1. Show that TP and TM can still be defined, with the extent conditions replaced by isomorphisms.

  2. Write out the type of IF under this weakening, inserting the coercions that the motive now requires, and display the coherence equation between two coercions that proposition 161.30 would need.

  3. Identify which step of theorem 161.34 then fails, and state what would have to be proved instead.

Exercise 161.10

★★★ Replace the single proposition syn by two propositions synL and synR whose conjunction is false, and write synLR:=synLsynR. For q ranging over the three propositions define #q and q as in definition 161.10.

  1. Given AL open-modal for synL, AR open-modal for synR, and a family S:AL×ARU with synLR-closed-modal values, construct a type S~ with #L(S~AL) and #R(S~AR).

  2. State the fracture theorem for synLR and say what it asserts about a type in this setting.

  3. Explain in one sentence why this configuration expresses a binary relation, and name the theorem of chapter 6 whose statement it internalizes.

Exercise 161.11

★★★ Practical project.stc-canonicity-witness Implement, in Agda, the analytic counterpart of construction 161.26construction 161.31 for the signature Σ of definition 161.1, and use it to compute canonicity witnesses.

Calculus to implement. Represent the object theory of definition 161.1 as an intrinsically typed syntax: an inductive type of object types, an inductive family of object terms indexed by a context and a type, and de Bruijn indices with capture-avoiding simultaneous substitution. Include bool with both constructors and the dependent eliminator, and dependent products with lam and app. Define a proof-relevant computability family: at bool, the type of witnesses that a closed term equals a constructor; at a product, the dependent function type of (161.2), indexed by a context and closed under renaming.

Invariant. The computability family must be indexed by a context and must come with an explicit renaming action satisfying (161.3); every clause of the fundamental lemma must be given that action, and the action must be checked to commute with the eliminators. This is the bookkeeping that remark 161.36, item 2, records as absent from the synthetic proof; the program must contain it in full.

Concrete result. A function that, given a closed term of Boolean type, returns the constructor it equals together with the witness produced by the fundamental lemma.

Acceptance test. Run the function on the following named inputs and compare against the stated outcomes: true and false return themselves with the injection witnesses of construction 161.27; the term b0 of example 161.2 returns false with the right injection, as computed in example 161.35; the term appneg(appnegtrue) returns true; the term app(lam(λx.x))false returns false; and the open term x in the context x:bool is rejected by the type of the function, which accepts closed terms only. In addition, produce three mutations that still typecheck — delete the renaming action from the product clause, replace the product clause by a non-dependent one, and replace the Boolean witness type by the unit type — and check that each makes some named case fail. Finally, state explicitly that the program illustrates theorem 161.34 and does not prove it: the program establishes the theorem for the finitely many named inputs, whereas the theorem quantifies over all closed terms.

Search the book

Type to search the local edition.