Quadratic type checking for objective type theory
QQuadratic type checking for objective type theory
Benno van den Berg
Institute for Logic, Language and Computation (ILLC), University of Amsterdam, P.O. Box 94242,1090 GE Amsterdam, The [email protected]
Martijn den Besten
Institute for Logic, Language and Computation (ILLC), University of Amsterdam, P.O. Box 94242,1090 GE Amsterdam, The [email protected]
Abstract
We introduce a modification of standard Martin-Löf type theory in which we eliminate definitionalequality and replace all computation rules by propositional equalities. We show that type checkingfor such a system can be done in quadratic time and that it has a natural homotopy-theoreticsemantics.
Theory of computation → Type theory
Keywords and phrases
Homotopy type theory, Polynomial time algorithms, categorical semantics
Among all formal systems for constructive mathematics, Martin-Löf’s constructive typetheory has a special status in that it successfully embodies many important constructivistideas. Among them is the idea that the meaning of a mathematical statement is fullyexplained by what counts as a proof of (or evidence for, or a construction of) that statement.In fact, for all practical purposes a mathematical statement can be identified with the type(or set) of its proofs: this is what is meant by the propositions as types idea. As a result, intype theory a ∈ σ can both be read as saying that a is an element of the set σ and that a is a proof of theproposition σ .The next question is whether the relation a ∈ σ should be decidable (possibly appearingin a context Γ, but we will ignore that for now). This is the case in Martin-Löf’s type theoryand, indeed, from a philosophical point of view, this seems desirable. If a is a proof of (orevidence for) σ , then seeing a should convince any rational being of the truth of σ , and wewould expect any rational being to be sufficiently reflective to recognise that a makes assentto σ inevitable. Put differently, if it is reasonable to simultaneously be presented with a andbe unsure about the truth of σ , then a is simply not conclusive evidence in favour of σ . Assummarised by Kreisel: “we can recognize a proof when we see one”. But also from the point of view of implementing type theory it is desirable to havedecidable type checking. Indeed, most proof assistants based on type theory use typechecking as their mechanism for verifying proofs. In this connection it should be stressed that Full quote: “The sense of a mathematical assertion denoted by a linguistic object A is intuitionisticallydetermined (or understood) if we have laid down what constructions constitute a proof of A , i.e., if wehave a construction r A such that, for any construction c , r A ( c ) = 0 if c is a proof of A and r A ( c ) = 1 if c is not a proof of A : the logical particles in this explanation are interpreted truth functionally, since weare adopting the basic intuitionistic idealization that we can recognize a proof when we see one, and so r A is decidable. (Note that this applies to proof , not provability .)” [10] a r X i v : . [ c s . L O ] F e b Quadratic type checking for objective type theory we are concerned here with derivability, not with validity of derivations. Whereas for manysystems the question whether some syntactic object is a valid derivation in the system ornot is decidable, type theory has in addition the special property that the question whether a ∈ σ is derivable or not is decidable.But once one has become convinced that we should make this question decidable, anatural next question is how difficult from a complexity-theoretic point of view it should beto check whether a ∈ σ holds. It turns out that in most versions of type theory, includingmost standard formulations of Martin-Löf type theory, the worst-case upper bounds are quitehorrendous. In fact, we have the following theorem by Statman [13]: (cid:73) Theorem 1.
Equality in the typed lambda calculus is not elementary recursive.
This has the consequence that the question whether a ∈ σ is derivable or not, is decidable,but not feasibly so.It should be said that from a philosophical point of view, this is slightly odd: this saysthat in most versions of type theory it may be infeasible to decide whether a should count ascompelling evidence in favour of σ . This means that one may be presented with evidence infavour of σ , but the task of deciding whether this is indeed conclusive evidence may be, froma practical point of view, impossible. This raises the question to which extent it should stillcount as compelling evidence.Again, this is more than just a philosophical problem. In an interesting paper [7], Geuversand Wiedijk write:In theorem provers based on type theory the main performance bottleneck is theconvertibility check: if the calculated type of a term M is A , but it used in a contextwhere the type should be B , then the system needs to verify that A = βιδ B , where δ is the equality arising from definitional expansion (unfolding definitions) and ι is theequality arising from functions defined by (higher order primitive) recursion. In fact,the inefficiency of the convertibility check means that type correctness is in practiceonly semi-decidable. Although in theory it is decidable whether a term M has type A ,in practice when it is not correct the system could be endlessly reducing and wouldnot terminate in an acceptable time any more.To see what the problem is, let us consider the following question: is ‘ refl ( A (3 , − ∈ Id( N , A (3 , − , A (4 , A is the Ackermann function? Most type checkers would try to answerthis question by normalising both A (3 , −
3) and A (4 , why statements are true. If we take the term refl ( A (3 , − A (3 , −
3) = A (4 , This slightly modifies an example mentioned in Geuvers and Wiedijk. . van den Berg and M. den Besten 3 from the fact that to do type checking a computer has to do many conversions, none of whichare stored in the proof term. And, indeed, they show that if we enrich our proof terms withexplicit conversions, we are able to make type checking feasible.The purpose of this paper is to present a different implementation of their idea. In ourview, our method has three advantages over theirs. First of all, it is systematic in that theway we store conversions in the proof terms relies on one simple idea. Secondly, our solutionmakes use of insights coming from homotopy type theory, so in that way it connects witha lot of exciting research which is currently happening. Thirdly, our proof of feasibilitymakes more realistic assumptions. For instance, Geuvers and Wiedijk assume that checkingsyntactic equality of strings can be done in unit time, while we assume that this requires atime linear in the length of the smallest string.Our starting point is the observation that Martin-Löf type theory has two kinds of equality:judgemental (or definitional) equality and propositional equality. Recent developments inHoTT strongly suggest that it should be possible to eliminate definitional equality completelyin favour of propositional equality, and, indeed, that is what we do here. The trick is tostate every computation rule in Martin-Löf type theory (which is naturally thought of as aconversion) as a propositional equality, including the computation rule for the identity typeitself. The first main result of this paper is that in doing this we obtain a system in whichtype checking is efficiently decidable: indeed, it is decidable in quadratic time.Clearly, such a system is weaker than the standard systems, so it is natural to wonderhow much weaker it is. We claim that this system still suffices for doing all of constructivemathematics; indeed, we conjecture that in such a system it should be possible to formalisemost of the HoTT book. Of course, a detailed verification of such a claim would be very timeand paper consuming, and we will not attempt that here. But it is generally understood (andthis is also backed up by the success of cubical type theory) that having the computationrule for the identity type as a propositional equality is not an obstacle to doing homotopytype theory (see also papers by Coquand and Danielsson [6] and Bocquet [5]; we are alsoaware of a talk by Nicolai Kraus at TYPES-2017). As another indication, we will prove, andthis will be our second main result, that the syntactic category of such a weak type theory isa path category with homotopy Π -types (see [3, 1, 2, 4]). Given this work it should be clearthat a lot of HoTT can be formalised in such a setting.Let us finish by pointing out that there are other reasons why it is interesting to explorethe consequences of abolishing definitional equality in favour propositional equality, whichhave nothing to do with feasibility.First of all, weaker rules have more models. As the work on cubical type theory makesclear, this is especially true from a constructive point of view.Secondly, eliminating definitional equality helps us to understand it better. The ideahere is that we do not fully understand what definitional equality is doing for us: to reallyunderstand this, the best way may be to try to live without it and see what happens. (Forinstance, an interesting question here is whether univalence still implies function extensionalityin such a setting.)Thirdly, it is hard to find objective grounds for deciding which equalities are definitionaland which ones are only propositional. The way things are done usually, for an arbitrary x ∈ N , we have that x + 0 = x holds definitionally, while 0 + x = x holds only propositionally.In fact, it is possible to define a variant of plus for which the opposite holds. This is not justodd, but can also be akward in formalisations. Even Martin-Löf himself suggested to theauthors that such decisions are best made on pragmatic grounds. For the last reason theauthors of this paper like to think of the type theory we are proposing as a kind of objective Quadratic type checking for objective type theory type theory . The contents of this paper are therefore as follows. In Section 2 we present objectivetype theory. In Section 3 we prove that type checking in objective type theory can be donein quadratic time. In Sections 4 – 6 we prove that the classifying category associated toobjective type theory is a path category with homotopy Π-types. We do this in several steps:we construct the classifying category in Section 4, show that it is a path category in Section5 and construct the homotopy Π-types in Section 6. We end with some directions for futureresearch in Section 7.
The goal of this section will be to introduce objective type theory. (cid:73)
Remark 2.
We imagine that this type theory has been formulated using some device likeDe Bruijn-indices so that there is no difference between α -equivalence and syntactic equalityof expressions. However, for the sake of human readability, we will be using variables. Butthis means that the notation s ≡ t , which we will use for syntactic equality of expressions,will act like α -equivalence. The type theory we wish to introduce derives statements of one of the following three forms: ‘ Γ Ctxt Γ ‘ σ ∈ Type Γ ‘ a ∈ σ The meaning of the first statement is that Γ is a context , that of the second is that σ is a type in context Γ, whilst the third means that a is a term of type σ in context Γ.Our type theory has only three basic rules. The first two tell us how to form contexts,the idea being that context Γ is a list of the form[ x : σ , x : σ , . . . , x n − : σ n − ]with the x i being distinct variables. In that spirit, the two context formation rules are: ‘ [] Ctxt ‘ Γ Ctxt Γ ‘ σ ∈ Type x fresh ‘ [Γ , x : σ ] Ctxt The third and final basic rule of our type theory is the following variable rule, which saysthat if x ∈ σ occurs in a context Γ, then Γ ‘ x ∈ σ holds. Formally: ‘ [Γ , x ∈ σ, ∆] CtxtΓ , x ∈ σ, ∆ ‘ x ∈ σ Here is an interesting quote in that respect: “My personal disenchantment with dependent type theoriescoincides with the decision to shift from extensional to intensional equality. This meant for examplethat 0 + n = n and n + 0 = n would henceforth be regarded as fundamentally different assertions,one an identity holding by definition and the other a mere equality proved by induction. Of course Iwas personally upset to see several years of work, along with Constable’s Nuprl project, suddenly putbeyond the pale. But I also had the feeling that this decision had been imposed on the communityrather than arising from rational discussion. And I see the entire homotopy type theory effort as anattempt to make equality reasonable again.” [11] . van den Berg and M. den Besten 5 The other rules follow the usual pattern of Martin-Löf type theory, in which each typeconstructor comes with four rules (formation, introduction, elimination and computation). Inthe appendix the reader can find the rules for identity and Π-types. They are the usual ones,except that the computation rule holds only propositionally : that is, it states a propositionalinstead of a definitional equality. This means that if we think of type theory as some sortof generalised algebraic theory, there will only be constructors, but no equations. In theformulation of these rules, we have used [ t , . . . , t n /x , . . . , x n ] for the result of a (captureavoiding) substitution of t , . . . , t n for x , . . . , x n , respectively. In addition, [ x , . . . , x n ] t means that the variables x , . . . , x n have become bound in the term or type t .We emphasise that we think of objective type theory as an open framework which neednot only include the Π- and Id-types, but could also include rules for Σ-types and a naturalnumbers type, for instance. Again, we imagine that these would be formulated in the usualway but with the computation rules in the form of propositional equalities. (cid:73) Remark 3.
In the appendix the reader can also find strengthened versions of these ruleswith a general contextual parameter. An important step in the development below will bethe proof that these are admissable.
We start off by making a number of simple observations about our axiomatisation of objectivetype theory. (cid:73)
Lemma 4. (Admissability of weakening and substitution)
The following weakening andsubstitution rules are admissable in the system: Γ , ∆ ‘ J Γ ‘ σ typeΓ , x ∈ σ, ∆ ‘ J Γ ‘ a ∈ σ Γ , x ∈ σ, ∆ ‘ J Γ , ∆[ a/x ] ‘ J [ a/x ] Proof.
By induction on the derivations of Γ , ∆ ‘ J and Γ , x ∈ σ, ∆ ‘ J , respectively. (cid:74)(cid:73) Lemma 5.
Each derivable judgement has a unique derivation.
Proof.
The reason is that each judgement, whether it is ‘ Γ Ctxt , Γ ‘ σ ∈ Type or Γ ‘ a ∈ σ appears as the conclusion of at most rule in our system. Indeed, this is clear for contexts,because the first two basic rules are the only ones introducing contexts into the system.For judgements of the form Γ ‘ σ ∈ Type we look at the main type constructor in σ : theintroduction rule for that type constructor is the only one introducing judgements of thatshape into the system. Similarly, for judgements of the form Γ ‘ a ∈ σ we look at the mainterm constructor in a : the rule introducing that constructor into the system is the only onewhich has a conclusion with that precise shape. (cid:74) In a similar fashion one shows: (cid:73)
Lemma 6. (Uniquess of types) If Γ ‘ a ∈ σ and Γ ‘ a ∈ τ , then σ ≡ τ . We now come to the first main result of this paper. (cid:73)
Theorem 7.
The question whether Γ ‘ a ∈ σ is derivable or not can be decided in quadratictime. Quadratic type checking for objective type theory
Proof.
When estimating the time it takes to decide Γ ‘ a ∈ σ , we may always assume thatthis judgement is actually derivable. For if it is not and our decision procedure exceeds thistime estimate without having reached a decision, we will simply conclude that Γ ‘ a ∈ σ mustnot have been derivable, time-out the computation and output false . Write Γ ‘ ∗ a ∈ σ forthe promise problem of deciding Γ ‘ a ∈ σ with promise Γ ‘ σ ∈ Type. In other words, in thestarred version of the problem it is permitted to give a wrong answer whenever Γ (cid:48) σ ∈ Type.Similarly, write Γ ‘ ∗ σ ∈ Type for the promise problem of deciding Γ ‘ σ ∈ Type withpromise ‘ Γ Ctxt. Denote the length of a string s by | s | . It is sufficient to prove thatΓ ‘ ∗ a ∈ σ and Γ ‘ ∗ σ ∈ Type can be decided in time O (( | a | + | σ | ) ) and O ( | σ | ) respectively,for the following reason. One easily verifies that a procedure to decide Γ ‘ ∗ σ ∈ Type intime O ( | σ | ) gives rise to a procedure to decide ‘ Γ ∈ Ctxt in time O ( | Γ | ), by inductionon | Γ | . Deciding Γ ‘ a ∈ σ is then just a matter of deciding ‘ Γ Ctxt, Γ ‘ ∗ σ ∈ Type andΓ ‘ ∗ a ∈ σ .We prove that Γ ‘ ∗ a ∈ σ and Γ ‘ ∗ σ ∈ Type can be decided in time k | a | + k | σ | and k | σ | respectively, for sufficiently large constants k < k , by (simultaneous) induction on | a | in the case of Γ ‘ ∗ a ∈ σ and | σ | in the case of Γ ‘ ∗ σ ∈ Type. The base case, Γ ‘ ∗ x ∈ σ ,can clearly be decided in k + k | σ | time steps, by comparing the string σ to the stringappearing in Γ at the position pointed to by x . We will go through the induction step foreach rule of the Π-type and Id-type.We start with the rules for the Π-type. Formation.
Let the problem Γ ‘ ∗ Π( A, [ x ] B ) ∈ Type be given. We make two recursivecalls to the algorithm to decide Γ ‘ ∗ A ∈ Type and Γ , x ∈ A ‘ ∗ B ∈ Type, at the cost of k ( | A | + | B | ) time steps. This is clearly less than k ( | A | + | B | + 1) , which is the numberof time steps available to us. Introduction.
Let the problem Γ ‘ ∗ λ ( A, [ x ] B, [ x ] t ) ∈ σ be given. We make the stringcomparison equal (Π( A, [ x ] B ) , σ ) at the cost of k | σ | time steps. Moreover, we make arecursive call to the algorithm to decide Γ , x ∈ A ‘ ∗ t ∈ B , at the cost of k | t | + k | B | additional time steps. As k < k , we have clearly used less than k ( | t | + | A | + | B | +1) + k | σ | time steps, which is the number of time steps available to us. There is no need to checkthe premises Γ ‘ A ∈ Type and Γ , x ∈ A ‘ B ∈ Type. Since we are working under theassumption that Γ ‘ Π( A, [ x ] B ) ∈ Type is derivable, it follows from unique derivability thatΓ ‘ A ∈ Type and Γ , x ∈ A ‘ B ∈ Type are derivable.
Elimination.
Let the problem Γ ‘ ∗ app ( A, [ x ] B, f, a ) ∈ σ be given. We make the stringcomparison equals ( B [ a/x ] , σ ) at the cost of k | σ | time steps. Moreover, we make fourrecursive calls to the algorithm to decide Γ ‘ ∗ A ∈ Type; Γ , x ∈ A ‘ ∗ B ∈ Type; Γ ‘ ∗ f ∈ Π( A, [ x ] B ) and Γ ‘ ∗ a ∈ A , at the cost of k ( | A | + | B | + | f | + | a | ) + k (2 | A | + | B | + 1).Since we may safely assume that k ≥ k , one easily verifies that we have used less than k ( | A | + | B | + | f | + | a | + 1) + k | σ | time steps in total, which is the number of time stepsavailable to us. Computation.
Let the problem Γ ‘ ∗ betaconv ( A, [ x ] B, a, [ x ] t ) ∈ σ be given. We makethe string comparison equals ( app ( A, [ x ] B, λ ( A, [ x ] B, [ x ] t ) , a ) = B [ a/x ] t [ a/x ] , σ ) at the costof k | σ | time steps. This is clearly less than k ( | A | + | B | + | a | + | t | + 1) + k | σ | , which is thenumber of time steps available to us. There is no need to check the premises Γ , x ∈ A ‘ t ∈ B and Γ ‘ a ∈ A . Since we are working under the assumption that Γ ‘ σ ∈ Type is derivableand we have verified that σ ≡ app ( A, [ x ] B, λ ( A, [ x ] B, [ x ] t ) , a ) = B [ a/x ] t [ a/x ], it follows fromunique derivability that Γ , x ∈ A ‘ t ∈ B and Γ ‘ a ∈ A are derivable.Finally, we check the rules for the Id-type. Formation.
Let the problem Γ ‘ ∗ a = A b ∈ Type be given. We make three recursive . van den Berg and M. den Besten 7 calls to the algorithm to decide Γ ‘ ∗ A ∈ Type, Γ ‘ ∗ a ∈ A and Γ ‘ ∗ b ∈ A , at the cost of k ( | A | + | a | + | b | ) + 2 k | A | time steps. Since we may assume that k ≥ k , this is clearlyless than k ( | A | + | a | + | b | + 1) , which is the number of time steps available to us. Introduction.
Let the problem Γ ‘ ∗ refl ( A, a ) ∈ σ be given. We make the stringcomparison equals ( a = A a, σ ) at the cost of k | σ | time steps. Moreover, we make a recursivecall to the algorithm to decide Γ ‘ ∗ a ∈ A at the cost of k | a | + k | A | time steps. Since k ≤ k , it is clear that we have used less than k ( | A | + | a | + 1) + k | σ | time steps in total,which is the number of time steps available to us. There is no need to check Γ ‘ A ∈ Type.Since we are working under the assumption that Γ ‘ σ ∈ Type is derivable and we haveverified that σ ≡ a = A a , it follows from unique derivability that Γ ‘ A ∈ Type is derivable.
Elimination.
Let the problem Γ ‘ ∗ idrec ( A, [ x, y, u ] P, a, b, p, [ x ] d )) ∈ σ be given. Wemake the string comparison equals ( P [ a, b, p/x, y, u ] , σ ) at the cost of k | σ | time steps.Moreover, we make six recursive calls to the algorithm to decide Γ ‘ ∗ A ∈ Type; Γ , x ∈ A, y ∈ A, u ∈ x = A y ‘ ∗ P ∈ Type; Γ ‘ ∗ a ∈ A ; Γ ‘ ∗ b ∈ A ; Γ ‘ ∗ p ∈ a = A b and Γ , x ∈ A ‘ ∗ d ∈ P [ x, x, refl ( A, x ) /x, y, u ]. Using the estimate | P [ x, x, refl ( A, x ) /x, y, u ] | ≤ | P | ( | A | + 2),these calls cost at most k ( | A | + | P | + | a | + | b | + | p | + | d | )+ k (3 | A | + | a | + | b | + | P | ( | A | +2)+1).Since we may safely assume that k ≥ k , one easily verifies that we have used less than k ( | A | + | P | + | a | + | b | + | p | + | d | + 1) + k | σ | time steps in total, which is the number oftime steps available to us. Computation.
Let the problem Γ ‘ ∗ idconv ( A, [ x, y, u ] P, a, [ x ] d ) ∈ σ be given. We makethe string comparison equals ( idrec ( A, [ x, y, u ] P, a, a, refl ( A, a ) , [ x ] d ) = P [ a,a, refl ( A,a ) /x,y,u ] d [ a/x ] , σ ) at the cost of k | σ | time steps. This is clearly less than k ( | A | + | P | + | a | + | d | + 1) + k | σ | , which is the number of time steps available to us. There is no need to check any of thepremises. Since we are working under the assumption that Γ ‘ σ ∈ Type is derivable and wehave verified that σ ≡ idrec ( A, [ x, y, u ] P, a, a, refl ( A, a ) , [ x ] d ) = P [ a,a, refl ( A,a ) /x,y,u ] d [ a/x ], itfollows from unique derivability that all of the premises are derivable. (cid:74)(cid:73) Remark 8.
As we mentioned before, we think of objective type theory as an open frameworkwhich can be extended with additional rules like those for a sum and a natural numbers type.If we extended objective type theory with these type constructors, the proof that we gaveabove would still work; but we will not attempt to formulate and prove a general statementfor general type constructors.
The second main result of this paper will be that the classifying category associated topropositional type theory is a path category with weak homotopy Π-types in the sense of[3]. In fact, if we assume function extensionality the homotopy Π-types will be strong in thesense of [4]. We will prove this result in several steps. In this section we will outline theconstruction of the classifying category. This is included for the convenience of the reader,because the construction is absolutely standard (see, for instance, the account in [8, Section2.4] which we will closely follow here). In the next we will prove that it is a path category;in the one after that we will construct weak and strong homotopy Π-types. A context morphism f : ∆ → Γ withΓ = [ x ∈ σ , x ∈ σ , . . . , x n ∈ σ n ] . Quadratic type checking for objective type theory is a sequence of terms ( t , . . . , t n ) for which the following statements are derivable:∆ ‘ t ∈ σ ∆ ‘ t ∈ σ [ t /x ] . . . ∆ ‘ t n ∈ σ n [ t , . . . , t n − /x , . . . , x n − ]We will regard two context morphisms ( s , . . . , s n ) , ( t , . . . , t n ) : ∆ → Γ as (syntactically)equal if they are componentwise syntactically equal.Note that for a context Γ as above we always have a context morphism Γ → Γ:1 Γ : ≡ ( x , . . . , x n ) . Context morphisms allow a notion of generalised substitution . Indeed, if θ is a type, termor judgement in context Γ and f : ∆ → Γ is a context morphism as above, then there is anew type, term or judgement θ [ f ] : ≡ θ [ t , . . . , t n /x , . . . , x n ]in context ∆. We clearly have θ [1 Γ ] ≡ θ .With this notion of generalised substitution, we can also regard the context morphismsas being inductively defined by the following rules: ∆ Ctxt! ∆ : ∆ → [] f : ∆ → Γ Γ ‘ σ ∈ Type ∆ ‘ t : σ [ f ]( f, t ) : ∆ → [ Γ , x : σ ] We also have the following generalising substitution rule: (cid:73)
Proposition 9. If f : ∆ → Γ is a context morphism and Γ , Θ ‘ J , then also ∆ , Θ[ f ] ‘ J [ f ] . Proof.
This is Proposition 2.12 in [8]. By induction on the structure of f . The base casefollows from weakening and in the induction step we use the induction hypothesis and thesubstitution rule. (cid:74) If g : Θ → ∆ and f : ∆ → Γ with f ≡ ( t , . . . , t n ), then we can form a new list of terms: f ◦ g : ≡ ( t [ g ] , . . . , t n [ g ]) . Then f ◦ g is a context morphism Θ → Γ. In fact, we have: (cid:73)
Proposition 10. If h : E → Θ , g : Θ → ∆ , f : ∆ → Γ , and Γ ‘ σ ∈ Type and Γ ‘ a ∈ σ ,then the following equations hold up to syntactic equality: Γ ◦ f ≡ f ≡ f ◦ ∆ f ◦ ( g ◦ h ) ≡ ( f ◦ g ) ◦ hσ [ f ◦ g ] ≡ σ [ f ][ g ] a [ f ◦ g ] ≡ a [ f ][ g ] Proof.
See [8, Proposition 2.13]. (cid:74)
The first two items of this proposition tell us that we have indeed defined a category.Within this category, two classes of morphisms will become important. . van den Berg and M. den Besten 9 (cid:73)
Definition 11.
IfΓ ‘ σ ∈ Type , then there is a map of the form [Γ , x ∈ σ ] → Γ dropping the last type from the context (moreprecisely, if Γ = [ x ∈ σ , . . . , x n − ∈ σ n − ], then it is the sequence ( x , . . . , x n − )). We willcall maps of this form display maps . Note that a section of this display map corresponds toa term a of type σ in context Γ. By closing the class of display maps under isomorphismsand composition, we obtain the class of fibrations .An important property of display maps and fibrations is that they are both stable underpullback. The reason is that if Γ ‘ a ∈ σ and f : ∆ → Γ is a context morphism, then[∆ , y ∈ σ [ f ]] [Γ , x ∈ σ ]∆ Γ [ f,y ] f is a pullback (see, for instance, [8, Proposition 3.9]). Having constructed the classifying category, we will now show that it has the structure ofa path category (see [3] for the definition) whose fibrations are precisely those maps whichwe have baptised fibrations in 11. To make the proof less cumbersome, we will often write x = A y (or x = y ) to mean that the type x = A y is inhabited (as in the HoTT book, forinstance). (cid:73) Lemma 12.
Propositional equality is a congruence.
Proof.
The argument is absolutely standard (see, for instance, [12, Chapter 2]). We onlyneed to verify that the standard proof can be performed in our objective type theory.First of all, we have refl to witness that equality is reflexive.Secondly, suppose x ∈ A ‘ B ∈ Type and ‘ p ∈ a = A b . Then from B [ a/x ] beinginhabited we wish to deduce that B [ b/x ] is inhabited as well (the Leibniz principle). Write Q : ≡ Π( B, [ z ] B [ y/x ]) and suppose that t ∈ B [ a/x ]. From x ∈ A, y ∈ A, u ∈ x = A y ‘ Q ∈ Typeand x ∈ A ‘ λ ( B, [ z ] B, [ z ] z ) ∈ Q [ x, x, refl ( A, x ) /x, y, u ]it follows thatΠ( B [ a/x ] , [ z ] B [ b/x ])is inhabited, by s say. So if t ∈ B [ a/x ], then app ( B [ a/x ] , [ z ] B [ b/x ] , s, t ) ∈ B [ b/x ] , as desired.From this symmetry and transitivity follow as well. Indeed, choose P : ≡ x = A a . Since refl ( A, a ) ∈ P [ a/x ], any p ∈ a = A b gives that P [ b/x ] ≡ b = A a is inhabited as well.Furthermore, if p ∈ a = A b and q ∈ b = A c , consider P : ≡ x = A c . Since P [ b/x ] isinhabited, so must be P [ a/x ], using symmetry and the Leibniz principle. (cid:74) (cid:73) Lemma 13.
One can define appropriate terms and types satisfying the rules for contextual Π -types (the rules in Table 4 in the appendix). Proof.
By induction on the length of the context ∆.If ∆ = [], then we can putΠ([] , [] B ) : ≡ B, and λ ([] , [] B, [] t ) : ≡ t, while app ([] , [] B, f, []) : ≡ f. Then app ([] , [] B, λ ([] , [] B, [] t ) , []) ≡ λ ([] t ) ≡ t ≡ t [[] / []] , so we can witness betaconv by refl .If the statement is true for ∆, then we can prove it for ∆ .A = [∆ , y ∈ A ], as follows. WeputΠ(∆ .A, [ ~x ] B ) : ≡ Π(∆ , [ ~y ]Π( A, [ y ] B )) , and λ (∆ .A, [ ~x ] B, [ ~x ] t ) : ≡ λ (∆ , [ ~y ]Π( A, [ y ] B ) , [ ~y ] λ ( A, [ y ] B, [ y ] t )) , while app (∆ .A, [ ~x ] B, f, ( ~a, a )) : ≡ app ( A, [ y ] B, app (∆ , [ ~y ]Π( A, [ y ] B ) , f, ~a ) , a ) . Then we have: app (∆ .A, [ ~x ] B, λ (∆ .A, [ ~x ] B, [ ~x ] t ) , ( ~a, a )) ≡ app ( A, [ y ] B, app (∆ , [ ~y ]Π( A, [ y ] B ) , λ (∆ , [ ~y ]Π( A, [ y ] B ) , [ ~y ] λ ( A, [ y ] B, [ y ] t )) , ~a ) , a ) = app ( A, [ y ] B, λ ( A, [ y ] B, [ y ] t )[ ~a/~y ] , a ) = t [( ~a, a ) /~x ] , using both the induction hypothesis and the previous lemma. (cid:74)(cid:73) Lemma 14.
One can define appropriate terms and types satisfying the rules for contextualidentity types (that is, the rules in Table 3 in the appendix).
Proof.
Suppose Γ , x ∈ A, y ∈ A, u ∈ x = A y, ∆ ‘ P ∈ TypeΓ , x ∈ A, ~z ∈ ∆[ x, x, refl ( A, x ) /x, y, u ] ‘ d ∈ P [ x, x, refl ( A, x ) /x, y, u ]Γ ‘ p ∈ a = A b Γ ‘ ~q ∈ ∆[ a, b, p/x, y, u ] . van den Berg and M. den Besten 11 Writing Q : ≡ Π(∆ , [ ~z ] P ) and s : ≡ λ (∆ , [ ~z ] P, [ ~z ] d )[ x, x, refl ( A, x ) /x, y, u ] , we have: Γ , x ∈ A, y ∈ A, u ∈ x = A y ‘ Q ∈ TypeΓ , x ∈ A ‘ s ∈ Q [ x, x, refl ( A, x ) /x, y, u ]Γ ‘ p ∈ a = A b so we have a term idrec ( A, [ x, y, u ] Q, a, b, p, [ x ] s )in Q [ a, b, p/x, y, u ] and therefore a term app (∆ , [ ~z ] P, idrec ( A, [ x, y, u ] Q, a, b, p, [ x ] s ) , ~q )[ a, b, p/x, y, u ]in P [ a, b, p/x, y, u ], as desired.To complete the proof, we assume a ∈ A and ~w ∈ ∆[ a, a, refl ( A, a ) /x, y, u ] and we haveto calculate: app (∆ , [ ~z ] P, idrec ( A, [ x, y, u ] Q, a, a, refl ( A, x ) , [ x ] s ) , ~w )[ a, a, refl ( A, a ) /x, y, u ] = app (∆ , [ ~z ] P, λ (∆ , [ ~z ] P, [ ~z ] d [ a/x ]) , ~w )[ a, a, refl ( A, a ) /x, y, u ] = d [ a, ~w/x, ~z ] . (cid:74)(cid:73) Theorem 15.
The syntactic category associated to our type theory is a path category.
Proof.
This follows from the previous lemma and the main result of [1]. (cid:74) Π -types We will now prove that the classifying category is a path category with homotopy Π-types(see [4] for the definition). We will give a categorical proof heavily exploiting the results from[4]. (cid:73)
Definition 16.
We say that a class of fibrations D in a path category is a class of displaymaps with weak (strong) homotopy Π -types if the following conditions are satisfied:Every identity map lies in D .The pullback of a map in D along any other map can be found in D .For every composable d, e ∈ D the weak (strong) homotopy Π-type Π e ( d ) exists and canbe found in D . (cid:73) Lemma 17.
The display maps in the classifying category form a class of display mapsweak homotopy Π -types, which will be strong as soon as function extensionality holds. Proof.
This is a standard exercise in translating type-theoretic definitions in categoricalterms. Note that by function extensionality we mean Axiom 2.9.3 from the HoTT book[12]. (cid:74)(cid:73)
Lemma 18.
Let D be a class of display maps with weak (strong) homotopy Π -types in apath category C . Write I for the class of isomorphisms in C . Then D ∪ I is a class of displaymaps with weak (strong) homotopy Π -types as well. Proof.
Let d : X −→ I be a map in D and let i : I −→ J be a map in I . We claim that theweak (strong) homotopy Π-type Π d ( i ) exists and can be found in D . It is not difficult toverify that id : X −→ J is a weak (strong) homotopy Π-type for d and i . Now note that id : X −→ J is the pullback of d along i − , hence isomorphic to some d : X −→ J in D ,which is therefore a weak (strong) homotopy Π-type for d and i as well. If on the otherhand i : X −→ I is a map in I and f : I −→ J is an arbitrary map, then it is easy to seethat 1 : J −→ J is a weak (strong) homotopy Π-type for i and f . The lemma follows sinceisomorphisms are fibrations and are closed under pullbacks. (cid:74)(cid:73) Lemma 19.
Let D be a class of display maps with weak (strong) homotopy Π -types in apath category C . Write D for the closure of D under composition. Then for every composable d ∈ D and f ∈ D , the weak (strong) homotopy Π -type Π f ( d ) exists. Proof.
Consider maps d : X −→ I , f : I −→ J and e : J −→ K , with d, e ∈ D and f ∈ D .By induction, it suffices to show that the weak (strong) homotopy Π-type Π ef ( d ) exists andcan be found in D , whenever the weak (strong) homotopy Π-type Π f ( d ) exists and can befound in D . Take the weak (strong) homotopy Π-type Π e Π f ( d ) and note that it can be foundin D . By Lemma 5.3 of [4], Π e Π f ( d ) is a weak (strong) homotopy Π-type for d and ef . (cid:74)(cid:73) Lemma 20.
Let D be a class of display maps with weak (strong) homotopy Π -types in apath category C . Write D for the closure of D under composition. Then for every composable f, g ∈ D , the weak (strong) homotopy Π -type Π f ( g ) exists. Proof.
Consider maps f : I −→ J , g : Y −→ I and d : X −→ Y , with f, g ∈ D and d ∈ D .By induction, it suffices to show that the weak (strong) homotopy Π-type Π f ( gd ) exists,whenever the weak (strong) homotopy Π-type Π f ( g ) exists. Take the pullback Q X (Π f ( g )) × J I Y e dε Y such that e lies in D . By pullback pasting, the pullback of a map in D along any other mapcan be found in D , so in particular π : (Π f ( g )) × J I −→ Π f ( g ) can be found in D . By 19,Π π ( e ) exists and by (the proof of) Proposition 5.2 of [4], Π π ( e ) is a weak (strong) homotopyΠ-type for gd and f . (cid:74)(cid:73) Lemma 21.
Write F and I for the classes of fibrations and isomorphisms in a pathcategory C . Let D be a class of display maps with weak (strong) homotopy Π -types andsuppose that F is the closure of D ∪ I under composition. Then all weak (strong) homotopy Π -types exist in C . Proof.
This follows from 20, since we may assume that D = D ∪ I by 18. (cid:74)(cid:73)
Theorem 22.
The classifying category is a path category with weak homotopy Π -types,which will be strong as soon as function extensionality holds. Proof.
This follows from 17 and 21 (cid:74) . van den Berg and M. den Besten 13
We have shown that by eliminating the notion of definitional equality from type theory andby replacing all computation rules by propositional equalities, we obtain a system for whichtype checking is efficiently decidable and which has a natural homotopy-theoretic semantics.This semantics provides strong evidence that most of what happens in the HoTT book [12]can be formalised in a suitable extension of such an objective type theory (with univalentuniverses and appropriate higher inductive types, for instance). In fact, we think it is verylikely that this can be done, but a detailed verification of such a claim would be an enormousamount of work.From a theoretical perspective there are two important questions. First of all, onewould like to understand this phenomenon theoretically by proving an appropriate coherencetheorem showing that traditional type theory is conservative over objective type theory.Even formulating such a statement in a mathematically precise way is a non-trivial task;nevertheless, work in this direction has already been done by Valery Isaev [9] and RafaëlBocquet [5].Another important question is whether objective type theory enjoys homotopy canonicity ;that is, can one effectively extract from a derivation of ‘ t ∈ N in objective type theory anatural number n , a term p and a derivation of ‘ p ∈ t = N succ n (0)? Kapulkin and Sattlerhave announced a proof of this result for ordinary homotopy type theory: from what we haveseen of the proof, we consider it likely that this could be adapted to objective type theory aswell, although questions surrounding the effectivity of the proof might remain.Finally, there remains the question of whether objective type theory can be of practicalimportance, as a proof assistant, for instance. The fact that type checking is efficientlydecidable would address some of the difficulties pointed out by Geuvers and Wiedijk. Clearly,by storing all the conversions in proof terms, these will become a lot longer than usual andone would have to think carefully about how to manage this complexity. Nevertheless, thesuccess of proof assistants such as HOL, which do store such explicit conversions, means thatit should be possible to make such systems practically useful. References B. van den Berg. Path categories and propositional identity types.
ACM Trans. Comput. Log. ,19(2):Art. 15, 32, 2018. doi:10.1145/3204492 . B. van den Berg. Univalent polymorphism.
Ann. Pure Appl. Logic , 171(6):102793, 29, 2020. doi:10.1016/j.apal.2020.102793 . B. van den Berg and I. Moerdijk. Exact completion of path categories and algebraic set theory.Part I: Exact completion of path categories.
J. Pure Appl. Algebra , 222(10):3137–3181, 2018. doi:10.1016/j.jpaa.2017.11.017 . M. den Besten. On homotopy exponentials in path categories. arXiv:2010.14313, 2020. R. Bocquet. Coherence of strict equalities in dependent type theories. arXiv:2010.14166, 2020. T. Coquand and N.A. Danielsson. Isomorphism is equality.
Indag. Math. (N.S.) , 24(4):1105–1120, 2013. doi:10.1016/j.indag.2013.09.002 . H. Geuvers and F. Wiedijk. A logical framework with explicit conversions. In
Proceedingsof the Fourth International Workshop on Logical Frameworks and Meta-Languages (LFM2004) , volume 199 of
Electron. Notes Theor. Comput. Sci. , pages 33–47. Elsevier Sci. B. V.,Amsterdam, 2008. doi:10.1016/j.entcs.2007.11.011 . M. Hofmann. Syntax and semantics of dependent types. In
Semantics and logics of computation(Cambridge, 1995) , volume 14 of
Publ. Newton Inst. , pages 79–130. Cambridge Univ. Press,
Cambridge, 1997. URL: http://dx.doi.org/10.1017/CBO9780511526619.004 , doi:10.1017/CBO9780511526619.004 . V. Isaev. Morita equivalences between algebraic dependent type theories. arXiv:1804.05045,2018. G. Kreisel. Foundations of intuitionistic logic. In
Logic, Methodology and Philosophy of Science(Proc. 1960 Internat. Congr.) , pages 198–210. Stanford Univ. Press, Stanford, Calif., 1962. L.C. Paulson. Formalising mathematics in simple type theory.
CoRR , abs/1804.07860,2018. To appear in
Reflections on the Foundations of Mathematics , Springer Verlag. URL: http://arxiv.org/abs/1804.07860 , arXiv:1804.07860 . The Univalent Foundations Program.
Homotopy type theory—univalent foundations of math-ematics . The Univalent Foundations Program, Princeton, NJ; Institute for Advanced Study(IAS), Princeton, NJ, 2013. R. Statman. The typed λ -calculus is not elementary recursive. Theoret. Comput. Sci. ,9(1):73–81, 1979. doi:10.1016/0304-3975(79)90007-0 . . van den Berg and M. den Besten 15 A Rules for objective type theory
Table 1
Rules for identity types Formation RuleΓ ‘ a ∈ A Γ ‘ b ∈ A Γ ‘ a = A b ∈ TypeIntroduction RuleΓ ‘ a ∈ A Γ ‘ refl ( A, a ) ∈ a = A a Elimination RuleΓ , x ∈ A, y ∈ A, u ∈ x = A y ‘ P ∈ TypeΓ ‘ p ∈ a = A b Γ , x ∈ A ‘ d ∈ P [ x, x, refl ( A, x ) /x, y, u ]Γ ‘ idrec ( A, [ x, y, u ] P, a, b, p, [ x ] d ) ∈ P [ a, b, p/x, y, u ]Computation RuleΓ , x ∈ A, y ∈ A, u ∈ x = A y ‘ P ∈ TypeΓ ‘ a ∈ A Γ , x ∈ A ‘ d ∈ P [ x, x, refl ( A, x ) /x, y, u ]Γ ‘ idconv ( A, [ x, y, u ] P, a, [ x ] d ) ∈ idrec ( A, [ x, y, u ] P, a, a, refl ( A, a ) , [ x ] d ) = P [ a,a, refl ( A,a ) /x,y,u ] d [ a/x ] Table 2
Rules for Π-types Formation RuleΓ ‘ A ∈ Type Γ , x ∈ A ‘ B ∈ TypeΓ ‘ Π( A, [ x ] B ) ∈ TypeIntroduction RuleΓ , x ∈ A ‘ t ∈ B Γ ‘ λ ( A, [ x ] B, [ x ] t ) ∈ Π( A, [ x ] B )Elimination RuleΓ ‘ f ∈ Π( A, [ x ] B ) Γ ‘ a ∈ A Γ ‘ app ( A, [ x ] B, f, a ) ∈ B [ a/x ]Computation RuleΓ , x ∈ A ‘ t ∈ B Γ ‘ a ∈ A Γ ‘ betaconv ( A, [ x ] B, a, [ x ] t ) ∈ app ( A, [ x ] B, λ ( A, [ x ] B, [ x ] t ) , a ) = B [ a/x ] t [ a/x ] . van den Berg and M. den Besten 17 B Admissable rules for objective type theory
Table 3
Rules for conextual identity typesFormation RuleΓ ‘ a ∈ A Γ ‘ b ∈ A Γ ‘ a = A b ∈ TypeIntroduction RuleΓ ‘ a ∈ A Γ ‘ refl ( A, a ) ∈ a = A a Elimination RuleΓ , x ∈ A, y ∈ A, u ∈ x = A y, ∆ ‘ P ∈ TypeΓ , x ∈ A, ~z ∈ ∆[ x, x, refl ( A, x ) /x, y, u ] ‘ d ∈ P [ x, x, refl ( A, x ) /x, y, u ]Γ ‘ p ∈ a = A b Γ ‘ ~q ∈ ∆[ a, b, p/x, y, u ]Γ ‘ idrec ( A, [ x, y, u ]∆ , [ x, y, u, ~z ] P, a, b, p, ~q, [ x, ~z ] d ) ∈ P [ a, b, p, ~q/x, y, u, ~z ]Computation RuleΓ , x ∈ A, y ∈ A, u ∈ x = A y ‘ P ∈ TypeΓ , x ∈ A, ~z ∈ ∆[ x, x, refl ( A, x ) /x, y, u ] ‘ d ∈ P [ x, x, refl ( A, x ) /x, y, u ]Γ ‘ a ∈ A Γ ‘ ~w ∈ ∆[ a, a, refl ( A, a ) /x, y, u ]Γ ‘ idconv ( A, [ x, y, u ] P, a, [ x ] d ) ∈ idrec ( A, [ x, y, u ]∆ , [ x, y, u, ~z ] P, a, a, refl ( A, a ) , ~w, [ x, ~z ] d ) = P [ a,a, refl ( A,a ) ,~w/x,y,u,~z ] d [ a, ~w/x, ~z ] Table 4
Rules for contextual Π-types Formation Rule ‘ Γ , ∆ Ctxt Γ , ~x ∈ ∆ ‘ B ∈ TypeΓ ‘ Π(∆ , [ ~x ] B ) ∈ TypeIntroduction RuleΓ , ~x ∈ ∆ ‘ t ∈ B Γ ‘ λ (∆ , [ ~x ] B, [ ~x ] t ) ∈ Π(∆ , [ ~x ] B )Elimination RuleΓ ‘ f ∈ Π(∆ , [ ~x ] B ) Γ ‘ ~a ∈ ∆Γ ‘ app (∆ , [ ~x ] B, f,~a ) ∈ B [ ~a/~x ]Computation RuleΓ , ~x ∈ ∆ ‘ t ∈ B Γ ‘ ~a ∈ ∆Γ ‘ betaconv (∆ , [ ~x ] B, a, [ ~x ] t ) ∈ app (∆ , [ ~x ] B, λ (∆ , [ ~x ] B, [ ~x ] t ) ,~a ) = B [ ~a/~x ] t [ ~a/~x~a/~x