Category Theory. Roger Jones. Abstract. Formalisation of some of the concepts of category theory in ProofPower-HOL. Created 2006/04/09

Similar documents
The Category of Categories

The Proposition. Roger Bishop Jones. Abstract. A place to play formally with the concept of proposition. Created 2009/11/22

NFU and NF in ProofPower-HOL

Topos Theory. Lectures 3-4: Categorical preliminaries II. Olivia Caramello. Topos Theory. Olivia Caramello. Basic categorical constructions

Pure Type Systems and HOL-Omega in ProofPower

CS 173 Lecture 18: Relations on a Set

Compiling to categories

Cubical sets as a classifying topos

1 Elementary number theory

Colecture 1: Algebras, algebraic data types, and recursion

An introduction to Category Theory for Software Engineers*

A more elegant specification for FRP

A.1 Numbers, Sets and Arithmetic

The three faces of homotopy type theory. Type theory and category theory. Minicourse plan. Typing judgments. Michael Shulman.

Z Notation. June 21, 2018

An Introduction to ProofPower

A Database of Categories

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p.

Math Introduction to Advanced Mathematics

BOBJ: A Quickstart for Software Engineers

Discrete Mathematics Lecture 4. Harper Langston New York University

Category Theory & Functional Data Abstraction

Topic 3: Propositions as types

3.7 Denotational Semantics

Arithmetic universes as generalized point-free spaces

An Algebra of Dependent Data Types

Modelling environments in call-by-value programming languages

Topoi: Theory and Applications

1 Elementary number theory

A Generic Matrix Manipulator

From natural numbers to the lambda calculus

COORDINATE GEOMETRY. 7.1 Introduction

Leinster s globular theory of weak -categories

Modular dependent induction in Coq, Mendler-style. Paolo Torrini

THE AGDA STANDARD LIBRARY

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

The Encoding Complexity of Network Coding

Chapter 3. Set Theory. 3.1 What is a Set?

CSE-321 Programming Languages 2010 Midterm

THE DOLD-KAN CORRESPONDENCE

Dependent Object Types - A foundation for Scala s type system

CSE 215: Foundations of Computer Science Recitation Exercises Set #9 Stony Brook University. Name: ID#: Section #: Score: / 4

Automated Reasoning Systems

in simplicial sets, or equivalently a functor

Category Theory. Andrew Pitts. Module L108, Part III and MPhil. ACS 2019 Computer Science Tripos University of Cambridge L0 1

On the Recognizability of Arrow and Graph Languages

Lists. Michael P. Fourman. February 2, 2010

Probabilistic systems a place where categories meet probability

Category Theory 3. Eugenia Cheng Department of Mathematics, University of Sheffield Draft: 8th November 2007

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Section 17.2

1 Introduction CHAPTER ONE: SETS

A computer implemented philosophy of mathematics

A NOTE ON MORPHISMS DETERMINED BY OBJECTS

Part VI. Imperative Functional Programming

Data types for mcrl2

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011

ACLT: Algebra, Categories, Logic in Topology - Grothendieck's generalized topological spaces (toposes)

ECC Elliptic Curve Cryptography. Foundations of Cryptography - ECC pp. 1 / 31

Databases = Categories

1 Introduction. 3 Syntax

2017 SOLUTIONS (PRELIMINARY VERSION)

ACLT: Algebra, Categories, Logic in Topology - Grothendieck's generalized topological spaces (toposes)

type classes & locales

arxiv: v2 [cs.ds] 9 Apr 2009

Inductive Data Types Based on Fibrations Theory in Programming

Computing Fundamentals 2 Introduction to CafeOBJ

Generic Constructors and Eliminators from Descriptions

Built-in Module BOOL. Lecture Note 01a

Lecture 4: examples of topological spaces, coarser and finer topologies, bases and closed sets

Functional Programming with Isabelle/HOL

Basic Foundations of Isabelle/HOL

Unit 6: Connecting Algebra and Geometry Through Coordinates

DIHEDRAL GROUPS KEITH CONRAD

A MODEL CATEGORY STRUCTURE ON THE CATEGORY OF SIMPLICIAL CATEGORIES

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1

Geometry. 4.1 Translations

Cheng Soon Ong & Christian Walder. Canberra February June 2018

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

2.1 Sets 2.2 Set Operations

Sub: EM-III (14MA301) Section: A & B Date: 13/07/17 One Mark Questions: 1. a) Write the iterative formula to compute 3 N by Newton s method.

Exercises for Chapter Three You know you've got to exercise your brain just like your muscles. Will Rogers ( )

I. An introduction to Boolean inverse semigroups

From Types to Sets in Isabelle/HOL

Trees. Solution: type TreeF a t = BinF t a t LeafF 1 point for the right kind; 1 point per constructor.

Propositional Calculus. Math Foundations of Computer Science

Saturated Sets in Fuzzy Topological Spaces

Derivation of a Pattern-Matching Compiler

The language of categories

Lesson 24 - Exploring Graphical Transformations and Composite Functions

Programming with Math and Logic

Introduction to Graphical Models

3.1 Constructions with sets

Activity 21 OBJECTIVE. MATERIAL REQUIRED Cardboard, white paper, adhesive, pens, geometry box, eraser, wires, paper arrow heads.

Categorical models of type theory

RECURSIVE AND COMPUTABLE FUNCTIONS

Program Calculus Calculational Programming

Typed Lambda Calculus for Syntacticians

Programming Languages Third Edition

Transcription:

Category Theory Roger Jones Abstract Formalisation of some of the concepts of category theory in ProofPower-HOL. Created 2006/04/09 Last Changed Date: 20/08/5 7:00:38 http://www.rbjones.com/rbjpub/pp/doc/t07.pdf Id: t07.doc,v.7 20/08/5 7:00:38 rbj Exp c Roger Bishop Jones; Licenced under Gnu LGPL

Contents Introduction 3 2 Categories Functors and Natural Transformations 3 2. Definition of Category.................................... 3 2.. Notation for Commutative Diagrams........................ 5 2.2 Categories........................................... 5 2.3 Functors............................................ 6 2.3. Subcategories..................................... 7 2.4 Natural Transformations................................... 7 3 Constructions on Categories 8 3. Opposites........................................... 8 3.2 Functor Categories...................................... 8 4 The Yoneda Embedding 8 5 Categorial Structures 8 6 Categories in Universal Algebra 9 6. Definition of Category.................................... 9 7 The Theory cat 7. Parents............................................ 7.2 Children........................................... 7.3 Constants........................................... 7.4 Aliases............................................ 7.5 Types............................................. 7.6 Fixity............................................. 7.7 Definitions.......................................... 2 7.8 Theorems........................................... 4 8 Index 5 2

References [] Roger Bishop Jones. Category Theory. RBJones.com, 200. http://www.rbjones.com/rbjpub/pp/doc/t07.pdf. [2] Roger Bishop Jones. Universal Algebra and Lattice Theory. RBJones.com, 200. http://www.rbjones.com/rbjpub/pp/doc/t039.pdf. Introduction This is minor exercise to help some of the elementary concepts of category theory into my brain, and is not intended to show offer any enlightenment which cannot be found in any elementary text on category theory. In fact I am following Saunders Mac Lane (roughly). Create new theory cat, parent rbjmisc. open theory "rbjmisc"; open PreConsisProof ; open UnifyForwardChain; open Trawling; force new theory "cat"; force new pc " cat"; merge pcs r" savedthm cs D proof "s " cat"; new parent "sum"; new parent "one"; set merge pcsr"rbjmisc", " cat"s; set flag p"pp use alias", trueq; 2 Categories Functors and Natural Transformations 2. Definition of Category We model a category by its set of arrows. It is therefore a set (of arrows), together with: a partial associative operation over the arrows left and right operators which return the domain and codomain of each arrow HOL Labelled Product CAT Arrows : a SET ; Compose : a; Left Right: a Before giving the definition of a category it will be convenient to define some auxiliary concepts. 3

Obj : a SET @ C a a P Obj C ô a P Arrows C ^ a Left C a We need often to state explicitly that two arrows are composable and therefore introduce a notation for this. We use an infix operator which yields a property of categories. declare infix p400, "Υ"q; $Υ : BOOL @ f g C pf Υ gq C ô f P Arrows C ^ g P Arrows C ^ Right C f Left C g Identity : a SET @ C a a P Identity C ô a P Arrows C ^ Left C a a ^ Right C a a ^ @b b P Arrows C ñ pleft C b a ñ Compose C a b bq ^ pright C b a ñ Compose C b a bq It will also be convenient to cite concisely the domain and codomain of an arrow, i.e. a notation for homsets. declare infixp400, " "q; $ : a SET @ f a b C f P pa bq C ô f P Arrows C ^ a P Arrows C ^ b P Arrows C ^ Left C f a ^ Right C f b declare alias p" ", $ q; An infix notation for composition: declare infixp500, "o c "q; 4

$o c : a @ f g C pf o c gq C Compose C f g Cat : BOOL @ c Cat c ô p@ x x P Arrows c ñ Left c x P Identity c ^ Right c x P Identity c q ^ p@ x y px Υ yq c ñ px o c yq c P Arrows c ^ ppx o c yq c q P ppleft c xq pright c yqq c q ^ p@ x y z px Υ yq c ^ py Υ zq c ñ px o c py o c zq c q c pppx o c yq c q o c zq c q 2.. Notation for Commutative Diagrams I have no idea whether this is any use. declare infix p30, "Ξ "q; declare infix p30, "Λ"q; $Λ : a LIST Ñ a @ C la a C Λ ras a ^ pla rs _ C Λ pcons a laq Compose C a pc Λ laqq $Ξ : a LIST LIST Ñ BOOL @ C lla CΞ lla ô Dx Fold Insert pmap p$λ C q llaq tu txu 2.2 Categories H c : a CAT Arrows H c tu 5

c : a CAT @x: a Cat p c xq ^ Arrows p c xq txu Of course, we have: Cat H c thm $ Cat H c Both of the above are special cases of discrete categories. In a discrete category all arrows are identity arrows. The following function allows the construction of arbitrary discrete categories. Discrete c : a SET Ñ a CAT @s: a SET Discrete c s MkCAT s pλx y xq pλxxq pλxxq Any set can be made into a discrete category in this way: discrete cat thm $ @s Cat pdiscrete c sq 2.3 Functors F unctor : bq SET @ A B f f P Functor pa,bq ô p@a a P Arrows A ñ f a P Arrows Bq ^ @a b pa Υ bq A ñ Right B pf aq f pright A aq ^ Left B pf bq f pleft A bq ^ Compose B pf aq pf bq f pcompose A a bq F ull : bq SET @ A B f f P Full pa,bq ô @b b P Arrows B ñ Da a P Arrows A ^ b f a F aithful : bq SET @ A B f f P Faithful pa,bq ô @a b a P Arrows A ^ b P Arrows A ^ f a f b ñ a b 6

Since functors are functions, they compose, and the composition is also a functor. Composition also preserves fullness and faithfulness. functor composition thm $ @A: a CAT ; B: b CAT ; C : c CAT ; ab: b; bc: b Ñ c ab P Functor pa,bq ^ bc P Functor pb,c q ñ pbc o abq P Functor pa,c q full compose thm $ @A: a CAT ; B: b CAT ; C : c CAT ; ab: b; bc: b Ñ c ab P Full pa,bq ^ bc P Full pb,c q ñ pbc o abq P Full pa,c q faithful compose thm $ @A: a CAT ; B: b CAT ; C : c CAT ; ab: b; bc: b Ñ c ab P Functor pa,bq ^ ab P Faithful pa,bq ^ bc P Faithful pb,c q ñ pbc o abq P Faithful pa,c q 2.3. Subcategories declare infix p30, " c "q; $ c : BOOL @ A A2 A c A2 ô p@a a P Arrows A ñ a P Arrows A2 ^ Left A a P Arrows A ^ Right A a P Arrows A ^ Left A a Left A2 a ^ Right A a Right A2 aq ^ p@a b a P Arrows A ^ b P Arrows A ñ Compose A a b P Arrows A ^ Compose A a b Compose A2 a bq A subcategory of a category is of course a category. subcat cat thm $ @a b: a CAT Cat a ^ b c a ñ Cat b 2.4 Natural Transformations $NatT ran : p b CAT q Ñ pp bq p bqq Ñ p bq SET @ A B R S τ τ P NatTran pa,bq pr,sq ô p@a a P Obj A ñ τ a P Arrows B ^ Left Bpτ aq R a ^ Right Bpτ aq S aq ^ p@f f P Arrows A ñ Left Bpτ pright A f qq R f ^ Right Bpτ pright A f qq S f ^ Compose B pτ pleft A f qq ps f q Compose B pr f q pτ pright A f qqq 7

$Id N T : p b CAT q Ñ p bq Ñ p bq @ A B R f Id N T pa,bq R f Left B pr f q 3 Constructions on Categories 3. Opposites declare postfix p400, " op "q; $ op : a CAT @ C C op MkCAT parrows C q pλx y Compose C y xq pright C q pleft C q 3.2 Functor Categories 4 The Yoneda Embedding I conjecture that the Yoneda embedding can be defined without resort to The category of sets, and without constraints on size. 5 Categorial Structures This doesn t belong here, and if it gets anywhere it will be moved elsewhere. Its an experiment in doing a kind of categorical foundation system by methods analogous to the study of foundations via the study of membership structures. In the domain of discourse there exist only arrows. Some of these are identity arrows and such arrows are themselves categories. The structure which constitutes a category is taken as defined in Category Theory []. The categorial structure is given by a type of arrows one element of which is distinguished as the universal category together with a function which assignes to each identity arrow in that category some other category. open theory "cat"; force new theory "fcat"; new parent "membership"; HOL Labelled Product F CAT Ucat : a CAT ; Catmap: a CAT 8

The idea is then to define the properties of FCAT which are desirable for if they are to serve as the model of a foundation system, as an ontology for mathematics. As in set theory we have some axioms which tell us what kind of things sets are, and then axioms which tell us which objects of that kind actually exist. F cat : a FCAT Ñ BOOL @fc: a FCAT Cat pucat fcq ^ @obj : a obj P Obj pucat fcq ñ Cat pcatmap fc obj q 6 Categories in Universal Algebra In this section I hope to explore the development of category theory as an application of the Universal Algebra under development in [2]. The motivations for this are not very strong. The greatest of these is my desire now to find a way to explore some possible philosophical applications of category theory. Why this should favour this particular approach is not obvious. However, I am working on the Universal Algebra and wanting to probe category theory, so doing the latter in the former makes some sense. Whether a category is an algebra is moot. It depends on what you mean by algebra. Universal algebra normally deals with systems in which there are only total first order operations over a single domain, extended by some theoretical computer scientists (most prominently Goguen) to many sorted algebras. Typically there is also a presumption that algebra is done in or with a first order equational logic (at least for some purposes, e.g. for the presentation of particular algebras). In Category theory one of the required operations, composition, is partial, and no particular logical institition is presumed. For these reasons Category theory may not be thought of as an algebra, but some of the results of our Universal Algebra may nevertheless be applicable, and crucially, the general manner of representing structures used in our Universal Algebra looks suitable for use in Category theory (a category being such a structure). I propose to begin by replaying some of the former material in a new theory using the Universalm Algebra. open theory "unalg"; force new theory "uacat"; force new pc " uacat"; merge pcs r" prove D ñ conv", " savedthm cs D proof "s " uacat"; set merge pcs r"unalg", " uacat"s; 6. Definition of Category We model a category by its set of arrows. It is therefore a set (of arrows), together with: a partial associative operation over the arrows left and right operators which return the domain and codomain of each arrow 9

We will represent categories using objects of type STRUCT having a suitable signature. The signature of a category is defined: CatSig : SIG CatSig IxPack rp" o 9c", 2 q; p"left c ", q; p"right c ", qs declare infix p300, " o 9c"q; We need a convenient notation for categories and therefore define the following constructor: MkCat : a SET Ñ p aq Ñ p aq Ñ p aq Ñ a STRUCT @D $ o 9c Left c Right c MkCat D $ o 9c Left c Right c MkSTRUCT D pixpack rp" o 9c", pack2op $ o 9cq; p"left c ", packop Left c q; p"right c ", packop Right c q To enable pattern matching in definitions we prove and install an appropriate existential theorem. val MkCat D lemma make alg D thm MkCat ; MkCat D lemma $ @ cf D f @ D $ o 9c Left c Right c f pmkcat D o 9c Left c Right c q cf D o 9c Left c Right c add D cd thms rmkcat D lemmas " uacat"; set merge pcs r"unalg", " uacat"s; Before giving the definition of a category it will be convenient to define some auxiliary concepts. Obj : a STRUCT Ñ a SET @D $ o 9c Left c Right c a let C MkCat D $ o 9c Left c Right c in a P Obj C ô a P SCar C ^ a Left c a 0

7 The Theory cat 7. Parents one sum rbjmisc 7.2 Children fcat 7.3 Constants Right a Left a Compose a Arrows a P MkCAT a P Ñ p aq Ñ p aq Ñ p aq Ñ a CAT Obj a P $Υ BOOL Identity a P $ a P $o c a Cat BOOL $Λ a LIST Ñ a $Ξ a LIST LIST Ñ BOOL H c a CAT c a CAT Discrete c a P Ñ a CAT F unctor bq P F ull bq P F aithful bq P $ c BOOL NatT ran bq p bq Ñ p bq P bq Ñ b Id N T $ op a CAT 7.4 Aliases $ : a P 7.5 Types CAT 7.6 Fixity Right Infix 30 : Right Infix 400 : Right Infix 500 : Postfix 400 : c Λ Ξ Υ o c op

7.7 Definitions CAT MkCAT Arrows Compose Left Right Obj Υ Identity $ D f TypeDefn pλ x T q f $ @ t x x2 x3 x4 Arrows pmkcat x x2 x3 x4 q x ^ Compose pmkcat x x2 x3 x4 q x2 ^ Left pmkcat x x2 x3 x4 q x3 ^ Right pmkcat x x2 x3 x4 q x4 ^ MkCAT parrows tq pcompose tq pleft tq pright tq t $ @ C a a P Obj C ô a P Arrows C ^ a Left C a $ @ f g C pf Υ gq C ô f P Arrows C ^ g P Arrows C ^ Right C f Left C g $ @ C a a P Identity C ô a P Arrows C ^ Left C a a ^ Right C a a ^ p@ b b P Arrows C ñ pleft C b a ñ Compose C a b bq ^ pright C b a ñ Compose C b a bqq $ @ f a b C f P pa bq C ô f P Arrows C ^ a P Arrows C ^ b P Arrows C ^ Left C f a ^ Right C f b o c Cat $ @ f g C pf o c gq C Compose C f g $ @ c Cat c ô p@ x x P Arrows c ñ Left c x P Identity c ^ Right c x P Identity c q ^ p@ x y px Υ yq c ñ px o c yq c P Arrows c ^ px o c yq c P pleft c x Right c yq c q ^ p@ x y z px Υ yq c ^ py Υ zq c ñ px o c py o c zq c q c ppx o c yq c o c zq c q 2

Λ $ @ C la a C Λ ras a ^ pla rs _ C Λ Cons a la Compose C a pc Λ laqq Ξ $ @ C lla C Ξ lla ô pd x Fold Insert pmap p$λ C q llaq tu txuq H c $ Arrows H c tu c $ @ x Cat p c xq ^ Arrows p c xq txu Discrete c $ @ s Discrete c s MkCAT s pλ x y xq pλ x xq pλ x xq F unctor $ @ A B f f P Functor pa, Bq ô p@ a a P Arrows A ñ f a P Arrows Bq ^ p@ a b pa Υ bq A ñ Right B pf aq f pright A aq ^ Left B pf bq f pleft A bq ^ Compose B pf aq pf bq f pcompose A a bqq F ull $ @ A B f f P Full pa, Bq ô p@ b F aithful b P Arrows B ñ pd a a P Arrows A ^ b f aqq $ @ A B f f P Faithful pa, Bq ô p@ a b a P Arrows A ^ b P Arrows A ^ f a f b ñ a bq c $ @ A A2 A c A2 ô p@ a a P Arrows A ñ a P Arrows A2 ^ Left A a P Arrows A ^ Right A a P Arrows A ^ Left A a Left A2 a ^ Right A a Right A2 aq ^ p@ a b a P Arrows A ^ b P Arrows A ñ Compose A a b P Arrows A NatT ran ^ Compose A a b Compose A2 a bq $ @ A B R S τ τ P NatTran pa, Bq pr, Sq ô p@ a a P Obj A ñ τ a P Arrows B ^ Left B pτ aq R a ^ Right B pτ aq S aq ^ p@ f f P Arrows A 3

Id N T op ñ Left B pτ pright A f qq R f ^ Right B pτ pright A f qq S f ^ Compose B pτ pleft A f qq ps f q Compose B pr f q pτ pright A f qqq $ @ A B R f Id N T pa, Bq R f Left B pr f q $ @ C C op MkCAT parrows C q pλ x y Compose C y xq pright C q pleft C q 7.8 Theorems Cat H c thm $ Cat H c Cat c thm $ @ x Cat p c xq discrete cat thm $ @ s Cat pdiscrete c sq f unctor composition thm $ @ A B C ab bc ab P Functor pa, Bq ^ bc P Functor pb, C q ñ bc o ab P Functor pa, C q full compose thm $ @ A B C ab bc ab P Full pa, Bq ^ bc P Full pb, C q ñ bc o ab P Full pa, C q functor arrow thm $ @ A B a ab a P Arrows A ^ ab P Functor pa, Bq ñ ab a P Arrows B faithful thm $ @ A B C ab bc ab P Functor pa, Bq ^ ab P Faithful pa, Bq ^ bc P Faithful pb, C q ñ bc o ab P Faithful pa, C q 4

8 Index uacat....................................... 9..................................., 2 $..................................... 4 $Λ.......................................... 5 $Υ.......................................... 4 $Ξ.......................................... 5 $o c.......................................... 5 Λ......................................., 3 Υ......................................., 2 Ξ......................................., 3 H c.................................... 5,, 3......................................... c.................................... 7,, 3 op..................................... 8,, 4 c..................................... 6,, 3 Arrows.................................., 2 CAT.................................. 3,, 2 Cat................................... 5,, 2 Cat c thm................................. 4 Cat H c thm.............................. 6, 4 CatSig..................................... 0 Compose................................, 2 discrete cat thm............................ 4 Discrete c.............................. 6,, 3 F aithful.............................. 6,, 3 faithful thm.............................. 4 F cat........................................ 9 F ull................................... 6,, 3 full compose thm.......................... 4 F unctor............................... 6,, 3 functor arrow thm.......................... 4 functor composition thm................... 4 Identity............................... 4,, 2 Id N T.................................. 8,, 4 Left...................................., 2 MkCAT................................., 2 MkCat..................................... 0 MkCat D lemma............................ 0 NatT ran.............................. 7,, 3 Obj................................... 4, 0 2 o c......................................., 2 Right..................................., 2 5