<<

arXiv:1603.03092v2 [math.LO] 25 Sep 2017 e od n phrases. and words Key ssrcue es hsbscpcuealw st envision to 2010 us allows Date picture found basic -theoretic This in sets. how structured to ther as are similar structures types, mathematical homotopy UF In tured types. homotopy be to h nvln onain fMteais(F [ (UF) of Foundations Univalent The Applications and Examples FOL for System 6. Deductive FOL of 5. Homotopy FOL of 4. MLTT in FOLDS of 3. Semantics FOLDS on 2. Preliminaries 1. Introduction etme 7 2017. 27, September : ahmtc ujc Classification. Subject Mathematics tutrso oooytps iia ohwfis-re log first-order how to similar types, homotopy on structures Abstract. noissgaue oino eedn ot ln h lin the an along of sorts notion dependent a of as well notion as a signatures its into ah ete en eutv system deductive struc a transport define then and We path, r trivial path. types, the a out as picking interpreted relations sorts the with otsrcue h eatc o FOL for semantics reflexiv The sorts, isomorphism structure. port signatures: these within sorts utv ytmfrsc oi,wihw alfis-re log first-order call we syntax, which the develop logic, We a such (FOL sets. for on system structures ductive define to us allows nwihteihbtnso smrhs ot elyd beha do of really rules the sorts of isomorphism soundness prove of and inhabitants the which in aeoisaeaimtzbei FOL stri in precategories, axiomatizable that are prove categories we application, an as nally, = ∼ .Tesna fFOL of syntax The ). IS-RE OI IHISOMORPHISM WITH LOGIC FIRST-ORDER h nvln onain eursalgcta losu to us allows that logic a requires Foundations Univalent The nvln onain,CtgrclLgc oooyTp T Type Homotopy Logic, Categorical Foundations, Univalent = ∼ h lvlo ahsr.Scn,b pcfigtrenwlogical new three specifying by Second, sort. each of -level IIRSTSEMENTZIS DIMITRIS = ∼ = ∼ xed FOL extends Introduction = ∼ 39,0B5 32,03C99. 03B22, 03B15, 03G99, Contents D ∼ = = ∼ . ihrsett t oooysmnis Fi- semantics. homotopy its to respect with = ∼ 1 ste endi oooytp theory type homotopy in defined then is = D ntowy.Frt yincorporating by First, ways. two in = ∼ o FOL for Uni13 tctgre n univalent and categories ct ∼ = t rdctsadtrans- and predicates ity cwt qaiy(FOL equality with ic uea rnpr along transport as ture flxvt rdctsas predicates eflexivity htecdstesense the encodes that so akisFOLDS Makkai’s of es aeterbscobjects basic their take ] elk like ve cwt isomorphism with ic oe hoyi which in theory model a toste r encoded are they ations eatc n de- and semantics fr noe sstruc- as encoded efore define heory. = ) 61 55 47 35 25 14 3 1 2 DIMITRIS TSEMENTZIS

mathematical objects are no longer described as structured sets, but rather as struc- tured homotopy types. In this paper we develop a logic through which this process can be carried out. We will call it first-order logic with isomorphism (FOL=∼) in order to reflect the following fundamental idea of UF: the primitive notion of equality in UF is itself a structure that behaves like the structure of isomorphisms between structures, rather than the fact of identity between sets. The syntax of FOL=∼ will be based on an extension of the syntax of Makkai’s FOLDS (First-Order Logic with Dependent Sorts) [Mak95]. The signatures of FOLDS can be understood as inverse categories where the arrows encode dependencies between the objects (understood as “sorts”). The key of FOL=∼ to FOLDS is to add a notion of an “h-level” to each sort as well as notions of “isomorphism sorts”, “reflexivity predicates” and “transport structure” understood as logical sorts (i.e. with a fixed denotation) defined on top of the non-logical sorts in accordance with the latter’s h-level. It is helpful to think of the syntax of FOL=∼ as standing to FOLDS in the same that the syntax of first-order logic with equality (FOL=) stands to plain first-order logic. To add equality to a first-order signature Σ, one simply adds a with a certain fixed denotation. The analogous process for a FOLDS signature L is carried out in terms of an “isomorphism completion” operation on inverse categories which attaches logical sorts to pre-existing sorts in L in a manner compatible with their h-level. The intended semantics for FOL=∼ is in UF, where in particular “isomorphism sorts” are interpreted as path spaces (if one thinks in terms of abstract homotopy theory) or identity types (if one thinks in terms of homotopy ). The basic idea of the “homotopy semantics” of FOL=∼ is the following: non-logical sorts of h-level m are interpreted as (dependent functions landing in) types of h-level m and we make this precise by interpreting FOL=∼ into a version of “book HoTT”, i.e. the outlined in [Uni13]. The isomorphism sorts that have been added to the syntax of FOL=∼ are then interpreted as identity types, the reflexivity predicates are interpreted as predicates picking out refl and transport structure is interpreted as (a relational version of) the transport trans induced by a given path. Finally, we present a deductive system D=∼ on the syntax of FOL=∼ that can justify its homotopy semantics. It is based on a standard for first-order logic to which we add three rules: a rule asserting the existence of the “reflexivity” isomorphisms, a rule specifying that “transport along reflexivity” does nothing and, crucially, a propositional version of the J-rule of MLTT. We can then prove that the deductive system is sound with respect to the above-sketched semantics, which is the main result of this paper. Related Work. Our work connects to several strands of ongoing work in UF. The connection between inverse categories and homotopy theory is well-known and has been developed extensively by Shulman in [Shu15a,Shu15b] and our work builds on this connection, albeit from a more syntactic viewpoint, rather than within the categorical semantics of HoTT. Our framework also provides a general definition of a FIRST-ORDERLOGICWITHISOMORPHISM 3

(logical) signature for UF and could thus be used to generalize the Structure Identity Principle of [Uni13] as indeed has been sketched in [ANS14, Tse17]. Formalizations of in the style of FOLDS has also been carried out by Ahrens in UniMath [VAG+] and his formalization overlaps with some of the material of Sec- tion 6. Furthermore, our system FOL=∼ (as well as FOLDS) can be thought of as a dependently-typed first-order logic with specific features that make it suitable for UF, and in that regard it connects to the work of Palmgren [Pal16]. Finally, although we do not (yet) adopt this point of view, FOL=∼ can be thought of as a proposal to add a “logic layer” to HoTT along the lines of so-called logic-enriched type theory [GA06] and therefore is connected to the work of [PL15]. Outline of the Paper. In Section 1 we introduce the syntax of FOLDS as well as a proof system DFOLDS for this syntax and state some preliminary results. In Section 2 we define an of the syntax of FOLDS into MLTT via a direct interpretation of the raw syntax of the former system into the raw syntax of the latter. In Section 3 we build on the syntax of FOLDS to define the syntax of FOL=∼. In Section 4 we define the homotopy semantics of FOL=∼ by defining an interpretation of the syntax of FOL=∼ into HoTT, building on the interpretation of FOLDS into MLTT. In Section 5 we define a proof system D=∼ for FOL=∼ and prove soundness for D=∼ with respect to our homotopy semantics. Finally, in Section 6 we show how precategories, strict categories and univalent categories can be axiomatized in terms of FOL=∼. 1. Preliminaries on FOLDS We will assume familiarity with the basics of categorical logic as well as of in- tensional Martin-Löf Type Theory and its homotopy interpretation. For category- theoretic background [ML98] remains the standard ; for the basics of de- pendent type theory we recommend [ML84, Hof97]; for the homotopy interpretation and an introduction to the Univalent Foundations see [Uni13,KLV14] and references therein. We will now present in more detail the basic syntax of FOLDS inspired by Makkai’s original presentation in [Mak95]. Definition 1.1 (Inverse Category). An inverse category is a category L such that (1) L has no non-identity endomorphisms (2) L is skeletal (3) For any object K there is a finite number of arrows with domain K Remark 1.2. An inverse category is so-named because it can be thought of as a category in which all arrows “go in one direction” and in particular a category in which all arrows “point downwards”. Condition (3) in Definition 1.1 (which Makkai called “finite fan-out”) ensures that every object in an inverse category is only a “finite path” away from an object at the “bottom”. This allows us to carry out inductive definitions on inverse categories as indeed we will be doing throughout this paper.

Notation. We write N∞ for the set N ∪ {∞}. We will sometimes write K ∈ L as an abbreviation for K ∈ ObL and we write L(K,K′) for the morphisms from K to 4 DIMITRIS TSEMENTZIS

′ ′ K in L. For any arrow f : K → K in an inverse category L we will write Kf for its K′. For any object K ∈ ObL we write K//L for the set (indeed, cosieve) of non-identity arrows with domain K. The objects of any inverse category L can be stratified into levels, defined (inductively) as follows: 0 if K is the domain only of 1  K l(K)=  sup l(Kf ) + 1 otherwise f∈K//L  Terminology. We will call l(K) the level of K. We will generally refer to the objects of L as sorts. We call a non-identity arrow f : K → A top-level (for K) if it does not factor through another arrow, i.e. if there is no non-identity arrows h, k ∈ MorL such that f = hk and we write top(K) for the set of top-level arrows of a sort K.

Definition 1.3. A proper order < on an inverse category is a pair (

Notation. For a proper order on L we will write simply K

Definition 1.4 (Inverse category over (O, M)). An inverse category over (O, M) (or (O, M)-inverse category) is an inverse category L such that ObL ⊂ O, MorL ⊂ M ∐{1K | K ∈ O} and the identity on an object K ∈ ObL is given by the 1K.

Definition 1.5 (FOLDS signature over (O, M)). A FOLDS signature over (O, M) (or (O, M)-FOLDS-signature) is a pair (L,<) where L is an (O, M)-inverse cat- egory and < is a proper order on L. We write FOLDS(O, M) for the category whose objects are the FOLDS signatures over (O, M) and whose arrows are the order- preserving functors between them, i.e. an arrow I : (L,<) → (L′,<′) is given by a functor I : L→L′ such that K

Terminology. Once fixed we will generally leave the choice of (O, M) implicit and speak simply of FOLDS signatures and write simply FOLDS for the associated cat- egory. We refer to morphisms in FOLDS as FOLDS morphisms. We also write FOLDSi for the important subcategory of FOLDS that consists of those FOLDS morphisms I : L→L′ that are full, faithful and level-preserving in the sense that l(K) = l(I(K)). We say that a FOLDS signature is finite if its underlying inverse category is finite.

Remark 1.6. The importance of the morphisms of FOLDSi is that they define inter- pretations of the syntax associated to a FOLDS signature, as we will see below.

Example 1.7. Let Lgraph denote the following FOLDS signature: A

d c  O As the name suggests this would be the signature useful to talk about graphs, where A would encode the “edges” between previously declared “vertices” of sort O, d the picking out the “domain” of an arrow and c the map picking out the “codomain” of an arrow. A proper order on Lgraph would be given by O < A, c

Example 1.8. Let Lrg denote the following FOLDS signature: I

i  A

c d  O subject to the relation di = ci. Intuitively, this corresponds to the signature for reflexive graphs, where I is a unary predicate that can only be “asked” of an “arrow” in A that we already know is a loop. Lrg will serve as a running example throughout this paper. A proper order on Lrg would be given by O

Definition 1.9 (Contexts, Sorts and Context Morphisms). Let L be a FOLDS sig- nature. We define the syntactic type theory T TL of L as follows. The syntax of T TL is the following: ′ SortL K,K , ... ::= A(xf )f∈A//L (A ∈ ObL) Var x, y, ... ::= V

ConL Γ, ∆, ... ::= ∅ | Γ, x: K We write |Γ| for the set of variables that appear in a context Γ. The judgments of T TL are the following:

• Γ ok • Γ ⊢ K Sort • Γ ⊢ x: K

We write JudL for the judgment expressions of T TL. The structural rules of T TL are the following: Γ ok Γ ⊢ K Sort (con-∅) (con-ext), x#|Γ| ∅ ok Γ, x: K ok Γ, ∆ ok Γ ⊢ K Sort Γ, x: K, ∆ ok (con-wk) (ax) Γ, ∆ ⊢ K Sort Γ, x: K, ∆ ⊢ x: K For every K ∈ ObL we have the following formation rule

Γ ⊢ xf : Kf (xpf ) f∈K//L (K-form) Γ ⊢ K(xf )f∈K//L Sort with the understanding that if K//L = ∅ there is nothing above the line except Γ ok (which means that objects of level 0 in L are types in the empty context), and the notation Γ ⊢ xf : Kf (xpf )  f∈K//L indicates the list of judgments

Γ ⊢ xf1 : Kf1 (xpf1 ) . . . Γ ⊢ xfn : Kfn (xpfn ) where f1,...,fn are all the arrows in K//L. A context of L (or L-context) is a well-formed context in T TL, i.e. a context Γ such that Γ ok is derivable in T TL. A sort of L (or L-sort) is a well-formed sort in T TL, i.e. a sort K such that Γ ⊢ K Sort is derivable in T TL. FIRST-ORDERLOGICWITHISOMORPHISM 7

Let Γ and ∆ = x1 : K1,...,xn : Kn(x1,...xn−1) be L-contexts. A well-formed context morphism Γ ⇒ ∆ in L is given by the following derivable judgments

Γ ⊢ y1 : K1

Γ ⊢ y2 : K2[y1/x1] . .

Γ ⊢ yn : Kn[y1/x1,...,yn−1/xn−1] Notation. We will usually write simply O for a sort O ǫ, i.e. for any sort O in L of level 0. We will write α: Γ ⇒ ∆ to indicate a context morphism, where α will be the list of variables y = (y1,...,yn) as in the above definition. Whenever convenient we will write simply A(x) for A(xf )f∈A//L. For a given sort K = A(x) with all variables appearing in the context ∆ we will write α(K) for the sort obtained from K by substituting all variable in x with those in y. (That this operation preserves well-formedness of sorts is proved as Lemma 1.14 below.) We will use the notation ≡ to refer to syntactic equality between expressions. Remark 1.10. What we call a “judgment” above is usually called a “judgment-in- context” or a “sequent” but we will call it simply a judgment in order to avoid clashing with the term “sequent” in Definition 1.15 below. Remark 1.11. Note that if L is infinite (i.e. has an infinite number of objects), then T TL has an infinite number of rules (since there is a (K-form) rule for every K in L). However it is still possible that T TL is equivalent to (in an appropriate sense) a finitely presentable (in an appropriate sense) type theory even when L is infinite. We will take up this important point in 4.18 below.

Example 1.12. Consider T TLrg . It has the following (raw) sort expressions

SortLrg = {O ǫ}∪{A(x, y) ⊢ x, y ∈ V } Its (raw) contexts therefore are of the following form (where we write simply O for O ǫ): x: O, f : A(x, y),g : A(z,w) Now we would expect to be able to derive that A(x, y) is a well-formed sort for any x, y : O. We outline how this derivation goes, starting with (con-∅): ∅ ok (O-form) ∅ ⊢ O Sort (con-ext) x: O ok (O-form) x: O ⊢ O Sort (con-ext) x: O,y : O ok (ax) x: O,y : O ⊢ x: O x: O,y : O ⊢ y : O (A-form) x: O,y : O ⊢ A(x, y) Sort

Now, as an example of a context morphism in Lrg let ∆ = x: O,y : O, f : A(x, y) and let Γ = z : O,g : A(z, z). Then we have a context morphism α = (z,z,g): Γ ⇒ ∆ 8 DIMITRIS TSEMENTZIS

given by the following judgments Γ ⊢ z : O Γ ⊢ z : O[z/x] Γ ⊢ g : A(x, y)[z/x][z/y] all of which are derivable since O[z/x] ≡ O and A(x, y)[z/x][z/y] ≡ A(z, z).

Lemma 1.13. If Γ ⊢ x: K is derivable in T TL then x: K appears in Γ.

Proof. The only way to derive a judgment of the form Γ ⊢ x: K in T TL is through (ax) which means that if such a judgment is derivable then Γ ≡ Γ′, x: K, ∆ for some contexts Γ′, ∆ which means that x: K appears in Γ, as required.  Lemma 1.14. If α: Γ ⇒ ∆ is a context morphism and ∆ ⊢ K Sort is derivable then so is Γ ⊢ α(K) Sort. In other words, the following rule is admissible in T TL: α: Γ ⇒ ∆ ∆ ⊢ K Sort (Sort-sub) Γ ⊢ α(K) Sort Proof. Let α(K) ≡ A(x). By Lemma 1.13 every variable in x appears in Γ and therefore the whole list of judgments needed to apply (K-form) will be derivable and therefore α(K) will be a sort in context Γ, as required. 

Definition 1.15 (Formulas and Sequents). We define the logical type theory LT TL of L as follows. The syntax of LLTL extends T TL by adding a of formulas:

FormulasL φ, ψ, ... ::= ⊥|⊤| φ ∧ ψ | φ ∨ ψ | φ → ψ | ∀x: K.φ | ∃x: K.φ For any formula φ we write FV(φ) for the set of variables that appear in φ unbound by ∃ or ∀, and we consider formulas only up to α-equivalence (i.e. up to consistent renaming of their bound variables). The judgments of LT TL are those of T TL together with: • Γ ⊢ φ formula

We once again write JudL for the judgment expressions of LT TL. The structural rules of LT TL are those of T TL together with: Γ, ∆ ok Γ ⊢ φ formula (form−wk) Γ, ∆ ⊢ φ formula

The formation rules of LT TL are those of T TL together with: Γ ok Γ ok (⊥−form) (⊤−form) Γ ⊢ ⊥ formula Γ ⊢ ⊤ formula Γ ok Γ ⊢ φ formula Γ ⊢ ψ formula (∗−form) Γ ⊢ φ ∗ ψ formula Γ ok Γ, x: K ⊢ φ formula (Q−form) Γ ⊢ Qx: K.φ formula FIRST-ORDERLOGICWITHISOMORPHISM 9 where ∗ = ∨, ∧, → and Q = ∃, ∀. We define φ to be an L-formula in context Γ whenever Γ ⊢ φ formula

is derivable in LT TL. A sequent is a syntactic entity of the form Γ | φ ⇒ ψ where both φ, ψ are L-formulas in context Γ. Given a context morphism α = (y1,...,yn): Γ ⇒ ∆ and a L-formula φ in context ∆ we define the formula expression α(φ) inductively as follows: • α(⊤)= ⊤ • α(⊥)= ⊥ • α(φ ∗ ψ)= α(φ) ∗ α(ψ), for ∗ = ∨, ∧, → • α(Qx: K.φ)= Qx: α(K).α(φ), for Q = ∃, ∀. Remark 1.16. It is reasonable to wonder whether we can generate through an inductive process every FOLDS signature L and therefore generating all LT TL in parallel with that process. Indeed this can be done, as has been outlined in [TW17] and (in a slighlty different form) in [Pal16].

Lemma 1.17. The following rule is admissible in LT TL: α: Γ ⇒ ∆ ∆ ⊢ φ formula (formula−sub) Γ ⊢ α(φ) formula Proof. Straightforward by structural induction over formula expressions.  Notation. We will usually write a L-formula φ in context Γ as Γ.φ. For formulas of the form ∃x: K(y).⊤ we will use the shorter and more standard form K(y).

Example 1.18. In LT TLrg we can derive as in Example 1.12 x: O,y : O ⊢ A(x, y) Sort from which we get x: O,y : O, f : A(x, y) ok By applying (⊤−form) we get x: O,y : O, f : A(x, y) ⊢ ⊤ formula and then by applying (∃) we get x: O,y : O ⊢ ∃f : A(x, y).⊤ formula which we will write, as suggested above, simply as A(x, y) with the understanding of course that this formula is stating that there exists an “inhabitant” of the sort A(x, y). This notation thus makes more sense in situations where the given sort is best understood as a predicate, as is the case with the “identity predicate” I in Lrg. Similar to what we just did we have a well-formed formula ∃τ : I(f, x).⊤ (in context x: O, f : A(x, x)) which we will sugar as I(f, x), and which can be understood as saying that there exists a witness to the fact that f is an identity “arrow” on the “object” x. 10 DIMITRIS TSEMENTZIS

All the definitions so far have depended on a specific choice of a proper order on L. We would like to know that this choice is irrelevant. The following definitions aim at making this precise by defining a notion of interpretation between type theories of a very general kind. The reader familiar and comfortable with notions such as derivation, admissibility etc. may skip the next few definitions (up to Corollary 1.27) which play no essential role in this paper other than to make precise the sense in which isomorphic FOLDS signatures give rise to equivalent (syntactic and logical) type theories. Definition 1.19. A ML type theory is a triple T T =(S, J, R) where:

• S =(S1,...,Sk) is a list of sets called syntactic components • J = (1,J1,...,Jl) is a list of judgments where 1 is a singleton and each

Ji = Sα(1) ×···× Sα(mi) with 1 ≤ α(j) ≤ k for each 1 ≤ j ≤ mi and mi ≥ 1. • R = (Ri)i∈N is a (possibly infinite) list of rules where each Ri is a (possibly partial) function

Jβ(1) ×···× Jβ(ri) → Jni

with 1 ≤ β(j), n1 ≤ l and ri ≥ 0 with the understanding that Ri =1 → Jni if ri = 0.

Example 1.20. For any FOLDS signature L, T TL is an ML type theory (SL,JL, RL) where

• SL =(SortL, Var, ConL) • JL = (1, ConL, ConL × SortL, ConL × Var × SortL) • RL = ((con-∅), (con-ext), (con-wk), (ax)) ∐ ((K-form)K∈L). As an example of how these rules can be defined as (partial) functions we have

(con-∅): 1 → ConL defined by (con-∅)(∗)= ∅ (where ∗ is the unique of 1).

To obtain LT TL we add the syntactic class of FormulasL to SL, a judgment of the form ConL × FormulasL to JL and the logical rules to RL.

Definition 1.21. Let T T =(S, J, R) be a ML type theory and let σ ∈ Jγ(1) ×···× Jγ(m) (for some 1 ≤ γ(i) ≤ l) and τ ∈ Jm for some 1 ≤ m ≤ l. A derivation in T T n is a list D =(d1,...,dn) ∈ R such that

dn ◦···◦ d1(σ)= τ

A function F : Jβ(1) ×···× Jβ(ri) → Jni is an admissible rule in T T (or simply

admissible in T T ) if for every σ ∈ Jβ(1) ×···× Jβ(ri) for which F is defined there is a derivation in T T from σ to F (σ). Definition 1.22. Let T T =(S, J, R) and T T ′ =(S′,J ′, R′) be ML type theories. An interpretation I : T T → T T ′ of ML type theories consists of

′ ′ • A family of functions (Ii : Si → Sj)1≤i≤k,1≤i≤k such that ′ • I(R1) is admissible in T T FIRST-ORDERLOGICWITHISOMORPHISM 11

′ • I(Rn) is admissible in T T given that each of I(R1),...,I(Rn−1) are also admissible

where if Ri : Jβ(1) ×···×Jβ(ri) → Jni we define I(Ri): I(Jβ(1))×···×I(Jβ(ri)) → I(Jni ) by the obvious induced action whenever the domain is in the of I and undefined otherwise.

Definition 1.23. There is an obvious identity interpretation 1T T given by the on S and given two interpretations I : T T → T T ′ and J : T T ′ → T T ′′ we get the composite interpretation J ◦ I defined by the composite function J ◦ I : S → S′′. We thus obtain a category MLTT whose objects are ML type theories and morphisms are the interpretations. We say that two ML type theories are bi-interpretable if they are isomorphic in MLTT. ′ Problem 1.24. For any morphism I : L→L in FOLDSi to construct an interpre- ∗ tation I : LT TL → LT TL′ ∗ Construction 1.25. We define I : SortsL → SortsL′ by

A(xf )f∈A//L 7→ I(A)(xI(f))f∈A//L (1) which is well-defined since I is assumed full and faithful which means that A//L is bijective to I(A)//L′. For the variables and contexts we define the obvious maps. Lastly, to see that I∗ does indeed define an interpretation we need to show that for ∗ each rule R of LT TL we have that I (R) is admissible in LT TL′ which is entirely straightforward and left to the reader. ∗ Proposition 1.26. The assignment L 7→ LT TL and I 7→ I defines a functor

LT T : FOLDSi → MLTT Proof. Immediate from Construction 1.25.  We can now make precise the sense in which the order on a FOLDS signature L is irrelevant to LT TL. Corollary 1.27. Let I : L→L′ be an isomorphism of FOLDS signatures. Then LT TL and LT TL′ are bi-interpretable. Over any FOLDS signature L we can now define a deductive system that gives us a notion of provability, and which is essentially an adaptation of a standard deductive system for FOL=. For added generality (i.e. to be able to work in fragments of FOLDS that do not contain all the logical connectives and quantifiers, namely the regular and coherent fragments) we define the deductive system as a sequent calculus. cl Definition 1.28 (DFOLDS, DFOLDS). We assume that every sequent that appears below is a well-formed L-sequent and the double lines denote a rule that goes in either direction. Structural Rules

∆ | φ ⇒ ψ (iden) (Sub), α: Γ ⇒ ∆ Γ | φ ⇒ φ Γ | α(φ) ⇒ α(ψ) 12 DIMITRIS TSEMENTZIS

Γ | φ ⇒ ψ Γ | ψ ⇒ χ Γ | φ ⇒ ψ (Cut) (Con-wk) Γ | φ ⇒ χ Γ, x: K | φ ⇒ ψ Γ,y : K′, x: K, Γ′ | φ ⇒ ψ (Con-exch), x#K′,y#K Γ, x: K,y : K′, Γ′ | φ ⇒ ψ Logical Rules

(⊤) (⊥) Γ | φ ⇒ ⊤ Γ |⊥⇒ φ

(∃⊤) Γ | ∃x: K.φ ⇒ ∃x: K.⊤ Γ | θ ⇒ φ Γ | θ ⇒ ψ Γ | φ ⇒ θ Γ | ψ ⇒ θ (∧) (∨) Γ | θ ⇒ φ ∧ ψ Γ | φ ∨ ψ ⇒ θ Γ | θ ∧ φ ⇒ φ (→) Γ | θ ⇒ φ → ψ Γ, x: K | θ ⇒ φ Γ, x: K | φ ⇒ θ (∀) (∃) Γ | θ ⇒ ∀x: K.φ Γ | ∃x: K.φ ⇒ θ If we are working in the regular or coherent fragment then we also add the following rule, which is otherwise derivable:

(Frob),x∈ / FV(φ) Γ | φ ∧ (∃x: K.ψ) ⇒ ∃x: K.(φ ∧ ψ) If we are working in the coherent fragment then we also add following rule, which is otherwise derivable:

(Dist) Γ | φ ∧ (ψ ∨ χ) ⇒ (φ ∧ ψ) ∨ (φ ∧ χ) cl Finally, to get DFOLDS we add the law of the excluded middle:

(LEM) Γ |⊤⇒ φ ∨ (φ → ⊥) Remark 1.29. The perhaps unfamiliar rule (∃⊤) is needed due to the lack of “atomic relation symbols” in our syntax, the role of which is played by statements of the form ∃x: K.⊤ for some sort K. The (∃⊤) allows us to extract from a witness that a certain proposition holds the witness for that proposition and can therefore be thought of as encoding, semantically, the “first projection” of a term of a Σ-type. Definition 1.30 (FOLDS theory). A FOLDS theory T over a signature L (or FOLDS L-theory) is a set of L-sequents. Definition 1.31 (Entailment). We say that a FOLDS L-theory T entails (resp. cl classically entails) an L-sequent τ if there is a derivation in DFOLDS (resp. DFOLDS) FIRST-ORDERLOGICWITHISOMORPHISM 13 of τ from a finite subset of the sequents in T. When that is the case we write T ⊢ τ (resp. T ⊢cl τ). Notation. Whenever what we want to say refers to both entailment and classical entailment then we will use the notation ⊢(cl). To conclude this section we present the (first-order) FOLDS axiomatization of category theory as an illustrative example that combines all the above-introduced notions.

Example 1.32. Let Lcat denote the following FOLDS signature

◦ I =A ❃❃ t s ❃❃ 0 ❃❃ i t1 ❃❃   Õ  w t t2 0 A

d c  O subject to the relations

dt0 = dt2, ct1 = c1t2, dt1 = ct0 di = ci ds = dt, cs = ct

The (first-order) Lcat-theory of categories Tcat consists of the following : (1) (Existence of identities) ∀x: O.∃i: A(x, x).∃σ : I(i, x, x).⊤ (2) (Functionality of composition-1) ∀x, y, z : O.∀f : A(x, y).∀g : A(y, z).∃h: A(x, z).∃τ : ◦ (f,g,h,x,y,z).⊤ (3) (Functionality of Composition-2) ′ ′ ∀x, y, z : O.∀f : A(x, y).∀g : A(y, z).∀h, h : A(x, z).∀τ1 : ◦ (f,g,h).∀τ2 : ◦ (f,g,h ). ′ ∃ǫ: =A (h, h , x, z) (4) (Associativity) ∀x,y,z,w : O.∀f : A(x, y).∀g : A(y, z).∀h: A(z,w).∀i: A(x, z).∀j : A(x, w).

∀k : A(y,w).∀τ1 : ◦ (f,g,i,x,y,z).∀τ2 : ◦ (i, h, j, x, z, w).∀τ3 : ◦ (g,h,k,y,z,w).

∃τ4 : ◦ (f,k,j,x,y,w).⊤ (5) (Uniqueness of identity) ∀x: O.∀i, j : A(x, x).∀σ1 : I(i, x, x).∀σ2 : I(j, x, x).∃ǫ: =A (i, j, x, x).⊤ (6) (Right unit) ∀x, y : O.∀i: A(x, x).∀g : A(x, y).∀σ : I(i, x, x).∃τ : ◦ (i,g,g,x,x,y).⊤ (7) (Left unit) ∀x, y : O.∀i: A(y,y).∀f : A(x, y).∀φ: I(i,y,y).∃τ : ◦ (f,i,f,x,y,y).⊤

Example 1.33. To obtain the (first-order) Lcat-theory of groupoids Tgpd we add to the axioms of Tcat the following 14 DIMITRIS TSEMENTZIS

(8) (Every arrow is an isomorphism) ∀x, y : K.∀p: x ∼= y.∃q : y ∼= x.∃u: x ∼= x.∃v : y ∼= y.I(u) ∧ I(v) ∧◦(p,q,u) ∧ ◦(q,p,v) where we have now used the sugared form for the composition and identity relations.

2. Semantics of FOLDS in MLTT We now describe a semantics of FOLDS in MLTT, constructed as a direct interpre- tation of the syntax of LT TL into MLTT, and prove that under this interpretation the cl rules of DFOLDS (resp. DFOLDS) are sound in MLTT (resp. classical MLTT, which we understand as MLTT together with (an inhabitant of the type representing) LEM). For the purposes of this section by MLTT we will understand type theory with Π, Σ, 1, a universe a-la-Tarski U and (depending on the fragment of first-order logic that we want to work with) +, 0. We first define for any FOLDS signature L a notion of an L-structure. We do this by describing a type expression Struc(L) (Definition 2.1), proving that this type expression is a well-formed type ( 2.7) and taking its terms to be our L- structures. We then define an interpretation of LT TL into MLTT which gives us (for any L-structure M) notions of M-contexts, formulas, sequents etc. (Definition 2.9) and prove that this interpretation is correct (Theorem 2.11). In particular, any sequent σ is interpreted as a type σM in type theory following the usual recipe of the proposition-as-types interpretation (interpreting ∧ as ×, ∀ as Π etc.) and then we say that M satisfies σ if σM is inhabited (Definition 2.16). Finally, we prove soundness of DFOLDS with respect to the above-defined semantics in MLTT (Theorem 2.19).

Notation. We write ConMLTT for the context expressions (“pre-contexts”), TermMLTT for the term expresssions (“pre-terms”), TypeMLTT for the type expressions (“pre- types”) and SeqMLTT for the sequent expressions (“pre-sequents”) of MLTT. We will use the notation ≡ for definitional equality when it is derived and the symbol =df, as usual, when we are defining a term by postulating a definitional equality. We write app(x, f) for function application and proj(x) for the projections in Σ-types, and we write El for the reflector of the universe U. We write ∗ for the term of 1. We will write ||A|| for the propositional truncation of a type A in U. We will usually write × for non-dependent sums (Σ-types) and → for non-dependent functions (Π-types). We will occasionally also use × and → in the Agda-style notation (x: A) → B and (x: A) × B for dependent functions and sums, whenever convenient. For a given (ordered) set S (almost exclusively of objects and arrows of a given inverse category) we will use the notation Σ and Π to denote the sums and functions over all the s∈S s∈S expressions indexed in some way by S (this is an “external” description of a type ex- pression in MLTT which a priori may not be well-formed). We will assume that every expression that ranges over the objects and morphisms of L is ordered according to the given proper order of L. For example, if S = {K1,...,Kn} is a set of objects of L such that K1 < ···

(for some expression E(K) in which K may appear) this notation will denote the expression E(K1) →···→ E(Kn) and similarly for Σ-types. This notational device will help us declutter notation significantly, especially in Definitions 2.1 and 4.1. Whenever S is empty then we stipulate that Π E = 1 → E K∈S Σ E = 0 K∈S For any context Γ and type A in context Γ we write Σ (Γ) A (resp. Π (Γ) A) for the iterated (closed) Σ-type (resp. Π-type) which has bound everything in context Γ. We will also sometimes write simply x: Γ for a list of variables in a given context, e.g. as in Π A Type. x: Γ We also fix several more conventions for the interaction for the syntax of a FOLDS signature L and the syntax of MLTT. We will allow ourselves to denote variables in type theory by morphisms of L. For example, in Lrg, we may describe the interpre- tation of A as a type in context c: O,d: O (cf. Example 2.3 below for a more precise illustration of how this works). For K ∈L and p =(p1,...,pm) a list of arrows in L the notation app[K(p)] in type theory will now be understood as the term expression

app(pm, app(pm−1,... app(p1,K) . . . )) with the understanding that app[K ǫ]= app(∗,K)

For example, in Lrg, the notation app[I(x, f)] stands for the term expression app(f, app(x, I)) which of course will make sense if I : (x: O) → (f : A(x, x)) → U and A(x, x) =df app(x, (x, A)) for A: O → O → U, as indeed will be the case when the notation is used.

Terminology. We say that a type (expression) A or context (expression) Γ etc. is well-formed (in type theory) if the appropriate judgment (AType or Γok) is derivable (in type theory). A closed type is a well-formed type in the empty context. We will generally refer to the relevant rules of MLTT (and, below, of HoTT) through the relevant type formers, e.g. Σ-formation, Π-elimination etc.

Definition 2.1. Let L be a finite FOLDS signature. The type of L-structures is given by the type expression

Struc(L)=df Σ (K : TK ) (2) K∈ObL where

TK =df Π (f : El(app[Kf (pf)p∈Kf //L])) U (3) f∈K//L

Proposition 2.2. If L and L′ are isomorphic FOLDS signatures then Struc(L) ≡ Struc(L′). 16 DIMITRIS TSEMENTZIS

Proof. If L and L′ are isomorphic then the type expressions Struc(L) and Struc(L′) are α-equivalent, and therefore denote the same type expression. 

Before proving that Struc(L) is indeed a well-formed type we give several examples that illustrate the idea.

Example 2.3. For Lrg we have

TO = 1 → U (since O//Lrg = ∅)

TA = Π (f : El(app[Af (pf)p∈Af //Lrg ])) U f∈{c,d}

= Π(c: El(app[Ac(pc)p∈Ac//Lrg ]))(d: El(app[Ad(pd)p∈Ad//Lrg ])) U = Π(c: El(app(∗,O)))(d: El(app(∗,O))) U ≡ El(app(∗,O)) → El(app(∗,O)) → U

TI = Π (f : El(app[Af (pf)p∈Af //Lrg ])) U f∈{di,i}

= Π(di: El(app(∗, Idi))(i: appIi(pi)p∈Ii//Lrg ) U = Π(di: El(app(∗,O))(i: El(app(di, app(ci, A))) U ≡ Π(x: El(app(∗,O))(f : El(app(x, app(x, A))) U ≡ Π(x: El(app(∗,O)) El(app(x, app(x, A))) → U

Note that if O : TO then TA is well-formed and that if A: TA then TI is well-formed. Furthermore, note that in the last two lines of the unpacking of definition of TI we have given an α-equivalent reformulation, where the repetition of the x is due to the fact that di = ci. If we abuse notation and write simply O for El(app(∗,O)) and simply A(x, x) for El(app(x, app(x, A))) then TI becomes the more recognizable type Π A(x, x) → U x: O With that in mind we get

Struc(Lrg)=(O : TO) × (A: TA) × (I : TI ) =(O : U) × (A: O → O → U) × (I : Π A(x, x) → U) x: O

which is the data type we should expect from Lrg, i.e. the type of “reflexive graphs”.

Example 2.4. We do an example that is a little more arbitrary. Consider the following FOLDS signature L R ❇❇ e ❇❇ f ❇❇  g ❇❇!  A1 A2 ❇❇ ❇❇ d k ❇❇ c ❇❇  l &  O1 O2 FIRST-ORDERLOGICWITHISOMORPHISM 17 subject to the relation df = cg. Then using the obvious notational abbreviations as in the previous example we have:

TO1 ≡ U

TO2 ≡ U

TA1 ≡ (k : O1) → (l : O2) → (d: O2) → U ≡ O1 → O2 → O2 → U

TA2 ≡ (c: O2) → U ≡ O2 → U

TR ≡ (df : O1) → (lf : O2) → (df : O2) → (ce: O2)

→ (f : A1(kf,lf,df)) → (g : A2(df)) → (e: A2(ce)) → U

≡ (x: O1) × (y : O2) × (z : O2) × (w : O2)

→ (f : A1(x, y, z)) × (g : A2(z)) × (e: A2(w)) → U Thus we get

Struc(L) =(O1 : U) × (O2 : U)×

(A1 : O1 → O2 → O2 → U) × (A2 : O2 → U)×

(R: (x: O1) × (y : O2) × (z : O2) × (w : O2)

→ (xf : A1(x, y, z)) × (xg : A2(z)) × (xe : A2(w)) → U) which is the data type we should expect from L.

Example 2.5. In Lcat we have TO, TA, TI just as in Lrg. Then we have, using the usual abbreviations:

T=A = Π (f : El(app[(=A)f (pf)p∈(=A)f //Lcat ])) U f∈{ds,cs,s,t} = Π(ds,cs: O)(s: El(app(cs, app(ds,A))))(t: El(app(ct, app(dt, A)))) U ≡ Π A(x, y) → A(x, y) → U x,y : O

T◦ = Π (f : El(app[◦f (pf)p∈◦f //Lcat ])) U f∈{dt0,ct0,ct2,t0,t1,t2}

= Π(dt0, dt1, ct2 : O)(t0 : El(app(ct0, app(dt0, A))))

(t1 : El(app(ct1, app(dt1, A))))(t2 : El(app(ct2, app(dt2, A)))) U ≡ Π A(x, y) → A(y, z) → A(x, z) → U x,y,z : O

As we should expect T=A is the type of a binary relation on arrows with the same domain and codomain and T◦ is the type of a tertiary relation on “commutative” triangles. Thus we get

Struc(Lcat) =(O : U) × (A: O → O → U) × (I : (x: O) → A(x, x) → U)× (◦: (x, y, z : O) → A(x, y) → A(y, z) → A(x, z) → U) which, as we shall make more precise in Section 6, is the “relational” form of the signature for (pre)category theory. 18 DIMITRIS TSEMENTZIS

Lemma 2.6. Let L be a FOLDS signature. For all K ∈ ObL the following context is well-formed ΓK =df (A: TA)A≤K

Proof. Firstly note that by the well-foundedness of (the underlying inverse category of) L for any K ∈ ObL there will be only finitely many A ≤ K and so ΓK will be a finite list. We now proceed by <-induction on K. If K is <-minimal then ΓK ≡ K : TK and by definition TK ≡ 1 → U. But since we assume that our type theory contains 1, Π and U we have ∅ ⊢ 1 → U Type (4)

which implies that K : 1 → U ≡ ΓK is well-formed, as required. Now assume that ΓA is well-formed for all A

Π (f : El(app[Kf (pf)p∈K//L])) U (5) f∈K//L it suffices to show that

ΓA, (f : El(app[Kf (pf)]))f∈K//L ⊢ U Type (6) for which it suffices to show that the context

ΓA, (f : El(app[Kf (pf)]))f∈K//L (7) is well-formed. We proceed by <-induction on f (by which we mean that starting with ΓA we will derive the context (7)). If f is <-minimal then l(Kf ) = 0 which means that El(app[Kf (pf)]) ≡ El(app(∗,Kf )) (8)

But since l(Kf ) = 0 and Kf < A, then Kf appears in ΓA and its type is 1 → U. Hence we can derive ΓA ⊢ El(app(∗,Kf )) Type

which implies that ΓA, (f : Kf ) is a well-formed context. Now assume that we know that for some f ∈ K//L the following context

∆=df ΓA, (g : El(app[Kg(pg)]))g

∆ ⊢ El(app[Kf (qf)]) Type (10)

is derivable. Since Kf

Kf : Π (h: El(app[Kh(qh)])) U (11) h∈Kf //L

and also for each q ∈ Kf //L we have qf

∆ ⊢ qf : El(app[Kqf (pqf)]) (12) FIRST-ORDERLOGICWITHISOMORPHISM 19 where, crucially, some of these judgments may be declaring the same variable since ′ ′ it may happen that qf = q f even if q =6 q . But then by (Kf //L-many) successive applications of Π-elimination using (11) and (12) we obtain

∆ ⊢ app[Kf (qf)]: U (13)

from which we immediately obtain (10) as required. Hence ΓA ⊢ TK Type and we are done. 

Theorem 2.7. Struc(L) is a closed type.

Proof. Since L is assumed finite, by Lemma 2.6 we get immediately that

ΓL =df (K : TK)K∈ObL is well-formed. And then we obtain Struc(L) (in the empty context) by successive applications of Σ-formation. 

Definition 2.8. An L-structure M is a term of Struc(L).

We will now define an interpretation J−K of LT TL into MLTT. To be clear, what we go on to describe in Definition 2.9 below is a mapping from the raw syntax of LT TL into the raw syntax of MLTT. We will then prove in Theorem 2.11 that this mapping preserves the rules of LT TL and therefore deserves to be called an interpretation. In particular, this means that we automatically obtain an interpretation of LT TL into any categorical model of MLTT (e.g. CwFs or C-systems with the appropriate extra structure).

Notation. For any L-structure M and any sort K in L we denote by KM the “Kth projection of M”. More precisely if K1 <...Km are the (ordered) objects of L then M (Ki) =df proji(M) (14)

Convention. We will assume that the variables of MLTT are given by a set that contains the variables V of LT TL. This allows us to simply re-use the same symbol for a variable and its interpretation, and as such we will not include the mapping of variables of LT TL to variables of MLTT in the definition below. 20 DIMITRIS TSEMENTZIS

Definition 2.9 (Interpretation of LT TL in MLTT). The depth of the expressions in the raw syntax of LT TL is defined as follows: d(∅)=0 d(Γ, x: K)= d(Γ) + d(K)+1 d(A(x)) = l(A)+1 d(⊤)= d(⊥)=1 d(φ ∗ ψ)= d(φ)+ d(ψ) (∗ = ∧, ∨, →) d(Qx: K.φ)= d(K)+ d(φ) (Q = ∃, ∀) d(Γ ok)= d(Γ) d(Γ ⊢ K Sort)= d(Γ) + d(K) d(Γ ⊢ x: K)= d(Γ)+1 d(Γ ⊢ φ formula)= d(Γ) + d(φ)

The interpretation of LT TL into MLTT consists of the following functions:

J−Kc : ConL → ConMLTT ∅ 7→ M: Struc(L)

Γ, x: K 7→ JΓKc, x: JKKs

J−Ks : SortL → TypeMLTT M K(xpf ) 7→ El(app[K (xpf )])

J−Kf : FormulasL → TypeMLTT ⊥ 7→ 0 ⊤ 7→ 1

φ ∧ ψ 7→ JφKf × JψKf

φ ∨ ψ 7→ JφKf + JψKf

φ → ψ 7→ JφKf → JψKf

∃x: K.φ 7→ Σ(x: JKKs) JφKf

∀x: K.φ 7→ Π(x: JKKs) JφKf We will drop the subscripts of each separate interpretation function and write simply JΓK, JKK, JφK. With this in mind the interpretation of the judgments of LT TL is given FIRST-ORDERLOGICWITHISOMORPHISM 21 by the following function:

J−K: JudL → SeqMLTT Γ ok 7→ JΓK ok Γ ⊢ K Sort 7→ JΓK ⊢ JKK Type Γ ⊢ x: K 7→ JΓK ⊢ x: JKK Γ ⊢ φ formula 7→ JΓK ⊢ JφK Type

For a judgment S in LT TL we write JSK for its interpretation in MLTT. Remark 2.10. Note that instead of interpreting the empty L-context as M: Struc(L) we could have instead interpreted it as the context ΓL = (K : TK)K∈ObL as defined in the proof of Theorem 2.7. The difference is entirely inessential with respect to anything we have to say in the rest of this paper. Theorem 2.11 (Correctness of the Interpretation). If S is a derivable judgment in LT TL then JSK is a derivable judgment in MLTT.

Proof. We proceed by induction on the depth of the expressions of LT TL. By inspec- tion we can see that the depth function in Definition 2.9 is correct in the sense that for every rule of LT TL the depth of the expression below the line is strictly greater than the depth of any of the expressions above the line. The proof thus can proceed by induction on the complexity of derivations of LT TL which here means that we need to show that every rule of LT TL is valid in MLTT under the interpretation in Definition 2.9. We take them in turn:

(con-∅): We have J∅ okK = M: Struc(L) ok (15) But by Theorem 2.7 Struc(L) is a well-formed type in the empty context which means that M: Struc(L) is a well-formed context.

(con-ext): Given that JΓK is a well-formed context and that JΓK ⊢ JKK Type is derivable, we get immediately that JΓK, x: JKK ok (16) is derivable. But JΓ, x: KK = JΓK, x: JKK and so the above sequent is exactly the interpretation of the sequent below the line in (con-ext).

(con-wk): Follows immediately from the analogous weakening rule in MLTT.

(ax): Follows immediately from the analogous rule in MLTT.

(K-form): By Lemma 1.13 we know that if Γ ⊢ xf : Kf (xpf ) is derivable in T TL (and hence LT TL) then xf : Kf (xpf ) must appear in Γ. Therefore xf : JKf (xpf )K must appear in JΓK for every f ∈ K//L. By the definition of the interpretation J−K we know that M JK(xf )f∈K//LK = El(app[K (xf )f∈K//L]) (17) 22 DIMITRIS TSEMENTZIS

Since KM is a dependent function into U of the appropriate type (by the defi- nition of Struc(L)) and each xf appears in the context JΓK then we know that M app[K (xf )f∈K//L] is a derivable term of U and therefore that M JΓK ⊢ El(app[K (xf )f∈K//L]) Type (18) is derivable. But this last sequent is exactly the interpretation of the bottom line of (K-form), as required.

(form−wk): Follows immediately from the analogous weakening rule in MLTT.

(⊤−form), (⊥−form): Since 1, 0 are included in our type theory these follow immedi- ately from the corresponding formation rules since JΓ ⊢ ⊤ formulaK = JΓK ⊢ 1 Type and similarly for ⊥.

(∗−form): For each of ∗ = ∧, ∨, → the (∗−form) rule follows from the corresponding formation rule for the relevant type former. For example, given that JΓK is a well- formed context and JφK and JψK are types in that context we have JΓK, x: JφK ⊢ JψK Type (19) Then by Π-formation we get JΓK ⊢ JφK → JψK Type (20) as required. The cases for ∨ and ∧ follow analogously using formation rules for + and Σ respectively.

(Q−form): For each of Q = ∃, ∀ the (Q−form) rule follows from the corresponding formation rule for the relevant type former. For example, given that JΓK, x: JKK is a well-formed context and JφK and is a type in that context we have by Σ-formation that JΓK ⊢ Σ(x: JKK) JφK Type (21) as required. The case for ∀ and ∧ follows analogously using Π-formation.  Notation. We will usually want to assume that we are given a specific L-structure M and speak of contexts and formulas in M. To express this we will use the notation ΓM and φM for contexts and formulas. We will also use the notation A(x)M for sorts, noting that it must be distinguished from the notation KM for an object K ∈ L which we have already used. The former denotes a type (in context) whereas the latter denotes a term of a certain type (a dependent function into a universe). The following result is now essentially a tautological restatement of Theorem 2.11. Corollary 2.12. For any L-structure M we have: (1) If Γ is an L-context then ΓM is a well-formed context. (2) If φ is an L-formula in context Γ then φM is a type in context ΓM. (3) If A(x) is an L-sort in context Γ then A(x)M is a type in context ΓM. FIRST-ORDERLOGICWITHISOMORPHISM 23

Corollary 2.13. If α: Γ ⇒ ∆ is a well-formed L-context morphism then αM : ΓM ⇒ ∆M is a context morphism where αM consists of the interpretations of the sequents defining α. Proof. If α is given by

Γ ⊢ y1 : K1

Γ ⊢ y2 : K2[y1/x1] . .

Γ ⊢ yn : Kn[y1/x1,...,yn−1/xn−1] then αM is given by M M Γ ⊢ y1 : K1 M M Γ ⊢ y2 : K2 [y1/x1] . . M M Γ ⊢ yn : Kn [y1/x1,...,yn−1/xn−1] which means exactly that we have a context morphism ΓM ⇒ ∆M in MLTT.  Definition 2.14 (Interpretation of a Sequent in M). The interpretation of a sequent Γ | φ ⇒ ψ in an L-structure M is given by M M M M (Γ | φ ⇒ ψ) =df Π (Γ ) φ → ψ (22) which is a closed type by Corollary 2.12. Definition 2.15 (Extension of a Formula). The extension of an L-formula Γ.φ in an L-structure M is the type M M M ExtΓ (φ)=df Σ (Γ ) φ M We call a derivable term a : ExtΓ (φ) a realization of Γ.φ in M. Definition 2.16 (Satisfaction of a Formula). Let φ be a L-formula in context Γ and M an L-structure. We define the satisfaction of Γ.φ by a in M as follows: M|= φ[a/Γ] iff a is a realization of Γ.φ in M The case where φ has no free variables is a special case of the above definition, in which case we write M |= φ and say that M is a model of φ. Satisfaction for sequents can be defined similarly as follows: M|=Γ | φ ⇒ ψ iff Π(ΓM) φM → ψM is inhabited We say that M satisfies a sequent σ if M |= σ. We say that M is a model of a FOLDS L-theory T if M satisfies every sequent in T. Notation. If we want to indicate that our semantics is taken in classical MLTT we will write |=cl and if we want to indicate that what we say applies to both MLTT and classical MLTT we will write |=(cl) 24 DIMITRIS TSEMENTZIS

Remark 2.17. Our notion of satisfaction is defined in terms of the notion of the derivability of a certain judgment in type theory. In terms of the categorical semantics of type theory, our notion of satisfaction depends on the (mere) existence or non- existence of a certain section to a certain canonical projection. Definition 2.18 (Semantic Consequence). For any FOLDS L-theory T and L-sequent τ we write T |=(cl) τ for the statement that for every (classical) L-structure M if M|=(cl) σ for all σ in T then M|=(cl) τ, in which case we say that τ is a semantic consequence of σ.

Theorem 2.19 (Soundness). Let T be a FOLDS L-theory. If T ⊢(cl) τ then T |=(cl) τ. Proof. The proof proceeds without difficulties by induction on the complexity of DFOLDS-derivations since we already know that the interpretation of an L-sequent is a closed type in MLTT. For example, for

(iden) Γ | φ ⇒ φ we know that (Γ | φ ⇒ φ)M ≡ Π (ΓM) φM → φM and ⊢ Π (ΓM) φM → φM Type To show that (iden) is sound we therefore need to show that Π (ΓM) φM → φM is inhabited, i.e. that there is a derivation of a term of that type. In a somewhat abbreviated form this derivation goes as follows ΓM ⊢ φM Type (Π-form), (wkg) ΓM ⊢ φM → φM Type (Π-form) ⊢ Π (ΓM) φM → φM Type (Π-intro) ⊢ λx: ΓM.(λy.y): Π(ΓM) φM → φM

Similar derivations work for the rest of the structural rules of DFOLDS. The soundness of the logical rules of DFOLDS follow straightforwardly by the introduction rules of the relevant type formers. We omit the (well-known) details. 

Finally we want to be able to define the “type of models” of an L-theory. But to do so we need to be able to list the sequents that comprise the theory within MLTT, a qualification made precise by the following definition.

Definition 2.20. A FOLDS L-theory T = {σi}i∈N is internalizable if there is a family of types i: N, M: Struc(L) ⊢ Ti(M) Type M such that Ti(M) ≡ (σi) . Remark 2.21. Every finite theory will be internalizable in MLTT since we can write out the list of sequents “by hand”. Infinite theories will be internalizable to the extent that LT TL can be internalized in MLTT. FIRST-ORDERLOGICWITHISOMORPHISM 25

Definition 2.22 (Type of Models). For an internalizable theory T, we define the type of models of T as T N M Mod( )=df Σ(M: Struc(L)) Π(i: ) σi Syntax of FOL 3. =∼

We will now introduce the syntax of FOL=∼ as an extension of the syntax of FOLDS described in Section 1. The signatures of FOL=∼ will be given by inverse categories L with extra structure. This extra structure consists of an assignment of a number to each object of L corresponding intuitively to its h-level, as well as allowing for certain specified objects and arrows encoding equality, reflexivity and transport (along equalities). Given these signatures, the contexts, formulas, sequents etc. of FOL=∼ can be defined just as in Section 1 by slight modifications that take into account the extra structure on the relevant signatures. As before, we assume fixed countably infinite disjoint sets O and M. Definition 3.1 (Logical Sorts and Arrows). We define by mutual induction two disjoint sets of symbols: ∼ Ob(O, M) K ::= A | =K | ρK | τf (A ∈ O)

Mor(O, M) f ::= h | sK | tK | rK | f1 | f2 | ef (h ∈ M) Notation. We will drop explicit mention of O, M and write simply Ob and Mor for Ob(O, M) and Mor(O, M), with the understanding, as before, that everything we say below is parametrized by our choice of O and M. Definition 3.2 (h-signatures). An h-signature is a pair (L, h) where: • L is a FOLDS signature over (Ob, Mor) • h is a function h: ObL→ N∞ such that: ∼ (1) If =K∈L then we have: (a) K ∈L with h(K) ≥ 2 ∼ ∼ (b) top(=K)= {sK, tK} = L(=K,K) ′ (c) f ◦ sK = f ◦ tK for any f : K → K ∼ (d) h(=K)= h(K) − 1 (2) If ρK ∈L then we have: (a) K ∈L with h(K) ≥ 2 ∼ (b) top(ρK )= {rK} = L(ρK, =K) (c) sK ◦ rK = tK ◦ rK (d) h(ρK )= h(K) − 2 (3) If τf ∈L then we have: (a) f ∈L(A, K) for some A, K ∈L with h(K) ≥ 3 and f ∈ top(A) ∼ (b) top(τf )= {ef , f1, f2} with L(τf , =K)= {ef } and L(τf , A)= {f1, f2} (c) sK ◦ ef = f ◦ f1 and tK ◦ ef = f ◦ f2 (d) g ◦ f1 = g ◦ f2, for all g ∈ A//L\{f} (e) q ◦ f ◦ f1 = q ◦ f ◦ f2, for all q ∈ K//L 26 DIMITRIS TSEMENTZIS

(f) h(τf )= h(A) − 1 (4) If h(K) = 0 then K ≡ ρA for some A in L In all the above conditions involving h we stipulate that ∞ − m = ∞.

Terminology. For an h-signature (L, h) we call h(K) the h-level of K. The height H(L, h)of (L, h) is the maximum h-level in L, i.e. H(L, h) = sup h(K) K∈obL ∼ ∼ We call =K the isomorphism sort of K, ρK the reflexivity sort (or predicate) on =K and for f : A → K we call τf the transport structure of A in position f (along the path picked out by ef ). We call sK and tK the source and target maps (for equality “paths”). We call all these symbols logical and any symbol that is not of this kind non-logical. For a given inverse category L over (Ob, Mor) we will write NL(L) for the set of non-logical sorts of L and we will refer to such an L with a finite NL(L) as essentially finite.

Remark 3.3. We now illustrate the idea behind each of the conditions in Definition 3.2 at some length, anticipating the semantics in Section 4. The function h: ObL → N∞ is to be understood as picking out the h-level of the dependent sort it is attached to, in the sense that a given sort with h(K) = m is to be understood as a family of types of h-level m dependent on the sorts in K//L in the appropriate way. The isomorphism sorts are to be understood as the identity types/path spaces of (the family defined by) a sort (at each of its instances). The conditions on an ∼ isomorphism sort =K ensure that it appears in an h-signature only in the following form ∼ m − 1 =K

sK tK  m K where m ≥ 2 because we only want to have an isomorphism sort over types that are at least sets (i.e. at least of h-level 2). The idea is that the identity type on a type K is always of h-level one less than the h-level of K (if that h-level is known to be ∼ finite) and that there can be no more arrows with domain =K since the identity type ∼ depends only on K (this is what the condition top(=K )= {sK, tK} achieves). Finally given any arrow f ∈ K//L as in ∼ m − 1 =K

sK tK  m K ✤ ✤ f ✤ n Kf FIRST-ORDERLOGICWITHISOMORPHISM 27 ∼ the condition fsK = ftK ensures that to declare a variable p: x =K y then x and y must have the same dependency, as is to be expected. The reflexivity predicates are to be understood as a type family picking out the reflexivity path from the identity type “below” them, i.e. as the identity type of paths identical to reflexivity. The conditions on a reflexivity predicate ρK ensure that it appears in an h-signature only in the following form

m − 2 ρK

rK  ∼ m − 1 =K

sK tK  m K

with the condition sK rK = tK rK ensuring (as in Lrg) that we can only ask of a path if it is reflexivity if we know that it is a loop. The transport structure is to be understood as a (functional) relation relating a term of a type to its transport along a path. The conditions on a transport relation τf ensure that it appears in an h-signature only in the following form

m − 1 τf f1 ❆ ❆❆ ef ❆❆ ❆❆ Ö f2 ❆ x ∼ m A =O ❄ s g ⑦ ❄❄ K ⑦ ❄❄ ⑦ f ❄❄ ⑦ ❄ Õ tK nK O w

with the conditions ensuring that the “path” ef has as source the “point” ff1 and as target the “point” ff2 (condition 3.(c)), that the “points” f1 and f2 belong to types differing only in “position” f (condition 3.(d)) and that the “points” ff1, ff2 are “points” of the same type (condition 3.(e)). Example 3.8 offers a more detailed illustration of these conditions. Semantically they will allow us to define each τf as the transport function induced by a path on O for a type family A over O. Finally, the fact that we do not allow non-logical sorts to be contractible (i.e. of h- level 0) is because we have no use for families of contractible types (over some other type). The fact that we do not allow isomorphism sorts and transport structure to be contractible is because we have no use for contractible identity types since, as we said above, we want to have isomorphism sorts and transport structure over types that are at least of h-level 2. On the other hand, the fact that we do allow reflexivity sorts to be of h-level 0 is, first, because we do have a use for stating the inhabitation of an isomorphism sort of h-level 1 and indeed because the reflexivity predicate for such an isomorphism sort will, semantically, correspond to a contractible type and, second, because making this (somewhat artificial expression) allows for a more uniform presentation of the deductive system D=∼ below since it will allow us to state a single “Id-introduction” rule. 28 DIMITRIS TSEMENTZIS

Notation. We will usually suppress explicit mention of K in the s, t and r maps. We will also often drop explicit mention of h in (L, h) and refer to an h-signature simply by its associated inverse category L. When displaying an h-signature we will usually write the h-level of each sort on the left of the displayed category, as illustrated by the examples below, and we will usually omit writing out reflexivity predicates of h-level 0.

Example 3.4. The h-signature L2,1 =(Lgraph, h2,1) is defined as follows 1 A

 2 O

Its underlying FOLDS signature is Lgraph. Note that L2,1 is not, for example, isomor- phic (as we make more precise below) to the h-signature L∞,1 =(Lgraph, h∞,1) given by 1 A

 ∞ O The h-level, in other words, is extra structure on FOLDS signatures. There will be non-isomorphic h-signatures whose underlying FOLDS signatures are isomorphic.

Example 3.5. Similarly, Lrg is the underlying FOLDS signature of several h-signatures. The following h-signature 1 I

i  2 A

c d  ∞ O would be appropriate (semantically) for talking about reflexive graphs on general types (i.e. types of any h-level). If we want to talk about reflexive graphs on h-sets then it would be appropriate to let h(O) = 2, i.e. to let O be of h-level 2. FIRST-ORDERLOGICWITHISOMORPHISM 29

= Example 3.6. We can define Lrg as the following h-signature

0 ρA ρO

∼ rA r=O   ∼ ∼ 1 I =A ==∼O ρO tA ∼ ∼ i t=O s=O  Õ sA  Ù w ∼ 2 A =O n ρO tO c d  z sO 3 O r subject to the usual relation on Lrg. By definition it is also subject to the following relations:

sO ◦ s=∼O = sO ◦ t=∼O , tO ◦ s=∼O = tO ◦ t=∼O

tO ◦ rO = sO ◦ rO,c ◦ tA = c ◦ sA

t=∼O ◦ ρO = s=∼O ◦ r=∼O , tA ◦ rA = sA ◦ rA

d ◦ tA = d ◦ sA

This signature can be thought of as Lrg “completed with respect to equality” according to its h-level, i.e. we have added those equality and reflexivity sorts that the h-level of the non-logical sorts determines is non-trivial. We will make this “completion” process more precise below, through the “globular completion monad” in Definition 3.16.

Example 3.7. A crucial feature of our formalism is that it allows us to express proper- ties and impose structure on the isomorphism sorts themselves. Semantically this will allow us to be able to express axioms and therefore define theories satisfying condi- tions relating to the inhabitants of isomorphism sorts (e.g. that they are in bijective correspondence with “isomorphisms” as defined over Lcat). For example, consider the =∼ following h-signature, extending Lrg ∼ ∼ 1 I =A ==∼O ρO P tA ∼ ∼ i t=O s=O  Õ sA  Ù w ∼ 2 A =O nh ρO tO h p c d  z sO 3 O r Intuitively, we have added a one-place predicate on the (first-level) isomorphism sort of O. Extensions of h-signatures that already contain isomorphism sorts thus allow us to express properties and impose structure on the isomorphism sorts themselves. 30 DIMITRIS TSEMENTZIS

Example 3.8. The following h-signature is useful for expressing properties of a “re- flexive graph” on a groupoid O together with properties of the “transported” sets of edges on any two points of the groupoid connected by a path:

1 I τd

i d1 ed  d x 2 & ∼ 2 A l =O tO d c  { sO ∞ O s In short, this is the signature for reflexive graphs with transport. As described in Remark 3.3, note that the relation cd1 = cd2 ensures that we are “transporting” between “types” that only (possibly) differ in the “domain” position d but do not differ in the “codomain” position c, i.e. we can think of τd as defining a function(al relation) A(x, z) → A(y, z) for the “type family” A(−, z): O → U

Example 3.9. The following h-signature Lprecat is useful for formalizing the theory of precategories: ∼ 1 ◦ I =A ❃ s ❃❃ t0 A ❃❃ i t ❃❃ 1 ❃   Õ t  w A 2 t2 0 A

d c  ∞ O where we have the relations of Lcat.

Example 3.10. The following h-signature Lucat is useful for formalizing the theory of univalent categories: ∼ ∼ 1 ◦ I =A U ==∼O rO

t0 i u1 t s  u2 &  Ù t1 %-* w & ∼ 2 4 A =O n r t2 t d c  z s 3 O r

where we have the same relations as Lprecat together with the relation

t ◦ u1 = s ◦ u2 The sort U can be thought of as allowing us to express a function between paths and arrows, and indeed to express the defining axiom for univalent categories. (The same

could also be accomplished through the transport relation τsO .) FIRST-ORDERLOGICWITHISOMORPHISM 31

Definition 3.11 (Category of h-signatures). We let hSig be the category whose objects are the h-signatures and whose morphisms I : (L, h) → (L′, h′) are given by FOLDS(Ob, Mor)-morphisms I : L→L′ that satisfy the additional condition h(K) ≤ h′(I(K)).

Terminology. We will refer to morphisms in hSig as h-morphisms.

Remark 3.12. The condition h(K) ≤ h′(I(K)) is imposed with the semantic fact that the h-level is “upwards cumulative” (i.e. that a type of h-level n is also a type of h-level m ≥ n) but not the other way around (i.e. a type of h-level n is not necessarily a type of h-level m ≤ n).

Definition 3.13. We define G: hSig → hSig to be the following functor:

• On objects G takes (L, h) ∈ hSig to the h-signature G(L, h)=(G(L),G(h)) with ∼ ObG(L)=ObL∪{=K | K ∈L, h(K) ≥ 2}∪{ρK | K ∈L, h(K) ≥ 2} • On arrows, given I : (L, h) → (L′, h′) we define G(I): G(L) → G(L′) as the following functor: ∼ – On objects we have G(I)|ObL = I and whenever =K , ρK ∈ ObG(L)\ObL ∼ ∼ we set G(I)(=K )=df=I(K) and G(I)(ρK)= ρI(K). – On arrows we once again have G(I)|ObL = I and whenever sK, tK,rK ∈ MorG(L)\MorL we set G(I)(sK)= sI(K), G(I)(tK )= tI(K) and G(I)(ρK)= ρI(K).

Lemma 3.14. G is well-defined.

Proof. Firstly, we note that G(L, h) is uniquely determined for any (L, h) since by Def- ∼ inition 3.2 the objects =K and ρK can only appear in an h-signature in a unique way and G(L) contains no more non-logical sorts than L and their h-level is determined by the h-level of their associated K. It remains to check that for I : (L, h) → (L′, h′) we have that G(I): G(L) → G(L′) is indeed an h-morphism, i.e. that I does not decrease h-level. For any K ∈ L this is immediate since I is assumed to be an h-morphism. ∼ Now let =K∈ ObG(L) \ ObL. Then we have = ∼ ′ ′= ∼ h (=K )= h(K) − 1 ≤ h (I(K)) − 1= h (=I(K))

The same works for ρK .  32 DIMITRIS TSEMENTZIS

Example 3.15. Let Lrg be as in Example 4.8. Then the action of G on Lrg is given by

Lrg 7−→ G(Lrg)

∼ 1 I 1 I =A ρO t A ⑤⑤ i i ⑤⑤ ⑤⑤ ρO   Ñ sA } ⑤ u ∼ ⑤ 2 A 7−→ 2 A =O tO c d c d   Ñ 3 O 3 O o sO Definition 3.16 (Globular Completion Monad). We define the globular comple- tion monad as the triple G = hG,µG, ηGi where: • G is the functor defined in Definition 3.13 • µG(L, h) is the “contraction” h-morphism that takes

ρρK 7→ ρK ∼ =ρK 7→ ρK ∼ ρ=∼K 7→ =K ∼ ∼ ==∼K 7→ =K

(ηG(L, h) is the inclusion (L, h) ֒→ G(L, h • Lemma 3.17. G is a monad. Proof. Straightforward from the definitions. 

Definition 3.18 (FOLDS=). We write FOLDS= for the category of free G-algebras, i.e. the Kleisli category for the monad G. The objects of FOLDS= are the h- signatures with equality. We write = (−) : hSig → FOLDS= for the free algebra functor associated to the monad G. Example 3.19. = Lrg 7−→ Lrg

∼ ∼ 1 I 1 I =A ==∼O ρO tA ∼ s∼ i i t=O =O   Ô sA  Ù w ∼ 2 A 7−→ 2 A =O n ρO tO c d c d   y sO 3 O 3 O r This explains the notation in Example 3.6. FIRST-ORDERLOGICWITHISOMORPHISM 33

τ Definition 3.20. We define a functor (−) : FOLDS= → hSig as follows: • On objects T takes (L, h) to the h-signature (L, h)τ =(Lτ , hτ ) where τ ObL = ObL∪{τf | f : A → K, f ∈ top(A), h(K) ≥ 2} • On arrows, given I : (L, h) → (L′, h′) we define T (I): Lτ →L′τ as the follow- ing functor: τ – On objects we have T (I)|L = I and if τf ∈ ObL \ObL we set T (I)(τf )= τI(f). – On arrows we once again have T (I)|L = I and whenever f1, f2, ef ∈ τ MorL \MorL we set T (I)(f1)= I(f)1, T (I)(f2)= I(f)2 and T (I)(ef )= eI(f). Lemma 3.21. (−)τ is well-defined. Proof. Just as in the proof of Lemma 3.14 the choice of the objects of (Lτ , hτ ) de- termines a unique h-signature and that each T (I) is an h-homomorphism follows easily.  Example 3.22. We have

1 I ∼ τ τ ∼∼ ρ τ τ =A c ❖❖ d ==O O s t ❖❖❖ ❇❇ ④ ❖❖ ❇❇ ed ④ c2 ❖❖❖ ❇❇ ④④ s1 ec ❖❖ ❇ ④  Ö ❖❖❖❇❇  } ④④ x d ❖' ④ = τ so c1 2 ∼ so s2 (Lrg) = 2 A hk =O jh c f es t1 d1  t2 3 O qn et = where we have omitted the names of those arrows that are already in Lrg for read- ability. Definition 3.23 (Transport Structure Endofunctor). We define the transport struc- = τ ture endofunctor T : FOLDS= → FOLDS= as the composite (−) ◦ (−) . Terminology. For a category C and an endofunctor F : C → C an object a of C is a fixed point of F if F (a)= a.

fin Definition 3.24. We write FOL=∼ for the full subcategory of FOLDS= consisting of fin the fixed points of the endofunctor T . The objects of FOL=∼ are the signatures of first-order logic with isomorphism of finite height or finite FOL=∼-signatures. m m Similarly we write FOL=∼ for the for the full subcategory of FOLDS= consisting of m the fixed points of the endofunctor T . The objects of FOL=∼ are the signatures of first-order logic with isomorphism of height m or FOL=∼-m-signatures.

= = = Example 3.25. We have T T (Lrg)= T (Lrg) and therefore Lrg is a FOL=∼-3-signature. We now wish to extend Definition 3.24 to h-signatures of possibly infinite height, and thus finally arrive at the full definition of a FOL=∼ signature. 34 DIMITRIS TSEMENTZIS

Definition 3.26. For any L in FOLDS= we let let JL be the functor

JL ω / FOLDS=

n nO 7→ T O L ≤ O m 7→ T mL where ω is the usual poset category on the ordinal ω, T iL is the i-fold application of .the functor T to L and each map T mL ֒→ T nL is the obvious inclusion

Lemma 3.27. The sequential colimit limJL of L exists in FOLDS= for any FOLDS=- −→ signature L.

i Proof. We construct limJL as the union of all the T L over i ∈ N, i.e. we set −→ i Ob(limJL)=df Ob(T L) −→ [ i∈N i Mor(limJL)=df Mor(T L) −→ [ i∈N It is then clear by the definition of h-signatures that this data defines a unique h- signature since each logical sort can occur in a unique way and all the T iL contain the same non-logical sorts, namely NL(L). Clearly limJL is a free G-algebra and each −→ T iL embeds into it in the obvious way, thus giving us a cocone which is immediately seen to be universal. 

Definition 3.28 (FOL=∼-signatures). For any L in FOLDS= we define its associated =∼ FOL=∼-signature L by =∼ L =df limJL (23) −→ The assignment L 7→ L=∼ defines an endofunctor

T : FOLDS= −→ FOLDS=

and we write FOL=∼ for the category of algebras of the endofunctor T . The objects of FOL=∼ are the signatures of first-order logic with isomorphism or FOL=∼- signatures. The morphisms of FOL=∼ are the FOL=∼-morphisms or logical h- morphisms. FIRST-ORDERLOGICWITHISOMORPHISM 35

We can now summarize the situation in the following diagram of functors, with U1, U2, U3 the obvious forgetful functors.

FOLDS= τ r ❖❖ (−) rr ❖❖ T G rr ❖❖❖ T rr = ❖❖ Ø ry rr (−) ❖❖' Ø o - o FOLDS(Ob, Mor) o hSig m FOLDS= o FOL=∼ U1 U3 U2

Kl(G) T -Alg

Notation. For a given FOL=∼-signature L we will write |L| for its image under the composite U1U2U3 of the corresponding forgetful functors. We write T TL and LT TL for T T|L| and LT T|L|.

Terminology. We call |L| the underlying FOLDS signature of a FOL=∼-signature L. We say that a FOL=∼-signature is essentially finite if its underlying FOLDS signature is essentially finite.

With this in mind we can use the fact that every FOL=∼-signature L has an under- lying FOLDS(Ob, Mor)-signature to define the syntax of FOL=∼ as the syntax of its underlying FOLDS(Ob, Mor)-signature. We thus arrive at the desired definition of the syntax of FOL=∼.

Definition 3.29 (Syntax of FOL=∼). Let L be a FOL=∼-signature. The contexts, sorts, context morphisms, formulas and sequents of L are defined as the contexts, sorts, context morphisms, formulas and sequents of LT TL. Homotopy Semantics of FOL 4. =∼

We will define the semantics for FOL=∼ as an interpretation directly into the syntax of Homotopy Type Theory (HoTT). HoTT is here understood as intensional MLTT with Π, Σ, Id, 1, 0, +-types, a univalent universe U and propositional truncation ||−||. As usual we will loosely refer to HoTT as type theory. We will follow the general pattern that we followed when defining the interpretation of FOLDS into MLTT. We first define for any essentially finite FOL=∼-signature (L, h) a notion of an L-structure by describing a type expression HStruc(L, h) of “homotopy L-structures” (Definition 4.1), proving that this type expression is a well-formed type (Theorem 4.14), and taking the terms of this type to be our notion of L-structure (Definition 4.15). The notions of interpretation, satisfaction, model, theory etc. are then defined similar to Section 1 with some modifications to account for the newly- introduced logical symbols. m Notation. For any m ∈ N∞ we will write U for the types of h-level m in U with ∞ the convention that U =df U. We will also use the more recognizable notation PropU , SetU and GpdU for types of h-level 1, 2 and 3 respectively. In general, we will abuse notation and conflate a term A: U m with its underlying type (i.e. with its first projection). In all other notational matters related to type theory we will follow 36 DIMITRIS TSEMENTZIS

the notation of [Uni13] closely. In particular, we write IdA(a, b) for the identity type x.P of terms a, b of A and we write transp (t) for the (“covariant”) transport along p of a(n appropriate) type family P bound at some variable x for a given term t. More x.P precisely, transp (t) can be understood as being controlled by the following rule Γ ⊢ t: P [a/x] Γ ⊢ p: IdA(a, b) Γ, x: A ⊢ P Type x.P (trans) Γ, x: A ⊢ transp (t): P [b/x] which we will have ocassion to refer to in the proof of Lemma 4.13 below. Terminology. We will use the HoTT terminology and call a type A a mere propo- sition if its identity types are contractible in the sense that we have an inhabitant of the type. With this in mind what we will refer to as the universal property of propo- sitional truncation means that given a term η : A → P where P is a mere proposition we obtain a term ||η||: ||A|| → P and leave the details of the particular implementation of the propositional truncation operator ||−|| implicit. Definition 4.1 (Homotopy (L, h)-structure). Let L = (L, h) be an essentially fi- nite h-signature. The type of homotopy (L, h)-structures is given by the type expression HStruc(L, h)=df Σ (K : TK ) (24) K∈NL(L) where h(K) TK =df Π (f : Kf ) U (25) f∈K//L d and where the symbol Kf is defined by induction on the level of Kf as follows: d • El(app(∗,Kf )) if l(Kf )=0 • El(app[Kf (pf)p∈K//L]), if Kf ∈ NL(L) ∼ • Id (sf, tf), if Kf = =A for some A ∈L Ksf • Id (rf, reflsrf ), if Kf = ρA for some A ∈L Kdrf ^ \ ^ d hh1f.Kh1f [hh1f/hh1f] • Id\ (h2f, transehf (h2f)), if Kf ≡ τh for some (top-level) Kh2f ] h: A → K in L and where hh1f denotes a variable distinct from hh1f and hh2f.

Remark 4.2. Note that the logical sorts of a FOL=∼-signature L will appear in HStruc(L, h) only if they are the codomain of a non-logical arrow in L. Since L is assumed essen- tially finite it will contain only a finite number of non-logical symbols, and therefore the type expression HStruc(L, h) will always be of finite length (even if it contains non-logical sorts of h-level ∞).

Remark 4.3. In the definition of TK in Definition 4.1 we are suppressing the informa- tion that the symbol Kf (pf) actually consists both of a type expression (displayed d FIRST-ORDERLOGICWITHISOMORPHISM 37 above) as well as a proof (expression) that that type is of a certain h-level. So, for example, strictly speaking we would have ∼ =A(pf)=df hId (sf, tf), isofhlevel(h(A) − 1)i Asf (psf) d However, in order to not clutterd the notation further, we will keep this information implicit, noting of course that it is important in the proofs of Theorem 4.14 below.

Notation. For a given essentially finite FOL=∼ signature L we will write simply HStruc(L) for the type of homotopy L-structures of its underlying h-signature. ∼ ′ ′ Proposition 4.4. If L = L as FOL=∼-signatures then HStruc(L) ≡ HStruc(L ). ∼ ′ Proof. If L = L as FOL=∼-signatures then there is an isomorphism between the un- derlying h-signatures that preserves logical sorts and h-level, which implies exactly that the expressions HStruc(L) and HStruc(L′) are α-equivalent.  Remark 4.5. Note that Proposition 4.4 is not true if in its statement we replace “as FOL=∼-signatures” with “as h-signatures” since we require an isomorphism that preserves the logical sorts. Proposition 4.6. HStruc(L) ≡ HStruc(L=∼) Proof. Logical sorts appear in HStruc(L, h) only if they are the codomain of non- logical sorts. But the objects in L=∼ that are not in L are those that are not the codomain of any non-logical sort.  Remark 4.7. As Proposition 4.6 makes precise, our semantics does not distinguish between an h-signature and (the underlying h-signature of) its associated FOL=∼- signature. This is to be expected since FOL=∼-signatures add to an h-signature logical sorts that one gets for free in type theory. The importance for our purposes of the full FOL=∼ structure is that it allows us to reason about constructs in HoTT (e.g. using the deductive system D=∼ defined below) externally to HoTT and in particular externally to any specific HoTT (e.g. cubical type theory, UniMath etc.).

321 Example 4.8. Let Lrg denote the following h-signature: 1 I

i  2 A

c d  3 O Then by exactly the same reasoning as in Example 2.3 we get 321 3 2 1 HStruc(Lrg )=(O : U ) × (A: O → O → U ) × (I : (x: O) → A(x, x) → U ) The only thing that has changed from Example 2.3 is that O, A, I are now (functions landing in) the subuniverse of types of a certain h-level. 38 DIMITRIS TSEMENTZIS

Example 4.9. Consider the h-signature Lucat from Example 3.10. Lucat includes an ∼ arrow u2 whose codomain is the isomorphism sort =O. This means that an identity type will appear in HStruc(Lucat). To see how this works let us calculate the type expression TU associated to the sort U, recalling that h(U)=1. h(U) TU = Π (f : Kf (pf)) → U f∈U//L d ∼ 1 =(du1,cu1 : O) → (u1 : A(du1,cu1)) → (u2 : tu2 =O su2) → U ∼ 1 ≡ (x, y : O) → (f : A(x, y)) → (p: x =O y) → U

Thus, TU can be understood as a propositional family (or relation) over a choice of any two points x, y : O, an “arrow” f : A(x, y) and a “path” p: x =O y from x to y in O. With additional axioms this relation can express e.g. that there is a between “arrows” and “paths”, as indeed we will do when we axiomatize univalent categories as a Lucat-theory in the final section. Overall, up to the obvious equivalence, we get: ∼ 1 HStruc(Lucat) ≃ HStruc(Lprecat)×(U : (x, y : O) → (f : A(x, y)) → (p: x =O y) → U )

Example 4.10. We now do an example that involves transport structure. Consider the following h-signature Lt: 1 P l ⑧⑧ ⑧⑧ m ⑧⑧ ⑧ ⑧  1 I τd

i d1 ed  d x 2 & ∼ 2 A l =O tO d c  { sO 3 O s 321 The non-logical sorts of Lt other than P are exactly as in Lrg above. So it remains to determine TP . We have: 1 TP = Π (f : Kf (pf)) U f∈P//L

= Π(dil, cd2m, sedm, tedm: O)(il : A(dil, cil))(d2m: A(dd2m),cd2m)(d1m: A(dd1m,cd1m)

(edm: IdO(sedm, tedm))(l : I(il, dil)) ^ ^ dd1m.A(dd1m,cd1m) 1 (m: IdA(dd2m,cd1m)(d2m, transedm (d1m)) U ≡ Π(x,y,z,w : O)(f : A(x, x))(h: A(w,y)(g : A(z,y))

(p: IdO(z,w))(l : I(x, f)) v.A(v,y) 1 (m: IdA(w,y)(h, transp (g)) U

Intuitively a term of the type TP may be thought of as a relation that compares an “identity arrow” f to the transport h of an “arrow” g along a path p. Overall, we FIRST-ORDERLOGICWITHISOMORPHISM 39 get: 321 λv.A(v,y) 1 HStruc(Lt) ≡ HStruc(Lrg ) × Π Π IdA(w,y)(h, transp (g)) → U x,y,z,w : O p: IdO(z,w) f : A(x,x) l : I(x,f) h: A(w,y) g : A(z,y)

Example 4.11. Consider the following h-signature Lcircle: 1 loop ✈✈ ✈✈ ✈✈ m ✈z ✈ 1 base l

 ∼ ∞ b =O s

 Ñ t ∞ O u with the relations sl = tl = bm. This h-signature can be thought of as encoding the type of circles, i.e. of types together with a preferred point (picked out by the “predicate” base) and a preferred loop on that point (picked out by the “predicate” loop). The reason for the arrow m: loop → base is in order to ensure that the source (and target) x of the path p that we pick out by loop is also such that it satisfies base(x). The corresponding type of homotopy Lcircle-structures is given by: 1 HStruc(Lcircle) =(O : U) × (base: O → U )× 1 (loop: (x: O) → base(x) → IdtypeO(x, x) → U )

Lemma 4.12. Let L be an h-signature and for any f ∈ MorL let Kf be as in d Definition 4.1. Then for f,g such that l(Kf ) = l(Kg) = n we have Kf ≡ Kg iff d d Kf = Kg and (pf)p∈Kf //L =(pg)p∈Kg//L. Proof. We do the right-to-left direction and leave the other direction (which we do not require below) to the reader. We proceed by induction on the level n of Kf and Kg. Assume l(Kf )= l(Kg) = 0. Then if

Kf = Kg (26) we get (26) Kf ≡ El(app(∗,Kf )) ≡ El(app(∗,Kg)) ≡ Kg (27) d d Now assume the left-to-right implication holds for all m < n and that l(Kf ) = l(Kg) = n. Then we take cases. If Kf = Kg ∈ NL(L) then we get Kf ≡ Kg by the ∼ essentially the same argument as above. If Kf = Kg ==A then wed get Kdsf = Ksg and if (pf)=(pg) then in particular we get (qsf)=(qsg) sf = sg tf = tg (28) 40 DIMITRIS TSEMENTZIS

Hence, by the inductive hypothesis we get

Ksf ≡ Ksg (29) d d and therefore (28),(29) K ≡ Id (sf, tf) ≡ Id (sg,tg) ≡ K (30) f K Ksg g d sf d Analogous workd for the ρA and τh cases.d 

Lemma 4.13. For all K ∈ NL(L) the following context is well-formed

ΓK =df (A: TA)A≤K,A∈NL(L)

Proof. We proceed by <-induction on K, as in Lemma 2.6. Indeed, the proof proceeds exactly as in Lemma 2.6 until we reduce the induction to the step of proving (10), which now becomes more involved. So assume that we know that the following context

∆=df ΓA, (g : Kg)g

∆ ⊢ Kf Type (32) d is derivable. To do so we need to consider all the cases for Kf (qf). If Kf ∈ NL(L) then the proof proceeds just as in Lemma 2.6. So it remainsd to check the cases where Kf is a logical sort. ∼ If Kf ≡ =A for some A ∈L then we need to show that ∆ ⊢ Id (sf, tf) Type (33) Ksf is derivable. Firstly, note that sf,tfd < f and (by condition 1.(b) in Definition 3.2) ∼ we have top(=A)= {s, t}. Hence, we have

∆ ≡ ΓA, (g : Kg)g

∆ ⊢ Id (rf, reflsrf ) Type (36) Krf is derivable. Firstly, note that rfd < f and (by condition 2.(b) in Definition 3.2) top(ρA)= {r}. Hence, we have

∆ ≡ ΓA, (g : Kg)g

This implies that ∆ ⊢ reflsrf : Krf (39) is derivable. Hence, by applying Id-formation tod

∆ ⊢ rf : Krf ∆ ⊢ reflsrf : Krf (40) d d we obtain exactly (36). Finally, if Kf ≡ τh for some h ∈ MorL then we need to show that ^ \ ^ hh1f.Kh1f [hh1f/hh1f] \ Type ∆ ⊢ Id (h2f, transehf (h2f)) (41) Kh2f is derivable. As above, by the relevant conditions in Definition 3.2 we have \ \ [ [ [ ∆ ≡ ΓA, (g : Kg)g

sehf = hh1f tehf = hh2f (44) we obtain [ (44) Kehf ≡ Id \ (sehf, tehf) ≡ Id \ (hh1f, hh2f) (45) Ksehf Khh1f [ Now, since h1f < f, by the inductive hypothesis we know that ∆ ⊢ Kh1f Type is [ derivable (by weakening the smaller context in which we already know Kh1f to be a

type). Hence, since h is top-level for (τh)h1 (i.e. the codomain of h1) we can derive ] \ [ ] ∆, hh1f : Khh1f ⊢ Kh1f [hh1f/hh1f] Type (46) Furthermore, by (45) above we can derive

∆ ⊢ ehf : Id \ (hh1f, hh2f) (47) Khh1f [ Finally, since h1f : Kh1f appears in ∆ we have [ ] ∆ ⊢ h1f : Kh1f [hh1f/hh1f] (48) But now from (46),(47) and(48) we can apply the transport rule (trans) to obtain ^ \ ^ hh1f.Kh1f [hh1f/hh1f] [ ] ] ∆ ⊢ transehf (h2f): Kh1f [hh1f/hh1f][hh2f/hh2f] (49) But now observe that [ [ Kh2f ≡ Kh1f [hh2f/hh1f] (50) [ ] ] ≡ Kh1f [hh1f/hh1f][hh2f/hh1f] (51) [ [ since Kh2f differs from Kh1f only in hh1f (by the conditions in Definition 3.2). Hence, we have ^ \ ^ hh1f.Kh1f [hh1f/hh1f] [ ∆ ⊢ transehf (h2f): Kh2f (52) 42 DIMITRIS TSEMENTZIS

Since we also have [ ∆ ⊢ h2f : Kh2f (53) by Id-formation on (52) and (53) we obtain exactly (41), and we are done.  Theorem 4.14. HStruc(L) is a closed type. Proof. Since L is assumed essentially finite, by Lemma 4.13 we get immediately that

ΓL =df (K : TK )K∈NL(L) is well-formed. And then we obtain HStruc(L) (in the empty context) by successive applications of Σ-formation.  Definition 4.15 (L-structure). A homotopy L-structure is a term M of type HStruc(L). Remark 4.16. It is reasonable to now wonder, as the notation suggests, whether HStruc(−) can be thought of as a “functor” hSig → U (for some universe U). While it is easy to see that that for full and faithful logical h-morphisms I : L ֒→ L′ we will get induced functions HStruc(L′) → HStruc(L) using the projections of the Σ- types, to promote this assignment to a functor would lead us into the usual coherence problems with U (cf. [ACK15, Shu14]). We discuss the prospects for fixing this issue in our concluding remarks.

We would now like to define for any FOL∼=-signature L the interpretation of LT TL into HoTT in a manner analogous to Definition 2.9. However, we are here faced with the problem, alluded to in Remark 1.11, that even if L is essentially finite, its underlying FOLDS signature may not be, which means that LT TL would contain an infinite number of rules (one rule (K-form) for each sort K in L). In particular, for an essentially finite L, this will be the case precisely when L contains a sort of h-level ∞. However, in those cases we can still show that LT TL is “finitely presentable” in a sense that we make precise now. Definition 4.17. An ML type theory T T = (S, J, R) is finitary if R is finite (as a list). An ML type theory is finitely presentable if it is bi-interpretable with a finitary ML type theory.

Proposition 4.18. For any essentially finite FOL=∼-signature L, T TL is finitely pre- sentable. fp Proof. For a given FOL=∼ signature L we define the finitary ML type theory T TL as follows. Its syntax and judgments are exactly the same as T TL and it has all the structural rules as well as all the (K-form) rules for non-logical K. However, instead of (K-form) rules for logical K it instead contains the following three rules (in the order in which they are listed since there is dependence between them): Γ ⊢ x: A(z) Γ ⊢ y : A(z) ∼ ∼ (= -form) Γ ⊢ x =A(z) y Sort ∼ Γ ⊢ x: A(z) Γ ⊢ q : x = z x A( ) (ρ -form) Γ ⊢ ρA(z)(q, x) Sort FIRST-ORDERLOGICWITHISOMORPHISM 43

Γ ⊢ y : O(z) Γ ⊢ y′ : O(z) Γ ⊢ α: A(w) Γ ⊢ β : A(w)[y′/y] ′ Γ ⊢ p: y =O(z) y Γ,w : O(z) ⊢ A(w)[w /y] Sort h h (τ-form), h ∈L(A, O) Γ ⊢ τh(p,α,β) Sort fp  It is then immediately checked that T TL and T TL are bi-interpretable.

Corollary 4.19. For any essentially finite FOL=∼-signature L, LT TL is finitely pre- sentable.

Proof. LT TL only adds a finite number of rules to T TL regardless of whether or not fp fp L is essentially finite. So we can just define LT TL just as LT TL but extending T TL instead of T TL. 

fp Notation. For any FOL=∼-signature L we will now write T TL and LT TL for T TL fp and LT TL for LT TL and treat them as the same type theory.

With this in mind the interpretation of FOL=∼-contexts, context morphisms, for- mulas and sequents for a given homotopy L-structure M proceeds as in Definition 2.9 with extra stipulations for the logical sorts.

Definition 4.20 (Interpretation of LT TL in HoTT). Let L be a FOL=∼-signature. The depth of the expressions in the raw syntax of LT TL is defined as in Definition 2.9 with the following extra clauses: ∼ d(=K (x)) = d(K)+1

d(ρK (x)) = d(K)+2

d(τh(x)) = d(K)+3

The interpretation of LT TL into HoTT consists of the function J−Kc defined just as in Definition 2.9 and the new functions J−Ks and J−Kf defined as follows:

J−Ks : SortL → TypeMLTT K(x) 7→ El(app[KM(x)]) (K ∈ NL(L)) ∼ =K (x) 7→ IdJK(xps)Ks (xs, xt) x IdId refl ρK( ) 7→ JK(xpsr )Ks (xsr,xtr)(xr, xsr )

xhh1 .Jdom(h)(xph1 )Ks[xhh1 /xhh1 ] τh(x) 7→ IdJdom(h)(x )K (xh , transeh (xh ) ph2 s 2 g g 1 44 DIMITRIS TSEMENTZIS

J−Kf : FormulasL → TypeMLTT ⊥ 7→ 0 ⊤ 7→ 1

φ ∧ ψ 7→ JφKf × JψKf

φ ∨ ψ 7→ ||JφKf + JψKf ||

φ → ψ 7→ JφKf → JψKf

∃x: K.φ 7→ ||Σ(x: JKKs) JφKf ||

∀x: K.φ 7→ Π(x: JKKs) JφKf

The interpretation of the judgments of LT TL is then just as in Definition 2.9. Remark 4.21. To make it clear, the two changes in Definition 4.20 over Definition 2.9 is that J−Ks is defined by induction on the level of K taking into account the logical sorts and that in J−Kf we are now truncating ∨ and ∃. Theorem 4.22 (Correctness of the HoTT Interpretation). If S is a derivable judg- ment in LT TL then JSK is a derivable judgment in MLTT.

Proof. We proceed by induction on the depth of the expressions of LT TL. By inspec- tion we can see that the depth function in Definition 4.20 is once again correct in the sense that for every rule of LT TL the depth of the expression below the line is strictly greater than the depth of any of the expressions above the line. The proof thus can proceed by induction on the complexity of derivations of LT TL. The only rules that we need to check whose proof is not the same as in Theorem 2.11 are the formation rules for the logical sorts and the formula formation rules for ∨ and ∃ which now involve truncation. We take them in turn:

(∼= -form): We have the following: ∼ JΓ ⊢ x: A(z)K JΓ ⊢ y : A(z)K J(= -form)K = ∼ JΓ ⊢ x =A(z) y SortK JΓK ⊢ x: JA(z)K JΓK ⊢ y : JA(z)K = JΓK ⊢ IdJA(z)K(x, y) Type But this is exactly Id-formation.

(ρ-form): We have the following: ∼ JΓ ⊢ x: A(z)K JΓ ⊢ q : x = z xK J(ρ-form)K = A( ) JΓ ⊢ ρA(z)(q, x) SortK

JΓK ⊢ x: JA(z)K JΓK ⊢ q : Jx ∼= z xK = A( ) Id JΓK ⊢ Id JA(z)K(x,x)(q, reflx) Type

JΓK ⊢ x: JA(z)K JΓK ⊢ q : Id z (x, x) = JA( )K Id JΓK ⊢ Id JA(z)K(x,x)(q, reflx) Type FIRST-ORDERLOGICWITHISOMORPHISM 45

But this follows by an application of Id-introduction on JΓK ⊢ x: JA(z)K followed by Id-formation. (τ-form): We have the following: JΓ ⊢ y : O(z)K JΓ ⊢ y′ : O(z)K JΓ ⊢ α: A(w)K JΓ ⊢ β : A(w)[y′/y]K ′ JΓ ⊢ p: y ∼= z y K JΓ,w : O(z) ⊢ A(w)[w /y] SortK J(τ-form)K = O( ) h h JΓ ⊢ τh(p,α,β) SortK JΓK ⊢ y : JO(z)K JΓK ⊢ y′ : JO(z)K JΓK ⊢ α: JA(w)K JΓK ⊢ β : JA(w)[y′/y]K ′ JΓK ⊢ p: Jy =∼ z y K JΓK,w : JO(z)K ⊢ JA(w)[w /y] SortK = O( ) h h wh.JA(w)K[wh/y] JΓK ⊢ IdJA(w)K(β, transp (α)) Type But this follows by an application of (trans) and Id-formation. (∨-form): Given that JΓK is a well-formed context and JφK and JψK are types in that context, then by +-formation we get JΓK ⊢ JφK + JψK Type (54) and then by an application of truncation we get JΓK ⊢ || JφK + JψK || Type (55) as required. (∃-form): Given that JΓ, x: KK = JΓK, x: JKK is a well-formed context and JφK is a type in that context, then by Σ-formation we get JΓK ⊢ Σ(x: JKK) JφK Type (56) and then by an application of truncation we get JΓK ⊢ || Σ(x: JKK) JφK || Type (57) as required.  Remark 4.23. Theorem 4.22 guarantees that for any categorical semantics of (any type theory HoTT+ extending) HoTT for which the initiality conjecture has been established there will be a model of LT TL in any model of those categorical semantics, and in particular in any model in ∞-toposes. However, in order to make this fact a fully rigorous corollary, we need to have a definition of a “model of LT TL” in terms of some yet-to-be-defined categorical semantics for LT TL. We plan on giving such definitions in a follow-up to this paper. With those definitions in hand Theorem 4.22 establishes that the term model (assuming it exists) of any HoTT+ will contain a model of (the categorical semantics for) LT TL, for any FOL=∼-signature L.

Corollaries 2.12 and 2.13 now carry over to FOL=∼ verbatim. Similarly, the notion of extension, realization, satisfaction, model and type of models in Definitions 2.15, 2.16 and 2.22 carry over immediately to FOL=∼, as does the notion of a theory and (classical) entailment in Definitions 1.30 and 1.31. 46 DIMITRIS TSEMENTZIS

That said, we now must record some results that are important in the setting of HoTT that do not necessarily arise in the more traditional setting of MLTT.

Corollary 4.24. For any formula-in-context Γ.φ and any L-structure M we have that φM is a mere proposition (in context ΓM).

Proof. Immediate by the definition of the interpretation of formulas, since the only type-formers that do not preserve h-level are Σ, + and we truncate them. 

Corollary 4.25. Let L be an h-signature. For any L-theory T let T=∼ be the same theory over L=∼. Then Mod(T)= Mod(T=∼)

Proof. Immediate from Proposition 4.6. 

We conclude this section with several examples illustrating the semantics of FOL=∼.

Example 4.26. Let LK,1 be the h-signature with one object of h-level 1. Then an LK,1-structure is simply a mere proposition P : PropU . Similarly, if we write LK,n for the FOL=∼-n-signature with one object of h-level n, a LK,n-structure is a type of h-level n.

Example 4.27. An Lgraph-structure consists of an h-set O : SetU and a mere relation A: O → O → PropU .

321 Example 4.28. An Lrg -structure M consists of the following data: M I : Π A(x, x) → PropU x: OM M M M A : O → O → SetU M O : GpdU 321 =∼ Note that an (Lrg ) -structure consists of exactly the same data since the logical sorts do not appear in HStruc(Lrg) (since no non-logical sort depends on them).

Example 4.29. In Lrg if we are given the formula φ ≡ ∃τ : I(x, f).⊤ then its inter- pretation in some Lrg-structure M will be given by || Σ 1|| which is of course τ : IM(x,f) equivalent to ||IM(x, f)||. The interpertation of φ in M thus consists of the following judgement x: OM, f : AM(x, x) ⊢ ||IM(x, f)|| Type where we are abusing notation in using IM(x, f) for what really is its first projection M since strictly speaking I was defined as a dependent function into PropU . Its extension is M M ExtΓ (φ) = Σ ||I (x, f)|| x: OM f : AM(x,x) and M|= φ[a/Γ] iff there is a derivable term M a : ExtΓ (φ) FIRST-ORDERLOGICWITHISOMORPHISM 47

= Example 4.30. Consider Lgraph:

1 A =O

 Õ 2 O w

Lgraph-formulas are then exactly (when suitably translated) the formulas of first-order logic with equality for a single-sorted signature Σ with a single binary predicate A. M Semantically, an Lgraph-structure M consists of an h-set O : SetU and a dependent M M M type A : O → O → PropU . This is all entirely analogous to Σ-structures in traditional set-theoretic semantics. FOL= can thus be thought of as the “classical limit” of FOL=∼.

Example 4.31. Consider the following Lrg-sentence φ ≡ ∀x: O∃f : A(x, x).I(f)

and let M be the Lrg-1-structure given by the following data

hSetU , λx.λy.x → y, λx.λf.Idx→x(f, 1x)i Then M is a model of φ. To see this, observe that M|= ∀x: O∃f : A(x, x).I(f) since ∅ ⊢ λx.(1x, refl1x ): Π || Σ Idx→x(f, 1x)|| x: SetU f : x→x is derivable in HoTT and since the interpretation of φ is given by M (∀x: O∃f : A(x, x).I(f)) ≡ Π || Σ Idx→x(f, 1x)|| x: SetU f : x→x

Example 4.32. If we define Tcircle as the Lcircle-theory which consists of the single axiom ∀x: O.∀τ : base(x).∃l : x =O x.loop(l, τ) we can easily deduce that

Mod(Tcircle) ≃ Σ(O : U)(base: O) IdO(base, base) The higher inductive type corresponding to the circle S1 can then be understood as an initial object in an appropriate precategory structure for Mod(Tcircle) as has been documented in [Soj15]. More generally, the existence of initial models for FOL=∼- theories will be equivalent to the existence of certain higher inductive types. This example thus illustrates the essence of the connection of FOL=∼ with the problem of finding a general specification of higher inductive types, a connection which seems to us worth pursuing. Deductive System for FOL 5. =∼

We will now describe a proof system D=∼ for FOL=∼ and prove a soundess theorem for it with respect to our homotopy semantics. The rules of D=∼ will be the rules of DFOLDS supplemented with an axiom (ρ) that postulates the existence of the “trivial 48 DIMITRIS TSEMENTZIS

isomorphism” in terms of the reflexivity sort, an axiom (τρ) that postulates that “transporting along the trivial isomorphism does nothing”, and a rule (J) governing the isomorphism sorts that can be understood as a “first-order” version of the Id- elimination rule of type theory. Notation. In the presentation below, we will assume all the sequents are well-formed. In particular, this will eliminate all ambiguity regarding which variables depend on which others, e.g. in the (τρ) rule below. We will generally suppress (implicit) variable dependencies, e.g. writing simply x =K y without making explicit the variables on which K might depend. We will also drop subscripts for equality, reflexivity and transport sorts when the sort to which they refer is clear from the context, and write ∼ simply =, ρ and τ. For a formula φ in context Γ, x: K,y : K,p: x =K y we will use the notation φ[x, x, q] (e.g. in the (J) rule below) to denote the formula δ(φ) obtained by along the “contraction” context morphism

δ : Γ, x: K, q : x =K x ⇒ Γ, x: K,y : K,p: x =K y

Definition 5.1. The proof system D=∼ for FOL=∼ for any given FOL=∼-signature L consists of the rules of (intuitionistic or classical, regular, coherent or full) DFOLDS together with the following three rules:

(ρ) Γ, x: K | θ ⇒ ∃q : x ∼= x.ρ(q)

(τρ) Γ, x: K, α: A, q : x ∼= x | ρ(q) ∧ θ ⇒ τ(q,α,α)

Γ, x: K, q : x ∼= x | ρ(q) ∧ θ[x, x, q] ⇒ φ[x, x, q] (J) Γ, x: K,y : K,p: x ∼= y | θ ⇒ φ

If we also include the law of the excluded middle (LEM) as an axiom then we cl denote the corresponding proof system by D=∼. cl Notation. When what we say applies to both D=∼ and D=∼ we will use the notation (cl) cl D=∼ . Analogous to Definition 1.31 we write ⊢=∼ (resp. ⊢=∼) for entailment in D=∼ (resp. cl (cl) D=∼) and when what we have to say applies to both systems we write ⊢=∼ ). Remark 5.2. The intuition behind the new rules is as follows. The (ρ) rule encodes the fact that for any term x of a sort K there is an inhabitant p of the isomorphism sort x ∼= x for which the “reflexivity predicate” can be asserted, i.e. there is always a trivial isomorphism from an object to itself. The (τρ) rule encodes the fact that transporting along the trivial isomorphism “does nothing”, i.e. it is the same as applying the identity “function(al relation)”. The (J) rule is an adaptation of the Id- elimination rule of type theory, and it can be understood (and thereby also justified at an intuitive level) as saying that if we wish to prove a statement about two objects and an isomorphism between them then it suffices to prove the same statement for FIRST-ORDERLOGICWITHISOMORPHISM 49 one of these objects and the trivial isomorphism. The remarkable consequence of this rule is that it ensures that every statement is “invariant under isomorphism” even as it allows us to consider multiple (distinct) isomorphisms between objects, and in particular non-trivial ones.

Remark 5.3. We note that the (J) rule above corresponds to what in MLTT would be called strong Id-elimination since θ behaves like a contextual parameter that may itself depend on the variables x,y,p. In the presence of Π-types, strong Id-elimination is equivalent to the usual form (without a contextual parameter). Similarly, in the presence of universal quantification our rule (J) is equivalent to the perhaps more recognizable form

Γ, x: K, q : x = x | ρ(q) ⇒ φ[x, x, q] (wJ) Γ, x: K,y : K,p: x =K y |⊤⇒ φ

T Theorem 5.4 (Soundness for homotopy semantics). Let be a FOL=∼ L-theory. If T (cl) T (cl) ⊢=∼ τ then |=h τ.

Proof. All rules of D=∼ that are in DFOLDS and do not involve ∃ or ∨ have been shown to be sound in Theorem 2.19. For the rules involving ∃ and ∨ we must now use the universal property of the propositional truncation in a straightforward way. We will do the case of the (∃) rule Γ, x: K | φ ⇒ ψ (∃) Γ | ∃x: K.φ ⇒ ψ as an illustration. If the interpretation of the top line in (∃) is true (in some M) this means that we have derived a term η : Π φM → ψM x: ΓM y : KM Then we can define the following term M M ξ =df λx.(λhy,pi.η(x,y)(p)): Π Σ φ → ψ x: ΓM y : KM But since ψM will be a mere proposition for any substitution instance of its free variables, by the universal property of the propositional truncation and the fact that Π-types preserve mere we obtain a term M M ||ξ|| =df λx.||(λhy,pi.η(x,y)(p))||: Π || Σ φ || → ψ x: ΓM y : KM This is exactly the translation of the (satisfaction of the) bottom sequent in (∃). The soundness of the rest of the rules involving ∨ and ∃ follows straightforwardly, making use of the universal property of the propositional truncation when needed in the manner just sketched. 50 DIMITRIS TSEMENTZIS

So it remains to prove soundness for the new rules (ρ), (J) and (τρ). As before, we fix an arbitrary L-structure M. For (ρ) we need to show that M satisfies the sequent Γ, x: K | θ ⇒ ∃q : x = x.ρ(q) (58) We have Γ, x: K|θ ⇒ ∃q : x = x.ρ(q))M = Π(ΓM, x: KM)θM → || Σ Id (q, refl )||  IdKM (x,x) x q : IdKM (x,x) (59) But then we have that the term

||hrefl , reflrefl i||: || Σ Id (p, refl )|| (60) x x IdKM (x,x) x p: IdKM (x,x) is derivable in context ΓM, x: KM which means exactly that in the same context we can derive a term M λy.||hrefl , reflrefl i||: θ → || Σ Id (p, refl )|| (61) x x IdKM (x,x) x p: IdKM (x,x) The derivability of this term means exactly that the required sequent (58) is satisfied by M. For (τρ) we need to show that M satisfies the sequent Γ, x: K, q : x ∼= x, α: A | ρ(q) ⇒ τ(q,α,α) (62) Given that the sequent is well formed we know we have a type family ΓM, x: KM ⊢ AM : Type (63) Then by the definition of transport in type theory we have: M A Γ, x: K ⊢ transreflx ≡ λα.α: A(x) → A(x) (64) which means that M A Γ, x: K , α: A(x) ⊢ transreflx (α) ≡ α (65) and therefore also M A Γ, x: K , α: A(x) ⊢ IdA(x)(α, transreflx (α)) (66) But the inhabitation of this last type is exactly equivalent to the inhabitation of the type A IdId (q, refl ) → Id M (α, trans (α)) (67)  KM (x,x) x  A (x) q M M M in context Γ , x: K , q : IdKM (x, , x), α: A , which means exactly that the required sequent (62) is satisfied in M. For (J), given the availability of Π-types in type theory, we will prove (wJ) for simplicity since the main idea of the argument is exactly the same. So assume we know that the sequent Γ, x: K, q : x = x | ρ(q) ⇒ φ[x, x, q] FIRST-ORDERLOGICWITHISOMORPHISM 51 is satisfied by M. This means that we have a term M ǫ: Π IdId M (x,x)(q, reflx) → φ [x, x, q] (68) z: ΓM K x: KM Id q : KM (x,x) in type theory. Hence we can define a term M M η =df λz: Γ .λx.ǫz,x(reflreflx ): Π φ [x, x, reflx] (69) z: ΓM x: KM But then by the elimination rule for identity types we immediately get a term of M M M Π (Γ ,x,y : K ,p: IdKM (x, y)) φ (70) which is of course equivalent to M M M Π (Γ ,x,y : K ,p: IdKM (x, y)) 1 → φ (71) But the inhabitation of (71) means exactly that the sequent below the line in (wJ) is satisfied by M, as required. Finally, we note that the of LEM in HoTT+LEM is immediate, essentially by definition, since φM is a mere proposition for any L- formula M.  Remark 5.5. We note that a “propositional” (τρ)-rule in which transporting a term along reflexivity is only propositionally equal to itself would also be sound since in A the proof of soundness above the judgmental equality transreflx (α) ≡ α is used to extract a propositional equality. For example, this would ensure that a soundness theorem for D=∼ can also be proven for a homotopy semantics in cubical type theory. Remark 5.6. One might wonder whether the class of (homotopy) models we are con- sidering for FOL=∼ is too wide. In particular, one might wonder whether FOL=∼ can take semantics where every type is interpreted as a set (i.e. a 0-type) much as in Makkai’s original formulation of the semantics of FOLDS. This is not the case. FOL=∼ does in fact have the expressive power to force a theory to have only models whose ground sorts are n-types. As the simplest possible illustration, take the h-signature LK,1 as in Example 4.26. Consider the (full first-order) LK,1-theory TO consisting of the single axiom ∼ ∼ φ =df ∀x, y : O.∃p, q : x =O y.¬(p =O q) with the obvious abbreviations. Every model of TO where O is interpreted as an h-set (resp. discrete groupoid) falsifies φ. But TO is satisfiable: simply take an L-structure where O is interpreted as a (proper) 1-type. Given the soundness theorem above this means that φ cannot be disproved by D=∼ even though it is not satisfied in any set-model of TO. As such, set models are not sufficient to describe provability for FOL=∼. We now indicate how the rules of the proof system have the consequences that our homotopy semantics demands. Proposition 5.7 (“Substitution Salva Veritate”). For any L-formula φ in context Γ, x: K the following sequent is derivable Γ, x: K,y : K | x = y ∧ φ ⇒ φ[y/x] 52 DIMITRIS TSEMENTZIS

Proof. Note that since x, y are declared last in the context there can be no free variable in φ which depends on either, which means that the substitution φ[y/x] is well-defined. This means in particular that no q : x = x can appear free in φ which implies that we have φ[y/x][x, x, q] ≡ φ[x, x, q] (72) With this in mind we have the following derivation, starting from (iden): Γ, x: K, q : x = x | φ[x, x, q] ⇒ φ[x, x, q] (∧-intro) Γ, x: K, q : x = x | ρ(q) ∧ φ[x, x, q] ⇒ φ[x, x, q] (72) Γ, x: K, q : x = x | ρ(q) ∧ φ[x, x, q] ⇒ φ[y, x][x, x, q] (J) Γ, x: K,y : K,p: x = y | φ ⇒ φ[y/x] (∃) Γ.x: K,y : K | x = y ∧ φ ⇒ φ[y/x] where (∧-intro) is the obvious derived rule. 

Together with (ρ), Proposition 5.7 gives us the usual rules for identity in any first- order sequent calculus (e.g. as it is presented in [Joh02]), as the following record. Corollary 5.8 (“Mere equality is an ”). The formula ∼ ∼ x =K y =df ∃p: x =K y.⊤ is reflexive, symmetric and transitive. But one could now wonder whether Proposition 5.7 and Corollary 5.8 generalize to sorts of higher h-level, i.e. whether we can prove that the inhabitants of isomorphism sorts also behave like the isomorphisms of (higher) groupoids (rather than merely recording the usual extensional equality). In particular we can ask whether logical sorts equip non-logical sorts of h-level m with the structure of an m-groupoid. This is indeed the case with the transport structure providing a notion of composition that is invisible at lower h-levels. We will here prove the case for sorts K of h-level 3, with the basic idea being the following: • K is the sort of objects of the groupoid ∼ • =K is the sort of isomorphisms ∼ • ==∼K is the equality on isomorphisms • ρK is the predicate that picks out the trivial isomorphism

• τsK is the composition (functional) relation We will now make this basic idea precise. Proposition 5.9 (“Transport is an equivalence”). The transport sorts τ(p,α,β) in a FOL=∼-signature L define a functional relation that is also an equivalence, in the sense that the following sequents are derivable: (1) Γ,p: x ∼= y, α: A(x, w) |⊤⇒∃β : A(y, w).τ(p,α,β) (2) Γ, α: A(x, w),p: x ∼= y,β,β′ : A(y, w) | τ(p,α,β) ∧ τ(p,α,β′) ⇒ β ∼= β′ (3) Γ,p: x ∼= y,α,α′ : A(x, w), β : A(y, w) | τ(p,α,β) ∧ τ(p, α′, β) ⇒ α ∼= α′ (4) Γ,p: x ∼= y, β : A(y, w) |⊤⇒∃α: A(x, w).τ(p,α,β) FIRST-ORDERLOGICWITHISOMORPHISM 53

Proof. All four sequents follow by a straightforward application of (τρ) and (J). We do (1) as an illustration and leave the rest to the reader:

(τρ) Γ, q : x ∼= x, α: A(x, w) | ρ(q) ⇒ τ(q,α,α) (∃-intro) Γ, q : x ∼= x, α: A(x, w) | ρ(q) ⇒ ∃β : A(x, w).τ(q,α,β) (J) Γ,p: x =∼ y, α: A(x, w) |⊤⇒∃β : A(y, w).τ(p,α,β) Here once again (∃-intro) signifies the obvious derived rule of existential instantiation. 

Lemma 5.10. Let LK,3 be the following h-signature:

1 τ ρ ∼∼ sK K ∼ ==K ❈ (sK )1 s=K ❈❈ ❈❈ rK ❈❈ (tK )1 ❈!   Ó t∼ ∼ w =K 2 3 =K esK sK tK  3 K

Then LK,3 is isomorphic, as an h-signature, to Lcat.

Proof. Let I : LK,3 →Lcat be the functor (indeed h-morphism) that on objects sends

K 7→ O, =K7→ A, τsK 7→ ◦, ρK 7→ I, ==K 7→=A and on arrows sends (sK)1 7→ t2,

(sK)2 7→ t1 and esK 7→ t0. By inspection one can immediately check that the relations between arrows imposed by the logical sorts in LK,3 are exactly the same as the stipulated relations in Lcat under this mapping, thus making I a full and faithful functor bijective on objects. 

Terminology. Lemma 5.10 allows us to speak of the FOLDS LK,3-theory of groupoids whose axioms are those of Tgpd but expressed over the isomorphic FOLDS signature LK,3 rather than over Lcat in the obvious way. We can then take the FOL=∼-signature =∼ =∼ LK,3 associated to LK,3 and thus obtain both the FOLDS LK,3-theory of groupoids =∼ (over DFOLDS) and the empty LK,3-theory (over D=∼). We say that two theories (un- derstood as a set of axioms together with a deductive system) are logically equivalent if there is an isomorphism between their signatures such that a sentence is derivable from one theory it is derivable from the other. With the above terminology in mind we can now make precise the sense in which sorts of h-level 3 in FOL=∼ are groupoids. =∼ Proposition 5.11 (“Sorts of h-level 3 are groupoids”). The FOLDS LK,3-theory of =∼ groupoids (over DFOLDS) is logically equivalent to the empty LK,3-theory (over D=∼). ∼ Proof. We will use the notation = for =K and = for ==K in LK,3 in order to hint at the intended interpretation. Furthermore, for p: x ∼= y,u: x ∼= z, q : y ∼= z we will use the notation ◦(p,q,u)=df τs(p,u,q) 54 DIMITRIS TSEMENTZIS

in order to understand u as the composite of p and q (even though q is the transport along p of u in the intended interpretation of τs). First, we check that all the axioms for the LK,3-theory of groupoids are derivable using only the rules of D:

(1) (Equality is an equivalence relation satisfying substitution salva veritate) As already noted, this follows from Proposition 5.7. (2) (Existence of identities) ∀x: K.∃i: x ∼= x.ρ(i) This follows immediately from (ρ). (3) (Functionality of composition-1) ∀x, y, z : K.∀f : x =∼ y.∀g : y ∼= z.∃h: x ∼= z. ◦ (f,g,h) This is a special case of Proposition 5.9. (4) (Functionality of Composition-2) ∀x, y, z : K.∀f : x =∼ y.∀g : y ∼= z.∀h, h′ : x ∼= z. ◦ (f,g,h) ∧◦(f,g,h′) → h = h′ This is once again a special case of Proposition 5.9. (5) (Right unit) ∀x, y : K.∀i: x ∼= x.∀g : x =∼ y.ρ(i) →◦(i,g,g) This is exactly the (τρ) rule. (6) (Left unit) ∀x, y : K.∀i: y ∼= y.∀f : x ∼= y.ρ(i) →◦(f, i, f) This follows by a straightforward application of the (J) rule. (7) (Uniqueness of identity) ∀x: K.∀i, j : x =∼ x.ρ(i) ∧ ρ(j) → i = j By Proposition 5.9.(2) it suffices to show ∀x: K.∀i, j : x ∼= x.ρ(i) ∧ ρ(j) →◦(i, j, j) ∧◦(i, j, i) (73) But this follows from the left and right unit axioms above. (8) (Associativity) ∀x,y,z,w : K.∀f : x =∼ y.∀g : y ∼= z.∀h: z ∼= w.∀i: x ∼= z.∀j : x ∼= w. ∀k : y ∼= w. ◦ (f,g,i) ∧◦(i, h, j) ∧◦(g,h,k) →◦(f,k,j) By the (J) rule it suffices to prove ◦(ρ(f),g,g) ∧◦(g, ρ(h),g) ∧◦(g, ρ(h),g) →◦(ρ(f),g,g) which follows immediately from the (already proven) left and right unit axioms. (9) (Every arrow is an isomorphism) ∀x, y : K.∀p: x ∼= y.∃q : y ∼= x.∃u: x ∼= x.∃v : y ∼= y. ◦ (p,q,ρ(u)) ∧◦(q,p,ρ(t)) Let us abbreviate the formula that begins with the existential quantifier as isiso(p). Then we have: ′ ′′ ′ ∼ ′ ∼ ′ ′′ ′ ′ ′ ′′ isiso(p)[x, x, q ] ≡ ∃q ,u : x = x.∃v : x = x.τs(ρ(u ), q , q ) ∧ τs(ρ(v ), q , q ) FIRST-ORDERLOGICWITHISOMORPHISM 55

By the (J) rule it now suffices to show that isiso(p)[x, x, q′] is derivable. Indeed, we have: ρ(q) → ∃u′ : x ∼= x.∃v′ : y =∼ y.ρ(u′) ∧ ρ(v′) ′ ′′ ∼ ′ ∼ ′ ′ ′′ (τρ), (ρ), 5.9 ρ(q) → ∃u , q : x = x.∃v : y = y.ρ(v ) ∧ τs(ρ(u ), ρ(q ), q) ′′ ′ ∼ ′ ∼ ′ ′′ ′ ′ ′ ′′ (τρ), 5.9 ∃q ,u : x = x.∃v : x = x.τs(ρ(u ), q , q ) ∧ τs(ρ(v ), q , q ) isiso(p)[x, x, q′]

Conversely, we must show that the rules (ρ), (τρ), (J) of D=∼ are derivable from the LK,3-theory of groupoids over DFOLDS. But note that the axioms (ρ) and (τρ) are direct translations of axioms of the theory of groupoids. And the (J) rule follows from the well-known result of Makkai in [Mak95] that the FOLDS Lcat-formulas are precisely the formulas that are invariant under isomorphism of objects in a category.  We expect the higher analogues of Proposition 5.11 to also be true. In particular, =∼ we expect that the empty FOL=∼-theory over the signature LK,∞ associated to the h- signature with only one object K of h-level ∞ to be logically equivalent to a (suitable) theory of ∞-groupoids. Making this a precise statement and proving it is left for future work. But even as things stand, D=∼ allows us to formulate a new definition of =∼ an ∞-groupoid: it is a model of the empty FOL=∼-theory over LK,∞. 6. Examples and Applications FOLDS was invented as a systematic way of avoiding the use of equalities that are irrelevant for the structures of interest, e.g. equality between objects when we care about categories only up to equivalence. On the other hand, FOL=∼ represents a partial reversal of this idea, since we are re-introducing equalities as logical sorts with a fixed interpretation, together with transport function(al relation)s and reflexivities. In this final section we examine applications and interesting examples that indicate that this partial reversal is useful in the setting of the Univalent Foundations. Let Lprecat be the h-signature described in Example 3.9. The Lprecat-theory of precategories Tprecat consists of the axioms laid out in Example 1.32. A homotopy Lprecat-structure thus consists of the following data: • A type O : U • A dependent function A: O → O → SetU • A dependent function I : Π A(x, x) → PropU x: O • A dependent function ◦: Π A(x, y) → A(y, z) → A(x, z) → PropU x,y,z : O

We can now translate the axioms of Tprecat into types in HoTT for an arbitrary M model M of Tcat. We will list them in order, writing = for the identity type on A and omitting M from superscripts for readability:

(T1) Π || Σ I(i, x)|| (T2) Π || Σ ◦ (f,g,h,x,y,z)|| x: O i: A(x,x) x,y,z : O h: A(x,z) f : A(x,y) g : A(y,z) 56 DIMITRIS TSEMENTZIS

′ (T3) Π h = h (T5) Π i = j x,y,z : O x: O f : A(x,y) i,j : A(x,x) g : A(y,z) φ: I(i,x) h,h′ : A(x,z) ψ : I(j,x) τ1 : ◦(f,g,h,x,y,z) ′ (T6) Π ◦ (i,g,g,x,x,y) τ2 : ◦(f,g,h ,x,y,z) x,y : O i: A(x,x) (T4) Π Π ◦(f,k,j,x,y,w) g : A(x,y) x,y,z,w : Oτ1 : ◦(f,g,i,x,y,z) φ: I(i,x) f : A(x,y) τ2 : ◦(i,h,j,x,z,w) g : A(y,z) τ3 : ◦(g,h,k,y,z,w) (T7) Π ◦ (f,i,f,x,y,y) h: A(z,w) x,y : O i: A(x,z) i: A(y,y) j : A(x,w) f : A(x,y) k : A(y,w) φ: I(i,y)

We thus obtain: Mod(T ) ≡ T × T × T × T × T × T × T precat X 1 2 3 4 5 6 7 O : U A: O→O→SetU I : Π A(x,x)→PropU x : O ◦: Π A(x,y)→A(y,z)→A(x,z)→PropU x,y,z : C On the other hand in [Uni13] a precategory is defined by the following data: (1) A type C : U (2) A dependent function HomC : C → C → SetU (3) A dependent function 1: Π HomC(a, a) a: C (4) A dependent function ◦: Π HomC(a, b) → HomC(b, c) → HomC(a, c) a,b,c: C (5) A dependent function assoc: Π Π h ◦ (g ◦ f)=(h ◦ g) ◦ f a,b,c,d: C f : HomC(a,b) g : HomC(b,c) h: HomC(c,d) (6) A dependent function ident: Π Π (f ◦ 1a = f) × (1b ◦ f = f) a,b: Cf : HomC (a,b)

We can now show that precategories are “FOL=∼-elementary” in the sense that they T are axiomatizable, up to equivalence, by cat over the FOL=∼-signature Lcat. In what follows below we will be making free use of the HoTT version of the Axiom of Unique Choice (AUC) ([Uni13], Corollary 3.9.2).

Proposition 6.1. PreCat ≃ Mod(Tprecat) Proof. The proof boils down to proving, using AUC, that an axiomatization of a category in terms of a relation of composition is equivalent to the usual axiomatization in terms of an operation of composition. First we define a function

p: Mod(Tprecat) → PreCat (74)

So let C : Mod(Tprecat) and write ti for the inhabitants of each axiom Ti that is part of the data of C. We need to provide the data for conditions (1)-(6) in the definition of precategories. We are given O and A and those immediately take care of conditions (1) and (2). For condition (3) we first observe that Σ I(i, x) is a mere i: A(x,x) proposition for any x: O. For suppose that (i, φ) and (j, ψ) are two terms of type FIRST-ORDERLOGICWITHISOMORPHISM 57

Σ I(i, x, x). To show that (i, φ)=(j, ψ) it suffices to show that there is p: i = j i: A(x,x) and that p∗(φ)= ψ. By applying t5 to the data hx, i, j, φ, ψi we get a proof that i = j, i.e. a term p: i = j. Clearly, since I(i, x, x) and I(j, x, x) are mere propositions, we also get that ψ = p∗(φ) and therefore we get that (i, φ)=(j, ψ) and therefore that the type Σ I(i, x, x) is a mere proposition. By AUC and t1 we get a term i: A(x,x) u: Π Σ I(i, x, x) (75) x: O i: A(x,x) Thus we can define, for each x: O, the following term

1x =def proj1(ux): A(x, x) (76) and thus we obtain a term C 1 =def λx.1x : Π A(x, x) (77) x: O as required by condition (3). Condition (4) follows similarly and we omit the details. For condition (5), let x,y,z,w : O and f : A(x, y),g : A(y, z) and h: A(z,w). Now let C C C r =def (t4) C C C C : Π ◦(f, h◦ g, h◦ (g◦ f),x,y,w) x,y,z,w,f,g,h,g◦ f,h◦ (g◦ f),h◦ g C τ1 : ◦(f,g,g◦ f,x,y,z) C C C τ2 : ◦(g◦ f,h,h◦ (g◦ f),x,z,w) C τ3 : ◦(g,h,h◦ g,y,z,w) (78) We can then define

p1 =def proj2(cx,y,z,f,g)

p2 =def proj2(cx,z,w,g◦Cf,h)

p3 =def proj2(cy,z,w,g,h)

C C C and thus rp1,p2,p3 : ◦ (f, h ◦ g, h ◦ (g ◦ f),x,y,w). But by definition we have a term π : ◦ (f, h ◦C g, (h ◦C g) ◦C f,x,y,w) and therefore we get a term C C C C (t ) C C refl refl C C C C : h◦ (g◦ f)=(h◦ g)◦ f 11 x,y,w,f,f,h◦ g,h◦ g, f , h◦C g ,h◦ (g◦ f),(h◦ g)◦ f,rp1,p2,p3 ,π (79) Thus we can define C assoc = (t ) C C refl refl C C C C (80) x,y,z,w,f,g,h def 4 x,y,w,f,f,h◦ g,h◦ g, f , h◦C g ,h◦ (g◦ f),(h◦ g)◦ f,rp1,p2,p3 ,π and this gives us the section assocC : Π Π h ◦ (g ◦ f)=(h ◦ g) ◦ f (81) a,b,c,d: Cf : HomC(a,b) g : HomC (b,c) h: HomC(c,d) as required by condition (5). Condition (6) follows similarly. So we can now write p(C) for the precategory given by the data (O, A, 1C, ◦C , assocC , idlC , idrC ) (82) 58 DIMITRIS TSEMENTZIS

Conversely, we need to define a function

q : PreCat → Mod(Tprecat) (83) So let C be a precategory given by the data (C, Hom, 1, ◦, assoc, idl, idr) (84)

Given 1 we know that for each x: C, Hom(x, x) is inhabited since 1x : Hom(x, x). Thus we can define

IC =def λx.(λf.(f =1x)): Π Hom(x, x) → PropU (85) x: C where we know that f = 1x is a mere proposition since Hom(x, x) is an h-set. Ex- actly analogously, since ◦ ensures that each type Hom(x, z) will be inhabited given f : Hom(x, y) and g : Hom(y, z) we define

◦C : Π Hom(x, y) → Hom(y, z) → Hom(x, z) → PropU (86) x,y,z : C The verification of the axioms for this data is then entirely straightforward and we omit the details. So we can now write q(C) for the Tprecat-model given by the data C C C C C C C (C, Hom, IC , ◦C, t1 , t2 , t3 , t4 , t5 , t6 , t7 ) (87) It is straightforward to check that p and q are quasi-inverses which gives us the required equivalence.  A strict category ([Uni13], Definition 9.6.1) is a precategory in which the type of objects is an h-set. We write StrCat for the type of strict categories. Let Lstrcat be the signature whose category part is the same as Lcat but with h(O)=2. Let Tstrcat be the Lstrcat-theory that contains the same axioms as Tcat. We now immediately obtain the following.

Corollary 6.2. StrCat ≃ Mod(Tstrcat) A univalent category ([Uni13], Definition 9.1.6) is a precategory satisfying the fol- lowing additional condition:

(7) cat: Π isequiv(idtoisoa,b) a,b: C

We write Unicat for the type of univalent categories. Now let Lucat be the following (associated) FOL=∼-signature ∼ 2 1 ◦ I =A U =O ρO

t0 i u1 O O t2 s2  u2  t1 % x % *- 1 o O 2 3 A O =O ρ t2 t1

d0 d1  { sO 3 O s 1 O O subject to all the same relations as Lcat as well as the additional relation t1 u1 = s1 u2. We can then define Tucat as the Lucat-theory given by the axioms of Tcat together with the following extra axioms: FIRST-ORDERLOGICWITHISOMORPHISM 59

1 (8) ∀x, y : O.∀f : A(x, y).Iso(f) → (∃!p: x =O y.U(f,p)) 1 (9) ∀x, y : O.∀f : A(x, y).∀p: x =O y.U(f,p) → Iso(f) 1 1 (10) ∀x: O.∀f : A(x, x).∀p: x =O x.(I(f, x) ∧ U(f,p) → rO(p, x)) 1 2 (11) ∀x, y : O.∀f : A(x, y).∀p, q : x =O y.(U(f,p) ∧ U(f, q) → p =O q) where we have used the abbreviations

Iso(f)=df ∃g : A(x, y)∃h1 : A(x, x)∃h2 : A(y,y). ◦ (f,g,h1) ∧◦(g,f,h2) ∧ I(h1) ∧ I(h2) and 1 1 1 2 ∃!p: x =O y.U(f,p)=df ∃p: x =O y.(U(f,p) ∧ (∀q : x =O y.(U(f, q) → p =O q))) Thus, axioms (8)-(10) express that U is a bijective relation between isomorphisms and paths that sends identity to reflexivity and axiom (11) expresses that U a functional relation. We can now show that univalent categories are also “FOL=∼-elementary”.

Proposition 6.3. UniCat ≃ Mod(Tucat)

Proof. From Proposition 6.1 we can assume that the data for a model of Tucat is given by the same data as that of for a precategory, together with the interpretation of U. M Given AUC, for any given Tucat-model M we can extract from U a section M M u : Π IdOM (x, y) → Iso (x, y) (88) x,y : OM where IsoM(x, y) ≡ Π isiso(f) (89) f : AM(x,y) such that π : Π isequiv(ux,y) (90) x,y : OM Thus we get

Mod(Tucat) ≃ Σ Π isequiv(ux,y) (91) C : Precat x,y : OC Id IsoC u: Π OC (x,y)→ (x,y) x,y : OC We can now take Unicat to be the type

Σ Π isequiv(idtoisox,y) (92) C : Precat x,y : OC

There is then a natural map f from UniCat to Mod(Tucat) which sends hD, univi to hD, idtoiso, univi. For a given

hD,u,πi: Mod(Tucat) (93) the homotopy fiber of f over hD,u,πi is given by

hfibf (hD,u,πi) ≡ Σ hC, idtoiso, univi = hD,u,πi (94) hC,univi: UniCat

To show that hfibf (hD,u,πi) is contractible it clearly suffices to show that for all x, y : O, ux,y = idtoisox,y and by function this reduces to giving an inhabitant of Π ux,y(p)= idtoisox,y(p) (95) x,y,p 60 DIMITRIS TSEMENTZIS

which by path induction reduces to providing an inhabitant of

Πux,x(reflx)= idtoisox,x(reflx) (96) x

But by the axioms of univalent categories and of Tucat we get that both sides of the are (propositionally) equal to the (unique) identity map on x. Thus f is an equivalence and we are done. 

Proposition 6.3 illustrates the kind of result that FOL=∼ was designed to tackle. Namely we want to use FOL=∼ as a tool for answering traditional model-theoretic questions (e.g. of elementariness) but about structures defined on homotopy types rather than sets. From this point of view, many future projects and questions suggest themselves. We list a few, in descending order of priority and ascending order of speculation:

(1) Defining the categorical semantics of FOL=∼ (possibly in terms of Reedy-fibrant diagrams as in [Shu15a]). In particular, to define an initial categorical seman- tics for LT TL for each L. (2) Proving a general completeness theorem for the homotopy semantics with respect to the deductive system D=∼. T (3) Defining a FOL=∼-signature LUF and an LUF -theory UF that can serve as an axiomatization of the universe of ∞-groupoids, i.e. a FOL=∼-axiomatization of ∞-groupoids. (4) Characterizing FOL=∼-elementary types in general, i.e. proving a Loś Theorem for FOL=∼ along the lines of [CK90], Theorem 4.1.12. (5) Characterizing “homotopy categorical” theories, i.e. finding necessary and T T sufficient conditions on a FOL=∼-theory such that Mod( ) is contractible. Finally, we ought to make a few remarks concerning the setting in which the in- vestigation of FOL=∼ can take place. Everything that we have done in this paper can be done either in (some) HoTT or in . By this we mean that, in addition to defining FOLDS(Ob, Mor), hSig, FOL=∼ etc., for each fixed FOL=∼-signature L we are able to define HStruc(L), LT TL and the interpretation of LT TL into MLTT either in type theory or in set theory. But as we mentioned in Remark 4.16 we should ideally like to regard HStruc(−) as an “interpretation functor” hSig → U which takes each L to the “correct” Σ-type in U. In particular, having such a functor would allow us to consider “infinitary” constructions on hSig which we could then reflect onto U. For example, as has been outlined in [WT17], by defining a function sst: N → hSig picking out for each n the signature for the n-truncated semi-simplicial types and then taking the (homotopy) limit over HStruc(sst(−)) in U would give us a defini- tion of the type of semi-simplicial types. Unfortunately it is unlikely that such an “interpretation functor” can be defined in the standard HoTT, due to the well-known coherence problems. One option would would be to move to a so-called “two-level type theory” (cf. [ACK17, ACK16, Voe13]) and, e.g., define inverse categories whose relations are sat- isfied strictly, building on what is done in [ACK17], Definition 10. Our preferred option, however, is to work in a HoTT with a postulated interpretation function, as FIRST-ORDERLOGICWITHISOMORPHISM 61 has been announced in [WT17], under the name of TT+I, but which perhaps should more appropriately be called HoTT+I. We believe this is the right setting in which to develop and apply FOL=∼, and we believe HoTT+I to be in many ways a more correct overall formalization of the Univalent Foundations since it is a univalent type theory (in the sense that there is only one, univalent, identity type) but which can still allow us to carry out constructions that are conjectured to be impossible to carry out in standard HoTT, e.g. defining semi-simplicial types. We believe a HoTT along the lines of HoTT+I is the right setting in which to study FOL=∼ natively within the Univalent Foundations. Such a study should be understood as a within the Univalent Foundations. Acknowledgements. I thank Benedikt Ahrens, Steve Awodey, Andrej Bauer, John Burgess, Thierry Coquand, Harry Crane, Nicola Gambino, Dan Grayson, Chris Ka- pulkin, Peter LeFanu Lumsdaine, Anders Mörtberg, Paige North, Mike Shulman, Vladimir Voevodsky and Matthew Weaver for helpful and stimulating conversations and emails. I would also like to single out in thanks an anonymous referee for very ex- tensive and helpful comments that significantly improved and substantially extended the scope of the paper.

References

[ACK15] Thorsten Altenkirch, Paolo Capriotti, and Nicolai Kraus, Infinite structures in type theory: Problems and approaches, TYPES, Tallinn, Estonia 20 (2015). [ACK16] , Extending homotopy type theory with strict equality, 25th EACSL Annual Confer- ence on Computer Science Logic 21 (2016), 1–17. [ACK17] Danil Annenkov, Paolo Capriotti, and Nicolai Kraus, Two-level type theory and applica- tions, arXiv preprint arXiv:1705.03307 (2017). [ANS14] B. Ahrens, P. North, and M. Shulman, Univalent FOLDS (2014). Abstract available at: http://www.ams.org/amsmtgs/2223_abstracts/1103-18-196.pdf. [CK90] C. C. Chang and H. Jerome Keisler, Model theory, Elsevier, 1990. [GA06] Nicola Gambino and Peter Aczel, The generalised type-theoretic interpretation of construc- tive set theory, The Journal of Symbolic Logic 71 (2006), no. 1, 67–103. [Hof97] Martin Hofmann, Syntax and semantics of dependent types, Extensional constructs in intensional type theory, 1997, pp. 13–54. [Joh02] P. Johnstone, Sketches of an elephant: A topos theory compendium, Oxford University Press, Oxford, 2002. [KLV14] K. Kapulkin, P. Lumsdaine, and V. Voevodsky, The simplicial model of univalent founda- tions, arXiv:1211.2851v2 (2014). [Mak95] M. Makkai, First order logic with dependent sorts with applications to category theory, 1995. http://www.math.mcgill.ca/makkai/folds/foldsinpdf/FOLDS.pdf. [ML84] Per Martin-Löf, Intuitionistic type theory, Bibliopolis, 1984. [ML98] , Categories for the working mathematician (graduate texts in mathe- matics), Springer, 1998. [Pal16] Erik Palmgren, Categories with families, folds and logic enriched type theory, arXiv preprint arXiv:1605.01586 (2016). [PL15] Fedor Part and Zhaohui Luo, Semi-simplicial types in logic-enriched homotopy type theory, arXiv preprint arXiv:1506.04998 (2015). [Shu14] M. Shulman, Homotopy type theory should eat itself (but so far, it’s too big to swallow).: Homotopy type theory blog post, 2014. 62 DIMITRIS TSEMENTZIS

[Shu15a] Michael Shulman, Reedy categories and their generalizations, arXiv preprint arXiv:1507.01065 (2015). [Shu15b] , Univalence for inverse diagrams and homotopy canonicity, Mathematical Struc- tures in Computer Science 25 (2015), no. 5, 1203–1277. [Soj15] Kristina Sojakova, Higher inductive types as homotopy-initial algebras, Acm sigplan no- tices, 2015, pp. 31–42. [Tse17] D. Tsementzis, A Higher Structure Identity Principle, arXiv preprint arXiv:1702.07776 (2017). [TW17] Dimitris Tsementzis and Matthew Weaver, Finite Inverse Categories as Dependently Typed Signatures, arXiv preprint arXiv:1707.07339 (2017). [Uni13] Univalent Foundations Program, Homotopy type theory: Univalent foundations of mathe- matics (2013). http://homotopytypetheory.org/book. [VAG+] Vladimir Voevodsky, Benedikt Ahrens, Daniel Grayson, et al., UniMath: Univalent Math- ematics. Available at https://github.com/UniMath. [Voe13] Vladimir Voevodsky, A simple type system with two identity types, Unpublished note (2013). [WT17] Matthew Weaver and Dimitris Tsementzis, Unfolding folds, Abstract, 2017. https://hott-uf.github.io/2017/abstracts/folds.pdf.

Rutgers University Current address: New Brunswick, NJ 08544, USA E-mail address: [email protected]