Universal Structure and a Categorical Framework for Type Theory

Makoto Takeyama

Doctor of Philosophy The University of Edinburgh

February 1995 (Graduation date: May 1995)

Abstract

This thesis investigates the possibility of a computer checked language for categories with extra structure; the language is to describe objects and morphisms of those categories and to reason about them. We do so first by developing an abstract analysis of representability. This is followed by the investigation of a categorical framework for studying type theory. Our computer checked language therefore allows us to reason about the semantics of programming languages and models of logics.

In order to provide our computer checked language, we need to classify categories with extra structure. Traditionally, that has been done in terms of equational structure, or more generally, essentially algebraic structure. That has proved to be somewhat awkward, both conceptually and computationally, so we give an alternative development of categories with extra structure in terms of universal structure, universality being the most important and most central concept of category theory. This unifies many of the concepts of the category theory, in particular many of those of greatest interest to computer scientists, such as cartesian closed structure, fibrations with extra structure, limits, colimits, and natural numbers objects. We use our definition of universal structure to develop a computer checked language in the proof system LEGO. We further give an abstract development of universal structure by showing how the concept of fibrations with extra structure may be seen in terms of universal structure.

We continue by an investigation of the use of category theory within computer science. One of the principle uses, perhaps the deepest use, is to provide a semantics for type theory. We give a unified treatment of those categories with extra structure that are needed for the semantics of type theory, thus allowing us to use our computer checked language to reason about the semantics of programs, via use of the underlying type theory of a programming language. It also allow us a semantic study of logics, via use of their corresponding type theories as given by the Curry-Howard isomorphism. This provides what we call a categorical framework for type theory. It extends the relationship between typed lambda calculus and cartesian closed categories, allowing us, for instance, to account for dependent types, as they appear in some programming languages and proof systems such as LEGO, with its underlying type system the Extended Calculus of Constructions. Finally we illustrate our categorical framework with its universal structures by study of the fibration of “deliverables”.

Acknowledgement

I would like to thank my supervisor, Rod Burstall, for his support and interest in both academic and non-academic aspects of my studies in Edinburgh.

I also thank the members of LEGO club; particularly James McKinna for his comment on the draft of thesis and his guidance as a senior member of the club, Randy Pollack for the LEGO system, and Martin Hofmann for numerous discussions on fibrations and type theory.

I am also grateful to Claudio Hermida and Bart Jacobs for their expertise on fibrations and encouragement.

My utmost acknowledgement is to John Power, who was my second supervisor in the last six months. Without his commitment as my supervisor, and his encouragement throughout the course of my study, this work would have never been composed as a thesis.

This work was supported by Edinburgh University Postgraduate Studentship and Overseas Research Studentship for the first three years of my study, and by Laboratory for the Foundations of Computer Science for the last six months.

Paul Taylor’s diagrams TeX macro package was used to produce diagrams in the text.

Declaration

I declare that this thesis was composed by myself, and the work contained in it is my own except where otherwise stated.

Makoto Takeyama

Table of Contents

Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i Acknowledgement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v

1. Introduction 1

2. Analysis of representability 10 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.2 The bicategory Mod of modules . . . . . . . . . . . . . . . . . . . . 13 2.3 Representability of modules . . . . . . . . . . . . . . . . . . . . . . 20 2.4 Examples of representable modules . . . . . . . . . . . . . . . . . . 23 2.5 Preservation of structure . . . . . . . . . . . . . . . . . . . . . . . . 28 2.6 Universal structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.7 Changing variance . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 2.8 Composite representations . . . . . . . . . . . . . . . . . . . . . . . 43

3. Formalisation of representability of modules in LEGO 46 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 3.2 Comparison with ”Computational Category Theory” . . . . . . . . 47 Table of Contents vi

3.3 LEGO syntax and commands . . . . . . . . . . . . . . . . . . . . . 49 3.4 General implementation issues . . . . . . . . . . . . . . . . . . . . . 51 3.5 The LEGO implementation . . . . . . . . . . . . . . . . . . . . . . 53

3.5.1 Basic definitions . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.5.2 Modules, representations, and generic commands . . . . . . 59 3.5.3 Binary products . . . . . . . . . . . . . . . . . . . . . . . . . 61 3.5.4 Terminal objects . . . . . . . . . . . . . . . . . . . . . . . . 62 3.5.5 Equalizers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.5.6 Pullbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 3.5.7 An example construction . . . . . . . . . . . . . . . . . . . . 70

4. Fibrations with extra structure 74 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 4.2 Fibrations and cartesian morphisms . . . . . . . . . . . . . . . . . . 75 4.3 Examples of fibrations . . . . . . . . . . . . . . . . . . . . . . . . . 82 4.4 Indexed categories . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 4.5 2-category Fib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 4.6 Local smallness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 4.7 Fibred limits and fibred ccc . . . . . . . . . . . . . . . . . . . . . . 97

4.7.1 Terminal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 4.7.2 Binary products . . . . . . . . . . . . . . . . . . . . . . . . . 99 4.7.3 Exponentials . . . . . . . . . . . . . . . . . . . . . . . . . . 102

4.8 B-coproducts and B-products . . . . . . . . . . . . . . . . . . . . . 102 Table of Contents vii 5. Type theory and fibrations 1 107

5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 5.2 Type dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

5.2.1 Generalised algebraic theories . . . . . . . . . . . . . . . . . 109 5.2.2 Standard interpretations of GA theories . . . . . . . . . . . . 114 5.2.3 Dependent product and coproduct types . . . . . . . . . . . 117 5.2.4 Interpretations between theories . . . . . . . . . . . . . . . . 120

5.3 Type system T F . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 5.3.1 T F theories . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 5.3.2 Interpretations between theories in T F . . . . . . . . . . . . 131

6. Type theory and fibrations 2 133 6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 6.2 Translation from GA to T F . . . . . . . . . . . . . . . . . . . . . . 135 6.3 Construction of F(T_{G}) . . . . . . . . . . . . . . . . . . . . . . . . . 136 6.4 Translations between T F λ and λP1 . . . . . . . . . . . . . . . . . . 138

6.4.1 From λP1 Theories to T F λ Theories . . . . . . . . . . . . . 138 6.4.2 From T F λ Theories to λP1 Theories . . . . . . . . . . . . . 139

6.5 T F ι theories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 6.6 Equivalence between T F ι and wML . . . . . . . . . . . . . . . . . 145

6.6.1 Translations between T F ι and wML . . . . . . . . . . . . . 145 6.6.2 Construction of F(T_{w}) . . . . . . . . . . . . . . . . . . . . . 147 6.6.3 Construction of G(T_{F}) . . . . . . . . . . . . . . . . . . . . . 147 6.6.4 The equivalence . . . . . . . . . . . . . . . . . . . . . . . . . 149

6.7 Equivalence between T F ισ and ML . . . . . . . . . . . . . . . . . 150 Table of Contents viii

6.7.1 T F ισ theories . . . . . . . . . . . . . . . . . . . . . . . . . . 150 6.7.2 Translation between T F ισ and ML . . . . . . . . . . . . . 151 6.7.3 The equivalence . . . . . . . . . . . . . . . . . . . . . . . . . 153

7. Analysis of deliverables 154 7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 7.2 Basic definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 7.3 Universal structures for deliverables . . . . . . . . . . . . . . . . . . 157

7.3.1 Fibred category Del_{1} . . . . . . . . . . . . . . . . . . . . . . 157 7.3.2 Cartesian closed structure on Del_{1} . . . . . . . . . . . . . . 159 7.3.3 Fibred category Del_{2} . . . . . . . . . . . . . . . . . . . . . . 160 7.3.4 Cartesian closed structure on Del_{2} . . . . . . . . . . . . . . 161 7.3.5 Local smallness . . . . . . . . . . . . . . . . . . . . . . . . . 163

7.4 Abstract deliverables . . . . . . . . . . . . . . . . . . . . . . . . . . 163 7.4.1 First-order deliverables . . . . . . . . . . . . . . . . . . . . . 164 7.4.2 Second-order deliverables . . . . . . . . . . . . . . . . . . . . 164

7.5 Kleisli construction of second-order deliverables . . . . . . . . . . . 168 7.6 The family construction of second-order deliverables . . . . . . . . . 172

7.6.1 Polynomial categories . . . . . . . . . . . . . . . . . . . . . . 172 7.6.2 Family construction . . . . . . . . . . . . . . . . . . . . . . . 175

8. Conclusions and further work 176

A. Proofs of Chapter 6 181 A.1.1 Proof of Proposition 6.4.2 . . . . . . . . . . . . . . . . . . . 181 A.1.2 Proof of Proposition 6.4.4 . . . . . . . . . . . . . . . . . . . 184 A.1.3 Proof of Proposition 6.4.6 . . . . . . . . . . . . . . . . . . . 186

A.1.4 Proof of Theorem 6.5.4 . . . . . . . . . . . . . . . . . . . . . 189

A.1.5 Proof of Proposition 6.5.6 . . . . . . . . . . . . . . . . . . . 192

A.1.6 Proof of Proposition 6.6.2 . . . . . . . . . . . . . . . . . . . 192

A.1.7 Proof of Proposition 6.6.5 . . . . . . . . . . . . . . . . . . . 194

A.1.8 Proof of Theorem 6.6.7 . . . . . . . . . . . . . . . . . . . . . 195

A.1.9 Proof for Theorem 6.7.7 . . . . . . . . . . . . . . . . . . . . 197

Bibliography 198

Chapter 1

Introduction

This thesis has two objectives. The first one is to provide category theorists with a computer checked language to describe morphisms of categories of their choice. The categories will in general have extra structure; we base our language on such structure. This supports the proofs of coherence theorems in particular, and any category theoretic proofs of a syntactic nature in general. The second goal, of more direct interest to computer science, is to provide what we might call a ”categorical framework” for type theory, together with a formalisation of that framework on a computer; with our computer checked language of the first goal providing the formalisation.

Earlier work related to the first goal of computer checked language is that of Rydeheard and Burstall’s book ”Computational Category theory” [71], which formalises several category theoretic constructions in ML. There, several individual universal constructions are described. Here, we give a uniform treatment, giving a general recipe for how to formalise universal constructions. This is of interest not only to category theorists but also to some computer scientists as they attempt to build programming languages based upon categorical constructions. Notable examples are Curien et. al.’s Categorical Abstract Machine [18], Hagino’s Categorical Programming Language [30], and Cockett and Spencer’s CHARITY [17, 75].

There are a number of ways to systematically formalise category theory on a computer. One common approach is to classify structure on a category as equational structure or more generally as essentially algebraic structure. There are many accounts of this in the category theoretic literature, but for an account directed toward computer scientists, see the paper “Why Tricategories?” [65,66] by Power. This paper also clarifies the importance of such systematic classification; we shall come back to this point in explaining our second goal. That particular classification, however, is sometimes a little awkward as we shall explain in more detail below. So, we prefer to classify structure on categories in terms of universal structure, universality being the single most important concept in category theory.

Universality embodies the thinking of how an object behaves with respect to the other objects of the category. In general, universal structure on categories is given by the existence of objects/morphisms specified by a universal property; e.g., categories with products, with limits, with exponentials, and with a subobject classifier. Our objective is to provide uniform ways to construct / manipulate / reason about objects/morphisms in those categories.

There are several ways to express universal structure. One way is to provide operations and equations that express the universality; i.e., universal structure may be treated as an instance of algebraic structure. These operations arbitrarily choose objects among all possible isomorphic copies. Although this algebraic approach is straightforward to incorporate in type theory as sets of available lemmas, it is not subtle enough in the following senses.

First, it does not reflect well the way we reason about universal structure. Elegant reasoning about universal structure is usually derived from direct consideration of the universal property involved, and not from equational reasoning by a chain of calculations. For instance, it is possible to specify a terminal object by operations and equations [21]. To do so, first one gives a nullary operation to provide the terminal object T. Then, one gives a unary operation which, to each object X of the category, provides an arrow from X to T. But then, to express the unicity of the arrow in terms of operations and equations, the usual approach [21] is to provide an operation that to each arrow f: X ^{}Y gives a commutative triangle, subject to operations forcing the commutative triangle to be given by f and the two arrows to T. Then, one must add an equation to make the arrow from T to itself given by the above unary operation be the identity. Obviously, only very rarely one does reason about terminal objects in this way; usually, one just uses the universal property.

Second, equational reasoning on arbitrarily complex entities (= objects and morphisms encoded in a type theory), rather than simple types and functions, is a specifically weak and awkward point in most computer proof assistant. These become particularly acute since in our context, we have to take explicit and precise care of coherent isomorphisms, which naturally arise from universal structure.

The following example clarifies both points. In a category with binary products, one speaks often of A × B × C. But formally, no such entity exists. One has (A × B) × C and A × (B × C): they are isomorphic, and satisfy the universal property one wants of A × B × C, but there is no operation explicitly defining the latter. When binary products are given by operations and equations, one may show the isomorphism between (A × B) × C and A × (B × C) by calculation

⟨⟨π_{0}, π_{0}π_{1}⟩, π_{1}π_{1}⟩⟨π_{0}π_{0}, ⟨π_{1}π_{0}, π_{1}⟩⟩
= ⟨⟨π_{0}, π_{0}π_{1}⟩⟨π_{0}π_{0}, ⟨π_{1}π_{0}, π_{1}⟩⟩, π_{1}π_{1}⟨π_{0}π_{0}, ⟨π_{1}π_{0}, π_{1}⟩⟩⟩

= ⟨⟨π_{0}⟨π_{0}π_{0}, ⟨π_{1}π_{0}, π_{1}⟩⟩, π_{0}π_{1}⟨π_{0}π_{0}, ⟨π_{1}π_{0}, π_{1}⟩⟩⟩, π_{1}⟨π_{1}π_{0}, π_{1}⟩⟩

= ⟨⟨π_{0}π_{0}, π_{0}⟨π_{1}π_{0}, π_{1}⟩⟩, π_{1}⟩
= ⟨⟨π_{0}π_{0}, π_{1}π_{0}⟩, π_{1}⟩
= ⟨⟨π_{0}π_{0}, π_{1}π_{0}⟩, π_{1}⟩
= ⟨⟨π_{0}, π_{1}⟩π_{0}, π_{1}⟩
= ⟨π_{0}, π_{1}⟩
= id_{,}

and similarly in the other way. But the natural reasoning is “they both classify triples of morphisms into A, B, and C, and hence are canonically isomorphic.” More precisely, one finds that (A×B)×C classifies a pair ((f, g), h) that consists of a pair (f, g) of morphisms and h, and that (A×(B ×C)) classifies a pair (f, (g, h)) of f and (g, h). The equivalence of the two is immediate. One may argue that, if products of sets should be treated formally, this requires the same calculation as above showing that the two sets {((f, g), h)|f: X ^{}A, g: X ^{}B, h: X ^{}C} and {(f, (g, h))| ⋯} are isomorphic. However, our point is that we feel much more natural about, and are more capable of, such calculation with sets than with objects of a given category. Note that the situation is exactly the same when one tries formalisation in a type theory with computer proof assistant. The assistant is designed for reasoning about types and functions, not objects and morphisms in a given category.

Therefore we seek an alternative approach. Among the other categorical ways of expressing universal structure, we regard representability of certain functors into Set as most suitable. Operations that give required universal objects/morphisms correspond to chosen representations of those functors. We aim to exploit this fact without breaking it down to sets of equations on operations. In this way, universal structure retains a direct connection with its universal property, accommodating our natural thinking. Yet the uniform nature of representable functors allows a uniform treatment across different kinds of universality. Note that this is a little more general than classifying the concept of universal structure in terms of adjoints.

For an instance of how this approach works, the above example of binary products may be treated as an instance of a category C for which the functor C(−, A) × C(−, B): C^{op} ^{}Set (A, B ∈ C) is representable. A machine then may be told that A × B is a representing object for this functor, and that fact can readily be used to interchange a morphism into A × B with a pair of morphisms into A and B. The particular encoding of objects and that of the construction A × B is irrelevant and hidden from the user. This further leads to the use of an internal language for cartesian categories.

This example is typical; many more examples are discussed in Chapter 2, culminating in an abstract definition of “universal structure”, which incorporates all examples we have in mind. In Chapter 3, we proceed to give a formalisation of universal structure in the proof system LEGO. We have chosen LEGO because we specifically seek a proof system to facilitate category theoretic proofs. So, LEGO is more appropriate than a general programming language such as ML. Of course, there are many possible proof systems we could have chosen; our specific choice of LEGO is based primarily upon convenience and familiarity. In Chapter 4, we develop our examples of universal structure to illustrate how sophisticated category theoretic concepts are expressible in those terms. In particular, we concentrate upon fibrations with extra structure as these are of particular interest to computer science. They are also more broadly used in categorical logic, algebraic topology, and elsewhere. That completes our study in this thesis of a computer checked language for category theory. We hope to further develop that work; see Chapter 8 for details.

We now turn to our second goal, that of providing a categorical framework for type theory together with a formalisation of that in a computer.

First, we put our use of the word “framework” into context and explain the relationship with the first goal. A canonical example of “framework” in studies of type theory and logics is the the Logical Framework [32,23]. Historically, we had diverse and ad hoc descriptions for various logics. To overcome this diversity, the Logical Framework provided a common basis for representing various logics in which it is claimed that one can perform unified study of them. Questions addressed by such unified study are the role of variable-binding, discharge of assumptions, context sensitive side conditions etc., which are all notions central to various logics but difficult to capture without a common basis [23]. The Logical Framework has immediate application in attempting to develop computer-assisted tools for reasoning about various logics [23].

Therefore, there is an analogy between the first goal and the Logical Framework. Our definition of universal structure provides a common basis with which various extra structures on categories are studied in a unified manner. Computerassisted treatment of those structure is our motivation. Also note that the three questions listed above are, semantically speaking, about introduction / elimination rules of logics, which in turn have a close connection with universality. In this sense, our approach to the first goal with universal structure aims to provide an abstract “categorical framework” for categories with extra structure. The term “categorical framework for type theory” signifies our goal of a unified study of type theory within such an abstract categorical framework, with a view to computerchecked formalisation.

A significant difference, however, between the Logical Framework and our framework is about what aspects of logic/type theory are studied in a unified manner. The Logical Framework is predominantly syntax-oriented. This is dictated by how it provides a common basis, i.e., encoding the syntax of various logics in a common type theory. In contrast, our framework is for semantics of various type theories, as we shall explain now (also see Section 5.1).

As we mentioned earlier, category theory has occasionally been used directly in computer science to build programming languages. Much more common, however, is for category theoretic structure to arise as the semantics for type theory.

Type theory has been widely used as a foundation for computer science. There are two distinct ways in which type theory is used. On the one hand, generic and strong systems are used as formalised and more manageable versions of set theory, acting as an ambient environment. The Calculus of constructions and its variants are such systems. Our “objects of study” e.g., programs, processes, or mathematical objects (in the case of formal proof development), are encoded or implemented in terms of type theory so that the implementation agrees with our informal understanding of objects. On the other hand, more specific systems tailored for each object of study are used to formally denote and manipulate them, reflecting our informal understanding of them. Various logics for concurrent processes are such examples.

The Logical Framework relates these two uses. Objects of study are specific object-level type systems. When one represents an object-level type system in an ambient type theory, the latter is used to implement the specification of the former.

One objection to these approaches is their heavily syntactic nature. When one studies an encoded object as a syntactic entity in type theory, its sheer complexity makes it difficult to concentrate on the essential properties of the original (informal) object without their being obscured by the incidental details that the syntax of type theory forces. In the Logical Framework approach, details of syntactic formulations of object logics may have inadvertent effects; e.g., one of two logics that are essentially the same can be represented while the other cannot (cf. Section 5.1.12 of Gardner’s thesis [23]).

This realization has led to the use of category theory and there have been many studies that exhibit categories with structure as the semantics for type theories. A canonical example is the correspondence between the simply typed lambda calculus seen as a type theory and cartesian closed categories [44]. More recently there have been much more sophisticated analyses, in particular, involving fibrations with extra structure. A readable reference is Bart Jacobs’ thesis [37]. Others are Dusko Pavlovic’s thesis [61], Seely’s work on hyperdoctrines [72], and Hermida’s work connecting logical relations with fibrations [34]. Of particular interest to us is Burstall and McKinna’s work on deliverables [11,52]. For a brief general account of the relationship between type theory and categories with structure one may again see ”Why Tricategories?” [65,66], which also explains the need for a categorical framework, although the term ”categorical framework” is not explicitly used there. Here, we add considerably more detail to that outline, and the work in our previous chapters provides a computer checked formalism for the framework.

In all that work, there has been little unified detailed analysis of the relationship between type theory and categories with structure in general. The above cited papers either address specific instances or give only a sketch of the relationship. Detailed analysis is needed in view of providing a basis for formalisation. So, in Chapters 5 and 6, we give a detailed account of a general class of type theories and their relationship with categories with universal structure. This allows us to use the results of our previous chapters to reason about programming languages and their semantics. These two chapters are a modified version of our previous work [84]. In Chapter 7, for concreteness, we illustrate the fibration of deliverables and the universal structures associated with it. Deliverables form an important proof technique for checking of correctness of programs. They are studied in detail in McKinna’s thesis [52] with accounts appearing in [11].

Finally, in Chapter 8, we outline our plans for further research.

In more detail, the thesis is organised as follows. Chapter 2 is directed towards Definition 2.6.3, that of universal structure; Section 2.2 defines the bicategory of modules. We capture the universality of structure by the representability of modules defined in Section 2.3. Section 2.4 lists common examples. The preservation of such structure by functors is examined in Section 2.5. This leads to Section 2.6, where we define universal structure. The remaining Sections 2.7 and 2.8 investigate change of variance and composition of universal operations.

Chapter 3 gives the current implementation in LEGO of our computer checked language. A comparison with the work of Rydeheard and Burstall is given in Section 3.2, followed by an introduction to the LEGO syntax and commands in Section 3.3. Section 3.4 address general implementation issues. The code itself is shown in Section 3.5, divided into the code common to all structures, for binary products, for terminal objects, for equalizers, for pullbacks, and finally for an example, the construction of equalizers from pullbacks and terminal objects.

Chapter 4 examines fibrations with extra structure as an example of sophisticated structure defined in terms of universality widely used in computer science. This also gives a purely categorical description of a particular structure used in the next two chapters. The chapter is put after the LEGO code since, although it is not difficult to apply our implementation to fibrations, we prefer to provide a basis for a systematic generalisation of our approach from ordinary categories to fibred categories. Section 4.1 explains this and the current limit of study. Sections 4.2 – 4.5 give the basic definitions and overall structure of the 2-category Fib of fibrations, including the correspondence with indexed categories. We describe the local smallness structure of fibrations in detail in Section 4.6. Using these, Sections 4.7 and 4.8 investigate fibred limits and products and coproducts indexed by base objects.

Chapter 5 starts the second part of our study. After clarifying the goal in Section 5.1, Section 5.2 gives a class of traditional type systems with dependent types; GA with no type-formation, λP1 with dependent products, wML with dependent products and weak dependent coproducts, ML with dependent products and strong dependent coproducts. Section 5.3 defines a new type system T F that corresponds to an equational presentation of locally small fibrations with the appropriate products and coproducts indexed by base objects. This is needed to give the precise relationship between the traditional type systems and locally small fibrations.

Chapter 6 studies that relationship in terms of syntactic translations between the traditional type systems and T F. Section 6.2 explains how local smallness captures the context comprehension of dependent type systems by defining translations from GA theories to T F theories. Section 6.3 shows that T F is a conservative extension of GA. Dependent products are dealt with in Section 6.4. Section 6.5 examines the difference between functions in λP1 and morphisms in T F, defining a variant T F ι of T F where these two notions coincide. Then Section 6.6 establishes the equivalence between wML and T F ι. This is extended in Section 6.7 to the equivalence between ML and T F ισ, another variant of T F.

Chapter 7 examines the fibrations p_{Del}_{1} and p_{Del}_{2} of first-order and secondorder deliverables and their structure. This is a concrete example of “objects of study” in an ambient type theory, and we exemplify how one can gain clarity by moving away from syntax and concentrating on a semantic property. The basic syntactic definitions are given in Section 7.2. The rich categorical structure of p_{Del}_{1} and p_{Del}_{2} are given in Section 7.3, showing they support the type systems studied in Chapter 6 as object-level type systems within the ambient type theory. This analysis leads to the definition of abstract first-order and second-order deliverables in Section 7.4. By moving from syntactically defined deliverables to abstract ones, we can clarify the relationship between first- and second-order deliverables as a Kleisli construction in Section 7.5. Finally, Section 7.6 applies this result to give a categorical analysis of the syntactic “family construction” given by McKinna [52].

Chapter 8 describes possible directions of further work. One particular issue is a generalisation of our analysis for ordinary categories in Chapter 2 to that for fibred categories. One needs this to put the second part of our work more in line with the first part, truly achieving a “categorical framework for type theory”. We indicate possible ways to solve this problem.

Analysis of representability

2.1 Introduction

This chapter is devoted to Definition 2.6.3 of universal structures. We capture the universality of structure by the notion of representability of a module by a functor.

A central feature of this analysis is the distinction between the existence of universal structure and an operation that assigns universal structure; for instance the difference between a category having binary products and an operation that specifies a particular choice of binary products. Our definition of universal structure allows us to say precisely what should be asked to exist in a uniform way without choosing operations. So we concentrate on that difference throughout the chapter, and we will see it vividly in writing our LEGO code in Chapter 3.

For readers unfamiliar with the concept of representability, we give an informal explanation of our use of modules and their representability. We work with a category C, diagrams of shape I in C, and their limits. Let Diagram be the set Ob [I, C] of diagrams of shape I in C and fix h ∈ Diagram.

Consider a functor Cones(−, h): C^{op} ^{}Set that sends

• an object C ∈ C to the set Cones(C, h) of cones over h with vertex C,

• a morphism f: C ^{}B to the function (−)∘f: Cones(B, h) ^{}Cones(C, h) given by composing f with each component of a cone.

The limit Lim h of the diagram h is a representing object of Cones(−, h), i.e., there is a natural bijection C(−, Lim h) ≅ Cones(−, h). Naturality is needed to determine Lim h up to unique isomorphism.

The notion module becomes involved when we vary h ∈ Diagram. Then, we have a family (Cones(−, h))_{h∈Diagram} of functors from C^{op} to Set and a family of representations (C(−, Lim h) ≅ Cones(−, h))_{h∈Diagram}. This gives a function Lim(−) from Diagram to Ob C. But we further want to express the uniformity with which Lim h varies as we vary h. So, we replace the set Diagram by the category [I, C] and extend the family (Cones(−, h))_{h∈Diagram} to a functor Cones: C^{op} × [I, C] ^{}Set. For each C ∈ C and s: h ^{}k, the function Cones(C, s): Cones(C, h) ^{}Cones(C, k) is given by componentwise composition. A module is such a functor that takes one contravariant argument and one covariant argument, and we say that Cones is a module from [I, C] to C. This determines Lim up to unique isomorphism as a functor from [I, C] to C with a natural isomorphism C(−, Lim ?) ≅ Cones(−,?); in other words, “the functor Lim represents the module Cones”. So, modules arise in our analysis as functorially parameterised families of functors into Set.

Our precise definition of universal structure requires delicate analysis, so we approach it gradually. First, we must define the notion of module from a category A to C. We do this in Section 2.2. Modules do not quite form a category; what they do form is a mild generalisation of a category, called a bicategory. The reason they do not form a category is because their composition is only associative up to coherent isomorphism, not up to equality. The definition of bicategory accounts for that. So, we give a definition of bicategory and show that modules form a bicategory.

The reason we introduce modules is because they capture the notion of structure that may asked to be universal. More precisely, it is expressed by the notion of representability of a module by a functor, which is defined in Section 2.3. A list of common examples that appear widely in category theory used in computer science appears in Section 2.4.

Then in Section 2.5, having investigated the presence in a category of universal structures we investigate the preservation of such structure by functors, continuing the analysis of our leading examples. The analysis is technical but important, since we must often pass between categories with structure and we need that structure preserved. Then, in Section 2.6, we define the notion universal structure.

In Section 2.7 and 2.8 we investigate that part of the theory of modules that we need for our applications of universal structure. Section 2.7 deals with the problem of contravariance; this is needed to accommodate exponentials. Section 2.8 explain how composition of operations that represent modules can be expressed in terms of the original modules. These are important to fully develop our computer checked treatment of universal structure, though they are yet to be incorporated to our LEGO implementation in Chapter 3.

Finally, note a difference, from our view point, between the status of structure in a given category C and that in Set. Since we partly formalise our analysis in the next chapter by replacing set theory by type theory, we need to clarify the relationship between these two structures. In doing so, we work in an external way, i.e., we think of C as an object formed within set theory. Our analysis externalises structure in C, giving a systematic way to reduce it to structure in Set. Structure in Set is assumed to be given in set theoretic terms; similarly, in the next chapter, we use primitive type constructors for operations on types. It is not our goal here to treat structure in a given C and that in Set in the same way. For this purpose, an internal way of working, i.e., regarding C or Set as a mathematical object satisfying certain (first-order) axioms, is more suited; this naturally leads to study of extra structure in terms of operations and equations, where the universal structure of some metatheory is all that is assumed, rather than that of Set. For related discussions, see Section V.5 “Internal Versus External” of Sheaves in Geometry and Logic [50] and Section I.6 “Foundations” of Categories for the Working Mathematician [49].

2.2 The bicategory Mod of modules

As in the Introduction, a universal structure on a category involves the representability of certain functors into Set. So, the following definition is central to us; for other basic category theory, however, we only refer to Mac Lane’s text [49].

Definition 2.2.1. Given a category C and a functor P: C^{op} ^{}Set, P is representable if there exists an object R in C together with a natural isomorphism ρ: C(−, R) ≅ P. Such a pair (R, ρ) is called a representation of P with representing object R. The element ρ_{R}(id_{R}) of set P R is called the counit of (R, ρ).

In our applications, these functors usually form a parameterised family and the parameters form a category. Consider, for example, binary products i.e. Example 2.4.1. The representing objects for this parametrised family are parametrised functorially if and only if the family is parametrised functorially, as we shall now explain.

Proposition 2.2.2. Given categories A and C, and let (P (−, A): C^{op} ^{}Set)_{A∈A} be a family of functors such that each component is representable, i.e., for each A, there exists R(A) ∈ C together with a natural isomorphism ϕ_{−,A}: C(−, R(A)) ≅ P (−, A). If the family (P (−, A))_{A∈A} can be extended to a functor P: C^{op} × A ^{}Set, then (R(A))_{A∈A} uniquely extends to a functor R: A ^{}C such that (ϕ_{−,A})_{A∈A} becomes a natural transformation C(−, R?) ^{}P (−,?): C^{op} × A ^{}Set. Conversely, if (R(A))_{A∈A} extends to a functor, then the family (P (−, A))_{A∈A} extends to a functor P: C^{op} × A ^{}Set. These processes are mutually inverse.

Proof In the forward direction, R(A ^{f}^{}B) is obtained as follows.

RA = = = = = = = = RA

≅ ; by the Yoneda lemma

1  \overline{}P (RA, A)

↓ P (RA, f) ∘ −

1  \overline{}P (RA, B)

≅ ; Yoneda

RA \overline{Rf ^{}}RB

In the reverse direction, given f: A ^{}A′ in A and g: C′ ^{}C in C, P (g, f): P (C, A) ^{}P (C′, A′) is given by

P (C, A) ≅^{ϕ_{C,A}^{−1}} C(C, RA) ^{C(g,Rf)}^{}C(C′, RA′) ≅^{ϕ_{C′,A′}} P (C′, A′).

We henceforth consider only functorial families of representations, and functoriality is built in to our terminology.

Definition 2.2.3. Given categories A and C, a module P from A to C, written P: A +^{}C, is a functor C^{op} × A ^{}Set. A morphism between two modules with the same domain and codomain is a natural transformation between them.

In the literature, modules are also called attributes, profunctors, distributors, and two-sided fibrations [4,5,45,80,77,79].

Note that a module P from, say A × B to C, that is, a functor P: C^{op} × (A × B) ^{}Set is different from a module P′: A +^{}(B^{op} × C), that is, a functor P′: (C × B^{op})^{op} × A ^{}Set, even if P and P′ are the same under the usual identification of C^{op} × (A × B) with (C × B^{op})^{op} × A. However, we often write modules in the form of functors into Set when confusion is unlikely. In particular, we often identify P: A +^{}C with C^{op} +^{}A^{op}; the latter may be written P^{op} if necessary. This is similar to omitting ( )^{op} from F^{op} in F^{op}: A^{op} ^{}C^{op} for F: A ^{}C.

As indicated by the notation A +^{}C, modules can be regarded as morphisms and one can define composition of them. However, this composition satisfies associativity and unit laws only up to coherent isomorphism. A bicategory is a structure that accounts for this kind of composition, generalising the notion of category. After giving the definition of bicategory, we show that modules form a bicategory.

Definition 2.2.4. A bicategory W is determined by the following data satisfying the axioms listed below.

(i) a set Ob W of objects of W. (ii) for each pair (A, B) of objects, a category W(A, B). An object f of W(A, B)

is called a 1-cell from A to B and written f: A ^{}B. A morphism s ∈ W(A, B)(f, g) is called a 2-cell and written s: f ⟹ g or A [figure: f; s⇓; g] B.

(iii) for each triple (A, B, C) of objects, a composition functor c_{A,B,C}: W(B, C) × W(A, B) ^{}W(A, C). For 1-cells f: B ^{}C and g: A ^{}B, the composite c_{A,B,C}(f, g) is written fg or f ∘g. For 2-cells A [figure: t⇓] B [figure: s⇓] C, c_{A,B,C}(s, t) is written st or s ∘ t.

(iv) for each object A, an object I_{A} ∈ W(A, A), called the identity 1-cell of A.

(v) for each quadruple (A, B, C, D) of objects and 1-cells f: C ^{}D, g: B ^{}C, and h: A ^{}B, an invertible 2-cell

(α_{A,B,C,D})_{f,g,h}: f(gh) ⟹ (fg)h,

natural in f, g, and h, called the associativity isomorphism. (vi) for each pair (A, B) of objects and 1-cell f: A ^{}B, invertible 2-cells

(l_{A,B})_{f}: I_{B}f ⟹ f and (r_{A,B})_{f}: fI_{A} ⟹ f, called the left identity and right identity, respectively.

We omit the indices A, B in l_{A,B} when they are specified by the domain and the codomain; e.g., for 1-cell f: A ^{}B, we write l_{f} for (l_{A,B})_{f}: I_{B}f ⟹ f. Similarly we omit the indices in α_{A,B,C,D}, r_{A,B}, etc.. The axioms for these data are

(i) for 1-cells x: D ^{}E, y: C ^{}D, z: B ^{}C, and w: A ^{}B,

((x ∘ y) ∘ z) ∘ w \overline{α_{x,y,z} ∘ id_{w}_{}}(x ∘ (y ∘ z)) ∘ w

[figure: (x ∘ y) ∘ (z ∘ w); α_{x∘y,z,w}; x ∘ ((y ∘ z) ∘ w); α_{x,y∘z,w}]
[figure: α_{x,y,z∘w}; id_{x} ∘ α_{y,z,w}]
x ∘ (y ∘ z)

commutes in W(A, D).

(ii) for 1-cells x: B ^{}C and y: A ^{}B,

(x ∘ I_{B}) ∘ y  \overline{α_{x,I,y}  ^{}}x ∘ (I_{B} ∘ y)
[figure: r_{x} ∘ id_{y}]
x ∘ y^{^{}id_{x} ∘ l_{y}}

commutes in W(A, C).

To put this definition in context, a one object bicategory is exactly a monoidal category: the 1-cells of the one object category correspond to the objects of the monoidal category; and the composition of 1-cells of the bicategory corresponds to the tensor product.

A leading example of a bicategory is given by Span: an object of which is a set X, a 1-cell from X to Y is a diagram of the form X ^{}Z ^{}Y, and composition is given by using pullbacks. The composition is not strictly associative because pullbacks are only determined up to isomorphism.

Composition of modules is defined in terms of a special kind of colimit called coend [49,40]

Definition 2.2.5. • For a functor G: A^{op} × A ^{}B and an object X ∈ B, a cowedge t: G ^{}X with vertex X is a family (t_{A})_{A∈A} of B-morphisms t_{A}: GAA ^{}X such that, for every f: C ^{}B in A,

[figure: GBC; GfC; GCC; GBB; GBf; t_{B}; X; t_{C}]

commutes.

• The functor Cowdg(G, −): B ^{}Set sends X in B to the set Cowdg(G, X) of cowedges from G to X, and f: X ^{}Y in B to the map that sends t ∈ Cowdg(G, X) to (ft_{A})_{A∈A} ∈ Cowdg(G, Y).

• A coend ∫^{A∈A} GAA of G in B is a representing object of Cowdg(G, −). The unit of the representation is written μ ∈ Cowdg(G, ∫_{A∈A} GAA)

More concretely, ∫^{A∈A} GAA is the vertex of a cowedge μ: G ^{}∫^{A∈A} GAA such that, for any cowedge t: G ^{}X, there is a unique morphism f: ∫^{A∈A} GAA ^{}X with t_{A} = fμ_{A} (A ∈ A).

Let μ: G ^{}∫^{A∈A} GAA and ν: H ^{}∫^{A∈A} HAA be universal cowedges for G, H: A^{op} × A ^{}B, respectively. For a natural transformation t: G ^{}H, the universality of μ determines the unique morphism

∫ ^{A∈A} t_{AA}: ∫ ^{A∈A} GAA ^{}∫ ^{A∈A} HAA

given by the cowedge (ν_{A}t_{AA})_{A∈A}: G ^{}∫^{A∈A} HAA.

Proposition 2.2.6. For a cocomplete category B, every coend ∫^{A∈A} GAA with small A exists.

Proof Given G: A^{op} × A ^{}B with small A, define σ: ∐_{A,B∈A} ∐_{f∈A(B,A)} GAB ∐_{A∈A} GAA by

[figure: ∐_{A,B∈A} ∐_{f∈A(B,A)} GAB; σ; ∐_{A∈A} GAA; GAB; i_{A,B,f}; GAf; GAA; i_{A}]

where i_{A,B,f} and i_{A} are injections. Similarly, define ρ: ∐_{A,B∈A} ∐_{f∈A(B,A)} GAB ^{} ∐_{A∈A} GAA by ρi_{A,B,f} = i_{B}GfB. Then, it is routine to check that the coend ∫^{A∈A} GAA is the coequalizer of σ and ρ:

∐_{A,B∈A} ∐_{f∈A(B,A)} GAB [figure: σ; ρ] ∐_{A∈A} GAA ^{μ}^{}∫ ^{A∈A} GAA.

Corollary 2.2.7. Set has all small coends.

The dual concept to coend is end; given G: A^{op}×A ^{}B, an end of G, written ∫_{A∈A} GAA, is the vertex of a universal wedge λ_{B}: ∫_{A∈A} GAA ^{}GBB with, for any f: A ^{}B, GAf ∘ λ_{A} = GfB ∘ λ_{B}. As a special case, given F, G: A ^{}B, the set of natural transformation [A, C](F, G) is an end ∫_{A∈A} B(F A, GA) with evaluation maps as the universal wedge; see Mac Lane’s text [49]. With this connection in mind, one can see that the following lemma is equivalent to the Yoneda lemma.

Lemma 2.2.8. (Yoneda lemma)

Given a functor G: A ^{}Set, there is an isomorphism

∫ ^{A∈A} A(A, B) × GA ≅ GB

natural in B ∈ A.

Proof The cowedge μ_{A}: A(A, B) × GA ^{}GB obtained by transposing G_{AB}: A(A, B) ^{}[GA, GB] exhibits GB as the coend ∫^{A∈A} A(A, B) × GA.

Having defined coends, now we can define composition of modules.

Definition 2.2.9. For modules P: B +^{}C and Q: A +^{}B, the composite module P ∘ Q: A +^{}C sends (C, A) in C^{op} × A to ∫^{B∈B} P (C, B) × Q(B, A) and (f, g): (C, A) ^{}(C′, A′) in C^{op} × A to ∫^{B∈B} P (f, B) × Q(B, g).

Observe here that this composition is only defined up to isomorphism. Henceforth, we assume that we have a particular choice, given set theoretically, of coend and universal cowedges for each P ∘ Q.

Proposition 2.2.10. The following data give the bicategory Mod of modules.

(i) an object A of Mod is a small category. (ii) for categories A and B, Mod(A, B) is the category of modules A +^{}B and

module morphisms. (iii) for categories A, B, and C, the composition functor

c_{A,B,C}: Mod(B, C) × Mod(A, B) ^{}Mod(A, C)

sends (P, Q) to P ∘ Q, and (s, t) to (∫^{B∈B} s_{CB} × t_{BA})_{C∈C,A∈A}. (iv) for a category A, the identity 1-cell I_{A}: C +^{}C is the Hom-functor C(−,?):

C^{op} × C ^{}Set.

(v) for modules P: C +^{}D, Q: B +^{}C, and R: A +^{}B, the associativity isomorphism α_{P,Q,R}: (P ∘ Q) ∘ R ^{}P ∘ (Q ∘ R) is given by the universal property of coends.

(vi) for a module P: A +^{}B, the identity isomorphisms l_{P} and r_{P} are given by Lemma 2.2.8; e.g., l_{P}: ∫^{B∈B} B(−, B) × P (B,?) ≅ P (−,?).

Checking the axioms of bicategories for Mod is a routine calculation using the Yoneda lemma; an example of such calculation is shown in the proof of the following proposition.

There are two canonical ways to embed Cat into Mod, regarding a module as a generalised functor (see [45]).

Proposition 2.2.11. Given F: A ^{}C, let F_{∗}: A +^{}C be the module defined by F_{∗}(C, A) = C(C, F A). Then, for F, G: A ^{}C, one has a natural isomorphism [A, C](F, G) ≅ Mod(A, C)(F_{∗}, G_{∗}). Similarly, for F^{∗}: C +^{}A with F^{∗}(A, C) = C(F A, C), one has [A, C](F, G) ≅ Mod(C, A)(F^{∗}, G^{∗}).

Proof

Mod(A, C)(F_{∗}, G_{∗}) ≡ [C^{op} × A, Set](C(−, F?), C(−, G?))
≅ [A, [C^{op}, Set]](C(−, F?), C(−, G?))
≅ ∫_{A}[C^{op}, Set](C(−, F A), C(−, GA))
≅ ∫_{A} C(F A, GA) ; by the Yoneda lemma
≅ [A, C](F, G)

Similarly for [A, C](F, G) ≅ Mod(C, A)(F^{∗}, G^{∗}).

2.3 Representability of modules

The reason we introduced modules is that they capture our notion of universal structure, that is, existence of a parameterised family of representing objects for functors into Set (cf. Proposition 2.2.2). The following definition makes precise what we mean by the assertion that each component of a module seen as a family of functors is representable.

Definition 2.3.1. Given a module P: A +^{}C, a right representation of P is a pair (R, ρ) consisting a functor R: A ^{}C and a natural isomorphism ρ: R_{∗} ≅ P. Dually, a left representation of P is a right representation of P^{op}: C^{op} +^{}A^{op}, i.e., a pair (L: C ^{}A, λ: L^{∗} ≅ P).

We often omit ρ, saying “a right representation R: A ^{}C”. Note that a right representation of a module P: A +^{}C is different from a representation of a functor P: C^{op} × A ^{}Set. In the literature, P is also said to converge to R [79].

Next, we define the notion of left Kan extension and left lifting and relate them to the above definition.

Definition 2.3.2. Given categories A, B, and C, a natural transformation ϕ

C

[figure: K; ⇑ ϕ; T]
A  \overline{G  ^{}}B

is said to exhibit T as a pointwise left Kan extension of G along K if ϕ induces a natural isomorphism ϕ̄ as follows.

{ϕ_{A}: GA ^{}T KA \atop C(KA, C) ^{}B(GA, T C)} ≅(Yoneda)

ϕ̄_{C,B}: B(T C, B) ≅ [A^{op}, Set](C(K−, C), B(G−, B)) ≅(Yoneda)

The natural isomorphism ϕ̄ shows that (T, ϕ) is uniquely determined by G and K up to isomorphism. We write Lan_{K}G for such a T.

Left Kan extensions play a central role in category theory. Their main application is as follows. If A and B are small categories and H: A ^{}B is a functor, then [H, Set]: [B, Set] ^{}[A, Set] has a left adjoint and it is given by left Kan extension along H. More generally, we have:

Proposition 2.3.3. Given functors G: A ^{}B, K: A ^{}C, and H: C ^{}B with A, C small and B cocomplete, pasting with the unit ϕ of Lan_{K}G induces a natural isomorphism

[C, B](Lan_{K}G, H) ≅ [A, B](G, HK), t ↦ tK · ϕ .

Proof One can check the following isomorphism sends t to tK · ϕ.

[C, B](Lan_{K}G, H) ≅ ∫_{C} B(Lan_{K}GC, HC)

≅ ∫_{C}[A^{op}, Set](C(K−, C), B(G−, HC)) ; by ϕ̄_{C,HC}
≅ ∫_{A} ∫_{C}[C(KA, C), B(GA, HC)]
≅ ∫_{A} B(GA, HKA) ; by Yoneda
≅ [A, C](G, HK)

One dual (reversing the direction of functors) to left Kan extensions are left liftings, defined below. Right representations can be reformulated in terms of left liftings, which in turn connect them to left Kan extensions (Corollary 2.3.7).

Definition 2.3.4. Given K: C ^{}B, G: A ^{}B, and T: A ^{}C, a natural transformation η

C
[figure: T; ⇑ η; K]
A  \overline{G  ^{}}B

is said to exhibit T as an absolute left lifting of G through K if η induces a natural isomorphism η̄ by Yoneda:

{η_{A}: GA ^{}T KA \atop η̄_{A,C}: C(T A, C) ≅ B(GA, KC).} ≅(Yoneda)

The functor T is determined by K and G up to isomorphism. We write Lit_{K}G for such T.

A special case of left liftings is an adjoint pair of functors A [figure: F; ⊥; G] B where the unit η of F ⊣ G exhibits F as Lit_{id_{A}}G.

The dual to Proposition 2.3.3 is:

Proposition 2.3.5. Given functors G: A ^{}B, K: C ^{}B, and H: A ^{}C, pasting with the unit η of Lit_{K}G induces a natural isomorphism

[A, C](Lit_{K}G, H) ≅ [A, B](G, KH), t ↦ Kt · η.

Functors with the universal properties of Propositions 2.3.3 and 2.3.5 are called (not necessarily pointwise) left Kan extension of G along K and (not necessarily absolute) left lifting of G through K, respectively. These properties are weaker than Definitions 2.3.2 and 2.3.4 [40]. However, since we do not use these weaker notions, we omit the word ‘pointwise’ and ‘absolute’ in the following.

Proposition 2.3.6. Given a diagram B^{op} × A

[figure: K × id_{A}; ⇑ ϕ; P]
A^{op} × A  \overline{A(−,?)  ^{}}Set,

ϕ exhibits P as Lan_{K×id}A(−,?) if and only if ϕ exhibits K × id as Lit_{P} A(−,?).

Proof Both statements amount to requiring that ϕ induces a natural isomorphism B(B, KA) ≅ P BA.

Corollary 2.3.7. Given a module P: A +^{}C, P has a right representation (R, ρ) if and only if the natural transformation η_{A,B}: A(A, B) ^{}P (RA, B) defined by

{C(A, RB) ^{ρ_{A,B}}^{}P AB \atop 1 ^{}P (RB, B)} ≅(Yoneda) A(A, B) ^{η_{A,B}}^{}P (RA, B) ≅(Yoneda)

exhibits P as a left Kan extension of A(−,?) along R × id_{A}:

C^{op} × A

[figure: R × id; ⇑ η; P]
A^{op} × A  \overline{A(−,?)  ^{}}Set.

Proof By the definition of Lit and Propostion 2.3.6.

2.4 Examples of representable modules

In this section, we introduce our leading examples of modules. The right or left representability of these modules defines categorical structures widely used in computer science.

Example 2.4.1. (Binary products)

Consider the right representation corresponding to a binary product functor on a category C. Define the module Pairs: C × C +^{}C by

Pairs : C^{op} × (C × C)  \overline{}Set
(X; A, B) ↦ C(X, A) × C(X, B),
(h; f, g) ↦ C(h, f) × C(h, g).

If Pairs admits a right representation

(−×?: C × C ^{}C, ˜×_{X,(A,B)}: C(X, A × B) ≅ C(X, A) × C(X, B)),

then A × B is a binary product of A and B. The morphism part of × agrees with the usual definition of the product functor based on the universal property of A × B. Conversely, if C has binary products, Pairs admits a right representation.

The two projections π_{0}: A × B ^{}A and π_{1}: A × B ^{}B are given by the counit of ˜×_{−,(A,B)}, i.e., the two components of ˜×_{A×B,(A,B)}(id_{A×B}).

Note that × in C is defined in terms of × in Set (as in C(X, A) × C(X, B)). Here, the latter × is naively given in set theoretic terms.

Example 2.4.2. (Equalizer)

Another example of a limit construction is an equalizer. To give the category of parameters for equalizers, let Para be the category indicated by {• [figure] •}. The functor category [Para, C] has as objects parallel pairs A [figure: f; g] B of morphisms of

C. A morphism of [Para, C] from A [figure: f; g] B to A′ [figure: f′; g′] B′ is a pair of morphisms of C (A ^{l}^{}A′,B ^{m}^{}B′) that makes the following diagrams commute.

[figure: A; f; B; A′; l; f′; B′; m; A; g; B; A′; l; g′; B′; m]

The module Ker: [Para, C] +^{}C^{op} given by

Ker  : C^{op} × [Para, C]  \overline{}Set
[figure: X; A; f; g; B; X′; k; A′; l; f′; g′; B′; m]↦ \begin{matrix}\{h: X  ^{}A|fh = gh\} \\ \{h′: X′ ^{}A′|f′h′ = g′h′\} & ^{^{}h ↦ lhk} \end{matrix}

admits a right representation (Eq(−, −): [Para, C] ^{}C,

Ẽq_{X;f,g}: C(X, Eq(f, g)) ≅ Ker(X; f, g)),

if and only if C has equalizers of all parallel pairs, and then they are given by Eq(f, g). The universal morphism Eq(f, g) ^{}A is given by the counit Ẽq_{Eq(f,g);f,g}(id_{Eq(f,g)}) , which is necessarily a mono since Ker(−; f, g) is a subfunctor of a representable.

The morphism part of Eq sends (l, m) to the unique k in the diagram

[figure: Eq(f, g); A; f; g; B; Eq(f′, g′); k; A′; l; f′; g′; B′.; m]

Note that

Ker(X; f, g)^{⊂} ^{}C(X, A) [figure: C(X,f); C(X,g)] C(X, B)

is the canonical equalizer diagram in Set; in other words, equalizers in C are defined by those in Set, similarly to the binary product case. This is a simple consequence of the fact that Yoneda functor C(?, −): C ^{}[C^{op}, Set] preserves all limits. This illustrates the more general situation that a concept in a category C internalises the corresponding, external concept in Set.

Example 2.4.3. (Subobject Classifier)

This is a non-limit example of a right representation. This differs from previous ones in that to talk about C having a classifier, one needs pullbacks of all monos along arbitrary maps in C. In this example, C is assumed to have all such pullbacks.

A subobject of A ∈ C is typically defined to be an isomorphism class (in C/A) of monomorphisms into A. This leads to an imprecise practice of treating subobjects as monomorphisms; operations on subobjects, for example, are defined on monomorphisms and checking well-definedness is often omitted.

So here, we modify the definition of subobjects by defining a subobject of A to be a representable sieve on A, i.e., a representable subfunctor of C(−, A). This is, conceptually, to regard subobjects as an internalisation of (representable) predicates on all morphisms into A. It is routine to verify that this is equivalent to the usual definition. For the forward direction, choose any representation φ: C(−, B) ≅ S of a representable subfunctor S of C(−, A). The counit φ_{B}(id_{B}) ∈ SB ⊂ C(B, A) is necessarily a monomorphism, thus defining an isomorphism class. Conversely, choose any monomorphism m: B ^{}A in an isomorphism class and define a subfunctor S by

SC = {f: C ^{}A|∃h: C ^{}B.f = mh}.

Then S is representable by C(−, B) ≅ S−, h ↦ mh. In both ways, the constructions do not depend on the choice and they are mutually inverse.

The pullback S[f] of a subobject S of A along a morphism f: B ^{}A is defined by the canonical pullback diagram of inclusions in [C^{op}, Set]:

S[f]  \overline{}S
⌋
[figure: C(−, B); ∩; C(−, f); C(−, A).; ∩]

More concretely, S[f](−) = {h: − ^{}B|fh ∈ S−}. For C to have pullbacks of monomorphisms along f is equivalent to saying that S[f] is representable whenever S is.

With this definition, the module Sub: 1 +^{}C given by the functor

Sub : C^{op}  \overline{}Set
A  {S|S ↪ C(−, A) and representable.}
↦
[figure: B; f; {T |T ↪ C(−, B) and representable.}; S ↦ S[f]]

admits a right representation

(Ω ∈ C, Ω̃: C(−, Ω) ≅ Sub(−)),

if and only if C has a subobject classifier Ω. The generic subobject of Ω as a representable subfunctor is given by the counit

Ω̃_{Ω}(id_{Ω}): T ^{⊂} ^{}C(−, Ω) ∈ Sub(Ω),

for some representable T. One can show that, for each X ∈ C, T X necessarily consists of one morphism X ^{⊤_{X}}^{}C for each X ∈ C. Therefore, a representing object 1 for T is always a terminal object of C and the counit 1 ^{⊤_{1}}^{}Ω of this representation C(−, 1) ≅ T − gives a generic monomorphism.

Example 2.4.4. (Tensor products)

Some operations are representations of modules whose definitions require not only two categories A and C, but some added data. For example, we consider tensor products. Suppose C is a concrete category, i.e., equipped with a faithful functor U: C ^{}Set. For A, B, and X in C, define Bilin(A, B; X) by the following pullback diagram in Set.

[figure: Bilin(A, B; X)] [UB, C(A, X)]
[UB, [UA, UX]] [figure: [UB, U_{AX}]]
[figure: [UA, C(B, X)]; [UA, U_{BX}]; [UA, [UB, UX]]; ≅; [UA × UB, UX]; ≅]

Because U is faithful, Bilin(A, B; X) consists of bilinear maps UA × UB ^{}UX, i.e., those maps which, in each argument, are underlying functions of morphisms in C. By the functoriality of the other three nodes, Bilin extends to a functor from (C × C)^{op} × C to Set, i.e., to a module Bilin: C +^{}C × C.

Let SL be the category of ∧-semilattices with U the underlying functor. Then, the explicit construction of the tensor A ⊗ B gives a left representation ⊗ of Bilin

⊗ = (−⊗?: SL × SL ^{}SL, ˜⊗_{AB−}: SL(A ⊗ B, −) ≅ Bilin(A, B; −))

with ˜⊗ provided by the characterisation theorem. The usual way to treat ⊗ more abstractly is to regard it as a monoidal structure, i.e., a bifunctor equipped with a few natural transformation subject to a few equations. One point of this work is to show that it is also a useful abstraction to regard it as a left representation with two arguments of a module that satisfies a condition.

2.5 Preservation of structure

Section 2.4 gave examples of universal structures on a category expressed as right/left representability of modules. However, a single module describes only an instance of a structure on a given category. The notion of structure corresponds to a uniform class of such instances. For example, the module Pairs(A): A×A +^{}A whose representability gives A binary products structure is exactly the same as Pairs(B): B × B +^{}B for B except, of course, that A is replaced by B.

In this section, we show that this uniformity is implicitly used in the notion of structure preserving functors, and should be given as part of the data that define structure. We first recall the usual definitions of structure preserving functors, which are expressed in terms of particular representations.

Example 2.5.1. (Binary products)

For a category A with chosen binary products, a functor G: A ^{}B preserves binary products if G sends the chosen, and hence every, product cone for A and B in A to a product cone for GA and GB in B [49].

A × B  G(A × B)
[figure: π_{0}; π_{1}; ↦^{G}; Gπ_{0}; Gπ_{1}]
A  B  GA  GB

Let Pairs(C)(−; ?_{0},?_{1}): C × C +^{}C be the module C(−,?_{0}) × C(−,?_{1}) for any category C. Suppose Pairs(A) has a right representation

×^{A} = (?_{0}×^{A}?_{1}: A × A ^{}A,
˜×^{A}_{X;A,B}: A(X, A ×^{A} B) ≅ Pairs(A)(X; A, B)).

The above definition of preservation amounts to requiring that the module

Pairs(B)(−; G?_{0}, G?_{1}): A × A +^{}B

is right representable, but with a specific right representation. To see what should be the right representation, let Pairs(G) be the morphism of modules G_{−?_{0}} × G_{−?_{1}} from Pairs(C) to Pairs(B)(G−; G?_{0}, G?_{1}), i.e.,

Pairs(G)_{X;A,B}: Pairs(A)(X; A, B) ≡ A(X, A) × A(X, B)

G_{XA}×G_{XB}^{}B(GX, GA) × B(GX, GA)

≡ Pairs(B)(GX; GA, GB).

One can show that G preserves products if and only if Pairs(B)(−; G?_{0}, G?_{1}) is right representable with the right representation

\begin{aligned}G×^{A} = ( & G(?_{0}×^{A}?_{1}): A × A ^{}B, \\ & G̃×^{A}_{X;A,B}: B(X, G(A ×^{A} B)) ≅ Pairs(B)(X; GA, GB)), \end{aligned}

where G̃×^{A} is defined by

A(X, A ×^{A} B) _{×^{A}} ; ≅ Pairs(A)(X; A, B) ^{Pairs(G)}^{}Pairs(B)(GX; GA, GB)
1 ^{}Pairs(B)(G(A ×^{A} B); GA, GB)

≅

B(X, G(A ×^{A} B)) _{G×^{A}}^{}Pairs(B)(X; GA, GB). ≅

Note that Pairs(B) itself need not be right representable, i.e., B does not necessarily have all binary products.

Example 2.5.2. (Limits)

More generally, for a category I and A with limits of shape I, a functor G: A ^{}B is said to preserve those limits whenever it sends a chosen, and hence every, limiting cone for F: I ^{}A in A to one for GF in B [49].

Let Cones(A)(−; ?): [I, A] +^{}A be the module [I, A](Δ−,?), where Δ is the diagonal functor. A category A is equipped with chosen limits Lim^{A}F of shape I when Cones(A) has a right representation

Lim^{A} = (Lim^{A}: [I, A] ^{}A, L̃im^{A}: A(−, Lim?) ≅ Cones(−; ?)).

The functor G sends any limiting object of every F: I ^{}A to that of GF in B if Cones(B)(−; GLim^{A}?): [I, A] +^{}B is right representable; but for G to send any limiting cone of F to that of GF, the representation must a specific one. Let Cones(G) be the morphism of modules given by

Cones(G)_{I;F}: Cones(A)(I; F) ≡ [I, A](ΔI, F)
[I,G]_{ΔIF}^{}[I, B](GΔI, GF)

= [I, B](ΔGI, GF) ≡ Cones(B)(GI; GF).

One can show that G preserves I-shaped limits if and only if Cones(B)(−; G?) has the right representation

GLim^{A} = (GLim^{A}?: [I, A] ^{}B,
G̃Lim^{A}: B(−, GLim^{A}?) ≅ Cones(B)(−; GLim^{A}?)),

where G̃Lim^{A} is defined by

A(−, Lim^{A}?) _{Lim^{A}} ; ≅ Cones(A)(−; ?) ^{Cones(G)}^{}Cones(G−; G?)

1 ^{}Cones(B)(GLim^{A}?; G?)

≅
B(−, GLim^{A}?) _{GLim^{A}}^{}Cones(B)(−; G?).

≅

For the preservation of LimF for a particular F: I ^{}A, one fixes ? in the above to be F and replace the domain [I, A] by 1; the rest of the calculation is the same.

Example 2.5.3. (Subobject classifier)

We adopt the usual definition of subobject as isomorphic classes of monomorphisms for the moment. The functor G: A ^{}B preserves a subobject classifier of A if it sends a generic subobject 1^{}^{⊤^{A}}^{}Ω of A to that of B. Further, G must preserve pullbacks of monomorphisms along arbitrary morphisms, since one expects G to preserve monomorphisms and send the characteristic morphism of a monomorphism m in A to the characteristic morphism of Gm in B. Usually this is implicit because often A and B are toposes and G is to preserve all finite limits.

With the definition of subobject as representable sieves, let Sub(C): C^{op} ^{}Set be the module 1 +^{}C defined in Section 2.4 for a category C with pullbacks of monomorphisms. For a functor G: A ^{}B with A having pullbacks of monomorphisms, and for a subfunctor S ^{⊂} ^{}A(−, A), define a subfunctor GS of B(−, GA) by that generated by the image of S by G:

GS− = {h: − ^{}GA|∃B ∈ A, k: B ^{}A ∈ SB, l: − ^{}GB. h = Gk ∘ l}.

A functor G preserves monomorphisms and pullbacks of them if and only if GS is representable whenever S is, and (GS)[Gf] = G(S[f]) (hence the former is representable) for any S ^{⊂} ^{}A(−, A) and f: A′ ^{}A. Any representation of S with a counit^{}^{m}^{}A induces one of GS with the counit Gm, i.e., this action on subobjects corresponds to that of G on (mono)morphisms.

Suppose Sub(A) has a representation Ω^{A} ∈ A, Ω̃^{A}: A(−, Ω) ≅ Sub(A)(−) and G: A ^{}B preserves pullbacks of monomorphisms. The above definition of subobject classifier preservation translates to the requirement that Sub(B)(−) : B^{op} ^{}Set has the representation

(GΩ ∈ B,
G̃Ω: B(−, GΩ) ≅ Sub^{B}(−))

where G̃Ω is defined by

A(−, Ω) _{Ω} ; ≅ Sub(A)(−) ^{Sub(G)}^{}Sub(B)(G−)

1 ^{}Sub^{B}(GΩ)

≅

B(−, GΩ) _{GΩ}^{}Sub^{B}(−) ≅

with

Sub(G) : Sub(A)(−) \overline{}Sub(B)(G−)
S  ↦  GS.

2.6 Universal structure

The above examples show a uniform relationship between right representations in domain categories and those in target categories induced by structure preserving functors. This leads to our definition of universal structure. First, observe the following.

Proposition 2.6.1. Given a functor G: A ^{}B, the morphism part of G exhibits G_{∗}: B^{op} × A ^{}Set as Lan_{G×id_{A}}A(−,?):

B^{op} × A

[figure: G × id_{A}; ⇑ G_{−?}; G_{∗}]
A^{op} × A \overline{A(−,?) ^{}}Set.

Proof The isomorphism \overline{G_{−?}} required in Definition 2.3.2 is equal to the inverse of the following isomorphism given by successive application of the Yoneda lemma.

\overline{G_{(B,A),X}}^{−1}: [(A^{op} × A)^{op}, Set]((B^{op} × A)((G × id)(−,?), (B, A)), [A(−,?), X]) ≅ ∫_{C∈A} ∫_{D∈A^{op}}[B(B, GC), [A(D, A), [A(C, D), X]]]

≅ ∫_{C∈A}[B(B, GC), [A(C, A), X]]
≅ ∫_{C∈A}[A(C, A), [B(B, GC), X]]
≅ [B(B, GA), X] = [G_{∗}(B, A), X]

Corollary 2.6.2. Given functors G: A ^{}B and R: C ^{}A, the natural transformation (G_{A,RC})_{A∈A,C∈C} exhibits (GR)_{∗} as a left Kan extension of A(−, R?) along G × id_{C}.

Then, let A be a category with binary products with a chosen representation (×^{A}, ˜×^{A}) for Pairs(A). Corollary 2.6.2 means that, for any G: A ^{}B, (G_{C;A×B})_{C,A,B∈A} exhibits the functor B(−, G(?_{0}×^{A}?_{1})): B^{op} × (A × A) ^{}Set as a left Kan extension of A(−,?_{0}×?_{1}) along G × id_{A×A}. So, by taking H in Proposition 2.3.3 to be Pairs(B)(−; G?_{0}, G?_{1}), we have a natural isomorphism

[B^{op} × (A × A), Set](B(−, G(?_{0}×^{A}?_{1})), Pairs(B)(−; G?_{0}, G?_{1})) ≅ [A^{op} × (A × A), Set](A(−,?_{0}×^{A}?_{1}), Pairs(B)(−; G?_{0}, G?_{1}) ∘ (G × id_{A×A})).

By routine calculation, one can check that the natural transformation

G̃×^{A}: B(−, G(?_{0}×^{A}?_{1})) ^{}Pairs(B)(−; G?_{0}, G?_{1}))

in Example 2.5.1 is the one determined by

Pairs(G)˜×^{A}: A(−,?_{0}×^{A}?_{1}) ^{}Pairs(B)(−; G?_{0}, G?_{1}) ∘ (G × id_{A×A})).

Diagrammatically, it can be shown as B^{op} × (A × A)

[figure: G × id] ⇑ G_{−,?_{0}×^{A}?_{1}} [figure: Pairs(B)(−; G?_{0}, G?_{1}); ⇑_{G×^{A}}; B(−, G(?_{0}×^{A}?_{1}))]

A^{op} × (A × A)  \overline{A(−,?_{0}×^{A}?_{1})  ^{}}Set

= [figure: B^{op} × (A × A); G × id; ⇑ Pairs(G); Pairs(B)(−; G?_{0}, G?_{1}); A^{op} × (A × A); Pairs(A)(−; ?_{0},?_{1}); ≅ _{×^{A}}; A(−,?_{0}×^{A}?_{1}); Set.]

So, requiring G̃×^{A} to be an isomorphism is equivalent to requiring that Pairs(G) exhibits Pairs(B)(−; G?_{0}, G?_{1}) as a left Kan extension of Pairs(A)(−; ?_{0},?_{1}) along G × id_{A×A}, thus eliminating the reference to the particular representation ×^{A}. The choice for representation can be avoided for the cases of limits and subobject classifiers in a similar way, using Cones(G) and Sub(G) instead of Pairs(G).

To make this precise, we define a universal structure as a family of modules whose components are related with each other in a uniform way.

Definition 2.6.3. A universal structure S consists of the following data.

• a subcategory Dom(S), the domain of S, of Cat.

Chapter 2. Analysis of representability 34

• a functor Param(S): Dom(S) ^{}Cat, the parameter functor of S.

• a module Module(S)(C)(−; ?): Param(S)(C) +^{}C for each C in Dom(S), the defining module of S for C.

• a morphism of modules

Module(S)(G): Module(S)(A)(−; ?) Module(S)(B)(G−; Param(S)(G)?): Param(S)(A) +^{}A

for each G: A ^{}B in Dom(S), the defining module morphism of S for G.

Example 2.6.4. ‘Binary products’ is a universal structure defined by the following data (omitting ‘binary products’ from Dom(‘binary product’) etc.):

• Dom = Cat

• Param: Cat ^{}Cat, C ↦ C × C,

• Module(C) = Pairs(C): C × C +^{}C, •

Module(G) = Pairs(G)

: Pairs(A)(−; (?_{0},?_{1})) ^{}Pairs(B)(G−; (G × G)(?_{0},?_{1})).

The reason to introduce Dom(S) is that, for some universal structures on C, extra structure on C is needed as it is the case for subobject classifiers.

Example 2.6.5. ‘Subobject classifier’ is a universal structure defined by

• Dom = {categories with pullbacks of monomorphisms and functors that preserve them}.

• Param: Dom ^{}Cat, C ↦ 1

• Module(C) = Sub(C): 1 +^{}C,

• Module(G) = Sub(G): Sub(A)(−; ∗)) ^{}Sub(B)(G−; ∗).

One can consider layered definitions of universal structures, a lower level definition providing extra structure for the domain categories of a higher structure.

Dually, a couniversal structure T is a universal structure where Param(T )(C) is replaced with (Param(T )(C^{op}))^{op}, Module(T )(C) with (Module(T )(C^{op}))^{op}. More concretely, it is given by

• a subcategory Dom(T ) of Cat.

• a functor Param: Dom(T ) ^{}Cat.

• a module Module(T )(C)(−; ?): C +^{}Param(C) for each C in Dom(T ).

• a morphism of modules

Module(T )(G): Module(T )(A)(−; ?) Module(T )(B)(Param(T )(G)−; G?)

for each G: A ^{}B.

This definition can be generalised in several ways. For example, to accommodate an initial algebra for T: C ^{}C, Module(‘initial algebra’)(C) should take an extra argument T. One may allow Dom(S) to be not just a subcategory of Cat but a category equipped with a functor Extra(S): Dom(S) ^{}Cat, specifying the category of those extra arguments; for example, Extra(‘initial algebra’)(C) = [C, C]. The codomain of Module(S)(C) may be generalised from just C to a result category Res(S)(C, T) which depends on C and an extra argument T. However, for the moment we keep our simple definition for brevity.

A later development may require uniformity with respect to natural transformations G ^{}G′: A ^{}B in Dom(S), but at this stage there seems no need for this.

Also, it is more natural to change Dom(S) from a subcategory of Cat to “categories with extra structure needed to define S”, once one obtains a deeper understanding of how Module(S) arises from an underlying structure.

With this definition of universal structure, those categories with a specified universal structure and structure-preserving functors between them can be defined in the following uniform way.

Definition 2.6.6. Given a universal structure S, a category C in Dom(S) has the structure S if Module(S)(C) is right representable.

Definition 2.6.7. Given a universal structure S, a functor G: A ^{}B in Dom(S) preserves S if Module(S)(G) exhibits Module(S)(B)(−; Param(S)(G)?) as a left Kan extension of Module(S)(A)(−; ?) along G × id_{Param(A)}.

B^{op} × Param(A)

[figure: G × id_{Param(A)}]

⇑ Module(G)

[figure]

Module(B)(−; Param(G)?)

A^{op} × Param(A) \overline{Module(A)(−; ?)  ^{}}Set

Dually, we define:

Definition 2.6.8. Given a couniversal structure T , a category C in Dom(S) has the structure T if Module(T )(C) is left representable.

Definition 2.6.9. Given a couniversal structure T , a functor G: A ^{}B in Dom(T ) preserves T if Module(S)(G) exhibits Module(T )(B)(Param(S)(G)−; ?) as a left Kan extension of Module(S)(A)(−; ?) along id_{Param(A)} × G.

Param(A) × B^{op}

[figure: id_{Param(A)} × G]

⇑ Module(G)

[figure]

Module(B)(Param(G)?; −)

Param(A) × A^{op} \overline{Module(A)(−; ?)  ^{}}Set

2.7 Changing variance

As explained in Chapter 1, we try to capture the notion of universal structure as independently as possible from the particular choice of representation. To do so, one needs to obtain, from a module P: A +^{}C with a right representation R, another P̄: C +^{}A which has R as its left representation; the reason for this is as follows.

The spirit of category theory is to concentrate on how objects behave rather than what they are. A universal construction embodies this spirit in that one specifies, up to isomorphism, one object by describing how it behaves with respect to all objects in terms of morphisms. This description, however, appears to be incomplete, giving information either on all morphisms into the specified object, or on those out of it.

For example, if A and B are objects of a category C with products, A × B is specified by the information that the morphisms into it naturally correspond to pairs of morphisms to A and B: C(−, A × B) _{×} ; ≅ C(−, A) × C(−, B). There is no reference to morphisms out of A × B.

What can be said about those morphisms out of A × B? If there is no simple formula for them that does not depend on what A × B is, one might imagine that one must commit to a particular choice of A × B among its isomorphic copies.

Fortunately, a simple application of the Yoneda lemma gives a description of morphisms out of A × B independent of the representation (×, ˜×).

C(A × B, −) ≅ [C^{op}, Set](C(?, A × B), C(?, −))
≅ [C^{op}, Set](C(?, A) × C(?, B), C(?, −))

This can be systematically generalised as follows. First recall that [C^{op}, Set] is the free cocompletion of C (see [40], Th 4.51).

Theorem 2.7.1. (Kan’s theorem)

For a cocomplete B, Cocts[[C^{op}, Set], B] = Ladj[[C^{op}, Set], B] ≃ [C, B].

The equivalence is given, in the forward direction, by composition with the Yoneda embedding Y: C ^{}[C^{op}, Set], and in the reverse direction, by Lan_{Y}−. Given a cocontinuous S: [C^{op}, Set] ^{}B, the left adjoint T to S is given by T B = B(SY−, B).

By taking B to be [C, Set]^{op}, one has the adjoint pair [C^{op}, Set] [figure: LanY Y′; ⊥] [C, Set]^{op} that corresponds to the Yoneda embedding Y′^{op}: C ^{}[C, Set]^{op}, C ↦ C(C, −):

[C^{op}, Set] [figure: Lan_{Y} Y′; ⊥] [C, Set]^{op}
[figure: Y; Y′]
C.

Proposition 2.7.2. Given P: C^{op} ^{}Set with a representation C(−, R) ≅ P, (Lan_{Y} Y′)(P): C ^{}Set is representable with the representing object being R.

Proof This follows from that Y is fully faithful and a general fact that the unit of Lan_{K}G is an isomorphism if K is fully faithful ([40], Proposition 4.23). Direct calculation is also easy:

(Lan_{Y} Y′)(P) ≅ [C^{op}, Set](P?, C(?, −))
≅ [C^{op}, Set](C(?, R), C(?, −))
≅ C(R, −),

with the right hand side of the first line being the functor that sends C ∈ C to [C^{op}, Set](P?, C(?, C)) ∈ Set.

Corollary 2.7.3. For two categories A and B, there is an adjoint pair

Mod(A, C) [figure: \overline{(−)}^{A,C}; ⊥] Mod(C, A)^{op}

such that, for P: A +^{}C with a right representation (R, ρ), \overline{P}^{A,C} admits a left representation (R, λ) for some λ.

Proof It follows by parameterising Proposition 2.7.2 with A:

[C^{op} × A, Set]

≅ [A, [C^{op}, Set]] [figure: [A,LanY Y′]; ⊥] [A, [C, Set]^{op}]
= [A^{op}, [C, Set]]^{op} ≅ [A^{op} × C, Set]^{op}

Note that this is not an instance of Proposition 2.7.2 with C^{op} replaced by C^{op} ×A.

More concretely, \overline{(−)}^{A,C} is given by

\overline{(−)}^{A,C} : [C^{op} × A, Set]  \overline{}[A^{op} × C, Set]^{op}
P CA  [C^{op}, Set](P?A, C(?, C))
↦
[figure: QCA; t_{C,A}; [C^{op}, Set](Q?A, C(?, C)); [C^{op}, Set](t_{?A}, id_{C(?,C)})]
(A ∈ A, C ∈ C)

From the self-duality of the diagram before Proposition 2.7.2, it is obvious that the right adjoint to \overline{(−)}^{A,C} is \overline{(−)^{op}}^{C^{op},A^{op}}, sending a left representable module from C to A to a right representable module from A to C.

So, now we have an explicit formula to reverse the variance of right/left representable module, which does not depend on the choice of representations.

It is also obvious that the adjoint restricts to an equivalence between the subcategory of right representable modules from A to C and that of left representables modules from C to A, both being equivalent to [A, C] by Proposition 2.2.11. This equivalence may mislead one to believe that \overline{P} determines P, so in particular that if \overline{P} is left (right) representable then P is right (left) representable. This is not true. The precise statement is as follows.

Proposition 2.7.4. For P: A +^{}C, the following are equivalent.

(i) P has a right representation. (ii) \overline{P} has a left representation (L: A ^{}C, λ: C(L?, −) ≅ \overline{P}) and the counit

λ_{A,LA}(id_{LA}): P?A ^{}C(?, LA) has a left inverse.

(iii) \overline{P} has a left representation and the following is a left Kan extension diagram

for each A ∈ A.

Set^{op}
[figure: (P −A)^{op}; ⇑ ϕ; [C^{op}, Set](P?A, [−, P?A])]
C  \overline{\overline{P} A−  ^{}}Set,

where ϕ is defined by

ϕ_{C}: \overline{P} AC ≡ [C^{op}, Set](P?A, C(?, C))
[C^{op},Set](id,(P −A)_{?C})^{}[C^{op}, Set](P?A, [P CA, P?A])

Proof By routine calculation. (Also see Theorem 4.80 of [40]; the left Kan extension diagram shows that P − A preserves the index colimit mentioned there.)

This extra condition on a representable \overline{P} is not strong, since this holds for the most common types of P that are constructed from Hom-sets by limit constructions and exponentials in Set. In such case, the representability of P can be checked by that of \overline{P}.

Example 2.7.5. (Initial object)

As the simplest application of Proposition 2.7.4, we show that the initial object of a category C coincides with the limit of id_{C} (cf. Lemma X.1.1. [49]). The limit Lim id_{C} is a representing objects for the functor

[C, Set](Δ − (?), id_{C}(?)): C^{op} ^{}Set

and the initial object 0 is a representing object for the functor

Δ1: C ^{}Set,

where Δ − (C) ≡ − for all C ∈ C. Then, since we have

[C, Set](Δ − (?), id_{C}(?)) ≅ [C, Set](Δ1(?), C(−,?))
≅ \overline{Δ1}^{1,C},

and since, for any C ∈ C, any t: Δ1(?) ^{}C(C,?) trivially has a left inverse, Proposition 2.7.4 shows that [C, Set](Δ − (?), id_{C}(?)) is representable if and only if Δ1 is, with the same representing objects.

Example 2.7.6. (Exponential)

Exponentials are an example where one has to change the variance of an module to define another. Suppose C has binary products, i.e., Pairs: C × C +^{}C is right representable. An exponentials B^{A} may be defined with a particular right representation × for Pairs.

C(−, B^{A}) ≅ C(− × A, B)

One can avoid this choice by replacing the right hand side by

C(−, B^{A}) ≅ \overline{Pairs}(−, A; B).

Thus, if the module Func: C^{op} × C +^{}C

Func : C^{op} × (C^{op} × C)  \overline{}Set
(X; A, B) ↦ \overline{Pairs}^{C×C,C}(X, A; B)

has a right representation

Exp = ((?)^{(−)}: C^{op} × C ^{}C, Ẽxp: C(X, B^{A}) ≅ Func(X; A, B)),

then C has exponentials. Note that Func(−; A, B) is an exponential of C(−, B) to C(−, A) in [C^{op}, Set].

This definition is more natural than the usual one in a sense, because although (−)^{A} is right adjoint to −×A for each A, it is clumsy to describe the whole functor (−)^{?} in the language of adjointness.

To finish this section, we present the universal structure ‘exponentials’ using Func. Recall that, given A with binary products and exponentials, and given a product preserving G: A ^{}B, G is said to preserve exponentials if

G(B^{A}) × GA ≅ G(B^{A} × A) ^{G(ε)}^{}GB,

where ε is the evaluation map in A, is the universal morphism exhibiting G(B^{A}) as GB^{GA} in B.

Translating this in terms of Func, the universal structure ‘exponentials’ is

• Dom = { categories with binary products and product preserving functors.} • Param: C ↦ C^{op} × C.

• Module(C) = Func(C)(−; ?_{0},?_{1}): C^{op} × C +^{}C.

• Module(G) = Func(G): Func(A)(−; ?_{0},?_{1}) ^{}Func(G−; G?_{0}, G?_{1}), where

Func(G) is defined by

Func(G)_{XAB}: Func(A)(X; A, B)
≡ \overline{Pairs(A)}^{A×A,A}(X, A; B)
≡ [A^{op}, Set](Pairs(A)(?; X, A), A(?, B))

[A^{op},Set](id,G_{?B})^{}[A^{op}, Set](Pairs(A)(?; X, A), B(G?, GB))

≅ [B^{op}, Set](Pairs(B)(?; GX, GA), B(?, GB))
≡ Func(GX; GA, GB).

The isomorphism is the one induced by the left Kan extension diagram that expresses G preserves products:

B^{op}

[figure: G; ⇑ Pairs(G)_{?XA}; Pairs(B)(?; GX, GA)]
A^{op}  \overline{Pairs(A)(?; X, A)  ^{}}Set

It is routine to check that G preserves exponentials in the usual sense if and only if G does so in the sense of Definition 2.6.7 with S =‘exponentials’.

2.8 Composite representations

Composing right and left representations of given modules, one can obtain a new functor. One may also obtain some non-functors, e.g., (X)^{(X)}, too, but these are not considered here. It is obvious that the choice of representations does not essentially affect the resultant functor. To reason about this functor independently of these choices, one needs to construct, from the original modules, a module that converges to the resultant functor. This can be treated more abstractly in terms of the inclusion of Cat into the bicategory of modules and module calculus [12]. However, we would like to keep track of explicit formulas for those composite modules.

At first sight, the question seems trivial. For example, −_{0}×(−_{1}×−_{2}) is trivially a right representation of the module that gives a set of triples of morphisms. One can simply unwind the definition of Pairs twice.

\begin{aligned}C(X, A × (B × C)) & ≅ C(X, A) × C(X, B × C) \\ & ≅ C(X, A) × (C(X, B) × C(X, C)). \end{aligned}

However, for A⊗(B ⊗C) in SL of Example 2.4.4, simply unwinding the definition of Bilin does not work.

SL(A ⊗ (B ⊗ C); X) ≅ Bilin(A, B ⊗ C; X)
≅ {h: UA × U(B ⊗ C) ^{}UX|......}
≅ ⋯?

Therefore, one needs a simple formula that does not unwind the definition of modules involved.

The desired formula is given by Lemma 2.2.8. Recall that, for G: C^{op} ^{}Set, ∫^{Y ∈C} C(D, Y) × GY ≅ GD. Setting G = C(A ⊗ −, X) and D = B ⊗ C, one can show that

C(A ⊗ (B ⊗ C), X) ≅ ∫^{Y} C(B ⊗ C, Y) × C(A ⊗ Y, X)
≅ ∫^{Y} Bilin(B, C; Y) × Bilin(A, Y; X)

Similarly,

C((A ⊗ B) ⊗ (C ⊗ D), X)
≅ ∫ ^{Y,Z} C(A ⊗ B, Y) × C(C ⊗ D, Z) × C(Y ⊗ Z, X)
≅ ∫ ^{Y,Z} Bilin(A, B; Y) × Bilin(C, D; Z) × Bilin(Y, Z; X).

One may need to change the variance of modules if right and left representations are combined. Suppose C has both tensor products and cartesian binary products.

C(A ⊗ (B × C), X) ≅ ∫^{Y} C(B × C, Y) × C(A ⊗ Y, X)
≅ ∫^{Y} \overline{Pairs}(B, C; Y) × Bilin(A, Y; X)

It is routine to generalise this to all combinations of right/left representation; namely, one can give a corresponding composite module to each functor (or more precisely, functor expression) which is constructed from right/left representations with the usual cartesian structure on Cat. Briefly, it goes as follows. Write right(P) (left(P)) for a right (left) representation of a right (left) representable module P.

Then, one can find a construction of the desired composite module in parallel to that of the composite left/right representation.

A +^{P}^{}B +^{Q}^{}C

right(Q)right(P) ≅ right(Q ∘ P), left(P)left(Q) ≅ left(Q ∘ P).

A +^{P}^{}B ^{}+^{Q} C

left(Q)right(P) ≅ left(\overline{P}^{A,B} ∘ Q)

A ^{}+^{P} B +^{Q}^{}C

right(Q)left(P) ≅ right(Q ∘ \overline{P}^{B,A})

A ^{}+^{P} C +^{Q}^{}B

⟨right(P), right(Q)⟩ ≅ right(S), where S(A, B; C) = P AC × QBC

A +^{P}^{}C +^{Q}^{}B

⟨left(P), right(Q)⟩ ≅ right(S), where S(A, B; C) = \overline{P}^{A,C}AC × QBC

A +^{P}^{}C ^{}+^{Q} B

⟨left(P), left(Q)⟩ ≅ right(S), where S(A, B; C) = \overline{P}^{A,C}AC × \overline{Q}^{B,C}BC

Formalisation of representability of modules in LEGO

3.1 Introduction

This chapter presents our current implementation of a computer checked language for categories with universal structure. The language is to describe and reason about morphisms / objects of those categories. It is implemented in the LEGO proof development system [48,64,62] as a set of LEGO definitions and LEGO theorems. These can be classified into three kinds. The first provides the definitions of types for, e.g., categories, modules, and representations. The second defines commands that construct and manipulate those entities; for example, given a module P: 1 +^{}C with a representation R, a command rIntro constructs X ^{}R from an element x ∈ P X. The type checking by LEGO system guarantees that these operations are combined validly. This is in that loose sense that we have a language for categories; but if LEGO had a parser-generator for object level languages, e.g., one with the Isabelle system ([60]), these commands provide a basis for a language with a more definitive look. The third proves properties of these manipulations, e.g., that the above operation is bijective.

From the viewpoint of the refinement style proof development, the language works in the following manner. Assume we have formalised a category C with limits of shape I, and we want to derive some morphism from an object A to the limit of a diagram h. The commands of the language allow us to derive such a morphism from a cone over h with the vertex A. The cone is a collection of hopefully simpler morphisms, so we have reduced our problem to a collection of simpler sub-problems. It is in this sense that the analysis of Chapter 2 may give rise to a type theory technique for deriving morphisms by refining a problem into simpler sub problems.

In this chapter, we review our current LEGO code that gives these definitions and theorems. As examples, it defines structure of binary product, terminal object, equalizers, and pullbacks. Preservation of structure is not yet implemented. Finally, as an example of using those structure, we give a construction of equalizers from terminal objects and pullbacks.

But first, we compare our work with that of Rydeheard and Burstall [71] in Section 3.2, give a summary of the LEGO system in Section 3.3, and consider general implementation issues in Section 3.4.

3.2 Comparison with ”Computational Category

Theory”

The most extensive mechanised treatment of universality is found in the book ”Computational Category Theory” by Rydeheard and Burstall [71]. Using the ML functional programming language, they defined ML types of categories etc. and constructed functions that compute, for example, coproducts, coequalizers, and more generally finite colimits, adjunctions, etc. in the category of finite sets. Our computer checked language advances this in two respects

First, we uniformly construct our structures based on the abstract framework of universal structure. We provide a set of generic commands that work for all structure. Each structure S on C is obtained by constructing the parameter category Param(S)(C), the defining module Module(S)(C), and finally some abbreviations for the particular instances of generic commands, if necessarily. In contrast, Rydeheard and Burstall [71] represented each structure by functions specific to the structure. As the form of functions varies from structure to structure, the treatment was not uniform. For example, a binary product was represented by a product-cone and a ‘universality function’ (f, g) ↦ ⟨f, g⟩, and a equalizer of (f, g) by a universal arrow e and a universality function that sends h with fh = gh to h̄ with eh̄ = h. There is little in common in the two cases.

Second, Rydeheard and Burstall [71] concentrated on construction of morphisms / objects in a category; the validity of the construction is checked informally. This was because ML’s type system was too weak to express axioms involved, e.g., associativity of composition. (see Section 3.7 of [71]). Also, even for simple operations, e.g., (f, g) ↦ fg, it was a user’s responsibility to ensure that the codomain of g is the same as the domain of f. In our implementation, the embedded logic of LEGO is used to express those axioms so that type checking of LEGO system guarantees the validity of construction. Also, dependent types allow us to specify operations with finer domains than ML types; e.g., our composition of two arrows is a function from Hom(b, c)×Hom(a, b) to Hom(a, c), thus an attempt to compose an invalid pair of morphisms results in a type-checking error.

3.3 LEGO syntax and commands

Here, we give only a summary of syntax and commands necessary to follow the LEGO code given in Section 3.5. The full explanation can be obtained from the manuals [48,64,62]. We use LEGO in a mode that implements the Extended Calculus of Constructions [47].

Syntax LEGO’s ASCII representation of ECC syntax is as follows. Here, v and T run over variables and terms, respectively.

{v:T}T,{v|T}T  Πv: T.T

      [v:T]T,[v|T]T  λx: T.T
      TT,T|T  T T
      <v:T>T  Σv: T.T

T.1  π_{1}(T)
T.2  π_{2}(T)

The syntax {v|T}T is used for types of functions that trigger LEGO’s argument synthesis feature. For example, given f:{x|A}{y:B x}C, a:A, and M:B a, one may form, as possibly not well-typed term, f M. The mark {x|A} triggers an attempt for the type checker to compute whatever application of type A. In this example, it first calculates the type of M and finds that it unifies with B x with x=a and accept f M as a well-typed term. The application of a is implicit. When one needs to supply a specific argument b for such an implicit application, the syntax f|b is used. A λ-term whose argument should be synthesised is written with the syntax

[v|T]T, so f may be defined by [x|A][y:B x]c with c:C.

The type P rop and and a type universe T ype(n) are represented by Prop and

Type(n).

Commands LEGO has two interactive modes; the LEGO state manages the context in which a user works, and the proof state assists user to develop a proof. Somewhat simplified explanation for important commands is as follows.

• [v:T]; – extends the current context by assuming a variable v of type T. (T must be of type Prop or Type(n).)

• [v = T]; or v == T; – defines the name v to be a term T. One can optionally specify the type of T' of T by [v = T:T']; or v:T' == T;.

• Discharge v; – discharges the variables introduced after v from the definitions made after the introduction of v.

• Goal T; – provided T is of type Prop or Type(n), puts LEGO into proof state with the initial goal ?:T.

• Intros v; – provided the current goal is of the form {u:T 0}T 1, introduces the variable v of type T 0 and generates a new goal ?:T 1[u:=v]. One may provide several variables to substitute several successive Intros.

• Intros #; – provided the current goal is of the form <u:T 0>T 1, generates two new goals ?:T 0 and ?':T 1[u:=?]

• Refine f; – tries to unify the current goal with the type of f. When f is a function, it also tries fx, fxy, etc., with free variables x, y …; if this succeeds, the command generates new goals that correspond to uninstantiated free variables. Otherwise, it fails.

• Qrepl t; – provided t is of type Eq M N, replaces all occurrence of M in the current goal with N.

• Equiv T; – provided T is convertible with the current goal, replaces the current goal with T.

• Save v; – after successfully finishing a proof, puts LEGO into the LEGO state and adds the definition [v=M] to the current context, where M is the proof term.

We also use the extension of ECC to inductive types. Particularly, we use inductive product types and Σ types defined in the standard LEGO library [39]. The library allows a user to specify the level of type universe in which inductive types are defined. However, because of the two sizes of categories, we have to manage two levels of universes at once; namely SET==Type(1) for possibly large sets and Set==Type(0) for small sets. Accordingly, we have two versions of definitions for each inductive types, which we distinguish by a prefix s for the latter. For example, prod:SET->SET->SET defines the products of two large sets and sprod:Set->Set->Set defines those of small sets. Other than this prefixing s, most names taken from the library are self-explanatory.

Definition by proving The proof assistant of the LEGO system is used not only for checking correctness of a LEGO theorem. When P is of type Type(n) or Prop, rather than directly typing in a definition [x=M:P], one may prove P with a specific proof that corresponds to M and then define x by Save x command. When M is a complex term (e.g., several screenfuls), developing a corresponding proof with the above command is more convenient than typing it in directly. This use of proofs is not found in proof development systems where proofs are metatheoretic objects, e.g., the Isabelle system [60]. In Section 3.5 we will note if a proof is used to define a specific term or to check correctness of a LEGO theorem.

3.4 General implementation issues

The size of categories Formalisation makes the problem of size more acute syntactically than it is in a usual mathematical argument. Usually, small sets and possibly large sets have operations on them with the same notation, and we need not have separate definitions for, e.g., functor categories [A, B] depending on the size of A and that of B. In our formalisation, we are forced to have ramified definitions for various operations depending on the size of categories involved. In implementing ECC’s cumulative universe hierarchy [47], the LEGO system provides some facility to address this issue of size, namely, type checking with typical ambiguity and universe polymorphism [31,63]. For example, a small category C:Cat can be type checked as a possibly large locally small category C:CAT. However, universe polymorphism is not flexible enough to avoid the above mentioned duplication. For example, there is no provision to make a single definition of Fun, the functor category forming operation, to work both as Cat->Cat->Cat and as Cat->CAT->CAT, depending on the size of the second argument.

Equality on Hom-sets In our implementation, a Hom-set of a category is formalised by a type in the universe Set. Given two parallel arrows, we compare them by the Leibniz equality. This simplifies the development, but leaves out the possibility of using a given equivalence relation as equality for morphisms. In the current implementation, we introduce ad hoc coercions from proofs of equivalence to those of the Leibniz equality when it is necessary. In future, we hope to adopt quotient types studied in Hofmann’s thesis [35]. There, he gives a syntactic model of quotient types in an intensional type theory; this can be seen as providing a set of macros to treat a user defined equality. A more direct approach is to formalise a Hom-set by more complex structure than a type, e.g, a type paired with a equivalence relation. In the library [68] for the Coq system [20], some basic category theory is formalised in this way. We avoid the extra complexity since our development is largely independent of this detail. More precisely, it is pointed out that there is a difficulty in formalising the category Cat of small categories in this approach, but our current implementation needs only the types of categories and functors, i.e., Cat is used metatheoretically; so, there should be little difficulty in adopting this approach.

Extensionality and proof irrelevance Extensionality for functions is needed, for example, to define the category Setc of small sets and the Hom-functors. As usual, we assumed the axiom ext of type {K|Type}{L:K->Type}{f,g:{x:K}L x}({x:K}Eq (f x) (g x))->Eq f g. Proof irrelevance is needed to formalise subsets; e.g., natural transformations are those functions that satisfy a naturality condition. We circumvent the lack of proof irrelevance in the LEGO system by providing ad hoc coercions of equality of the superset to that of the subsets. Our assumption of extensionality and proof irrelevance may seem ad hoc and in conflict with the intensional type system of LEGO, which is decided for with computational consideration. Once again, we hope that Hofmann’s work [35] can be applied to give more systematic solutions for these problems.

Inductive vs. Native Σ type LEGO and its standard library provide two version of Σ type; one natively implements Σ type of ECC and the other is inductively defined. Native Σ types have more concise syntax but lack η rule. Inductive ones have clumsier syntax but are equipped with elimination constants that prove (propositional) η rule. We use an inductive Σ type when we use equality on that type, and a native one otherwise. Although it is not a problem to assume propositional η rule for native Σ types as an axiom, elimination constants for inductive ones are found to be more flexible and easier to use than such an axiom. (Note: the current version of LEGO has the Record syntax sugar that avoids the clumsiness of inductive Σ types defined in the standard library.)

3.5 The LEGO implementation

Our LEGO code is divided into a few LEGO modules (= units of compilation, not to be confused with categorical modules).

categories.l the basic category theory definitions

modules.l the definition of modules, right and left representations, and generic commands for all structures

termmod.l  terminal objects
prodmod.l  binary products
eqmod.l  equalizers
pbmod.l  pullbacks

eqex.l an example construction of equalizers from pullbacks

and terminal objects

In this section, we review each module explaining the fine points of implementation.

3.5.1 Basic definitions

Categories First, we define the type of small categories. A category is represented by a dependent tuple of 1. an object set, 2. a Hom-set function, 3. a composition function, 4. a proof of left identity 5. that of right identity, and 6. that of associativity. The Σ type used here is the native one, since we do not ask if two categories are equal.

(* Type of small categories *)
Cat ==
(* Signature *)
<Ob:Set>
<H:Ob->Ob->Set>
<id:{x:Ob}(H x x)>
<o:{x,y,z|Ob}(H y z)->(H x y)->(H x z)>
(* Axioms *)
<ul:{x,y|Ob}{f:(H x y)}(Eq f (o (id y) f))>
<ur:{x,y|Ob}{f:(H x y)}(Eq f (o f (id x)))>
{x,y,z,w|Ob}{f:(H z w)}{g:(H y z)}{h:(H x y)}
        (Eq (o f (o g h)) (o (o f g) h));

For each component of any Σ type, we define a selector. The name of the selector should usually be the same as the variable name used in the definition. It is vital for the selector to be appropriately type cast using those selectors on which it depends; otherwise, the whole development would be swamped by meaningless expressions like X.2.2.· · ·.2.1. Careful use of argument synthesis is also important to mimic the usual notation.

Ob      == [X:Cat] X.1:Cat->Set;
[X|Cat];
H       == X.2.1:(Ob X)->(Ob X)->Set;
id      == X.2.2.1:{x:Ob X}(H x x);
o       == X.2.2.2.1:{x,y,z|Ob X}(H y z)->(H x y)->(H x z);
ul      == X.2.2.2.2.1:{x,y|Ob X}{f:(H x y)}(Eq f (o (id y) f));
ur      == X.2.2.2.2.2.1:{x,y|Ob X}{f:(H x y)}(Eq f (o f (id x)));
o_a     == X.2.2.2.2.2.2
        :{x,y,z,w|Ob X}{f:(H z w)}{g:(H y z)}{h:(H x y)}
        (Eq (o f (o g h)) (o (o f g) h));
o_b     == [x,y,z,w|Ob X]
           [f:H z w][g:H y z][h:H x y]Eq_sym (o_a f g h);
        (* assoc. for the reverse direction *)
Discharge X ;

Henceforth, we omit the listing of such selectors. (Note: Record syntax of the current version of LEGO would make needs for such definitions obsolete.)

As explained in the previous section, we also need a separate definition of the type CAT for locally small but possibly large categories. We omit the definition, since the only difference from that of Cat is that the type of object set is SET rather than Set. The names of the selectors for CAT are the same as those for Cat except for a prefix B, e.g., BH:{X|CAT}(BOb X)->(BOb X)->Set. ECC’s universe

hierarchy means that any small category C:Cat is also a large category C:CAT.

Next we define the large category Setc whose objects are sets, i.e., types T:Set

and whose morphisms are functions between them. The definition is given by a

specific proof of CAT, rather than typing it in directly.

(* Category Setc of Set *)
Goal CAT;
Intros #; Refine Set;                   (* Ob Setc *)
Intros # x y; Refine x->y;              (* Hom set *)
Intros # x; Refine [T:Type][t:T]t;      (* identity *)
Intros # x y z f g h; Refine f(g(h));   (* composition *)
Intros # x y f;Refine ext [u:x]y;Intros z;Refine Eq_refl;
                                       (* left id *)
Intros # x y f;Refine ext [u:x]y;Intros z;Refine Eq_refl;
                                       (* right id *)
Intros x y z w f g h;Refine Eq_refl;    (* associativity *)
Save Setc;

One can examine the result by

Lego> Setc;
value of Setc =
        (Set,
        [x,y:Set]x->y,
        [x:Set]([T:Type][t:T]t) x,
        [x,y,z|Set]
          [f:([x'4,y'5:Set]x'4->y'5) y z]
          [g:([x'5,y'6:Set]x'5->y'6) x y]
          [h:x]
          f (g h),

⋮

type of Setc  = CAT

Note that to prove the identity laws for Setc, one needs extensionality axiom ext.

For this instance, it is possible to avoid the use of ext by redefining the sense of

equality for functions, as in [52].

The opposite category is obtained by reversing the order of arguments for the

Hom-set function H.

(* Opposite category (small) *)
[A:Cat];
Goal Cat;
Intros #; Refine Ob A;                  (* objects *)
Intros #; Refine [x:Ob A][y:Ob A]H y x; (* morphisms *)
Intros #; Refine [x:Ob A]id x;          (* identity *)

Intros # x y z f g; Refine o g f;       (* composition *)

⋮

Save opcat;
Discharge A;

During the development, we used some templates for proof components of a small category to speed up compilation once actual proofs are done. For example,

(* constants to substitute real proofs *)
[claim_ul:
        {Ob:Set}{H:Ob->Ob->Set}{id:{x:Ob}H x x}
        {o:{x,y,z|Ob}(H y z)->(H x y)->H x z}
        {x,y|Ob}{f:H x y}(Eq f (o (id y) f))];

They also proved to be useful for “rapid prototyping”; in our uniform treatment, most proofs fall into the two patterns of proving that something is a category or a functor, so a small number of templates can be used widely.

Functors and natural transformations Now we turn to our definitions of functors and natural transformations. Depending on the size of domain and codomain categories, at least two types for functors are needed; Fun0 for those from a small category to a large category and ssFun0 for those from a small category to a small category. Although there is an implicit type inclusion from ssFun0 to Fun0, the former is needed to properly type functions that send functors to functors.

Similarly to Cat, a functor is represented by a dependent tuple of 1. an objectpart function, 2. a morphism-part function, 3. a proof of identity preservation, and 4. that of composition preservation. We list here only the definition of Fun0.

(* Type of functors (small -> big) *)
[A:Cat][B:CAT];
Fun0:SET ==
        <O:(Ob A)->(BOb B)>
        <M:{x,y|(Ob A)}(H x y)->(BH (O x) (O y))>
        <pid:{x:(Ob A)}(Eq (M (id x)) (Bid (O x)))>
        {x,y,z:Ob A}{f:(H y z)}{g:(H x y)}
             (Eq (M (o f g)) (Bo (M f) (M g))) ;
Discharge A;

The selectors for Fun0’s four components are named as O, M, pid, pcomp; those for ssFun0 are sO, sM, spid, spcomp. The names of templates for the proof components of a functor are claim pid and claim pcomp.

In the usual notation, a functor F: A ^{}B is at the same time F: A^{op} ^{}B^{op}, but we need explicit operation opfun for this.

value of opfun = · · ·
type of opfun  = {A,B|Cat}(ssFun0 A B)->ssFun0 (opcat A) (opcat B)

Given F,G:Fun0 A B, a natural transformation t:Nat F G consists of a function cpt t that sends an object of A to an morphism of B, together with a proof natcom t of the usual commutative square.

(* Type of natural transformations *)
value of Nat = [A|Cat][B|CAT][F,G:Fun0 A B]
                <cpt:{x:Ob A}BH (O F x) (O G x)>
                {x,y|Ob A}{f:H x y}
                Eq (Bo (cpt y) (M F f)) (Bo (M G f) (cpt x))
type of Nat  = {A|Cat}{B|CAT}(Fun0 A B)->(Fun0 A B)->Set

Then we proceed to give other basic definitions of functor calculus, but we just list the type of each defined terms.

  (* Composition of natural transformations *)
  ott = ... : {A|Cat}{B|CAT}{F,G,K|Fun0 A B}
               (Nat G K)->(Nat F G)->Nat F K
  (* Identity functor *)
  id' = ... : {A:Cat}ssFun0 A A
  (* Identity natural transformation *)
  idt = ... : {A|Cat}{B|CAT}{F:Fun0 A B}Nat F F
  (* Composition of functors of various size *)
  fun_sfun_comp = ...
      : {A,B|Cat}{C|CAT}(Fun0 B C)->(ssFun0 A B)->Fun0 A C
  sfun_sfun_comp = ...
      : {A,B,C|Cat}(ssFun0 B C)->(ssFun0 A B)->ssFun0 A C

To define a functor category, one needs equality for natural transformation. We introduce a constant to ignore the difference in the proof part.

  natEq : {A|Cat}{B|CAT}{F,G|Fun0 A B}{t,s:Nat F G}
           ({x:Ob A}Eq (cpt t x) (cpt s x))->Eq t s

Now the category Fun A B:CAT of functors of type Fun0 A B can be defined as follows.

(* Functor category *)
[A:Cat][B:CAT];
Goal CAT;

Intros #; Refine Fun0 A B;                      (* objects *)
Intros # F G; Refine Nat F G;                   (* morphisms *)
Intros # F; Refine idt;                         (* identity *)
Intros # F G H; Refine ott;                     (* composition *)
Intros # F G t; Refine natEq; Intros x; Refine Bul; (* left id *)
Intros # F G t; Refine natEq; Intros x; Refine Bur; (* right id *)
Intros F G K L s t u; Refine natEq; Intros x; Refine Bo_a;
                                               (* assoc *)
Save Fun;
Discharge A;

Product categories To define a module P: A +^{}C as a functor from C^{op} ×

A ^{}Set, we provide the definition of the product category prodcat A B for

small categories A,B:Cat.

(* Product categories *)
[A,B:Cat];
Goal Cat;
Intros #; Refine sprod (Ob A) (Ob B);           (* object *)
Intros # x y;                                   (* morphism *)
Refine sprod (H (sFst x) (sFst y)) (H (sSnd x) (sSnd y));
Intros # x;                                     (* identity *)
Refine sPair (id (sFst x)) (id (sSnd x));
Intros # x y z f g;                             (* composition *)
Refine sPair (o (sFst f) (sFst g)) (o (sSnd f) (sSnd g));

⋯

Save prodcat;
Discharge A;

We also define the product of two functors, the currying of functors from prodcat

A B to C; the types of these operations are:

type of prodfun  = {A,B,C,D|Cat}(ssFun0 A C)->(ssFun0 B D)
                        ->ssFun0 (prodcat A B) (prodcat C D)
type of curr  = {A,B|Cat}{C|CAT}
                 (Fun0 (prodcat A B) C)->Fun0 A (Fun B C)

Natural isomorphisms A natural isomorphism is represented by a dependent

pair of a natural transformation t and a proof that each component of t is an

isomorphism.

(* Natural isomorphism *)
value of IsoNat = [A|Cat][B|CAT][F,G:Fun0 A B]
                  <t:Nat F G>{x:Ob A}isIso (cpt t x)
type of IsoNat  = {A|Cat}{B|CAT}(Fun0 A B)->(Fun0 A B)->Set

The selector for the first component is isonat.

type of isonat  = {A|Cat}{B|CAT}{F,G|Fun0 A B}(IsoNat F G)->Nat F G

A lemma provides the construction of the inverse natural transformation from a natural isomorphism

value of isonatinv = · · ·
type of isonatinv  = {A|Cat}{B|CAT}{F,G|Fun0 A B}
                     (IsoNat F G)->Nat G F

Hom functors Our last basic definition is for Hom functors:

(* Hom functors *)
[A|Cat];
Goal Fun0 (prodcat (opcat A) A) Setc;
Intros # xy; Refine H|A (sFst xy) (sSnd xy);    (* obj part *)
Intros # xy zw fg h; Refine o|A; Refine +1 o|A; (* mor part *)
Refine +3 h; Refine (sSnd fg); Refine (sFst fg);

⋮

Save Hom;
Discharge A;
type of Hom  = {A|Cat}Fun0 (prodcat (opcat A) A) Setc

3.5.2 Modules, representations, and generic commands

This section reviews our LEGO implementation of modules and representations, and generic commands to manipulate them.

Modules The type Mod0 A C of modules from a small category A to another C is simply that of functors from C^{op} × A to Setc. So, the type of module morphisms is given by that of natural transformation.

(* Type of module *)
Mod0 [A,C:Cat] == Fun0 (prodcat (opcat C)  A) Setc:SET;
Mod1 [A,C|Cat][P,Q:Mod0 A C] == Nat P Q:Set;
Mod [A,C:Cat] == Fun (prodcat (opcat C) A) Setc:CAT;

Now we define the two operations that send F: A ^{}C to F_{∗} and F^{∗} considered in Proposition 2.2.11 by F_{∗} = A(−,?) ∘ (id_{A}^{op} × F) and similarly for F_{∗}. By the duality of definition, we can use F_{∗} to give to give F^{∗} = (F^{op})_{∗}, but we found it too clumsy to put extra opfun and to convert (opcat (opcat A)) to A, etc. So, in our implementation, we give explicit symmetric definitions for the dual cases. We only list those definition concerning right representations.

(* Cat --> Mod *)
value of fun_rMod
        = [A,C|Cat][F:ssFun0 A C]
          fun_sfun_comp (Hom|C) (prodfun (id' (opcat C)) F)
type of fun_rMod  = {A,C|Cat}(ssFun0 A C)->Mod0 A C

Right / left representations Given a module P:Mod0 A C and a functor R:Fun0 A C, rRep P R is the type of natural isomorphism P≅ R_{∗}. A right representation can be given as an element of the Σ type <R:Fun0 A C>rRep P R, but we found that it is slightly more convenient to have R and the natural isomorphism separately.

(* Representability of modules *)
[A,C|Cat][P:Mod0 A C][Q:Mod0 C A][F:ssFun0 A C];
rRep == IsoNat P (fun_rMod F);
lRep == IsoNat Q (fun_lMod F);
Discharge A;

Generic commands and lemmas Our uniform treatment of all universal structure means that we can give generic commands and lemmas about them at this level of generality. The commands themselves are simple terms; they repackage and conveniently type cast the natural isomorphism of a right or left representation. To use a command, a user refine a goal with such a term.

The main generic commands are rIntro and rElim. Given a module P: A +^{}C and a functor F: A ^{}C which right represents P as ρ: F_{∗} ≅ P, the command rIntroρ produce the morphism C ^{}F A uniquely determined by an x ∈ P (C, A) (C ∈ C and A ∈ A); rElim ρ is for the reverse direction. They are so named since they correspond to introduction rules and elimination rules of type theory, respectively.

(* Introduction and Elimination *)
value of rIntro = [A,C|Cat][P|Mod0 A C][F|ssFun0 A C]
                  [p:rRep P F][c:Ob C][a:Ob A][x:O P (sPair c a)]
                  cpt (isonat p) (sPair c a) x
type of rIntro  = {A,C|Cat}{P|Mod0 A C}{F|ssFun0 A C}

                  (rRep P F)->{c:Ob C}{a:Ob A}(O P (sPair c a))
                  ->H c (sO F a)
value of rElim = [A,C|Cat][P|Mod0 A C][F|ssFun0 A C]
                 [p:rRep P F][c:Ob C][a:Ob A][f:H c (sO F a)]
                 cpt (isonatinv p) (sPair c a) f
type of rElim  = {A,C|Cat}{P|Mod0 A C}{F|ssFun0 A C}
                 (rRep P F)->{c:Ob C}{a:Ob A}(H c (sO F a))
                 ->O P (sPair c a)

Next we prove lemmas that prove these are bijective, injective, natural, etc.. These unwind the definition of isomorphisms instantiated in Setc and give a typing easier to use. We only list the types of those lemmas.

type of rIEbij  = {A,C|Cat}{P|Mod0 A C}{F|ssFun0 A C}
                  {p:rRep P F}{c:Ob C}{a:Ob A}{f:H c (sO F a)}
                  Eq (rIntro p c a (rElim p c a f)) f
type of rEIbij  = {A,C|Cat}{P|Mod0 A C}{F|ssFun0 A C}
                  {p:rRep P F}{c:Ob C}{a:Ob A}{x:O P (sPair c a)}
                  Eq (rElim p c a (rIntro p c a x)) x
type of rElim_inj  = {A,C|Cat}{P|Mod0 A C}{F|ssFun0 A C}
                     {p:rRep P F}{c:Ob C}{a:Ob A}{f,g:H c (sO F a)}
                     (Eq (rElim p c a f) (rElim p c a g))->Eq f g
type of rI_nat1  = {A,C|Cat}{P|Mod0 A C}{F|ssFun0 A C}
                   {p:rRep P F}{c:Ob C}{a:Ob A}{d:Ob C}
                   {h:H d c}{x:O P (sPair c a)}[ha=sPair h (id a)]
                Eq (rIntro p d a (M P ha x)) (o (rIntro p c a x) h)

3.5.3 Binary products

Given the definitions and lemmas we reviewed so far, one can develop LEGO code for a specific structure in a uniform way by simply giving a module that defines the structure. Our first example is binary products structure. The following code provides the definition of module Pairs(C): C × C +^{}C in Section 2.4. Due to some name conflict with the standard library, here the module is called prodmod.

Assuming C:Cat is given, prodmod is defined as follows.

[C:Cat];
(* the module for product functor *)
(* the object part *)
[prodmod0 =
        [zxy:Ob (prodcat (opcat C) (prodcat C C))]
        sprod (H|C (sFst3 zxy) (sSnd3 zxy))
                    (H|C (sFst3 zxy) (sThd3 zxy))];
(* the morphism part *)

[prodmod1 =
        [zxy,wuv|Ob (prodcat (opcat C) (prodcat C C))]
        [hfg:H zxy wuv]
        [kl:prodmod0 zxy]
        sPair (o (sSnd3 hfg) (o (sFst kl) (sFst3 hfg)))
              (o (sThd3 hfg) (o (sSnd kl) (sFst3 hfg)))];
Goal Mod0 (prodcat C C) C;
Intros #; Refine prodmod0;
Intros #; Refine prodmod1;

⋮

Save prodmod;
Discharge C;

One may also derive from the generic commands some abbreviation specific to

binary products for ease of use. For example, rIntro command can be re-typed

as below.

timesIntro = ... : C|Cat
        times|ssFun0 (prodcat C C) C(rRep (prodmod C) times)
        ->{a,b,x:Ob C}
        (H x a)->(H x b)->H x (sO times (sPair a b))

The simplest use is as follows. In the context defined in the above display, to

solve the goal C(x, a × b), a user can type in Refine timesIntro p;.

  ?13 : H x (O times (sPair a b))
Lego> Refine timesIntro p;
Refine by timesIntro p
  ?19 : H x a
  ?20 : H x b

3.5.4 Terminal objects

The next example is the structure of terminal objects. The terminal object in a

category C is defined by the module termmod : 1 +^{}C which sends every C ∈ C

to the singleton set.

We first define the terminal category termcat.

(* the terminal category *)
Goal Cat;
Intros #; Refine sunit;
Intros # x y; Refine sunit;
Intros # x; Refine svoid;
Intros # x y z f g; Refine svoid;

⋮

Save termcat;

; Similarly, the definition of termmod is given by

(* the module for terminal objects *)
[C:Cat];
Goal Mod0 termcat C;
Intros # x; Refine sunit;
Intros # x y h; Refine [t:sunit]t;

⋮

Save termmod;
Discharge C;

An abbreviation of rIntro is

termIntro = ... : {C|Cat}
        {termfun:ssFun0 termcat C}(rRep (termmod C) termfun)
        ->{x:Ob C}H x (sO termfun svoid)

We also give a lemma that proves any two morphism from an object X to a terminal object T in C are the same. Given two morphisms f, g: X ^{}T, both are determined by the unique element of the singleton set termmod(X, ∗), and hence are the same.

(* All morphisms into the terminal object are the same *)
[C|Cat];
[termfun:ssFun0 termcat C][p:rRep (termmod C) termfun];
[x:Ob C][f,g:H x (sO termfun svoid)];
Goal Eq f g;
Refine rElim_inj p;
Refine all_sunitvoid; Refine Eq_sym; Refine all_sunitvoid;
Save sh_unique;
Discharge C;

3.5.5 Equalizers

LEGO code for equalizers is developed in the same manner. The module that define the equalizer structure on C is Ker: [Para, C] +^{}C given in Section 2.4. As before, we first construct the domain category paracat C for a category C based on the concrete description of [Para, C] given in Section 2.4. This may be given as a functor category, but a direct definition is found to be easier to use. First, we

define the type of objects.

[C:Cat];
(* The category of parallel pairs *)
(* Objects *)
paracat0:Set == sSigma (Ob C)
                ([x:Ob C] sSigma (Ob C)
                ([y:Ob C] sprod (H x y)(H x y)));

The four selectors are paradom, paracod, parafst, and parasnd. Given f,g:H x

y, the constructor paracons0 f g gives an element of paracat0 using argument

synthesis.

Hom-sets are given by

(* Hom-sets *)
[fg,kl:paracat0];
paracat1
        == sSigma (H|C (paradom fg) (paradom kl))
           ([u:(H|C (paradom fg) (paradom kl))]
           sSigma (H|C (paracod fg) (paracod kl))
           ([v:(H|C (paracod fg) (paracod kl))]
            (and (Eq (o v (parafst fg)) (o (parafst kl) u))
                (Eq (o v (parasnd fg)) (o (parasnd kl) u)))));
Discharge fg;

The selectors are paramor0, paramor1, parmorcom0, and paramorcom1.

Next, we define identities and composition. These are given by specific proofs

of appropriate types.

(* Identities *)
Goal {fg:paracat0}paracat1 fg fg;
Intros fg;
Refine sdep_pair; Refine id;
Refine sdep_pair; Refine id;
Refine pair;
Qrepl (Eq_sym (ul (parafst fg))); Qrepl (Eq_sym (ur (parafst fg)));
Refine Eq_refl;
Qrepl (Eq_sym (ul (parasnd fg))); Qrepl (Eq_sym (ur (parasnd fg)));
Refine Eq_refl;
Save paraid;
(* The composition *)
Goal {fg,ij,kl:paracat0}{st:paracat1 ij kl}{uv:paracat1 fg ij}
        paracat1 fg kl;
Intros fg ij kl st uv;
Refine sdep_pair; Refine o (paramor0 st) (paramor0 uv);
Refine sdep_pair; Refine o (paramor1 st) (paramor1 uv);
Refine pair;

Refine o_b; Qrepl Eq_sym (paramorcom0 st);
Refine o_a; Qrepl Eq_sym (paramorcom0 uv);
Refine o_b; Refine Eq_refl;
Refine o_b; Qrepl Eq_sym (paramorcom1 st);
Refine o_a; Qrepl Eq_sym (paramorcom1 uv);
Refine o_b;
Save paracomp;

The category paracat:Cat is obtained by packing these definitions.

Then we define the module eqmod:Mod0 (paracat C) C, which is called Ker

in Section 2.4. The object part are as follows, with the selectors eqmod0mor and

eqmod0prf.
(* The module for equalizers *)
(* The object part *)
[x:Ob C][fg:paracat0];
eqmod0 == sSigma (H x (paradom fg))
          ([h:H x (paradom fg)]
                Eq (o (parafst fg) h) (o (parasnd fg) h));
Discharge x;

The morphism part is given by the following specific proof.

(* The morphism part *)
[x,y:Ob C][fg,kl:paracat0][w:H y x][uv:paracat1 fg kl];
[hp:eqmod0 x fg];
Goal  eqmod0 y kl;
Refine sdep_pair;
Refine (o (o (paramor0 uv) (eqmod0mor hp)) w);
Qrepl o_a (parafst kl) (o (paramor0 uv) (eqmod0mor hp)) w;
Qrepl o_a (parafst kl) (paramor0 uv) (eqmod0mor hp);
Qrepl Eq_sym (paramorcom0 uv);
Qrepl o_b (paramor1 uv) (parafst fg) (eqmod0mor hp);
Qrepl eqmod0prf hp;
Qrepl o_a (paramor1 uv) (parasnd fg) (eqmod0mor hp);
Qrepl paramorcom1 uv;
Qrepl o_a (parasnd kl) (o (paramor0 uv) (eqmod0mor hp)) w;
Qrepl o_a (parasnd kl) (paramor0 uv) (eqmod0mor hp);
Refine Eq_refl;
Save eqmod1;
Discharge x;

The module eqmod is defined by packing these definitions with appropriate re-

typing.

(* Packing these definitions to the module eqmod *)
eqmod0' [xfg:Ob (prodcat (opcat C) paracat)]
        == eqmod0 (sFst xfg) (sSnd xfg);
eqmod1' [xfg,ykl:Ob (prodcat (opcat C) paracat)]

        [wuv:H xfg ykl]
        [hp:eqmod0' xfg]
        == eqmod1 (sFst xfg) (sFst ykl) (sSnd xfg) (sSnd ykl)
                (sFst wuv) (sSnd wuv) hp;
Goal Mod0 paracat C;
Intros #; Refine eqmod0';
Intros #; Refine eqmod1';

⋮

Save eqmod;

Finally, we introduce an abbreviation for the instance of rIntro for eqmod.

value of eqlIntro = · · ·
type of eqlIntro  = {C|Cat}
        {eql:ssFun0 (paracat|C) C}(rRep (eqmod|C) eql)
        ->a,b|Ob Cf,g:H a bx:Ob C(eqmod0 x (paracons0 f g))
        ->H x (sO eql (paracons0 f g))

3.5.6 Pullbacks

First, given a category C, we define the domain category pbcat C of the defining module pbmod: pbcat(C) +^{}C. pbcat(C) is the functor category [\begin{matrix}& & · \\ · & → & ·^{} \end{matrix}, C]; but for the same reason as [Para, C], we define the small category pbcat(C) directly. An object of pbcat(C) is a pair of morphisms A ^{f}^{}C ^{}^{g} B with the same codomain. In LEGO, this is represented by a dependent tuple of 1. the domain of f, 2. the domain of g, 3. the codomain of f and g, and 4. the pair (f, g). The morphism of pbcat(C) from A ^{f}^{}C ^{}^{g} B to D ^{k}^{}F ^{}^{g} E is a triple (u: A ^{}D, v: B ^{}E, w: C ^{}F), such that two squares below commutes.

[figure: A; f; C; g; B; D; u; k; F; w; l; E; v]

In LEGO, this is represented by a dependent tuple of u, v, w, and the proof that the two squre commutes. The identity and composition are defined in the obvious way, but in LEGO one has to supply the proof that they make relevant squares commute. The type of objects are given as follows.

[C:Cat];

(* Domain cat of pbmod *)
(* The objects *)
pbcat0:Set == sSigma (Ob C)
        ([a:Ob C] sSigma (Ob C)
        ([b:Ob C] sSigma (Ob C)
        ([c:Ob C] sprod (H a c) (H b c))));

The selectors for the five components are pbcat0a, pbcat0b, pbcat0c, pbcat0fst,

and pbcat0snd. Given f:H a c and g:H b c, the constructor pbcat0cons f g

gives an element of pbcat0. The Hom-sets are given by

(* Hom-sets *)
pbcat1 [fg,kl:pbcat0]
       == sSigma (H (pbcat0a fg) (pbcat0a kl))
       ([u:(H (pbcat0a fg) (pbcat0a kl))]
        sSigma (H (pbcat0b fg) (pbcat0b kl))
       ([v:(H (pbcat0b fg) (pbcat0b kl))]
        sSigma (H (pbcat0c fg) (pbcat0c kl))
       ([w:(H (pbcat0c fg) (pbcat0c kl))]
       (and (Eq (o w (pbcat0fst fg)) (o (pbcat0fst kl) u))
            (Eq (o w (pbcat0snd fg)) (o (pbcat0snd kl) v)))))):Set;

with the selectors pbcat1a, pbcat1b, pbcat1c, pbcat1com0, and pbcat1com1.

The identities and the composition are defined by the following proof.

(* Identities *)
[fg:pbcat0];
Goal pbcat1 fg fg;
Refine sdep_pair; Refine id (pbcat0a fg);
Refine sdep_pair; Refine id (pbcat0b fg);
Refine sdep_pair; Refine id (pbcat0c fg);
Refine pair;
Qrepl Eq_sym (ul (pbcat0fst fg)); Qrepl Eq_sym (ur (pbcat0fst fg));
Refine Eq_refl;
Qrepl Eq_sym (ul (pbcat0snd fg)); Qrepl Eq_sym (ur (pbcat0snd fg));
Refine Eq_refl;
Save pbcatid;
Discharge fg;
(* Composition *)
[fg,kl,ij:pbcat0] [uvw:pbcat1 kl ij] [rst:pbcat1 fg kl];
Goal pbcat1 fg ij;
Refine sdep_pair; Refine o (pbcat1a uvw) (pbcat1a rst);
Refine sdep_pair; Refine o (pbcat1b uvw) (pbcat1b rst);
Refine sdep_pair; Refine o (pbcat1c uvw) (pbcat1c rst);
Refine pair;
Refine o_b; Qrepl Eq_sym (pbcat1com0 uvw);
Refine o_a; Qrepl Eq_sym (pbcat1com0 rst);
Refine o_b;
Refine o_b; Qrepl Eq_sym (pbcat1com1 uvw);
Refine o_a; Qrepl Eq_sym (pbcat1com1 rst);
Refine o_b;

Save pbcatcomp;
Discharge fg;

The category pbcat C for C:Cat is obtained by packing these definitions.

The module pbmod(C): pbcat(C) +^{}C sends (X ∈ C, (f, g) ∈ pbcat(C)) to

the set of pairs of morphisms (p, q) such that the following diagram commutes.

[figure: X; p; A; B; q; g; C; f]

This is represented in LEGO by a dependent tuple of p, q, and the proof that

fp = gq. Given t: Y ^{}X in C and (u, v, w): (f, g) ^{}(k, l) in pbcat(C), the

morphism part of pbmod(C) sends (p, q) ∈ pbmod(C)(X, (f, g)) to (upt, vqt). The

conditions on (p, q) and (u, v, w) ensure that (upt, vqt) is in pbmod(C)(Y, (k, l)).

The proof of this fact in LEGO supplies the proof part of the representation of

(upt, vqt) in LEGO. A representation F: pbcat(C) ^{}C then sends (f, g) to the

vertex of a pullback square for f and g with the counit giving the two morphisms

that complete the square. First, the object part is given by

(* The module pbmod *)
(* The object part, a temporary definition *)
pbmod0 [a,b,c:Ob C][f:H a c][g:H b c][x:Ob C]
        == sSigma (H x a)
        ([p:H x a] sSigma (H x b)
        ([q:H x b] Eq (o f p) (o g q))):Set;

with the selectors pbmod0p, pbmod0q, and pbmod0r and

(* The object part *)
pbmod0' [xfg:Ob (prodcat (opcat C) pbcat)]
        == [fg = sSnd xfg]
                  pbmod0 (pbcat0a fg)
                  (pbcat0b fg)
                  (pbcat0c fg)
                  (pbcat0fst fg)
                  (pbcat0snd fg)
                  (sFst xfg):Set;

Given f:H a c, g:H b c, p:H x a, q:H x b, and t:Eq (o f p) (o g q), the

constructor pbmod0cons f g p q t gives an element of pbmod0. The morphism

part is defined by

(* The morphism part, a temporary definition *)
[x:Ob C][fg:Ob pbcat];
[y:Ob C][kl:Ob pbcat];
[t:H y x][uvw:pbcat1 fg kl];
[pqr:pbmod0' (sPair x fg)];
Goal pbmod0' (sPair y kl);
Refine sdep_pair; Refine o (pbcat1a uvw) (o (pbmod0p pqr) t);
Refine sdep_pair; Refine o (pbcat1b uvw) (o (pbmod0q pqr) t);
Qrepl o_a (pbcat0fst kl) (pbcat1a uvw) (o (pbmod0p pqr) t);
Qrepl o_a (pbcat0snd kl) (pbcat1b uvw) (o (pbmod0q pqr) t);
Qrepl Eq_sym (pbcat1com0 uvw);
Qrepl Eq_sym (pbcat1com1 uvw);
Qrepl o_b (pbcat1c uvw) (pbcat0fst fg) (o (pbmod0p pqr) t);
Qrepl o_b (pbcat1c uvw) (pbcat0snd fg) (o (pbmod0q pqr) t);
Qrepl o_a (pbcat0fst fg)(pbmod0p pqr) t;
Qrepl o_a (pbcat0snd fg)(pbmod0q pqr) t;
Qrepl pbmod0r pqr;
Refine Eq_refl;
Save pbmod1;
Discharge x;
(* The morphism part *)
pbmod1' [xfg,ykl:Ob (prodcat (opcat C) pbcat)]
        [tuvw:H xfg ykl]
        [pqr:pbmod0' xfg]
        ==
        pbmod1 (sFst xfg) (sSnd xfg) (sFst ykl) (sSnd ykl)
               (sFst tuvw) (sSnd tuvw) pqr:pbmod0' ykl;

The module pbmod is defined by packing these definitions.

Finally, we provide some abbreviations for rIntro instantiated with pbmod.

value of pbIntro = · · ·
type of pbIntro  = {C|Cat}
        {pb:ssFun0 (pbcat C) C}(rRep (pbmod C) pb)
        ->{a,b,c|Ob C}{f:H a c}{g:H b c}
        {x:Ob C}{p:H x a}{q:H x b}
        (Eq (o f p) (o g q))
        ->H x (sO pb (pbcat0cons f g))

We can not just compare two elements (p, q) and (p′, q′) of pbmod(C)(X, (f, g))

with Eq because of their proof components. To ignore any difference in their proof

parts, we define a constant pbmod0Eq that produce Eq((p, q), (p′, q′)) from Eq(p, p′)

and Eq(q, q′).

(* For the proof irrelevance *)
[C|Cat][a,b,c|Ob C][f|H a c][g|H b c];
[x|Ob C][pqr,pqr':pbmod0 C a b c f g x];
$[pbmod0Eq:(Eq (pbmod0p C pqr) (pbmod0p C pqr'))->
           (Eq (pbmod0q C pqr) (pbmod0q C pqr'))->Eq pqr pqr'];
Discharge C;

3.5.7 An example construction

As an example use of the commands defined in the previous sections, we construct equalizers from pullbacks and terminal objects. The construction goes as follows. Let C be a category with a terminal object T and pullbacks, and A [figure: f; g] B a parallel pair of morphisms in C. Construct the object C in C as the vertex of the pullback

[figure: C; B; B; !_{B}; T; !_{B}]

where !_{B} is the unique morhpism from B to T. The object C is a binary product of B with itself, but we adhere to its definition by the pullback for explanatory purpose. By the universality of T, !_{B}f and !_{B}g are the same, hence (f, g) is an element of pbmod(C)(A, (!_{B},!_{B})). Let h: A ^{}C be the morphism determined by (f, g). Also let Δ: B ^{}C be the morphism determined by the element (id_{B}, id_{B}) of pbmod(C)(B, (!_{B},!_{B})). Finally, let E be the vertex of the following pullback.

[figure: E; e; A; B; Δ; C; h]

Then, by the universality of the two pullbacks above, E is an equalizer of (f, g) and e the universal arrow.

In LEGO, this argument can be formalized as follows. First, we define some abbreviations.

[C:Cat];
[pb:ssFun0 (pbcat C) C];
[pbprf:rRep (pbmod C) pb];
CpbIntro == pbIntro pb pbprf;
CpbElim == pbElim pb pbprf;
[termfun:ssFun0 termcat C];
[termprf:rRep (termmod C) termfun];
Cterm == sO termfun svoid:Ob C;
Csh == termIntro termfun termprf:{b:Ob C}H b Cterm;
Csh_unique == sh_unique termfun termprf;

Next, we construct the object C, and a function tpair that sends (f, g: X ^{}B) to ⟨f, g⟩: X ^{}C; this is an instance of rIntro.

[a,b|Ob C];
(* (b x b) by pb's *)
[f,g:H a b];
Goal pbmod0 C b b Cterm (Csh b) (Csh b) a;
Refine sdep_pair; Refine f; Refine sdep_pair;
Refine g; Refine Csh_unique;
Save tpmod0cons;
Goal H a (sO pb (pbcat0cons (Csh b) (Csh b)));
Refine CpbIntro (Csh b) (Csh b);
Refine f; Refine g;
Refine Csh_unique;
Save tpair;
Discharge f;

The following are some lemmas about tpair that are instances of the generic lemmas given in Section 3.5.2.

tpair_ext1 = ... : {a,b|Ob C}
        {f,g,k,l:H a b}(Eq (tpair f g) (tpair k l))->Eq f k
tpair_ext2 = ... : {a,b|Ob C}
        {f,g,k,l:H a b}(Eq (tpair f g) (tpair k l))->Eq g l
(* Naturality of tpair                        *)
(* (tpair f g) o h = (tpair  (f o h) (g o h)) *)
tpair_nat = ... : {a,b|Ob C}
        {f,g:H a b}{x:Ob C}{h:H x a}
        Eq (tpair (o f h) (o g h)) (o (tpair f g) h)

Now we give the definition of Δ: B ^{}C and E, which are denoted delta b and eql in the code, respectively.

delta [b:Ob C] == tpair (id b) (id b);
(* The construction of equalizer *)
[a,b|Ob C][f,g:H a b];
eql == sO pb (pbcat0cons (tpair f g) (delta b));

Finally, we give the correspondence between a morphism X ^{h}^{}A with fh = gh and a morphism X ^{}E. First, in the forward direction, we use the properties of tpair to deduce from fh = gh that (h, fh) is an element of pbmod(C)(X, (tpair(f, g), Δ)), which in turn determines X ^{}E.

[x:Ob C];
[h:H x a];
[prf:Eq (o f h) (o g h)];
Goal H x eql;
Refine CpbIntro; Refine h; Refine (o f h);
Qrepl Eq_sym (tpair_nat f g x h);
Expand delta; Qrepl Eq_sym (tpair_nat (id b) (id b) x (o f h));
Qrepl prf; Qrepl Eq_sym (ul (o g h));
Refine Eq_refl;
Save eqlIntro;
Discharge h;

In the reverse direction, the corresponding morphism is obtained as the first com-

ponent of the element (p, q) ∈ pbmod(C)(X, (tpair(fg), Δ)) determined by the

given X ^{}E.

[h:H x eql];
Goal H x a;
Refine pbmod0p; Refine +4 CpbElim; Refine +4 h;
Save eql_mor;

Not only the construction of the morphism eql mor, one can also show that this

indeed satisfies that f ∘ eql mor = g ∘ eql mor. First, the second component and

the proof part of (p, q) given in the above paragraph is extracted.

Goal H x b;
Refine pbmod0q; Refine +4 CpbElim; Refine +4 h;
Save eql_wit;
Goal Eq (o (tpair f g) eql_mor) (o (delta b) eql_wit);
Refine pbmod0r; Refine +4 CpbElim; Refine +4 h;
Save eql_temp0;

With these and the properties of tpair, one can deduce the desired equality.

Goal Eq (o f eql_mor) (o (id b) eql_wit);
Refine tpair_ext1;
Refine (o g eql_mor); Refine (o (id b) eql_wit);
Qrepl tpair_nat f g x eql_mor;
Qrepl tpair_nat (id b) (id b) x eql_wit;
Refine eql_temp0;
Save eql_temp1;
Goal Eq (o g eql_mor) (o (id b) eql_wit);
Refine tpair_ext2;
Refine (o f eql_mor); Refine (o (id b) eql_wit);
Qrepl tpair_nat f g x eql_mor;
Qrepl tpair_nat (id b) (id b) x eql_wit;
Refine eql_temp0;

Save eql_temp2;
Goal Eq (o f eql_mor) (o g eql_mor);
Refine Eq_trans; Refine +1 eql_temp1; Refine Eq_sym (eql_temp2);
Save eql_prf;
Discharge h;

To complete a proof that the construction gives an equalizer, one further needs to prove that the above correspondence is bijective and that it is also natural. They can be shown similarly with suitable instances of generic lemmas given in Section 3.5.2.

Fibrations with extra structure

4.1 Introduction

In this section, we study fibrations and structures on them. This is to illustrate how sophisticated categorical structures can be developed in terms of universality. This also provides a purely categorical description of the structure on fibrations used in Chapter 5 and 6 in a type theoretic context. Fibrations are of particular interest to computer science; their applications includes models for type theory, the study of logical predicates, and the semantics for concurrency (see, e.g., [37, 34,67]).

In the spirit of the analysis in Chapter 2, our presentation pays attention to making clear what functor is required to be representable for a fibration to have certain structure. Since a fibration consists of its total category and a base category related by a functor, a structure on a fibration can be broken down into structures on these two categories and a relationship between them. We can therefore apply our definition of universal structure in Chapter 2. However, in this chapter, we do not restrict ourselves to technically applying our definition of universal structure for ordinary categories. This is because we favour the view that a fibration is a parameterised category [8,78]. So, we give a presentation where a fibration is dealt with as a whole. Particularly, we emphasise the role of E_{u}(−, −), that is, a collection of morphisms in a total category E over a specified base morphism u. We also give a detailed description of locally small fibrations, with which one can internalise arguments based on E_{u}(−, −). Our study is not enough to give a definition of universal structure on a fibration with the same technical detail as that for ordinary categories, but our presentation here is a start towards finding such a framework. We discuss a direction for further development in Chapter 8.

Fibrations are defined in Section 4.2. We give an alternative formulation based on E_{u}(−, −) showing that a cartesian morphism is the counit of a certain representation. Section 4.3 gives a few example of fibrations and Section 4.4 explains the relationship between fibrations and indexed categories. Section 4.5 defines morphisms and 2-cells of fibrations, giving the 2-category Fib of fibrations. Products and exponentials of fibrations are also defined. In Section 4.6, we describe locally small fibrations in detail. Fibred limits and fibred cartesian closed categories are defined in Section 4.7. For the particular cases of terminal objects and binary products, we reformulate the general definition in terms of E_{u}(−, −) and internalise it using local smallness. Finally, Section 4.8 describes products and coproducts indexed by base objects.

The novelty of this chapter is the new emphasis in the presentation and some corresponding reformulation of known material; the original work can be found, for example, in papers by Grothendiek [28], Giraud [24], Bénabou [7,6], and Celeyrette [15].

4.2 Fibrations and cartesian morphisms

Given a functor p: E ^{}B, a diagram D: I ^{}E in E is said to be over the diagram pD: I ^{}B. For I ∈ B, the fibre E_{I} over I is the subcategory of E given by objects and morphisms over I and id_{I}, respectively; i.e., those objects X of E for which pX = I, and those morphisms sent to id_{I} by p. A morphism in a fibre is called vertical. A fibre E_{I} is also written p^{−1}(I).

Given u: J ^{}I, X ∈ E_{I}, and Y ∈ E_{J}, E_{u}(Y, X) is the subset of E(Y, X) consisting of those morphisms over u, i.e.,

E_{u}(Y, X) ≡ {f: Y ^{}X | pf = u}.

Given u: pY ^{}pX in B, we will write f: Y _{(u)}^{}X or Y \begin{matrix}f \\ (u) \end{matrix}^{}X if f ∈ E_{u}(Y, X). Given v: K ^{}J in B and Z ∈ E_{K}, the function

E_{u}(Z, f): E_{v}(Z, Y) ^{}E_{uv}(Z, X)

is the restriction of

E(Z, f): E(Z, Y) ^{}E(Z, X).

Dually, given v: I ^{}K in B and Z ∈ E_{K},

E^{u}(f, Z): E_{v}(X, Z) ^{}E_{vu}(Y, Z)

is the restriction of

E(f, Z): E(X, Z) ^{}E(Y, Z),

We now introduce our central definitions. These are not the usual version in the literature, but it is easily observable that they are equivalent.

Definition 4.2.1. Given X ∈ E_{I} and u: J ^{}I in B, a morphism f: Y _{(u)}^{}X in E is called cartesian over u if, for all v: K ^{}J and Z ∈ E_{K},

E_{u}(Z, f): E_{v}(Z, Y) ^{}E_{uv}(Z, X)

is a bijection.

Diagrammatically, for each g over uv, there exists unique g′ over v such that the above of the following commutative diagrams lies over the lower.

Z  ^{g′  ^{}}Y
[figure: g; f]
X

p K  \overline{v  ^{}}J
I.

[figure: uv; u]

We write f: Y +^{}X if f is cartesian; so, a cartesian morphism f over u is written f: Y +_{(u)}^{}X. In this chapter, the notation A +^{}C for modules is not used.

For conciseness, we often fold a diagram in E over another diagram in B into one diagram using the notation X \begin{matrix}f \\ (u) \end{matrix}^{}Y; e.g., The above diagram may be written

Z  \begin{matrix}g′ \\ (v) \end{matrix}  ^{}Y
[figure: g; (uv); f; (u)]
X

Definition 4.2.2. A functor p: E ^{}B is a fibration if, for each pair (X, u) with X ∈ E_{I} and u: J ^{}I, there exists a cartesian morphism over u with codomain X.

In many cases, p is the only fibration associated with E and B and is clear from the context; so we will often omit explicit mention of p, saying simply that E is fibred over B.

The categories E and B are called the total category and the base category of the fibration, respectively.

We now show that cartesian morphisms are determined up to unique isomorphism in E_{J}.

Lemma 4.2.3. If f: Y +_{(u)}^{}X and f′: Z +_{(u)}^{}X are cartesian over u: J ^{}I, there is a unique isomorphism c: Y ≅ Z in E_{J} such that f = f′c.

Proof Let c and c′ be the morphisms over id_{J}, which exist (uniquely) by Definition 4.2.1, such that the following commute.

[figure: Y; \begin{matrix}c \\ (id_{J}) \end{matrix}; Z; ×; f; (u); ×; f′; (u); A; Y; \begin{matrix}c′ \\ (id_{J}) \end{matrix}; Z; ×; f′; (u); ×; f; (u); A]

Then, the composition cc′ makes the outer triangle of the diagram below commute.

[figure: Y; \begin{matrix}c \\ (id_{J}) \end{matrix}; Z; \begin{matrix}c′ \\ (id_{J}) \end{matrix}; Y]
[figure: f; f]
A^{f′^{}}

But, Y ^{id_{X}}^{}Y over id_{J} also makes this commute. Since f is cartesian, there is only one such morphism over id_{J} and cc′ must be equal to id_{A′}. Similarly, c′c = id_{A′′}.

Henceforth, we may omit the name of a cartesian morphism, only specifying the underlying base morphism. For example, we will write Y +_{(u)}^{}X for Y +^{f}_{(u)}^{}X.

Equivalently, a cartesian morphism can be seen as the counit of a representation which describes the domain Y of Y +_{(u)}^{}X in terms of morphisms into it over specified base morphisms, as we now see:

Proposition 4.2.4. Given (X, u: J ^{}I) with X ∈ E_{I}, an object Y ∈ E_{J} is the domain of a cartesian morphism Y +_{(u)}^{}X over u if and only if, for each Z ∈ E_{K} and v: K ^{}J, there is a bijection ϕ_{(v,Z)}: E_{v}(Z, Y) ≅ E_{uv}(Z, X) satisfying the following naturality condition: given h: W ^{}Z in E over w: L ^{}K in B, the following commutes.

[figure: E_{v}(W, Y); ϕ_{(v,W)}; E_{uv}(W, X); E_{vw}(Z, Y); E^{w}(h, Y); ϕ_{(vw,Z)}; E_{uvw}(Z, X); E^{w}(h, X)]

Proof The naturality condition ensures that f ≡ ϕ_{(id_{J} ,Y)}(id_{Y}) is cartesian, i.e., ϕ_{(v,Z)} = E_{u}(Z, f).

We indicate this naturality in Z by the notation

{Z _{(v)}^{}X′ \atop Z _{(uv)}^{}X.} ≅

The natural bijection determines Y up to unique isomorphism. This is by the same argument as that a representing object C ∈ C of a functor C ^{}Set is determined up to isomorphism. However, the difference between specifying morphisms into Y and specifying morphisms into Y over a specified base morphism is important. Particularly, Y is determined up to isomorphism in E_{J}, not just in E.

The definition has immediate consequences in composition and cancellation of cartesian morphisms.

Lemma 4.2.5. (i) Any cartesian morphism over an identity is an isomorphism. (ii) If f and g are cartesian, so is fg. (iii) If fg and f is cartesian, so is g.

Proof (i) is obvious. Let f: Y ^{}X, g: Z ^{}Y, u = pf, and v = pg. For (ii), given any W ∈ E_{L} and w: L ^{}pZ, one has

\begin{matrix}{W _{(w)}^{}Z \atop W _{(vw)}^{}Y} & ≅ ; g ∘ − \\ W _{(uvw)}^{}X, \end{matrix} ; ≅ ; f ∘ −

and one can check that this bijection is natural in W and w, and that Z ^{id_{Z}}^{}Z corresponds to fg. Similarly for (iii), given any W ∈ E_{L} and w: L ^{}pZ, one has

{W _{(w)}^{}X \atop W _{(uvw)}^{}Z} ≅ ; fg ∘ − W _{(vw)}^{}Y. ≅ ; the inverse of f ∘ −

Lemma 4.2.6. Any morphism Y _{(u)}^{}X in the total category of a fibration factorises as a cartesian morphism Z +_{(u)}^{}X over u followed by a vertical morphism ū: Y _{(id_{pY} )}^{}Z. The factorisation is unique up to isomorphism in E_{pY}.

Proof Immediate from the definition.

It is sometimes convenient to chose particular cartesian morphisms for all pairs (X, u: J ^{}I) with X ∈ E_{I}. In the light of Proposition 4.2.4, this is similar to choosing particular product cones for all pairs of objects in a category with binary products.

Definition 4.2.7. A cleavage for a fibration p is a choice, for each (X, u: J ^{}I) with X ∈ E_{I}, of a cartesian morphism over u with codomain X. A cloven fibration is a fibration together with a cleavage. The specified cartesian morphism for (X, u) is written û(X): X[u] +^{}X. A splitting is a cleavage which satisfies the conditions: îd_{I}(X) = id_{X}, and for X ∈ E_{I}, u: J ^{}I, and v: K ^{}J, v̂(X[u])û(X) = ûv(X). A split fibration is a fibration with a splitting.

In a diagram, we may omit û(X) and (u) from X[u] +^{_{u}(X)}_{(u)}^{}X and write X[u] +^{}X.

Using the axiom of choice, one can assume, without a loss of generality, that a fibration is always equipped with a cleavage. Also, we will later see that any cloven fibration is equivalent, in a 2-category of fibrations defined below, to a split fibration. The axiom of choice is an axiom of classical set theory and it does not, in general, hold in an topos or a type theory in which one may work internally. However, the existence of a cleavage is often a reasonable assumption as it is not the assumption of the axiom of choice in the base category (which may be a topos and whose internal logic one may use), but in the metatheory.

The universality of X[u] with u: J ^{}I and X ∈ E_{I} extends the assignment X ↦ X[u] to a functor E_{I} ^{}E_{J}.

Definition 4.2.8. Given a cleavage and u: J ^{}I in B, the substitution functor (−)[u]: E_{I} ^{}E_{J} sends Y ^{f}^{}X in E_{I} to the unique morphism Y [u] ^{f[u]}^{}X[u] in E_{J} that satisfies

[figure: Y [u]; \begin{matrix}f[u] \\ (id_{J}) \end{matrix}; X[u]; Y; +; \begin{matrix}f \\ (id_{I}) \end{matrix}; X.; +]

The functoriality of (−)[u] is immediate from the uniqueness of f[u]. Since the substitution functor for every cleavage is isomorphic to each other, we loosely say, for example, the “substitution functor preserves a limit” omitting “for any given cleavage”.

The assignment I ↦ E_{I}, together with u ↦ (−)[u], satisfies the coherence condition to form an indexed category [59]. As we will see later, fibration and indexed category are equivalent concepts.

When a fibration p is regarded as a generalised category [8], the following definition gives the “opposite category ” of p [6].

Definition 4.2.9. Given a fibration p: E ^{}B, the opposite fibration of p, written p^{(op)}: E^{(op)} ^{}B, is defined as follows. The category E^{(op)} has the same objects as E. Given X, Y ∈ E, consider the set of pairs of morphisms (X ^{}\begin{matrix}f \\ (id) \end{matrix} Y′ +^{c}^{}Y) with f vertical and c cartesian. Define the equivalence relation on this set by

(X ^{}\begin{matrix}f \\ (id) \end{matrix} Y′ +^{c}^{}Y) ∼ (X ^{}\begin{matrix}g \\ (id) \end{matrix} Y′′ +^{d}^{}Y)

⇔

∃ i: Y′ ≅ ; (id)^{}Y′′.

Y′
[figure: f; (id); ×; c]
X  Y
[figure: g; (id); ×; d]
Y′′ \begin{aligned}i_{≅} &  \\ & (id) \end{aligned}  commutes

A morphism of E^{(op)} from X to Y is such an equivalence class of pairs of morphisms. Given two E^{(op)} morphisms [(f, c)]: Y ^{}Z and [(g, d)]: X ^{}Y where (f, c) and (g, d) are representatives for respective equivalence classes, the composition [(f, c)] ∘ [(g, d)]: X ^{}Z is the equivalence class given by (gf′, cc′):

X

[figure: Y′; g; \begin{matrix}d \\ + \end{matrix}] Y
[figure: Z′′; f′; \begin{matrix}c′ \\ + \end{matrix} ; (pd); Z′; f; \begin{matrix}c \\ + \end{matrix}; Z,]

where c′ is any cartesian morphism over pd and f′ is the unique vertical morphism that makes the square commutes. It is easy to check that the choice of (f, c), (g, d), and c′ does not affect the equivalence class [(gf′, cc′)]. The fibration p^{(op)} sends X to pX and [(f, c)] to pc.

Fibrewise, one has (E^{(op)})_{I} ≅ (E_{I})^{op}.

4.3 Examples of fibrations

Family fibration

An intuition behind the definition of fibrations is to abstract the situation where a category, or its object, is parameterized by objects of another category. The most basic example in this regard is given as follows.

Definition 4.3.1. Let C be a category.

• The category Fam(C) of families of objects of C is given by Objects Families (X_{i})_{i∈I} (X_{i} ∈ C, I ∈ Set) of objects of C. Morphisms Fam(C)((Y_{j})_{j∈J}, (X_{i})_{i∈I}) = {(u, f) | u: J ^{}I, f = (f_{j}: Y_{j} ^{}X_{uj})_{j∈J}}. Composition

{(v, g): (Z_{k})_{k∈K} ^{}(Y_{j})_{j∈J} (u, f): (Y_{j})_{j∈J} ^{}(X_{i})_{i∈I} \atop (u, f) ∘ (v, g) ≡ (uv, (f_{vk}g_{k})_{k∈K}): (Z_{k})_{k∈K} ^{}(X_{i})_{i∈I}}

• The split fibration p_{C}: Fam(C) ^{}Set sends (u, f): (Y_{j})_{j∈J} ^{}(X_{i})_{i∈I} to u: J ^{}I. For ((X_{i})_{i∈I}, u: J ^{}I), the canonical splitting is given by

û(X) = (u, (id_{X_{uj}})_{j∈J}): (X_{uj})_{j} ^{}(X_{i})_{i∈I}.

So, a cartesian morphism of p_{C} over u gives re-indexing of families along u. The inverse of E_{u}(Z, û(X)) required in Definition 4.2.1 is trivially given by

{Z \begin{matrix}(uv,(f_{uv(k)})_{k∈pZ}) \\ (uv) \end{matrix}^{}X \atop Z \begin{matrix}(v,(f_{uv(k)})_{k∈pZ}) \\ (v) \end{matrix}^{}X[u].} ≅

The fibre Fam(C)_{I} over I ∈ Set is isomorphic to C^{I}, i.e., C parameterised by the set I.

Codomain fibrations

There is a trivial bijection between I-indexed families of disjoint sets and maps from some set J into I. Generalizing this, one may regard a morphism J ^{}I in a category as a family of object indexed by I.

Definition 4.3.2. Given a category B with pullbacks, the codomain fibration cod: B^{2} ^{}B sends an object f: X ^{}I to I and a morphism (u, h) from f: X ^{}I to g: Y ^{}J to u. The cartesian morphisms are pullback squares.

The composition with the pullback square

[figure: Y; X; J; u; I]

has the inverse mapping (uv, f) ↦ (v, f̄), as required in Definition 4.2.1

[figure: Z; f; X; K; x; v; J; u; I; Z; f̄; Y; X; K; x; v; J; u; I]≅

where f̄: Z ^{}Y is the unique morphism determined by f and vx. The fibre B_{I} over I ∈ B is the slice category B/I.

Domain fibrations

The following fibration plays an important role in conjunction with the change of base operation defined later.

Definition 4.3.3. Given a category B and an object I in B, the split fibration Y_{I}: B/I ^{}B sends an object f: J ^{}I to J and a morphisms h: J ^{}K from f: J ^{}I to g: K ^{}I to h. the canonical splitting for (f: J ^{}I, u: K ^{}J) is given by f[u] = fu and û(f) = u: (fu) ^{}f ∈ B/I.

4.4 Indexed categories

Indexed categories [59] provide an alternative formulation of fibrations. We give the definition and the Grothendieck construction of a fibration from an indexed category. In some applications, indexed categories are more intuitive than fibrations; for a computer science application, see e.g. [85]. But technically they are less convenient than fibrations. A detailed comparison of the two concepts can be found in [8].

Definition 4.4.1. Given a category B, an indexed category S with the base B is given by the data

• for each I ∈ B, a category S_{I}.

• for each u: J ^{}I in B, a functor u^{∗}: S_{I} ^{}S_{J},

• for each I ∈ B, a natural isomorphism γ_{I}: id_{S_{I}} ≅ id_{I}^{∗}

• for each composable pair u: J ^{}I and v: K ^{}J, a natural isomorphism δ_{u,v}: v^{∗}u^{∗} ≅ (uv)^{∗}].

satisfying the conditions

• for any u: J ^{}I, δ_{u,id_{J}} ∘ γ_{J}u^{∗} = id_{u^{∗}} and δ_{id_{I},u} ∘ u^{∗}γ_{I} = id_{u}^{∗}.

• for any u: J ^{}I, v: K ^{}J, and w: L ^{}K, δ_{uv,w}∘w^{∗}δ_{u,v} = δ_{u,vw}∘u^{∗}δ_{v,w}.

Note that a functor S: B^{op} ^{}Cat is an indexed category with all γ_{I} and δ_{u,v} being identity. In fact, indexed categories are exactly pseudo functors [27] from B^{op} to Cat.

Any cloven fibration p: E ^{}B gives rise to an indexed category with the data I ↦ E_{I}, u ↦ (−)[u], and natural isomorphisms given by the universality of each X[u] with X ∈ E_{I} and u: J ^{}I. We write this indexed fibration as F(p).

Conversely, given an indexed category S, one can construct a cloven fibration.

Definition 4.4.2. (Grothendieck construction)

Given an indexed category S, the Grothendieck category G(S) of S is defined by

• an object of G(S) is a pair (I ∈ B, X ∈ S_{I}).

• a morphism of G(S) from (J, Y) to (I, X) is a pair (u, f) with u: J ^{}I in B and f: Y ^{}u^{∗}X in S_{J}.

• the composition of (u, f): (J, Y) ^{}(I, X) and (v, g): (K, Z) ^{}(J, Y) is given by (uv, δ_{u,v} ∘ v^{∗}f ∘ g).

• the identity on (I, X) is (id_{I}, γ_{I,X}).

It is straightforward to check the following.

Proposition 4.4.3. The functor p_{S}: G(S) ^{}B given by the first projections for both objects and morphisms is a cloven fibration. The cleavage for ((I, X), u) with u: J ^{}I and (I, X) ∈ G(S)_{I} is given by the morphism (u, id_{u^{∗}X}).

Particularly, if all γ_{I}, δ_{u,v} are identity, i.e., if S is a mere functor from B^{op} to Cat, then the fibration p_{S} has a splitting.

Further, it is also straightforward to check that F and G are mutually inverse constructions, i.e., for any indexed category S, F(G(S)) is isomorphic to S, and for any cloven fibration p: E ^{}B p_{F(p)}: G(F(p)) ^{}B is isormophic to p. But to make this precise, one needs to define the 2-category of fibrations.

4.5 2-category Fib

We define the 2-category Fib of fibrations and the sub 2-category Fib(B) of fibrations with the base B. Then we define products and exponentials of fibrations in Fib(B). The latter is applied to show that every cloven fibration is equivalent to a split fibration.

Definition 4.5.1. • Given two fibrations p: E ^{}B and q: F ^{}C, a fibred 1-cell from p to q is a pair (F: B ^{}C, G: E ^{}F) of functors such that the diagram

[figure: E; G; F; B; p; F; C; q]

commutes and moreover, for every cartesian morphism f in E, Gf is cartesian in F over F pf. If p and q are cloven (split), (F, G) is called cleavage preserving (splitting preserving, respectively) if G sends the chosen cartesian morphism for (X ∈ E_{I}, u: J ^{}I) in E to that for (GX, F u) in F.

• Given two fibred 1-cells (F, G) and (K, L) from a fibration p to q, a fibred 2-cell from (F, G) to (K, L) is a pair (s: F ^{}K, t: G ^{}L) of natural transformations such that, for every X ∈ E, qt_{X} = s_{X}p.

[figure: E; G; ⇓ t; L; F; B; p; F; ⇓ s; K; C; q]

• The 2-category Fib has as objects fibrations, as 1-cells fibred 1-cells, and as 2-cells fibred 2-cells. The composition is given componentwise using that of Cat. The subcategory Fib_{s} of Fib has as objects split fibrations, as morphisms splitting preserving fibred 1-cells, and as 2-cells fibred 2-cells. For each B in Cat, the subcategory Fib(B) of Fib has as objects fibrations with the base B, as morphisms fibred 1-cells with their first component being id_{B}, as 2-cells fibred 2-cells with their first component id_{id_{B}}. A fibred 1-cells in Fib(B) is also called a cartesian functor.

Pulling back a fibration along a functor, one obtains another fibration.

Proposition 4.5.2. Given a fibration p: E ^{}B and a functor F: C ^{}B, let the change of base diagram be the following pullback in Cat.

[figure: F^{∗}(E); E; C; F^{∗}p; F; B; p]

Then, F^{∗}p is a fibration.

Proof Given (C, X) ∈ F^{∗}(E)_{C}, i.e., (C, X) with F C = pX, let u: D ^{}C be a morphism in C and c: Y +_{(F u)}^{}X a cartesian morphism with respect to p. Then, a F^{∗}p-cartesian morphism over u with codomain (C, X) is given by (u, c): (D, Y) ^{}(C, X).

This extends to the change of base 2-functor F^{∗}(−): Fib(B) ^{}Fib(C) [37, 34].

When F is also a fibration, one has the following.

Proposition 4.5.3. Given two fibrations p: E ^{}B and q: F ^{}B, a product p × q of p and q in Fib(B) is given by the pullback diagram

E ×_{B} F

[figure: p^{∗}q; q^{∗}p]
E  F
[figure: p; q]
B. p × q_{}

Proof The functor p × q is a fibration since p^{∗}q is a fibration and the composition of two fibrations is again a fibration. It is also obviously a product of p and q in Cat/B, i.e., (Cat/B)(r, p × q) ≅ (Cat/B)(r, p) × (Cat/B)(r, q). One can check that this restricts to Fib(B)(r, p × q) ≅ Fib(B)(r, p) × Fib(B)(r, q) when r is a fibration.

The product is fibrewise in the sense that, for I ∈ B, (E ×_{B} F)_{I} ≅ E_{I} × F_{I}.

The 2-category Fib(B) also has the terminal object id_{B}.

The exponentials are defined with the aid of a fibred version of Yoneda lemma.

Lemma 4.5.4. (Yoneda lemma)

Given a cloven fibration p: E ^{}B and I ∈ B, Fib(B)(Y_{I}, p) ≃ E_{I}.

Proof The equivalence is given, in the forward direction, F ∈ Fib(B)(Y_{I}, p) ↦ F_{I}(id_{I}) ∈ E_{I} and t: F ^{}G ↦ t_{I}(id_{I}). In the reverse direction, let X ∈ E_{I}. Let F_{X}: Y_{I} ^{}p to be a functor that sends f ∈ B/I to X[f], and h: f ^{}g in B/I to the unique morphism F_{X}h over h that makes the diagram

X[f]  \begin{matrix}F_{X}h \\ (h) \end{matrix}  ^{}X[g]
[figure: ×; ×]
X

commutes. Any morphism h of B/I is cartesian, but F (h) is cartesian by Lemma 4.2.5, so F_{X} is a cartesian functor. One can similarly define, for each k: X ^{}Y, a natural transformation from F_{X} to F_{Y}. The verification of the equivalence is straightforward.

Given u: I ^{}J, define a cartesian functor Y_{u}: Y_{I} ^{}Y_{J} in Fib(B) by u ∘ (−).

Definition 4.5.5. Given two fibrations p: E ^{}B and q: F ^{}B, the exponential fibration q^{p} in Fib(B) is given by the Grothendieck construction on the functor Fib(B)(Y_{−} × p, q) from B^{op} to Cat that sends I to the category Fib(B)(Y_{I} × p, q) and u: I ^{}J to the functor

Fib(B)(Y_{u} × p, q): Fib(B)(Y_{J} × p, q) ^{}Fib(B)(Y_{I} × p, q).

In [15], q^{p} is shown to have the universal property

Fib(B)(r, q^{p}) ≃ Fib(B)(r × p, q).

The proof is somewhat involved, but in the special case where r = Y_{I}, one can easily see that

Fib(B)(Y_{I}, q^{p}) ≅ (q^{p})^{−1}(I) = Fib(B)(Y_{I} × p, q).

Note that Fib(B)(Y_{−} × p, q) is a functor, not just a pseudo functor, so q^{p} has a splitting. By taking p to be the terminal object of Fib(B), i.e., id_{B}, one has

Proposition 4.5.6. Every cloven fibration p is equivalent to a split fibration p^{id^{B}}.

4.6 Local smallness

In this section, we study local smallness [15,6] of fibrations. With a locally small fibration p, one can form an object in the base category B that plays a role of a Hom-set for an ordinary category. This allows one to internalise various concepts on p in B, generalising the relationship between an ordinary category and the category Set of sets [8]. More interestingly to computer scientists, local smallness provides the key connection between type theory and fibrations. We will see this in detail in Chapter 5 and 6.

Definition 4.6.1. Given a fibration p: E ^{}B, the groupoid fibration p_{gpd}: E_{gpd} ^{}B is a restriction of p to the subcategory E_{gpd} given by all cartesian morphisms of E.

Each fibre (E_{gpd})_{I} is a groupoid, i.e., every morphism in a fibre (E_{gpd})_{I} is an isomorphism.

Definition 4.6.2. Given a fibration p: E ^{}B and a pair of objects A ∈ E_{I} and B ∈ E_{J}, define the functor H_{AB}: E_{gpd}^{op} ^{}Set by

H_{AB}: E_{gpd}^{op}  \overline{}Set
X  \{ (c, g)| [figure: A; \underline{\begin{matrix}c \\ + \end{matrix}}; X; g; B]\}
↦
Y^{f +}  \{ (c′, g′)| [figure: A; \underline{\begin{matrix}c′ \\ + \end{matrix}}; Y; g′; B]\}.^{^{}(c, g) ↦ (cf, gf)}

We say p is locally small at (A, B) if H_{AB} is representable; p is locally small if p is so at every (A, B).

The chosen counit of a representation for H_{AB} is denoted by

[figure: A; \underline{+}; A′; χ_{AB}; B]

p
[figure: I; d_{0,AB}; Hom(A, B); d_{1,AB}; J]

usually suppressing the suffix AB. The morphisms d_{0} and d_{1} are called Homprojections. The definition amounts to require, for each (u, f) below, the unique existence of a cartesian morphism f̄ that makes the following commute.

A

[figure: ×; (u); ×; (d_{0})]
A′′  f̄ ; +  ^{}A′
[figure: f; χ; (d_{1})]
B

Proposition 4.6.3. Given a locally small fibration p: E ^{}B with finitely complete B and A ∈ E, one can extend the assignment (A, B) ↦ Hom(A, B) to a fibred 1-cell

Hom(A, −): p \overline{}cod
E  \overline{Hom(A, −) ^{}}B^{2}
[figure: B; p; I × (−); B; cod]

Proof The functor Hom(A, −) sends B ∈ E_{J} to Hom(A, B) ^{⟨d_{0,AB},d_{1,AB}⟩}^{}I × J, and B ^{f}^{}C over J ^{u}^{}K to

Hom(A, B) \overline{Hom(A, f)_{}}Hom(A, C)
[figure: I × J; ⟨d_{0,AB}, d_{1,AB}⟩; I × u] I × K^{⟨d_{0,AC}, d_{1,AC}⟩^{}}

where Hom(A, f) is the morphism which underlies the unique cartesian morphism f′ below.

A′  \begin{matrix}f′ \\ + \end{matrix}  ^{}A′′
[figure: ×; (d_{0,AB}); ×; (d_{0,AC})]
A
[figure: B; χ_{AB}; f; C; χ_{AC}]

It remains to show that Hom(A, −) sends a cartesian morphism f in E to a cartesian morphism in B^{2}, i.e., a pullback square. Suppose f: B ^{}C is cartesian. Then, we have, for any ⟨v, w⟩: L ^{}I × J,

B/I × J(⟨v, w⟩, ⟨d_{0,AB}, d_{1,AB}⟩) ≅ \{(c, h)|A ^{}+^{c}_{(v)} · \begin{matrix}h \\ (w) \end{matrix}^{}B\}

≅ \{(c, k)|A ^{}+^{c}_{(v)} · \begin{matrix}k \\ (uw) \end{matrix}^{}C\} ; by (c, h) ↦ (c, fh)

≅ B/I × K((I × u)⟨v, w⟩, ⟨d_{0,AC}, d_{1,AC}⟩),

which shows that ⟨d_{0,AB}, d_{1,AB}⟩ is a pullback of ⟨d_{0,AC}, d_{1,AC}⟩ along (I × u).

For a morphism f, to say that Hom(A, f) gives the above pullback square is an internal way to say that f is cartesian.

Dually, the (contravariant) fibred 1-cell

Hom(−, A): p^{(op)}  \overline{}cod
E^{(op)}  \overline{Hom(−, A) ^{}}B^{2}
[figure: B; p^{(op)}; (−) × I; B; cod]

sends B ∈ E_{J} to ⟨d_{0,BA}, d_{1,BA}⟩: Hom(B, A) ^{}J × I, and [(f, c)]: C ^{}B in

E^{(op)} over u: K ^{}J, i.e., C ^{}\begin{matrix}f \\ (id) \end{matrix} · +^{c}_{(u)}^{}B to

Hom(C, A) \overline{Hom([(f, c)], A)_{}}Hom(B, A)
[figure: K × I; ⟨d_{0,CA}, d_{1,CA}⟩; u × I] J × I^{⟨d_{0,BA}, d_{1,BA}⟩^{}}

where Hom([(f, c)], A) underlies the unique h determined by any representative of the equivalence class [(f, c)] ∘ [(χ_{CA}, d)], i.e., the morphism h that corresponds to (cd′, χ_{CA}f′) below by the universality of (d_{0,BA}, χ_{BA}).

·  \begin{matrix}h \\ + \end{matrix}  ^{}A′
[figure: f′; ×; d′; (d_{0,CA}); ×; (d_{0,BA})]
A′′  ·
[figure: ×; d; (d_{0,CA}); f; ×; c; (u)]
C  B

[figure: A; χ_{CA}; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =; A; χ_{BA}]

When p is cloven and B has binary products, the local smallness of p: E ^{}B at (A ∈ E_{I}, B ∈ E_{J}) can be expressed by the representability of the functor H′_{AB}: (B/I × J)^{op} ^{}Set that sends ⟨u, v⟩: K ^{}I × J to E_{K}(A[u], B[v]) and w: ⟨u, v⟩ ^{}⟨k, l⟩ to the function f ↦ f[w]. The representing object is ⟨d_{0,AB}, d_{1,AB}⟩: Hom(A, B) ^{}I × J and the counit χ̄_{A,B}: A[d_{0}] ^{}B[d_{1}] in E_{Hom(A,B)} is the vertical factor of χ_{AB}: A′ _{(d_{1})}^{}B.

Example 4.6.4. When p = p_{C}: Fam(C) ^{}Set, p_{C} is locally small if and only if C is locally small in the usual sense. With the counit

A[d_{0}]

[figure: ×; χ ≡ (d_{1}, (f: A_{i} → B_{j})_{(i,j,f)})]
A  B

Hom(A, B) ≡ {(i, j, f) | f: A_{i} → B_{j}}^{^{}p_{C}}
[figure: d_{0} ≡ ((i, j, f) ↦ i); d_{1} ≡ ((i, j, f) ↦ j)]
I  J,

the natural bijection E_{K}(A[u], B[v]) ≅ B/(I × J)(⟨u, v⟩, ⟨d_{1}, d_{0}⟩) is given by

(A[u] ^{(id_{K},(f_{k}:A_{uk}→B_{vk})_{k})}^{}B[v]) ↦ \binom{K  \overline{}Hom(A, B)}{k  ↦ (uk, vk, f_{k})} .

Note that the morphism ⟨d_{0}, d_{1}⟩: Hom(A, B) ^{}I × J corresponds to the family (C(A_{i}, B_{j}))_{i∈I,j∈J}.

The following “fibrewise” version of local smallness is equivalent to the above definition when B is finitely complete [78].

Definition 4.6.5. For A, B ∈ E_{I}, p is fibrewise locally small at (A, B) over I if the functor

H_{I,AB}: E_{gpd}^{op}  \overline{}Set
X  \{ (c, g)| [figure: A; \underline{\begin{matrix}c \\ + \end{matrix} ; (u)}; X; \begin{matrix}g \\ (u) \end{matrix}; B]\}
↦
Y^{f +}  \{ (c′, g′)| [figure: A; \underline{\begin{matrix}c′ \\ + \end{matrix} ; (u′)}; Y; \begin{matrix}g′ \\ (u′) \end{matrix}; B]\}.^{^{}(c, g) ↦ (cf, gf)}

is representable.

The chosen counit of a representation for H_{I,AB} is denoted by

[figure: A; \underline{+}; A′; χ′_{I,AB}; B]

p
[figure: I; d_{I,AB}; Hom_{I}(A, B); d_{I,AB}; J]

Proposition 4.6.6. Given a fibration p: E ^{}B with B finitely complete, p is fibrewise locally small if and only if p is locally small.

Proof For the forward direction, given A ∈ E_{I} and B ∈ E_{J}, let A′ +_{(π_{0,IJ})}^{}A and B′ +_{(π_{1,IJ})}^{}B be cartesian morphisms over π_{0,IJ}: I × J ^{}I and π_{1,IJ}: I × J ^{}J, respectively. Then, the counit of a representation of H_{AB} is given by

A ^{}+_{(π_{0})} A′ ^{}+^{c}_{(d_{I×J,A′B′})} A′′ ^{χ_{I×J,A′B′}}^{}B′ +_{(π_{1})}^{}B,

where (c, χ_{I×J,A′B′}) is the counit of a representation of H′_{I×J,A′B′}. For the reverse direction, given A, B ∈ E_{I}, the counit of a representation H′_{I,AB} is given by

A ^{}+^{d}_{(d_{0,AB})} A′ ^{}+^{c}_{(e)} A′′ +^{c}_{(e)}^{}A′ \begin{matrix}χ_{AB} \\ (d_{1,AB}) \end{matrix}^{}B,

where (d, χ_{AB}) is the counit of a representation of H_{AB} and c is any cartesian morphism over the equalizer e of Hom(A, B) [figure: d_{0,AB}; d_{1,AB}] I in B.

Analogous to the previous global definition, when p is cloven, d_{I,AB} represents the functor H′_{I,AB}: (B/I)^{op} ^{}Set that sends u: K ^{}I to E_{K}(A[u], B[u]) and w: u ^{}v to a function f ↦ f[w]. This gives a natural bijection B/I(u, d_{I,AB}) ≅ E_{K}(A[u], B[u]) whose counit χ_{I,AB}: A[u] ^{}B[u] is the vertical factor of χ′_{I,AB} above.

Further, one can equationally characterise the universality of d_{I,AB} as follows. This provides the basis for our presentation of a locally small fibration as a type theory in Chapter 5. Let ≺u, −≻: E_{K}(A[u], B[u]) ^{}B/I(u, d_{I,AB}) be a function. Then the three equations

d_{I,AB}≺u, f≻ = u,

χ_{I,AB}[≺u, f≻] = f,
≺uw, f[w]≻ = ≺u, f≻w (w: L ^{}K)

express the natural bijection in the previous paragraph. These three equations make it clear that a Hom-object is similar to a disjoint sum, equipped with a first projection, a second projection, and a surjective dependent pairing; cf. Remark 4.1.9 of Jacobs’ thesis [37] on encoded “disjoint sums” for comprehension categories.

The following lemma has an application in modelling dependent sum types and dependent coproduct types in type theory, see Section 4.8 and Chapter 5 and 6.

Proposition 4.6.7. Given a fibrewise locally small fibration p: E ^{}B, u: J ^{}I in B and A, B ∈ E_{I}, the following square in B is a pullback diagram.

[figure: Hom_{J}(A[u], B[u]); ≺ud_{J,A[u]B[u]}, χ_{J,A[u]B[u]}≻; Hom_{I}(A, B); J; d_{J,A[u]B[u]}; u; I; d_{I,AB}]

Proof The top morphism underlies the unique cartesian morphism h that makes the following commutes.

[figure: A[u]; +; A; ·; +; (d_{J,A[u]B[u]}); \begin{matrix}h \\ + \end{matrix}; ·; (d_{(I,AB)}); +; B[u]; χ_{J,A[u]B[u]}; +; B; χ_{I,AB}]

The proof is similar to that of Proposition 4.6.3.

This shows that the class of those morphisms isomorphic to d_{I,AB} for some I ∈ B and A, B ∈ E_{I} satisfies the stability condition of display maps [86,36], i.e., they are closed under pulling back along arbitrary morphisms.

When p has a fibred terminal object 1_{p} ∈ E_{1}, (see Section 4.7), for any X ∈ E_{I}, the fibrewise Hom-projection d_{I,1_{p}[!_{I}]X}: Hom_{I}(1_{p}[!_{I}], X) ^{}I is isomorphic to (global) Hom-projections ⟨d_{0,1_{p}X}, d_{1,1_{p}X}⟩: Hom(1_{p}, X) ^{}1 × I. Under this isomorphism, the top morphism of the above diagram corresponds to Hom(1_{p}, û(X)): Hom(1_{p}, X[u]) ^{}Hom(1_{p}, X). So, in this case, Proposition 4.6.7 is an instance of Proposition 4.6.3. This also shows that a fibration with a fibred terminal that is locally small at (1, X) for every X ∈ E gives rise to a comprehension category [37] Hom(1, −). For more on locally small fibrations and comprehension categories, see Section 4.5 of ibid.

Example 4.6.8. When p = cod: B^{2} ^{}B, p is fibrewise locally small if and only if B is locally cartesian closed [15]. For brevity, assume B has chosen pullbacks, i.e., p is cloven. Then, for g, h in B/I, and u: J ^{}I, the natural bijection B/I(u, d_{I,fg}) ≅ B/J(f[u], g[u]) gives that d_{I,gh} satisfies the same universality in B/I as h^{g}.

\begin{matrix}{u ^{}d_{I,gh} \atop g[u] ^{}h[u] ∈ B/J} & ≅ \\ u(g[u]) ^{}h ∈ B/I \end{matrix} ; ≅ ; u × g ^{}h ∈ B/I ; ≅

4.7 Fibred limits and fibred ccc

Fibred version of the limit concept is defined by that for the ordinary category and the concept of limit preservation. So, the analysis of Chapter 2 applies.

Definition 4.7.1. Given a fibration p: E ^{}B and a functor F: I ^{}E with a small I, a fibred limit of D in p is a limit of F in E that is preserved by p.

In the rest of this section, we spell out this definition for terminal objects and binary products and give several equivalent formulations of them. These equivalent formulations can be generalised for any fibred limit. For 2-categorical treatment of fibred limits, see [34].

4.7.1 Terminal

A fibred terminal object 1_{p} (the subscript is often omitted) of p is a terminal object of E such that p(1_{p}) is a terminal object of B.

Fibrewise, this is equivalent to the following.

Lemma 4.7.2. Given a fibration p: E ^{}B, p has a fibred terminal object if and only if each fibre has a terminal object preserved by the substitution functors.

Proof If X +^{c}^{}1_{p} then c is necessarily over the unique pX ^{!}^{}p1_{p} and

E_{pX}(Y, X) ≅ E_{!}(Y, 1_{p}) ≅ {∗}.

Using Hom(−, −), one can internalise the definition.

Lemma 4.7.3. An object T ∈ E is a fibred terminal object if and only if, for any X ∈ E_{I}, p is locally small at (X, T) and d_{0,XT}: Hom(X, T) ^{}I × pT is an isomorphism natural in X; i.e., for any f: X ^{}Y in E^{(op)}, d_{0,XT} Hom(f, T) = d_{0,Y T}.

Proof By the definition of Hom(X, T).

Example 4.7.4. When p = p_{C}: Fam(C) ^{}Set, p has a fibred terminal object if and only if C has a terminal object. When p = cod: B^{2} ^{}B, p has a fibred terminal object if and only if B has a terminal object.

4.7.2 Binary products

Given two objects A ∈ E_{I} and B ∈ E_{J}, a fibred binary product of A and B is given by a product diagram

A ^{}^{π_{0}} A × B ^{π_{1}}^{}B

in E such that I ^{}^{pπ_{0}} p(A × B) ^{pπ_{1}}^{}J is a product diagram in B.

Example 4.7.5. When p = p_{C}: Fam(C) ^{}Set, p has fibred binary products if and only if C has binary products.

Proposition 4.7.6. Given A ∈ E_{I} and B ∈ E_{J}, an object P of E_{K} is a fibred product of A and B if and only if K is a product of I and J and there is a natural bijection

E_{u}(X, P) ≅ E_{π_{0}u}(X, A) × E_{π_{1}u}(X, B).

where I ^{}^{π_{0}} K ^{π_{1}}^{}J is a product diagram in B.

Proof The necessity is obvious. To see this is sufficient, note that there is a natural bijection

E(X, P) ≅ ∐_{u:L  K} E_{u}(X, P)

≅ ∐_{u}(E_{π_{0}u}(X, A) × E_{π_{1}u}(X, B))

≅ ∐_{v:L I,w:L J}(E_{v}(X, A) × E_{w}(X, B))

≅ E(X, A) × E(X, B)

and that its counit is over (π_{0}, π_{1}).

When p is a locally small fibration, one have the following internal version.

Proposition 4.7.7. Let p: E ^{}B be a locally small fibration with B having finite limits. Given A ∈ E_{I} and B ∈ E_{J}, for each X ∈ E_{K}, consider the following pullback in B.

V_{X}  \overline{π_{0X} ^{}}Hom(X, A)
[figure] d_{0,XA} × d_{0,XB} [figure]
[figure: Hom(X, B); π_{1X}; d_{0,XB}; K; d_{0,XA}]

Also, for each f: X ^{}Y in E^{(op)}, let V_{f}: V_{X} ^{}V_{Y} be the morphism determined by (Hom(f, A)π_{0X}, Hom(f, B)π_{1X}) and the universality of V_{Y}. Then, P ∈ E_{I×J} is a fibred binary product of A and B if and only if, for all X ∈ E_{K},

[figure: V_{X}; ⟨d_{1,XA}π_{1X}, d_{1,XB}π_{0X}⟩; I × J; K; d_{0,XA} × d_{0,XB}]

exhibits V_{X} as Hom(X, P) and V_{f} as Hom(f, P).

Proof Again, by unwinding the definition of Hom(−, −), it is straightforward to see that this is equivalent to the formulation given in Proposition 4.7.6.

The fibrewise version of binary product is defined below and is equivalent to the original global definition.

Definition 4.7.8. Given A, B ∈ E_{I}, P ∈ E_{I} is a fibrewise binary product, written A ×_{I} B, of A and B if there is a natural bijection

E_{u}(X, P) ≅ E_{u}(X, A) × E_{u}(X, B).

For a fibrewise locally small fibration, this can be internally expressed by:

Proposition 4.7.9. Given a fibrewise locally small fibration p: E ^{}B, P ∈ E_{I} is a fibrewise binary product of A and B in E_{I} if and only if, for any X ∈ E_{I}, d_{I,XP} ≅ d_{I,XA} × d_{I,XB} in B/I and natural in X in the obvious sense.

With the substitution functors, one has

Lemma 4.7.10. Given a cloven fibration p: E ^{}B and A, B ∈ E_{I}, P ∈ E_{I} is a fibrewise binary product of A and B if and only if P is a product of them in E_{I} preserved by any substitution functor.

Proof For u: J ^{}I and X ∈ E_{J}, there is a natural bijection

E_{u}(X, P) ≅ E(X, P [u])

≅ E(X, A[u]) × E(X, B[u])
≅ E_{u}(X, A) × E_{u}(X, B)

The equivalence of the global and fibrewise definitions can be seen as follows.

Lemma 4.7.11. Given a fibration p: E ^{}B with B having binary products, p has all fibred binary product if and only if p has all fibrewise binary products.

Proof For the forward direction, a fibrewise binary product of A, B ∈ E_{I} is given by (A × B)[⟨id_{A}, id_{A}⟩]. For the reverse direction, a fibred product of A ∈ E_{I} and B ∈ E_{J} is given by A[π_{0,IJ}] ×_{I×J} B[π_{1,IJ}].

The forward direction of the above proof is a special case of the following, where fibrewise binary products arise from fibred binary products.

Lemma 4.7.12. Consider the following diagram

[figure: A′; (id_{K}); P′; (id_{K}); B′; A; (u); +; \begin{matrix}π \\ (π) \end{matrix}; P; (⟨u, v⟩); +; \begin{matrix}π′ \\ (π′) \end{matrix}; B; +; (v)]

where K ∈ B and A ^{}P ^{}B is a fibred product diagram over I ^{}^{π} I × J ^{π′}^{}J. Then, [figure: A′; (id_{K}); P′; (id_{K}); B′]is a fibrewise product diagram.

Proof

E_{w}(X, P′) ≅ E_{⟨u,v⟩w}(X, P)
≅ E_{π⟨u,v⟩w}(X, A) × E_{π′⟨u,v⟩w}(X, B)
≅ E_{uw}(X, A) × E_{vw}(X, B)
≅ E_{w}(X, A′) × E_{w}(X, B′).

4.7.3 Exponentials

A fibred cartesian closed categories is defined here in terms of each fibre. For a global version, see Hermida’s thesis [34]. In Chapter 7, we see a concrete example of fibred ccc, deliverables.

Definition 4.7.13. Given a fibration p: E ^{}B be with fibred / fibrewise binary products, p is a fibred cartesian closed category if each fibre is cartesian closed and if the substitution functors preserve cartesian closure.

Example 4.7.14. Given a category C, the family fibration p_{C} is a fibred ccc if and only if C is a ccc.

4.8 B-coproducts and B-products

Given a fibration, one can define coproducts and products of objects in the total category indexed by objects of the base. They are called B-coproducts and Bproducts [15]. They are of interest in computer science since a modified version of them are used to model dependent sum types and dependent product types in type theory, see Chapter 5 and 6 for the detail.

Definition 4.8.1. A cofibration p: E ^{}B is a fibration p^{op}: E^{op} ^{}B^{op}. A morphism is called cocartesian if it is cartesian for p^{op}.

In other words, f: X ^{}Y is cocartesian if the composition (−) ∘ f restricts to, for each u: pY ^{}I and Z ∈ E_{I}, a bijection E_{u}(Y, Z) ≅ E_{u∘pf}(X, Z). We denote a cocartesian morphism over u by X ∘_{(u)}^{}Y.

Definition 4.8.2. Given a fibration p: E ^{}B, p has B-coproducts if it is a cofibration such that, for any X ∈ E_{J} and any pullback square in B,

[figure: L; v′; J; K; u′; v; I,; u]

the unique morphism f determined by any cartesian morphisms over v and v′ and any cocartesian morphism over u, is cocartesian over u′.

[figure: X_{1}; \begin{matrix}+ \\ (v′) \end{matrix}; X; X_{2}; f; (u′); \begin{matrix}+ \\ (v) \end{matrix}; X_{0}; (u); ∘]

The condition in the definition is called the Beck-Chevalley condition.

Example 4.8.3. For p = p_{C}: Fam(C) ^{}Set, p has B-coproducts if and only if C has (small) coproducts.

When p is cloven, one can give a fibrewise formulation of this. Let us say p is cocloven if it is equipped with a choice, for each (X, u: J ^{}I) with X ∈ E_{J}, of a cocartesian morphism X ∘_{(u)}^{}X′.

Proposition 4.8.4. Given a cloven fibration p: E ^{}B, p is cocloven and has B-coproduct if and only if

• for any u: J ^{}I, the substitution functor (−)[u]: E_{I} ^{}E_{J} has a left adjoint Σ_{u}: E_{J} ^{}E_{I}, and • for any X ∈ E_{J} and any pullback square

[figure: L; v′; J; K; u′; v; I,; u]

the morphism Σ_{u′}(X[v′]) _{(id)}^{}(Σ_{u}X)[v] given by

{X \begin{matrix}η_{X} \\ (id) \end{matrix}^{}(Σ_{u}X)[u] \atop X[v′] _{(id)}^{}(Σ_{u}X)[uv′]} ; f ↦ f[v′]

X[v′] _{(id)}^{}(Σ_{u}X)[vu′] ≅

Σ_{u′}(X[v′]) _{(id)}^{}(Σ_{u}X)[v] ≅

is an isomorphism (η is the unit of the adjunction Σ_{u} ⊣ (−)[u]).

Proof For the forward direction, define Σ_{u}X by the codomain X′ of the chosen cocartesian morphism c_{X}: X ∘_{(u)}^{}X′. One can extend this to a functor Σ_{u}: E_{I} ^{}E_{J} in the same way as the definition of substitution functors. Then, Σ_{u} is a left adjoint to (−)[u] as

{X _{(id)}^{}Y [u] \atop X _{(u)}^{}Y} ≅; f ↦ û(Y)f Σ_{u}X _{(id)}^{}Y ≅; the inv. of f ↦ fc^{X}

The second condition is equivalent to the Beck-Chevalley condition. For the reverse direction, given (X, u: J ^{}I) with X ∈ E_{J}, the morphism û(X)η_{X} from X to Σ_{u}X is cocartesian with the similar argument as the forward direction. Again, the Beck-Chevalley condition is equivalent to the second condition.

The object Σ_{u}X is said to be the coproduct of X along u.

The dual to B-coproducts are B-products.

Definition 4.8.5. Given a fibration p: E ^{}B, p has B-products if the opposite fibration p^{(op)}: E^{(op)} ^{}B has B-coproducts.

By the definition of p^{(op)}, this is equivalent to requiring the following.

• For every (X, u: I ^{}J) with X ∈ E_{J}, there is an object Π_{u}X ∈ E_{J} and a pair of morphisms X ^{}\begin{matrix}ε_{X} \\ (id) \end{matrix} · +^{c_{X}}_{(u)}^{}Π_{u}X.

• Given any v: J ^{}K and Z ∈ E_{K}, for each X ^{}\begin{matrix}f \\ (id) \end{matrix} · +^{a}_{(uv)}^{}Z, there exists,

unique up to the equivalence, a pair of morphisms Π_{u}X ^{}f̄ ; (id) · +^{ā}_{(v)}^{}Z that satisfies the following condition: the pair (f̄, ā) satisfies ε_{X}g = f, where g is determined by c_{X}g = f̄b and b, in turn, is determined by bā = a.

[figure: Z; \underline{ā ; + ; (v)}; ·; f̄ ; (id); Π_{u}X]
[figure: ×; b; (u)]
·^{(u)+}c_{X}
[figure: g; (id)]

[figure: W; a; +; (uv); \begin{matrix}f \\ (id) \end{matrix}] X \begin{aligned}(id) & \\ & ε_{X} \end{aligned}

• Given X ∈ E_{J} and any pullback diagram in B

[figure: L; v′; J; K; u′; v; I,; u]

the pair of morphisms (f, c) determined by any choice of the three horizontally drawn cartesian arrows has the same universal property as (ε_{Y} , c_{Y}) for (Y, u′).

·  \overline{\begin{matrix}+ \\ (v′) \end{matrix} ^{}}Π_{u}X

[figure: ·; c; +; (u′); \begin{matrix}+ \\ (v′) \end{matrix}] ·^{(u) +} c_{X}

[figure: Y; f; (id); \begin{matrix}+ \\ (v) \end{matrix}] X^{(id) ^{}}ε_{X}

We omit the dual to Proposition 4.8.4 as it is easy to see.

Example 4.8.6. The codomain fibration cod: B^{2} ^{}B has B-product if and only if B is locally cartesian closed.

In computer science applications, often not all (co)products along all base morphisms are needed, and requiring all of them is too strong a condition. When we restrict our attention to fibrewise locally small fibrations, those fibrations having (co)products along d_{I,AB}: Hom_{I}(A, B) ^{}I for some A, B ∈ E_{I} are of particular interest, since only those are needed to model dependent sum types and dependent product types. In this case, one can restrict pullbacks in the Beck-Chevelley condition to those pullbacks of Proposition 4.6.7. So, we define the following.

Definition 4.8.7. Given a fibrewise locally small fibration p: E ^{}B, p has products along Hom-projections if, given any two objects A and B in E_{I}, for any object X in E_{Hom_{I}(A,B)} there exists a cocartesian morphism X ∘_{(d_{I,AB})}^{}X′ over the projection d_{I,AB}: Hom_{I}(A, B) ^{}I and moreover if, for any u: J ^{}I, A, B ∈ E_{I}, the morphism f determined by the three other cartesian and cocartesian morphisms below, is cartesian.

[figure: X_{1}; \begin{matrix}+ \\ (≺ud_{J,A[u]B[u]}, χ_{J,A[u]B[u]}≻) \end{matrix}; X; X_{2}; f; (d_{J,A[u]B[u]}); \begin{matrix}+ \\ (u) \end{matrix}; X′; (d_{I,AB}); ∘]

A fibration p has products along Hom-projections if p^{(op)} has coproducts along Hom-projections.

Jacobs’ [37] gave a formulation of products and coproducts along a restricted class of morphisms in terms of comprehension categories, which is closely related to locally small fibrations; see the remark after Proposition 4.6.7, also see Jacobs’ thesis [37].

Type theory and fibrations 1

5.1 Introduction

In Chapter 1 and 2, we developed a methodology to treat universal structure on categories in a computer checked manner using a proof development system LEGO. The following chapters study a categorical framework for type theory. This is motivated by the fact that the most common application of categorical structure in computer science is to provide models for type theories. Also, it is often the case that categorical structure of our objects of studies, e.g., processes, becomes apparent via consideration of their type theory. By studying a categorical framework, we aim to raise availability of categorical methods for those who are more familiar with type theories. The methodology developed in the previous chapters can then be used to develop and formalise various application of type theory, as well as studies of type theory itself.

By a framework, we mean a uniform family of categorical structures that provide semantics for various type systems. This study of frameworks for semantics, rather than those for syntax á la Logical Framework [32,23], is proposed by Power; his papers [65,66] outline his program and give the references for the substantial development achieved so far. The framework chosen in his program is algebraic structure, or more generally, essentially algebraic structure on categories. From a different view point, Jacobs [37] classifies various type systems in terms of TS-settings and TS-features and then give their categorical counterparts as a way to organise categorical models for various type systems.

Our study differs from these in that we are interested not only in the semantics of a semantic framework, but also in its formalisation, including consideration for its syntax. Therefore, we provide syntax for categorical structures that model a general class of type systems and give, using the syntax, a detailed account of relationship between type systems and those structures. The syntax is presented as a type system that is directly derived from those structures. This allows us to give a detailed account of relationship between traditional type systems and these categorical structures.

There have been studies of categorical combinators which also provide syntax directly derived from categorical structure, e.g. Curien, Ritter et. al.’s Categorical Abstract Machines [18,19,70]. Hagino [30,29] studied Categorical Programming Language based on categorical structure of dialgebras. Cockett and Spencer [16, 17,75] advanced this with functorial strength in their work on CHARITY. Unlike these studies, which proposed alternative computation mechanisms , we do not give reduction rules for our syntax, but emphasise the detailed study of relationship with traditional type systems.

Formalisation of semantics of type theory within an ambient type theory has been studied by authors including McKinna and Pollack [53], Altenkirch [1], and Pollack [63]. The semantics used there is of an operational flavour.

In this chapter, we present a general class of four traditional type systems, and devise a new type system, T F, that provides syntax for locally small fibrations with particular extra structure. This provides the basis for the next chapter, where we establish the relationship between these four type systems and T F.

In Section 2, we define four type systems. Our terminology is that a type theory is specified by a type system together with sets of constants and axioms. We give detailed definitions to explain the complex interplay between well-formedness of expressions and derivability of judgement. We also define interpretations from a type theory to another, to form a category of type theories in Chapter 6.

Section 3 defines our type system, T F, that describes fibrewise locally small fibrations with a fibred terminal object, products and coproducts along Homprojections. The syntax of T F is directly derived from the categorical structure so that passing from the syntax to objects / morphisms of fibrations is trivial. As such, terms of T F have domain and codomain like morphisms; substitution is an explicit operation rather than a metatheoretic one; variables are replaced by generic terms, avoiding problems concerning variable names. Again, a notion of interpretations between T F -theories is defined.

A locally small fibration is an instance of categories with universal structure. However, it is not convenient to strictly apply our definition of universal structure in Chapter 2 in order to study the role of the structure in the relationship with type theory. What we need is a study of universal structure on fibrations, rather than on mere categories, which is unfortunately unsatisfactory so far. Therefore, T F is based on algebraic presentation using operations and equations. This does not prevent us from applying our methodology in each fibre category when it is equipped with universal structure. In Chapter 8, we discuss a possible way to extend the first part of thesis to universal structures on fibrations so that we can treat structure across different fibre categories.

5.2 Type dependency

This section introduces four type systems having type dependency with the usual syntax. They are Generalised Algebra GA [13], λP1 with dependent products, wML with dependent products and weak dependent coproducts, and ML with strong ones.

5.2.1 Generalised algebraic theories

A basic type system handling dependent types is generalised algebra(GA) introduced by Cartmell [13,14]. In the more modern terms of Jacobs’ classification [37], this is the type system with setting (Sort = {∗}, ≻= {(∗, ∗)}) and feature ‘constants’.

A theory in GA or a GA theory is a generalisation of a usual many-sorted equational theory. In GA, the notion of type is generalised to that of type expressions constructed from constant types, which may contain variables of other types, e.g. F(x_{1}, x_{2}). A type expression containing variables, which can vary depending on terms substituted for variables, is called a dependent type.

The notation E[x] for an expression E of a GA theory means that x is a free variable of E which may occur vacuously. E[x/A] denote the substitution of the expression A for x and E[x⃗/A⃗] the simultaneous substitution of A⃗ = A_{1}, ⋯, A_{n} for x⃗ = x_{1}, ⋯, x_{n}. Parentheses are used to show the precedence, to denotes applications as in F(A_{1}, A_{2}), and to list all the free variables of E as in E(x_{1}, ⋯, x_{n}).

For readers not familiar with type dependency, we give a leisurely account of the formal syntax of GA theories here and omit such details for the system T F later.

The precise definition of a GA theory is tedious because of the complex type discipline. In the generalised algebraic case, type and operator symbols must be introduced in a theory with justification, which is done by showing that relevant expressions are well-formed; in turn, well-formedness of an expression depends on derivability of equations in the theory whose language is now being defined. We follow Cartmell’s treatment [14] with some modification to avoid this difficulty. (See also Hyland and Pitts [36].)

Let

• V be a set of (countably many) variables, for which we use metavariables x, x_{1}, x_{2}, y, · · ·.

• W_{T y} be a set of constant type symbols, with metavariables F, F_{1}, · · ·.

• W_{T m} be a set of constant term symbols, with metavariables C, C_{1}, · · ·.

Definition 5.2.1. The set of possibly not well-formed type expressions (written K, L, G, H, K_{1}, ⋯) and term expressions (written A, A_{1}, B, ⋯) relative to V and W are defined inductively by

- for all x ∈ V, x is a term expression.

- for all F ∈ W_{T y} and A_{1}, ⋯, A_{n} (0 ≤ n) term expressions, F(A_{1}, ⋯, A_{n}) is a type expression.

- for all C ∈ W_{T m} and A_{1}, ⋯, A_{n} (0 ≤ n) term expressions, C(A_{1}, ⋯, A_{n}) is a term expression.

Definition 5.2.2. A context x_{1}: K_{1}, ⋯, x_{n}: K_{n}, also written x⃗: K⃗, is a finite sequence of distinct pairs (variable, type expression).

A judgement is an expression of one of the following five forms.

(i) (Structural judgements for context) x⃗: K⃗ Context (read “x⃗: K⃗ is a wellformed context.”)

(ii) (Structural judgements for types) x⃗: K⃗⊢H: Type (“H is a well-formed type

in context x⃗: K⃗.”) (iii) (Structural judgements for terms) x⃗: K⃗⊢A: H (“A is a well-formed term of

type H under a context x⃗: K⃗.”) (iv) (Equality judgements for types) x⃗: K⃗⊢G = H: Type (“G and H are equal

well-formed types under a context x⃗: K⃗.”)

(v) (Equality judgements for terms) x⃗: K⃗⊢A = B: H (“A and B are equal wellformed terms of type H in context x⃗: K⃗.”)

Definition 5.2.3. A pretheory T is determined by following data (relative to V, W_{T y}, and W_{T m}).

(i) for each constant type symbol F, an associated structural judgement J_{F}^{T} of the form x⃗: K⃗⊢F(x⃗): Type with some x⃗: K⃗.

(ii) for each constant term symbol C, an associated structural judgement J_{C}^{T}, of

the form x⃗: K⃗⊢C(x⃗): H with some x⃗: K⃗ and H. (iii) a set Ax_{T} of axioms consisting of equality judgements for types or terms.

Definition 5.2.4. A judgement J is derivable in a pretheory T if there is a labelled finite tree (derivation) such that the root node is labelled with J, the leaves are empty, and each branching has a label

\begin{aligned}J_{1} & J_{2} & ⋯ & J_{n} \\ & & J_{0} \end{aligned}

which is an instance of the following inference rules. An inference rule such that the conclusion J_{0} is a structural (equality) judgement is called a structural (equality ) inference rule. (Notations x⃗: K⃗⊢H, H′: Type etc. are abbreviations of “x⃗: K⃗⊢H: Type x⃗: K⃗⊢H′: Type” etc..)

( ) Context (context1)
x⃗: K⃗⊢K_{n+1}: Type

x⃗: K⃗, x_{n+1}: K_{n+1} Context (provided x_{n+1} is distinct from the x_{i}’s.)

(context2)

x⃗: K⃗ Context
x⃗: K⃗⊢F (x⃗): Type (for each J_{F}^{T} of the form x⃗: K⃗⊢(F (x⃗)): Type)

(constant1)

x⃗: K⃗⊢H: Type

x⃗: K⃗⊢C(x⃗): H (for each J_{C}^{T} of the form x⃗: K⃗⊢C(x⃗): H)

(constant2)

\begin{matrix}x⃗: K⃗⊢K_{n+1}: Type \\ x⃗: K⃗, x_{n+1}: K_{n+1}⊢x_{n+1}: K_{n+1} \end{matrix} (assumption)
x⃗: K⃗⊢K_{n+1}: Type x⃗: K⃗⊢H: Type

(x⃗: K⃗, x_{n+1}: K_{n+1})⊢H: Type

(weakening1)

\begin{matrix}x⃗: K⃗⊢K_{n+1}: Type & x⃗: K⃗⊢A: H \\ (x⃗: K⃗, x_{n+1}: K_{n+1})⊢A: H \end{matrix} (weakening2)
x⃗: K⃗⊢F(x⃗): Type y⃗: G⃗⊢A_{i}: K_{i}[x_{1}, ⋯ x_{i−1}/A_{1}, ⋯ A_{i−1}] (1≤i≤n)
y⃗: G⃗⊢F(A⃗): Type

(subst1)

\begin{aligned}x⃗: K⃗⊢C(x⃗): H & y⃗: G⃗⊢A_{i}: K_{i}[x_{1}, ⋯ x_{i−1}/A_{1}, ⋯ A_{i−1}] & (1≤i≤n) \\ & y⃗: G⃗⊢C(A⃗): H[x⃗/A⃗] \end{aligned} (subst2)

x⃗: K⃗⊢H, H′: Type x⃗: K⃗⊢H = H′: Type (axiom1) (provided x⃗: K⃗⊢H = H′: Type ∈ Ax_{T})

\begin{matrix}x⃗: K⃗⊢A, A′: H \\ x⃗: K⃗⊢A = A′: H \end{matrix} (axiom2) (provided x⃗: K⃗⊢A = A′: H ∈ Ax_{T})

x⃗: K⃗⊢H: Type x⃗: K⃗⊢H = H: Type (reflexivity1) \begin{matrix}x⃗: K⃗⊢A: H \\ x⃗: K⃗⊢A = A: H \end{matrix} (reflexivity2)
x⃗: K⃗⊢H = H′: Type x⃗: K⃗⊢H′ = H: Type (symmetry1) \begin{matrix}x⃗: K⃗⊢A = A′: H \\ x⃗: K⃗⊢A′ = A: H \end{matrix} (symmetry2)

Chapter 5. Type theory and fibrations 1 113

x⃗: K⃗⊢H_{1} = H_{2}: Type x⃗: K⃗⊢H_{2} = H_{3}: Type
x⃗: K⃗⊢H_{1} = H_{3}: Type

(transitivity1)

\begin{matrix}x⃗: K⃗⊢A_{1} = A_{2}: H & x⃗: K⃗⊢A_{2} = A_{3}: H \\ x⃗: K⃗⊢A_{1} = A_{3}: H \end{matrix} (transitivity2)
\begin{aligned}x⃗: K⃗⊢A: H & x⃗: K⃗⊢H = H′: Type \\ & x⃗: K⃗⊢A: H′ \end{aligned} (replacement1)
\begin{matrix}x⃗: K⃗⊢A = A′: H & x⃗: K⃗⊢H = H′: Type \\ x⃗: K⃗⊢A = A′: H′ \end{matrix} (replacement2)
( \begin{matrix}x⃗: K⃗⊢H = H′: Type \\ y⃗: G⃗⊢A_{i} = A′_{i}: K_{i}[x_{1}, ⋯ x_{i−1}/A_{1}, ⋯ A_{i−1}] (1 ≤ i ≤ n) \end{matrix} )
y⃗: G⃗⊢H[x⃗/A⃗] = H′[x⃗/A⃗′]: Type

(congruence1)

\begin{aligned}( & \begin{matrix}x⃗: K⃗⊢B = B′: H \\ y⃗: G⃗⊢A_{i} = A′_{i}: K_{i}[x_{1}, ⋯ x_{i−1}/A_{1}, ⋯ A_{i−1}] (1 ≤ i ≤ n) \end{matrix} & ) \\ & y⃗: G⃗⊢B[x⃗/A⃗] = B′[x⃗/A⃗′]: H[x⃗/A⃗] \end{aligned} (congruence2)

In the (context1) rule, () represents the empty context. The only starting rule of this inductive definition is the judgement () Context. (context2) rules out contexts such as x_{1}: K_{1}(x_{2}), x_{2}: K_{2}(x_{1}).

(constant1) and (constant2) mean that introductions of constant type or term symbols are justified only when the associated structural judgements have wellformed contexts. (axiom1) and (axiom2) show that introductions of axioms are justified only when the expressions involved are well-formed. For these clauses, concluded judgements are called well-formed.

In (weakening1) and (weakening2), the added variable x_{n+1} is counted as a free variable of H or A which occurs vacuously, for technical convenience.

Through (replacement1) and (replacement2), typing and well-formedness of expressions are entangled with equality of types, which, in turn, is determined by equality of terms. This is the main source of extra complication in passing from the usual algebraic case to the generalised algebraic case.

We add the following constants and equalities as inference rules because we need these to relate T F with GA. These rules are guaranteed to be well-formed in any GA theory.

Definition 5.2.4. (Continued.) The following are inference rules of a pretheory in GA.

\begin{matrix}()⊢1: Type & (1F) \\ ()⊢∗: 1 & (1I) \\ \begin{matrix}x⃗: K⃗⊢A: 1 \\ x⃗: K⃗⊢A = ∗: 1 \end{matrix} & (1E) \end{matrix}

Definition 5.2.5. A GA theory T is a pretheory whose axioms and judgements J_{F}^{T} , J_{C}^{T} associated to constant type or term symbols are all well-formed.

It should be remarked that a large, simultaneous, recursive definition of wellformed expressions and derivability of judgements will do the same task. But such a definition of a theory causes some problems of exposition. For example, we must introduce notions concerned with a language of a theory in the form of definition-proposition, proving that the definition makes sense.

Equality of types and terms is always determined under a specified context. This treatment of equality, stratification, is already required in many-sorted equational theories, see [25]. However, we omit contexts of equations whenever they are clearly understood from the “context” (in the usual sense). We also make implicit use of (transitivity), (congruence), etc. writing equations in usual style.

Phrases of the form “a term x⃗: K⃗⊢A: H ...” mean “a term A, which is of a type H and well-formed under a context x⃗: K⃗, ...” in the following.

5.2.2 Standard interpretations of GA theories

Now we informally introduce the standard interpretation of dependent types in the families of sets indexed by sets to give an insight into how locally small fibrations models type dependency later. First, we fix some notation.

Definition 5.2.6. Given I-indexed family X = (X_{i})_{i∈I} of sets, a map u: J → I, and an J-indexed family (f_{j})_{j∈J} with f_{j} ∈ X_{uj}, • X[u] denotes the re-indexing of X along u, that is, the family (X_{u(j)})_{j∈J}

indexed by J.

• χ_{X} denotes a ∐_{i∈I} X_{i}-indexed family of elements (e)_{(i,e)∈∐_{i∈I} X_{i}}.

• d_{X}: ∐_{i∈I} X_{i} ^{}I is the map sending (i, e) to i.

• ≺u, f≻: J ^{}∐_{i∈I} X_{i} is the map sending j to (uj, f_{j}).

The operators χ_{−}, ≺−, −≻, and d_{−} describe the local smallness of the fibration p_{C}: Fam(Set) ^{}Set.

We write \overline{E} for the informal interpretation of GA expression E into the families of sets indexed by sets. A closed type ⊢A: Type (a type without free variables) and a closed term ⊢A: K are interpreted as a set \overline{K} and its element \overline{A} ∈ \overline{K}. Consider an open type x: K⊢L(x): Type. For each closed term ⊢A: K, (subst1) rule gives a closed type ⊢L(A): Type, so an open type x: K⊢L(x): Type defines a family of closed types indexed by the set of closed terms of type K. Then the interpretation \overline{L(x)} is naturally given by a family of sets (\overline{L}_{k})_{k∈\overline{K}} indexed by \overline{K} with \overline{L}\overline{A} = \overline{L(A)}. Similarly an open term x: K⊢B(x): L(x) is interpreted as a family of elements (\overline{B}_{k})_{k∈\overline{K}}, where \overline{B}_{k} ∈ \overline{L}_{k} for all k ∈ \overline{K}.

A type with two or more free variables, say x: K, y: L(x)⊢H(x, y): Type, is also considered as a family of sets that are interpretations of closed types, but the indexing set is no longer a mere interpretation of a closed type. Instead, one has closed type H(A, B) for each pair of closed terms ⊢A: K and ⊢B: L(A), i.e., terms consistently assignable to x: K, y: L(x). Interpreting such pairs, one gets the set ∐_{k∈\overline{K}} \overline{L}_{k} = \{(k, l)|k ∈ \overline{K}, l ∈ \overline{L}_{k}\}, which is the interpretation \overline{x: K, y: L(x)} of the context. The interpretation \overline{H(x, y)} is then a family (\overline{H}_{(k,l)})_{(k,l)∈\overline{x:K,y:L(x)}} indexed by this set.

The definition of Ē for a well-formed expression E follows from the the derivation of E. In the following, K_{n+1}, A etc. represent the same expressions occurring in corresponding rules in Definition 5.2.4.

The empty context given by (context1) is interpreted as a singleton set \overline{()} = {∗}.

As for (context2), suppose a sets Γ = \overline{x⃗: K⃗} and a family of set \overline{K_{n+1}} = (\overline{K_{n+1}} _{γ})_{γ∈Γ} are already defined. \overline{x⃗: K⃗, x_{n+1}: K_{n+1}} is defined to be ∐_{γ∈Γ} \overline{K_{n+1}} _{γ}(= \{(γ, k)|γ ∈ Γ k ∈ \overline{K}\}).

1 and ∗ introduced by (1 F) and (1 I) are interpreted by \overline{1} = \{∗\} and \overline{∗} = ∗, respectively. For other constants introduced by (constant1) and (constant2), \overline{F (x⃗)} is a family of sets (\overline{F}_{γ})_{γ∈\overline{x⃗:K⃗}} and \overline{C(x⃗)} a family of elements (\overline{C}_{γ})_{γ∈\overline{x⃗:K⃗}} with \overline{C}_{γ} ∈ \overline{H}_{γ} so that the axioms are satisfied. It is impossible to define interpretations of all the constants first and then check satisfaction of axioms because well-definedness of interpretation depends on satisfaction of equations as remarked in Section 5.2.1.

The interpretation of a variable introduced by (assumption) is \overline{x_{n+1}} = χ\overline{K_{n+1}}.

As for (weakening1), one must distinguish the interpretation of the type H occurring in x⃗: K⃗⊢H: Type from one occurring in (x⃗: K⃗, x_{n+1}: K_{n+1})⊢H: Type because they should have different indexing sets. The interpretation of the latter H is given by that of the former, that is, \overline{H}^{x⃗:K⃗,x_{n+1}:K_{n+1}} = \overline{H}^{x⃗:K⃗}[d_{\overline{K_{n+1}}}]. Rule (weakening2) is treated similarly. In particular, a variable introduced by successive application of (weakening2) is interpreted by \overline{x_{i}}^{x⃗:K⃗} = χ_{\overline{K_{i}}}[d_{K_{i+1}}d_{K_{i+2}} ⋯ d_{K_{n}}].

Before giving the interpretation of F(A⃗) in (subst1), we show the simplest case. Suppose w: G⊢A[w]: K and x: K⊢F(x): Type. The type w: G⊢F(A[w]): Type is then naturally interpreted by the family of sets (\overline{F}_{\overline{A}g})_{g∈\overline{G}} indexed by \overline{G}. Identifying \overline{(w: G)} = ∐_{∗∈1} \overline{G} with \overline{G}, one can write \overline{F(A)} = \overline{F}[≺!, A≻] where ! is the unique map from \overline{G} to a singleton set. For the general case, given

y⃗: G⃗⊢A_{i}: K_{i}[x_{1}, ⋯ x_{i−1}/A_{1}, ⋯ A_{i−1}] (1 ≤ i ≤ n),

one obtains a map ≺≺≺ ⋯ ≺≺!, \overline{A}_{1}≻, \overline{A}_{2}≻, ⋯ ≻, \overline{A}_{n−1}≻, \overline{A}_{n}≻: \overline{y⃗: G⃗} ^{}\overline{x⃗: K⃗}, sending (g_{1}, ⋯, g_{m}) to (\overline{A_{1}})_{(g_{1},···,g_{m})}, ⋯, (\overline{A_{n}})_{(g_{1},···,g_{m})}. Then, for constant type x⃗: K⃗⊢F(x⃗): Type, we put

\overline{F(A⃗)} = \overline{F}[≺≺≺ ⋯ ≺≺!, \overline{A}_{1}≻, \overline{A}_{2}≻, ⋯ ≻, \overline{A}_{n−1}≻, \overline{A}_{n}≻].

The interpretation of C(A⃗) in (subst2) is defined similarly.

5.2.3 Dependent product and coproduct types

The type system GA is strengthened with new kinds of type forming operations. This subsection introduces three of these, dependent product type and two kinds of dependent coproduct type formations.

Type system λP1

λP1 is a type system obtained from GA by adjoining dependent product types. Intuitively, a dependent product type is a type of functions whose result types depend on their arguments. In terms of Jacobs’ classification, this adds to GA the feature (∗, ∗)-products.

Definition 5.2.7. The type expressions and term expressions of λP1 are defined by

- (clauses given in Definition 5.2.1.)

- for all type expressions K and H, Πx: K.H is a type expression.

- for all type expressions K and all term expression A, λx: K.(A) is a term expression.

Definition 5.2.8. The derivable judgements of a pretheory in λP1 are defined with inference rules (context1) – (congruence2) given in Definition 5.2.4 plus the following rules.

x⃗: K⃗, x_{n+1}: K_{n+1}⊢H: Type x⃗: K⃗⊢Πx_{n+1}: K_{n+1}.H: Type

(ΠF)

\begin{matrix}x⃗: K⃗, x_{n+1}: K_{n+1}⊢A: H \\ x⃗: K⃗⊢λx_{n+1}: K_{n+1}.(A): Πx_{n+1}: K_{n+1}.H \end{matrix} (ΠI)
\begin{matrix}x⃗: K⃗⊢B: Πx_{n+1}: K_{n+1}.H & x⃗: K⃗⊢C: K_{n+1} \\ x⃗: K⃗⊢BC: H[x_{n+1}/C] \end{matrix} (ΠE)

\begin{matrix}\begin{matrix}x⃗: K⃗, x_{n+1}: K_{n+1}⊢A: H & x⃗: K⃗⊢C: K_{n+1} \\ x⃗: K⃗⊢(λx_{n+1}: K_{n+1}.(A))C = A[x_{n+1}/C]: H[x_{n+1}/C] \end{matrix} & (β) \\ \begin{matrix}x⃗: K⃗⊢B: Πx_{n+1}: K_{n+1}.H \\ x⃗: K⃗⊢λz: K_{n+1}.(Bz) = B: Πx_{n+1}: K_{n+1}.H \end{matrix} & (η) \end{matrix}

Chapter 5. Type theory and fibrations 1 118

x⃗: K⃗⊢K_{n+1} = K′: Type x⃗: K⃗, x′: K′⊢H′ = H[x_{n+1}/x′]: Type
x⃗: K⃗⊢Πx_{n+1}: K_{n+1}.H = Πx: K′.H′: Type

(congruence1)

x⃗: K⃗⊢K_{n+1} = K′: Type
x⃗: K⃗, x_{n+1}: K_{n+1}⊢H: Type
x⃗: K⃗, x′: K′⊢A′ = A[x_{n+1}/x′]: H[x_{n+1}/x′]

x⃗: K⃗⊢λx_{n+1}: K_{n+1}.(A) = λx′: K′.(A′): Πx_{n+1}: K_{n+1}.H

(congruence2)

The occurrences of x_{n+1} in the conclusion of (ΠF) and (ΠI) are called bound as usual. Instead of complicating the rules with tedious side conditions, we presuppose, at a meta-level, the usual variable conventions such as no variables having bound and free occurrences at the same time and all bound variables being distinct.

If H occurring in a type Πx: K.H contains no free occurrence of x, the type is written K⊃H because its intuitive meaning agrees with the usual function type from K to H.

Type system wML

Dependent coproduct types are similar to disjoint sums of sets. A term of a dependent coproduct types is a pair of terms whose second component has varying type depending on its first component. We first add to T F λ dependent coproduct types, yielding the type system wML. In Jacobs’ terms, this is weak (∗, ∗)-sum. The added inference rules are as follows.

x⃗: K⃗, x_{n+1}: K_{n+1}⊢G: Type x⃗: K⃗⊢Σx_{n+1}: K_{n+1}.G: Type

(wΣF)
\begin{matrix}x⃗: K⃗⊢A_{1}: K_{n+1} & x⃗: K⃗⊢A_{2}: G[x_{n+1}/A_{1}] \\ x⃗: K⃗⊢⟨A_{1}, A_{2}⟩: Σx_{n+1}: K_{n+1}.G \end{matrix} (wΣI)
x⃗: K⃗⊢A: Σx_{n+1}: K_{n+1}.G x⃗: K⃗⊢H: Type x⃗: K⃗, x_{n+1}: K_{n+1}, y: G⊢B: H
x⃗: K⃗⊢let⟨x_{n+1},y⟩=A in B: H

(wΣE)
( \begin{matrix}x⃗: K⃗⊢A_{1}: K_{n+1} & x⃗: K⃗⊢A_{2}: G[x_{n+1}/A_{1}] \\ x⃗: K⃗⊢H: Type & x⃗: K⃗, x_{n+1}: K_{n+1}, y: G⊢B: H \end{matrix} )

x⃗: K⃗⊢let⟨x,y⟩=⟨A_{1},A_{2}⟩ in B = B[x, y/A_{1}, A_{2}]: H

(β′)
\begin{matrix}x⃗: K⃗⊢A: Σx_{n+1}: K_{n+1}.G & x⃗: K⃗, z: Σx_{n+1}: K_{n+1}.G⊢C: H \\ x⃗: K⃗⊢let⟨x,y⟩=A in C[z/⟨x, y⟩] = C[z/A]: H \end{matrix} (η′)

Congruence rules similar to (congruence1,2) in Definition 5.2.8 is omitted.

With this weaker notion of dependent coproduct, one cannot extract the second component A_{2} of ⟨A_{1}, A_{2}⟩: Σx_{n+1}: K_{n+1}.G, since, in (wΣE) rule, the type H of B can not depend on x_{n+1}: K_{n+1}. This restriction corresponds to a familiar restriction on eigen variables in the elimination rule for ∃ of the first-order logic.

\begin{matrix}⋮ ; ∃x_{n+1}.G[x_{n+1}] & {[G] \atop ⋮ . B} ; H \\ H \end{matrix}

In the above natural deduction style rule, the proof B must not contain open assumptions containing x_{n+1} freely. Categorically, this restriction gives the pattern of adjointness.

Type system ML

The type system ML has usual dependent coproduct types with first and second projections. In Jacobs’ terms, they are strong (∗, ∗)-sums. The inference rules added to those of λP1 are:

x⃗: K⃗, x_{n+1}: K_{n+1}⊢G: Type

x⃗: K⃗⊢Σx_{n+1}: K_{n+1}.G: Type

(ΣF)

\begin{matrix}x⃗: K⃗⊢A_{1}: K_{n+1} & x⃗: K⃗⊢A_{2}: G[x_{n+1}/A_{1}] \\ x⃗: K⃗⊢⟨A_{1}, A_{2}⟩: Σx_{n+1}: K_{n+1}.G \end{matrix} (ΣI)
\begin{matrix}x⃗: K⃗⊢A: Σx_{n+1}: K_{n+1}.G \\ x⃗: K⃗⊢fst(A): K_{n+1} \end{matrix} (ΣE1) \begin{matrix}x⃗: K⃗⊢A: Σx_{n+1}: K_{n+1}.G \\ x⃗: K⃗⊢snd(A): G[x_{n+1}/fst(A)] \end{matrix} (ΣE2)
\begin{matrix}x⃗: K⃗⊢A_{1}: K_{n+1} & x⃗: K⃗⊢A_{2}: G[x_{n+1}/A_{1}] \\ x⃗: K⃗⊢fst(⟨A_{1}, A_{2}⟩) = A_{1}: K_{n+1} \end{matrix} (fst(−)eq)
\begin{matrix}x⃗: K⃗⊢A_{1}: K_{n+1} & x⃗: K⃗⊢A_{2}: G[x_{n+1}/A_{1}] \\ x⃗: K⃗⊢snd(⟨A_{1}, A_{2}⟩) = A_{2}: G[x_{n+1}/A_{1}] \end{matrix} (snd(−)eq)
x⃗: K⃗⊢A: Σx_{n+1}: K_{n+1}.G

x⃗: K⃗⊢⟨fst(A), snd(A)⟩ = A: Σx_{n+1}: K_{n+1}.G

(⟨⟩eq)

One can define the let construct of wML by

let⟨x_{n+1},y⟩=A in B ≡ B[x_{n+1}/fst(A), y/snd(A)], then (β′) and (η′) rules of wML are derivable in ML.

5.2.4 Interpretations between theories

We define a notion of interpretations between theories. An interpretation is a map that sends well-formed expressions of one theory to those of the other, preserving equality. Through an interpretation, derivations in one theory can be mapped to those in another. Later, we will form categories of theories with interpretations as morphisms to show the equivalence of those to categories of suitable models.

Definition 5.2.9. Given two GA theories T_{G} and T′_{G}, a map I(−) from the set of well-formed expressions paired with their contexts of T_{G} to the set of possibly not well-formed expressions of T′_{G} is a preinterpretation from T_{G} to T′_{G} if and only if the following conditions are satisfied. The conditions are listed following structural inference rules for expressions of T_{G} with the same notation in Definition 5.2.4. For brevity, the set of variable symbols of T′_{G} is supposed to be the same as that of T_{G}.

(context1) I(( )) = ( )
(context2) I(x⃗: K⃗, x_{n+1}: K_{n+1}) = (I(x⃗: K⃗), x_{n+1}: I(K_{n+1}))
(assumption) I(x_{n+1})^{x⃗:K⃗,x_{n+1}:K_{n+1}} = x_{n+1}
(weakening1) I(H)^{x⃗:K⃗,x_{n+1}:K_{n+1}} = I(H)^{x⃗:K⃗}
(weakening2) I(A)^{x⃗:K⃗,x_{n+1}:K_{n+1}} = I(A)^{x⃗:K⃗}
(subst1) I(F(A⃗))^{y⃗:G⃗} = I(F(x⃗))^{x⃗:K⃗}[x⃗/I(A_{1})^{y⃗:G⃗}, ⋯, I(A_{n})^{y⃗:G⃗}]
(subst2) I(C(A⃗))^{y⃗:G⃗} = I(C(x⃗))^{x⃗:K⃗}[x⃗/I(A_{1})^{y⃗:G⃗}, ⋯, I(A_{n})^{y⃗:G⃗}]

An interpretation is a pretranslation satisfying the following conditions.

(constant1) I(x⃗: K⃗)⊢I(F(x⃗))^{x⃗:K⃗}: Type is derivable in T′_{G}
(constant2) I(x⃗: K⃗)⊢I(C(x⃗))^{x⃗:K⃗}: I(H)^{x⃗:K⃗} is derivable in T′_{G}
(axiom1),(axiom2) Axioms of T_{F} are sent to derivable judgements of T′_{G}

A preinterpretation I(−) is determined by I(F(x⃗))’s and I(C(x⃗))’s under the above conditions. One can show the soundness of interpretations from T_{G} to T′_{G} by induction on derivations in T_{G}.

Lemma 5.2.10. Given an interpretation I(−) from a GA theory T_{G} to T′_{G}, interpretations of the derived judgements of T_{G} are also derivable in T′_{G}.

Definition 5.2.11. Given two λP1 theories T_{G} to T′_{G}, a (pre)interpretation from T_{G} and T′_{G} is a map satisfying the conditions given in Definition 5.2.9 with the conditions below.

(ΠF) I(Πx_{n+1}: K_{n+1}.H)^{x⃗:K⃗} = Πz: I(K_{n+1})^{x⃗:K⃗}.I(H)^{x⃗:K⃗,x_{n+1}:K_{n+1}}[x_{n+1}/z]
(ΠI) I(λx_{n+1}: K_{n+1}.(A))^{x⃗:K⃗} = λz: I(K_{n+1})^{x⃗:K⃗}.(I(A)^{x⃗:K⃗,x_{n+1}:K_{n+1}}[x_{n+1}/z])
(ΠE) I(BC)^{x⃗:K⃗} = I(B)^{x⃗:K⃗}I(C)^{x⃗:K⃗}

where z is a fresh variable.

Definition 5.2.12. Given two wML theories T_{w} and T′_{w}, a (pre)interpretation from T_{w} and T′_{w} is a map satisfying the conditions given in Definition 5.2.9 and 5.2.11 plus the following conditions.

(wΣF) I(Σx_{n+1}: K_{n+1}.H)^{x⃗:K⃗} = Σz: I(K_{n+1})^{x⃗:K⃗}.I(H)^{x⃗:K⃗,x_{n+1}:K_{n+1}}[x_{n+1}/z]
(wΣI) I(⟨A_{1}, A_{2}⟩)^{x⃗:K⃗} = ⟨I(A_{1})^{x⃗:K⃗}, I(A_{2})^{x⃗:K⃗}⟩
(wΣE) I(let⟨x_{n+1},y⟩=A in B)^{x⃗:K⃗}

= let⟨z,w⟩=I(A)^{x⃗:K⃗} in I(B)^{x⃗:K⃗,x:K_{n+1},y:G}[x_{n+1}/z, y/w] (z, w are fresh variables.)

Definition 5.2.13. Given two ML theories T_{M} and T′_{M}, a (pre)interpretation from T_{M} to T′_{M} is a map satisfying the conditions given in Definition 5.2.9 and 5.2.11 plus the following conditions.

(ΣF) I(Σx_{n+1}: K_{n+1}.H)^{x⃗:K⃗} = Σz: I(K_{n+1})^{x⃗:K⃗}.I(H)^{x⃗:K⃗,x_{n+1}:K_{n+1}}[x_{n+1}/z]
(ΣI) I(⟨A_{1}, A_{2}⟩)^{x⃗:K⃗} = ⟨I(A_{1})^{x⃗:K⃗}, I(A_{2})^{x⃗:K⃗}⟩
(ΣE1) I(fst(A))^{x⃗:K⃗} = fst(I(A)^{x⃗:K⃗})
(ΣE2) I(snd(A))^{x⃗:K⃗} = snd(I(A)^{x⃗:K⃗})

where z is a fresh variable.

In each case, the notion interpretations is defined similarly to Definition 5.2.9. The soundness of these interpretations is also shown by similar induction.

5.3 Type system T F

This section defines the type system T F and gives intuition behind its inference rules. T F is a syntactical and equational presentation of fibrewise locally small fibrations with a terminal object, product and coproducts along Hom-projections.

The characteristics of T F are as follows. First, it has a generalised notion of terms such that a term must be specified with a domain type and a codomain type. This notion of generalised term allows T F to have more general structure than usual type systems. Direct connections with a greater variety of models and the duality between dependent product and coproduct types are also obtained with this notion.

Second, variable names are abandoned in the syntax of T F. Substitution is addressed by re-indexing operations along context mappings and generic term that express indeterminate values. The resulting system is similar to de Bruijn notation.

A fibration p: E ^{}B expressed in T F has a splitting and satisfies the strict Beck-Chevalley condition, every base object is isomorphic to one of the form Hom_{I}(1, X) for some I ∈ B and X ∈ E_{I}. The strictness condition excludes many natural examples, but this makes it feasible to set up notation and show precise calculations, which are already complex even without coherent isomorphisms.

However, this involves no substantial loss of generality since, given a fibration p, one can construct a split fibration equivalent to p in the 2-category of fibrations (see Proposition 4.5.6).

5.3.1 T F theories

Expressions of a T F theory are classified in four kinds: contexts Γ, Δ, ⋯, context mappings u, v, ⋯, types K, L, ⋯, generalised terms A, B, · · ·. Each of these corresponds to the form of structural judgements that assert well-formedness and typing of expressions. Context mappings, types, and generalised terms of a theory in T F have a notion of equality asserted with equality judgements.

Definition 5.3.1. Judgements are expressions of the following forms.

• (Structural judgements for contexts.) Γ Context (read “Γ is a well-formed context.”)

• (Structural judgements for context mappings.) u: Γ → Δ (“u is a well-formed context mapping from a context Γ to Δ.”)

• (Structural judgements for types.) Γ⊢K: Type (“K is a well-formed type under a context Γ.”)

• (Structural judgements for terms.) Γ⊢A: K ⇒ L (“A is a well-formed term under a context Γ from a domain type K to a codomain type L.”)

• (Equality judgements for context mappings.) u = u′: Δ → Γ

• (Equality judgements for types.) Γ⊢K = K′: Type

• (Equality judgements for terms.) Γ⊢A = A′: K ⇒ L

The definition of T F theories exhibits the same difficulty as the one that appeared in Section 5.2.1. The set of expressions, well-formedness and typing of expressions, and well-formedness of introduction rules and axioms are all defined by a simultaneous recursive definition of the derivability of judgements. In contrast to Section 2, we give a large simultaneous definition to which the rest of this section is devoted. However, we will swap between the two possible presentations when it is convenient. For example, we refer to the set of possibly not well-formed expressions without explicit definition, because it should be easily understood.

Definition 5.3.2. Given the data listed below,

• a set of constant type symbols.

• a set of constant term symbols.

• for each constant type symbol F, an associated structural judgement J_{F}^{T} of the form Γ⊢F: Type for some Γ.

• for each constant term symbol C, an associated structural judgement J_{C}^{T} of the form Γ⊢C: K ⇒ L for some Γ and K, L.

• a set Ax_{T} of axioms consisting of equality judgements for types or terms.

A T F theory T consists of a class of derivable (or well-formed) judgements closed under the inference rules given in the rest of this section. The well-formed expressions of T are ones subject to derivable judgements of T. Moreover, all the given structural judgements associated with constant symbols and all the axioms of T must be well-formed in T.

In the following, we motivate inference rules by informally showing the correspondence between a type theory T and a fibrewise locally small fibration p: E ^{}B with a terminal object, products and coproducts along Hom-projections.

Contexts and context mappings

Definition 5.3.2. (Continued.) The following form part of the inference rules of T.

() Context (C1) Γ⊢K, L: Type (Γ, K ⇒ L) Context (C2)
id_{Γ}: Γ → Γ (PM1) \begin{matrix}u: Δ → Γ & v: Ξ → Δ \\ u∘v: Ξ → Γ \end{matrix} (CM2)
\begin{matrix}u: Δ → Γ \\ id_{Γ}∘u = u: Δ → Γ \end{matrix} (ECM1) \begin{matrix}u: Δ → Γ \\ u∘id_{Δ} = u: Δ → Γ \end{matrix} (ECM2)
u: Δ → Γ v: Ξ → Δ w: Θ → Ξ

(u∘v)∘w = u∘(v∘w): Θ → Γ (ECM3)

Γ Context ; !_{Γ}: Γ → () (CM3) \begin{matrix}w: Γ → () \\ w = !_{Γ}: Γ → () \end{matrix} (ECM4)
Γ⊢K, L: Type

d_{K⇒L}: (Γ, K ⇒ L) → Γ (CM4)

Γ⊢K, L: Type u: Δ → Γ Δ⊢A: K[u] ⇒ L[u]

≺u, A≻: Δ → (Γ, K ⇒ L) (CM5)

Γ⊢K, L: Type u: Δ → Γ Δ⊢A: K[u] ⇒ L[u]

d_{K⇒L}∘≺u, A≻ = u: Δ → Γ (ECM5)

Γ⊢K, L: Type w: Δ → (Γ, K ⇒ L)

≺d_{K⇒L}∘w, χ_{K⇒L}[w]≻ = w: Δ → (Γ, K ⇒ L) (ECM6)

Subscripts Γ in !_{Γ} and K ⇒ L in d_{K⇒L} are occasionally omitted if they are recoverable from the context.

The intuition behind these inference rules is given by the following correspondence between T and p. Contexts correspond to objects of the base category B and context mappings to morphisms of B.

T  p: E ^{}B
(C1) () 1 ∈ B (the terminal of B)
(C2) (Γ, K ⇒ L)  Hom_{Γ}(K, L) ∈ B
(CM1)  id_{Γ}  id_{Γ}: Γ → Γ ∈ B
(CM2)  u∘v  uv: Δ → Ξ ∈ B
(CM3)  !_{Γ}  !_{Γ}: Γ → 1 ∈ B (the unique projection)
(CM4)  d_{K⇒L}  d_{Γ,KL}: Hom_{Γ}(K, L) → Γ ∈ B
(CM5) ≺u, A≻ ≺u, A≻: Δ → Hom_{Γ}(K, L) ∈ B

where types and terms are identified with appropriate objects and morphisms of F, as we shall see below.

(ECM5), (ECM6), and (ETM9) given below are the conditions that characterise (Γ, K ⇒ L) as the object Hom_{Γ}(K, L) with d_{K⇒L} as d_{Γ,KL}.

Types

Definition 5.3.2. (Continued.) The following are inference rules of T.

()⊢1: Type (TY1) ΓContext ; Γ⊢F: Type (TY2)

for each J_{F}^{T} of the form Γ⊢F: Type)

u: Δ → Γ Γ⊢K: Type

Δ⊢K[u]: Type (TY3)

Γ Context Γ⊢K[id_{Γ}] = K: Type

(ETY1)

Γ⊢K: Type u: Δ → Γ v: Ξ → Δ
Ξ⊢K[u][v] = K[u∘v]: Type

(ETY2)

(Γ, K ⇒ L)⊢H: Type Γ⊢Π_{K⇒L}.H: Type (TY4) (Γ, K ⇒ L)⊢G: Type Γ⊢Σ_{K⇒L}.G: Type (TY5)
Γ⊢K, L: Type (Γ, K ⇒ L)⊢H: Type u: Δ → Γ

Δ⊢(Π_{K⇒L}.H)[u] = Π_{K[u]⇒L[u]}.H[≺u∘d_{K[u]⇒L[u]}, χ_{K[u]⇒L[u]}≻]: Type (ETY3)

Γ⊢K, L: Type (Γ, K ⇒ L)⊢G: Type u: Δ → Γ

Δ⊢(Σ_{K⇒L}.G)[u] = Σ_{K[u]⇒L[u]}.G[≺u∘d_{K[u]⇒L[u]}, χ_{K[u]⇒L[u]}≻]: Type (ETY4)

The rule (TY2) is an introduction rule for F. (Later, the associated judgement J_{F}^{T} will also be called introduction rule.) The type 1[!_{Γ}] inferred by (TY3) and (CM3) is often written 1.

As for the correspondence between T and p, well-formed types under a certain context are objects of a fibre over the context regarded as an object of the base category B. The correspondence is summarised as follows.

T  p: E ^{}B
(TY1) 1 1 ∈ E_{1} (the terminal of E_{1})
(TY3) K[u]  K[u] ∈ E_{Δ}
(TY4) Π_{K⇒L}.H Π_{KL}(H) ∈ E_{Γ}
(TY5) Σ_{K⇒L}.G Σ_{KL}(G) ∈ E_{Γ}

Equations inferred by (ETY1) and (ETY2) require that p splits. Type equations (ETY3) and (ETY4) are the strict Beck-Chevalley condition for Π_{KL} and Σ_{KL} (see Definition 4.8.7). These equations show commutativity between the substitution operation and Π, Σ formation operations on types. Informally using the usual notation for substitution, we may show, for example,

(Π_{x:K(y)⇒L(y)}.H(x, y))[y/A(z)] = Π_{x:K(A(z))⇒L(A(z))}.H(x, A(z))
= Π_{x:K(y)[y/A(z)]⇒L(y)[y/A(z)]}.H(x, y)[x/x, y/A(z)].

In other words, a substitution (−)[u] for a type Π_{K⇒L}.H gets inside the Π formation and acts on H as (−)[≺u∘d_{K[u]⇒L[u]}, χ_{K[u]⇒L[u]}≻] which acts in the same way as (−)[u] but leaves the “bound slot” unchanged.

Terms

Definition 5.3.2. (Continued.) The following are inference rules of T.

Γ Context ; Γ⊢C: K ⇒ L (TM1) (for each J_{C}^{T} of the form Γ⊢C: K ⇒ L)
Γ⊢K: Type Γ⊢id_{K}: K ⇒ K (TM2) \begin{matrix}Γ⊢A: K ⇒ L & Γ⊢B: L ⇒ G \\ Γ⊢B∘A: K ⇒ G \end{matrix} (TM3)
{Γ⊢A: K ⇒ L \atop id_{L}∘A = A} (ETM1) {Γ⊢A: K ⇒ L \atop A∘id_{K} = A} (ETM2)
\begin{matrix}Γ⊢A: K ⇒ L & Γ⊢B: L ⇒ G & Γ⊢C: G ⇒ H \\ Γ⊢(C∘B)∘A = C∘(B∘A): K ⇒ H \end{matrix} (ETM3)
\begin{matrix}Γ⊢K: Type \\ Γ⊢!_{K}: K ⇒ 1[!_{Γ}] \end{matrix} (TM4) \begin{matrix}Γ⊢C: K ⇒ 1[!_{Γ}] \\ Γ⊢C = !_{K}: K ⇒ 1[!_{Γ}] \end{matrix} (ETM4)
\begin{matrix}u: Δ → Γ & Γ⊢A: K ⇒ L \\ Δ⊢A[u]: K[u] ⇒ L[u] \end{matrix} (TM5) \begin{matrix}Γ⊢A: K ⇒ L \\ Γ⊢A[id_{Γ}] = A: K ⇒ L \end{matrix} (ETM5)
\begin{matrix}Γ⊢A: K ⇒ L & u: Δ → Γ & v: Ξ → Δ \\ Ξ⊢A[u][v] = A[u∘v]: K[u∘v] ⇒ L[u∘v] \end{matrix} (ETM6)
Γ⊢K: Type u: Δ → Γ
Δ⊢(id_{K})[u] = id_{K[u]}: K[u] ⇒ K[u]

(ETM7)

\begin{matrix}Γ⊢A: K ⇒ L & Γ⊢B: L ⇒ G & u: Δ → Γ \\ Δ⊢B[u]∘A[u] = (B∘A)[u]: K[u] ⇒ G[u] \end{matrix} (ETM8)
Γ⊢K, L: Type

(Γ, K ⇒ L)⊢χ_{K⇒L}: K[d_{K⇒L}] ⇒ L[d_{K⇒L}] (TM6)

Γ⊢K, L: Type u: Δ → Γ Δ⊢A: K[u] ⇒ L[u]

Δ⊢χ_{K⇒L}[≺u, A≻] = A: K[u] ⇒ L[u] (ETM9)

\begin{matrix}(Γ, K ⇒ L)⊢A: G[d_{K⇒L}] ⇒ H \\ Γ⊢λ_{K⇒L}.(A): G ⇒ Π_{K⇒L}.H \end{matrix} (TM7)
(Γ, K ⇒ L)⊢H: Type

(Γ, K ⇒ L)⊢φ_{K⇒L}^{H}: (Π_{K⇒L}.H)[d_{K⇒L}] ⇒ H (TM8)

\begin{matrix}(Γ, K ⇒ L)⊢A: G[d_{K⇒L}] ⇒ H \\ (Γ, K ⇒ L)⊢φ_{K⇒L}^{H}∘((λ_{K⇒L}.(A))[d_{K⇒L}]) = A: G[d_{K⇒L}] ⇒ H \end{matrix} (ETM10)
\begin{matrix}Γ⊢B: G ⇒ Π_{K⇒L}.H \\ Γ⊢λ_{K⇒L}.(φ_{K⇒L}^{H}∘B[d_{K⇒L}]) = B: G ⇒ Π_{K⇒L}.H \end{matrix} (ETM11)
Γ⊢G: Type (Γ, K ⇒ L)⊢H: Type u: Δ → Γ
(Δ, K[u] ⇒ L[u])⊢ \begin{matrix}φ_{K⇒L}^{H}[≺u∘d_{K[u]⇒L[u]}, χ_{K[u]⇒L[u]}≻] = \\ φ_{K[u]⇒L[u]}^{H[≺u∘d_{_{K[u]}_{⇒}_{L[u]}},χ_{_{K[u]}_{⇒}_{L[u]}}≻]} \\ : (Π_{K⇒L}.H)[u] ⇒ H[≺u∘d_{K[u]⇒L[u]}, χ_{K[u]⇒L[u]}≻] \end{matrix}

(ETM12)

\begin{matrix}(Γ, K ⇒ L)⊢A: G ⇒ H[d_{K⇒L}] \\ Γ⊢ν_{K⇒L}.(A): Σ_{K⇒L}.G ⇒ H \end{matrix} (TM9)
(Γ, K ⇒ L)⊢G: Type

(Γ, K ⇒ L)⊢ψ_{K⇒L}^{G}: G ⇒ (Σ_{K⇒L}.G)[d_{K⇒L}] (TM10)

\begin{matrix}(Γ, K ⇒ L)⊢A: G ⇒ H[d_{K⇒L}] \\ (Γ, K ⇒ L)⊢(ν_{K⇒L}.(A))[d_{K⇒L}]∘ψ_{K⇒L}^{G} = A: G ⇒ H[d_{K⇒L}] \end{matrix} (ETM13)
\begin{matrix}Γ⊢B: Σ_{K⇒L}.G ⇒ H \\ Γ⊢ν_{K⇒L}.(B[d_{K⇒L}]∘ψ_{K⇒L}^{G}) = B: Σ_{K⇒L}.G ⇒ H \end{matrix} (ETM14)
(Γ, K ⇒ L)⊢G: Type Γ⊢H: Type u: Γ → Δ
(Δ, K[u] ⇒ L[u])⊢ \begin{matrix}ψ_{K⇒L}^{G}[≺u∘d_{K[u]⇒L[u]}, χ_{K[u]⇒L[u]}≻] = \\ ψ_{K[u]⇒L[u]}^{G[≺u∘d_{_{K[u]}_{⇒}_{L[u]}},χ_{_{K[u]}_{⇒}_{L[u]}}≻]} \\ : G[≺u∘d_{K[u]⇒L[u]}, χ_{K[u]⇒L[u]}≻] ⇒ (Σ_{K⇒L}.G)[u] \end{matrix}

(ETM15)

The rule (TM1) is called an introduction rule for C. The associated judgement J_{C}^{T} is also called an introduction rule.

Intuitively, a term Γ⊢A: K ⇒ L corresponds to a morphisms of E_{Γ} as follows.

a T F theory T  p: E ^{}B
(TM2)  id_{K}  id_{K}: K → K ∈ E_{Γ}
(TM3)  B∘A  BA: K → G ∈ E_{Γ}
(TM4)  !_{K}  !_{K}: K → 1 ∈ E_{Γ}
(TM5)  A[u]  A[u]: K[u] → L[u] ∈ E_{Δ}
(TM6)  χ_{K⇒L}  χ_{Γ,KL}: K[d_{Γ,KL}] → L[d_{Γ,KL}] ∈ E_{Hom_{Γ}(K,L)}

(TM7)−(T M10) See below. With (ETM4), each fibre E_{Γ} has a terminal 1[!_{Γ}]. In fact, a terminal in the fibre E_{1} is sufficient because it is preserved by (−)[!_{Γ}]. (ETM 5) and (ETM6) show that p splits. (ETM 7) and (ETM 8) express the functoriality of (−)[u]: E_{Γ} → E_{Δ}. (ETM9) characterises χ_{K⇒L} as a generic morphism in the fibre E_{Hom_{Γ}(K,L)}.

λ_{K⇒L}.(A) introduced with (TM7) represents the transposition of a morphism

A: G[d_{Γ,KL}] → H ∈ E_{Hom_{Γ}(K,L)}

across the adjunction (−)[d_{Γ,KL}] ⊣ Π_{KL}. (ETM10) and (ETM11) show the bijection λ_{K⇒L}.(−) with ψ_{K⇒L}^{H} being the H-component of the counit. (ETM12) is part of the Beck-Chevalley condition for Π_{KL}.

(TM9)-(ETM15) are the duals of (TM7)-(ETM12). The term ν_{K⇒L}.(A) in (TM9) represents the transposition of a morphism A across the adjunction Σ_{KL} ⊣ (−)[d_{Γ,KL}]. The term ψ_{K⇒L}^{G} corresponds to the unit.

In the special case of p = p_{Set} : Fam(Set) ^{}Set, this can be explained as follows. Contexts are sets of tuples of functions, context mappings are maps, types are families of sets, and reindexing is that of families of sets. Then, a well-formed term Γ⊢A: K ⇒ L is given as a family of functions indexed by Γ. Each component function A_{γ} (γ ∈ Γ) maps the elements of K_{γ} to those of L_{γ}.

A generic term χ_{K⇒L} introduced with (TM6) is interpreted by

(χ_{K⇒L})_{(γ,A)} = A for all (γ, A) ∈ (Γ, K ⇒ L).

In (TM7), the last slot K ⇒ L is a “dummy” slot for the domain type G[d_{K⇒L}] of A. For such a generalised term A, λ abstraction λ_{K⇒L}.(A) is, in the case of p = p_{Set}, the family of maps (λ_{K⇒L}.(A))_{γ}: G_{γ} ^{}(Π_{K⇒L}.H)_{γ}, sending g to (A_{(γ,B)}g)_{(B:K_{γ}→L_{γ})}. This coincides with usual λ abstraction when G = 1[!_{Γ}]. The term φ_{K⇒L}^{H} is the family of evaluation map (φ_{K⇒L}^{H})_{(γ,A)}: (Π_{K⇒L}.H)_{γ} ^{}H_{(γ,A)}, sending f to f_{A}. With this interpretation of φ_{K⇒L}^{H}, (ETM 10) and (ETM11) correspond to beta and eta conversion rules, respectively.

In T F, dependent coproduct types are dual to dependent product types. (TM9) introduces its ν abstraction, which is dual to λ abstraction. In the case of p = p_{Set}, it is the family of maps (ν_{K⇒L}.(A))_{γ}: (Σ_{K⇒L}.G)_{γ} ^{}H_{γ}, sending (B, g) to A_{(γ,B)}(g). This is a generalised case expression which selects a map depending on the first component of its argument. The term ψ_{K⇒L}^{G} in (T M10) corresponds to the injection (ψ_{K⇒L}^{G})_{(γ,A)}: G_{(γ,A)} ^{}(Σ_{K⇒L}.G)_{γ}, sending g to (A, g).

Axioms

Definition 5.3.2. The following are inference rules of T.

Γ⊢H: Type Γ⊢H′: Type Γ⊢H = H′: Type (ETY6) (Γ⊢H = H′: Type ∈ Ax_{T})
\begin{matrix}Γ⊢A: K ⇒ L & Γ⊢A: K ⇒ L \\ Γ⊢A = A′: K ⇒ L \end{matrix} (ETM16) (Γ⊢A = A′: K ⇒ L ∈ Ax_{T})

General properties of equalities

Definition 5.3.2. (Continued, sketch.) Besides, there are the inference rules of T that express the following.

- (reflexivity, symmetry, transitivity) rules The reflexivity, symmetry, and transitivity of equality.

- (replacement) rules Well-formedness and typing of expressions are preserved by the replacement of equal types.

- (congruence) rules Type equality is compatible with Π,Σ type formation and λ,ν abstraction.

(End of Definition 5.3.2.)

The explicit forms of these rules are omitted as they are easily understood by analogy with the λP1’s rules.

We write equations of T F in the usual style for the sake of readability, omitting the context.

5.3.2 Interpretations between theories in T F

Given two theories T and T′ in T F, an interpretation from T to T′ corresponds to a fibred 1-cell between two split locally small fibrations that preserves splitting and the choice of Hom_{−}(−, −).

Definition 5.3.3. Given two theories T and T′ in T F, a preinterpretation I(−) from T to T′ is a map which assigns to each well-formed expression of T a possibly not well-formed expression of T′ and satisfying the following conditions. We follow the notation in Section 5.3.1.

\begin{matrix}(C1) & I(()) = () \\ (C2) & I((Γ, K ⇒ L)) = (I(Γ), I(K) ⇒ I(L)) \end{matrix}

(CM1) I(id_{)}Γ = id_{I(Γ)}
(CM2) I(u∘v) = I(u)∘I(v)
(CM3) I(!_{Γ}) = !_{I(Γ)}
(CM4) I(d_{K⇒L}) = d_{I(K)⇒I(L)}
(CM5) I(≺u, A≻) = ≺I(u), I(A)≻
(TY1) I(1) = 1
(TY3) I(K[u]) = I(K)[I(u)]
(TY4) I(Π_{K⇒L}.H) = Π_{I(K)⇒I(L)}.I(H)
(TY5) I(Σ_{K⇒L}.G) = Σ_{I(K)⇒I(L)}.I(G)
(TM2) I(id_{K}) = id_{I(K)}
(TM3) I(B∘A) = I(B)∘I(A)
(TM4) I(!_{K}) = !_{I(K)}
(TM5) I(A[u]) = I(A)[I(u)]
(TM6) I(χ_{K⇒L}) = χ_{I(K)⇒I(L)}
(TM7) I(λ_{K⇒L}.(A)) = λ_{I(K)⇒I(L)}.(I(A))
(TM8) I(φ_{K⇒L}^{H}) = φ_{I(K)⇒I(L)}^{I(H)}
(TM9) I(ν_{K⇒L}.(B)) = ν_{I(K)⇒I(L)}.(I(B))
(TM10) I(ψ_{K⇒L}^{G}) = ψ_{I(K)⇒I(L)}^{I(G)}

An interpretation is a preinterpretation that sends every introduction rule and axiom of T to a derivable judgement of T′.

This definition makes sense because the interpretation of any well-formed expression of T is indeed well-formed in T′. Moreover, the following is the case.

Lemma 5.3.4. Let I(−) be an interpretation from a T F theory T to T′. For every derivable judgement J of T, I(J) is also derivable in T′.

Proof By induction on derivations in T.

Type theory and fibrations 2

6.1 Introduction

In this chapter, we establish the connection between the four traditional type systems introduced in the previous chapter and our T F. Particularly, we show two variants of T F are equivalent to wML and ML, respectively. These are instances of the correspondence between categorical structures and type systems; in the literature, one can find a long list of other instances [2,3,41,42,43,44,46,51, 55,72,74,83]. Since the four type systems studied here represent, with appropriate constants and axioms, a wide range of type theories, these connection can be used to exploit categorical methods in an application of these type theories.

The connection is studied in terms of translations between these type systems and T F. In one direction, this provides a categorical semantics for these type systems in fibrewise locally small fibrations. Categorical semantics of dependent type systems has been extensively studied. Our contribution in this area is the use of local smallness and the detailed, syntactic exposition of connection in both direction.

Categorical structures used in the literature to model type dependency are: contextual categories / categories with attributes [13,14,82], locally cartesian closed categories [73], categories with display-maps or relatively cartesian closed categories [36,86], D-categories [22], comprehensive categories [61], comprehension categories [37,38], the last one being most standard by now. These are all (though it is implicit in some earlier works) fibrations with extra structure that models the context comprehension rule (context2) in Definition 5.2.4.

Local smallness is yet another such structure on fibrations and there are close connections with the above structures. Its advantage over the others is that it is already a well-established concept in category theory, particularly fundamental from the viewpoint of fibrations as parameterised categories [15,6,8,79,78]. In a locally small fibration, one can specify base objects that play a role of Hom sets of ordinary categories (Example 4.6.4).

This chapter is organised as follows. First, in Section 6.2, we show how type dependency is modelled by locally small fibrations by introducing the notion of translations from GA theories to T F^{−} theories, T F^{−} being a subsystem of T F without irrelevant Π and Σ. Then, Section 6.3 shows T F^{−} is a conservative extension of GA. Given a GA-theory T_{G}, we construct a T F^{−}-theory F(T_{G}) with a faithful translation from T_{G} to F(T_{G}). Section 6.4 considers dependent product types of λP1 and T F λ (a subsystem without Σ). Product types allow a translation of generalised terms, so we have translations in both direction between λP1 and T F λ. However the notion of generalised term in T F and that of functions in λP1 are subtly different. So, in order to establish equivalences, Section 6.5 studies a restricted class of T F theories where these two notions coincide. The restricting condition is most conveniently expressed with weak dependent coproducts, so we define a system T F ι which is T F with appropriate extra axioms. Given this, Section 6.6 establishes the equivalence between T F ι theories and wML theories. For the stronger notion of dependent coproduct, one further needs to restrict T F ι theories with a condition to establish the equivalence. Section 6.7 considers the condition and proves the equivalence. To keep the chapter concise, some proofs involving a detailed calculation are separately shown in Appendix A.

6.2 Translation from GA to T F

In this section, we start investigating relations between T F and type systems with usual notation by introducing the notion of translations between theories of different type systems. In this section we focus on the point that local smallness structure gives the essence of type dependency, studying the translation of GA theories into T F theories. For this section, we do not need Π and Σ types of T F and only consider the subsystem without them, which we call T F^{−}.

We define a global element (or simply, element) of a type K to be a term from 1 to K. A translation [[−]]_{T F}_{−} associates a well-formed term A: K of a GA theory with a global element [[A]]: 1 ⇒ [[K]] of a T F^{−} theory. The subscript T F^{−} in [[−]]_{T F}_{−} may be omitted if it is clear from the context.

Definition 6.2.1. A map [[−]]_{T F}_{−} from the set of well-formed expressions paired with contexts of a GA theory T_{G} to the set of possibly not well-formed expressions of a T F^{−} theory T_{F} is a pretranslation if and only if it satisfies the conditions listed below. The notation is the same as that in Definition 5.2.4 and 5.2.8.

(context1) [[( )]] = ( )
(context2) [[x⃗: K⃗, x_{n+1}: K_{n+1}]] = ([[x⃗: K⃗]], 1 ⇒ [[K_{n+1}]]^{x⃗:K⃗})
(assumption) [[x_{n+1}]]^{x⃗:K⃗,x_{n+1}:K_{n+1}} = χ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}
(weakening1) [[H]]^{x⃗:K⃗,x_{n+1}:K_{n+1}} = [[H]]^{x⃗:K⃗}[d_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}]
(weakening2) [[A]]^{x⃗:K⃗,x_{n+1}:K_{n+1}} = [[A]]^{x⃗:K⃗}[d_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}]
(subst1) [[F(A⃗)]]^{y⃗:G⃗} = [[F(x⃗)]]^{x⃗:K⃗}[u_{n}]
(subst2) [[C(A⃗)]]^{y⃗:G⃗} = [[C(x⃗)]]^{x⃗:K⃗}[u_{n}]
(where u_{0} = !_{[[_{y⃗:G⃗}]]}, u_{i} = ≺u_{i−1}, [[A_{i}]]^{y⃗:G⃗}≻ (1 ≤ i ≤ n).)

A translation is a pretranslation that sends every introduction rule and axiom of T_{G} to a derivable judgement in T_{F}.

Note that [[−]]_{T F}_{−} forgets variable names in a way similar to a translation into de Bruijn notation. Generic terms re-indexed along d’s, χ, χ[d], χ[d∘d], ⋯, play the role of de Bruijn indices 0, 1, 2,· · ·. The context mapping u_{n} in the condition (subst1) and (subst2) can be written explicitly as

u_{n} = ≺≺≺ ⋯ ≺≺!_{[[_{y⃗:G⃗}]]}, [[A_{1}]]^{y⃗:G⃗}≻, [[A_{2}]]^{y⃗:G⃗}≻, ⋯ ≻, [[A_{n−1}]]^{y⃗:G⃗}≻, [[A_{n}]]^{y⃗:G⃗}≻.

In other words, a tuple of terms is translated to a context mapping.

A translation preserves well-formedness and equality of expressions. The following theorem shows this soundness property of a translation.

Proposition 6.2.2. Let [[−]]_{T F}_{−} be a translation from a GA theory T_{G} to a T F^{−} theory T_{F}. If x⃗: K⃗ Context, x⃗: K⃗⊢H: Type, x⃗: K⃗⊢A: H, x⃗: K⃗⊢H = H′: Type, x⃗: K⃗⊢A = A′: H are derivable judgements of T_{G}, then

[[Γ]] Context

[[x⃗: K⃗]]⊢[[H]]^{x⃗:K⃗}: Type [[x⃗: K⃗]]⊢[[A]]^{x⃗:K⃗}: 1 ⇒ [[H]]^{x⃗:K⃗} [[x⃗: K⃗]]⊢[[H]]^{x⃗:K⃗} = [[H′]]^{x⃗:K⃗}: Type [[x⃗: K⃗]]⊢[[A]]^{x⃗:K⃗} = [[A′]]^{x⃗:K⃗}: 1 ⇒ H

are also derivable in T_{F}.

Proof See the proof of Proposition 6.4.2 in Appendix A.

6.3 Construction of F(T_{G})

With these translations, T F^{−} is shown to be a conservative extension of GA. For any GA theory T_{G}, there is a T F theory F(T_{G}) into which T_{G} can be embedded faithfully, i.e., there is a translation from T_{G} to F(T_{G}) such that if the translations of two terms of T_{G} are equal in F(T_{G}) then they are already equal in T_{G}. Moreover, F(T_{G}) is universal among the T F^{−} theories into which T_{G} can be translated. We fix a theory T_{G} in the rest of this section.

Definition 6.3.1. The T F^{−} theory F(T_{G}) and the canonical translation [[−]]_{F(T_{G})} from T_{G} to F(T_{G}) are mutually defined by • for each constant type symbol F of T_{G}, F̃ is a constant type symbol of F(T_{G}).

• for each constant term symbol F of T_{G}, C̃ is a constant term symbol of F(T_{G}).

• the canonical translation [[−]]_{F(T_{G})} from T_{G} to F(T_{G}) is given by [[F]]_{F(T_{G})} = F̃ and [[C]]_{F(T_{G})} = C̃.

• the theory F(T_{G}) is specified with the introduction rules and axioms

– for each introduction rule x⃗: K⃗⊢F: Type(x⃗) of T_{G}, [[x⃗: K⃗]]_{F(T_{G})}⊢F̃: Type is an introduction rule of F(T_{G}).

– for each introduction rule x⃗: K⃗⊢C(x⃗): H of T_{G}, [[x⃗: K⃗]]_{F(T_{G})}⊢C̃: 1 ⇒ [[H]]_{F(T_{G})} is an introduction rule of F(T_{G}).

– for each axiom x⃗: K⃗⊢H = H′: Type or x⃗: K⃗⊢A = A′: H of T_{G},

[[x⃗: K⃗]]_{F(T_{G})}⊢[[H]]_{F(T_{G})} = [[H′]]_{F(T_{G})}: Type

or

[[x⃗: K⃗]]_{F(T_{G})}⊢[[A]]_{F(T_{G})} = [[A′]]_{F(T_{G})}: 1 ⇒ [[H]]_{F(T_{G})}

is an axiom of F(T_{G}).

It is proved by induction on derivations in T_{G} that this definition indeed defines a T F^{−} theory.

Proposition 6.3.2. The canonical translation [[−]]_{F(T_{G})} from T_{G} to F(T_{G}) is faithful, i.e., given x⃗: K⃗⊢A: H and x⃗: K⃗⊢A′: H, if

[[x⃗: K⃗]]_{F(T_{G})}⊢[[A]]_{F(T_{G})} = [[A′]]_{F(T_{G})}: 1 ⇒ [[H]]_{F(T_{G})}

is derivable in F(T_{G}) then x⃗: K⃗⊢A = A′: H is already derivable in T_{G}.

Proof See the proof of Proposition 6.4.4 in Appendix A.

Theorem 6.3.3. Given any translation [[−]]_{T F}_{−} from a GA theory T_{G} to a T F^{−} theory T_{F}, there is a unique translation I(−) from F(T_{G}) to T_{F} such that the iterated translation I([[−]]_{F(T_{G})}) from T_{G} to T_{F} via F(T_{G}) agrees with the given [[−]]_{T F}_{−}.

Proof We define a pretranslation I(−) from F(T_{G}) to T_{F} by specifying its values at the constant symbols of F(T_{G}) by

• each constant type symbol F̃ of F(T_{G}) introduced by [[x⃗: K⃗]]_{F(T_{G})}⊢F̃: Type is sent to [[F]]_{T F}_{−}.

• each constant term symbol C̃ of F(T_{G}) introduced by [[x⃗: K⃗]]_{F(T_{G})}⊢C̃: 1 ⇒ [[H]]_{F(T_{G})} is sent to [[C]]_{T F}_{−}.

By definition of I(−) and [[−]]_{F(T_{G})}, this composite evidently agrees with [[−]]_{T F}_{−}. Since [[−]]_{T F}_{−} is a translation,

I([[x⃗: K⃗]]_{F(T_{G})})⊢I(F̃): Type
I([[x⃗: K⃗]]_{F(T_{G})})⊢I(C̃): 1 ⇒ I([[H]]_{F(T_{G})})

are derivable in T_{F}. So I(−) is a translation. The uniqueness part is a consequence of the fact that a translation is determined by its values at constant symbols.

The above theorem can be seen as a universal property of T_{G} with respect to F(T_{G}). Then a natural question arises: does every T F^{−} theory has such a universal GA theory? If so, one can conclude that T F^{−} and GA are equivalent type systems, but this is not the case. We will come back to this question in Section 6.6.

6.4 Translations between T F λ and λP1

In this section, we extend [[−]]_{T F}_{−} to include dependent product types of λP1. We restrict T F to a subsystem T F λ without dependent coproducts and denote new translations by [[−]]_{T F λ}. With dependent products, one can also define translations in the other direction, i.e., from T F λ theories to λP1 theories.

6.4.1 From λP1 Theories to T F λ Theories

Definition 6.4.1. A map [[−]]_{T F λ} from the set of well-formed expressions of a λP1 theory T_{G} to the set of possibly not well-formed expressions of a T F λ theory T_{F} is a pretranslation if it satisfies the conditions listed in Definition 6.2.1 plus the following.

\begin{matrix}(ΠF) & [[Πx_{n+1}: K_{n+1}.H]]^{x⃗:K⃗} = Π_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}.[[H]]^{x⃗:K⃗,x_{n+1}:K_{n+1}} \\ (ΠI) & [[λx_{n+1}: K_{n+1}.(A)]]^{x⃗:K⃗} = λ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}.([[A]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}) \end{matrix}

(ΠE) [[BC]]^{x⃗:K⃗} = φ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}^{[[H]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}}[≺id_{[[_{x⃗:K⃗}]]}, [[C]]^{x⃗:K⃗}≻]∘[[B]]^{x⃗:K⃗}

A translation is a pretranslation that sends every introduction rule and axioms of T_{G} to a derivable judgement of T_{F}.

The properties of translations [[−]]_{T F}_{−} given in Section 6.3 (soundness, construction of F(T_{G}), conservativeness of canonical translations) extend to this definition. The proofs are in Appendix A.

Proposition 6.4.2. Proposition 6.2.2 holds with T F^{−}, [[−]]_{T F}_{−}, and GA replaced by T F λ, [[−]]_{T F λ}, and λP1, respectively.

Definition 6.4.3. Given a λP1 theory T_{G}, the T F λ theory F(T_{G}) defined in the same way as in Definition 6.3.1.

Proposition 6.4.4. Proposition 6.3.2 holds with T F^{−}, [[−]]_{T F}_{−}, and GA replaced by T F λ, [[−]]_{T F λ}, and λP1, respectively.

6.4.2 From T F λ Theories to λP1 Theories

Next, we define the notion of translations from T F λ theories to λP1 theories. This cannot be done for GA theories since the translation of generalised terms requires function types, which is a special case of dependent product types.

Definition 6.4.5. A map [[−]]_{λP1} from the set of well-formed expressions of a T F λ theory T_{F} to the set of possibly not well-formed expressions of a λP1 theory T_{G} is a pretranslation if it satisfies the following conditions. The subscript λP1 may be omitted when it is obvious. We adopt the notation in Definition 5.3.2 with the following addition:

\begin{aligned}Γ & = & (K_{1} ⇒ L_{1}, K_{2} ⇒ L_{2}, ⋯ K_{n} ⇒ L_{n}), & [[u]] & = & (B_{1}, ⋯, B_{n}), \\ Δ & = & (G_{1} ⇒ H_{1}, G_{2} ⇒ H_{2}, ⋯, G_{m} ⇒ H_{m}), & [[v]] & = & (C_{1}, ⋯, C_{m}). \end{aligned}

\begin{matrix}(C1) & [[( )]] = ( ) \\ (C2) & [[(Γ, K ⇒ L)]] = ([[Γ]], v_{KL}: ([[K]] ⊃ [[L]])) \end{matrix}

(CM1) [[id_{Γ}]] = (v_{K_{1}L_{1}}, v_{K_{2}L_{2}}, ⋯, v_{K_{n}L_{n}})
(CM2) [[u∘v]] = (B_{1}[v_{G_{1}H_{1}}/C_{1}, ⋯, v_{G_{m}H_{m}}/C_{m}],
⋯, B_{n}[v_{G_{1}H_{1}}/C_{1}, ⋯, v_{G_{m}H_{m}}/C_{m}])
(CM3) [[!_{Γ}]] = ( )
(CM4) [[d_{K⇒L}]] = (v_{K_{1}L_{1}}, ⋯, v_{K_{n}L_{n}})
(CM5) [[≺u, A≻]] = ([[u]], [[A]])
(TY1) [[1]] = 1
(TY3) [[H[u]]] = [[H]][v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}]
(TY4) [[Π_{K⇒L}.H]] = Πx: ([[K]] ⊃ [[L]]).[[H]][v_{KL}/x]
(TM2) [[id_{K} ]] = λx: [[K]].(x)
(TM3) [[B∘A]] = λx: [[K]].([[B]]([[A]](x)))
(TM4) [[!_{K} ]] = λx: [[K]].(∗)

\begin{matrix}(TM5) & [[χ_{K⇒L}]] = v_{KL} \\ (TM6) & [[A[u]]] = [[A]][v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}] \end{matrix}

\begin{matrix}(TM7) & [[λ_{K⇒L}.(A)]] = λx: [[G]].(λz: ([[K]] ⊃ [[L]]).([[A]][v_{KL}/z]x)) \\ (TM8) & [[φ_{K⇒L}^{H}]] = λx: [[Π_{K⇒L}.H]].((x v_{KL})), \end{matrix}

where v_{KL} is a variable symbol uniquely assigned to the pair (K, L), and x, z are fresh variables other than the v_{KL}’s.

A translation is A pretranslation that sends every introduction rule and axiom of T_{F} to a derivable judgement of T_{G}.

A pretranslation [[−]]_{λP1} is determined by its value at constant types and terms of T_{F}.

A well-formed context of T_{F} is translated to a well-formed context of T_{G} replacing each slot K ⇒ L with a declaration v_{KL}: [[K]]⊃[[L]] of a canonically named variable.

A well-formed context mapping u: Δ → Γ of T_{F} is translated to a tuple (B_{1}, B_{2}, ⋯, B_{n}) of well-formed terms of T_{G}. Each term B_{i} has free variables declared in [[Δ]] and is of type [[K_{i}]]⊃[[L_{i}]]. With substitution of closed terms for free variables in the B_{i}’s, [[u]] can be regarded as a map sending a tuple of closed terms of type [[G_{1}]]⊃[[H_{1}]], ⋯, [[G_{m}]]⊃[[H_{m}]] to a tuple of closed terms of type [[K_{1}]]⊃[[L_{1}]], ⋯, [[K_{n}]]⊃[[L_{n}]].

Re-indexing operations (−)[u] are translated by the substitutions of terms for free variables. When u = d_{K⇒L} for some K and L, translations [[H[d_{K⇒L}]]] and [[H]] are the same type expressions in different contexts.

Proposition 6.4.6. Let [[−]]_{λP1} be a translation from a T F λ theory T_{F} to a GA theory T_{G}. If Γ Context, Γ⊢H: Type, Γ⊢A: K ⇒ L, u = u′: Δ → Γ, Γ⊢H = H′: Type, and Γ⊢A = A′: K ⇒ L are derivable judgements of T_{F}, then

[[Γ]] Context [[Γ]]⊢[[H]]: Type [[Γ]]⊢[[A]]: ([[K]] ⊃ [[L]])

Δ⊢B_{i} = B′_{i}: [[K_{i}]][v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{i−1}L_{i−1}}/B_{i−1}] (1 ≤ i ≤ n)

[[Γ]]⊢[[H]] = [[H′]]: Type [[Γ]]⊢[[A]] = [[A′]]: [[K]]⊃[[L]]

are also derivable in T_{G}, respectively, where (K_{1} ⇒ L_{1}, ⋯, K_{n} ⇒ L_{n}) = Γ, (B_{1}, ⋯, B_{n}) = [[u]], and (B′_{1}, ⋯, B′_{1}) = [[u′]].

Proof By induction on derivations. See Appendix A.

6.5 T F ι theories

Although we have translations between T F λ theories and λP1 theories in both directions, these are not subtle enough to establish the equivalence of the two type systems. In the previous section, we used functions (terms of dependent types) of λP1 to translate generalised terms of T F λ. However, when we regard generalised terms as functions, and composition of global elements as application, a T F λ theory need not satisfy the condition equivalent to the functional completeness of λP1. In any λP1 theory, application A ↦ Ax gives the bijection A ↔ B in

{Γ⊢A: K⊃L \atop Γ, x: K⊢B: L,} ≅

while in a T F λ theory the composition A ↦ A ∘ χ_{1⇒K} need not give a bijection A ↔ B in

{Γ⊢A: K ⇒ L \atop Γ, 1 ⇒ K⊢B: 1 ⇒ L[d_{1⇒K}].} ≅

A counterexample is given by considering a T F λ theory that corresponds to p_{C}: Fam(C) ^{}Set where C(1, −) is not fully faithful.

Therefore, to establish the equivalence between a T F -style type system and a λP1-style system in later sections, one needs to restrict attention to T F theories where this bijection exists. The simplest way to stipulate this condition, without adding a new operation on terms, is to move up to type systems with dependent coproducts and add new constants to express the required axiom.

First, note that in any wML theory T, the terms of type K are in one-to-one correspondence with those of the type Σx: K.1 with the bijections A: K ↦ ⟨A, ∗⟩: Σx: K.1 and B: Σx: K.1 ↦ let⟨x,y⟩=B in x: K.

The corresponding property of dependent coproduct types of a T F theory would be the assertion that, for every type Γ⊢K: Type, the term ν_{1⇒K}.(χ_{1⇒K}) of type Γ⊢ν_{1⇒K}.(χ_{1⇒K}): Σ_{1⇒K}.1 ⇒ K has the inverse. However, it is not the case in general. We stipulate ν_{1⇒K}.(χ_{1⇒K}) to be an isomorphism introducing a constant ι_{K}. In other words, we require every type K to be isomorphic to a certain coproduct of 1.

Definition 6.5.1. A T F ι theory is defined as in Definition 5.3.2 with the following additional rules.

\begin{matrix}Γ⊢K: Type \\ Γ⊢ι_{K}: K ⇒ Σ_{1⇒K}.1 \end{matrix} (TM11)
Γ⊢K: Type

Γ⊢ν_{1⇒K}.(χ_{1⇒K})∘ι_{K} = id_{K}: K ⇒ K (ETM16)

Γ⊢K: Type

Γ⊢ι_{K}∘ν_{1⇒K}.(χ_{1⇒K}) = id_{Σ_{1⇒K}.1}: Σ_{1⇒K}.1 ⇒ Σ_{1⇒K}.1 (ETM17)

With the constant ι_{K}, one has the desired bijection as follows.

Lemma 6.5.2. In a theory T in T F ι, generalised terms Γ⊢A: K ⇒ L, (Γ, 1 ⇒ K)⊢B: 1 ⇒ L[d_{1⇒K}], and Γ⊢C: 1 ⇒ Π_{1⇒K}.L[d_{1⇒K}] are in bijection with each other.

Proof one has the following natural bijection of terms.

\begin{matrix}\begin{matrix}Γ⊢A: K ⇒ L \\ Γ⊢A′: Σ_{1⇒K}.1 ⇒ L \end{matrix} & ≅ \\ (Γ, 1 ⇒ K)⊢B: 1 ⇒ L[d_{1⇒K}] \end{matrix} ≅

Γ⊢C: 1 ⇒ Π_{1⇒K}.L[d_{1⇒K}] ≅

We name the explicit expressions for these bijections as follows. For each K, L, A, B, and C such that Γ⊢K, L: Type, Γ⊢A: K ⇒ L, (Γ, 1 ⇒ K)⊢B: 1 ⇒ L[d_{1⇒K}], and Γ⊢C: 1 ⇒ Π_{1⇒K}.L[d_{1⇒K}], the following are defined.

Γ⊢K⊃L ≡ Π_{1⇒K}.L[d_{1⇒K}]: Type
(Γ, 1 ⇒ K)⊢uncurr_{K}(A) ≡ A[d_{1⇒K}]∘χ_{1⇒K}: 1 ⇒ L[d_{1⇒K}]
Γ⊢curr_{K}(B) ≡ ν_{1⇒K}.(B)∘ι_{K}: K ⇒ L
Γ⊢code_{K⇒L}(A) ≡ λ_{1⇒K}.(uncurr_{K}(A)): 1 ⇒ K⊃L
(Γ, 1 ⇒ K)⊢λ_{1⇒K}^{−1}(C) ≡ φ_{1⇒K}^{L}∘C[d_{1⇒K}]: 1 ⇒ L[d_{1⇒K}]
Γ⊢decode_{K⇒L}(C) ≡ curr_{K}(λ_{1⇒K}^{−1}(C)): K ⇒ L

Iterating application of these bijections, one can replace all expressions of generalised terms with global elements.

Definition 6.5.3. A well-formed expression E of a T F ι theory T_{F} is hereditarily elementary (h.e., for short) if a structural judgement for E has a derivation in T_{F} such that all the slots of all the contexts appearing in the derivation is of the form 1 ⇒ K for some K.

Note that K must also be h.e.. Iterating uncurr_{−}(−), one has

Theorem 6.5.4. (Definition-Theorem) Let T_{F} be a T F ι theory whose constant types and terms are all h.e.. Then, for each well-formed expression E, one can define an h.e. expression E^{+} such that the mapping E ↦ E^{+} is bijective in the following sense.

• For each well-formed expression E of T_{F}, its h.e. form E^{+} has the following

structural judgements.

– For Γ Context, Γ^{+} Context.

– For u: Δ → Γ, u^{+}: Δ^{+} → Γ^{+}.

– For Γ⊢H: Type, Γ^{+}⊢H^{+}: Type.

– For Γ⊢A: K ⇒ L, Γ^{+}⊢A^{+}: 1 ⇒ K^{+}⊃L^{+}.

• The map A ↦ A^{+} gives a bijection between terms A of type Γ⊢A: K ⇒ L and B of type Γ⊢B: 1 ⇒ K^{+}⊃L^{+} with inverse

B ↦ B^{−} ≡ δ_{L}∘decode_{K^{+}⇒L^{+}}(B)[α_{Γ}]∘γ_{K}.

• For each well-formed context Γ, there are context mappings α_{Γ}: Γ → Γ^{+} and β_{Γ}: Γ^{+} → Γ, satisfying α_{Γ}∘β_{Γ} = id_{Γ^{+}}: Γ^{+} → Γ^{+} and β_{Γ}∘α_{Γ} = id_{Γ}: Γ → Γ.

• For each context mapping u: Δ → Γ, u^{+}∘α_{Δ} = α_{Γ}∘u: Δ → Γ^{+} holds.

• For each type Γ⊢K: Type, there are terms Γ⊢γ_{K}: K ⇒ K^{+}[α_{Γ}] and Γ⊢δ_{K}: K^{+}[α_{Γ}] ⇒ K, satisfying Γ⊢γ_{K}∘δ_{K} = id_{K^{+}[α_{Γ}]}: K^{+}[α_{Γ}] ⇒ K^{+}[α_{Γ}] and Γ⊢δ_{K}∘γ_{K} = id_{K}: K ⇒ K.

For the definition of E^{+}, see Appendix A. Then, one has:

Proposition 6.5.5. If all constant types and terms contained in a well-formed expression E are hereditarily elementary then so is E^{+}.

The bijection A ↔ B in Lemma 6.5.2 gives another characterisation of T F ι theories among all T F theories.

Proposition 6.5.6. In any T F ι theory T_{F}, there is a natural bijection between terms Γ⊢A: K ⇒ L and context mappings u: (Γ, 1 ⇒ K) → (Γ, 1 ⇒ L) such that d_{1⇒L}∘u = d_{1⇒K}. Conversely, any T F theory T_{F} having this natural bijection A ↔ u also has the inverse of ν_{1⇒K}.(χ_{1⇒K}).

Proof See Appendix A.

This connects Jacobs’ full comprehension categories ([37] and Section 4.10 of [38]) and T F ι theories. As in the remark after Proposition 4.6.7, the functor Hom(1, −) that sends K to d_{1⇒K} gives rise to a comprehension category. The natural bijection shows fully faithfulness of comprehension categories that correspond to T F ι theories.

6.6 Equivalence between T F ι and wML

Having restricted T F theories to T F ι theories, we can now show the equivalence between T F ι and wML. First, the notion of translations given in Section 6.4 is extended to include dependent coproduct types. Then the construction F(T_{G})(−) in Section 6.3 can be extended to the wML case and proved to be a part of an adjoint equivalence between the category of T F ι theories and that of wML theories.

6.6.1 Translations between T F ι and wML

Definition 6.6.1. A pretranslation from a wML theory T_{w} to a T F ι theory T_{F} is a map [[−]]_{T F ι} from the set of well-formed expressions of T_{w} to the set of possibly not well-formed expressions of T_{F} which satisfies the conditions in Definition 6.4.1 and those listed below. We use the notation in Section 5.2.3.

(wΣF) [[Σx_{n+1}: K_{n+1}.G]]^{x⃗:K⃗} = Σ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}.[[G]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}
(wΣI) [[⟨A_{1}, A_{2}⟩]]^{x⃗:K⃗} = ψ_{1⇒K}^{G}[≺id_{[[_{x⃗:K⃗}]]}, [[A_{1}]]^{x⃗:K⃗}≻]∘[[A_{2}]]^{x⃗:K⃗}
(wΣE) [[let⟨x_{n+1},y⟩=A in B]]^{x⃗:K⃗}

= (ν_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}.(curr_{[[G]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}}([[B]]^{x⃗:K⃗,x_{n+1}:K_{n+1},y:G})))∘[[A]]^{x⃗:K⃗}

A translation is a pretranslation that sends every introduction rule to a h.e. judgement derivable in T_{F}.

Note that ι_{K} constant in curr_{−}(−) is needed to translate let⟨x,y⟩=A in B.

The additional condition for constant types and terms to be sent to h.e. types and constants is not so strong in view of Theorem 6.5.4. What we gain is the strictness of translations. The soundness of interpretation is proved as usual but requires complex calculations, relying on the bijection given in Lemma 6.5.2.

Proposition 6.6.2. If [[−]]_{T F ι} is a translation from wML theory T_{w} to T F ι theory T_{F}, all derivable judgements of T_{w} are translated to those of T_{F} by [[−]]_{T F ι}.

Proof See Appendix A.

Definition 6.6.3. A (pre)translation [[−]]_{wML} from a T F ι theory to a wML theory is a map that satisfies the conditions (C1)-(TM8) in Definition 6.4.2, plus the following condition.

(TY5) [[Σ_{K⇒L}.G]] = Σz: ([[K]] ⊃ [[L]]).[[G]][v_{KL}/z]
(TM9) [[ν_{K⇒L}.(A)]] = λz: [[Σ_{K⇒L}.G]].(let⟨x,y⟩=z in [[A]][v_{KL}/x]y)
(TM10) [[ψ_{K⇒L}^{G}]] = λy: [[G]].(⟨v_{KL}, y⟩)
(TM11) [[ι_{K} ]] = λz: [[K]].(⟨λw: 1.(z), ∗⟩)

Proposition 6.6.4. The soundness lemma 6.4.6 extends to T F ι theories.

6.6.2 Construction of F(T_{w})

Construction of F(T_{G}) for a GA theory T_{G} and the canonical translation from F(T_{G}) to T_{G} in Section 6.3 can be extended to the wML case. For wML theory T_{w}, the corresponding wML theory F(T_{w}) and the canonical translation [[−]]_{F(T_{w})} from T_{w} to F(T_{w}) are defined similarly to F(T_{G}) and [[−]]_{F(T_{G})}, respectively. Proposition 6.4.4 and Theorem 6.3.3 extends to the wML case. See Appendix A for the additional calculation.

Proposition 6.6.5. The canonical translation [[−]]_{F(T_{w})} from a wML theory T_{w} to F(T_{w}) is faithful.

Theorem 6.6.6. Given any translation [[−]]_{T F ι} from a wML theory T_{w} into a T F ι theory T_{F}, there is a unique interpretation I(−) from F(T_{w}) to T_{F} such that the composite translation I([[−]]_{F(T_{w})}) from T_{w} to T_{F} via F(T_{w}) agrees with the given [[−]]_{T F ι}.

6.6.3 Construction of G(T_{F})

The bijection in 6.5.2 between generalised terms and functions of global elements exactly characterises T F theories of the form F(T_{w}). This subsection answers the problem posed in the end of Section 6.3.3 with T F λ replaced by wML.

Theorem 6.6.7. Given a T F ι theory T_{F}, one can construct a wML theory G(T_{F}) and a canonical translation [[−]]_{G(T_{F})} from G(T_{F}) to T_{F} with the following universal property. For any T F ι theory T′_{F} and any translation [[−]]_{T F ι} from G(T_{F}) to T′_{F}, there is a unique interpretation I(−) from T_{F} to T′_{F} such that the composite I([[−]]_{G(T_{F})}) agrees with [[−]]_{T F ι}.

We only give the construction and interpretation, leaving the proof to Appendix A. In the following, a T F ι theory T_{F} is fixed.

Definition 6.6.8. The wML theory G(T_{F}) is defined by • for every h.e. type H of T_{F}, c_{H} is a constant type symbol of G(T_{F}).

• for every h.e. term A of T_{F}, c_{A} is a constant term symbol of G(T_{F}).

• the canonical translation [[−]]_{G(T_{F})} from expressions of G(T_{F}) to those of T_{F} is the translation which sends constant symbols c_{H} and c_{A} of G(T_{F}) onto H and A, respectively.

• for every h.e. type 1 ⇒ K_{1}, …, 1 ⇒ K_{n}⊢H: Type,

x_{1}: c_{K_{1}}, …, x_{n}: c_{K_{n}}⊢c_{H}(x⃗): Type

is an introduction rule of G(T_{F}).

• for every h.e. term 1 ⇒ K_{1}, …, 1 ⇒ K_{n}⊢A: 1 ⇒ H,

x_{1}: c_{K_{1}}, …, x_{n}: c_{K_{n}}⊢c_{A}(x⃗): c_{H}(x⃗)

is an introduction rule of G(T_{F}).

• the axioms of G(T_{F}) are the equality judgements of G(T_{F}) whose translations by [[−]]_{G(T_{F})} are derivable in T_{F}.

Definition 6.6.9. A preinterpretation I(−)_{T F ι} from G(T_{F}) to T′_{F} is specified relatively to [[−]]_{T F ι} by

• for every constant type F introduced as Γ⊢F: Type of T_{F}, I(F)_{T F ι} = [[c_{F^{+}} ]]_{T F ι}[α_{I(Γ)_{T F ι}}].

• for every constant term C introduced as Γ⊢C: K ⇒ L, I(C)_{T F ι} = ([[c_{C^{+}} ]]_{T F ι})^{−}.

By Theorem 6.5.4, I(−)_{T F ι} is a translation.

The theory G(T_{F}) has another universal property other than that of Theorem 6.6.7.

Theorem 6.6.10. For any wML theory T_{w} and any translation [[−]]_{T F ι} from T_{w} to T_{F}, there is a unique interpretation [[−]]_{wML} from T_{w} to G(T_{F}) such that [[[[−]]_{wML}]]_{G(T_{F})} agrees with [[−]]_{T F ι}.

Proof By definition, the value of [[−]]_{T F ι} is h.e.. Define I(H)_{T F ι} = c_{[[H]]_{T F ι}} etc.

6.6.4 The equivalence

Through the construction of G(T_{F}) and F(T_{w}), one can show that T F ι and wML are equivalent type systems.

Definition 6.6.11. The category T F ιCat (wMLCat) has T F ι (wML) theories as objects and interpretations between them as morphisms.

Lemma 6.6.12. Let T_{F} and T_{w} be a T F i theory and a wML theory, respectively. Then, there is a bijection between T F ιCat(F(T_{w}), T_{F}) and wMLCat(T_{w}, G(T_{F})).

Proof With Theorem 6.6.6 and 6.6.10, the following bijections are obtained.

F(T_{w}) → T_{F} ∈ wMLCat The translations from T_{w} to T_{F}

≅ (by Th. 6.6.6)

T_{w} → G(T_{F}) ∈ T F ιCat ≅ (by Th. 6.6.10)

One can naturally extend the construction F(−) to a functor from T F ιCat to wMLCat. The bijection of Lemma 6.6.12 exhibits an adjunction F(−) ⊣ G(−) between T F ιCat and wMLCat.

Proposition 6.6.13. Given a T F ι theory T_{F}, F(G(T_{F})) is isomorphic to T_{F}, that is, there are interpretations

\begin{matrix}I(−)_{T F ι}: F(G(T_{F})) → T_{F} ∈ T F ιCat \\ J(−): T_{F} → F(G(T_{F})) ∈ T F ιCat \end{matrix}

such that the composite interpretations I(J(−))_{T F ι} and J(I(−)_{T F ι}) agree with the identity interpretations on T_{F} and F(G(T_{F})), respectively. Similarly, for every wML theory T_{w}, G(F(T_{w})) is isomorphic to T_{w}.

Proof Let I(−)_{T F ι} be the counit of the adjunction F(−) ⊣ G(−). Namely, I(−)_{T F ι} is the unique interpretation given by Theorem 6.6.6 where we take [[−]]_{T F ι} to be the canonical translation [[−]]_{G(T_{F})} from G(T_{F}) to T_{F}. J(−) is given by Theorem 6.6.7 by replacing [[−]]_{T F ι} by the canonical translation [[−]]_{F(G(T_{F}))} from G(T_{F}) to F(G(T_{F})). Then, we have both I(J([[−]]_{G(T_{F})}))_{T F ι} = [[−]]_{G(T_{F})} and Id([[−]]_{G(T_{F})}) = [[−]]_{G(T_{F})} where Id(−) is the identity interpretation. By the uniqueness asserted by Theorem 6.6.7, I(J(−))_{T F ι} = Id(−). Similarly, J(I(−)_{T F ι}) = Id(−) can be shown using Theorem 6.6.10.

Therefore, we have:

Theorem 6.6.14. F(−) ⊣ G(−) defines an adjoint equivalence between T F ιCat and wMLCat.

6.7 Equivalence between T F ισ and ML

We now turn to the stronger notion of dependent coproduct types in ML theories. By adding another family of constants to T F ι with axioms, one obtains an equivalence similar to that in the previous section.

6.7.1 T F ισ theories

To obtain the equivalence, we add to T F ι theories new constants σ_{KL} that act as the second projections snd(−) in ML. First we fix some notation for elements of coproduct types of T F. In view of Lemma 6.5.2, we focus only on global elements.

Definition 6.7.1. For types Γ⊢K: Type and (Γ, 1 ⇒ K)⊢L: Type in a T F ι theory, the following are defined.

(Γ, 1 ⇒ K, 1 ⇒ L)⊢pair_{KL} ≡ uncurr_{L}(ψ_{1⇒K}^{L}): 1 ⇒ Σ_{1⇒K}.L[d_{1⇒K}∘d_{1⇒L}] Γ, 1 ⇒ Σ_{1⇒K}.L⊢fst_{KL} ≡ uncurr_{Σ_{1⇒K}.L}(ν_{1⇒K}.(χ_{1⇒K}∘!_{L})): 1 ⇒ K[d_{1⇒Σ_{1⇒K}.L}]

For two terms Γ⊢A_{1}: 1 ⇒ K and Γ⊢A_{2}: 1 ⇒ L[≺id_{Γ}, A_{1}≻] of a T F ι theory, define the pair of A_{1} and A_{2} to be the term

Γ⊢pair_{KL}[≺≺id_{Γ}, A_{1}≻, A_{2}≻](= φ_{1⇒K}^{L}[≺id_{Γ}, A_{1}≻]∘A_{2}): 1 ⇒ Σ_{1⇒K}.L.

The first component of a pair can be extracted by fst_{KL}:

fst_{KL}[≺id_{Γ}, pair_{KL}[≺≺id_{Γ}, A_{1}≻, A_{2}≻]≻] = A_{1}.

But, in general, T F ι theories support no operations that extract second components of pairs. The constants σ_{KL} are adjoined to T F ι theories for this purpose.

Definition 6.7.2. A T F ισ theory is given as in Definition 6.5.1 with the following additional inference rules.

(Γ, 1 ⇒ K)⊢L: Type

Γ, 1 ⇒ Σ_{1⇒K}.L⊢σ_{KL}: 1 ⇒ L[≺d_{1Σ_{1⇒K}.L}, fst_{KL}≻] (TM12)

(Γ, 1 ⇒ K)⊢L: Type

Γ, 1 ⇒ Σ_{1⇒K}.L⊢ ψ_{1⇒K}^{L}[≺d_{1⇒Σ_{1⇒K}.L}, fst_{KL}≻]∘σ_{KL} = χ_{1⇒Σ_{1⇒K}.L} : 1 ⇒ (Σ_{1⇒K}.L)[d_{1⇒Σ_{1⇒K}.L}]

(ETM18)

(Γ, 1 ⇒ K)⊢L: Type

(Γ, 1 ⇒ K, 1 ⇒ L)⊢σ_{KL}[≺d_{1⇒K}∘d_{1⇒L}, pair_{KL}≻]=χ_{1⇒L}: 1⇒L[d_{1⇒L}] (ETM19)

The second component of pair_{KL}[≺≺id_{Γ}, A_{1}≻, A_{2}≻] can be obtained by using (ETM19) as follows.

σ_{KL}[≺id_{Γ}, pair_{KL}[≺≺id_{Γ}, A_{1}≻, A_{2}≻]≻]
= σ_{KL}[≺d_{1⇒K}∘d_{1⇒L}, pair_{KL}≻][≺≺id_{Γ}, A_{1}≻, A_{2}≻]
= χ_{1⇒L}[≺≺id_{Γ}, A_{1}≻, A_{2}≻] = A_{2}

The rule (ETM18) shows that the pairing is surjective. Also note that any term σ′ that satisfies (ETM18) and (ETM19) is necessarily equal to σ_{KL}.

6.7.2 Translation between T F ισ and ML

Definition 6.7.3. A (pre)translation [[−]]_{ML} from a T F ισ theory T_{F} to a ML theory T_{M} is a map that satisfies the conditions given in Definition 6.6.3 and the following.

(TM12) [[σ_{KL}]]_{ML} = λz: 1.(snd(v_{1Σ_{1⇒K}.L}∗))

The soundness of interpretations extends to this case without difficulty.

Lemma 6.7.4. If [[−]]_{ML} is a translation from a T F ισ theory T_{F} to a ML theory T_{M}, all the derivable judgements of T_{F} are translated to those of T_{M} by [[−]]_{ML}.

Definition 6.7.5. A (pre)translation [[−]]_{T F ισ} from a ML theory T_{M} to a T F ισ theory T_{F} is a map that satisfies the conditions in Definition 6.4.1, plus the following conditions.

(ΣF) [[Σx_{n+1}: K_{n+1}.G]]^{x⃗:K⃗} = Σ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}.[[G]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}
(ΣI) [[⟨A_{1}, A_{2}⟩]]^{x⃗:K⃗} = ψ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}^{[[G]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}}[≺id_{[[_{x⃗:K⃗}]]}, [[A_{1}]]^{x⃗:K⃗}≻]∘[[A_{2}]]^{x⃗:K⃗}
(ΣE1) [[fst(A)]]^{x⃗:K⃗}

= ν_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}.(χ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}∘!_{[[G]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}})∘[[A]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}

(ΣE2) [[snd(A)]]^{x⃗:K⃗} = σ[[_{K_{n+1}}]]_{x⃗:K⃗}_{[[L]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}}[≺id_{[[_{x⃗:K⃗}]]}, [[A]]^{x⃗:K⃗}≻]

Proposition 6.7.6. If [[−]]_{T F ισ} is a translation from a ML theory T_{M} to a T F ισ theory T_{F}, all the derivable judgements of T_{M} are translated to those of T_{F} by [[−]]_{T F ισ}.

Proof The soundness for the equality inference rules (fst(−)eq) and (snd(−)eq) in Section 5.2.3 is easily checked. As for (⟨⟩eq) one has the following equation. Writing [[G]] for [[G]]^{x⃗:K⃗,x_{n+1}:K_{n+1}},

[[⟨fst(A), snd(A)⟩]]^{x⃗:K⃗}
= ψ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}^{[[G]]}[≺id_{[[_{x⃗:K⃗}]]}, fst[[_{K_{n+1}}]]_{x⃗:K⃗}_{[[G]]}[≺id_{[[_{x⃗:K⃗}]]}, [[A]]^{x⃗:K⃗}≻]≻]
∘σ[[_{K_{n+1}}]]_{x⃗:K⃗}_{[[G]]}[≺id_{[[_{x⃗:K⃗}]]}, [[A]]^{x⃗:K⃗}≻]
= (ψ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}^{[[G]]}[≺d_{1⇒[[Σ_{1⇒K}.L]]^{x⃗:K⃗}}, fst[[_{K_{n+1}}]]_{x⃗:K⃗}_{[[G]]}≻]
∘σ[[_{K_{n+1}}]]_{x⃗:K⃗}_{[[G]]})[≺id_{[[_{x⃗:K⃗}]]}, [[A]]^{x⃗:K⃗}≻]
= χ_{1⇒[[Σ_{1⇒K}.L]]^{x⃗:K⃗}}[≺id_{[[_{x⃗:K⃗}]]}, [[A]]^{x⃗:K⃗}≻]
= [[A]]^{x⃗:K⃗}.

6.7.3 The equivalence

With the soundness theorems 6.7.4 and 6.7.6 for [[−]]_{ML}’s and [[−]]_{T F ισ}’s, the equivalence between T F ι theories and wML theories can be easily extended to one between T F ισ theories and ML theories. All the propositions and theorems given in Section 6.6.2 − 6.6.4 also hold for ML theories with an obvious modification given in Appendix A.

Writing T F ισCat (MLCat) for the category of T F ισ (ML) theories and interpretations between them, one obtains:

Theorem 6.7.7. The constructions F(−) and G(−) form an adjoint equivalence between T F ισCat and MLCat.

Analysis of deliverables

7.1 Introduction

The aim of this chapter is to give an example of categorical analysis on concrete objects syntactically defined within an ambient type theory. We chose deliverables [52,11] in the LEGO system for our example because of their rich structure and their immediate usefulness in the problem of program correctness.

Categorical structure revealed by such analysis serves two related purposes. First, it allows us to study the semantics of concrete objects with our theory of universal structure in Chapter 2. By abstracting out the detail of the original syntactic definition, clarity is gained. Our computer checked language for categories with universal structure can be used to develop and formalise such a semantic study. More concretely, one can define a formalised category Del of syntactically defined deliverables as a term of the type Cat in Chapter 3 and instantiate the generic commands, lemmas given there with Del. (Note, however, one needs to adjust the universe levels used in Chapter 3 in the particular case of Del.)

Second, the categorical structure of concrete objects gives rise to a type theory within a categorical framework, which complements and helps the above semantic study. Here, two levels of type theory are considered; one is the ambient type theory and the other is an object-level type theory for the concrete objects.

The formalised semantic study and the object-level type theory retain a direct connection with the syntactic definition, all coexisting within the ambient type theory.

In this chapter, we give a categorical analysis of deliverables that provides a basis for this development. The main technical contribution is our analysis of second-order deliverables as a Kleisli construction over first-order deliverables. This gives a clear understanding of the syntactic “family construction” [52] and provide a basis for integrating the two object-level type theories for first- and second-order deliverables. (Also see Hermida [34] Section 4.3.4.)

In Section 7.2, we give the syntactic definition of first-order and second-order deliverables. Section 7.3 describes the categorical structure of deliverables, emphasising the fibred nature of structure on both first-order and second-order deliverables. To analyse the relationship between first- and second-order deliverables, abstract first- and second-order deliverables are defined in Section 7.4 as mild abstractions, as the term indicates, to give the categorical structure of deliverables. This structure is used in Section 7.5 to show that second-order deliverables are obtained form first-order deliverables by a Kleisli construction. Finally, using the connection between Kleisli constructions and polynomial categories, the family construction of second-order deliverables is analysed categorically.

In his original work [52], McKinna also investigated the categorical structure of deliverables. Using the categorical combinators derived from the structure, he developed an extensive methodology for provably correct programming. We emphasise the fibred aspect of the structure so that, for the second purpose mentioned above, we can use familiar (dependent) type theory rather than categorical combinators. With a different motivation, Hofmann [35] uses deliverables and their structure to study models of extensional type theory within intensional type theory. Also, Mendler [54] studies a construction on indexed categories related with abstract deliverables to give models for his modal logic.

7.2 Basic definitions

We first recall the syntactic definition of deliverables defined in our idealised LEGO; we assume proof irrelevance and extensionality. Following McKinna [52], we work in a fixed context Γ in order to give simpler definitions. In terms of the fibration that models the ambient type theory, we work in the fibre over a fixed base object. However, an abstract treatment of deliverables remains the same if we consider various contexts at once.

First, a specification is formalised simply as a type and proposition on it.

Definition 7.2.1. A specification is a pair of terms

(Γ ⊢ s: Type, Γ ⊢ S: s → Prop).

As usual, we omit contexts and/or types in writing the pair of terms (s, S). Also we use the letters S, T , ⋯ for specifications (s, S), (t, T), ⋯, respectively.

Given two specifications S and T , a first-order deliverable is a function with a proof that it produces from an input satisfying S an output satisfying T.

Definition 7.2.2. A first-order deliverable from S to T is a pair

(Γ ⊢ f: s → t, Γ ⊢ p: ∀x: s.Sx ⇒ T (fx)).

In [52], a Σ type is used to make this pair a term of the ambient type theory.

First-order deliverables can not specify input-output relations. This lead to the definitions of relativised specifications and second-order deliverables (see Section 3.2.1 of McKinna’s thesis [52]).

Definition 7.2.3. A relativised specification over S is a pair of terms

(Γ ⊢ t: Type, Γ ⊢ R: s → t → Prop).

Definition 7.2.4. Given two relativised specifications (t, Q) and (u, R) over S, a second-order deliverable over S from (t, Q) to (u, R) is a pair of terms

(Γ ⊢ f: s → t → u, Γ ⊢ p: ∀x: s.∀y: t.S(x) ⇒ Q(x, y) ⇒ R(x, (fxy))).

A second-order deliverable may be defined between relativised specifications over two different specifications; a morphism in Del_{2} defined in Definition 7.3.4 accounts for this.

7.3 Universal structures for deliverables

In this section we examine the universal structure that arises from the definitions in the previous section. These structures are also examined in Chapter 3 of [52] using semi-adjunction [33] to cater for proof relevance of LEGO. Here we give a simpler version by restricting our attention to our idealised version of LEGO with extensionality and proof irrelevance in order to obtain familiar categorical structures rather than exotic semi- counterparts of them that appear in [52]. This restriction is justified by observing that the idea of deliverables is to separate functions and proofs, so that we need not look for computational contents of the proof.

In Chapter 3 of [52], it is shown that both first-order deliverables and secondorder deliverables over a given specification form a semi-cartesian closed category. We recall the fact in our simpler setting. We also show that both categories are fibred categories that are locally small.

7.3.1 Fibred category Del_{1}

Definition 7.3.1. • The category Del_{1} has specifications as objects and firstorder deliverables as morphisms. The composition of two deliverables

(f: s_{0} → s_{1}, p: ∀x: s_{0}.S_{0}x ⇒ S_{1}(fx)): S_{0} ^{}S_{1},
(g: s_{1} → s_{2}, q: ∀x: s_{1}.S_{1}x ⇒ S_{2}(gx)): S_{1} ^{}S_{2}

is defined by

(g, q) ∘ (f, p) = (Γ ⊢ λx: s_{0}.g(fx): s_{0} → s_{2},

Γ ⊢ λx: s_{0}.λh: S_{0}x.q(fx)(pxh): ∀x: s_{0}.S_{0}x ⇒ S_{2}(g(fx)))
: S_{0} ^{}S_{2}

• The category Typ has types and functions under the context Γ as objects and morphisms, with the obvious composition defined by LEGO.

• The functor p_{Del}_{1}: Del_{1} ^{}Typ is given by projections of the first components for both specifications and first-order deliverables.

The identity on S ∈ Del_{1} is given by

id_{S} = (λx: s.x: s → s, λx: s.λh: Sx.h: ∀x: s.Sx ⇒ Sx).

Note that, without extensionality, even the definition of Typ requires a modified identification of terms to force the associativity of composition [52].

Proposition 7.3.2. The functor p_{Del}_{1} is a fibration.

Proof The canonical cartesian morphism with codomain S over a function f: t → s is defined by

(f: t → s, λx: t.λh: S(fx).h): (t, λx: t.S(fx)) ^{}(s, S),

which we write f̂S: (t, S[f]) ^{}S. To see f̂S is cartesian, consider a function g: u → t and a specification (u, U). The composition with f̂S

f̂S ∘ (−): Del_{1}_{g}((u, U), (t, S[f])) → Del_{1}_{fg}((u, U), (s, S))

is trivially bijective and natural in (u, U) with the inverse

\begin{matrix}Del_{1}_{fg}((u, U), (s, S)) & → & Del_{1}_{g}((u, U), (t, S[f])) \\ (fg, p: ∀x: u.Ux ⇒ S(f(gx))) & ↦ & (g, p: ∀x: u.Ux ⇒ S[f](gx)). \end{matrix}

It is also easy to check that ˆ(−)(−) does give a splitting on p_{Del}_{1}.

The fibre Del_{1s} over s ∈ Typ is the preorder of s-parameterised propositions S: s → Prop where a morphism from S_{0} to S_{1} exists if there is a proof p: ∀x: sS_{0}x ⇒ S_{1}x. This is clearly isomorphic to the preorder of propositions under the context (Γ, x: s).

Proposition 7.3.3. The fibration p_{Del}_{1} is locally small.

Proof Given R, S ∈ p_{Del}_{1}s, the projection d_{s,RS}: Hom_{s}(R, S) ^{}s in Typ (Definition 4.6.5) is given by the first projection π_{0}: (Σx: s.∀x: s.Sx ⇒ Rx) ^{}s. This being a Hom-object depends on proof irrelevance.

With proof irrelevance and extensionality, it is also easy to show that p_{Del}_{1} has products and coproducts along d_{s,RS}.

7.3.2 Cartesian closed structure on Del_{1}

Next we observe that p_{Del}_{1} is a fibred cartesian closed category. This gives an instance of logical predicates for simply typed λ calculus (see Section 4.2 of Hermida [34]).

Terminal object The terminal object of Del_{1} is given by (Unit, λx: Unit.True), which is evidently preserved by p_{Del}_{1}. The unique morphism from (s, S) is (λx: s.∗, λx: s.λh: Sx.triv), where ∗ and triv are the unique elements of Unit and True, respectively.

Binary products Since each fibre Del_{1s} has binary product preserved by substitutions (s, S_{0}) ×_{s} (s, S_{1}) ≡ (s, λx: s.S_{0}x ∧ S_{1}x), Del_{1} has fibred binary products. Spelling out, the product of two specifications S and T is given by

S × T = (s × t, λx: s × t.S(π_{0}x) ∧ T (π_{1}x))

The adjunction is

\begin{matrix}(u, U) ^{(f,p)}^{}(s, S) & (u, U) ^{(f,p)}^{}(t, T) \\ (u, U) _{(λx:u.⟨fx,gx⟩,λx:u.λh:Ux.⟨pxh,qxh⟩)}^{}(s × t, λx: s × t.S(π_{0}x) ∧ T (π_{1}x)) \end{matrix}

{(u, U) ^{(f,p)}^{}(s × t, λx: s × t.S(π_{0}x) ∧ T (π_{1}x)) \atop (u, U) ^{(π_{0}f,λx:u.λh:Ux.π_{0}(pxh))}^{}(s, S) (u, U) ^{(π_{0}f,λx:u.λh:Ux.π_{1}(pxh))}^{}(t.T).}

Exponentials Each fibre Del_{1s} (s ∈ Typ) is a cartesian closed category with exponentials given by pointwise implications. For R, S: s → Prop,

SR ≡ λx: s.Rx ⇒ Sx.

The adjunction is given by

Q → SR ≡ ∀x: s.Qx ⇒ Rx ⇒ Sx if and only if ∀x: s.Qx ∧ Rx ⇒ Sx.

Given f: t → s, the substitution (−)[f] preserves the implication as SR[f] = λx: t.R(fx) ⇒ S(fx) = S[f]R[f].

7.3.3 Fibred category Del_{2}

Definition 7.3.4. • The category Del_{2} has as objects relativised specifications. A morphism from a relativised specification R ≡ (r, R) over a specification S ≡ (s, S) to V ≡ (v, V) over T ≡ (t, T) is a quadruple (g, p, f, q) where (g, p) ∈ Del_{1}(S, T ) and (f, q) is a second-order deliverable from R to (v, λx: s.λy: v.V (gx, y)) over S, i.e.,

(Γ ⊢ g: s → t,
Γ ⊢ p: ∀x: s.Sx ⇒ T (gx),
Γ ⊢ f: s → r → v,
Γ ⊢ q: ∀x: s∀y: r.Sx ⇒ R(x, y) ⇒ V (gx, fxy)).

Given W ≡ (w, W) over U ≡ (u, U) and a morphism (k, a, h, b): V ^{}W, the composition (k, a, h, b) ∘ (g, p, f, q): R ^{}W is

(k ∘ g,
λx: s.λc: Sx.a(gx)(pxc),
λx: s.λy: r.h(gx)(fxy),

λx: s.λy: r.λc: Sx.λd: R(x, y).b(gx)(fxy)(pxc)(qxycd)).

• The functor p_{Del}_{2}: Del_{2} ^{}Del_{1} sends relativised specifications to their underlying first-order specifications, and morphisms to first-order deliverables comprising their first two components.

Proposition 7.3.5. p_{Del}_{2} is a split fibration.

Proof Given (r, R) ∈ Del_{2(s,S)} and (t, T) ^{(g,p)}^{}(s, S) in Del_{1}, define ˆ(g, p)(r, R) by

(r, R)[(g, p)] ≡ (r, λx: tλy: r.R(gx, y)),
ˆ(g, p)(r, R): (r, R)[(g, p)] ^{(g,p,λx:tλy:r.y,p′)}^{}(r, R)

where

p′ ≡ λx: tλy: r.λa: T x.λb: R(gx, y).b
: ∀x: t.∀y: r.T x ⇒ R(gx, y) ⇒ R(gx, y).

Then, given (u, U) ^{(k,q)}^{}(t, T) in Del_{1} and (v, V) ∈ Del_{2(u,U)}, the composition with ˆ(g, p)(r, R) is a trivial bijection

\begin{matrix}ˆ(g, p)(r, R) ∘ (−): & Del_{2(k,q)}((v, V), (r, R)[(g, p)]) \overline{} & Del_{2(g,p)∘(k,q)}((v, V), (r, R)) \\ (k, q, f, c) & ↦ & \begin{matrix}(g ∘ k, \\ λx: u.λy: Ux.p(kx)(qxy), \\ f, \\ c) \end{matrix} \end{matrix}

It is also easy to check that this gives a splitting on p_{Del}_{2}.

A morphisms in the fibre Del_{2S} over a specification S is precisely a secondorder deliverables over S.

7.3.4 Cartesian closed structure on Del_{2}

Terminal object The terminal object of Del_{2} is given by the relativised specification 1 ≡ (Unit, λx: s.λu: Unit.T rue) over the terminal specification. This is a fibred terminal object, since p_{Del}_{2} obviously preserves it. The unique morphism from (r, R) over (s, S) is given by the unique first-order deliverable !_{(s,S)} from (s, S) to (Unit, True) and the second-order deliverable

(λx: s.λy: r.∗, λx: s.λy: r.λp: Sx.λq: R(x, y).triv)
: (r, R) ^{}1[!_{(s,S)}].

Binary products Given two relativised specifications (r, R) and (t, T) over (s, S), the binary product of (r, R) and (t, T) in the fibre Del_{2(s,S)} is given by (r, R) × (t, T) ≡ (r × t, λx: s.λy: r × t.λp: Sx.R(x, π_{0}y) ∧ T (x, π_{1}y)). Given a firstorder deliverable (f, p): (u, U) ^{}(s, S), the substitution functor

(−)[(f, p)]: Del_{2(s,S)} ^{}Del_{2(u,U)}

preserves the product as

((r, R) × (t, T))[(f, p)] = (r × t, λx: u.λy: r × t.λp: Ux.R(gx, π_{0}y) ∧ T (gx, π_{1}y)) = (r, R)[(f, p)] × (t, T)[(f, p)].

So, Del_{2} has fibred binary products.

Exponentials The fibration p_{Del}_{2} has fibred exponentials as follows. First, each fibre Del_{2(s,S)} is cartesian closed. The exponential object of (r, R) and (t, T) is given by

(t, T)(r, R) ≡ (r → t, λx: s.λy: r → t.∀z: r.R(x, z) ⇒ T (x, yz)).

The transposition of a morphism (f, q): (v, V) × (r, R) ^{}(t, T) in Del_{2(s,S)} is

(λx: s.λy: v.(λw: r.fx⟨y, w⟩),
λx: s.λy: v.λp: Sx.λa: V (x, y).λz: r.λb: R(x, z).qx⟨y, z⟩p⟨a, b⟩)
: (v, V) ^{}(t, T)(r, R).

For the inverse direction, given (f, q): (v, V) ^{}(t, T)(r, R) in Del_{2(s,S)}, the transposition is

(λx: s.λy: v × r.fx(π_{0}y)(π_{1}y),

λx: s.λy: v × r.λp: Sx.λa: V (x, π_{0}y) ∧ R(x, π_{1}y).qx(π_{0}y)p(π_{0}a)(π_{1}y)(π_{1}a))

: (v, V) × (r, R) ^{}(t, T).

Second, to see this is preserved by substitution, let (f, p): (u, U) ^{}(s, S) be a first-order deliverable. Then in fact,

(t, T)(r, R)[(f, p)] = (r → t, λx: u.λy: r → t.∀z: r.R(fx, z) ⇒ T (fx, yz))
= (t, T)[(f, p)](r, R)[(f, p)].

7.3.5 Local smallness

Proposition 7.3.6. The fibration p_{Del}_{2} is locally small.

Given two relativised specifications (r, R) and (t, T) over (s, S), the Hom-projection

d_{(s,S),(r,R)(t,T)}: Hom_{(s,S)}((r, R), (t, T)) ^{}(s, S)

is given by

\begin{matrix}(s × (r → t), λx: s.λg: r → t.Sx ∧ ∀y: r.Sx ∧ R(x, y) ⇒ T (x, gy)) \\ (s, S) & ^{^{}(π_{0}, λ(x, g): s × (r → t).λp.π_{0}p(x, g))} \end{matrix}

Once Hom-projections are given, it is straightforward to show that p_{Del}_{2} also has products and coproducts along d_{(s,S),(r,R)(t,T)}. Therefore, p_{Del}_{2} supplies a model for our categorical framework in Chapter 5.

7.4 Abstract deliverables

In this section, we rephrase the above syntactic definition in terms of the fibration. The level of abstraction is chosen to make clear the construction of second-order deliverables out of first-order ones.

7.4.1 First-order deliverables

The fist order deliverables are treated simply as a fibration p: E ^{}B with fibred finite products. Finite products are needed for the construction of the second order deliverables in terms of p.

Definition 7.4.1. (McKinna [52])

Given a fibration p: E ^{}B with fibred finite products, the objects and the morphisms of E are called abstract specification and abstract first-order deliverables.

The categories B and E correspond to Typ and Del_{1}, respectively. In more detail, we informally identify them as follows and use objects of B etc. in place of types etc..

• An object I ∈ B corresponds to a type I under the context Γ, and a morphism u: J ^{}I in B to a function u: J → I, regarding J and I as types in the latter.

• An object A ∈ E_{I} corresponds to a specification A ≡ (I, A: I → Prop). A morphism f: B _{(u)}^{}A in E over u corresponds to a first-order deliverable f ≡ (u, f: ∀x: J.Bx ⇒ A(ux)).

Particularly, if the above f in E is cartesian, the corresponding deliverable is isomorphic to ûA = (u, λx: J.λh: A(ux).h), and B is identified with the specification (J, λx: J.A(ux)). However, we do not assume a particular cleavage nor a splitting on p.

7.4.2 Second-order deliverables

Now we identify a relativised specification with a diagram in E. First, note that a relativised specification R ≡ (J, R: I × J → Prop) over a specification A ≡ (I, A: I → Prop) can be specified by A, J, and the specification R ≡ (I × J, R: I × J → Prop), with the obvious identification of the two types I → J → Prop and I × J → Prop. Therefore, one may identify a relativised specification R with a tuple (A ∈ E_{I}, J ∈ B, R ∈ E_{I×J}). Next, we examine what corresponds to a morphism of Del_{2} in terms of p. Consider another relativized specification S ≡ (L, S: K × L → Prop) over a specification B ≡ (K, B: K → Prop) and a morphism (u, f, g, p): S ^{}R, i.e,

(u: K → I, f: ∀x: J.Bx ⇒ A(ux), g: K → L → J, h: ∀x: K.∀y: L.Bx ⇒ S(x, y) ⇒ R(ux, gxy)).

Then, observe the following.

• the first-order deliverable given by (u, f): (K, B) ^{}(I, A) corresponds to a morphism f: A _{(u)}^{}B in E over u:.

• the function g: K → L → J corresponds to a morphism g: K × L ^{}J in B.

• to see what should correspond to h, first note that its type can be rewritten

h: ∀z: K × L.B(π_{0,KL}z) ∧ Sz ⇒ R(⟨uπ_{0,KL}, g⟩z).

Then, h, combined with the function ⟨uπ_{0,KL}, g⟩: K × L → I × J, forms a first-order deliverables

(⟨uπ_{0,KL}, g⟩, h): (K × L, λz: K × L.B(π_{0,KL}z) ∧ Sz) ^{}(I × J, R).

The domain of (⟨uπ_{0,KL}, g⟩, h) is equal to a product in E_{K×L} of two specifications (K × L, λz: K × L.B(π_{0,KL}z)) and (K × L, S). The former corresponds to an object B′ ∈ E_{K×L} with a cartesian morphism B′ +_{(π_{0,KL})}^{}B. Therefore, h corresponds to the morphism h: B′ ×_{K×L} S ^{}R of E over the base morphism ⟨uπ_{0,KL}, g⟩: K × L ^{}I × J.

[figure: B; \underline{+}; B′; π_{0,B′S}; B′ × S; π_{1,B′S}; S]
p
K ^{_{}π_{0,KL}} K × L = = = = = K × L = = = = = K × L

In order to express the composition of second-order deliverables, it is convenient to regard this construction (B, S) ↦ (B′, S) ↦ B′ ×_{K×L} S as a primitive construction.

Definition 7.4.2. Let p: E ^{}B be a fibration with B having binary products. Given A ∈ E_{I}, J ∈ B, and R ∈ E_{I×J}, define an object A · R ∈ E_{I×J} to be a representing object such that, for each (X, u: K ^{}I × J) with X ∈ E_{K}, there is a natural bijection

E_{u}(X, A · R) ≅ E_{π_{0,IJ} ∘u}(X, A) × E_{u}(X, R).

The chosen counit is written (π_{0,AR}: A · R _{(π_{0,IJ})}^{}A, π_{1,AR}: A · R _{(id_{I×J})}^{}R) and has the following universal property.

∀f: X _{(π_{0,IJ} u)}^{}A.∀g: X _{(u)}^{}Y.∃!h: X _{(u)}^{}A · R.π_{0,AR}h = f ∧ π_{1,AR}h = g

[figure: X; f; g; A; π_{0,AR}; A · R; h; π_{1,AR}; R; over; K; π_{0,IJ} ∘ u; u; I; π_{0,IJ}; I × J; u; id_{I×J}; I × J]

We write the morphism h given by f and g as ⟨f, g⟩, and ⟨kπ_{0,AR}, lπ_{1,AR}⟩ as k · l.

Now B · S is isomorphic to B′ ×_{K×L} S in the above paragraph since we have

E_{u}(X, B′ ×_{K×L} S) ≅ E_{u}(X, B′) × E_{u}(X, S)

≅ E_{π_{0,KL}u}(X, B) × E_{u}(X, S)
≅ E_{u}(X, B · S).

With this definition, we define the abstract version of second order deliverables as follows.

Definition 7.4.3. Given a fibration p: E ^{}B with (−) ·(−) of Definition 7.4.2,

• the category L ≡ L(E) of the abstract relativised specification has as objects the tuples (A ∈ E_{I}, J ∈ B, R ∈ E_{I×J}). A morphism of L from (A, J, R) to (B, L, S) is a morphism (f, g): π_{0,AR} ^{}π_{0,BS} of E^{2}, i.e., a pair (f, g) that makes the following diagram commute.

[figure: A · R; g; B · S; A; π_{0,AR}; f; B; π_{0,BS}]

The composition of morphisms is given by (f, g) ∘ (k, l) = (fk, gl).

• the functor q: L ^{}E sends an object (A, J, R) of L to A and a morphism (f, g) to f.

• a morphism in the fibre L_{A} is called an abstract second-order deliverable over the abstract specification A.

Lemma 7.4.4. The functor q: L ^{}E is a fibration.

Proof Given an object (A ∈ E_{I}, J ∈ B, R ∈ E_{I×J}) in L_{A} and a morphism f: B _{(u)}^{}A in E over u: K ^{}I in B, let Q be an object in E_{K×J} with a p-cartesian morphism c: Q +_{(u×id_{J})}^{}R over u × id_{J}: K × J ^{}I × J. Then, (f, h): (B, K, Q) ^{}(A, J, R) in the diagram below is a q-cartesian morphism over f.

[figure: Q; \begin{matrix}c \\ + \end{matrix}; R; B · Q; π_{1,BQ}; h; A · R; π_{1,AR}; B; π_{0,BQ}; f; A; π_{0,AR}; p; I × J; u × id; K × J; I × J; ‖; u × id; K × J ‖; I; π_{0,IJ}; u; K; π_{0,KJ}]

In fact, given (C ∈ E_{L}, M ∈ B, P ∈ E_{L×M}) ∈ L_{C} and C \begin{matrix}g \\ (v) \end{matrix}^{}B in E, the inverse of L_{f}((C, M, P), (f, h)): L_{g}((C, M, P), (B, K, Q)) ^{}L_{fg}((C, M, P), (A, J, R)) is given by the following bijection (k ↦ k̄) of dotted morphisms (over specified B morphisms) that make each diagram commute: (writing w for ⟨vπ_{0,LM}, π_{1,KJ}∘pk⟩,)

[figure: C · P; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; \begin{matrix}k \\ ((u × id)w) \end{matrix}; A · R; C; π_{0}; \begin{matrix}g \\ (v) \end{matrix}; B; \begin{matrix}f \\ (u) \end{matrix}; A; π_{0}; C · P; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; ((u × id)w); R; ≅; C · P; .; .; .; .; .; .; .; .; .; .; .; .; .; .; .; (w); Q; ≅; C · P; .; .; .; .; .; .; .; .; .; .; .; .; .; .; k̄ ; (w); B · Q; C; π_{0}; \begin{matrix}g \\ (v) \end{matrix}; B; π_{0}]  ≅

7.5 Kleisli construction of second-order deliver-

ables

In this section, we study L in terms of Kleisli construction. The result is used in the next section to show a second-order deliverable as a first-order deliverable in an extended context. First, recall the following.

Lemma 7.5.1. Given an adjunction A [figure: F; ⊥; G] B, B is isomorphic to the Kleisli category A_{F G} for the comonad F G: A ^{}A if and only if the object part of G is a bijection.

Proof The necessity is clear from the usual construction of Kleisli categories described in e.g. Mac Lane [49]. To see that it is sufficient, we show that B has the same universal property as the Kleisli category A_{F G}; namely, for any adjunction A [figure: K; ⊥; L] X with KL = F G, there is a unique functor H: B ^{}X such that

B ^{H ^{}}X ; \begin{matrix}A & ^{F^{}}⊣ G & = = = = = = = = \\ A & ^{K^{}}⊣ L \end{matrix}

is a morphism of adjunctions. First, the object part of G is determined by HG = L as, for A ∈ B, HA = LG^{−1}A. Second, the morphism part of H is determined by that of KH = F. To see this, let η: id_{X} ^{}LK and ε: KL ^{}id_{A} be the unit and the counit of the adjunction K ⊣ L. Then, the following commutes, showing that Hf = Lε_{G^{−1}B} ∘ LF f ∘ η_{HA} for any f: HA ^{}HB = LG^{−1}B in B.

HA  \overline{Hf ^{}}LG^{−1}B = = = = = = = = = = LG^{−1}B
[figure: Lε_{G^{−1}B}]
[figure: LKHA; η_{HA}; \begin{matrix}LKHf \\ = LF f \end{matrix}; LKHB; η_{LG^{−1}B}]

It is easy to check the functoriality of H, KHB = F B, and HGf = Lf.

Let s(B) be the simple of the category B [34]. An object of s(B) is a pair of objects of B. A morphism from (I, J) to (K, L) is a pair of morphisms

(f: I ^{}K, g: I × J ^{}K × L)

with π_{0,KL} ∘ g = fπ_{0,IJ}. Consider the following limit diagram in Cat.

F

[figure: q]
E  s(B)^{}E
[figure: B; p; π_{0}; B × B; U; π_{1}; B; p]

where the functor U: s(B) ^{}B × B sends (I, J) to (I, I × J) and (f, g) to (f, g).

The category F has the same objects as L and a morphism from (A ∈ E_{I}, J ∈ B, R ∈ E_{I×J}) to (B ∈ E_{K}, L ∈ B, S ∈ E_{K×L}) is a pair (f: A ^{}B, g: R ^{}S) of morphisms of E such that the following commutes.

[figure: I × J; pg; K × L; I; π_{0}; pf; J; π_{0}]

The composition of morphisms is given componentwise. The functor q sends objects and morphisms to their first components.

Proposition 7.5.2. The functor q: F ^{}E is a fibration.

Proof It is immediate from a construction of the above limit diagram by pullbacks and the fact that a pullback preserves fibrations. More concretely, a cartesian morphism over f: B ^{}A with a codomain (A, J, R) is given by (B ^{f}^{}A, R[pf × id_{J}] +^{}R).

The fibre F_{A} over A ∈ E_{I} has as an object a pair (J ∈ B, R ∈ E_{I×J}) and as a morphism from (K, Q) to (J, R) a morphism in E f: Q ^{}R with π_{0,IJ} ∘ pf = π_{0,IK}. The composition and the identity are inherited from E.

Define the functor T: F ^{}F by

T: F \overline{}F
(A, J, R)  (A, J, A · R)
↦
[figure: (B, L, S); (f, g); (B, L, B · S).; (f, f · g)]

The morphism f · g is well-defined by the condition on a morphism in F, and (f, f · g) is a morphism of F because p(f · g) = pg.

The functor T is a part of the comonad (T, μ, δ) on F. The counit μ: T ^{}id_{F} is given by, for each (A, J, R) in F,

μ_{(A,J,R)} ≡ (id_{A}, π_{1,AR}): (A, J, A · R) ^{}(A, J, R).

The comultiplication δ: T ^{}T T is given by, for each (A, J, R),

δ_{(A,J,R)} ≡ (id_{A}, ⟨π_{0,AR}, id_{A · R}⟩⟩): (A, J, A · R) ^{}(A, J, A ·(A · R)).

The proof of the comonad laws can be easily checked.

Proposition 7.5.3. The category L is the Kleisli category for the comonad T. Moreover, each fibre L_{A} is the Kleisli category for the comonad T_{A}, the restriction of T to F_{A}.

Proof By Lemma 7.5.1, it is enough to show that T can be decomposed as F ^{G}^{}L ^{F}^{}F with F ⊣ G and G being bijective on objects.

By definition, a morphism (f, g): (A, J, R) ^{}(B, L, S) in L is also a morphism (f, g): (A, J, A · R) ^{}(B, L, B · S) in F. This gives the morphism part of the functor F: L ^{}F whose object part is that of T. In the converse direction, given a morphism (f, g): (A, J, R) ^{}(B, L, S) in F, the morphism T (f, g) = (f, f · g): (A, J, R) ^{}(B, L, S) is also a morphism in L with the same domain and codomain. Thus, the morphism part of T with the identity object part defines the functor G: F ^{}L. Since obviously T = F G and G is bijective on objects, it remains to show that F ⊣ G. The bijection between g and ḡ below gives the desired adjunction F(F (A, J, R), (B, L, S)) ≅ L((A, J, R), G(B, L, S)).

[figure: S; g; A · R; ḡ; B · S; π_{1}; A; π_{0}; f; B; π_{0}; such that; pA × J; pg = pḡ; pB × L; pA; π_{0}; pf; pB; π_{0}]

It is also clear that the unit

A · R \overline{⟨π_{0}, id⟩_{}}A ·(A · R)
η_{(A,J,R)}:
[figure: A; π_{0}; = = = = = = = = = = =; A; π_{0}]

in F is over id_{A} and F and G restrict to an adjunction between F_{A} and L_{A}.

Note, however, F and G do not form a fibred adjunction ( Definition 1.2.12 of Hermida’s thesis [34]), since G does not preserve cartesian morphisms. (cf. Section 6.2.7 of ibid., the adjunction described there was not fibred with the same reason; he has since proved a precise improved statement.)

7.6 The family construction of second-order de-

liverables

In this section, we exploit the result of the previous section to categorically analize the view that a second-order deliverable is a first-order deliverable in an extended context. McKinna [52] gave a syntactic construction, called family construction, of second-order deliverables from such first-order deliverables.

Proposition 7.6.1. (McKinna [52])

Suppose we have Γ ⊢ s: Type, Γ ⊢ S: s → P rop, and two relativized specifications (t, T) and (u, U) over (s, S). Then, to give a second-order deliverable over (s, S) from (t, T) to (u, U) is equivalent to to give Γ, x: s ⊢ f_{x}: t → u and a first-order deliverable under the context Γ, x: s, h: Sx from a specification (t, T x) to (u, Ux) with its first component being f_{x}.

We show that this correspondence is a consequence of the analysis given in the previous section. This is to expand the last remark in Section 4.3.4 of Hermida’s thesis [34].

7.6.1 Polynomial categories

In Chapter 6, we saw an extension of context can be modelled by construction of a Hom-object in the base of a locally small fibration. An alternative, more external interpretation is possible with the concept of polynomial categories [44,34]. Given a category A with finite products, a polynomial category category A[x: A] with A ∈ A is obtained by freely adjoining a new morphism (‘indeterminate’) x: 1 ^{}A to A [44]. The inclusion of A into A[x: A], hence A[x: A], can be characterised by the following universal property.

Proposition 7.6.2. (Prop. 5.1 of Lambek & Scott [44])

Let A be a category with finite products, A ∈ A, and H_{x}: A ^{}A[x: A] the inclusion into the polynomial category. For any product preserving functor F: A ^{}B and any morphism h: 1 ^{}F A in B, there exists a unique product preserving functor ⟨F, h⟩: A[x: A] ^{}B with ⟨F, h⟩H_{x} = F and F x = h.

Proof See [44].

The following is also well known.

Proposition 7.6.3. The polynomial category A[x: A] is isomorphic to the Kleisli category A_{A×(−)} for the comonad A × (−): A ^{}A with the counit ε_{B} = π_{1}: A × B ^{}B and the comultiplication δ_{B}: ⟨π_{0}, id_{A×B}⟩: A × B ^{}A × (A × B).

The proof found in [44] shows that A_{A×(−)} has the universal property of A[x: A] in Proposition 7.6.2. The proof is based on a concrete description of A_{A×(−)}.

The category A_{A×(−)} can be described as follows. The objects are the same as A, a morphism f from X to Y is a that of A from A × X to A × Y with π_{0,AY} f = π_{0,AX}; the composition and the identity are inherited from A. This description differs a little from the one given in [44], but the equivalence is immediate. The Kleisli resolution A [figure: F; ⊥; G] A[x: A] is given by F X = A × X, F f = f, GX = X, and Gf = A × f.

We show a different, conceptually clearer proof of Proposition 7.6.3 in order to apply this to the construction of abstract second-order deliverables. This is a special case of Hermida’s general 2-categorical treatment [34]. The proof is given in two parts.

Proposition 7.6.4. Let A [figure: F; ⊥; G] B be an adjunction with G being bijective on objects, η the unit, and H: A ^{}C, K, K′: B ^{}C functors with KG = H and K′G = H. Then, K′ηG = KηG implies K = K′.

Proof Let ε be the counit of the adjunction. The morphism parts of K and K′ agree because the image of ηG by K (K′) determines the rest of the morphism part K_{GX,GY} as follows.

B(GX, GY)  K_{GX,GY} ^{}C(HX, HY)
[figure: F_{GX,GY}; (−) ∘ η_{GX}]
[figure: A(F GX, F GY); B(GF GX, GY); K_{GF GX,GY}; C(HF GX, HY); (−) ∘ Kη_{GX}]
[figure: ε_{Y} ∘ (−); G_{F GX,Y}; H_{F GX,Y}]
A(F GX, Y)^{^{≅}}

This is a special case of Street’s 2-categorical analysis ([76], also see [34]). In his term, B classifies those co-op-algebras (oplax cocones in [34]) for the comonad F G and ηG is the universal such.

Corollary 7.6.5. In the above situation, further suppose A has finite products preserved by H, and (F, G) is the Kleisli resolution of the A×(−) comonad. Then, Kη_{G1} = K′η_{G1} implies K = K′.

Proof This follows from that Kη_{GX} (K′η_{GX}) is determined by Kη_{G1}(= K′η_{G1}). KGX

[figure: KGX; Kη_{GX}; KGF GX = = = = = = = = = = =; H(A × X); id; Hπ_{1} = KGπ_{1}]

[figure: KG1; KG!_{X}; Kη_{G1}; KGF G1 = = = = = = = = = = = =; H(A × 1); H(A×!_{X})]

The triangle commutes because π_{1}: A×(−) ^{}id_{A} is the counit of the resolution. This determines Kη_{GX} since the right column is a product cone.

Proof (of Proposition 7.6.3) Corollary 7.6.5 shows the uniqueness part of Proposition 7.6.2. The same two proofs of Corollary 7.6.5 and Proposition 7.6.4 also show the existence; a morphism 1 ^{}A gives rise to a natural transformation KG ^{}H(A × (−)), which in tern gives rise to a morphism part of a functor from A to C with its object part being X ↦ HG^{−1}X. It is also easy to check that this functor preserves products in A[x: A].

7.6.2 Family construction

Now we turn to our abstract second-order deliverables with the Kleisli resolution F_{A} [figure: F_{A}; ⊥; G_{A}] L_{A}. First note that this is the same as A [figure: ⊥] A[x: A], but with the difference between A ·(−) and A × (−). However, Corollary 7.6.5 remains valid when one replaces A × (−) by A ·(−). To see this, consider A ∈ E_{I} and (J, R ∈ E_{I×J}) ∈ F_{A}. The terminal object of F_{A} is given by (1 ∈ B, 1 ∈ E_{I×1}). The diagram (1, A · 1) ^{}^{A ·!} (J, A · R) ^{π_{1}}^{}(J, R) is a product cone in F_{A}. So the proof of Corollary 7.6.5 still applies.

So, we have the following modified version of Proposition 7.6.3.

Proposition 7.6.6. Given A ∈ E_{I}, L_{A} is isomorphic to the polynomial category F_{A}[x: (1, A · 1)].

Using the description of F_{A}, one can spell this out as follows: to give a morphism in L_{A} from (J, Q) to (K, R) is equivalent to to give, with an indeterminate x: 1 ^{}A, a morphism f: Q ^{}R in E such that π_{0,IK}pf = π_{0,IJ}. This precisely rephrases Proposition 7.6.1; the correspondence of letters is: I ↦ s, J ↦ t, K ↦ u, A ↦ (s, S), x ↦ (x, h), R ↦ (t, T), and Q ↦ (u, U).

One can further continue this analysis in a fibred setting with varying A, after the analysis given in Hermida’s thesis [34]. One needs some modification to it to account for the condition π_{0,IK} ∘ pf = π_{0,IJ} that is not found in his analysis.

Conclusions and further work

In this thesis, we achieved two objectives. First, we provided category theorists with a computer checked language to describe arrows of categories of their choice with extra structure. That was done in order to support the proofs of coherence theorems in particular, and of any category theoretic proof of a syntactic nature in general. Then we provided what we called a categorical framework for type theory, our computer checked language providing formalisation of that framework on a computer.

The first objective extends the work of Rydeheard and Burstall, who formalised category theoretic constructions in ML, in that we provided a more uniform treatment, giving a general recipe for how to formalise universal constructions. That is of interest not only to category theorists, but also to those computer scientists who may attempt to build programming languages based upon categorical constructions, such as the Categorical Abstract Machines (Curien et. al. [18], Ritter [70]), Categorical Programming Language (Hagino [30]), and CHARITY (Cockett and Spencer [17,75]).

A common approach to this involves the classification of structure on categories as equational structure, or more generally, as essentially algebraic structure. We explained why that is somewhat awkward, both conceptually and computationally. We therefore developed an alternative approach, namely the classification of categorical structure as universal structure, universality being the single most important category theoretic concept. This incorporated very many examples of category theoretic concepts, in particular those of greatest interest to computer scientists, such as cartesian closed structure, fibrations with extra structure, limits, colimits, and natural numbers objects.

We gave a formal definition of universal structure, developed the concept abstractly, and gave many examples. We further used it as the basis for a computer checked language in the proof system LEGO. We needed a proof system as our specific aim was to support category theoretic proof. We chose LEGO as it was both familiar to us and convenient.

We then proceeded to investigate the use of category theory in computer science. One of the greatest uses, perhaps the deepest one, is the use of category theory as a semantics for type theory. Many instances of this appear in the literature, the best known being the relationship between the simply typed lambda calculus and cartesian closed categories.

Type theory has been widely used as a foundation for computer science. Programming languages typically have an underlying type theory, and logics typically have a corresponding type theory, given by the Curry-Howard isomorphism. So, for both the study of programming languages and for the study of logics, in particular logics for reasoning about programming languages, one often passes to type theory. For instance, the underlying type theory of the proof system LEGO is the Extended Calculus of Constructions. Categories with structure provide a semantics for type theory.

We therefore gave a unified treatment of the relationship between a general and subtle class of type theories and categories with extra structure. The type system T F ι was devised to describe locally small fibrations with particular structure, and its equivalence to the type system wML with weak dependent coproduct types were shown in detail. The equivalence between the type system ML with strong coproducts and T F ισ was similarly shown. That extra structure needed was indeed universal structure, so our computer checked language can provide a formalisation of our categorical framework on a computer. Finally, we illustrated this framework and the corresponding universal structure by a study of the fibration of deliverables. Our analysis gave a categorical understanding of the syntactic “family construction”.

We now turn to further work. We seek to develop the work of this thesis in several ways. First, we should like to extend our abstract study of universal structure so that we study not only universal structures on categories, but more generally, universal structures on fibrations. As we have illustrated, fibrations are a fundamental concept in category theory, in particular for providing the semantics of type theory, especially for modelling dependent types. They are also used to model parametricity, and are in fact equivalent to a study of logical relations. Bénabou goes so far in his abstract development of fibrations in analogy with category theory as to actually use the word ”category” for fibrations [8]. Categories in fact may be seen as special fibrations in several ways.

We had hoped to achieve that aim for this thesis but it proved to be too ambitious. However, having developed the concept of universal structure for ordinary categories, it is now much clearer how to extend it to fibrations. What we need is a Yoneda structure on the 2-category of fibrations. The 2-category of fibrations is studied extensively in Hermida’s thesis [34]; Yoneda structures are an established category theoretic notion that allows an abstract account of representability [81, 80,77]. It seems likely that the 2-category of fibrations does posses a Yoneda structure and hence allows us to give an account of representability, and we hope to investigate that further. The formulation of fibrations as bicategory enriched categories [9,26,79] should also be investigated, since this seems to provide a natural and concise way to treat universal structure across different fibres. For example, locally small fibrations with B-products and B-coproducts correspond to such enriched categories with cotensors and tensors, respectively.

Another direction is to investigate consequences of our analysis in terms of Lawvere’s [45] generalised logic. From this view point, for example, operations given by universal structure have a strong connection with the description operator.

We hope to present our proposed computer checked language for categories with structure to category theorists working on coherence problems to see their reaction. There are many difficult, highly technical coherence problems being addressed by category theorists nowadays, for instance in the study of higher order categories, such as tricategories, quadricategories, and beyond [66]. The very definition of tricategory requires several pages and the higher order categories are so complex that they have not yet had a complete formal definition. It seems obvious that computer checking could provide a valuable aid to these endeavours. In fact, that has already been achieved to a certain extent by use of programs to calculate the cocycle equations for higher order categories and by use of PROLOG in connection with n-categories and pasting problems [10]. We hope that our investigation may help in this regard, and we hope to further develop our language after consultation with category theorists about their specific needs. We also hope to develop this language based upon the needs of computer scientists working with category theory, continuing to develop the programme outlined by Rydeheard and Burstall [71].

To achieve this goal, we need to account for monoidal structure. In general, monoidal structure is not universal structure, but many instances of monoidal structure are defined by universal properties, typically by colimits. We hope to capture common aspects of such instances in our abstract framework.

Finally, we seek to develop our categorical framework for type theory. There are several issues that we have not yet addressed. For instance, our framework only addresses those functors that strictly preserve structure, such as functors that send an assigned terminal object to an assigned terminal object as explained in [65,66]. These are too restrictive for category theorists even in modelling logic. Moreover, the abstract framework for our computer checked language can already account for the more general functors that are much more common in category theory, such as those functors that preserve a terminal object in the usual sense, meaning up to coherent isomorphism. In ”Why Tricategories?” [65,66]there is an informal account not only of the importance of this endeavour, but also how one might address it. We plan to provide the details, thus extending the relationship we have provided between type theory and categories with structure. In contrast to ”Why Tricategories?”, our classification is in terms of universal structure, rather than in terms of operations and equations, and we believe that this will make the relationship easier to describe.

Less directly arising from this thesis, we have gained much deeper understanding of the relationship between categories with structure and type theories, and how to formalise the proofs of theorems about categories with structure. We hope to bring this knowledge to bear on a treatment of a semantics of particular feature of programming languages and their underlying type theories. Specifically, we plan to analyse the semantics of local variables using the structures we have developed. The study of local variables is intimately linked to the study of parametricity, and hence to the study of fibrations [88,89,69,34,37]. We plan to do this based upon the work of O’Hearn and Tennent [87,88,57,58,89,56] and in collaboration with them.

Appendix A

Proofs of Chapter 6

A.1.1 Proof of Proposition 6.4.2

To prove soundness of a translation [[−]]_{T F λ}, the following substitution lemma is needed.

Lemma A.1.7. Let [[−]]_{T F λ} be a translation from a λP1 theory T_{G} to a T F λ theory T_{F}. Then the equality judgements

[[y⃗: G⃗]]⊢[[H[x⃗/A⃗]]]^{y⃗:G⃗} = [[H]]^{x⃗:K⃗}[u_{n}]: Type

and

[[y⃗: G⃗]]⊢[[C[x⃗/A⃗]]]^{y⃗:G⃗} = [[C]]^{x⃗:K⃗}[u_{n}]: 1 ⇒ [[H]]^{x⃗:K⃗}[u_{n}]

are derivable in T_{F}, where u_{n} is the context mapping defined in Definition 6.2.1 and x⃗: K⃗⊢H: Type, x⃗: K⃗⊢C: H, and y⃗: G⃗⊢A_{i}: K_{i}[x_{1}, ⋯ x_{i−1}/A_{1}, ⋯ A_{i−1}] with (1 ≤ i ≤ n) are derivable in T_{G}.

Proof By induction on derivations in T_{G}. The case H ≡ Πx_{n+1}: K_{n+1}.H′[x_{n+1}], for example, is checked as follows.

Let v_{n+1} be the context mapping defined by

v_{0} = !_{[[_{y⃗:G⃗,y_{n+1}:K_{n+1}[x⃗/A⃗]}]]}
v_{i} = ≺v_{i−1}, [[A_{i}]]^{y⃗:G⃗,y_{n+1}:K_{n+1}[x⃗/A⃗]}≻
(1 ≤ i ≤ n)
v_{n+1} = ≺v_{n}, χ_{1⇒[[K_{n+1}[x⃗/A⃗]]]^{y⃗:G⃗,y_{n+1}:K_{n+1}[x⃗/A⃗]}}≻.

From the equations

[[A_{i}]]^{y⃗:G⃗,y_{n+1}:K_{n+1}[x⃗/A⃗]} = [[A_{i}]]^{y⃗:G⃗}[d_{1⇒[[K_{n+1}[x⃗/A⃗]]]^{y⃗:G⃗}}],

one gets

v_{n+1} = ≺u_{n}∘d_{1⇒[[K_{n+1}[x⃗/A⃗]]]^{y⃗:G⃗}}, χ_{1⇒[[K_{n+1}[x⃗/A⃗]]]^{y⃗:G⃗,y_{n+1}:K_{n+1}[x⃗/A⃗]}}≻.

Then it follows that

[[(Πx_{n+1}: K_{n+1}.H′[x_{n+1}])[x⃗/A⃗]]]^{y⃗:G⃗}
= [[Πy_{n+1}: K[x⃗/A⃗].H′[x⃗/A⃗, x_{n+1}/y_{n+1}]]]^{y⃗:G⃗}
= Π_{1⇒[[K[x⃗/A⃗]]]^{y⃗:G⃗}}.[[H′[x⃗/A⃗, x_{n+1}/y_{n+1}]]]^{y⃗:G⃗,y_{n+1}:K[x⃗/A⃗]}
= Π_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[u_{n}]}.[[H′]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}[v_{n+1}]
= Π_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[u_{n}]}.([[H′]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}
[≺u_{n}∘d_{1⇒[[K_{n+1}[x⃗/A⃗]]]^{y⃗:G⃗}}, χ_{1⇒[[K_{n+1}[x⃗/A⃗]]]^{y⃗:G⃗}}≻])
= (Π_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}.[[H′]]^{x⃗:K⃗,x_{n+1}:K_{n+1}})[u_{n}]
= [[Πx_{n+1}: K_{n+1}.H′[x_{n+1}]]][u_{n}].

Other cases can be checked in a similar way.

Proof (of Proposition 6.4.2) By induction on derivations in T_{G}.

If the last rule used is one of the structural inference rules or one of the equality inference rules (reflexivity), (symmetry), (transitivity), (replacement) and (compatibility), then an easy induction step gives the desired judgement in T_{F}. As for (congruence1) and (congruence2), induction steps follow from Lemma A.1.7.

What remains is to check the equality inference rules (β) and (η). For (β), as a special case of Lemma A.1.7, one has

[[A[x_{n+1}/B′]]]^{x⃗:K⃗} = [[A]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}[≺id_{[[_{x⃗:K⃗}]]}, [[B′]]^{x⃗:K⃗}≻].

Then, the inference rule (ETM10) gives

[[(λx_{n+1}: K_{n+1}.(A))B′]]
= (φ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}^{[[H]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}})[≺id_{[[_{x⃗:K⃗}]]}, [[B′]]^{x⃗:K⃗}≻]∘λ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}.([[A]]^{x⃗:K⃗,x_{n+1}:K_{n+1}})
= (φ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}^{[[H]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}}∘(λ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}.([[A]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}))[d_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}])
[≺id_{[[_{x⃗:K⃗}]]}, [[B′]]^{x⃗:K⃗}≻]
= [[A]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}[≺id_{[[_{x⃗:K⃗}]]}, [[B′]]^{x⃗:K⃗}≻]
= [[A[x_{n+1}/B′]]]^{x⃗:K⃗}

as desired. To prove that (η) is soundly translated, the Beck-Chevalley condition (ETY3) and (ETY12) are required as well as (ETM11). With (ETY3), one gets

[[Πx_{n+1}: K_{n+1}.H]]^{x⃗:K⃗,z:K_{n+1}} = [[Πx_{n+1}: K_{n+1}.H]]^{x⃗:K⃗}[d_{1}]
= (Π_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}.[[H]]^{x⃗:K⃗,x_{n+1}:K_{n+1}})[d_{1}]
= Π_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[d_{1}]}.[[H]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}[≺d_{1}∘d_{2}, χ_{2}≻],

where d_{1} = d_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}, d_{2} = d_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[d_{1}]}, and χ_{2} = χ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[d_{1}]}. The rule (η) is checked as follows.

[[λz: K_{n+1}.(B)z]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}
= λ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[d_{1}]}.(ϕ_{1}[≺id_{[[_{x⃗:K⃗}]]}, [[z]]^{x⃗:K⃗,z:K_{n+1}}≻]∘[[B]]^{x⃗:K⃗,x_{n+1}:K_{n+1}})
= λ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[d_{1}]}.(ϕ_{2}[≺d_{1}∘d_{2}, χ≻][≺id_{[[_{x⃗:K⃗}]]}, χ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}≻]
∘[[B]]^{x⃗:K⃗,x_{n+1}:K_{n+1}})
= λ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[d_{1}]}.(ϕ_{2}[≺d_{1}, χ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}≻]∘[[B]]^{x⃗:K⃗,x_{n+1}:K_{n+1}})
= λ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[d_{1}]}.(ϕ_{2}∘[[B]]^{x⃗:K⃗}[d_{1}])
= [[B]]^{x⃗:K⃗}

where ϕ_{1} = φ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[d_{1}]}^{[[H]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}[≺d_{1}∘d_{2},χ≻]} and ϕ_{2} = φ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}^{[[H]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}}.

A.1.2 Proof of Proposition 6.4.4

To show the faithfulness of [[−]]_{F(T_{G})}, some preparation is needed. The technical difficulty is that if we naively translate a term A: H of T_{G} to that of F(T_{G}) by [[−]]_{F(T_{G})} and then translate it back to T_{G}, the resulting term has the type 1 ⊃ [[[[H]]]] rather than [[[[H]]]].

Proposition A.1.8. (Definition-Proposition) For each well-formed type x⃗: K⃗⊢H: Type of T_{G}, the following well-formed type and terms are defined.

• z⃗: 1⊃(K⃗)ˆ ⊢Ĥ: Type, where z⃗: 1⊃(K⃗)ˆ = z_{1}: 1⊃(K_{1})ˆ , ⋯, z_{n}: ⊃K_{n}.

• z⃗: 1⊃(K⃗)ˆ ⊢Â: 1⊃(H)ˆ , where x⃗: K⃗⊢A: H.

• x⃗: K⃗⊢B̌: H, where z⃗: 1⊃(K⃗)ˆ ⊢B: 1⊃(H)ˆ .

These satisfy the condition that x⃗: K⃗⊢Âˇ = A: H and z⃗: 1⊃(K⃗)ˆ ⊢B̌ˆ = B: 1⊃(H)ˆ are derivable in T_{G}, that is, the maps A ↦ Â, B ↦ B̌ are bijective.

Proof The definition is given by induction on the derivation of x⃗: K⃗⊢H: Type. We use the notation in the corresponding inference rules of λP1.

• (constant1)

– For x⃗: K⃗⊢F: Type(x⃗), z⃗: 1⊃(K⃗)ˆ ⊢F̂[z⃗] ≡ F((z⃗)ˇ ): Type where (z⃗)ˇ = ž_{1}, ž_{2}, ⋯, ž_{n}.

– For x⃗: K⃗⊢A[x⃗]: F(x⃗), z⃗: 1⊃(K⃗)ˆ ⊢Â[z⃗] ≡ λv: 1.(A[(z⃗)ˇ ]): 1⊃F̂.

– For z⃗: 1⊃(K⃗)ˆ ⊢B[z⃗]: 1⊃F̂, x⃗: K⃗⊢B̌[x⃗] ≡ B[ˆx⃗](∗): (x⃗)

• (subst1)

– For y⃗: G⃗⊢F(A⃗): Type, w⃗: 1⊃(G⃗)ˆ ⊢(F(A⃗))ˆ ≡ F(A⃗[y⃗/(w⃗)ˇ ]): Type.

– For y⃗: G⃗⊢C: F(A⃗), w⃗: 1⊃(G⃗)ˆ ⊢Ĉ[w⃗] ≡ λv: 1.(C[y⃗/(w⃗)ˇ ]): 1⊃(F(A⃗))ˆ .

– For w⃗: 1⊃(G⃗)ˆ ⊢B: 1⊃(F(A⃗))ˆ ,

y⃗: G⃗⊢B̌[y⃗] ≡ (B[w⃗/ˆy⃗])(∗): F(A⃗).

• (Π F)

– For x⃗: K⃗⊢Πx_{n+1}: K_{n+1}.H: Type,

z⃗: 1⊃(K⃗)ˆ ⊢(Πx_{n+1}: K_{n+1}.H)ˆ ≡Πz_{n+1}: 1⊃K̂_{n+1}.Ĥ[z⃗, z_{n+1}]: Type

– For x⃗: K⃗⊢A: Πx_{n+1}: K_{n+1}.H,

z⃗: 1⊃(K⃗)ˆ ⊢ Â[z⃗] ≡ λv: 1.(λz_{n+1}: 1⊃K̂_{n+1}.((A[x⃗/(z⃗)ˇ ](ž_{n+1}))ˆ (∗))) : 1⊃(Πx_{n+1}: K_{n+1}.H)ˆ .

– For z⃗: 1⊃(K⃗)ˆ ⊢B: 1⊃(Πx_{n+1}: K_{n+1}.H)ˆ ,

x⃗: K⃗ ⊢ B̌[x⃗]≡λx_{n+1}: K_{n+1}.((λv: 1.(B[z⃗/ˆx⃗](∗)(x̂_{n+1})))ˇ )

: Πx_{n+1}: K_{n+1}.H.

• For other type forming inference rules such as (weakening), the definition is obvious.

Definition A.1.9. [[−]]_{G} is a pretranslation from F(T_{G}) to T_{G} given by [[F̃]]_{G} = F̂ and [[C̃]]_{G} = Ĉ for constants.

To show that [[−]]_{G} is indeed a translation, the next proposition suffices.

Proposition A.1.10. The iterated translation [[[[−]]_{F(T_{G})}]]_{G} from T_{G} to itself coincides with the maps A ↦ Â on terms up to equality in T_{G}. More precisely, for every x⃗: K⃗⊢A: H derivable in T_{G}, the equality judgement

z_{1}: 1⊃K̂_{1}, ⋯, z_{n}: 1⊃K̂_{n}⊢[[[[A]]_{F(T_{G})}]]_{G} = Â: 1⊃Ĥ

is derivable in T_{G}.

Proof (of Proposition 6.4.4) Applying [[−]]_{G}, one gets a derivable judgement

z_{1}: [[[[K_{1}]]_{F(T_{G})}]]_{G}, ⋯, z_{n}: [[[[K_{n}]]_{F(T_{G})}]]_{G}⊢ \begin{matrix}[[[[A]]_{F(T_{G})}]]_{G} = [[[[A′]]_{F(T_{G})}]]_{G} \\ : 1⊃[[[[H]]_{F(T_{G})}]]_{G} \end{matrix}

of T_{G}. By the previous proposition, this is equivalent to

z_{1}: 1⊃K̂_{1}, ⋯, z_{n}: 1⊃K̂_{n}⊢Â = Â′: 1⊃Ĥ.

So, A = A′.

A.1.3 Proof of Proposition 6.4.6

Proof By induction on derivations in T F λ. For structural judgements, easy induction steps show that [[−]]_{λP1} results wellformed expressions of T_{G} with desired typing.

For an equality judgement, if the last rule used in the derivation is one of (symmetry), (reflexivity), (transitivity), (replacement), and (compatibility) rules of T F λ, then corresponding rule of λP1 combined with induction hypotheses gives the desired equality judgement of T_{G}.

Hence, it is sufficient to show that, for each equality inference rule

\begin{aligned}J_{1} & J_{2} & & ⋯ & J_{n} \\ & & J \end{aligned}

of T F, the translation of J is derivable from those of J_{i}’s in T_{G}.

(ECM1) [[id_{Γ}∘u]] = (v_{K_{1}L_{1}}[v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}], ⋯,
v_{K_{n}L_{n}}[v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}])
= (B_{1}, ⋯, B_{n}) = [[u]]
(ECM2)  (similar to (ECM1))

(ECM3) [[(u∘v)∘w]]
= (B_{1}[v_{G_{1}H_{1}}/C_{1}, ⋯, v_{G_{m}H_{m}}/C_{m}][v_{I_{1}J_{1}}/D_{1}, ⋯, v_{I_{l}J_{l}}/D_{l}], ⋯,
B_{n}[v_{G_{1}H_{1}}/C_{1}, ⋯, v_{G_{m}H_{m}}/C_{m}][v_{I_{1}J_{1}}/D_{1}, ⋯, v_{I_{l}J_{l}}/D_{l}])
= (B_{1}[v_{G_{1}H_{1}}/C_{1}[v_{I_{1}J_{1}}/D_{1}, ⋯, v_{I_{l}J_{l}}/D_{l}], ⋯,
v_{G_{m}H_{m}}/C_{m}[v_{I_{1}J_{1}}/D_{1}, ⋯, v_{I_{l}J_{l}}/D_{l}]], ⋯,
B_{n}[v_{G_{1}H_{1}}/C_{1}[v_{I_{1}J_{1}}/D_{1}, ⋯, v_{I_{l}J_{l}}/D_{l}], ⋯,
v_{G_{m}H_{m}}/C_{m}[v_{I_{1}J_{1}}/D_{1}, ⋯, v_{I_{l}J_{l}}/D_{l}]])
= [[u∘(v∘w)]]

where

Ξ = (I_{1} ⇒ J_{1}, ⋯, I_{l} ⇒ J_{l})
[[w]] = (D_{1}, ⋯, D_{l})

(ECM4) [[w]] = ( ) = [[!_{Γ}]]
(ECM5) [[d_{K⇒L}∘≺u, A≻]]
= (v_{K_{1}L_{1}}[v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}, v_{KL}/[[A]]], ⋯,
v_{K_{n}L_{n}}[v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}, v_{KL}/[[A]]])
= (B_{1}, ⋯, B_{n}) = [[u]]
(ECM6) [[≺d_{K⇒L}∘w, χ_{K⇒L}[w]≻]]
= (v_{K_{1}L_{1}}[v_{K_{1}L_{1}}/D_{1}, ⋯, v_{K_{n}L_{n}}/D_{n}, v_{KL}/D_{n+1}], ⋯,

v_{K_{n}L_{n}}[v_{K_{1}L_{1}}/D_{1}, ⋯, v_{K_{n}L_{n}}/D_{n}, v_{KL}/D_{n+1}],

v_{KL}[v_{K_{1}L_{1}}/D_{1}, ⋯, v_{K_{n}L_{n}}/D_{n}, v_{KL}/D_{n+1}])
= (D_{1}, ⋯, D_{n+1})

where

[[w]] = (D_{1}, ⋯, D_{n+1})

(ET Y 1) [[K[id_{Γ}]]] = [[K]][v_{K_{1}L_{1}}/v_{K_{1}L_{1}}, ⋯, v_{K_{n}L_{n}}/v_{K_{n}L_{n}}]
= [[K]]
(ET Y 2) [[K[u][v]]] = [[K]][v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}][v_{G_{1}H_{1}}/C_{1}, ⋯, v_{G_{m}H_{m}}/C_{m}]
= [[K]][v_{K_{1}L_{1}}/B_{1}[v_{G_{1}H_{1}}/C_{1}, ⋯, v_{G_{m}H_{m}}/C_{m}], ⋯,
v_{K_{n}L_{n}}/B_{1}[v_{G_{1}H_{1}}/C_{1}, ⋯, v_{G_{m}H_{m}}/C_{m}]]
= [[K[u∘v]]]

(ETY3) [[Π_{K⇒L}.H[u]]]
= (Πz: ([[K]] ⊃ [[L]]).[[H]][v_{KL}/z])[v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}]
= Πz′: [[K]][v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}]⊃[[L]][v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}].
[[H]][v_{KL}/z][v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}][z/z′]
= Πz′: [[K[u]]]⊃[[L[u]]].
[[H[≺u∘d_{K[u]⇒L[u]}, χ_{K[u]⇒L[u]}≻]]][v_{KL}/z′]
= [[Π_{K[u]⇒L[u]}.H[≺u∘d_{K[u]⇒L[u]}, χ_{K[u]⇒L[u]}≻]]]
(ET M1) [[id_{L}∘A]]  = λx: [[K]].((λz: [[L]].(z))([[A]]x))
= λx: [[K]].([[A]]x)
= [[A]]
(ET M2)  (similar to (ET M1))
(ET M3) [[(C∘B)∘A]] = λx: [[K]].((λx′: [[L]].([[C]]([[B]]x′)))([[A]]x))
= λx: [[K]].([[C]]([[B]]([[A]]x)))
= λx: [[K]].([[C]]((λx′: [[G]].([[B]]([[A]]x′)))x))
= [[C∘(B∘A)]]
(ET M4) [[C]]  = λz: 1.([[C]]z)
= λz: 1.(∗)
= [[!_{K} ]]

(ET M5) [[A[id_{Γ}]]] = [[A]][v_{K_{1}L_{1}}/v_{K_{1}L_{1}}, ⋯, v_{K_{n}L_{n}}/v_{K_{n}L_{n}}]
= [[A]]
(ET M6) (similar to (ET Y 2))

(ET M7) [[id_{K}[u]]]  = λx: [[K]].(x)[v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}]
= λx: [[K[u]]].(x) = [[id_{K[u]}]]
(ET M8) [[B[u]∘A[u]]] = λx: [[K[u]]].([[B]][v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}]
([[A]][v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}]x))
= (λx: [[K]].([[B]]([[A]]x)))[v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}]
= [[(B∘A)[u]]]

\begin{aligned}(ETM9) & [[χ_{K⇒L}[≺u, A≻]]] & = & v_{KL}[v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}, v_{KL}/[[A]]] \\ & & = & [[A]] \end{aligned}

Appendix A. Proofs of Chapter 6 189

(ET M10) [[φ_{K⇒L}^{H}∘(λ_{K⇒L}.(A)[d_{K⇒L}])]]
= λx: [[G]].((λx′: [[Π_{K⇒L}.H]].(x′v_{KL}))
((λz: [[G]].λz′: ([[K]] ⊃ [[L]]).[[A]][v_{KL}/z′]z)x))
= λx: [[G]].([[A]]x)
= [[A]]
(ET M11) [[λ_{K⇒L}.(φ_{K⇒L}^{H}∘B[d_{K⇒L}])]]
= λx: [[G]].λz: ([[K]] ⊃ [[L]]).((λx′: [[G]].
((λz′: [[Π_{K⇒L}.H]].(z′v_{KL}))([[B]]x′)))[v_{KL}/z])x
= λx: [[G]].λz: ([[K]] ⊃ [[L]]).λx′: [[G]].([[B]]x′zx)
= [[B]]

\begin{matrix}(ET M12) & [[φ_{K⇒L}^{H}[≺u∘d_{K[u]⇒L[u]}, χ_{K[u]⇒L[u]}≻]]] \\ = & (λx: [[Π_{K⇒L}.H]].(x v_{KL}))[v_{K_{1}L_{1}}/B_{1}, ⋯, v_{K_{n}L_{n}}/B_{n}, v_{KL}/v_{K[u]L[u]}] \\ = & λx: [[Π_{K⇒L}.H[u]]].(x v_{K[u]L[u]}) \\ = & [[φ_{K[u]⇒L[u]}^{H[≺u∘d_{_{K[u]}_{⇒}_{L[u]}},χ_{_{K[u]}_{⇒}_{L[u]}}≻]}]] \end{matrix}

A.1.4 Proof of Theorem 6.5.4

First, observe: Lemma A.1.11. In any T F ι theory T_{F}, a well-formed context (Γ, K ⇒ L) is isomorphic to (Γ, 1 ⇒ K⊃L). Proof In T_{F}, the following two terms can be derived.

(Γ, K ⇒ L)⊢χ_{K⇒L}: K[d_{K⇒L}] ⇒ L[d_{K⇒L}]

(Γ, K ⇒ L)⊢P_{KL} ≡ code_{K[d_{K⇒L}]⇒L[d_{K⇒L}]}(χ_{K⇒L}): 1 ⇒ K[d_{K⇒L}]⊃L[d_{K⇒L}]

Γ, 1 ⇒ K⊃L⊢χ_{1⇒K⊃L}: 1 ⇒ K⊃L

Γ, 1⇒K⊃L⊢Q_{KL} ≡decode_{K[d_{K⇒L}]⇒L[d_{K⇒L}]}(χ_{1⇒K⊃L}): K[d_{1⇒K⊃L}]⇒L[d_{1⇒K⊃L}] Then, context mappings ≺d_{K⇒L}, P_{KL}≻ and ≺d_{1⇒K⊃L}, Q_{KL}≻ give a desired isomorphism.

The full version of Theorem 6.5.4 is as follows.

Theorem A.1.12. (Definition-Theorem) Given a T F ι theory T_{F}, the following are defined and satisfy the conditions below.

• For each well-formed expression E of T_{F}, its h.e. form E^{+} is defined and

satisfies a well-formedness condition.

– For Γ Context, Γ^{+} Context.

– For u: Δ → Γ, u^{+}: Δ^{+} → Γ^{+}.

– For Γ⊢H: Type, Γ^{+}⊢H^{+}: Type.

– For Γ⊢A: K ⇒ L, Γ^{+}⊢A^{+}: 1 ⇒ K^{+}⊃L^{+}.

• For each well-formed context Γ, there are two context mappings α_{Γ}: Γ → Γ^{+} and β_{Γ}: Γ^{+} → Γ satisfying α_{Γ}∘β_{Γ} = id_{Γ^{+}}: Γ^{+} → Γ^{+} and β_{Γ}∘α_{Γ} = id_{Γ}: Γ → Γ.

• For each context mapping u: Δ → Γ, u^{+}∘α_{Δ} = α_{Γ}∘u: Δ → Γ^{+} holds.

• For each type Γ⊢K: Type, there are terms Γ⊢γ_{K}: K ⇒ K^{+}[α_{Γ}] and Γ⊢δ_{K}: K^{+}[α_{Γ}] ⇒ K satisfying Γ⊢γ_{K}∘δ_{K} = id_{K^{+}[α_{Γ}]}: K^{+}[α_{Γ}] ⇒ K^{+}[α_{Γ}] Γ⊢δ_{K}∘γ_{K} = id_{K}: K ⇒ K.

• The map A ↦ A^{+} is bijective and the inverse is

B ↦ B^{−} ≡ δ_{L}∘decode_{K^{+}⇒L^{+}}(B)[α_{Γ}]∘γ_{K}.

These are all mutually defined by induction on derivations in T_{F}.

(C1) ()^{+} = ()
α_{()} = β_{()} = id_{()}
(C2) (Γ, K ⇒ L)^{+} = (Γ^{+}, 1 ⇒ K^{+}⊃L^{+})
α_{(Γ,K⇒L)} = ≺d_{K^{+}}_{⇒}_{L^{+}}, P_{K^{+}}_{L^{+}}≻
∘≺α_{Γ}∘d_{K⇒L}, γ_{L}[d_{K⇒L}]∘χ_{K⇒L}∘δ_{K}[d_{K⇒L}]≻
β_{(Γ,K⇒L)}
= ≺β_{Γ}∘Q_{K^{+}}_{L^{+}}, δ_{L}[β_{Γ}∘d_{K^{+}}_{⇒}_{L^{+}}]∘Q_{K^{+}}_{L^{+}}
∘γ_{L}[β_{Γ}∘d_{K^{+}}_{⇒}_{L^{+}}]≻∘
≺d_{K^{+}}_{⇒}_{L^{+}}, Q_{K^{+}}_{L^{+}}≻

(CM1) (id_{Γ})^{+} = id_{Γ^{+}}
(CM2) (u∘v)^{+} = u^{+}∘v^{+}
(CM3) (!_{Γ})^{+} = !_{Γ^{+}}
(CM4) (d_{K⇒L})^{+} = d_{1⇒K^{+}⊃L^{+}}
(CM5) (≺u, A≻)^{+} = ≺u^{+}, A^{+}≻
(TY1) 1^{+} = 1
(TY2) F^{+} = F[β_{Γ}]
γ_{F} = δ_{F} = id_{F}
(TY3) (H[u])^{+} = H^{+}[u^{+}]  γ_{H[u]} = γ_{H}[u]  δ_{H[u]} = δ_{H}[u]
(TY4) (Π_{K⇒L}.H)^{+} = Π_{1⇒K^{+}⊃L^{+}}.H^{+}
γ_{Π_{K⇒L}.H} = λ_{K⇒L}.((δ_{H}∘φ_{1⇒K^{+}⊃L^{+}}^{H^{+}})[α_{(Γ,K⇒L)}])
δ_{Π_{K⇒L}.H} = λ_{1⇒K^{+}⊃L^{+}}.((γ_{H}∘φ_{K⇒L}^{H})[β_{(Γ,K⇒L)}])[α_{Γ}]
(TY5) (Σ_{K⇒L}.G)^{+} = Σ_{1⇒K^{+}⊃L^{+}}.G^{+}
γ_{Σ_{K⇒L}.H} = ν_{1⇒K^{+}⊃L^{+}}.((ψ_{K⇒L}^{G}∘δ_{G})[β_{(Γ,K⇒L)}])[α_{Γ}]
δ_{Σ_{K⇒L}.H} = ν_{K⇒L}.((ψ_{1⇒K^{+}⊃L^{+}}^{G^{+}}∘γ_{G})[α_{(Γ,K⇒L)}])

(TM1) C^{+} = C[β_{Γ}]
(TM2) id_{K}^{+} = id_{K^{+}}
(TM3) (B∘A)^{+} = code_{K^{+}}_{⇒}_{G^{+}}(decode_{L^{+}⇒G^{+}}(B^{+})∘decode_{K^{+}⇒L^{+}}(A^{+}))
(TM4) !_{K}^{+} = !_{K^{+}}
(TM5) χ_{K⇒L}^{+} = χ_{1⇒K^{+}⊃L^{+}}
(TM6) (A[u])^{+} = A^{+}[u^{+}]
(TM7) (λ_{K⇒L}.(A))^{+}
= code_{G^{+}}_{⇒}_{(Π_{K⇒L}.H)^{+}}(λ_{1⇒K^{+}⊃L^{+}}.(decode_{G^{+}[d]⇒H^{+}}(A^{+})))
(TM8) (φ_{K⇒L}^{H})^{+} = φ_{1⇒K^{+}⊃L^{+}}^{H^{+}}
(TM9) (ν_{K⇒L}.(A))^{+}
= code_{(Σ_{K⇒L}.G)^{+}}_{⇒}_{H^{+}}(ν_{1⇒K^{+}⊃L^{+}}.(decode_{G^{+}⇒H^{+}[d]}(A^{+})))
(TM10) (ψ_{K⇒L}^{G})^{+} = ψ_{1⇒K^{+}⊃L^{+}}^{G^{+}}
(TM11) ι_{K}^{+} = code_{K^{+}}_{⇒}_{(Σ_{1⇒K}.1)^{+}}(ι_{K^{+}})

Proof Required conditions are checked by straightforward calculation.

Note that A^{+} is equal to code_{K^{+}}_{⇒}_{L^{+}}((γ_{L}∘A∘δ_{K})[β_{Γ}]), but this expression is not h.e..

A.1.5 Proof of Proposition 6.5.6

Proof In the forward direction, one can show that two maps u ↦ curr_{K}(χ_{1⇒L}[u]) and A ↦ ≺d_{1⇒K}, uncurr_{K}(A)≻ are reciprocal to each other. In the reverse direction, if the bijection A ↔ u is given, the inverse of ν_{1⇒K}.(χ_{1⇒K}) is obtained as the term Γ⊢A: K ⇒ Σ_{1⇒K}.1 that corresponds to

≺d_{1⇒K}, ψ_{1⇒K}^{1}≻: (Γ, 1 ⇒ K) → (Γ, 1 ⇒ Σ_{1⇒K}.1).

A.1.6 Proof of Proposition 6.6.2

Lemma A.1.13. The substitution lemma A.1.7 for [[−]]_{T F λ} also holds for any translation [[−]]_{T F ι} from a wML theory T_{w} to a T F ι theory T_{F}.

Proof We only give the proof for the case of let⟨x_{n+1},w⟩=B in C, i.e., if

x⃗: K⃗⊢H: Type,
x⃗: K⃗, x_{n+1}: K_{n+1}, w: G⊢C: H,
x⃗: K⃗⊢B: Σx_{n+1}: K_{n+1}.G, and
y⃗: G⃗⊢A_{i}: K_{i}[x_{1}, ⋯ x_{i−1}/A_{1}, ⋯ A_{i−1}](1 ≤ i ≤ n)

are derivable in T_{w}, one has the following equality judgement in T_{F}.

[[y⃗: G⃗]] ⊢ [[(let⟨x_{n+1},w⟩=B in C)[x⃗/A⃗]]]^{y⃗:G⃗} = [[let⟨x_{n+1},w⟩=B in C]]^{x⃗:K⃗}[u_{n}]
: 1 ⇒ [[H]]^{x⃗:K⃗}[u_{n}]

where u_{n} is the context mapping defined in the clause for (subst1) of Definition 6.4.1.

[[(let⟨x_{n+1},w⟩=B in C)[x⃗/A⃗]]]_{T F ι}^{x⃗:K⃗} = [[let⟨y_{n+1},w′⟩=B[x⃗/A⃗] in C′]]^{x⃗:K⃗}

= ν_{1⇒[[K_{n+1}′]]^{y⃗:G⃗}}.(ν_{1⇒G′}.(C′)∘ι_{G′})∘[[B[x⃗/A⃗]]]^{y⃗:G⃗}
= ν_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[u_{n}]}.(ν_{1⇒G_{1}[≺u_{n}∘d_{1},χ_{1}≻]}.(C_{1}[≺≺u_{n}∘d_{1}∘d_{2}, χ_{1}[d_{2}]≻, χ_{2}≻])∘
ι_{G_{1}[≺≺u_{n}∘d_{1}∘d_{2},χ_{1}[d_{2}]≻,χ_{2}≻]})∘[[B]]^{x⃗:K⃗}[u_{n}]
= ν_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[u_{n}]}.(ν_{1⇒G_{1}[≺u_{n}∘d_{1},χ_{1}≻]}.(
(C_{1}∘ι_{G_{1}})[≺≺u_{n}∘d_{1}∘d_{2}, χ_{1}[d_{2}]≻, χ_{2}≻]))∘[[B]]^{x⃗:K⃗}[u_{n}]
= (ν_{1⇒[[K_{n+1}]]^{x⃗:K⃗}}.(ν_{1⇒G_{1}}.(C_{1})∘ι_{G_{1}})∘[[B]]^{x⃗:K⃗}[u_{n}])[u_{n}]
= [[let⟨x_{n+1},w⟩=B in C]]^{x⃗:K⃗}

where

K_{n+1}′ = K_{n+1}[x⃗/A⃗], G_{1} = [[G]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}, C_{1} = [[C]]^{x⃗:K⃗,x_{n+1}:K_{n+1},w:G}, G′ = [[G[x⃗/A⃗, x_{n+1}/y_{n+1}]]]^{y⃗:G⃗,y_{n+1}:K_{n+1}′}, C′ = [[C[x⃗/A⃗, x_{n+1}/y_{n+1}, w/w′]]]^{y⃗:G⃗,y_{n+1}:K_{n+1}′,w′:G′}, d_{1} = d_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[u_{n}]}, χ_{1} = χ_{1⇒[[K_{n+1}]]^{x⃗:K⃗}[u_{n}]}, d_{2} = d_{1⇒G_{1}[≺u_{n}∘d_{1},χ_{1}≻]}, and χ_{1} = χ_{1⇒G_{1}[≺u_{n}∘d_{1},χ_{1}≻]}.

Proof (of Proposition 6.6.2) With the above lemma, it is sufficient to check (β′) and (η′) rules in Section 5.2.3 are soundly translated. The notation is the same as the one used in Section 5.2.3. With abbreviation

K_{1} = [[K_{n+1}]]^{x⃗:K⃗}, G_{1} = [[G]]^{x⃗:K⃗,x_{n+1}:K_{n+1}}, B_{1} = [[B]]^{x⃗:K⃗,x_{n+1}:K_{n+1},y:G}, C_{1} = [[C]]^{x⃗:K⃗,z:Σx_{n+1}:K_{n+1}.G}, and Appendix A. Proofs of Chapter 6 194

S_{1} = [[Σx_{n+1}: K_{n+1}.G]]^{x⃗:K⃗}, we have the following equations.

[[let⟨x_{n+1},y⟩=⟨A_{1},A_{2}⟩ in B]]^{x⃗:K⃗}

= ν_{1⇒K_{1}}.curr_{G_{1}}(B_{1})∘ψ_{1⇒K_{1}}^{G_{1}}[≺id_{[[_{x⃗:K⃗}]]}, [[A_{1}]]^{x⃗:K⃗}≻]∘[[A_{2}]]^{x⃗:K⃗} = (ν_{1⇒K_{1}}.curr_{G_{1}}(B_{1})[d_{1⇒K_{1}}]∘ψ_{1⇒K_{1}}^{G_{1}})[≺id_{[[_{x⃗:K⃗}]]}, [[A_{1}]]^{x⃗:K⃗}≻]∘[[A_{2}]]^{x⃗:K⃗} = (ν_{1⇒G_{1}}.(B_{1})∘ι_{G_{1}})[≺id_{[[_{x⃗:K⃗}]]}, [[A_{1}]]^{x⃗:K⃗}≻]∘[[A_{2}]]^{x⃗:K⃗} = ((ν_{1⇒G_{1}}.(B_{1})∘ι_{G_{1}})[d_{1⇒S_{1}}]∘χ_{1⇒S_{1}})[≺≺id_{[[_{x⃗:K⃗}]]}, [[A_{1}]]^{x⃗:K⃗}≻, [[A_{2}]]^{x⃗:K⃗}≻] = uncurr_{S_{1}}(curr_{G_{1}}(B_{1}))[≺≺id_{[[_{x⃗:K⃗}]]}, [[A_{1}]]^{x⃗:K⃗}≻, [[A_{2}]]^{x⃗:K⃗}≻] = B_{1}[≺≺id_{[[_{x⃗:K⃗}]]}, [[A_{1}]]^{x⃗:K⃗}≻, [[A_{2}]]^{x⃗:K⃗}≻] = [[B[x_{n+1}/A_{1}, y/A_{2}]]]^{x⃗:K⃗}

[[let⟨x,y⟩=A in C[z/⟨x, y⟩]]]^{x⃗:K⃗}

= ν_{1⇒K_{1}}.(curr_{G_{1}}(C_{1}[≺d_{1⇒K_{1}}∘d_{1⇒G_{1}}, pair_{K_{1}G_{1}}≻]))∘[[A]]^{x⃗:K⃗} = ν_{1⇒K_{1}}.(curr_{G_{1}}(uncurr_{S_{1}}(curr_{S_{1}}(C_{1}))[≺d_{1⇒K_{1}}∘d_{1⇒G_{1}}, pair_{K_{1}G_{1}}≻]))∘[[A]]^{x⃗:K⃗} = ν_{1⇒K_{1}}.(curr_{G_{1}}(curr_{S_{1}}(C_{1})[d_{1⇒K_{1}}∘d_{1⇒G_{1}}]∘ψ_{1⇒K_{1}}^{G_{1}}[d_{1⇒G_{1}}]∘χ_{1⇒G_{1}}))∘[[A]]^{x⃗:K⃗} = ν_{1⇒K_{1}}.(curr_{G_{1}}(uncurr_{G_{1}}((curr_{S_{1}}(C_{1}))[d_{1⇒K_{1}}]∘ψ_{1⇒K_{1}}^{G_{1}})))∘[[A]]^{x⃗:K⃗} = ν_{1⇒K_{1}}.((curr_{S_{1}}(C_{1}))[d_{1⇒K_{1}}]∘ψ_{1⇒K_{1}}^{G_{1}})∘[[A]]^{x⃗:K⃗} = curr_{S_{1}}(C_{1})∘[[A]]^{x⃗:K⃗} = (curr_{S_{1}}(C_{1})[d_{1⇒S_{1}}]∘χ_{1⇒S_{1}})[≺id_{[[_{x⃗:K⃗}]]}, [[A]]^{x⃗:K⃗}≻] = uncurr_{S_{1}}(curr_{S_{1}}(C_{1}))[≺id_{[[_{x⃗:K⃗}]]}, [[A]]^{x⃗:K⃗}≻] = C_{1}[≺id_{[[_{x⃗:K⃗}]]}, [[A]]^{x⃗:K⃗}≻] = [[C[z/A]]]^{x⃗:K⃗}

A.1.7 Proof of Proposition 6.6.5

The proposition is proved similarly to Proposition 6.4.4. We only give extensions of the maps ˇ() and ˆ() for dependent sum types.

• (ΣF) – For x⃗: K⃗⊢Σx_{n+1}: K_{n+1}.G: Type,

z⃗: 1⊃(K⃗)ˆ ⊢(Σx_{n+1}: K_{n+1}.)ˆ ≡ Σz_{n+1}: 1⊃(K_{n+1})ˆ .Ĝ[z⃗, z_{n+1}]: Type.

– For x⃗: K⃗⊢A: Σx_{n+1}: K_{n+1}.G,

z⃗: 1⊃(K⃗)ˆ ⊢Â[z⃗] ≡ λv: 1.(let⟨u,w⟩=A in ⟨û, ŵ(∗)⟩): 1⊃(Σx_{n+1}: K_{n+1}.G)ˆ .

– For z⃗: 1⊃(K⃗)ˆ ⊢B: 1⊃(Σx_{n+1}: K_{n+1}.G)ˆ ,

x⃗: K⃗⊢B̌[x⃗] ≡ let⟨v,w⟩=B(∗) in ⟨v̌, (λv′: 1.(w))ˇ ⟩: Σx_{n+1}: K_{n+1}.G.

A.1.8 Proof of Theorem 6.6.7

With evident induction, one can prove that all introduction rules and axioms are well-formed and that [[−]]_{G(T_{F})} defines a translation.

Lemma A.1.14. The canonical translation [[−]]_{G(T_{F})} sends every well-formed type and term expression of G(T_{F}) to an h.e. type and an h.e. term of T_{F}, respectively.

Lemma A.1.15. In G(T_{F}), every well-formed type or term is equal to a constant type or a constant term.

Proof Suppose x⃗: K⃗⊢H: Type in G(T_{F}). By the above lemma, c_{[[H]]_{G(T_{F})}} is a constant symbol of G(T_{F}). The judgement

x⃗: K⃗⊢c_{[[H]]_{G(T_{F})}} = H: Type

is an axiom of G(T_{F}) since [[−]]_{G(T_{F})} sends this to

[[x⃗: K⃗]]_{G(T_{F})}⊢[[H]]_{G(T_{F})} = [[H]]_{G(T_{F})}: Type,

which is derivable in the theory T_{F} by definition. The same argument serves for term expressions.

Lemma A.1.16. For every well-formed type H of T_{F}, (I(H)_{T F ι})^{+} = [[c_{H^{+}} ]]_{T F ι} holds.

Proof By induction on the derivation of Γ⊢H: Type and Γ⊢A: K ⇒ L in T_{F}. For constant types, the lemma is obvious. As for Π_{K⇒L}.H, for example, one has

(I(Π_{K⇒L}.H)_{T F ι})^{+} = (Π_{_{I(K)_{T F ι}}⇒_{I(L)_{T F ι}}}.I(H)_{T F ι})^{+}
= Π_{1⇒I(K)_{T F ι}^{+}⊃I(L)_{T F ι}^{+}}.I(H)_{T F ι}^{+}
= Π_{1⇒[[c_{K^{+}} ]]_{T F ι}⊃[[c_{L^{+}} ]]_{T F ι}}.[[c_{H^{+}} ]]_{T F ι}
= [[Πx: (Πy: c_{K^{+}}.c_{L^{+}}).c_{H^{+}} ]]_{T F ι}
= [[c_{Π_{1⇒K^{+}⊃L^{+}}.H^{+}} ]]_{T F ι}
= [[c_{(Π_{K⇒L}.H)^{+}} ]]_{T F ι}.

Proposition A.1.17. I(−)_{T F ι} is an interpretation.

Proof Consider an introduction rule Γ⊢F: Type of T_{F}. Let Γ be the context (K_{1} ⇒ L_{1}, …, K_{n} ⇒ L_{n}). By Theorem A.1.12, Γ^{+}⊢F[β_{Γ}]: Type is derivable in T_{F}. Since Γ^{+} = (…, 1 ⇒ K^{+}⊃L^{+}, …), (…, x_{i}: c_{K^{+}}_{⊃}_{L^{+}}, …)⊢c_{F[β_{Γ}]}: Type is an introduction rule of G(T_{F}) and

(…, 1 ⇒ [[c_{K^{+}}_{⊃}_{L^{+}} ]]_{T F ι}, …)⊢[[c_{F[β_{Γ}]}]]_{T F ι}: Type

is derivable in T′_{F}. With the previous lemma, one has I(K)_{T F ι}^{+}⊃I(L)_{T F ι}^{+} = [[c_{K^{+}}_{⊃}_{L^{+}} ]]_{T F ι} and (I(Γ)_{T F ι})^{+} = (…, 1 ⇒ [[c_{Π_{1⇒K^{+}}.L^{+}[d]}]]_{T F ι}, …). Therefore,

I(Γ)_{T F ι}⊢[[c_{F[β_{Γ}]}]]_{T F ι}[α_{I(Γ)_{T F ι}}]: Type

is shown to be derivable in T′_{F}. The translations of introduction rules for terms and axioms of T_{F} are shown to be well-formed in a similar way.

Lemma A.1.18. For an h.e. type H and an h.e. term A, ([[c_{H} ]]_{T F ι})^{+} = [[c_{H^{+}} ]]_{T F ι} and ([[c_{A}]]_{T F ι})^{+} = [[c_{A^{+}} ]]_{T F ι}.

Proof (of Theorem 6.6.7) It is sufficient to note that, on constant types and terms of T_{w}, the values of the iterated translation I([[−]]_{G(T_{F})})_{T F ι} and [[−]]_{T F ι} are equal by the previous lemma.

A.1.9 Proof for Theorem 6.7.7

We only give the necessarily modification for Theorem A.1.12. The h.e. form of σ_{KL} is given by

(TM12) σ_{KL}^{+} = code_{1⇒(L[≺d,fst_{KL}≻])^{+}}(σ_{1⊃K^{+}}_{L^{+}}[≺d_{1⇒1⊃(Σ_{1⇒K}.L)^{+}}, Q_{1(Σ_{1⇒K}.L)^{+}}≻]).

Bibliography

[1] T. Altenkirch. Constructions, Inductive Types and Strong Normalization. PhD thesis, University of Edinburgh, 1993.

[2] J. L. Bell. Toposes and Local Set Theories: An Introduction, volume 14 of Oxford Logic Guides. Oxford Science Publications, 1988.

[3] J. Bénabou. Structures algébraiques dans les catégories. Cahiers de Top. et Géom. Diff., 10:1–126, 1968.

[4] J. Bénabou. 2-dimensional limits and colimits of distributors. Mathematisches Forschungsinstitut Oberwolfach, Tagungsbericht 30:6–7, 1972.

[5] J. Bénabou. Les distributeurs. Seminaires de Math Pure, Rapport No 33, 1973.

[6] J. Bénabou. Fibrations petites et localement petites. Comptes Rendus Hebdomadaires de Séances de l’Acad́emie de Sciences (Paris), Séries A et B, 281:A897–A900, 1975.

[7] J. Bénabou. Théories relative à un coupus. Comptes Rendus Hebdomadaires de Séances de l’Académie de Sciences (Paris), Séries A et B, 281:A831–A834, 1975.

[8] J. Bénabou. Fibered categories and the foundations of naive category theory. The Journal of Symbolic Logic, 50:10–37, 1985.

[9] R. Betti, A. Carboni, R. Street, and R. Walters. Variation through enrichment. Journal of Pure and Applied Algebra, 29:109–127, 1983.

[10] Richard Buckland and Michael Johnson. Modelling algebraic structures with prolog, 1995. Extended abstract of full paper for CANT’95.

[11] R. Burstall and J. McKinna. Deliverables: a categorical approach to program development in type theory. Technical Report 92-242, LFCS, 1992.

[12] A. Carboni, S. Kasangian, and R. Walters. An axiomatics for bicategories of modules. Journal of Pure and Applied Algebra, 45:127–141, 1987.

[13] J. Cartmell. Generalized Algebraic Theories and Contextual Categories. PhD thesis, Oxford, 1978.

[14] J. Cartmell. Generalized algebraic theories and contextual categories. Annals Pure Applied Logic, 32:209–243, 1986.

[15] J. Celeyrette. Fibrations et extensions de Kan, 1975. Thèse de troisièm cycle, Université Paris-Nord.

[16] J. R. B. Cockett. Distributive logic. Technical Report CS-89-01, University of Tennessee, 1989.

[17] J. R. B. Cockett and D. Spencer. Strong categorical datatypes I. In R. A. G. Seely, editor, Proc. International Meeting on Category Theory 1991, Canadian Mathmatical Society Proceedings, pages 141–169, 1991.

[18] G. Cousineau, P-L. Curien, and M. Mauny. The categorical abstract machine. In ACM Conf. on Functional Programming Languages and Computer Architecture, Nancy, 1985.

[19] P. L. Curien. Categorical Combinators, Sequential Algorithms and Functional Programming. Pitman, 1986.

[20] G. Dowek et. al. The Coq proof assistant user’s guide. Rapport Techniques 154, INRIA, Rocquencourt, France, 1993. Version 5.8.

[21] E. J. Dubuc and G. M. Kelly. A presentation of topoi as algebraic relative to categories or graphs. Journal of Pure and Applied Algebra, 81:420–433, 1983.

[22] T. Ehrhard. A categorical semantics of constructions. In Logic in Computer Science, pages 264–273, 1988.

[23] P. Gardner. Representing Logics in Type Theory. PhD thesis, University of Edinburgh, 1992.

[24] J. Giraud. Cohomologie non abélienne. Springer-Verlag, 1971.

[25] J. A. Goguen and J. Meseguer. Completeness of Many-Sorted Equational Logic. Technical Report CSLI-84-15, CENTER FOR THE STUDY OF LAN-GUAGE AND INFORMATION, 1984.

[26] R. Gordon and A. J. Power. Enrichment through variation. Technical Report 93-254, LFCS, 1993.

[27] J. W. Gray. Formal Category Theory: Adjointness for 2-Categories, volume 391 of Lecture Notes in Mathematics. Springer-Verlag, Berlin, 1974.

[28] A. Grothendieck. Catégories fibrées et descente. In Revêtements étales et groupe foundamental, Séminaire de Géométrie Algébriques du Bois-Marie 1960/61 (SGA 1). Exposé VI, 3rd ed., Institut des Haute Études Scientifiques, Paris, 1963. reprint, LNM 224, Springer-Verlag, Berlin,1971, pp.145-194.

[29] T. Hagino. A Typed Lambda Calculus with Categorical Type Constructors. In D.H. Pitt et.al., editor, Category Theory and Computer Science (LNCS 240), pages 140–157. Springer Verlag, 1987.

[30] T. Hagino. A Categorical Programming Language. PhD thesis, University of Edinburgh, 1987.

[31] B. Harper and H. Pollack. Type checking with universes. Theoretical Computer Science, 89:107–136, 1991.

[32] R. Harper, F. Honsell, and G. Plotkin. A framework for defining logics. In Proc. Symposium on Logic in Computer Science, pages 194–204, 1987.

[33] S. Hayashi. Adjunction of Semifunctors: Categorical Structures in Nonextensional Lambda Calculus. Theo. Comp. Sci., 41:95–104, 1985.

[34] C. Hermida. Fibrations, Logical Predicates and Indeterminates. PhD thesis, University of Edinburgh, 1993.

[35] Martin Hofmann. Extensional Concepts in Intensional Type Theory. PhD thesis, University of Edinburgh, 1995.

[36] J.M.E. Hyland and A.M. Pitts. The theory of constructions: Categorical semantics and topos-theoretic models. In Categories in Computer Science and Logic, pages 137–199, 1989.

[37] B. Jacobs. Categorical Type Theory. PhD thesis, Catholic University of Nijmegen, 1991.

[38] B. Jacobs. Comprehension categories and the semantics of type dependency. Theoretical Computer Science, 107:169–207, 1993.

[39] C. Jones and S. Maharaj. The New LEGO Library, 1995. available as a part of the LEGO distribution, will be available as a LFCS technical report.

[40] G.M. Kelly. Basic Concepts of Enriched Category Theory. Cambridge University Press, 1982.

[41] J. Lambek. Deductive systems and categories II. In Category Theory, Homology Theory and their Applications I, volume 86 of Lecture Notes in Mathematics, pages 76–122. Springer-Verlag, Berlin, 1969.

[42] J. Lambek. Deductive systems and categories III. In Toposes, Algebraic Geometry and Logic, volume 274 of Lecture Notes in Mathematics, pages 57–82. Springer-Verlag, Berlin, 1972.

[43] J. Lambek. From λ-calculus to cartesian closed categories. In To H.B. Curry: essays on combinatory logic, lambda calculus and formalism, pages 374–402. Academic Press, London, 1980.

[44] J. Lambek and P.J. Scott. Introduction to higher order categorical logic. Cambride University Press, Cambridge, 1986.

[45] F. W. Lawvere. Metric spaces, generalized logic, and closed categories. Rend. Sem. Mat. e Fis. di Milano, XLIII:135–166, 1973.

[46] F.W. Lawvere. Functorial semantics of algebraic theories. Proc. Nat. Acad. Sci. U.S.A, 50:869–872, 1963.

[47] Z. Luo. An Extended Calculus of Constructions. PhD thesis, University of Edinburgh, 1990.

[48] Z. Luo and R. Pollack. LEGO proof development system: User’s manual. Technical Report 92-211, LFCS, 1992.

[49] S. Mac Lane. Categories for the working mathematician, volume 5 of Graduate Text Mathematics. Springer-Verlarg, 1971.

[50] S. Mac Lane and I. Moerdijk. Sheaves in Geometry and Logic. Universitext. Springer-Verlag, New York, 1992.

[51] M. Makkai and G.E. Reys. First Order Categorical Logic, volume 611 of Lecture Notes in Mathematics. Springer Verlag, 1977.

[52] J. McKinna. Deliverables: a categorical approach to program development in type theory. PhD thesis, University of Edinburgh, 1992.

[53] J. McKinna and R. Pollack. Pure type systems formalized. In M.Bezem and J.F.Groote, editors, Proceedings of the International Conference on Typed Lambda Calculi and Applications, TLCA’93, pages 289–305. Springer-Verlag, LNCS 664, March 1993.

[54] M. V. Mendler. A Modal Logic for Handling Behavioral Constraints in Formal Hardware Verification. PhD thesis, University of Edinburgh, 1993.

[55] W. Mitchell. Boolean topoi and the theory of sets. Journal of Pure and Applied Algebra, 2:261–274, 1972.

[56] P. W. O’Hearn. A model for syntactic control of interference. Mathematical Structures in Computer Science.

[57] P. W. O’Hearn and R. D. Tennent. Semantics of local variables. In M. P. Fourman, P. T. Johnstone, and A. M. Pitts, editors, Applications of Categories in Computer Science, volume 177 of London Mathematical Society Lecture Note Series, pages 217–238. Cambridge University Press, 1992.

[58] P. W. O’Hearn and R. D. Tennent. Relational parametricity and local variables. In POPL93, pages 171–184, 1993.

[59] R. Paré and D. Schumacher. Abstract families and the adjoint functor theorems. In P. T. Johnston and R. Paré, editors, Indexed categories and their applications, volume 661 of Lecture Notes in Mathematics. Springer-Verlag, Berlin, 1978.

[60] L. C. Paulson. The Isabelle reference manual. Technical Report 283, University of Cambridge, Computer Laboratory, 1993.

[61] D. Pavlović. Predicates and fibrations. PhD thesis, Utrecht, 1990.

[62] R. Pollack. Incremental changes in LEGO: 1994, 1994. available as a part of the LEGO distribution from LFCS.

[63] R. Pollack. The Theory of LEGO: A proof Checker for the Extended Calculus

of Constructions. PhD thesis, University of Edinburgh, 1994.

[64] R. Pollack and C. Jones. Incremental changes in LEGO, 1993. available as a part of the LEGO distribution from LFCS.

[65] A. J. Power. Why tricategories? Technical Report 94-289, LFCS, 1994.

[66] A. J. Power. Why tricategories? Information and Computation, To appear.

[67] A. J. Power and C. Hermida. Abstract control structure, 1995. Draft.

[68] Project Coq. the Coq Library, 1994. available as a part of the Coq distribution from INRIA.

[69] J. C. Reynolds. Syntactic control of interference, part 2. In G. Ausiello, M. D. Ciancaglini, and S. R. D. Rocca, editors, Automata, Languages and Programming, volume 372 of Lecture Notes in Computer Science, pages 704– 722, 1989.

[70] E. Ritter. Categorical Abstract Machines for Higher-Order Typed Lambda Calculi. PhD thesis, University of Cambridge, 1992.

[71] D. E. Rydeheard and R. Burstall. Computational Category Theory. International Series in Computer Science. Prentice Hall, 1988.

[72] R.A.G. Seely. Hyperdoctrines, natural deduction and the beck condition. Zeitschr. f. math. Logik und Grundlagen d. Math., 29:505–542, 1983.

[73] R.A.G. Seely. Locally cartesian closed categories and type theory. Math. Proc. Camb. Phil. Soc, 95:33–48, 1984.

[74] R.A.G. Seely. Categorical semantics for higher order polymorphic lambda calculus. The Journal of Symbolic Logic, 52:969–989, 1987.

[75] D. L. Spencer. Categorical Programming with Functorial Strength. PhD thesis, Oregon Graduate Institute of Science & Technology, 1993.

[76] R. Street. The formal theory of monads. Journal of Pure and Applied Algebra, 2:149–168, 1972.

[77] R. Street. Cosmoi of internal categories. Transactions of the American Mathematical Society, 258(2):271–318, 1980.

[78] R. Street. Some parameterized categorical concepts. Communications in Algebra, 16(11):2313–2347, 1988.

[79] R. Street. Enriched categories and cohomology. Questiones Mathematicae, 6:265–283, 83.

[80] R. H. Street. Elementary cosmoi. I. In Category seminar Sydney 1972/73, volume 420 of Lecture Notes in Mathematics, pages 134–180. Springer-Verlag, Berlin, 1974.

[81] R. H. Street and R. F. C. Walters. Yoneda structures on 2-categories. Journal of Algebra, 50:350–379, 1978.

[82] T. Streicher. Correctness and Completeness of a Categorical Semantics of the Calculus of Constructions. PhD thesis, Passau University, 1989.

[83] M. E. Szabo. Algebra of proofs, volume 88 of Studies in Logic and The Foundations of Mathematics. North-Holland, Amsterdam, 1978.

[84] M. Takeyama. A type system based on locally small fibrations, 1990. Master’s Thesis, University of Tokyo.

[85] A. Tarlecki, R. M. Burstall, and J. A. Goguen. Some fundamental algebraic tools for the semantics of computation part iii: Indexed categories. Technical Report 88-60, LFCS, 88.

[86] P. Taylor. Recursive Domains, Indexed Categories and Polymorphism. PhD thesis, University of Cambridge, 1986.

[87] R. D. Tennent. Semantics of interference control. Theoretical Computer Science, 27:297–310, 1983.

[88] R. D. Tennent. Semantical analysis of specification logic. Information and Computation, 85(2):135–162, 1990.

[89] R. D. Tennent. Semantical analysis of specification logic, 2. Information and Computation, 107(1):25–57, 1993.