Logic and Categories As Tools for Building Theories
Total Page:16
File Type:pdf, Size:1020Kb
Logic and Categories As Tools For Building Theories Samson Abramsky Oxford University Computing Laboratory 1 Introduction My aim in this short article is to provide an impression of some of the ideas emerging at the interface of logic and computer science, in a form which I hope will be accessible to philosophers. Why is this even a good idea? Because there has been a huge interaction of logic and computer science over the past half-century which has not only played an important r^olein shaping Computer Science, but has also greatly broadened the scope and enriched the content of logic itself.1 This huge effect of Computer Science on Logic over the past five decades has several aspects: new ways of using logic, new attitudes to logic, new questions and methods. These lead to new perspectives on the question: What logic is | and should be! Our main concern is with method and attitude rather than matter; nevertheless, we shall base the general points we wish to make on a case study: Category theory. Many other examples could have been used to illustrate our theme, but this will serve to illustrate some of the points we wish to make. 2 Category Theory Category theory is a vast subject. It has enormous potential for any serious version of `formal philosophy' | and yet this has hardly been realized. We shall begin with introduction to some basic elements of category theory, focussing on the fascinating conceptual issues which arise even at the most elementary level of the subject, and then discuss some its consequences and philosophical ramifications. 2.1 Some Basic Notions of Category Theory We briefly recall the basic definitions. A category has a collections of objects A, B, C, . , and a collection of arrows (or morphisms) f, g h . Each arrow has specified objects as its domain and codomain.2 We write f : A ! B for an arrow with domain A and codomain B. For any triple of objects A; B; C there is an operation of composition: given f : A ! B and g : B ! C, we can form g ◦ f : A ! C. Note that the codomain of f has to match with the domain of g. Moreover, for each object A, there is an identity arrow idA : A ! A. These data are subject to the following axioms: h ◦ (g ◦ f) = (h ◦ g) ◦ f f ◦ idA = f = idB ◦ f whenever the indicated compositions make sense, i.e. the domains and codomains match appro- priately. These definitions appear at first sight fairly innocuous: some kind of algebraic structure, rem- iniscent of monoids (groups without inverses), but with the clumsy-looking apparatus of objects, 1This view is not universally held, either among Computer Scientists or logicians, but I and many of my colleagues do believe it | and we are right! 2More formally, there are operations dom, cod from arrows to objects. 1 domains and codomains restricting the possibilities for composition of arrows. These first appear- ances are deceptive, as we shall see, although in a few pages we can only convey a glimpse of the richness of the notions which arise as the theory unfolds. Let us now see some first examples of categories. • The most basic example of a category is Set: the objects are sets, and the arrows are functions. Composition and identities have their usual meaning for functions. • Any kind of mathematical structure, together with structure preserving functions, forms a category. E.g. { Mon (monoids and monoid homomorphisms) { Grp (groups and group homomorphisms) { Vectk (vector spaces over a field k, and linear maps) { Pos (partially ordered sets and monotone functions) { Top (topological spaces and continuous functions) • Rel: objects are sets, arrows R : X ! Y are relations R ⊆ X × Y . Relational composition: R; S(x; z) () 9y: R(x; y) ^ S(y; z) • Let k be a field (for example, the real or complex numbers). Consider the following category Matk. The objects are natural numbers. A morphism M : n ! m is an n × m matrix with entries in k. Composition is matrix multiplication, and the identity on n is the n × n diagonal matrix. • Monoids are one-object categories. Arrows correspond to the elements of the monoid, com- position of arrows to the monoid multiplication, and the identity arrow to the monoid unit. • A category in which for each pair of objects A, B there is at most one morphism from A to B is the same thing as a preorder, i.e. a reflexive and transitive relation. Note that the identity arrows correspond to reflexivity, and composition to transitivity. 2.1.1 Categories as Contexts and as Structures Note that our first class of examples illustrate the idea of categories as mathematical contexts; settings in which various mathematical theories can be developed. Thus for example, Top is the context for general topology, Grp is the context for group theory, etc. This issue of \mathematics in context" should be emphasized. The idea that any mathematical discussion is relative to the category we happen to be working in is pervasive and fundamental. It allows us simultaneously to be both properly specific and general: specific, in that statements about mathematical structures are not really precise until we have specified which structures we are dealing with, and which morphisms we are considering | i.e. which category we are working in. At the same time, the awareness that we are working in some category allows us to extract the proper generality for any definition or theorem, by identifying exactly which properties of the ambient category we are using. On the other hand, the last two examples illustrate that many important mathematical struc- tures themselves appear as categories of particular kinds. The fact that two such different kinds of structures as monoids and posets should appear as extremal versions of categories is also rather striking. This ability to capture mathematics both \in the large" and \in the small" is a first indication of the flexibility and power of categories. 2 2.1.2 Arrows vs. Elements Notice that the axioms for cateories are formulated purely in terms of the algebraic operations on arrows, without any reference to `elements' of the objects. Indeed, in general elements are not available in a category. We will refer to any concept which can be defined purely in terms of composition and identities as arrow-theoretic. We will now take a first step towards learning to \think with arrows" by seeing how we can replace some familiar definitions for functions between sets couched in terms of elements by arrow-theoretic equivalents. We say that a function f : X −! Y is: injective if 8x; x0 2 X: f(x) = f(x0) =) x = x0 , surjective if 8y 2 Y: 9x 2 X: f(x) = y , monic if 8g; h : Z ! X: f ◦ g = f ◦ h =) g = h , epic if 8g; h : Y ! Z: g ◦ f = h ◦ f =) g = h . Note that injectivity and surjectivity are formulated in terms of elements, while epic and monic are arrow-theoretic. Proposition 1 Let f : X ! Y . Then: 1. f is injective iff f is monic. 2. f is surjective iff f is epic. Proof We show 1. Suppose f : X ! Y is injective, and that f ◦ g = f ◦ h, where g; h : Z ! X. Then for all z 2 Z: f(g(z)) = f ◦ g(z) = f ◦ h(z) = f(h(z)) : Since f is injective, this implies g(z) = h(z). Hence we have shown that 8z 2 Z: g(z) = h(z) ; and so we can conclude that g = h. So f injective implies f monic. For the converse, fix a one-element set 1 = {•}. Note that elements x 2 X are in 1{1 correspon- dence with functionsx ¯ : 1 ! X, wherex ¯(•) := x. Moreover, if f(x) = y theny ¯ = f ◦ x¯ . Writing injectivity in these terms, it amounts to the following: 8x; x0 2 X: f ◦ x¯ = f ◦ x¯0 =) x¯ =x ¯0: Thus we see that being injective is a special case of being monic. The reader will enjoy | and learn from | proving the equivalence for functions of the condi- tions of being surjective and epic. 2.1.3 Generality of Notions Since the concepts of monic and epic are defined in purely arrow-theoretic terms, they make sense in any category. This possibility for making definitions in vast generality by formulating them in purely arrow-theoretic terms can be applied to virtually all the fundamental notions and constructions which pervade mathematics. As an utterly elementary, indeed \trivial" example, consider the notion of isomorphism. What is an isomorphism in general? On might try a definition at the level of generality of model theory, or Bourbaki-style structures, but this is really both unnecessarily elaborate, and still insufficiently general. Category theory has exactly the language needed to give a perfectly general answer to the question, in any mathematical context, as specified by a category. An isomorphism in a category C is an arrow f : A ! B with a two-sided inverse: an arrow g : B ! A such that g ◦ f = idA; f ◦ g = idB: 3 One can check that in Set this yields the notion of bijection; in Grp it yields isomorphism of groups; in Top it yields homeomorphism; in Matk, it yields the usual notion of invertible matrix; and so on throughout the range of mathematical structures. In a monoid considered as a category, an isomorphism is an invertible element. Thus a group is exactly a one-object category in which every arrow is an isomorphism! This cries out for generalization; and the notion of a category in which every arrow is an isomorphism is indeed significant | it is the idea of a groupoid, which plays a key r^olein modern geometry and topology.