Formalizing Abstract Computability : Turing Categories in Coq
Total Page:16
File Type:pdf, Size:1020Kb
Formalizing Abstract Computability : Turing Categories in Coq Polina Vinogradova A thesis submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy in Computer Science 1 Department of Electrical Engineering and Computer Science Faculty of Engineering University of Ottawa © Polina Vinogradova, Ottawa, Canada, 2017 1The Ph.D. program is a joint program with Carleton University, administered by the Ottawa- Carleton Institute of Computer Science Abstract The concept of a recursive function has been extensively studied using traditional tools of computability theory. However, with the development of category-theoretic methods it has become possible to study recursion in a more general (abstract) sense. The particular model this thesis is structured around is known as a Turing category. The structure within a Turing category models the notion of partiality as well as recursive computation, and equips us with the tools of category theory to study these concepts. The goal of this work is to build a formal language description of this computation model. Specifically, to use the Coq proof assistant to formulate informal definitions, propositions and proofs pertaining to Turing categories in the underlying formal language of Coq, the Calculus of Co-inductive Constructions (CIC). Furthermore, we have instantiated the more general Turing category formalism with a CIC description of the category which models the language of partial recursive functions exactly. ii Acknowledgements First of all, I would like to thank my supervisors, Dr. Amy Felty and Dr. Philip Scott, for their guidance and financial support, which was absolutely essential for the completion of this dissertation. Without their in-depth understanding of formal logic, knowledge of the requirements and expectations of the process of completing a doctoral dissertation, as well as excellent reference material and problem-solving suggestions, I would have no idea what I am doing. It has been a very positive learning experience working with both of them, and I am grateful they encouraged me to continue on with the completion of this degree when I was considering giving up. I would also like to thank my supervisors for giving me the opportunity to at- tend a number of very interesting conferences, where I had many fruitful interactions with other researchers in mine and related fields. I would particularly like to thank Dr. Felty for giving me the idea for the direction of the project undertaken for this dissertation. Working on this project has allowed me to explore a very interesting new perspective on an existing subject. I would like to express my gratitude to all the fellow students and professors who have participated in the Logic and Foundations of Computing research group | it has been a great experience getting to know everyone interested in logic in Ottawa, and their support and enthusiasm for logic has been a constant motivation for continuing my research. I would like to thank Dr. Pieter Hofstra and Dr. Richard iii Acknowledgements iv Blute for organizing so many interesting talks. I also wish to thank Dr. Hofstra for initially suggesting I discuss the possibility of doing doctoral research under Dr. Felty's supervision | I am glad I took this advice. Finally, I would like to express a huge thank you to my parents and sister, who have been unbelievably understanding and supportive over the time of this long and arduous undertaking. I do not believe that I would have been able to finish my thesis if I had moved out of my family's house and lived on my own. I would also like to thank my friends (some of whom refer to me as `the one who is writing her thesis') for accepting my standing excuse of `I have to write my thesis' to get out of anything, and who have consistently believed in the possibility of me one day completing it. Contents 1 Introduction 1 1.1 Methodology . .4 1.2 Traditional Computation . .5 1.3 Choice of Categorical Abstraction Strategy for Traditional Compu- tation . .6 1.4 Choice of Formalism and Category Theory Library . .8 1.5 Plan of the Thesis . 10 1.6 Contributions . 12 2 Turing Category Background 14 2.1 Restriction Categories . 14 2.2 Cartesian Restriction Categories. 20 2.3 Turing Category Structure . 21 2.4 Partial Combinatory Algebras . 26 3 Ranges in Turing Categories 32 3.1 Range Categories . 32 3.2 Ranges and Retractions . 36 3.3 The Beck-Chevalley Condition . 40 3.4 Ranges and PCA's . 42 v CONTENTS vi 4 Formalization and Coq 46 4.1 Formalization . 46 4.2 Logical Framework behind Coq . 48 4.2.1 The Barendregt Lambda Cube . 48 4.2.2 Sorts, Universes and Impredicativity . 51 4.3 The Coq Proof Assistant . 52 4.4 The Category Theory Library . 59 4.4.1 Library Structure . 62 5 Formalizing Abstract Computational Structure 66 5.1 Existing Formalizations Work . 66 5.2 Using Type Classes to Formalize Partiality . 69 5.3 Formalizing Turing Structure . 77 5.4 Proving Results about Turing Categories . 79 5.5 Formalizing Combinatory Complete Structure and the Turing Cat- egory Embedding Result . 86 5.5.1 Full Cartesian Restriction Subcategory of Objects An .... 86 5.5.2 PCAs and Combinatory Completeness . 93 5.5.3 Formal Idempotent Splitting and the Embedding . 97 5.6 Formalizing Range Structure . 104 5.6.1 Range Structure in Restriction Categories . 104 5.6.2 Range Structure in Turing Categories . 109 6 Formalizing Categorical Examples 112 6.1 Restriction Structure Instance . 113 6.2 Formalizing Traditional Computability as a Turing Category . 123 6.2.1 Existing Formalizations of Recursive Maps in Coq . 125 6.2.2 Defining a Category Using the prf Language . 129 CONTENTS vii 6.2.3 Use of Specialized Versions of the Axiom of Choice . 147 6.2.4 Partial Results in Defining Ranges in a Formal PRF Category 149 7 Conclusion 151 7.1 Discussion of Contributions . 151 7.1.1 Formalizing Abstract Computational Structure . 151 7.1.2 Formalizing Categorical Examples . 152 7.1.3 Concluding Remarks . 154 7.2 Future Work . 157 References 164 Chapter 1 Introduction Traditional computation on the natural numbers, as well as the theory of computabil- ity (or recursion) built around it, has historically been the main approach to studying computation in mathematics and computer science, mainly due to its widespread ap- plicability. More recently, there have been several attempts at capturing the essential properties of computation in a broader sense through various mathematical abstrac- tions. Many concepts of traditional recursion and computation theory have begun to be effectively analyzed categorically. This includes early fundamental work of Elgot on flowchart semantics, and its connections with denotational semantics (cf. M. Arbib and E. Manes [36]), to analysis of Church's theories of lambda calculi (both typed and untyped) in cartesian closed categories and associated higher-order categorical logics ([34]). In a series of works of increasing categorical generality, beginning with Longo and Moggi [35], Di Paola and Heller [40] and culminating in recent work of Cockett and Hofstra [15], we see the beginnings of a new and direct categorical development of the foundations of recursion theory. Now, theoretical computer science requires more than just numerical computa- tion: one has increasingly abstract theories of computation over various data types, 1 1. Introduction 2 higher-order computation, computation based on various programming language paradigms, newer paradigms of computation (parallel, probabilistic, quantum) etc. Category theory appears to be both general and expressive enough to be the tool of choice for modeling computation in these newer senses. For an overview of category theory and how it uses objects, arrows and equations to model mathematical and computer science concepts, see [1], as this outside the scope of this thesis. The model we have selected to study in this thesis is a category-theoretic ap- proach to exploring more general instances of computational systems, referred to as \Turing Categories" [15]. Turing categories are currently the most general compu- tational model, because they model both total and partial computation and have multiple non-isomorphic objects. The notion of Turing category provides a robust, abstract framework for discussing computation over a wide range of settings. Our study of the Turing category computation model takes the form of build- ing a formal language description (formalization) of the relevant concepts. A formal language is a set of strings of symbols constrained by rules specific to it. The formal definitions of the model are made up of the symbols representing concepts such as sets or maps, with rules about them; while proofs are essentially sequences of rule applications. The key motivation behind taking this approach is the level of orga- nization, consistency, and guaranteed correctness it provides in working with proofs and definitions for which informal formulations may omit important and interesting details. Turing category theory can be viewed as an (up until now) informally-presented language that can be used to describe (also informally-presented) formal computation. As computation on a physical computer is a formal procedure, it seems natural to verify that a formal description of it formally fits the selected model. This is the motivating idea and the main objective of this work. The insights into traditional and abstract computability this formalization effort yielded are outlined later in this introduction. There is not a huge amount of work done in this direction of research, 1. Introduction 3 none formalizing specifically a category as an instance of an abstract computational model. For more details on the related work, see Section 5.1. In particular, our intent was to first use an existing formal language and category theory library written in that language to specify the mathematical definitions found in the framework of the Turing Category abstract computation model, as well as the abstracted versions of other types of structures naturally occurring in the traditional computation model, then formally prove (the more abstract versions of) a number of the results from traditional recursion theory.