{"id":9,"date":"2006-06-07T10:02:00","date_gmt":"2006-06-07T10:02:00","guid":{"rendered":"http:\/\/scientopia.org\/blogs\/goodmath\/2006\/06\/07\/a-first-glance-at-category-theory\/"},"modified":"2006-06-07T10:02:00","modified_gmt":"2006-06-07T10:02:00","slug":"a-first-glance-at-category-theory","status":"publish","type":"post","link":"http:\/\/www.goodmath.org\/blog\/2006\/06\/07\/a-first-glance-at-category-theory\/","title":{"rendered":"A First Glance at Category Theory"},"content":{"rendered":"<p>To get started, what is category theory?<\/p>\n<p>Back in grad school, I spent some time working with a thoroughly insane guy named <a href=\"http:\/\/www.cis.udel.edu\/~case\/\">John Case<\/a> who was the new department chair. When he came to the university, he brought a couple of people with him, to take temporary positions. One of them was a category theorist whose name I have unfortunately forgotten. That was the first I&#8217;d ever heard of cat theory. So I asked John what the heck this category theory stuff was. His response was &#8220;abstract nonsense&#8221;. I was astonished; a guy as wacky and out of touch with reality as John called something abstract nonsense? It turned out  to be a classic quotation, attributed to one of the founders of category theory, Norman Steenrod. It&#8217;s not an entirely bad description.<\/p>\n<p>Category theory is one of those fields of mathematics that fascinates me: where you take some fundamental concept, and abstract it down to its bare essentials in order to understand just what it really is, what it really means. Just like group theory takes the idea of an algebraic operation, strip it down to the bare minimum, and discovering the meaning of symmetry; category theory looks at what happens if you take the concept of a function as a mapping from one thing to another, and strip it down to the bare minimum, and see what you can discover?<\/p>\n<p>The fundamental thing in category theory is an <em>arrow<\/em>, also called a <em>morphism<\/em>.  A morphism is an abstraction of the concept of <em>homomorphism<\/em>, which I <a href=\"http:\/\/goodmath.blogspot.com\/2006\/04\/group-isomorphism-defining-symmetry.html\">talked about a bit<\/a> when I was writing about group theory. We take that concept of a function mapping from one set of values to another, and strip it down: the basic concept is something that provides a map from one thing to some other thing &#8211; and that&#8217;s all we want.<\/p>\n<p>In classic style, we&#8217;ll define a <em>category<\/em> C as a tuple: <code>(O, M, &ordm;)<\/code>, where:<\/p>\n<ul>\n<li> O, or Obj(C), is a set of <em>objects<\/em>. Objects are <em>anything<\/em> &#8211; we don&#8217;t care. Anything that we can define maps over.\n<li>  M, or Mor(C) is a set of arrows or morphisms. Every arrow has a unique <em>source<\/em> and a unique <em>target<\/em>, both of which are objects in M. Given two objects a and b in O, we also write Mor(a,b) for the set of morphisms from a to b. To talk about a specific morphism from a to b, we write it as &#8220;name : a &rarr; b&#8221;; as in &#8220;f : int &rarr; int&#8221;.\n<li> &ordm; is a binary operation that is the abstraction of function composition; &ordm; is a mapping from (Mor(a,b), Mor(b,c)) to Mor(a,c). It&#8217;s got the basic properties of function composition:\n<ol>\n<li> Associativity: (&forall; f : a &rarr; b, g : b &rarr; c, h : c &rarr; d) h &ordm; (g &ordm; f) = (h &ordm; g) &ordm; f\n<li> Identity: (&forall; a,b &isin; O(C)) (exists 1<sub>a<\/sub>, 1<sub>b<\/sub> &isin; Mor(C)) (&forall; f : a &rarr; b)  1<sub>b<\/sub> &ordm; f = f = f &ordm; 1<sub>a<\/sub>.\n<\/ol>\n<\/ul>\n<p>One neat little trick to simplify things is that we can actually throw away Obj(C), and replace it with the set of identity morphisms: since there is exactly one identity morphism per object, there&#8217;s no real need to distinguish between the identity morphism and the object. It&#8217;s a nice trick because it means that we have nothing but morphisms all the way down; but it&#8217;s really just a trick. We can talk about Obj(C); or Id(C); but we still need to be able to talk about the objects in some way, whether they&#8217;re just a subset of the morphisms, or something distinct.<\/p>\n<p>Now, we get to something about category theory that I really don&#8217;t like. Category theory is front-loaded with rather a lot of definitions about different kinds of morphisms and different kinds of categories. The problem with that is that these definitions are very important, but we don&#8217;t have enough of the theory under our belts to be able to get much of a sense for why we should care about them, or what their intuitive meaning is.  But that&#8217;s the way it goes sometimes; you have to start somewhere. It <em>will<\/em> make sense eventually, and you&#8217;ll see why these definitions matter.<\/p>\n<p>There are a lot of special types of morphisms, defined by properties. Here&#8217;s the basic list:<\/p>\n<ul>\n<li> A <em>monic<\/em> (or monomorphism) is an arrow f : a &rarr; b such that (&forall; g<sub>1<\/sub> , g<sub>2<\/sub>: x &rarr; a)  f &ordm; g<sub>1<\/sub> = f &ordm; g<sub>2<\/sub> &rArr; g<sub>1<\/sub> = g<sub>2<\/sub>.  (That is, if any two arrows composed with f in f &ordm; g end up at the same object only if they are the same.)\n<li> An <em>epic<\/em> (or epimorphism) is an arrow f : a &rarr; b such that (&forall; g<sub>1<\/sub> , g<sub>2<\/sub>: b &rarr; x)  g<sub>1<\/sub> &ordm; f = g<sub>2<\/sub> &ordm; f  &rArr;  g<sub>1<\/sub> = g<sub>2<\/sub>. (This is almost the same as a monic, but it&#8217;s from the other side of the composition; instead of (f &ordm; g) in the definition, it&#8217;s (g &ordm; f).)\n<li> An <em>isomorphism<\/em> is an arrow f : a &rarr; b such that (&exist; g : b &rarr; a) f &ordm; g = 1<sub>b<\/sub> &and; g &ordm; f = 1<sub>a<\/sub>.\n<li> An <em>endomorphism<\/em> is an arrow f : a &rarr; b such that a = b.\n<li> An <em>automorphism<\/em> is an arrow that is both an endmorphism and an isomorphism.\n<\/ul>\n<p> One last definition, just because it gives me a chance to point out something useful about category theory. A <em>functor<\/em> is a morphism in the category of all categories. What that means is that it&#8217;s a structure-preserving mapping between categories.  It&#8217;s neat in a theoretical way, because it demonstrates that we&#8217;re already at a point where we&#8217;re seeing how category theory can make it easier to talk about something complicated: we&#8217;re using it to describe itself! But the concept of functor also has a lot of applications; in particular, the module system of my favorite programming language makes extensive use of functors.<\/p>\n<p> In Ocaml, a module is something called a structure, which is a set of definitions with constrained types. One of the things you often want to be able to do is to write a piece of code in a way that allows you to make it parametric on some other structure. The way you do that is to write a functor:  a &#8220;function&#8221; from a structure  to a structure. For example, to implement a generic binary tree, you need a type of values that you&#8217;ll put in the tree; and an operation to compare values. The way you do that is to write a functor which takes a structure defining a type and a comparison operator, and mapping it to a structure which is an implementation of a binary tree for that type and comparison.<\/p>\n<p> The Ocaml functor is a category theoretic functor: category theory provides an easy way to talk about the concept of the compile-time &#8220;function&#8221; from structure to structure.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To get started, what is category theory? Back in grad school, I spent some time working with a thoroughly insane guy named John Case who was the new department chair. When he came to the university, he brought a couple of people with him, to take temporary positions. One of them was a category theorist [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[76,24],"tags":[],"class_list":["post-9","post","type-post","status-publish","format-standard","hentry","category-category-theory","category-goodmath"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4lzZS-9","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/9","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":0,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/9\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/media?parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/categories?post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/tags?post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}