<<

Introduction to theory

Valdis Laan∗ December 10, 2003

Contents

1 Categories 2 1.1 On -theoretical foundations ...... 2 1.2 Definition of category ...... 2 1.3 Functional programming languages as categories ...... 3 1.4 Some constructions ...... 4

2 Properties of and objects 5 2.1 Properties of morphisms ...... 5 2.2 Properties of objects ...... 9

3 11 3.1 Covariant and contravariant functors ...... 11 3.2 On ...... 13 3.3 Some properties of functors ...... 14 3.4 Comma categories ...... 15

4 Natural transformations 18 4.1 Definition and examples of natural transformations ...... 18 4.2 Categories of functors ...... 20 4.3 The ...... 20 4.4 The Godement of natural transformations ...... 22

5 Limits and colimits 24 5.1 Products and ...... 24 5.2 Equalizers and ...... 30 5.3 Pullbacks and pushouts ...... 32 5.4 Limits and colimits ...... 33 5.5 Complete categories ...... 36 5.6 preserving functors ...... 38 5.7 Exercises ...... 39

6 Adjunctions 41 6.1 Motivating examples ...... 41 6.2 ...... 42 6.3 Examples of adjuncions ...... 45 6.4 The Adjoint Theorem ...... 47 6.5 Equivalence of categories ...... 48 6.6 Exercises ...... 49

∗These notes are a compilation of sources [1]-[5], not an original work by V.L.

1 1 Categories 1.1 On set-theoretical foundations It is well-known that the set of all sets does not exist. However, would like to deal with collections of all sets, all groups, all topological spaces etc. A way to handle this is to assume the of the existence of so-called universes.

Definition 1.1 (U, ∈) is a universe, if it satisfies the following properties: 1. x ∈ y and y ∈ U ⇒ x ∈ U, S 2. I ∈ U and (∀i ∈ I)(xi ∈ U) ⇒ i∈I xi ∈ U, 3. x ∈ U ⇒ P(x) ∈ U, 4. x ∈ U, y ⊆ U, f : x → y is a surjective ⇒ y ∈ U, 5. ω ∈ U, where ω is the set of all finite ordinals and P(x) is the set of all subsets of x.

Some of the consequences of this definition are the following (cf. [1], Proposition 1.1.3).

Proposition 1.2 1. x ∈ U, y ⊆ U and y ⊆ x ⇒ y ∈ U, 2. x ∈ U and y ∈ U ⇒ {x, y} ∈ U, 3. x ∈ U and y ∈ U ⇒ x × y ∈ U, 4. x ∈ U and y ∈ U ⇒ xy ∈ U.

The properties of U ensure that any of the standard operations of applied to elements of U will always produce elements of U; in particular ω ∈ U provides that U also contains the usual sets of real numbers and related infinite sets. We can then regard “ordinary” mathematics as carried out extensively within U, i.e. on elements of U. Now let the universe U be fixed and call its elements sets. Thus U is the collection of all sets and we denote it by Set. We also call subsets of U classes. Since x ∈ y ∈ U implies x ∈ U, every element y of U is also a subset of U, that is, every set is a . Conversely, the class U itself is not a set because U ∈ U would contradict the axiom of regularity, which asserts that there are no infinite chains . . . xn ∈ xn−1 ∈ xn−2 ∈ ... ∈ x0. The classes that are not sets are called proper classes. In this way we can consider for example proper classes of all groups, all topological spaces etc. as subclasses of Set.

1.2 Definition of category Definition 1.3 A category C consists of the following:

1. a class C0, whose elements will be called “objects of the category”; 2. for every pair A, B of objects, a set C(A, B), whose elements will be called “morphisms” or “arrows” from A to B; 3. for every triple A, B, C of objects, a composition law

C(A, B) × C(B,C) −→ C(A, C);

the composite of the pair (f, g) will be written g ◦ f or just gf;

4. for every object A, a 1A ∈ C(A, A), called the identity morphism of A. These data are subject to the following . 1. Associativity axiom: given morphisms f ∈ C(A, B), g ∈ C(B,C), h ∈ C(C,D) the following equality holds: h(gf) = (hg)f.

2 2. Identity axiom: given morphisms f ∈ C(A, B), g ∈ C(B,C), the following equalities hold: 1Bf = f, g1B = g.

A morphism f ∈ C(A, B) is often written as f : A → B, A is called the domain (notation: dom f) or the source of f and B is called the (notation: cod f) or the target of f. A morphism f : A → A is called an of A.

Remarks 1.4 1. It turns out that 1A is the only identity morphism of A, because if iA ∈ C(A, A) is another morphism satisfying the identity axiom, then 1A = 1AiA = iA. 2. Very much in the same way as in the case of semigroups, the associativity axion implies that parentheses in any composite of finite number of morphisms can be placed in arbitrary way and therefore actually omitted.

Definition 1.5 A category is small if its objects constitute a set, otherwise it is large .

Example 1.6 The next table gives some examples of categories. Notation Objects Morphisms Set sets mappings Rel sets binary relations between sets Mon Gr groups homomorphisms Ab abelian groups group homomorphisms Rng rings with unit homomorphisms

VecR real vector spaces linear mappings ModR right modules over ring R homomorphisms Ban∞ real Banach spaces bounded linear mappings Ban1 real Banach spaces linear contractions Top topological spaces continuous mappings Pos posets order-preserving mappings Lat lattices homomorphisms Graph graphs graph homomorphisms Sgraph graphs strong graph homomorphisms 0 none none 1 A 1A 2 A, B A → B, 1A, 1B In most cases, the composition of morphisms is just the composition of mappings and identity morphisms are identity transformations. In Rel, the composition of relations is their product and the identity morphism is the equality . The category 0 is called the empty category .

Example 1.7 1. Objects: natural numbers, morphisms from m to n are all matrices (over a fixed field) with m rows and n columns, the composition of morphisms is the usual multiplication of matrices. 2. A poset (P, ≤) can be regarded as a category P with object set P . If x, y ∈ P then P(x, y) consists of exactly one morphism if x ≤ y, and is empty otherwise. 3. Every set can be viewed as a , i.e. a category where the only morphisms are the identity morphisms.

4. Every monoid (M, ·) gives rise to a category M with a single object ∗, M0 = {∗}, and M(∗, ∗) = M; the composition of morphisms is the multiplication · of M. Also conversely, the set of all morphisms of every one-object category is a monoid.

1.3 Functional programming languages as categories A (pure) functional programming language has 1. Primitive data types, given in the language.

3 2. Constants of each type. 3. Operations, which are functions between the types. 4. Constructors, which can be applied to data types and operations to produce derived data types and operations of the language. The language consists of the set of all operations and types derivable from the primitive data types and primitive operations. To see that a functional programming language L corresponds in a canonical way to a category C(L), we have to make two assumptions and one small change. 1. We assume that for each type A (both primitive and constructed) there is a do-nothing operation 1A. When applied, it does nothing to the data. 2. We add to the language an additional type called 1, which has the property that from every type A there is a unique operation to 1. We interpret each constant c of type A as a morphism c : 1 → A. 3. We assume that the language has a comptosition constructor: if f is an operation with inputs of type A and outputs of type B and another operation g has inputs of type B and output of type C, then doing one after the other is a derived operation (or program) typically denoted f; g, which has input of type A and output of type C. Under these conditions, a functional programming language L induces a category C(L), for which 1. the objects of C(L) are the types of L, 2. the morphisms of C(L) are the operations (primitive and derived) of L, 3. domain and codomain of a morphism are the input and output types of the corresponding operation, 4. composition of morphisms is given by the composition constructor, written in the reverse order, 5. the identity morphisms are the do-nothing operations.

Example 1.8 Consider a language with three data types nat (natural numbers and 0), boolean (true or false) and char (characters). We give a description of its operations in categorical style. 1. nat should have a constant 0 : 1 → nat and an operation succ : nat → nat. 2. There should be two constants true, false : 1 → boolean and an operation ¬ : boolean → boolean subject to the equalities ¬ ◦ true = false and ¬ ◦ false = true. 3. char should have one constant c : 1 → char for each character c. 4. There should be two type conversion operators ord : char → nat and chr : nat → char. These must satisfy the equality chr◦ord = 1char. (One can think of chr as operating modulo the number of characters, so that it is defined on all natural numbers.)

An example program is the morphism ‘next’ defined to be the composite chr ◦ succ ◦ ord : char → char, which calculates the next character. Note that two morphisms (programs) in C(L) are identified if they must be the same because of the equalities. For example, the morphisms chr ◦ succ ◦ ord and chr ◦ succ ◦ ord ◦ chr ◦ ord must be the same. Observe that nat has constants succ ◦ ... ◦ succ ◦ 0 : 1 → nat where succ occures zero or more times.

1.4 Some constructions Definition 1.9 A category B is called a of a category A, if

1. B0 ⊆ A0;

0 0 0 2. B(B,B ) ⊆ A(B,B ) for every pair B,B ∈ B0, so that (a) f ∈ B(B,B0) and g ∈ B(B0,B00) implies gf ∈ B(B,B00),

4 (b) 1B ∈ B(B,B) for every B ∈ B0.

Definition 1.10 A subcategory B of a category A is called a full subcategory if

0 0 0 B,B ∈ B0 ⇒ B(B,B ) = A(B,B ).

Example 1.11 The category Ab is a full subcategory of Gr, Gr is a full subcategory of Mon, Mon is a subcategory of the category Sgr of semigroups, which is not full. The category Ban∞ is a subcategory of

VecR, but not a full subcategory. Definition 1.12 The product of two categories A and B is the category A × B defined as follows.

1. (A × B)0 = A0 × B0. 2. (A × B)((A, B), (A0,B0)) = {(a, b) | a : A → A0 in A, b : B → B0 in B}. 3. The compostion of A × B is induced by the compositions of A and B, namely

(a0, b0)(a, b) = (a0a, b0b).

Definition 1.13 If A ∈ A0 is a fixed object of a category A then there is a category (A ↓ A) of objects under A, defined as follows. 1. Objects are pairs (B, f) where f : A → B. 2. A morphism h :(B, f) → (B0, f 0) is a morphism h : B → B0 of A such that hf = f 0. 3. The composition in (A ↓ A) is induced by the composition in A.

A ?  ?? f  ? f 0  ??  ??  ??   ? BBB / B0 h Similarly one can construct the category (A ↓ A) of objects over A.

Example 1.14 If (P, ≤) is a poset considered as a category P and a ∈ P , then (a ↓ P) is the set of all elements, greater than or equal to a, i.e. the upper induced by a.

Exercises 1.15 1. Choose some objects and morphisms between them in such a way that they form a category. Explain why they form a category. In what follows, let us call this category “your favourite category”. 2. Give some example of a full and non-full subcategory of your favourite category.

2 Properties of morphisms and objects 2.1 Properties of morphisms Definition 2.1 A morphism f : A → B in a category C is called 1. a if it is left cancellable, i.e.

fg = fh ⇒ g = h

for every pair of morphisms g, h : C → A; 2. a split monomorphism (or section or coretraction ) if it is left invertible, i.e. there exists a morphism g : B → A such that gf = 1A. In that case A is called a retract of B.

Proposition 2.2 In a category C,

5 1. every split monomorphism is a monomorphism; 2. every identity morphism is a split monomorphism; 3. the composite of two (split) is a (split) monomorphism; 4. if the composite kf of two morphisms is a (split) monomorphism then f is a (split) monomorphism.

Proof. 1. Suppose that kf = 1A and fg = fh where f : A → B, k : B → A and g, h : C → A. Then

g = 1Ag = (kf)g = k(fg) = k(fh) = (kf)h = 1Ah = h.

2. For every A ∈ C0, 1A = 1A1A. 3. Suppose k : B → D and f : A → B are monomorphisms and (kf)g = (kf)h, where g, h : C → A.

g f k C // A / B / D h

Then k(fg) = k(fh) and hence fg = fh, because k is a monomorphism. Since f is a monomorphism, g = h. Thus we have shown that kf is a monomorphism. If sk = 1B and tf = 1A for some s : D → B and t : B → A then

(ts)(kf) = t(sk)f = t1Bf = tf = 1A shows that kf is a split monomorphism. 4. Suppose that kf is a monomorphism and fg = fh, where f : A → B, g, h : C → A, k : B → D. Then (kf)g = k(fg) = k(fh) = (kf)h implies g = h. Hence f is a monomorphism. If kf is a split monomorphism, i.e. s(kf) = 1A for some s : D → A then (sk)f = 1A means that also f is a split monomorphism.

Definition 2.3 A morphism f : A → B in a category C is called 1. an if it is right cancellable, i.e.

gf = hf ⇒ g = h

for every pair of morphisms g, h : B → C; 2. a split epimorphism (or retraction) if it is right invertible, i.e. there exists a morphism g : B → A such that fg = 1B.

Proposition 2.4 In a category C, 1. every split epimorphism is an epimorphism; 2. every identity morphism is a split epimorphism; 3. the composite of two (split) is a (split) epimorphism; 4. if the composite kf of two morphisms is a (split) epimorphism then k is a (split) epimorphism.

Definition 2.5 A category is called a if its objects are sets (usually with some structure), morphisms are mappings (preserving that structure), composition of morphisms is composition of mappings and identity morphisms are identity mappings.

Set, Gr, Rng, Top, Ban∞, Pos and many others are examples of concrete categories. Rel is not a concrete category. In concrete categories, more can be said about relationships between different types of morphisms.

6 Proposition 2.6 In a concrete category, the following implications are valid for a morphism:

(smi) (im) split monomorphism =⇒ injective =⇒ monomorphism, (ses) (se) split epimorphism =⇒ surjective =⇒ epimorphism.

Proof. (smi). Suppose that for f : A → B there is g : B → A such that gf = 1A. If f(a1) = f(a2), a1, a2 ∈ A, then also a1 = (gf)(a1) = g(f(a1)) = g(f(a2)) = (gf)(a2) = a2, i.e. f is injective. (im). Suppose that f : A → B is injective and fg = fh for g, h : C → A. Then for every c ∈ C, f(g(c)) = f(h(c)), which implies g(c) = h(c). Thus g = h and we have proven that f is a monomorphism. It is not difficult to see that also (ses) and (se) hold.

Example 2.7 In the category Set, the monomorphisms are exactly the injective mappings. By Proposi- tion 2.6 we already know that injective mappings are monomorphisms, so let us prove the converse. Let f : A → B be a monomorphism and for every a ∈ A, let ga : {∗} → A be a mapping from a singleton to 0 0 A, that maps ∗ to a. If f(a) = f(a ), a, a ∈ A, then fga(∗) = fga0 (∗), or fga = fga0 . By the assumption, 0 ga = ga0 , which is equivalent to a = a . Hence f is injective.

Example 2.8 In the category Top, the monomorphisms are exactly the injective continuous mappings. Indeed, considering the singleton {∗} and any other topological space A we notice that the mappings ga : {∗} → A, a ∈ A, defined in Example 2.7, are continuous. Hence the proof of Example 2.7 can be carried over.

Example 2.9 In the categories Gr and Ab, the monomorphisms are exactly the injective group homo- morphisms. Again, we only need to show that monomorphisms are injective. Let f : G → H be a monomorphism of groups and for every a ∈ G, let ga : Z → G be a mapping

z ga(z) := a .

0 Clearly ga is a group . If f(a) = f(a ), then fga(1) = fga0 (1) and it follows that 0 fga = fga0 . By the assumption, ga = ga0 and so a = a .

Example 2.10 In the category Ban1, the monomorphisms are exactly the injective linear contractions. The elements of the unit ball of a B are in bijective correspondence with the linear con- tractions R → B. Indeed, if ||b|| ≤ 1 then kb : R → B, defined by

kb(r) := rb, r ∈ R, is a linear contraction. Conversely, if k : R → B is a linear contraction then ||k(1)|| ≤ |1| = 1, that is k(1) belongs to the unit ball of B. Clealry these constructions are inverse to each other. Suppose now that f : B → C is a monomorphism of Banach spaces and f(b) = f(b0). If ||b||, ||b0|| ≤ 1 0 then fkb(1) = fkb0 (1), which implies fkb = fkb0 . Since f is a monomorphism, kb = kb0 and hence b = b . Thus f is injective on unit ball. By the linearity of f this extends to the whole B.

Example 2.11 The implication (im) is not reversible, i.e. not all monomorphisms in concrete categories are injective. Consider the category Div of divisible abelian groups. The natural surjection π : Q → Q/Z on the of a divisible group Q by Z is obviously not injective. Let us show that it is a monomorphism. Suppose that A is a divisible and f, g : A → Q are group homomorphisms such that πf = πg. Setting h := f − g we have πh = 0 and the claim becomes h = 0. For an element a ∈ A, 0 = πh(a) = h(a) means that h(a) ∈ Z. If h(a) 6= 0 then  a  1 h = 2h(a) 2

 a  1  and therefore πh 2h(a) = 2 6= 0, a contradiction.

Example 2.12 Also the implication (smi) is not reversible. In Set, the empty mapping ∅ → A is injective but has no left inverse if A 6= ∅. However, every injective mapping B → A in Set, where B 6= ∅, is a split monomorphism.

7 Example 2.13 In Set, the epimorphisms are exactly the surjective mappings. Let f : A → B be an epimorphism, consider the two-element set {0, 1} with the mappings g, h : B → {0, 1} defined by

 1, if b ∈ f(A), g(b) = 0, if b 6∈ f(A), h(b) = 1 for every b ∈ B.

Clearly gf = hf is the constant mapping on 1. Hence g = h, which means that f(A) = B. The converse follows from Proposition 2.6. Moreover, in Set every surjective mapping is a split epimorphism. Let f : A → B be a surjective mapping. We define a mapping g : B → A by choosing for every b ∈ B an element a ∈ A such that f(a) = b and setting g(b) := a. Then clearly fg(b) = f(a) = b for every b ∈ B, so fg = 1B. (Note that the is exactly what is needed to make all these generally infinitely many choices.)

Example 2.14 In the category Top, the epimorphisms are exactly the surjective continuous mappings. The proof of Example 2.13 applies if we use the topological space {0, 1} with the {∅, {0, 1}} and the same g and h.

Example 2.15 In the category Ban1, the epimorphisms are the linear contractions with the dense . (A linear mapping f : A → B in Ban1 has dense image if f(A) = B, that is, for every b ∈ B and every ε > 0 there exists a ∈ A such that ||f(a) − b|| < ε.) Suppose that f : A → B is an epimorphism. Then f(A) is a closed subspace of B and B/f(A) is a Banach space. Both the canonical surjection π : B → B/f(A) and the zero mapping 0 : B → B/f(A) are linear contractions. From the equalities πf = 0 = 0f we conclude π = 0, which means B = f(A). Conversely, suppose that f(A) = B and gf = hf, g, h : B → C. Since g and h agree on f(A), by continuity g, h agree also on f(A) = B. Hence g = h.

Example 2.16 The implication (ses) is not reversible. In the category Graph there is a surjective homo- morphism • •     •  / •  ? ? ?? ?? ?? ?? • • which has no right inverse.

Example 2.17 The implication (se) is not reversible. Consider the category Mon of monoids and monoid homomorphisms and the inclusion i of the monoid (N ∪ {0}, +) into (Z, +), which is definitely not surjective. However it turns out to be an epimorphism. Suppose that f :(Z, +) → (S, ·) is a monoid homomorphism. For every n ∈ N, f(n) = f(1 + ··· + 1) = f(1)n, i.e. f(n) is determined by f(1). Also, f(1) is the inverse of f(−1), because

f(1)f(−1) = f(−1)f(1) = f(−1 + 1) = f(0) = 1.

Since every element of S can have only one inverse, f(−1) is determined by f(1). Also the value of f at every other negative integer is determined by f(1). Hence the homomorphism f is completely determined by f(1). Now suppose that g, h : Z → S are such that gi = hi. Then g(1) = gi(1) = hi(1) = h(1) and hence g = h. Thus i is an epimorphism.

Definition 2.18 A morphism is called a bimorphism, if it is both monomorphism and epimorphism, i.e. if it is cancellable.

Definition 2.19 A morphism is called an , if it is both split monomorphism and split epimorphism, i.e. if it is invertible. Two objects A and B of a category C are isomorphic if there exists an isomorphism f : A → B. We write A =∼ B to denote isomorphism.

8 Proposition 2.20 In a category C, 1. every isomorphism is a bimorphism; 2. every identity morphism is an isomorphism; 3. the composite of two bimorphisms () is a bimorphism (isomorphism).

Proof. Follows from Proposition 2.2 and Proposition 2.4.

Proposition 2.21 In a category, if an epimorphism is a split monomorphism, it is an isomorphism.

Proof. Exercise.

Example 2.22 In Set the isomorphisms are exactly the bijective mappings.

Example 2.23 In the categories Gr, Ab and Rng, the isomorphisms are exactly the bijective homomor- phisms.

Example 2.24 In the category Top, the isomorphisms are exactly the . Since continu- ous bijections need not be homeomorphisms, this provides an example of a category where bimorphisms need not be isomorphisms.

Example 2.25 In the category VecR, the isomorphisms are exactly the bijective linear mappings.

Example 2.26 In the category Ban1, the isomorphisms are precisely the isometric bijections. Every isometric bijection f : A → B is an isomorphism, because ||b|| = ||ff −1(b)|| = ||f −1(b)|| for every b ∈ B and hence f −1 is a linear contraction. Conversely, if the linear contraction f : A → B has an inverse mapping f −1 : B → A which is also a linear contraction, then f −1 is isometric, because

||a|| = ||f −1f(a)|| ≤ ||f(a)|| and ||f(a)|| ≤ ||a|| for every a ∈ A by the contracting properties of f −1 and f respectively.

Example 2.27 Every group can be viewed as a one-object category where all morphisms are isomor- phisms.

Example 2.28 Recall that every poset can be regarded as a category. In such category every morphism is a bimorphism because between any two objects there is at most one morphism. But isomorphisms are only the identity morphisms.

2.2 Properties of objects Definition 2.29 An object 1 of a category C is called a terminal object if from every object C of C there is exactly one morphism from C to 1. An object 0 of C is initial if there is exactly one morphism from 0 to every object of C. An object is a if it is both terminal and initial.

Proposition 2.30 Every two terminal (initial, zero) objects of a category are isomorphic.

0 0 0 Proof. If C,C ∈ C0 are terminal objects then C(C,C) = {1C } and C(C ,C ) = {1C0 }. Also there 0 0 exist morphisms f : C → C and g : C → C. Since gf : C → C, gf = 1C , and similarly fg = 1C0 .

Example 2.31 In the category Set, the empty set is the initial object and singletons are terminal objects. The same is true for the category Top.

Example 2.32 In the categories Ab, VecR, Ban1 etc., {0} is both the initial and terminal object, hence the zero object.

Example 2.33 In the category Rng of rings with unit and homomorphisms that preserve unit, {0} is the terminal object and Z is the initial object. Definition 2.34 An object P of a category C is called projective if for every epimorphism g : B → C and every morphism f : P → C there exists a morphism h : P → B such that gh = f.

9 P  h   f     BCB g / / C

Proposition 2.35 A retract of a is projective.

Proof. In the following diagram, let P be projective and let A with ri = 1A be its retract (see Definition 2.1). i PPAo o AAP r / /   h    fr   f       BCB g / / C Given f : A → C, by projectivity of P there exists h : P → B such that gh = fr. Hence ghi = fri = f

Definition 2.36 An object A of a category C is called injective if for every monomorphism g : B → C and every morphism f : B → A there exists a morphism h : C → A such that hg = f.

g BBC/ / C ??  ??  ??  f ??  h ??  ?  A

Example 2.37 Every object of Set is projective. Using the fact that every epimorphism splits in Set and the notation of Definition 2.34, we can find p : C → B with gp = 1C . Setting h := pf we obtain gh = gpf = f.

Example 2.38 A classical result, the so-called Baer criterion for injectivity, states that an abelian group is injective if and only if it is divisible.

Example 2.39 Projective and injective objects play an important role in the theory of module over rings. A classical result is that a module is projective if and only if it is a direct summand of a .

Exercises 2.40 1. Prove that if an epimorphism is a split monomorphism then it is an isomorphism. 2. Prove that in a concrete category, every split epimorphism is surjective (see Proposition 2.6). 3. Prove that in a concrete category, every surjective morphism is an epimorphism (see Proposi- tion 2.6). 4. What are the monomorphisms, epimorphisms, bimorphisms and isomorphisms in your favourite category? 5. Does your favourite category have terminal, initial or zero object? 6. Prove directly, that every object of Set is projective (see Example 2.37). 7. What are the projective objects of your favourite category? 8. Prove that an object of Set is injective if and only if it is nonempty.

10 3 Functors 3.1 Covariant and contravariant functors Definition 3.1 A(covariant) functor F from a category A to a category B consists of

1. a mapping F0 : A0 → B0 between the classes of objects of A and B; the image of A ∈ A0 is written F (A);

0 0 A,A 0 0 2. for every pair of objects A, A of A, a mapping F1 : A(A, A ) → B(F (A),F (A )); the image of f ∈ A(A, A0) is written F (f); such that the following axioms are satisfied: 1. for every pair of morphisms f ∈ A(A, A0), g ∈ A(A0,A00),

F (gf) = F (g)F (f);

2. for every object A ∈ A0, F (1A) = 1F (A).

AAF / F (A)

f F (f)   A0 / F (A0)

Definition 3.2 A contravariant functor F from a category A to a category B consists of:

1. a mapping F0 : A0 → B0 between the classes of objects of A and B; the image of A ∈ A0 is written F (A);

0 0 A,A 0 0 2. for every pair of objects A, A of A, a mapping F1 : A(A, A ) → B(F (A ),F (A)); the image of f ∈ A(A, A0) is written F (f); such that the following axioms are satisfied: 1. for every pair of morphisms f ∈ A(A, A0), g ∈ A(A0,A00),

F (gf) = F (f)F (g);

2. for every object A ∈ A, F (1A) = 1F (A).

AAF / F (A) O

f F (f)  A0 / F (A0)

Examples 3.3 Let us list some examples of (covariant) functors.

1. For every category A, there is the identity functor 1A : A → A, defined by 1A(A) = A on objects and by 1A(f) = f on morphisms. 2. Every subcategory B of a category A induces in a natural way the inclusion functor B → A, which is just the restriction of the identity functor 1A to B.

11 3. If A and B are categories and B ∈ B0 is a fixed object then there is the constant functor on B, A ∆B : A → B (or simply ∆B), defined by

∆B(A) := B, ∆B(f) := 1B

for every A ∈ A0 and every morphism f of A. 4. The U : Gr → Set maps a group (A, ·) to its underlying set A and group homomorphisms to the corresponding mappings. Also, one can for example consider forgetful

functors Rng → Ab (forgets multiplication), Rng → Mon (forgets addition) or Ban1 → VecR (forgets norm). 5. The functor F : Set → Gr assigns to every set A the free group with a set of generators A, and to each mapping f of sets the that coincides with f on the generators. 6. For every group A, let A0 be the commutator of A, i.e. the subgroup generated by all elements of the form aba−1b−1. Define F : Gr → Ab by F (A) := A/A0, F (h)(aA0) := h(a)B0, for all groups A, B and group homomorphisms h : A → B. Then F is a functor which is called the abelianization functor.

7. If R is a ring and MR is a fixed right R-module then there is a functor MR ⊗ − : RMod → Ab of tensor multiplication by MR (from the category of left R-modules to the category Ab of abelian groups) defined by (MR ⊗ −)(RN) := M ⊗R N,MR(f) := 1M ⊗ f

for every left R-module RN and every homomorphism f of left R-modules. Examples 3.4 There are also many examples of contravariant functors. 1. There is a functor P : Set → Set, which takes every set A to its powerset P(A) and a mapping f : A → B to the inverse image mapping f −1 : P(B) → P(A), which maps a subset C of B to f −1(C) ⊆ A. 2. If (X, τ) is a topological space then the set τ of all open subsets U of X is a V with respect to inclusion relation and hence gives rise to a category; there is a morphism iU : V → U if and only if V ⊆ U. Let C(U) = {h : U → R | h is continuous }. Then C : τ → Set becomes a V functor if we define a mapping C(iU ): C(U) → C(V ) by V C(iU )(h) := h|V .

Next we introduce functors which play a fundamental role in the theory of categories. Example 3.5 For a fixed object C of a category C, the assignment

A / C(C,A)

f f◦−   B / C(C,B) defines a covariant functor C(C, −): C → Set, which is called a covariant (the functor is represented by C) or a covariant hom-functor. (Note that C(C, f) is often written instead of f ◦ −.) Example 3.6 For a fixed object C of a category C, the assignment

A / C(A, C) O

f −◦f  B / C(B,C)

12 defines a contravariant functor C(−,C): C → Set, which is called a contravariant representable functor or a contravariant hom-functor.

For functors F : A → B and G : B → C we can form their composite GF : A → C (which again will be a functor) by defining (GF )(A) := G(F (A)), GF (f) := G(F (f)) for every object A ∈ A0 and every morphism f of A. Such composition will be associative and identity functors will act as identities with respect to this composition. This can lead to an idea of forming the “category of all categories” where functors would play the role of morphisms. Unfortunately, the collection of all categories is not a class anymore and also the collection of all functors from one category to another needs not to be a set. A way out is to modify the definition of category by allowing bigger collections (sometimes called conglomerates) for objects and morphisms. We shall call such things quasi- categories (following Herrlich and Strecker). Thus the collection of all categories and functors between them equipped with the composition of functors is a quasicategory which is denoted by CAT. However, if A is a small category and B is arbitrary category then the collection Fun(A, B) of all functors from A to B is a class, and if B is also small then Fun(A, B) is a set. Hence we can speak about the category of all small categories, which is denoted by Cat.

3.2 On duality Roughly speaking, categorical duality is the process “Reverse all morphisms”.

Definition 3.7 For a category C, the Cop is defined as follows.

op op 1. C0 = C0 (C and C have the same objects). op op op 2. For all A, B ∈ C0 , C (A, B) = C(B,A), so the morphisms of C are the morphisms of C “written in the reverse direction”. To avoid confusion, we write f op : A → B if we consider a morphism op op op op f : B → A of C as a morphism of C . Note that (f ) = f and the morphisms 1A and 1A are identified. 3. The composition in Cop is defined by

f opgop := (gf)op.

gf (gf)op In C :ABAC/ BC/) In Cop : ABACou BCo f g f op gop For every notion defined in a category, there is a notion (usually named using the prefix ‘co-’) which is obtained by reversing the direction of all morphisms involved and replacing every composite fg by the composite gf. Similarly, every statement has a dual statement. The duality principle asserts that if some statement is true in every category then also its dual statement is true in every category. So we see that projectivity is the dual notion of injectivity, terminal objects are dual to initial objects etc. Also, for example, if we know that terminal objects are determined uniquely up to isomorphism then the duality principle implies that also initial objects are determined uniquely up to isomorphism. If F : A → B is a contravariant functor, we define a functor Fˆ : Aop → B by

Fˆ(A) := F (A), Fˆ(f op) := F (f).

Then Fˆ(f opgop) = Fˆ((gf)op) = F (gf) = F (f)F (g) = Fˆ(f op)Fˆ(gop) and Fˆ(1op) = F (1 ) = 1 = 1op , which makes Fˆ a covariant functor from Aop to B. A A F (A) Fˆ(A) Conversely, if G : Aop → B is a covariant functor, we define G : A → B by

G(A) := G(A), G(f) := G(f op).

13 Then G(gf) = G((gf)op) = G(f opgop) = G(f op)G(gop) = G(f)G(g), op G(1A) = G(1A ) = 1G(A) = 1G(A), so G is a contravariant functor from A to B. Moreover, if F : A → B is a contravariant functor and f a morphism of A then Fˆ(f) = Fˆ(f op) = F (f), and if G : Aop → B is a covariant functor and f op a morphism of Aop then Gˆ (f op) = G(f) = G(f op). Thus we have proven the following Proposition 3.8 For categories A and B, there is one-to-one correspondence between contravariant functors A → B and covariant functors Aop → B. Having this result in mind, in what follows, by default we always speak about covariant functors (either from A or Aop). Note also that sometimes it may be convenient to regard contravariant functors A → B as covariant functors A → Bop.

3.3 Some properties of functors 0 Definition 3.9 Consider a functor F : A → B and for every pair of objects A, A ∈ A0 the mapping A,A0 0 0 F1 : A(A, A ) → B(F (A),F (A )), f 7→ F (f). The functor F is 0 A,A 0 1. faithful if the mapping F1 is injective for every A, A ∈ A0; 0 A,A 0 2. full if the mapping F1 is surjective for every A, A ∈ A0; 0 A,A 0 3. full and faithful if the mapping F1 is bijective for every A, A ∈ A0;

4. an isomorphism of categories if it is full and faithful and induces a bijection A0 → B0 between the classes of objects. For example, the forgetful functor U : Gr → Set is faithful but not full and not a bijection between objects. Definition 3.10 Consider a functor F : A → B. 1. F preserves monomorphisms if, for every morphism f of A, f monomorphism ⇒ F (f) monomorphism .

2. F reflects monomorphisms if, for every morphism f of A, F (f) monomorphism ⇒ f monomorphism .

Similar definitions can, of course, be given for all other types of morphisms. Proposition 3.11 A faithful functor reflects monomorphisms and epimorphisms. Proof. Consider a faithful functor F : A → B and a morphism f : A → A0 in A such that F (f): F (A) → F (A0) is a monomorphism in B. Suppose that fg = fh for some g, h : A00 → A. Then fg = fh ⇒ F (f)F (g) = F (f)F (h) ⇒ F (g) = F (h) ⇒ g = h, where the second implication holds because F (f) is a monomorphism and the last implication holds because F is faithful. Similarly if F (f) is an epimorphism and gf = hf for some g, h : A0 → A00, then gf = hf ⇒ F (g)F (f) = F (h)F (f) ⇒ F (g) = F (h) ⇒ g = h.

Proposition 3.12 Every functor preserves isomorphisms.

Proof. If kf = 1A for f : A → B and k : B → A then F (k)F (f) = F (1A) = 1F (A). This proves that F preserves both split monomorphisms and split epimorphisms, and hence isomorphisms. Proposition 3.13 A full and faithful functor reflects isomorphisms. Proof. Suppose F : A → B is a full and faithful functor, f : A → A0 in A and F (f): F (A) → F (A0) 0 is an isomorphism in B. Then F (f)s = 1F (A0) and sF (f) = 1F (A) for some s : F (A ) → F (A). Since F is 0 full, s = F (g) for some g : A → A. Hence F (fg) = F (1A0 ) and F (gf) = F (1A) imply fg = 1A0 , gf = 1A by faithfulness of F . Thus f is an isomorphism.

14 3.4 Comma categories Using a given functor (or functors), it is possible to construct new categories. We present some of such constructions. Definition 3.14 Let F : A → C and G : B → C be functors. The (F ↓ G) (also written (F,G)) is defined in the following way.

1. The objects of (F ↓ G) are the triples (A, f, B) where A ∈ A0, B ∈ B0 and f : F (A) → G(B) is a morphism of C. 2. A morphism from (A, f, B) to (A0, f 0,B0) in (F ↓ G) is a pair (a, b) where a : A → A0 in A, b : B → B0 in B and f 0F (a) = G(b)f. 3. The composition law of (F ↓ G) is induced by the composition laws of A and B, that is, (a0, b0)(a, b) = (a0a, b0b).

F (a) F (a0) F (A) / F (A0) / F (A00)

f f 0 f 00    G(B) / G(B0) / G(B00) G(b) G(b0)

Example 3.15 In the previous definition, let A = 1 be the discrete category with a single object ? and let C ∈ C0. Then C may be regarded as a functor FC : 1 → C, ? 7→ C. Taking F = FC we obtain a category (FC ↓ G) where objects are triples (?, f, B) where B ∈ B0 and f : C → G(B), and morhisms 0 0 0 0 0 (?, f, B) −→ (?, f ,B ) are pairs (1?, b) where b : B → B is such that f = f F (1?) = G(b)f. Clearly this category is isomorphic to a category with objects (f, B), B ∈ B0, f : C → G(B), where morphisms (f, B) → (f 0,B0) are morphisms b : B → B0 such that f 0 = G(b)f. We denote the last category by (C ↓ G) and call it the category of objects G-under C.

C  ?? f  ?? f 0  ??  ??  ??   ? G(B) / G(B0) G(b)

If we further take G = 1C the identity functor of C, we obtain precisely the category (C ↓ 1C) = (C ↓ C) of objects under C (cf. Def. 1.13). Similarly one obtains the category of objects F -over C and the category of objects over C. Another construction, which is very similar to the construction of comma categories, is the construc- tion of algebras of an endofunctor. (A functor A → A is called an endofunctor of A.) Definition 3.16 The category Alg(F ) of algebras of an endofunctor F : A → A (shortly: F -algebras) is constructed as follows. 1. Objects are pairs (A, f A) where f A : F (A) → A.

0 0 2. A morphism ϕ :(A, f A) → (A0, f A ) is a morphism ϕ : A → A0 of A such that f A F (ϕ) = ϕf A. 3. The composition law of Alg(F ) is induced by the composition law of A.

F (ϕ) F (ψ) F (A) / F (A0) / F (A00)

0 00 f A f A f A    AAA / A0 / A00 ϕ ψ

15 Example 3.17 Traditionally, a (A, (fi)i∈I ) is given by a set A and a collection of A ni A F ni operations fi : A → A. The operations may be combined into a single mapping f : i∈I A → A, so that a universal algebra is given by a set A and a mapping f A : F (A) → A, where the endofunctor F F ni of Set, F (X) = i∈I X , determines the type of that algebra. (For example, a group can be regarded as an F -algebra of the Set endofunctor F (X) = X0 t X1 t X2.) If (A, f A) and (B, f B) are two algebras of the same type, then a mapping ϕ : A → B induces canonically a mapping F (ϕ): F (A) → F (B). It can be shown that ϕ is a homomorhism if and only if the following diagram commutes:

F (ϕ) F (A) / F (B)

f A f B   AABϕ / B .

In computer science, so-called coalgebras have turned out to be very useful.

Definition 3.18 The category Coalg(F ) of coalgebras of an endofunctor F : A → A (shortly: F -coalgebras) is constructed as follows.

1. Objects are pairs (A, αA) where αA : A → F (A). (If A = Set, this αA is called the structure mapping of the coalgebra (A, αA).)

0 0 2. A morphism ϕ :(A, αA) → (A , αA0 ) is a morphism ϕ : A → A of A such that F (ϕ)αA = αA0 ϕ. 3. The composition law of Coalg(F ) is induced by the composition law of A.

ϕ AAA/ A0

αA αA0

  F (A) / F (A0) F (ϕ)

Example 3.19 Finite and infinite Σ-lists can be modelled as a coalgebra of the functor F : Set → Set, defined by F (X) := {∗} t Σ × X. ∞ ∞ On the set Σ of all finite and infinite sequences of elements of Σ, the structure mapping αΣ∞ :Σ → {∗} t Σ × Σ∞ is defined by

 ∗, if σ is the empty sequence, α ∞ (σ) := Σ (head(σ), tail(σ)), if σ is a nonempty sequence.

Example 3.20 Nonempty binary trees with leaves of type Σ can be modelled as a coalgebra of the functor F : Set → Set, defined by F (X) := Σ t X × X.

On the set T of all such trees, the structure mapping αT : T → Σ t T × T is defined by  t ∈ Σ, if t is a leaf, α (t) := T (left(t), right(t)), if t is not a leaf.

Example 3.21 Assume that the operations deposit(amount) and showbalance are defined for a data type A = bank account: deposit : A × R → A, showbalance : A → R. A bank account type with these operations is a coalgebra for the functor F (X) = XR × R. The structure mapping αA : A → AR × R has the form

αA(a) = (deposit(a, −), showbalance(a)).

16 Example 3.22 Deterministic automata can be considered as coalgebras. For a fixed set Σ, consider the covariant hom-functor F = Set(Σ, −) = (−)Σ : Set → Set. An F -coalgebra is given by a mapping Σ αA : A → A . Such mappings are in one-to-one correspondense with mappings δA : A × Σ → A, that is, with deterministic automata with input alphabet Σ, set of states A and transition function δA, if we define δA(a, σ) := αA(a)(σ).

ϕ AAB/ B

αA αB

  AΣ / BΣ F (ϕ)=ϕ◦−

A mapping ϕ : A → B is a homomorphism of F -coalgebras if ϕαA(a) = αB(ϕ(a)), that is, if

ϕ(δA(a, σ)) = ϕ(αA(a)(σ)) = (ϕαA(a))(σ) = (αB(ϕ(a)))(σ) = δB(ϕ(a), σ), for every a ∈ A and σ ∈ Σ. The equality ϕ(δA(a, σ)) = δB(ϕ(a), σ) is exactly the definition of a homomorphism of automata.

Exercises 3.23 1. Construct a functor from your favourite category to some other category of from some category to your favourite category. Does it have any nice properties? 2. Prove that a functor F : A → B is an isomorphism of categories if and only if there exists a functor G : B → A such that FG = 1A and GF = 1B. 3. Prove that an isomorphism of categories preserves and reflects monomorphisms and epimorphisms. 4. Show that the product A × B of categories A and B (see 1.12) can be considered as a comma category.

17 4 Natural transformations 4.1 Definition and examples of natural transformations Natural transformations can be regarded as morphisms between functors.

Definition 4.1 Let F,G : A → B be two functors from a category A to a category B.A α : F ⇒ G from F to G is a family (αA : F (A) → G(A))A∈A0 of morphisms of B 0 indexed by the objects of A, such that αA0 F (f) = G(f)αA for every morphism f : A → A in A, i.e. the following square is commutative:

α A F (A) A / G(A)

f F (f) G(f)    A0 F (A0) / G(A0) . αA0

The morphism αA for an object A ∈ A0 is called the component of the natural transformation α at A. Definition 4.2 Let F,G : A → B be two contravariant functors from a category A to a category B.A natural transformation α : F ⇒ G from F to G is a family (αA : F (A) → G(A))A∈A0 of morphisms 0 of B indexed by the objects of A, such that G(f)αA0 = αAF (f) for every morphism f : A → A in A, i.e. the following square is commutative:

α A F (A) A / G(A) O O

f F (f) G(f)  A0 F (A0) / G(A0) . αA0

Definition 4.3 A natural transformation α : F ⇒ G, where F,G : A → B, is called a natural iso- morphism if αA is an isomorphism in B for every A ∈ A0. Functors F and G are called naturally isomorphic (notation: F =∼ G) if there exists a natural isomorphism F ⇒ G.

For functors F,G : A → B, we denote the conglomerate of all natural transformations from F to G by Nat(F,G).

Example 4.4 For every functor F : A → B there is the identity natural transformation 1F : F ⇒ F defined by (1F )A := 1F (A). Example 4.5 Let f : B → A be a fixed morphism of a category A. The definition

A(f, −)C (g) := gf, g : A → C, gives a natural transformation A(f, −): A(A, −) ⇒ A(B, −) between the functors represented by A and B because of the commutativity of the following square:

A(f,−)C C A(A, C) / A(B,C)

h A(A,h)=h◦− A(B,h)=h◦−    C0 A(A, C0) / A(B,C0) . A(f,−)C0

Dually, for a fixed f : A → B in A, the definition

A(−, f)C (g) := fg, g : C → A, gives a natural transformation A(−, f): A(−,A) ⇒ A(−,B) between contravariant repre- sentable functors.

18 Example 4.6 For a fixed field K we can consider the contravariant hom-functor VecK (−,K): VecK → ∗ Set. It is well-known that for a V over K, the set VecK (V,K) = Hom(V,K) = V of linear mappings from V to K can be considered as a vector space over K with pointwise operations. Moreover, ∗ ∗ if f : V → U is a linear mapping in VecK then VecK (−,K)(f) = − ◦ f : U → V is also a linear mapping. Hence the functor VecK (−,K) can be considered as a contravariant functor VecK → VecK . We denote this functor shortly by (−)∗. The composite of (−)∗ with itself will be a covariant functor ∗∗ VecK → VecK . We denote it by (−) and call it the second dual functor. For every vector space V ∗∗ we define αV : V → V = Hom(Hom(V,K),K) by

(αV (a))(g) := g(a), a ∈ V , g ∈ Hom(V,K). From we know that αV is a linear mapping of vector spaces. For every f ∈ Hom(V,U), every a ∈ V and every h ∈ Hom(U, K) = U ∗,

∗∗ (f αV )(a)(h) = (αV (a)(− ◦ f))(h) = αV (a)(hf) = hf(a) = h(f(a)) = αU (f(a))(h) = (αU f)(a)(h),

∗∗ which proves that α = (αV )V ∈(VecK )0 : 1VecK ⇒ (−) is a natural transformation.

α VVVV / V ∗∗

f −◦(−◦f)=f ∗∗ αU (f(a))  ∗∗ ∗ ∗ * UUUα / U U / V / K U −◦f αV (a)

∗ ∗ Example 4.7 If K is the multiplicative group of a field K then detK : GLn(K) → K is a homomor- phism of groups. Moreover, the square

det K ∗ GLn(K) / K

∗ GLn(f) f

  ∗ GLn(L) / L detL commutes for every homomorphism f : K → L of fields (here GLn(f) applies f to all entries of a matrix and f ∗ is the restriction of f to K∗). This means that determinant is a natural transformation ∗ ∗ det : GLn ⇒ (−) between two functors GLn, (−) : → Gr.

Example 4.8 Suppose that some programming language L (for instance the language from Example 1.8) has a constructor (−)∗ which allows for every data type A (i.e. a set of constants) to construct a new type A∗ which is the set of all finite lists with elements of type A (shortly: A-lists). For example, if A = {a, b}, then the lists [a, b, a], [], [b, b, b, b] will belong to A∗. If f : A → B is an operation in language L then f ∗ will denote the (derived) operation A∗ → B∗ which applies f to all elements of a given A-list (e.g. f ∗([a, b, a]) = [f(a), f(b), f(a)] ∈ B∗). It is easy to see that (−)∗ : C(L) → C(L) is an endofunctor of the category C(L) induced by the language L. For a type A, one can also consider the set (A∗)∗ = A∗∗, consisting of all lists of A-lists, obtained by ap- plying the functor (−)∗ twice. For such type A∗∗, one may want to have the operation of flattening, which simply concatenates the lists in the list. For example, flatten([[a, b, a], [], [b, b, b, b]]) = [a, b, a, b, b, b, b]. The collection of all these flattening operations is a natural transformation (−)∗∗ ⇒ (−)∗, because the following square commutes for every operation f : A → B:

flatten A∗∗ A / A∗

f ∗∗ f ∗

  B∗∗ / B∗ . flattenB

19 4.2 Categories of functors Lemma 4.9 If F, G, H : A → B are functors from A to B and α : F ⇒ G, β : G ⇒ H are natural transformations then the formula (β ◦ α)A := βAαA,

A ∈ A0, defines a natural transformation β ◦ α : F ⇒ H. Proof. For every morphism f : A → A0 in A,

H(f)(β ◦ α)A = H(f)βAαA = βA0 G(f)αA = βA0 αA0 F (f) = (β ◦ α)A0 F (f).

α βA F (A) A / G(A) / H(A)

F (f) G(f) H(f)

 0  0  0 F (A ) α 0 / G(A ) / H(A ) A βA0

It easily follows from the definition that the composition ◦ of natural transformations is associative and identity natural transformations act as units with repect to this composition. Thus we may form the quasicategory Fun(A, B) of all functors from A to B with morphisms the natural transformations between such functors. If A is small, this quasicategory becomes a category.

4.3 The Yoneda Lemma

Theorem 4.10 (The Yoneda Lemma) Let A be a category, F : A → Set a functor, A ∈ A0 and A(A, −): A → Set the corresponding representable functor. 1. There exists a bijective correspondence

θF,A : Nat(A(A, −),F ) −→ F (A) between the natural transformations from A(A, −) to F and the elements of the set F (A); in par- ticular those natural transformations constitute a set.

2. The bijections θF,A constitute a natural transformation in the variable A.

3. If A is a small category, the bijections θF,A also constitute a natural transformation in the variable F .

Proof. 1. We define mappings

θF,A Nat(A(A, −),F ) / F (A) o τ by θF,A(α) := αA(1A) for every natural transformation α : A(A, −) ⇒ F , and

τ(a)B(f) := F (f)(a)

for every a ∈ F (A),B ∈ A0 and f : A → B. We have to check that τ(a) = (τ(a)B)B∈A0 is a natural transformation A(A, −) ⇒ F . Indeed, for all morphisms g : B → C and f : A → B in A,

F (g)τ(a)B(f) = F (g)F (f)(a) = F (gf)(a) = τ(a)C (gf) = τ(a)C (g ◦ −)(f).

τ(a)B A(A, B) / F (B)

g◦− F (g)   A(A, C) / F (C) τ(a)C

20 Next, for every a ∈ F (A) we have

θF,Aτ(a) = τ(a)A(1A) = F (1A)(a) = 1F (A)(a) = a, proving that θF,Aτ = 1F (A). On the other hand, if α : A(A, −) ⇒ F and f : A → B in A, then

(τθF,A(α))B(f) = (τ(αA(1A)))B(f) = F (f)(αA(1A)) = (F (f)αA)(1A)

= (αB(f ◦ −))(1A) = αB(f1A) = αB(f). Here the fourth equality follows from the naturality of α, more precisely from the commutativity of diagram α A(A, A) A / F (A)

f◦− F (f)   A(A, B) / F (B) . αB

Hence τθF,A(α) = α for every α, which proves that τθF,A = 1Nat(A(A,−),F ). 2. To prove the naturality of the bijections for a fixed functor F , let us consider the functor N : A → Set, defined on objects by N(A) := Nat(A(A, −),F ), and on morphism f : A → B of A, the mapping N(f): Nat(A(A, −),F ) / Nat(A(B, −),F ) is defined by N(f)(α) := α ◦ A(f, −), where A(f, −): A(B, −) ⇒ A(A, −) (see Example 4.5) and α : A(A, −) ⇒ F . We are claiming that the definition νA := θF,A, A ∈ A0, gives a natural transformation ν : N ⇒ F .

θF,A Nat(A(A, −),F ) / F (A)

N(f) F (f)   Nat(A(B, −),F ) / F (B) θF,B

Indeed, for every α : A(A, −) ⇒ F ,

F (f)θF,A(α) = F (f)αA(1A) = αB(f ◦ −)(1A) = αB(f),

θF,BN(f)(α) = θF,B(α ◦ A(f, −)) = (α ◦ A(f, −))B(1B)

= αBA(f, −)B(1B) = αB(1Bf) = αB(f). 3. If A is a small category, then we can consider the category Fun(A, Set) of all functors from A to Set. For a fixed object A ∈ A0 we this time consider the functor M : Fun(A, Set) → Set defined on objects F : A → Set by M(F ) := Nat(A(A, −),F ); and if γ : F ⇒ G is a morphism of Fun(A, Set), then the mapping M(γ): Nat(A(A, −),F ) / Nat(A(A, −),G) is defined by M(γ)(α) := γ ◦ α.

On the other hand, there is a functor of “evaluation in A” evA : Fun(A, Set) → Set defined by

evA(F ) := F (A);

evA(γ) := γA.

The assertion is that the definition µF := θF,A, F : A → Set, gives a natural transformation µ : M ⇒ evA.

θF,A Nat(A(A, −),F ) / F (A)

γ◦−=M(γ) γA=evA(γ)   Nat(A(A, −),G) / G(A) θG,A

21 Indeed, for every γ : F ⇒ G and α : A(A, −) ⇒ F ,

γAθF,A(α) = γAαA(1A) = (γ ◦ α)A(1A) = θG,A(γ ◦ α) = θG,A(γ ◦ −)(α).

Corollary 4.11 If A, B ∈ A0 then each natural transformation A(A, −) ⇒ A(B, −) has the form A(f, −) for a unique morphism f : B → A.

Proof. Let α : A(A, −) ⇒ A(B, −); we shall apply the Yoneda Lemma for F = A(B, −). Since the mapping τ : A(B,A) / Nat(A(A, −), A(B, −)) is bijective, there is a unique morphism f : B → A such that α = τ(f). Hence, for every C ∈ A0 and g : A → C,

αC (g) = τ(f)C (g) = (A(B, −)(g))(f) = (− ◦ g)(f) = gf = A(f, −)C (g), which means that α = A(f, −). For a category A, define a mapping Y op : A → Fun(A, Set) by

Y op(A) := A(A, −), Y op(f) := A(f, −): A(A, −) ⇒ A(B, −) where f : B → A in A. It can be seen that for morphisms f : A → B, h : B → C in A,

op op op op Y (hf) = Y (f)Y (h),Y (1B) = 1Y op(B). (1) So Y op is a contravariant functor. It is called the contravariant Yoneda .

Proposition 4.12 The Yoneda embedding functors are full and faithful.

Proof. We have to show that for all A, B ∈ A0, the mapping

op B,A op op (Y )1 : A(B,A) / Fun(A, Set)(Y (A),Y (B)) = Nat(A(A, −), A(B, −)) is bijective. But as we saw in Corollary 4.11, τ(f) = A(f, −) = Y op(f) for every f : B → A. Hence Y op is bijective on morphisms because τ is.

4.4 The Godement product of natural transformations There exists another way of composing natural transformations.

Proposition 4.13 Consider the following situation:

F H / / AB⇓α BC⇓β , / / G K where A, B, C are categories, F, G, H, K are functors and α, β are natural transformations. The formula

(β ∗ α)A := βG(A)H(αA) = K(αA)βF (A) : HF (A) → KG(A) defines a natural transformation β ∗ α : HF ⇒ KG.

HF / AC⇓ β ∗ α / KG

Proof. First we note that, indeed, βG(A)H(αA) = K(αA)βF (A), because β is a natural transformation:

H(αA) HF (A) / HG(A)

βF (A) βG(A)   KF (A) / KG(A) . K(αA)

22 The claim is that, for every morphism f : A → A0 in A, the outer rectangle in the diagram

H(αA) βG(A) HF (A) / HG(A) / KG(A)

HF (f) HG(f) KG(f)    HF (A0) / HG(A0) / KG(A0) H(αA0 ) βG(A0) is commutative. This is true since the left-hand square commutes by naturality of α and functoriality of H and the right-hand square commutes by naturality of β. The composition ∗, defined in Proposition 4.13 is called the Godement product of the natural transformations α and β. Also, sometimes the composition ∗ is called the horizontal composition of natural transformations and ◦ is called the vertical composition of natural transformations. Very often, instead of writing 1F for the identity natural transformation of a functor F , the symbol F itself is used. Hence, for example

(β ∗ F )A = βF (A), (2)

(H ∗ α)A = H(αA), (3) where β ∗ F : HF ⇒ KF and H ∗ α : HF ⇒ HG.

Exercises 4.14 1. Recall that every monoid can be considered as a category (see Example 1.7). What are functors between such categories? Suppose that A, B are groups, considered as one- object categories, and f, g : A → B two functors between these categories. Show that there is a natural transformation f ⇒ g if and only if f and g are conjugate, that is,

(∃b ∈ B)(∀a ∈ A)(f(a) = b−1g(a)b).

2. Prove that a natural transformation α : F ⇒ G is a natural isomorphism if and only if there exists a natural transformation β : G ⇒ F such that β ◦ α = 1F and α ◦ β = 1G. In other words, natural isomorphisms are isomorphisms in quasicategories Fun(A, B) of functors.

3. For a fixed object A ∈ A0, define evA : Fun(A, Set) → Set by

evA(F ) := F (A),

evA(γ) := γA,

F,G : A → Set, γ : F → G. Prove that evA is a functor. 4. Prove the equalities (1). 5. For a category A, consider the quasicategory Fun(A, Set). Prove that a morphism α of Fun(A, Set) (i.e. a natural transformation) is a monomorphism if and only if each component αA, A ∈ A0, is a monomorphism in Set (i.e. an injective mapping). (Hint: use the Yoneda Lemma.) 6. Prove the interchange law for compositions ∗ and ◦, i.e. that the equality

(δ ∗ γ) ◦ (β ∗ α) = (δ ◦ β) ∗ (γ ◦ α)

holds whenever all composites on both sides are defined.

23 5 Limits and colimits 5.1 Products and coproducts If A and B are sets then their is

A × B = {(a, b) | a ∈ A, b ∈ B}.

It is equipped with two canonical projections

pA : A × B → A, (a, b) 7→ a, pB : A × B → B, (a, b) 7→ b.

Moreover if Q is a set and f : Q → A, g : Q → B are arbitrary mappings then there is a unique mapping

m : Q → A × B, q 7→ (f(q), g(q)), which makes the following diagram commutative:

Q ?  ?? f  ?? g  m ??  ??  ?    ? AAAo A × BBB / B pA pB

This motivates the following definition.

Definition 5.1 A product of objects A, B ∈ C0 is a triple (P, pA, pB) where P ∈ C0 and pA : P → A, pB : P → B are morphisms in C (called projections) with the property that if Q ∈ C0 is any other object and f : Q → A, g : Q → B are morphisms, then there exists a unique morphism m : Q → P such that the diagram Q ?  ?? f  ?? g  m ??  ??  ?    ? AAPo PBP / B pA pB commutes.

Usually, A × B is written instead of P . The property of existing the unique m is often called the of products. Instead of m, hf, gi is sometimes written. By dualizing the definition of product we obtain the notion of which generalizes the con- struction of of sets.

Definition 5.2 A coproduct (or sum) of objects A, B ∈ C0 is a triple (P, uA, uB) where P ∈ C0 and uA : A → P , uB : B → P are morphisms in C (called injections) with the property that if Q ∈ C0 is any other object and f : A → Q, g : B → Q are morphisms, then there exists a unique morphism m : P → Q such that the diagram Q ? O _?  ?? f  ?? g  m ??  ??  ?  ? APA / PBP o B uA uB commutes.

Usually, A ` B is written instead of P . Definitions of products and coproducts can be generalized to any number of objects.

Definition 5.3 Let I be a set and (Ci)i∈I a family of objects in a category C.A product of that family is a pair (P, (pi)i∈I ) with the following properties:

24 1. P is an object of C;

2. for every i ∈ I, pi : P → Ci is a morphism in C, called the of P on Ci;

3. for each pair (Q, (qi)i∈I ) (where Q ∈ C0 and qi : Q → Ci for every i ∈ I) there exists a unique morphism m : Q → P such that the triangle

Q ? ?? ?? qi m ?? ?? ?  ? PCP / C pi i

commutes for every i ∈ I. Q Usually, i∈I Ci is written instead of P .

Definition 5.4 Let I be a set and (Ci)i∈I a family of objects in a category C.A coproduct of that family is a pair (P, (ui)i∈I ) with the following properties: 1. P is an object of C;

2. for every i ∈ I, ui : Ci → P is a morphism in C, called the injection of Ci into P ;

3. for each pair (Q, (qi)i∈I ) (where Q ∈ C0 and qi : Ci → Q for every i ∈ I) there exists a unique morphism m : P → Q such that the triangle

Q O _? ?? ?? qi m ?? ?? ?? PCP o C ui i

commutes for every i ∈ I. ` Usually, i∈I Ci is written instead of P . Let us prove some properties of products.

Proposition 5.5 If (P, (pi)i∈I ) is a product of (Ci)i∈I and h, k : C → P are morphisms with the property that for each i ∈ I, pih = pik, then h = k.

Proof. Both h and k make all triangles

C ? ?? ?? pih h k ?? ?? ??   pi PPC/ Ci commutative, hence they must be equal by Definition 5.3. The claim of Proposition 5.5 can also be expressed by saying that “projections of products are simul- taneously left cancellable”.

0 0 0 Proposition 5.6 If both (P, (pi)i∈I ) and (P , (pi)i∈I ) are products of (Ci)i∈I then P and P are isomor- phic.

25 0 Proof. Since P and P are products of Ci, i ∈ I, there exist ϕ and ψ making the triangles

P 0 ?? ? p0 ?? i ϕ ?? ?? ??  pi PCP / C i ? p0  i  ψ      P 0 commutative for every i ∈ I. Now

0 0 pi = piϕ = piψϕ, 0 pi = piψ = piϕψ,

∼ 0 for every i ∈ I imply ψϕ = 1P 0 and ϕψ = 1P by Proposition 5.5. Hence P = P . Of course, the dual statements are true for coproducts. We say that a category C has (co)products if every family (Ci)i∈I of objects of C has a (co)product. We say that C has finite (co)products if every finite family of objects has a (co)product.

Proposition 5.7 If a category C has binary products (of all pairs of objects) then it has ternary products. Moreover, for every A, B, C ∈ C0,

(A × B) × C =∼ A × (B × C), A × B =∼ B × A, and if C has a terminal object 1 then

A × 1 =∼ A, 1 × A =∼ A.

Proof. For A, B, C ∈ C0 let (A×B, pA, pB) be the product of A and B, and let ((A×B)×C, pA×B, pC ) be the product of A × B and C. (A × B) × C pA×B ?  ??  ? pC A × B ?? pA ? pB ??  ?? ?   ? ? A B C

We claim that ((A × B) × C, pApA×B, pBpA×B, pC ) is the product of A, B and C in the sense of Def- inition 5.3. To verify the universal property, suppose that for some object D there exist morphisms f : D → A, g : D → B and h : D → C. We must prove that there exists a unique morphism m : D → (A × B) × C such that

1. pApA×Bm = f,

2. pBpA×Bm = g,

3. pC m = h. First we can find a unique morphism n : D → A × B such that the diagram

D ?  ?? f  ?? g  n ??  ??  ?    ? AAAo A × BBB / B (4) pA pB

26 commutes. This in turn induces a unique morphism m : D → (A × B) × C such that

D ?  ?? n  ? h  m ??  ??  ??    ? A × B o (A×B)×CCC / C (5) pA×B pC is commutative. Hence pApA×Bm = pAn = f, pBpA×Bm = pBn = g and pC m = h. 0 0 0 0 If m : D → (A×B)×C is another morphism such that pApA×Bm = f, pBpA×Bm = g and pC m = h 0 0 then by the uniqueness of n in (4), n = pA×Bm . Therefore also m = m because m in (5) is unique. Similarly one can prove that also A×(B×C) is a ternary product of A, B and C. Hence (A×B)×C =∼ A × (B × C) by Proposition 5.6. It is also easy to prove that A × B =∼ B × A. Suppose now that C has a terminal object 1 and for every C ∈ C0 let tC be the unique morphism C → 1. We shall show that (A, 1A, tA) is a product of A and 1. Indeed, in the diagram Q ?  ?? q  ? tQ  q ??  ??  ??    ? AAAo A / 1 1A tA the vertical q is the unique morphism that makes both triangles commute. A generalization of this proof shows that if a category has binary products then it has products of n objects for every n ≥ 2. It is also easy to see that a product of the empty family of objects is a terminal object and (A, 1A) is a product of a family consisting of a single object A. Hence the following result holds. Proposition 5.8 If a category has binary products and a terminal object then it has all finite products. Proposition 5.9 Let C be a category with finite products and an initial object 0. The following assertions are equivalent. ∼ 1. For every A ∈ C0, if there is a morphism f : A → 0 then A = 0. ∼ 2. For every object A ∈ C0, A × 0 = 0.

Proof. For every C ∈ C0 denote the unique morphism 0 → C by iC . ∼ If 1 holds then p0 : A × 0 → 0 implies A × 0 = 0. ∼ Conversely, suppose that A × 0 = 0 and f : A → 0 for an object A ∈ C0. Then also 0 is a product of A and 0, and the projections must be iA and 10 = i0. Hence the diagram A  ??  ? 1A  ?? f  f ??  ??  ?    ? A o 0/ 0 iA 10 must commute. In particular, f is a split monomorphism. Since its codomain is an initial object, it is also an epimorphism. Hence f is an isomorphism. If an initial object 0 of a category C has the property mentioned in Proposition 5.9(1) then it is called a strict initial object. In a poset (considered as a category), the smallest element (if it exists) is a strict initial object. In Mon, the one-element monoid {1} is initial but not strictly initial, because S × {1} =∼ S. Let us list some examples of products.

Example 5.10 In the category Set, the product of a family (Ci)i∈I is the cartesian product Y Ci = {(xi)i∈I | xi ∈ Ci} i∈I with projections pk ((xi)i∈I ) = xk, k ∈ I.

27 Example 5.11 Binary products of objects of the quasicategory CAT are defined in Definition 1.12. The projecions are defined by

PA : A × B → A, (A, B) 7→ A, (a, b) 7→ a, PB : A × B → B, (A, B) 7→ B, (a, b) 7→ b, which obviously will be functors. Similarly the product of an arbitrary small family of categories can be defined.

Example 5.12 In the categories of algebraic structures (e.g. groups, abelian groups, rings, modules, vector spaces, boolean algebras etc.) the product of a family of objects is their cartesian product equipped Q with pointwise operations. For example if Ci, i ∈ I, are abelian groups then Ci = {(xi)i∈I | xi ∈ Ci} Q i∈I and addition on i∈I Ci is defined by

(xi)i∈I + (yi)i∈I := (xi + yi)i∈I .

Example 5.13 In the category Ban1, the product of a family (Ci)i∈I is given by Q i∈I Ci = {(xi)i∈I | xi ∈ Ci, supi∈I ||xi|| ≤ ∞}, ||(xi)i∈I || := supi∈I ||xi|| Q and pointwise operations. The projections pk : i∈I Ci → Ck are linear contractions because, for every k ∈ I, ||pk ((xi)i∈I ) || = ||xk|| ≤ supi∈I ||xi|| = ||(xi)i∈I ||. Let qi : Q → Ci, i ∈ I, be also a family of linear contractions and consider an element x ∈ Q. Then ||qi(x)|| ≤ ||x|| for every i ∈ I. Hence Q Q supi∈I ||qi(x)|| ≤ ||x|| and we can define a mapping m : Q → i∈I Ci by m(x) := (qi(x))i∈I ∈ i∈I Ci which is unique and a linear contraction. Q Example 5.14 In the category Top, the product of a family (Xi, τi)i∈I is (X, τ), where X = i∈I Xi is just the cartesian product. For τ, we choose as basic open subsets the subsets of the form Y Ui = {(xi)i∈I | xi ∈ Ui} ⊆ X i∈I where Ui ∈ τi for every i ∈ I and the set {i ∈ I | Ui 6= Xi} is finite. The topology τ consists of all unions of basic open subsets. The projections pk : X → Xk,(xi)i∈I 7→ xk, are continuous because if U ∈ τk then

−1 Y pk (U) = Vi i∈I where Vk = U and Vi = Xi for every i ∈ I \{k}. To check the universal property, let

qi :(Y, σ) → (Xi, τi), i ∈ I, be a family of continuous mappings. We have to show that the mapping

m : Y → X, y 7→ (qi(y))i∈I Q is continuous. If i∈I Ui ∈ τ is a basic open subset then ! −1 Y \ −1 m Ui = {y ∈ Y | (∀i ∈ I)(qi(y) ∈ Ui)} = qi (Ui). (6) i∈I i∈I

−1 −1 For every i ∈ I, qi (Ui) ∈ σ, since qi is continuous and Ui ∈ τi. Moreover, if Ui = Xi then qi (Ui) = Y and this term does not play any role in the intersection (6). Hence ! −1 Y [ −1 m Ui = q (Ui)

i∈I i∈I,Ui6=Xi which is a finite intersection of open subset of Y and hence an open subset.

28 Example 5.15 If we consider a poset (P, ≤) as a category (see 1.7) then products (if they exist) are precisely the greatest lower bounds.

Example 5.16 To allow operations depending on several variables in a functional programming language L (as considered in subsection 1.3), it is reasonable to assume that for any types A and B the language has a record type P with two field selectors P.A : P → A and P.B : P → B which satisfies the universal property. For example a record type person could have fields name and age. Thus having the record type constructor in a language L would mean that the corresponding category C(L) has all finite products.

Consider some examples of coproducts.

Example 5.17 In the category Set, the coproduct of a family (Ci)i∈I is its disjoint union. A convenient way to construct it is to set a [ Ci := (Ci × {i}) = {(x, i) | i ∈ I, x ∈ Ci}. i∈I i∈I ` The injections ui : Ci → i∈I Ci are defined by ui(x) := (x, i), x ∈ Ci. Example 5.18 In the quasicategory CAT, the coproduct of family of categories just their disjoint union.

Example 5.19 In the category Ab, the coproduct of a family (Ai)i∈I is their a Y Ai := {(xi)i∈I | xi ∈ Ai, {i ∈ I | xi 6= 0} is finite } ≤ Ai, i∈I i∈I ` where addition is componentwise. The injections uk : Ak → i∈I Ai are defined by uk(x) := (xi)i∈I where xk = x and the other components are all zeros. If B is another abelian group and qi : Ai → B, ` i ∈ I, is a family of group homomorphisms then the unique mapping m : Ai → B is defined by P i∈I m((xi)i∈I ) := i∈I qi(xi) where the last sum is actually the sum of (finitely many) nonzero elements.

Example 5.20 In the category Gr, the coproduct of a family (Gi)i∈I is constructed as follows. Let V ∗ be the disjoint union of the sets Gi and let V be the with the basis V , i.e. the set of all finite sequences (“words”) of elements of V together with the concatenation operation. Consider on V ∗ the σ generated by the following rules:

• the unit element of every group Gi is equivalent to the empty sequence,

• a sequence containing two consequtive elements belonging to the same Gi is equivalent to the sequence obtained from it by replacing these two elements by their product in Gi. This σ will be a congruence and the quotient monoid

a ∗ Gi := V /σ i∈I

−1 −1 −1 will be a group where [v1 . . . vn]σ = [vn . . . v1 ]σ, v1, . . . , vn ∈ V . The mappings a ui : Gi → Gi, x 7→ [x]σ, i∈I ` are group homomorphisms and it can be shown that Gi is indeed the coproduct of groups Gi, i ∈ I. ` i∈I In , i∈I is usually called the of groups Gi, i ∈ I.

Example 5.21 In the category Top, the coproduct of a family (Xi, τi)i∈I is (X, τ) where X is the disjoint union of the sets Xi and τ is the topology on X generated by the disjoint union of τi.

Example 5.22 If we consider a poset (P, ≤) as a category (see 1.7) then coproducts (if they exist) are precisely the least upper bounds.

29 5.2 Equalizers and coequalizers Definition 5.23 Let f, g : A → B be morphisms in a category C. An equalizer of f and g is a pair (E, e) with the following properties: 1. e : E → A is a morphism in C; 2. fe = ge; 3. for any other morphism e0 : E0 → A in C such that fe0 = ge0, there exists a unique morphism k : E0 → E such that ek = e0.

f e EEA/ AAB/ \: B g / : Ô ÔÔ 0 k : ÔÔ e E0

Definition 5.24 Let f, g : A → B be morphisms in a category C.A of f and g is a pair (C, c) with the following properties: 1. c : B → C is a morphism in C; 2. cf = cg; 3. for any other morphism c0 : B → C0 in C such that c0f = c0g, there exists a unique morphism k : C → C0 such that kc = c0.

f c AB/ BBC/ C g / : :: Ô 0 : Ô c : ÔÒ k C0

Proposition 5.25 Equalizer of two morphisms, if it exists, is unique up to isomorphism.

Proof. Suppose that both (E, e) and (E0, e0) are equalizers of f, g : A → B. Then there exist k : E0 → E and l : E → E0 such that ek = e0 and e0l = e.

f e / EAE : / AAB/ \: :l e0 ÔB g : : ÔÔ k :  ÔÔ E0

Now both 1E and kl make the triangle e EAE / A \: B \::::kl e Ô :::: ÔÔ 1E : ÔÔ E ∼ 0 commutative and therefore have to be equal. Similarly lk = 1E0 , which proves that E = E .

Proposition 5.26 If (E, e) is an equalizer of f, g : A → B in a category C then e is a monomorphism.

Proof. Suppose that ek = el for k, l : E0 → E. Then k = l because there is exactly one morphism making the triangle below commutative.

f e / EEA/ AAB/ \:\:: k B g : :: ÔÔ :: : Ôek l : ÔÔ E0

30 Example 5.27 In most concrete categories (Set, Top, Gr, Ab, Ban1, ...) an equalizer of two morphisms f, g : A → B is given by E = {a ∈ A | f(a) = g(a)}, (7) provided with the structure induced by the structure of A, and the inclusion mapping e : E → A. For instance, in Set an equalizer of the mappings f, g : R × R → R, f(x, y) = x2 + y2, g(x, y) = 1, is the circle {(x, y) ∈ R2 | x2 + y2 = 1}. In Ab, an equalizer of f, g : A → B, defined by (7), is the of the difference homomorphism f − g : A → B.

Example 5.28 In the category of all nonempty sets (or nonempty semigroups) there exist parallel mor- phisms which do not have an equalizer.

Example 5.29 In the category Set, a coequalizer of mappings f, g : A → B is the quotient B/σ where σ is the equivalence relation generated by the set of pairs {(f(a), g(a)) | a ∈ A}.

Example 5.30 In the category Ab, a coequalizer of a homomorphism f : A → B and the zero homo- morphism is the natural surjection π : B → B/f(A) on the quotient group B/f(A). More generally, a coequalizer of homomorphisms f, g : A → B is a coequalizer of f − g : A → B and the zero homomor- phism, that is, the natural surjection B → B/(f − g)(A). Descriptions of coequalizers in VecR and ModR are analogous.

Example 5.31 In many categories of algebraic structures (e.g. groups, rings) the situation is more complicated. The general procedure for constructing a coequalizer of homomorphisms f, g : A → B is to factor B by the congruence generated by the set {(f(a), g(a)) | a ∈ A}.

Example 5.32 If f, g :(X, τ) → (Y, θ) are continuous mappings in the category Top then their coequal- izer is (Y/σ, θ0) where σ is the equivalence relation generated by the set {(f(x), g(x)) | x ∈ X} and θ0 is the quotient topology, i.e. θ0 = {V ⊆ Y/σ | π−1(V ) ∈ θ} where π : Y → Y/σ is the natural surjection.

One way of thinking about an equalizer is as the largest on which an equation or a set of equations is true. A coequalizer is the least identification necessary to force an equation to be true on the equivalence classes. The following example illustrates this.

Example 5.33 There are two ways to define the rational numbers. In the first construction we identify a c b with d if and only if a · d = b · c. This can be described as a coequalizer

f π T / × / ( × )/σ = g / Z N Z N Q where T = {(a, b, c, d) ∈ Z × N × Z × N | ad = bc}, f(a, b, c, d) = (a, b), g(a, b, c, d) = (c, d), σ is constructed canonically as in Example 5.29 and we denote a b := [(a, b)]σ. The second way is to define that rational numbers are pairs (a, b) ∈ Z × N where a and b are relatively prime. The set of such pairs is an equalizer

gcd e Q = {(a, b) ∈ Z × N | gcd(a, b) = 1} / Z × N / N const1 where e is the inclusion and const1 is the constant mapping on 1.

31 5.3 Pullbacks and pushouts Definition 5.34 Let f : A → C and g : B → C be two morphisms in a category C.A pullback of f and g is a triple (P, p1, p2) with the following properties:

1. p1 : P → A and p2 : P → B are morphisms in C;

2. fp1 = gp2;

3. for any other morphisms q1 : Q → A and q2 : Q → B in C such that fq1 = gq2, there exists a unique morphism m : Q → P such that p1m = q1 and p2m = q2.

Q O /?OOO // ? OOO / ? OOOq2 / m? OOO // ? OO / ? OOO // p2 OO' q1 / PPB/ B // // //p1 g // /   AAC/ C f The square in the previous diagram is called a pullback square.

The dual notion of “pullback” is “pushout”.

Definition 5.35 Let I be a set and fi : Ai → C, i ∈ I, a family of morphisms in a category C.A multiple pullback of morphisms fi is a pair (P, (pi)i∈I ) with the following properties:

1. pi : P → Ai is a morphism in C for each i ∈ I;

2. there is a morphism u : P → C such that fipi = u for each i ∈ I;

3. if qi : Q → Ai, i ∈ I, and v : Q → C are morphisms in C such that fiqi = v for each i ∈ I then there exists a unique morphism m : Q → P in C such that pim = qi for each i ∈ I.

Q '', ;; ' , ;; ' m;; '' , ; ' ;; v qi ' , ; '  ;; ' P L ; '' LL ;; ' pi LL ; ' u LLL;;   L% Ai / C fi

Example 5.36 In Set, a pullback of mappings f : A → C and g : B → C is (P, p1, p2) where

P = {(a, b) | a ∈ A, b ∈ B, f(a) = g(b)} ⊆ A × B and p1(a, b) = a, p2(a, b) = b for every (a, b) ∈ P . If A and B are subsets of C and f, g inclusions then P is isomorphic to the intersection A ∩ B. A similar construction of pullbacks works in many categories (e.g. Gr, ModR, Rng, Top) if P is equipped with the structure induced by the structure of the product A × B.

Definition 5.37 A pullback of a morphism f with itself is called a kernel pair of f.

Example 5.38 From Example 5.36 it follows that the kernel of a morphism f in Set is a kernel pair of f. The same holds in the category Mon of all monoids.

32 5.4 Limits and colimits It turns out that all the constructions considered in this section are special cases of a more general construction. From this point on to the of this section D will always stand for a small category and I = D0 for its set of objects.

Definition 5.39 Let F : D → C be a functor. A cone on F is a pair (C, (pi)i∈I ) with the following properties:

1. C ∈ C0;

2. for every object i ∈ I, pi : C → F (i);

3. for every morphism d : i → j in D, pj = F (d)pi.

Alternatively, a pair (C, (pi)i∈I ) is a cone on F if and only if p = (pi)i∈I : ∆C ⇒ F , where ∆C : D → C is the constant functor on C (see Example 3.3(3)). That is, cones on F are natural transformations from constant functors to F .

Definition 5.40 Let F : D → C be a functor and (B, (qi)i∈I ), (C, (pi)i∈I ) two cones on F . A morphism f : B → C of C is called a morphism from cone (B, (qi)i∈I ) to cone (C, (pi)i∈I ) if pif = qi for every i ∈ I.

B Ø 66 ØØ 66 ØØ f 66 qi Ø 6 qj ØØ  66 ØØ C 66 Ø pi oo OOO pj 6 ØØ oo OO 66 ØÔ wooo OO'  F (i) / F (j) F (d)

Proposition 5.41 For a fixed functor F : D → C, the cones on F and their morphisms form a category.

Proof. The morphisms in this new category will be composed as in category C.

A -  --  g --  --   -  B --  6 - ri  Ø 6 - rj  ØØ 66 --  ØØ f 66 -  Ø 6 --  Øqi qj 6 -  ØØ  66 -  Ø C O 6 --  ØØ oo OOO 66- Ø opo p O 6- ØØÔ wooo i j OO'   F (i) / F (j) F (d)

Suppose that f :(B, (qi)) → (C, (pi)) and g :(A, (ri)) → (B, (qi)) are two morphisms of cones on F . Then pi(fg) = (pif)g = qig = ri and hence indeed fg :(A, (ri)) → (C, (pi)) is a morphism of cones. The identity morphism of a cone (C, (pi)) will, of course, be 1C . The associativity of composition follows from the corresponding property of C. The category constructed in Proposition 5.41 is denoted by cone(F ) and called the category of cones on F .

Definition 5.42 A limit of a functor F : D → C is a terminal object of the category cone(F ) of cones on F . Thus a cone (L, (pi)i∈I ) on F is a limit of F if for every cone (Q, (qi)I∈I ) on F , there exists a unique morphism m : Q → L such that for every object i ∈ I, qi = pim. One often writes (L, (pi)i∈I ) = lim F or even L = lim F .

33 Q Ø 66 Ø 66 ØØ m 6 q Ø 6 q i ØØ 66 j ØØ  66 Ø L p 6 Ø pi oo OOO j 6 ØØ oo OO 66 ØÔ ow oo OO'  F (i) / F (j) F (d)

Definition 5.43 Let F : D → C be a functor. A cocone on F is a pair (C, (ui)i∈I ) with the following properties:

1. C ∈ C0;

2. for every object i ∈ I, ui : F (i) → C;

3. for every morphism d : j → i in D, uj = uiF (d).

Dually to the case of cones, one can define the category cocone(F ) of cocones on a functor F .

Definition 5.44 A colimit of a functor F : D → C is an initial object of the category cocone(F ) of cocones on F . Thus a cocone (L, (ui)i∈I ) on F is a colimit of F if for every cone (Q, (vi)i∈I ) on F , there exists a unique morphism m : L → Q such that for every object i ∈ I, vi = mui. One often writes (L, (ui)i∈I ) = colimF

Q ØD O 6Z 6 Ø 66 ØØ m 6 v Ø 6 vj i ØØ 66 ØØ 66 Ø L u 6 Ø ui oo7 Og OO j 6 Ø oo OO 66 ØØooo OO F (i) o F (j) F (d)

Examples 5.45 1. Consider a discrete category D with two objects, D0 = {1, 2} (see Example 1.7(3)). A functor F : D → C is determined by a pair (F (1),F (2)) of objects of C. A cone on F is a diagram

p1 p2 F (1) o P / F (2)

and a cocone on F is a diagram u u F (1) 1 / P o 2 F (2).

Hence (P, p1, p2) is a limit of F if and only if it is a product of F (1) and F (2) and (P, u1, u2) is a colimit of F if and only if it is a coproduct of F (1) and F (2). 2. Let D = 0 be the empty category. Then a cone or a cocone on a functor F : D → C is just an object of C. Hence C is a limit (colimit) of F if and only if it is a terminal (resp. initial) object of C.

3. If I is a set and D is a discrete category with D0 = I then a functor F : D → C is determined by a family (F (i))i∈I of objects of C. A cone on F is a pair (C, (pi)i∈I ) where pi : C → F (i). This cone is a limit of F if and only if it is a product of the family (F (i))i∈I . Dually a colimit of F is a coproduct of (F (i))i∈I .

4. Consider a category D with D0 = {1, 0} and two nonidentity morphisms d1, d2 : 1 → 0. A functor F : D → C is determined by a pair f1, f2 : F (1) → F (0) of parallel arrows in C. A cone on F is a e0

f1 % EF/ F (1) / F (0) e1 / f2

34 and a cocone on F is a diagram

c1

f1 $ F (1) / F (0) / C / c0 f2

Hence (E, e0, e1) is a limit of F if and only if (E, e1) is an equalizer of f1 and f2 and (C, c0, c1) is a limit of F if and only if (C, c0) is a coequalizer of f1 and f2.

5. Consider a category D with D0 = {0, 1, 2} and two nonidentity morphisms d1 : 1 → 0 and d2 : 2 → 0. A functor F : D → C is determined by a pair f1 : F (1) → F (0), f2 : F (2) → F (0) of morphisms of C. A cone on F is a commutative diagram

p2 PPF/ F (2) OOO OOO OO p0 p1 OO OOO f2 OOO  OO'  F (1) / F (0) . f1

Hence (P, p0, p1, p2) is a limit of F if and only if (P, p1, p2) is a pullback of f1 and f2.

6. Let D be a category with D0 = J t {0} and nonidentity morphisms dj : j → 0, j ∈ J. A functor F : D → C is determined by a family fj : F (j) → F (0) of morphisms of C. A cone on F is a commutatve diagram P ? ?? ?? p0 pj ? ?? ??  ? F (j) / F (0) . fj

Hence (P, (pi)i∈Jt{0}) is a limit of F if and only if (P, (pj)j∈J ) is a multiple pullback of fj, j ∈ J. The following table summarizes the previous example. For the sake of completeness we have included here also multiple equalizers, coequalizers and pushouts, although we have not given their explicit defini- tions because we shall not need these constructions in what follows. We believe that an interested reader can work out the details if needed. Object set of D Nonidentity C has D-limits means that C C has Dop-colimits means morphisms of D ... that C ... none none has a terminal object has an initial object {1, 2} none has binary products has binary coproducts / {0, 1} d1, d2 : 1 / 0 has equalizers has coequalizers {0, 1, 2} d1 : 1 → 0, d2 : has pullbacks has pushouts 2 → 0 Object set of D Nonidentity C has D-limits for all cate- C has Dop-colimits for all morphisms of D gories D of this form means categories D of this form that C ... means that C ... I set none has products has coproducts {1, 2} di : 1 → 2, i ∈ I has multiple equalizers multiple coequalizers J t {0}, J set dj : j → 0, j ∈ J has multiple pullbacks has multiple pushouts It turns out that all limits (but also colimits) exist in Set and can be constructed in a canonical way.

Theorem 5.46 Let F : D → Set be a functor and Y L = {(xi)i∈I | xi ∈ F (i), (∀d : i → j in D)(F (d)(xi) = xj)} ⊆ F (i). i∈I

Then (L, (pi)i∈I ), where pi : L → F (i), i ∈ I, are the restrictions of the projections of the cartesian Q product i∈I F (i), is a limit of F .

35 Proof. Obviously (L, (pi)i∈I ) is a cone on F . If (Q, (qi)i∈I ) is another cone on F then the required unique mapping m : Q → L is for x ∈ Q defined by

m(x) := (qi(x))i∈I .

Limits in many other concrete categories may be constructed in a similar way. For example if F : Q D → Gr then L is a subset of the i∈I F (i) of groups F (i), which is a group with respect to componentwise operations. Since every F (d) is a homomorphism of groups,

F (d)(xiyi) = F (d)(xi) · F (d)(yi) = xjyj, −1 −1 −1 F (d)(xi ) = (F (d)(xi)) = xj , Q and hence L is a subgroup of i∈I F (i). Clearly the mappings pi are group homomorphisms and also m is a if all qi’s are.

5.5 Complete categories Definition 5.47 A category C is 1. D-complete (or has D-limits), where D is a category, if every functor D : D → C has a limit; 2. finitely complete (or has finite limits) if C is D-complete for every finite category D; 3. complete (or has limits) if C is D-complete for every small category D. Theorem 5.48 For every category C, the following assertions are equivalent: 1. C is complete. 2. C has multiple pullbacks and a terminal object. 3. C has products and pullbacks. 4. C has products and equalizers. Proof. 1 ⇒ 2 is obvious. 2 ⇒ 3. Let 1 be a terminal object of C and let us show that the product of objects Ai, i ∈ I, of C exists, where I is a set. For every i ∈ I, there is a unique morphism fi : Ai → 1. Let (P, (pi)i∈I ) be the multiple pullback of fi, i ∈ I. P ? ?? ?? u pi ? ?? ??  ? Ai / 1 fi

It easily follows from the terminality of 1 that then (P, (pi)i∈I ) is also a product of Ai, i ∈ I. 3 ⇒ 4. We have to prove that an equalizer of a pair f, g : A → B exists. By the universal property of products we obtain unique morphisms h1A, fi, h1A, gi such that the diagrams

A A ? ?  ??  ?? 1A  ?? f 1A  ?? g  h1A,fi ??  h1A,gi ??  ??  ??  ?  ?    ?    ? AAAo A × BBB / B AAAo A × BBB / B pA pB pA pB commute. Construct a pullback l PPA/ A

k h1A,gi

  AAA/ A × B h1A,fi

36 of h1A, fi and h1A, gi, and observe that

k = 1Ak = pAh1A, fik = pAh1A, gil = 1Al = l, fk = pBh1A, fik = pBh1A, gil = gl = gk.

f k PAP / AAB/ \: B g / : Ô m ÔÔ 0 : ÔÔ k P 0 If there is another k0 : P 0 → A such that fk0 = gk0 then also

0 0 0 pAh1A, fik = k = pAh1A, gik 0 0 pBh1A, fik = pBh1A, gik ,

0 0 which by Proposition 5.5 imply h1A, fik = h1A, gik . Since P is a pullback, there is a unique morphism m : P 0 → P such that km = k0 = lm. 4 ⇒ 1. Consider a small category D and a functor F : D → C. First we construct the products ! ! Y Y F (i), (si)i∈I and F (cod(d)), (rd)d∈D . i∈I d∈D

By the universal property of the second product, there exist a unique morphism α such that rdα = scod(d) = sj for every d : i → j ∈ D and a unique morphism β such that rdβ = F (d)sdom(d) = F (d)si for every d : i → j ∈ D. Let (L, l) be the equalizer of the pair (α, β), so in particular αl = βl. We define pi := sil and we shall prove that (L, (pi)i∈I ) is the limit of the functor F .

QQF/ F (i) F (cod(d)) ? qi ?? O ? O ??  ??  ??  ?  ?? q scod(d)  0 ? s  r m m ?? i  d ??  ??  ??  ??  ??  α   l  / L / Q F (i) Q F (cod(d)) i∈I / d∈D  β     p si  i  sdom(d) rd           F (i) F (dom(d)) / F (cod(d)) F (d)

For every morphism d : i → j in D we have

F (d)pi = F (d)sil = rdβl = rdαl = sjl = pj, which means that (L, (pi)i∈I ) is a cone on F . Suppose that (Q, (qi)i∈I ) is another cone on F . By the Q universal property of product i∈I F (i), there is a unique morphism q such that siq = qi for every i ∈ I. Now, for every d : i → j in D,

rdαq = sjq = qj = F (d)qi = F (d)siq = rdβq.

By Proposition 5.5 we obtain αq = βq. This implies, by the universal property of equalizer (L, l), the existence of a unique m : Q → L such that lm = q. Consequently

pim = silm = siq = qi

37 for every i ∈ I. It remains to prove that m is unique. Suppose that m0 : Q → L is another morphism 0 such that pim = qi for every i ∈ I. Then

0 0 silm = siq = qi = pim = silm for every i ∈ I, which again by Proposition 5.5 implies lm = lm0. This implies m = m0 by Proposition 5.26, because l is an equalizer. Similarly one can prove the followig result.

Theorem 5.49 For every category C, the following assertions are equivalent: 1. C is finitely complete. 2. C has pullbacks and a terminal object. 3. C has finite products and pullbacks. 4. C has finite products and equalizers.

Examples 5.50 1. The category of finite sets and the category of finite topological spaces are both finitely complete and finitely cocomplete but neither of them is complete or cocomplete. 2. The category of finite groups is finitely complete but not finitely cocomplete. 3. The categories Set, Gr, Ab and Top are complete and cocomplete. 4. A poset considered as a category is complete as a category precisely when it is complete as a poset.

5.6 Limit preserving functors

Definition 5.51 Let D be a small category and denote again I = D0. A functor G : A → B

1. preserves D-limits if for every functor F : D → A, if (L, (pi)i∈I ) is a limit of F then (G(L), (G(pi))i∈I ) is a limit of GF : D → B;

2. reflects D-limits if for every functor F : D → A, if (L, (pi)i∈I ) is a cone on F in A and (G(L), (G(pi))i∈I ) is a limit of GF : D → B, then (L, (pi)i∈I ) is a limit of F .

Definition 5.52 A functor G : A → B 1. preserves limits (resp. preserves finite limits) if G preserves D-limits for every small category (resp. finite category) D; 2. reflects limits (resp. reflects finite limits) if G reflects D-limits for every small category (resp. finite category) D.

Examples 5.53 1. The forgetful functors from Gr, ModR, Rng to Set preserve and reflect limits but none of them preserves or reflects arbitrary colimits. 2. The forgetful functor from Top to Set preserves limits and colimits but does not reflect either.

3. If A has finite products and A ∈ A0 is a fixed object then the functor (A × −): A → A preserves limits.

Using the proofs of Theorem 5.48 and Theorem 5.49, one can prove the following results.

Theorem 5.54 If A is a finitley complete category and F : A → B is a functor then the following assertions are equivalent: 1. G preserves finite limits. 2. G preserves pullbacks and terminal objects. 3. G preserves finite products and pullbacks. 4. G preserves finite products and equalizers.

38 Theorem 5.55 If A is a complete category and G : A → B is a functor then the following assertions are equivalent: 1. G preserves limits. 2. G preserves multiple pullbacks and terminal objects. 3. G preserves products and pullbacks. 4. G preserves products and equalizers.

Proposition 5.56 Consider a category A and an object A ∈ A0. The covariant representable functor A(A, −): A → Set preserves all existing limits, including large ones.

Proof. Consider an arbitrary functor F : D → A and its limit (L, (pi)i∈I ), where I = D0. Then of course (A(A, L), (pi ◦ −)i∈I ) is a cone on the composite functor A(A, F (−)) = A(A, −) ◦ F in Set. Let (qi : M → A(A, F (i)))i∈I be another cone on the functor A(A, F (−)). That is, for every d : i → j in D,

qj = A(A, F (d)) ◦ qi = (F (d) ◦ −) ◦ qi, so for every element m ∈ M, qj(m) = F (d) ◦ qi(m). The last means that (A, (qi(m))i∈I ) is a cone on F . Hence there exists a unique morphism q(m): A → L such that pi ◦ q(m) = qi(m) for every i ∈ I.

A M 66 66 ØØ 6 ØØ 6 Ø 6 Ø q 6 ØØ q(m6)6 ØØ 66 qi(m) Ø 6 qj (m) qi Ø 6 qj ØØ  66 ØØ  66 Ø L 6 Ø A(A, L) 6 Øp O pj 6 Ø 6 Ø i oo OO 6 piØ◦− O pj ◦−6 ØØ oo OO 66 ØØ oo OOO 66 ØÔ ow oo OO'  ØÔ wooo O'  F (i) / F (j) A(A, F (i)) / A(A, F (j)) F (d) F (d)◦−

This defines a mapping q : M → A(A, L) in Set with the property that (pi ◦ −) ◦ q = qi for each i ∈ I. It remains to prove that q is unique. Suppose that also r : M → A(A, L) is such that (pi ◦ −)r = qi for each i ∈ I. Then pi ◦ r(m) = qi(m) for every m ∈ M and i ∈ I. Since L is a limit, q(m) = r(m) for every m ∈ M. Hence the mappings q and r are equal.

5.7 Exercises Exercises 5.57 1. Does your favourite category have (co)products, (co)equalizers or pullbacks? Is it (co)complete? 2. Let C be a category with finite products. Show that there is a functor − × − : C × C → C defined by assignments

(− × −)(A, B) := A × B, (− × −)(f, g) := f × g : A × B → A0 × B0,

where f : A → A0, g : B → B0 in C and f × g is the unique morphism which makes the diagram

pA pB A o A × BBA BB/ B f f×g f    A0 o A0 × B0 / B0 pA0 pB0

commute. (A functor from a product of two categories to a third category is usually called a bifunctor.) 3. Show that any nontrivial group considered as a one-object category does not have binary products. 4. Let (E, e) be an equlizer of f, g : A → B. Prove that e is an isomorphism if and only if f = g.

39 5. Give an example of a category C where there are two morphisms f, g : A → B, which do not have a coequalizer in C. (Hint: one can consider of Set.) 6. Formulate the definition of pushout as the dual of the definition of pullback. 7. Prove that the projections of kernel pairs are split epimorphisms. 8. Define the notion of a morphism of cones in terms of natural transformations. 9. Prove that Proposition 5.5 generalizes to arbitrary limits, i.e. projections of limits are simultane- ously left cancellable.

10. Using the previous exercise prove that if f is a monomorphism and (P, p1, p2) is a pullback of f and g then p2 is a monomorphism. 11. Prove directly that pullbacks can be (canonically) constructed using products and equalizers. In more detail, let f : A → C and g : B → C be two morphisms of C. Prove that if (A × B, pA, pB) is a product of A and B and if (E, e) is an equalizer of fpA and gpB then the outer square in the diagram pB e EEBJ /: B JJ tt JJ tt JJ tt e JJ ttp JJ tt B JJ tt J$ tt pAe A × B g t tt tt tt ttpA tt  tt  AACzt / C f is a pullback square. 12. Prove that if G : A → B and H : B → C preserve all limits then also HG : A → C preserves all limits.

13. For a category A and a fixed object A ∈ A0 give the definition of a functor (A × −): A → A analogously to exercise 2. Prove that if A is finitely complete then A × − preserves equalizers.

40 6 Adjunctions 6.1 Motivating examples

Consider the category VecK of all vector spaces over a field K with linear mappings as morphisms. The forgetful functor U : VecK → Set sends every vector space V to its set of elements. For any set X there is a vector space VX with X as a set of basis vectors; it consists of all formal finite K-linear combinations k1x1 + ... + knxn of the elements of X with the evident operations. Every mapping f : X → Y can in an obvious way be extended to a linear mapping VX → VY , so that a functor F : Set → VecK with F0(X) = VX , for every set X, results. For every set X and a vector space W there is a bijective mapping ϕ : Vec (F (X),W ) −→ Set(X,U(W )), X,W K (8) f 7→ f|X .

Its inverse ψX,W : Set(X,U(W )) −→ VecK (F (X),W ) extends every mapping g : X → U(W ) to a unique linear mapping fg : F (X) → W , which is explicitly given by

fg(k1x1 + ... + knxn) = k1g(x1) + ... + kng(xn) (9)

(so fg takes formal linear combinations in F (X) to actual linear combinations in W ). The mappings ϕX,W are the components of a natural transformation ϕ, if both sides of (8) are considered as functors of X and W . It suffices to verify naturality in X and W separately (see Exercise 6.12 (1)). Naturality in X means that for each morphism k : X0 → X the diagram

ϕX,W VecK (F (X),W ) / Set(X,U(W ))

−◦F (k) −◦k

 0 0  VecK (F (X ),W ) / Set(X ,U(W )) ϕX0,W is commutative. Indeed, for every linear mapping f : F (X) → W and every x ∈ X0,

[(− ◦ k) ◦ ϕX,W ](f)(x) = (ϕX,W (f) ◦ k)(x) = f|X (k(x)) = fk(x) = f(F (k)(x)) = (f ◦ F (k))|X0 (x)

= [ϕX0,W (f ◦ F (k))](x) = [ϕX0,W ◦ (− ◦ F (k))](f)(x). A similar calculation shows that ϕ is natural in W . Moreover, the mapping that sends every x ∈ X into the same x regarded as a vector of VX is a morphism ιX : X → U(VX ) = UF (X) in Set. For any other vector space W and a mapping g : X → U(W ), the linear mapping fg : VX → W is the unique linear mapping extending g, i.e. making the triangle

ιX XXU/ U(VX ) VX ? ?? ?? ?? U(fg ) fg g ?? ? ?   U(W ) W commutative. There are some other similar examples. There is a bijective mapping

ϕS,R : Set(S × T,R) −→ Set(S, Set(T,R)) given by [ϕS,R(f)(s)](t) := f(s, t) for every mapping f : S × T → R and elements s ∈ S, t ∈ T, r ∈ R. Such ϕ is natural in S and R (but also T ). If a set T is fixed and we define F,G : Set → Set by F := −×T and G := Set(T, −), this bijection takes the form

ϕS,R : Set(F (S),R) −→ Set(S, G(R)). For modules A, B over a R and an abelian group C there is a similar isomorphism

ϕB,C : Ab(A ⊗R B,C) −→ ModR(A, ModR(B,C)).

41 6.2 Adjoint functors Definition 6.1 Let A and B be categories. An adjunction from A to B is a triple hF, G, ϕi : A → B, where F : A → B and G : B → A are functors and ϕ is a mapping which assigns to each pair of objects A ∈ A0, B ∈ B0 a bijective mapping

ϕA,B : B(F (A),B) → A(A, G(B)) (10) which is natural in A and B. If hF, G, ϕi : A → B is an adjunction, we say that F is left adjoint for G and G is right adjoint for F , and write F a G.

The functor B(F (−), −) on the left hand side of (10) is the bifunctor

F ×1B hom Aop × B / Bop × B / Set which sends each pair of objects (A, B) to the morphism-set B(F (A),B), and a morphism (kop, h): (A, B) → (A0,B0) of the Aop × B to the mapping h ◦ − ◦ F (k): B(F (A),B) → B(F (A0),B0) in Set, and the right hand side is a similar bifunctor Aop × B → Set. Therefore the naturality of the bijection ϕ means that for all k : A0 → A and h : B → B0 both the diagrams

ϕA,B ϕA,B B(F (A),B) / A(A, G(B)) B(F (A),B) / A(A, G(B))

−◦F (k) −◦k h◦− G(h)◦−     B(F (A0),B) / A(A0,G(B)) B(F (A),B0) / A(A, G(B0)) ϕA0,B ϕA,B0 will commute (see Exercise 6.12 (1)). That is, for all k : A0 → A in A, h : B → B0 and f : F (A) → B,

ϕA0,B(fF (k)) = ϕA,B(f)k, (11)

ϕA,B0 (hf) = G(h)ϕA,B(f). (12)

Definition 6.2 Let G : B → A be a functor and A ∈ A0.A universal morphism from A to G is an initial object of the category (A ↓ G) of objects G-under A (see Example 3.15).

Thus a universal morphism from A to G is a pair (u, B), consisting of an object B ∈ B0 and a 0 0 0 morphism u : A → G(B) such that for every pair (g, B ) with B ∈ B0 and g : A → G(B ) a morphism of A, there is a unique morphism f : B → B0 in B such that G(f)u = g. In other words, every morphism g to G factors uniquely through the universal morphism u.

u AAG/ G(B) B ? ?? ? ?? f g ? G(f) ?? ? ?   G(B0) B0 Dually one can define universal morphisms from F to B. Since initial and terminal objects are unique up to isomorphism, also universal morphisms are unique up to isomorphism.

Theorem 6.3 An adjunction hF, G, ϕi : A → B determines

1. a natural transformation η : 1A ⇒ GF such that for each object A ∈ A0 the pair (ηA,F (A)) is a universal morphism from A to G, and for each f : F (A) → B,

ϕA,B(f) = G(f)ηA : A → G(B); (13)

2. a natural transformation ε : FG ⇒ 1B such that for each object B ∈ B0 the pair (G(B), εB) is a universal morphism from F to B, and for each g : A → G(B),

−1 ϕA,B(g) = εBF (g): F (A) → B. (14)

42 Moreover, both the composites (G∗ε)◦(η ∗G) and (ε∗F )◦(F ∗η) are the identity natural transformations (of G, resp. F ). η∗G G∗ε F ∗η ε∗F G / GF G / G, F / F GF / F. (15) We call η the unit and ε the counit of the adjunction. Note that by (2) and (3) the condition (15) translates to so-called triangular identities

G(εB)ηG(B) = 1G(B), εF (A)F (ηA) = 1F (A), (16)

A ∈ A0,B ∈ B0, i.e. the commutativity of triangles

ηG(B) F (ηA) G(B) / GF G(B) F (A) / F GF (A) ? ? ?? ?? ?? ?? ε ?? G(εB ) ?? F (A) 1G(B) ?? 1F (A) ?? ?  ?  G(B) F (A) . (17)

Proof. 1. For every A ∈ A0, take B := F (A) in (10) and define

ηA : A → GF (A), ηA := ϕA,F (A)(1F (A)). (18) First we note that (12) implies that for every f : F (A) → B,

ϕA,B(f) = ϕA,B(f1F (A)) = G(f)ϕA,F (A)(1F (A)) = G(f)ηA. (19)

To prove the universality of (ηA,F (A)), suppose that g : A → G(B) is a morphism from A to G. Then −1 ϕA,B(g): F (A) → B and we obtain

−1 −1 G(ϕA,B(g))ηA = ϕA,B(ϕA,B(g)) = g.

ηA A / GF (A) F (A) ? ?? ? ?? −1 −1 ? G(ϕA,B (g)) ϕA,B (g) g ?? ? ?   G(B) B

−1 If also G(h)ηA = g for a morphism h : F (A) → B then g = ϕA,B(h) implies ϕA,B(g) = h. Thus ηA is a universal morphism from A to G. 0 To prove that η = (ηA)A∈A0 is a natural transformation, consider for k : A → A a diagram

η 0 A0 A / GF (A0)

k GF (k)   A. / GF (A) ηA

Its commutativity follows from the calculation

GF (k)ηA0 = GF (k)ϕA0,F (A0)(1F (A0)) = ϕA0,F (A)(F (k)1F (A0)) = ϕA0,F (A)(1F (A)F (k))

= ϕA,F (A)(1F (A))k = ηAk where we used (18), (11) and (12). This calculation may also be illustrated by the following commutative diagram: F (k)◦− −◦F (k) B(F (A0),F (A0)) / B(F (A0),F (A)) o B(F (A),F (A))

ϕA0,F (A0) ϕA0,F (A) ϕA,F (A)    A(A0, GF (A0)) / A(A0, GF (A)) o A(A, GF (A)) GF (k)◦− −◦k

43 2. For every B ∈ B0, set A := G(B) in (10) and define a morphism

−1 εB : FG(B) → B, εB := ϕG(B),B(1G(B)). (20)

−1 It turns out to be a universal morphism from F to B and ϕA,B(g) = εBF (g) for every g : A → G(B). Finally, the triangles (17) commute because

1G(B) = ϕG(B),B(εB) = G(εB)ηG(B), −1 1F (A) = ϕA,F (A)(ηA) = εF (A)F (ηA).

Theorem 6.4 Each adjunction hF, G, ϕi : A → B is completely determined by the items in any one of the following lists:

1. Functors F,G, and a natural transformation η : 1A ⇒ GF such that each ηA : A → GF (A) is universal from A to G. Then ϕ is defined by (13).

2. Functors F,G, and a natural transformation ε : FG ⇒ 1B such that each εB : FG(B) → B is universal from F to B. Here ϕ−1 is defined by (14).

3. Functors F,G and natural transformations η : 1A ⇒ GF and ε : FG ⇒ 1B such that both composites (15) are the identity transformations. Here ϕ is defined by (13) and ϕ−1 by (14).

Proof. 1. The universality of ηA : A → GF (A) means that for each g : A → G(B) there is exactly one f : F (A) → B making the triangle

ηA A / GF (A) ? ?? ?? ?? G(f) g ?? ? ?  G(B) commutative. This states precisely that

ψA,B(f) := G(f)ηA defines a bijection ψA,B : B(F (A),B) → A(A, G(B)). For every k : A0 → A in A and f : F (A) → B in B,

ψA,B(f)k = G(f)ηAk = G(f)GF (k)ηA0 = G(fF (k))ηA0 = ψA0,B(fF (k)), hence ψ is natural in A. For every h : B → B0 and f : F (A) → B in B,

G(h)ψA,B(f) = G(h)G(f)ηA = G(hf)ηA = ψA,B0 (hf), so ψ is also natural in B.

ψA,B ψA,B B(F (A),B) / A(A, G(B)) B(F (A),B) / A(A, G(B))

h◦− G(h)◦− −◦F (k) −◦k     B(F (A),B0) / A(A, G(B0)) B(F (A0),B) / A(A0,G(B)) ψA,B0 ψA0,B

Thus we have an adjunction hF, G, ψi. In case η was the unit obtained from an adjunction hF, G, ϕi, then ψ = ϕ, because, by (13), ψA,B(f) = G(f)ηA = ϕA,B(f) for every f : F (A) → B. 2 is dual to 1. ϕA,B / 3. For every A ∈ A0 and B ∈ B0 we define two mappings B(F (A),B) o A(A, G(B)) by θA,B

ϕA,B(f) := G(f)ηA,

θA,B(g) := εBF (g),

44 f : F (A) → B, g : A → G(B). Using functoriality of G, naturality of η and the first triangular identity (16), we obtain

ϕA,BθA,B(g) = ϕA,B(εBF (g)) = G(εBF (g))ηA = G(εB)GF (g)ηA

= G(εB)ηG(B)g = 1G(B)g = g.

Hence ϕA,BθA,B = 1A(A,G(B)). Dually θA,BϕA,B = 1B(F (A),B), and so ϕA,B is a bijection. Naturality of ϕ, that is, equalities (11) and (12) for arbitrary morphisms k : A0 → A, h : B → B0 and f : F (A) → B, is proven by calculations

ϕA0,B(fF (k)) = G(fF (k))ηA0 = G(f)GF (k)ηA0 = G(f)ηAk = ϕA,B(f)k,

ϕA,B0 (hf) = G(hf)ηA = G(h)G(f)ηA = G(h)ϕA,B(f).

Consequently we have obtained an adjunction (and if we started with an adjunction, it is the one from which we started). As an example, consider two partially ordered sets A and B as categories (see Example 1.7(2)). Order-preserving mappings between A and B are covariant functors and order-reversing mappings are contravariant functors. Consider two order-reversing mappings f : A → B, g : B → A as covariant functors f A / Bop o g (see Proposition 3.8). Then f a g if

a ≤ gf(a) in A and fg(b) ≤ b in Bop (or b ≤ fg(b) in B) (21) for every a ∈ A and b ∈ B. This follows from Theorem 6.4 (3): the naturality conditions and the triangular identities are automatically satisfied since in a poset, between two objects there is at most one morphism. Thus condition (21) is equivalent to the existence of a bijection Bop(f(a), b) → A(a, g(b)), which reduces to b ≤ f(a) in B ⇐⇒ a ≤ g(b) in A for every a ∈ A an b ∈ B. Such a situation between posets is called a Galois connection.

6.3 Examples of adjuncions The following table lists some examples of adjoints.

45 A B F : A → B G : B → A Unit of adjunction 1 Set VecK X 7→ VX , forgetful functor U ιX : X → U(VX ), vector space on basis insertion of generators (cf. X 6.1) 2 Set Gr X 7→ F (X), forgetful functor U X → UF (X), free group with gener- insertion of generators ators x ∈ X 3 Gr Ab A 7→ A/A0, forgetful functor U A → A/A0, abelianization functor projection on the quotient (cf. Example 3.3 (6)) 4 Domm Field D 7→ Q(D), forgetful functor U ιD : D → UQ(D), a field of quotients inclusion of D: a 7→ 1 5 Met Cmet completion of metric inclusion functor X → X, space inclusion of X into its com- pletion 6 Set Top X 7→ (X, τ), forgetful functor U 1X : X → X τ discrete ( functor) 7 Top Haus (X, τ) 7→ (X, τ)/∆X , inclusion functor (X, τ) → (X, τ)/∆X , quotient by the closure projection on the quotient of diagonal T 8 Set Set − × T , Set(T, −) = (−) , S → Set(T,S × T ), s 7→ fs T is a fixed set T is a fixed set where fs(t) = (s, t) 9 ModR Ab −⊗RB, ModR(B, −), A → ModR(B,A ⊗ B), B is a fixed R-module B is a fixed R-module a 7→ fa where fa(b) = a ⊗ b 10 B2 B ` :(B,B0) 7→ B ` B0, B 7→ (B,B), pair of injections ` 0 coproduct uB : B → B B , 0 ` 0 uB0 : B → B B 2 Q 0 0 11 A A A 7→ (A, A), :(A, A ) 7→ A×A , δA : A → A × A diagonal functor product functor

There are similar descriptions for counits. For example in the vector space VX on basis X, if ιX (x) = hxi ∈ VX for every x ∈ X, then the elements of VX are the finite vector sums k1hx1i+...+knhxni, ki ∈ K, −1 xi ∈ X. Then for every vector space A the counit εA : VU(A) → A is defined by εA = ϕU(A),A(1U(A)) −1 where ϕU(A),A = ψU(A),A is given by (9). Hence εA = ψU(A),A(1U(A)) = f1U(A) (see (20) and (6.1)) and

εA(k1ha1i + ... + knhani) = k11U(A)(a1) + ... + kn1U(A)(an) = k1a1 + ... + knan.

In the adjunction 4, Domm is the category of all integral domains with arrows all monomorphisms of integral domains (note that a homomorphism of fields is necessarily a monomorphism). For every integral domain D, a familiar construction gives a field Q(D) of quotients of D together with a monomorphisn a ιD : D → Q(D), a 7→ 1 . If K is any field and g : D → U(K) a monomorphism then there is a unique homomorphism f : Q(D) → K such that U(f)ιD = g. Thus ιD is a universal morphism from D to UQ(D). However, in the larger category Dom where morphisms are all homomorphisms of integral domains there is no universal homomorphism from (for example) Z to forgetful functor U. This follows from the fact that for every prime p there is a surjective homomorphism Z → Zp. In the adjunction 5, Met is the category of all metric spaces with distance preserving mappings as morphisms (these must be necessarily injective). Cmet is the full subcategory of Met where objects are complete metric spaces. The completion procedure of metric spaces induces a functor Met → Cmet which is a left adjoint to the inclusion functor Cmet → Met. The usual inclusion X → X of a into its completion is the unit of this adjunction. In the adjunction 6, a left adjoint of the forgetful functor Top → Set takes every set X to a topological space (X, τ) where τ is the discrete topology on X. In the adjunction 7, Haus is the full subcategory of Top, consisting of all Hausdorff spaces. A topo- logical space (X, τ) is a Hausdorff space if and only if its diagonal ∆X ⊆ X × X is closed. The inclusion functor Haus → Top has a left adjoint F : Top → Haus where F (X, τ) = (X, τ)/∆X is the quotient of the topological space (X, τ) by the closure of its diagonal ∆X ⊆ X × X, which is indeed an equivalence relation.

46 6.4 The Adjoint Functor Theorem Proposition 6.5 If the functor G : B → A has a left adjoint, G preserves all limits which exist in B.

Proof. Let hF, G, ϕi : A → B be an adjunction. Consider a category D and write I = D0. Suppose (L, (pi)i∈I ) is a limit of a functor D : D → B. We must prove that (G(L),G(pi)i∈I ) is a limit of GD. Clearly (G(L),G(pi)i∈I ) is a cone on GD, so it suffices to prove the universal property. Consider a cone (A, (qi)i∈I ) on GD.

A F (A) 6 Ø 6 Ø 66 ØØ 66 Ø 6 Ø q 6 ØØ r 66 q Ø 6 qj Ø 6 i ØØ 66 ri Ø 6 rj Ø  6 ØØ  66 Ø G(L) 6 Ø L 6 Ø 6 Ø p O pj 6 GØ(pi) O G(pj6) Ø i oo OO 6 ØØ ooo OOO 66 Ø oo OO 66 ØÔ ow o O'  ØÔ Ø wooo OO'  GD(i) / GD(j) D(i) / D(j) GD(d) D(d)

−1 For every i ∈ I, set ri := ϕA,D(i)(qi): F (A) → D(i). Then for any morphism d : i → j in D, the commutativity of the square

−1 ϕA,D(i) B(F (A),D(i)) o A(A, GD(i))3 qi

D(d)◦− GD(d)◦−   B(F (A),D(j)) o −1 A(A, GD(j)) ϕA,D(j) implies

−1 −1 −1 rj = ϕA,D(j)(qj) = ϕA,D(j)(GD(d)qi) = D(d)ϕA,D(i)(qi) = D(d)ri, and hence (F (A), (ri)i∈I ) is a cone on D. Therefore there exists a unique morphism r : F (A) → L such that pir = ri for every i ∈ I. Denoting q := ϕA,L(r): A → G(L) and using the commutativity of

ϕA,L r ∈B(F (A),L) / A(A, G(L)) 3 q

pi◦− G(pi)◦−   B(F (A).,D(i)) / A(A, GD(i)) ϕA,D(i) we obtain G(pi)q = G(pi)ϕA,L(r) = ϕA,D(i)(pir) = ϕA,D(i)(ri) = qi. 0 0 If also q : A → G(L) is such that G(pi)q = qi for every i ∈ I, then

−1 0 0 ϕA,D(i)(piϕA,L(q )) = G(pi)q = qi = ϕA,D(i)(ri)

−1 0 implies piϕA,L(q ) = ri for every i ∈ I by the injectivity of ϕA,D(i). By the uniqueness of r, we conclude −1 0 0 ϕA,L(q ) = r, which means q = ϕA,L(r) = q. The dual of Proposition 6.5 states that a functor that has a right adjoint preserves all colimits. Thus all functors F in the fourth column of the table of examples above preserve all colimits.

Theorem 6.6 Let C be a complete category. Then C has an initial object if and only if it satisfies the following Solution Set Condition. There is a set S ⊆ C0 such that for every C ∈ C0 there is a morphism A → C with A ∈ S.

47 We shall use the abbreviation SSC for the Solution Set Condition. Every small category C has a solution set S = C0. Proof. Necessity. If 0 is an initial object of C, we may take S = {0}. Sufficiency. Let S = {Ai | i ∈ I} be a solution set for C. Let (P, (pi)i∈I ) be the product of objects Ai, i ∈ I. 1P / pi PPP / PA/ Ai  O eks s   e  f  g  k /  KKE/ ECE / C h Construct the multiple equalizer (E, e) of the set of of P . We claim that E is the initial object of C. If C ∈ C0, then there is a morphism f : Ai → C for some i ∈ I. Hence we have at least one morphism fpie : E → C form E to C. Suppose that there are two morphisms g, h : E → C and consider their equalizer (K, k). By the assumption and the construction of P , there is a morphism s : P → K. So both 1P and eks are endomorphisms of P , which implies ekse = 1P e = e1E. Since e is a monomorphism by a generalization of Proposition 5.26 we conclude kse = 1E. Thus k is a split epimorphism, and hence gk = hk implies g = h. The proofs of the next two results have been omitted.

Lemma 6.7 If B is complete and a functor G : B → A preserves all products (resp. equalizers) then for every A ∈ A0, the category (A ↓ G) of all objects G-under A has all small products (resp. equalizers).

Theorem 6.8 (The Adjoint Functor Theorem) Let B be a complete category. A functor G : B → A has a left adjoint functor if and only if G preserves limits and the category (A ↓ G) satisfies the SSC for every A ∈ A0.

We note that explicitly the SSC for (A ↓ G) means that there exists a set SA ⊆ B0 of objects such that 0 0 0 0 0 (∀B ∈ B0)(∀f : A → G(B))(∃B ∈ SA)(∃f : A → G(B ))(∃h : B → B)(G(h)f = f).

f 0 AAG/ G(B0) B0 ? ?? ?? ?? G(h) h f ?? ? ?   G(B) B

If F a G then we can set SA := {F (A)} and use the universal morphism ηA : A → GF (A). Let A and B be posets considered as categories and let B be complete, that is, B has arbitrary greatest lower bounds. A covariant functor (i.e. an order-preserving mapping) g : B → A has a left adjoint if and only if g preserves all greatest lower bounds. The SSC is satisfied because the category (a ↓ g) is small for every a ∈ A.

6.5 Equivalence of categories Definition 6.9 A functor G : B → A is called an equivalence of categories if there is a functor F : A → B and natural isomorphisms η : 1A ⇒ GF and ε : FG ⇒ 1B. In such a case the categories A and B are called equivalent.

Theorem 6.10 For a functor G : B → A the following assertions are equivalent. 1. G is an equivalence of categories.

2. G has a left adjoint F : A → B and the unit η : 1A ⇒ GF and counit ε : FG ⇒ 1B are isomorphisms. ∼ 3. G is full and faithful and for every A ∈ A0 there exists B ∈ B0 such that G(B) = A.

48 Thus for a functor G : B → A the following implications hold:

G isomorphism ⇒ G equivalence ⇒ G has left adjoint.

Examples 6.11 1. The category of all finite sets is equivalent to its full subcategory, which has as objects all sets {1, 2, . . . , n}, n ∈ N, and the empty set. 2. For any field K, the category of all finite dimensional vector spaces over K is equivalent to the category of Example 1.7 (1).

6.6 Exercises

Exercises 6.12 1. Prove that if F,G : A×B → C are bifunctors and ϕ = (ϕA,B)(A,B)∈(A×B)0 : F ⇒ G is natural both in A and B then it is natural in (A, B). 2. Choose some concrete adjunction and write out explicitly its unit, counit and bijection ϕ. 3. Prove that equivalence of categories is an equivalence relation (i.e. reflexive, symmetric and tran- sitive).

49 Index D-complete category, 36 functor, 11 D-limit preserving functor, 38 contravariant, 11 D-limit reflecting functor, 38 covariant, 11 faithful, 14 adjoint full, 14 left, 42 full and faithful, 14 right, 42 preserving D-limits, 38 adjunction, 42 preserving finite limits, 38 preserving limits, 38 bifunctor, 39 reflecting D-limits, 38 bimorphism, 8 reflecting finite limits, 38 reflecting limits, 38 category, 2 D-complete, 36 Galois conection, 45 complete, 36 Godement product, 23 discrete, 3 finitely complete, 36 hom-functor large, 3 contravariant, 13 of objects G-under C, 15 covariant, 12 of objects under A, 5 of small categories, 13 identity functor, 11 small, 3 inclusion functor, 11 category of cones, 33 initial object, 9 class, 2 injection cocone, 34 of coproduct, 24, 25 coequalizer, 30 , 10 colimit, 34 interchange law, 23 comma category, 15 isomorphic objects, 8 complete category, 36 isomorphism, 8 composition of natural transformations, 20 of categories, 14 concrete category, 6 cone, 33 kernel pair, 32 constant functor, 12 large category, 3 coproduct, 24, 25 limit, 33 coretraction, 5 limit preserving functor, 38 discrete category, 3 limit reflecting functor, 38 empty category, 3 monomorphism, 5 endofunctor, 15 split, 5 endomorphism, 3 morphism of cones, 33 epimorphism, 6 multiple pullback, 32 split, 6 natural isomorphism, 18 equalizer, 30 natural transformation, 18 equivalence of categories, 48 naturally isomorphic functors, 18 evaluation functor, 21 opposite category, 13 faithful functor, 14 finite limit preserving functor, 38 preservation finite limit reflecting functor, 38 of monomorphisms, 14 finitely complete category, 36 product, 24 forgetful functor, 12 of categories, 5 free product of groups, 29 projection full and faithful functor, 14 of product, 24, 25 full functor, 14 projective object, 9 full subcategory, 5 proper class, 2

50 pullback, 32 pullback square, 32 pushout, 32 quasicategory, 13 of all categories, 13 quasicategory of functors, 20 reflection of monomorphisms, 14 representable functor contravariant, 13 covariant, 12 retract, 5 retraction, 6 section, 5 set, 2 small category, 3 split epimorphism, 6 split monomorphism, 5 strict initial object, 27 subcategory, 4 subcateory full, 5 sum, 24 terminal object, 9 triangular identities, 43 unit of adjunction, 43 universal morphism, 42 universe, 2

Yoneda embedding contravariant, 22 Yoneda Lemma, 20 zero object, 9

51 References

[1] F. Borceux, Handbook of Categorical Algebra 1: Basic Category Theory (Cambridge University Press, Cambridge, 1994). [2] S. Mac Lane, Categories for the Working Mathematician (Springer, New York, 1971). [3] Ch. Wells, Electronic supplement to Category Theory for Computing Science. [4] H. Herrlich, G. Strecker, Category Theory (Allyn and Bacon, Boston, 1973). [5] H.P. Gumm, Elements of the general theory of coalgebras (1999?), www.mathematik.uni- marburg.de/∼gumm/Papers/Luatcs.ps

52