Category Theory For Dummies

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27
At a glance
Powered by AI
The document provides an introduction to basic concepts in category theory such as categories, functors, universal constructions and categorical properties. It aims to familiarize the reader with these ideas at a high level without expecting expertise.

The main topics covered include categories and examples, categorical properties like isomorphisms and inverses, and basic categorical constructions like products, sums and exponents. It also discusses how category theory can provide an alternative foundation for mathematics.

A category in category theory consists of objects and arrows (also called morphisms) between objects. It satisfies properties like composition of arrows being associative and identities existing for each object. Categories form the basic structures studied in category theory.

Category Theory for Dummies (I)

James Cheney

Programming Languages Discussion Group

March 12, 2004

Not quite everything youve ever wanted to know...


You keep hearing about category theory. Cool-sounding papers by brilliant researchers (e.g. Wadlers Theorems for free!) But its scary and incomprehensible. And Category Theory is not even taught here. Goal of this series: Familarity with basic ideas, not expertise
2

Outline
Categories: Why are they interesting?

Categories: What are they? Examples.

Some familiar properties expressed categorically

Some basic categorical constructions

Category theory
An abstract theory of structured things and structure preserving function-like things. Independent of the concrete representation of the things and functions. An alternative foundation for mathematics? (Lawvere) Closely connected with computation, types and logic. Forbiddingly complex notation for even simple ideas.
4

A mathematicians eye view of the world

Algebra Groups, Rings,... Homomorphisms

Topology Topological Spaces Continuous Functions Set Theory

Logic Formulas Implication

A category theorists eye view of the world


Category Theory Objects Arrows

Algebra Groups, Rings,... Homomorphisms

Topology Topological Spaces Continuous Functions

Logic Formulas Implication

My view (not authoritative):


Category theory helps organize thought about a collection of related things

and identify patterns that recur over and over.

It may suggest interesting ways of looking at them

but does not necessarily help understand the things being studied (and may get in the way).

What is a category?

Some structures
Sets A

Vector spaces of vectors over R: (V, + : V V V, : R V V)

ML types int, , , list

Some classes of functions


Set functions f : A B = {(x, f (x)) | x A}

Matrices M : V W with M ( V x +V V y) = W f (x) +W W f (y)

Function terms x : A.e : A B

10

Composition
Functions are closed under composition (when domain and range match) I.E., if f : A B and g : B C then g f : A C is a function too. For sets g f = {(x, g(f (x))) | x A}. For matrices g f = g f (matrix multiply). For ML-terms, g f = x : A.g(f (x)).
11

Identity
For every structure A, there is an identity function, lets write it idA : A A.

For sets, idA = {(x, x) | x A}.

For matrices, idV = I, the identity matrix over V .

For any ML type , id = x : .x : .

12

Facts
Composition is associative: h (g f ) = (h g) f

idA is a unit for composition: if f : A B, idB f = f = f idA

13

Surprise!
You now know the denition of a category C = (C, , id, ) 1. C is a collection of objects. 2. If A, B are in C, then A B is a collection of arrows f from A to B. 3. idA : A A and whenever f : A B, g : B C, then g f : A C. 4. is associative, and idA is a unit with respect to . Note: Objects and arrows can be anything.
14

Diagrams
Equations can be expressed using commutative diagrams:
A g o f f g B h o g f A id A f A f

id B

Idea: every pair of paths with same source and target are equal.
15

Examples
Set is the category of sets and set functions.

Vec is the category of vector spaces and matrices.

ML is the category of ML types and function terms.

These examples are misleading: They all have more in common than just the category structure.

16

Numbers as categories
0 is a category. Its empty.

1 is a category:
0 id 0

2 is a category, etc:
id 0 0 1 id 1

17

Some weird categories


A monoid (M, : M, : M M M ) is a set with an associative operation with unit .

In fact, a monoid is basically a category with one object. It has one object M , and each element x M is an arrow x:M M idM = is a unit, x y = x y is associative

And a category with only one object is basically a monoid.


18

Some weird categories


Similarly, any graph G can be used to construct a category: Objects are vertices. Arrows are paths (sequences of edges).

Lesson: Objects are not always really sets, and arrows not always really functions.

So what works in Set doesnt necessarily work in all categories. Not even close.
19

Categorical properties

20

Categorical properties
A categorical property is something that can be dened in the language of category theory

without reference to the underlying mathematical structure (if any).

That is, in terms of objects, arrows, composition, identity (and equality)

Why? Categorical properties are meaningful in any category


21

Inverses
Having an inverse is one of the most basic properties of functions. In C, f : A B has an inverse g : B A if f g = idA
A id A A f g f

g f = idB
B id B B

22

Isomorphism
Invertible functions are called isomorphisms, and A, B are isomorphic (A = B) if there is an isomorphism in A B (or vice versa). In Set, A = B if |A| = |B|. In Vec, V = W if dim(V ) = dim(W ).

What about ML? int = int = 12 = ( 1)( 2)


23

Isomorphic = Really the Same


Isomorphic objects are interchangeable as far as you can tell in C.

In category theory, unique almost always means unique up to isomorphism.

Category theorists love proving that two very dierent-looking things are isomorphic.

24

One-to-One Functions, Monomorphisms and an Evil Pun


In Set, a function is 1-1 if f (x) = f (y) implies x = y. Equivalently, if f g = f h then g = h (why?) In C, f : A B is monomorphic if this is the case. Mnemonic for remembering that one-to-one functions are monomorphisms: mono a mono. You may groan. But you will not forget.
25

Onto Functions and Epimorphisms


In Set, a function f : A B is onto if for every y B there is an x A with y = f (x).

Equivalently, if g f = h f then g = h (why?)

In C, f : A B is epimorphic if this is the case.

I have no evil pun for this.

26

Next
Functors: Structure-preserving maps between categories

Universal constructions: units, voids, products, sums, exponentials.

Functions between functors: when are two implementations of polymorphic lists equivalent? when are two semantics equivalent?

Even scarier stu.


27

You might also like