BRICS LS-95-1 J. van Oosten: Basic Category Theory

BRICS

Basic Research in Computer Science

Basic Category Theory

Jaap van Oosten

BRICS Lecture Series LS-95-1 ISSN 1395-2048 January 1995 Copyright \begin{matrix}c \\ ◯ \end{matrix} 1995, BRICS, Department of Computer Science

University of Aarhus. All rights reserved.

Reproduction of all or part of this work is permitted for educational or research use on condition that this copyright notice is included in any copy.

See back inner page for a list of recent publications in the BRICS Lecture Series. Copies may be obtained by contacting:

BRICS Department of Computer Science University of Aarhus Ny Munkegade, building 540 DK - 8000 Aarhus C Denmark

Telephone: +45 8942 3360
Telefax: +45 8942 3255
Internet: BRICS@daimi.aau.dk

BRICS publications are in general accessible through WWW and anonymous FTP:

http://www.brics.aau.dk/BRICS/
ftp ftp.brics.aau.dk (cd pub/BRICS)

Basic Category Theory

Jaap van Oosten

Jaap van Oosten

BRICS^{1}

Department of Computer Science

University of Aarhus

Ny Munkegade DK-8000 Aarhus C, Denmark

1Basic Research In Computer Science, Centre of the Danish National Research Foundation.

Preface

These notes contain the material of a short course on categories I gave in Århus in the autumn of 1994, as part of Glynn Winskel’s semantics course. Later on, while writing, I added some material, but not much.

The style in which they are written reflects my view on category theory: it is, especially at this low level, practice rather than theory which counts. I have therefore given many proofs as exercises. If you really want to get a grip on the subject, I strongly suggest you do as many of them as you can.

The same goes for the examples. They are the flesh and bones of the theory, and many of them have been chosen so they are a recurring theme; functors \xymatrix{C \ar[r] & D \ar[l]} may be given as examples in chapter 1, be shown to constitute an adjunction in chapter 5, while this may turn out to be a monadic situation in chapter 6.

For the same reason, references are omitted. Even a sketchy proof, or a hint of the crucial argument, is better than an intimidating reference to [R].

Of course, the examples will be best understood by students who are familiar with the mathematical notions involved, but in general these notes do not require a lot of mathematical background, except for some basic knowledge of groups, rings and topological spaces (although examples on the latter may be skipped, since I have not pursued them through the whole text).

What I did presuppose is some familiarity with logic and the λ-calculus. Although definitions are given, standard facts about substitution and the like are suppressed (a teacher can easily supply them when he gives the course). This familiarity does not include a good understanding of set theory or even an inkling of the size problems one can run into. I’ve used the terms “set” and “small” wherever necessary, although I don’t suppose they mean much to many students. For that reason I’ve also omitted a proof of Freyd’s Adjoint Functor Theorem and an explanation of the role of the solution set condition.

Apart from chapters 4 and 7, where in spite of the fact that the results are well-known I haven’t been able to find references where they are treated in a concise enough form, and so had to develop the material myself, everything is pretty standard. I have consulted the following sources:

• S. MacLane, Categories for the Working Mathematician, Springer (Berlin) 1971. Still the best text. For non-mathematicians it may be a little tough going, but it is worth the trouble.

• F. Borceux, Handbook of Categorical Algebra, (Encyclopaedia of Mathematics and its Applications) Cambridge University Press (Cambridge) 1994. Next best. Gives a lot of material in a very readable style; also on specialized topics. Three volumes.

A strange error in the definition of Grothendieck universes in the first chapter, making the definition inconsistent, supports the point about set theory, I made before.

Many concrete examples. The reader will find many answers to my exercises in this book.

• M. Barr & C. Wells, Category Theory for Computing Science, Prentice Hall (New York) 1990. At this moment out of print. The emphasis on sketches is debatable, for a first course in the theory. Otherwise a very valuable source.

• P.T. Johnstone, Stone Spaces, Cambridge University Press (Cambridge) 1982. Not a book on category theory proper, but a systematic study on various dualities of the Stone type. A lot of material on posetal structures like frames, Boolean algebras etc.

• A. Asperti, Categorical Topics in Computer Science, Ph.D. Thesis, Pisa 1990. Later reworked into: A. Asperti & G. Longo, Categories, Types, and Structures: An Introduction to Category Theory for the Working Computer Scientist (Foundations of Computing), MIT Press (Cambridge Massachusetts) 1991.

• M. Makkai & G. Reyes, First Order Categorical Logic (Lecture Notes in Mathematics 611), Springer (Berlin) 1977. “The” book on categorical logic. It is my feeling that a sequel is badly needed. The main ideas are developed here.

• S. MacLane & I. Moerdijk, Sheaves in Geometry and Logic (Universitext), Springer 1992. Treats topos theory, with important applications to logic. Can almost be read from scratch.

• J. Lambek & P. Scott, Introduction to higher order categorical logic, Cambridge University Press (Cambridge) 1986. This may very well be a book of the future, but for a first acquaintance with category theory the approach is too formal for my taste. Gives a very elaborate account of the correspondences between type theories and certain types of categories.

Of course this list doesn’t make any pretense whatsoever at being complete or even a guide into the literature. It mainly reflects my personal attitude.

Acknowledgements. I am grateful to the group of students who patiently and critically sat through my lectures, and in particular to Thomas Hildebrandt and Søren Bøgh Lassen who pointed out mistakes in my original hand-written notes.

The help of my office mate Vladi Sassone, has been invaluable. A critical reading by him of the whole first version revealed a couple of embarassing mistakes (“the functor (−) × X also has a left adjoint”, ha ha—there is no limit to what a confused brain can come up with); then he put a lot of effort in the visual layout of the text, teaching me emacs and LaTEX in the process, and designed the rococo painting which is the title page.

It goes without saying that the remaining errors are mine, and that the poor visual quality of the text is a testimony of my ignorance of LaTEX, which I am not proud of.

References

[R] J. Razdajev, Some facts about functors, Novosibirsk Journal of Diving Research XLVII (1947), pp. 634-98 (Russian) iv

Contents

1 Categories and Functors 1 1.1 Definitions and examples . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Some special objects and arrows . . . . . . . . . . . . . . . . . . 6

2 Natural transformations 9 2.1 The Yoneda lemma . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.2 Examples of natural transformations . . . . . . . . . . . . . . . . 12 2.3 Equivalence of categories; an example . . . . . . . . . . . . . . . 14

3 (Co)cones and (co)limits 17 3.1 Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.2 Limits by products and equalizers . . . . . . . . . . . . . . . . . 24 3.3 Colimits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4 A little piece of categorical logic 29 4.1 Regular categories and subobjects . . . . . . . . . . . . . . . . . 29 4.2 Coherent logic in regular categories . . . . . . . . . . . . . . . . . 33 4.3 The language L(C) and theory T (C) associated to a regular cat-

egory C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 4.4 Example of a regular category . . . . . . . . . . . . . . . . . . . . 39

5 Adjunctions 43 5.1 Adjoint functors . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 5.2 Expressing (co)completeness by existence of adjoints; preserva-

tion of (co)limits by adjoint functors . . . . . . . . . . . . . . . . 48

6 Monads and Algebras 53 6.1 Algebras for a monad . . . . . . . . . . . . . . . . . . . . . . . . 54 6.2 T -Algebras at least as complete as D . . . . . . . . . . . . . . . . 59 6.3 The Kleisli category of a monad . . . . . . . . . . . . . . . . . . . 59

7 Cartesian closed categories and the λ-calculus 63 7.1 Cartesian closed categories (ccc’s); examples and basic facts … 63 7.2 Typed λ-calculus and cartesian closed categories . . . . . . . . . 67 7.3 Representation of primitive recursive functions in ccc’s with nat-

ural numbers object . . . . . . . . . . . . . . . . . . . . . . . . . 70

Index 73 vi

\underline{Categories}

1 Categories and Functors

1.1 Definitions and examples

A category C is given by a class C_{0} of objects and a class C_{1} of arrows which have the following structure.

• Each arrow has a domain and a codomain which are objects; one writes f : X → Y or X →^{f} Y if X is the domain of the arrow f, and Y its codomain. One also writes X = dom(f) and Y = cod(f);

• Given two arrows f and g such that cod(f) = dom(g), the composition of f and g, written gf, is defined and has domain dom(f) and codomain cod(g):

X →^{f} Y →^{g} Z

• Composition is associative, that is: given f : X → Y, g : Y → Z and h : Z → W, h(gf) = (hg)f;

• For every object X there is an identity arrow id_{X}, satisfying id_{X}g = g for every g : Y → X and fid_{X} = f for every f : X → Y.

Exercise 1. Show that id_{X} is the unique arrow with domain X and codomain X with this property.

Instead of “arrow” we also use the terms “morphism” or “map”. Examples

a) 1 is the category with one object ∗ and one arrow, id_{∗};

b) 0 is the empty category;

c) A preorder is a set X together with a binary relation ≤ which is reflexive (i.e. x ≤ x for all x ∈ X) and transitive (i.e. x ≤ y and y ≤ z imply x ≤ z for all x, y, z ∈ X). This can be viewed as a category, with set of objects X and exactly one arrow: x → y iff x ≤ y.

Exercise 2. Prove this. Prove also the converse: if C is a category such that C_{0} is a set, and such that for any two objects X, Y of C there is at most one arrow: X → Y, then C_{0} is a preordered set.

d) A monoid is a set X together with a binary operation, written like multiplication: xy for x, y ∈ X, which is associative and has a unit element e ∈ X, satisfying ex = xe = x for all x ∈ X. Such a monoid is a category with one object, and an arrow x for every x ∈ X. e) Set is the category which has the class of all sets as objects, and functions

between sets as arrows.

Most basic categories have as objects certain mathematical structures, and the structure-preserving functions as morphisms. Examples:

f) Top is the category of topological spaces and continuous functions.

g) Grp is the category of groups and group homomorphisms.

h) Rng is the category of rings and ring homomorphisms.

i) Grph is the category of graphs and graph homomorphisms.

j) Pos is the category of partially ordered sets and monotone functions.

Given two categories C and D, a functor F : C → D consists of operations F_{0} : C_{0} → D_{0} and F_{1} : C_{1} → D_{1}, such that for each f : X → Y, F_{1}(f) : F_{0}(X) → F_{0}(Y) and:

• for X →^{f} Y →^{g} Z, F_{1}(gf) = F_{1}(g)F_{1}(f);

• F_{1}(id_{X}) = id_{F_{0}(X)} for each X ∈ C_{0}.

But usually we write just F instead of F_{0}, F_{1}. Examples.

a) There is a functor U : Top → Set which assigns to any topological space X its underlying set. We call this functor “forgetful”: it “forgets” the mathematical structure. Similarly, there are forgetful functors Grp → Set, Grph → Set, Rng → Set, Pos → Set etcetera;

b) For every category C there is a unique functor C → 1 and a unique one 0 → C;

c) Given two categories C and D we can define the product category C × D which has as objects pairs (C, D) ∈ C_{0} × D_{0}, and as arrows:(C, D) → (C′, D′) pairs (f, g) with f : C → C′ in C, and g : D → D′ in D. There are functors π_{0} : C × D → C and π_{1} : C × D → D;

1. Categories and Functors

d) Given two functors F : C → D and G : D → E one can define the composition GF : C → E. This composition is of course associative and since we have, for any category C, the identity functor C → C, we have a category Cat which has categories as objects and functors as morphisms. e) Given a set A, consider the set Ã of strings a_{1} … a_{n} on the alphabet

A ∪ A^{−1} (A^{−1} consists of elements a^{−1} for each element a of A; the sets A and A^{−1} are disjoint and in 1-1 correspondence with each other), such that for no x ∈ A, xx^{−1} or x^{−1}x is a substring of a_{1} … a_{n}. Given two such strings a⃗ = a_{1} … a_{n}, b⃗ = b_{1} … b_{m}, let a⃗ ⋆ b⃗ the string formed by first taking a_{1} … a_{n}b_{1} … b_{m} and then removing from this string, successively, substrings of form xx^{−1} or x^{−1}x, until one has an element of Ã.

This defines a group structure on Ã. Ã is called the free group on the set A.

Exercise 3. Prove this, and prove that the assignment A ↦ Ã is part of a functor: Set → Grp. This functor is called the free functor.

f) Every directed graph can be made into a category as follows: the objects are the vertices of the graph and the arrows are paths in the graph. This defines a functor from the category Dgrph of directed graphs to Cat. The image of a directed graph D under this functor is called the category generated by the graph D.

g) Quotient categories. Given a category C, a congruence relation on C specifies, for each pair of objects X, Y, an equivalence relation ∼_{X,Y} on the class of arrows C(X, Y) which have domain X and codomain Y, such that

• for f, g : X → Y and h : Y → Z, if f ∼_{X,Y} g then hf ∼_{X,Z} hg;

• for f : X → Y and g, h : Y → Z, if g ∼_{Y,Z} h then gf ∼_{X,Z} hf.

Given such a congruence relation ∼ on C, one can form the quotient category C/ ∼ which has the same objects as C, and arrows X → Y are ∼_{X,Y} -equivalence classes of arrows X → Y in C.

Exercise 4. Show this and show that there is a functor C → C/∼, which takes each arrow of C to its equivalence class.

h) An example of this is the following (“homotopy”). Given a topological space X and points x, y ∈ X, a path from x to y is a continuous mapping f from some closed interval [0, a] to X with f(0) = x and f(a) = y. If f : [0, a] → X is a path from x to y and g : [0, b] → X is a path from y to z

there is a path gf : [0, a+b] → X (defined by gf(t) = \{ \begin{matrix}f(t) & t ≤ a \\ g(t − a) & else \end{matrix} )

from x to z. This makes X into a category, the path category of X, and of course this also defines a functor Top → Cat. Now given paths f : [0, a] → X, g : [0, b] → X, both from x to y, one can define f ∼_{x,y} g if there is a continuous map F : A → X where A is the area:

[figure: (0, 1); (b, 1); (0, 0); (a, 0)]

in IR^{2}, such that

F (t, 0) = f(t)
F (t, 1) = g(t)
F (0, s) = x  s ∈ [0, 1]
F (s, t) = y  (s, t) on the segment (b, 1) − (a, 0)

One can easily show that this is a congruence relation. The quotient of the path category by this congruence relation is a category called the category of homotopy classes of paths in X.

i) let C be a category such that for every pair (X, Y) of objects the class C(X, Y) of arrows from X to Y is a set (such C is called locally small).

For any object C of C then, there is a functor h_{C} : C → Set which assigns to any object C′ the set C(C, C′). Any arrow f : C′ → C′′ gives by composition a function C(C, C′) → C(C, C′′), so we have a functor. A functor of this form is called a representable functor.

j) Let C be a category and C an object of C. The slice category C/C has as objects all arrows g which have codomain C. An arrow from g : D → C to h : E → C in C/C is an arrow k : D → E in C such that hk = g. Draw like:

[figure: D; k; g; E; h; C]

We say that this diagram commutes if we mean that hk = g.

Exercise 5. Convince yourself that the assignment C ↦ C/C gives rise to a functor C → Cat.

k) Remember that for every group (G, ·) we can form a group (G, ⋆) by putting f ⋆ g = g · f.

For categories the same construction is available: given C we can form a category C^{op} which has the same objects and arrows as C, but with reversed direction; so if f : X → Y in C then f : Y → X in C^{op}. To make it notationally clear, write f̄ for the arrow Y → X corresponding to f : X → Y in C. Composition in C^{op} is defined by:

f̄ḡ = \overline{gf}

Often one reads the term “contravariant functor” in the literature. What I call functor, is then called “covariant functor”. A contravariant functor F from C to D inverts the direction of the arrows, so F_{1}(f) : F_{0}(cod(f)) → F_{0}(dom(f)) for arrows f in C. In other words, a contravariant functor from C to D is a functor from C^{op} → D (equivalently, from C to D^{op}).

Exercise 6. Let C be locally small. Show that there is a functor (the “Hom functor”) C(−, −) : C^{op} × C → Set, assigning to the pair (A, B) of objects of C, the set C(A, B).

l) Given a partially ordered set (X, ≤) we make a topological space by defining U ⊆ X to be open iff for all x, y ∈ X, x ≤ y and x ∈ U imply y ∈ U (U is “upwards closed”, or an “upper set”). This is a topology, called the Alexandroff topology w.r.t. the order ≤.

If (X, ≤) and (Y, ≤) are two partially ordered sets, a function f : X → Y is monotone for the orderings if and only if f is continuous for the Alexandroff topologies. This gives an important functor: Pos → Top.

Exercise 7. Show that the construction of the quotient category in example g) generalizes that of a quotient group by a normal subgroup. That is, regard a group G as a category with one object; show that there is a bijection between congruence relations on G and normal subgroups of G, and that for a normal subgroup N of G, the quotient category by the congruence relation corresponding to N, is to the quotient group G/N.

m) “Abelianization”. Let Abgp be the category of abelian groups and homomorphisms. For every group G the subgroup [G, G] generated by all elements of form aba^{−1}b^{−1} is a normal subgroup. G/[G, G] is abelian, and for every group homomorphism ϕ : G → H with H abelian, there is a unique homomorphism ϕ̄: G/[G, G] → H such that the diagram

[figure: G; p; ϕ; G/[G, G]; ϕ̄; H]

commutes. Show that this gives a functor: Grp → Abgp. n) “Specialization ordering”. Given a topological space X, you can define an

ordering ≤_{s} on X as follows: say x ≤_{s} y if for all open sets U, if x ∈ U then y ∈ U.

For many spaces, ≤_{s} is trivial (in particular when X is T_{1}) but in case X is for example the Alexandroff topology on a poset (X, ≤) as in l), then x ≤_{s} y iff x ≤ y.

Exercise 8. If f : X → Y is a continuous map of topological spaces then f is monotone w.r.t. the specialization orderings ≤_{s}. This defines a functor Top → Pos.

1.2 Some special objects and arrows

We call an arrow f : A → B mono (or a monomorphism, or monomorphic) in a category C, if for any other object C and for any pair of arrows g, h : C → A, fg = fh implies g = h.

In Set, f is mono iff f is an injective function. The same is true for Grp, Grph, Rng, Preord, Pos,…

We call an arrow f : A → B epi (epimorphism, epimorphic) if for any pair g, h : B → C, gf = hf implies g = h.

The definition of epi is “dual” to the definition of mono. That is, f is epi in the category C if and only if f is mono in C^{op}, and vice versa. In general, given a property P of an object, arrow, diagram,… we can associate with P the dual property P^{op}: the object or arrow has property P^{op} in C iff it has P in C^{op}.

The duality principle, a very important, albeit trivial, principle in category theory, says that any valid statement about categories, involving the properties P_{1}, …, P_{n} implies the “dualized” statement (where direction of arrows is reversed) with the P_{i} replaced by P_{i}^{op}. Example. If gf is mono, then f is mono. From this, “by duality”, if fg is epi, then f is epi.

Exercise 9. Prove these statements.

In Set, f is epi iff f is a surjective function. This holds (less trivially!) also for Grp, but not for Mon, the category of monoids and monoid homomorphisms:

In Mon, the embedding ℕ → ℤ is an epimorphism.

For suppose [figure: ℤ; f; g; (M, e, ⋆)] two monoid homomorphisms which agree on the

nonnegative integers. Then

f(−1) = f(−1) ⋆ g(1) ⋆ g(−1) = f(−1) ⋆ f(1) ⋆ g(−1) = g(−1)

so f and g agree on the whole of ℤ.

We say a functor F preserves a property P if whenever an object or arrow (or…) has P, its F -image does so.

Now a functor does not in general preserve monos or epis: the example of Mon shows that the forgetful functor Mon → Set does not preserve epis.

An epi f : A → B is called split if there is g : B → A such that fg = id_{B} (other names: in this case g is called a section of f, and f a retraction of g).

Exercise 10. By duality, define what a split mono is. Prove that every functor preserves split epis and monos.

f : A → B is an isomorphism if there is g : B → A such that fg = id_{B} and gf = id_{A} We call g the inverse of f (and vice versa, of course); it is unique if it exists. We also write g = f^{−1}.

Every functor preserves isomorphisms.

Exercise 11. In Set, every arrow which is both epi and mono is an isomorphism. Not so in Mon, as we have seen. Here’s another one: let CRng1 be the category of commutative rings with 1, and ring homomorphisms (preserving 1) as arrows. Show that the embedding ℤ → ℚ is epi in CRng1.

Exercise 12.

i) If two of f, g and fg are iso, then so is the third;

ii) if f is epi and split mono, it is iso;

iii) if f is split epi and mono, f is iso.

A functor F reflects a property P if whenever the F -image of something (object, arrow,…) has P, then that something has.

A functor F : C → D is called full if for every two objects A, B of C, F : C(A, B) → D(F A, F B) is a surjection. F is faithful if this map is always injective.

Exercise 13. A faithful functor reflects epis and monos.

An object X is called terminal if for any other object Y there is exactly one morphism Y → X in the category. Dually, X is initial if for all Y there is exactly one X → Y.

Exercise 14. A full and faithful functor reflects the property of being a terminal (or initial) object.

\underline{Categories}

Exercise 15. If X and X′ are two terminal objects, they are isomorphic, that is there exists an isomorphism between them. Same for initial objects.

2. Natural transformations

2 Natural transformations

2.1 The Yoneda lemma

A natural transformation between two functors F, G : C → D consists of a family of morphisms (μ_{C} : F C → GC)_{C∈C_{0}} indexed by the collection of objects of C, satisfying the following requirement: for every morphism f : C → C′ in C, the diagram

[figure: F C; F f; μ_{C}; GC; Gf; F C′; μ_{C′}; GC′]

commutes in D (the diagram above is called the naturality square). We say μ = (μ_{C})_{C∈C_{0}} : F ⇒ G and we call μ_{C} the component at C of the natural transformation μ.

Given natural transformations μ : F ⇒ G and ν : G ⇒ H we have a natural transformation νμ = (ν_{C}μ_{C})_{C} : F ⇒ H, and with this composition there is a category DC with functors F : C → D as objects, and natural transformations as arrows.

One of the points of the naturality square condition in the definition of a natural transformation is given by the following proposition. Compare with the situation in Set: denoting the set of all functions from X to Y by Y^{X}, for any set Z there is a bijection between functions Z → Y^{X} and functions Z × X → Y (Set is cartesian closed: see chapter 7).

Proposition 2.1 For categories C, D and E there is a bijection:

Cat(E × C, D) →^{∼} Cat(E, DC)

Proof. Given F : E × C → D define for every object E of E the functor F_{E} : C → D by F_{E}(C) = F (E, C); for f : C → C′ let F_{E}(f) = F (id_{E}, f) : F_{E}(C) = F(E, C) → F(E, C′) = F_{E}(C′)

Given g : E → E′ in E, the family (F (g, id_{C}) : F_{E}(C) → F_{E′}(C))_{C∈C_{0}} is a

natural transformation: F_{E} ⇒ F_{E′}. So we have a functor F ↦ F_{(−)} : E → DC.

Conversely, given a functor G : E → DC we define a functor G̃ : E ×C → D on objects by G̃(E, C) = G(E)(C), and on arrows by G̃(g, f) = G(g)_{C′}G(E)(f) = G(E′)(f)G(g)_{C}:

[figure: G(E)(C) = G̃(E, C); G(E)(f); G(g)_{C}; G̃(E′, C) = G(E′)(C); G(E′)(f); G̃(E, C′); G(g)_{C′}; G̃(E′, C′) = G(E′)(C′)]

Exercise 16. Write out the details. Check that G̃ as just defined, is a functor, and that the two operations

\xymatrix{Cat(E × C, D) \ar[r] & Cat(E, DC) \ar[l]}

are inverse to each other.

An important example of natural transformations arises from the functors h_{C} : C^{op} → Set (see example i) in the preceding chapter); defined on objects by h_{C}(C′) = C(C′, C) and on arrows f : C′′ → C′ so that h_{C}(f) is composition with f: C(C′, C) → C(C′′, C).

Given g : C_{1} → C_{2} there is a natural transformation

h_{g} : h_{C_{1}} ⇒ h_{C_{2}}

whose components are composition with g.

Exercise 17. Spell this out.

We have, in other words, a functor

h_{(−)} : C → Set^{C^{op}}

This functor is also often denoted by Y and listens to the name Yoneda embedding.

An embedding is a functor which is full and faithful and injective on objects. That Y is injective on objects is easy to see, because id_{C} ∈ h_{C}(C) for each object C, and id_{C} is in no other set h_{D}(E); that Y is full and faithful follows from the famous

Proposition 2.2 (Yoneda lemma) For every object F of Set^{C^{op}} and every object C of C, there is a bijection f_{C,F} : Set^{C^{op}}(h_{C}, F) → F (C). Moreover, this bijection is natural in C and F in the following sense: given g : C′ → C in C and μ : F ⇒ F′ in Set^{C^{op}}, the diagram

[figure: Set^{C^{op}}(h_{C}, F); Set^{C_{op}} (g,μ); f_{C,F}; F (C); μ_{C′} F (g)=F′(g)μ_{C}; Set^{C_{op}}(h_{C′}, F′); f_{C′,F′}; F′(C′)]

commutes in Set.

Proof. For every object C′ of C, every element f of h_{C}(C′) = C(C′, C) is equal to id_{C}f which is h_{C}(f)(id_{C}).

If κ = (κ_{C′}|C′ ∈ C_{0}) is a natural transformation: h_{C} ⇒ F then, κ_{C′}(f) must be equal to F (f)(κ_{C}(id_{C})). So κ is completely determined by κ_{C}(id_{C}) ∈ F(C) and conversely, any element of F (C) determines a natural transformation h_{C} ⇒ F.

Given g : C′ → C in C and μ : F ⇒ F′ in Set^{C^{op}}, the map Set^{C^{op}}(g, μ) sends the natural transformation κ = (κ_{C′′}|C′′ ∈ C_{0}) : h_{C} ⇒ F to λ = (λ_{C′′}|C′′ ∈ C_{0}) where λ_{C′′} : h_{C′}(C′′) → F′(C′′) is defined by

λ_{C′′}(h : C′′ → C′) = μ_{C′′}(κ_{C′′}(gh))

Now

f_{C′,F′}(λ) = λ_{C′}(id_{C′})
= μ_{C′}(κ_{C′}(g))
= μ_{C′}(F (g)(κ_{C}(id_{C})))
= (μ_{C′}F (g))(f_{C,F} (κ))

which proves the naturality statement.

Corollary 2.3 The functor Y : C → Set^{C^{op}} is full and faithful.

Proof. Immediate by the Yoneda lemma, since

C(C, C′) ≅ h_{C′}(C) ≅ Set^{C^{op}}(h_{C}, h_{C′})

and this bijection is induced by Y.

The use of the Yoneda lemma is often the following. One wants to prove that objects A and B of C are isomorphic. Suppose one can show that for every object X of C there is a bijection f_{X} : C(X, A) → C(X, B) which is natural in X; i.e. given g : X′ → X in C one has that

[figure: C(X, A); C(g,id_{A}); f_{X}; C(X, B); C(g,id_{B}); C(X′, A); f_{X′}; C(X′, B)]

commutes.

Then one can conclude that A and B are isomorphic in C; for, from what one has just shown it follows that h_{A} and h_{B} are isomorphic objects in Set^{C^{op}}; that is, Y (A) and Y (B) are isomorphic. Since Y is full and faithful, A and B are isomorphic by the following exercise:

Exercise 18. Check: if F : C → D is full and faithful, and F (A) is isomorphic to F (B) in D, then A is isomorphic to B in C.

Exercise 19. Suppose objects A and B are such that for every object X in C there is a bijection f_{X} : C(A, X) → C(B, X), naturally in a sense you define yourself. Conclude that A and B are isomorphic (hint: duality + the previous).

This argument can be carried further. Suppose one wants to show that two functors F, G : C → D are isomorphic as objects of DC. Let’s first spell out what this means:

Exercise 20. Show that F and G are isomorphic in DC if and only if there is a natural transformation μ : F ⇒ G such that all components μ_{C} are isomorphisms (in particular, if μ is such, the family ((μ_{C})^{−1}|C ∈ C_{0}) is also a natural transformation G ⇒ F).

Now suppose one has for each C ∈ C_{0} and D ∈ D_{0} a bijection

D(D, F C) ≅ D(D, GC)

natural in D and C. This means that the objects h_{F C} and h_{GC} of Set^{D^{op}} are isomorphic, by isomorphisms which are natural in C. By full and faithfulness of Y, F C and GC are isomorphic in D by isomorphisms natural in C; which says exactly that F and G are isomorphic as objects of DC.

2.2 Examples of natural transformations

a) Let M and N be two monoids, regarded as categories with one object as in chapter 1. A functor F : M → N is then just the same as a homomorphism of monoids. Given two such, say F, G : M → N, a natural transformation F ⇒ G is (given by) an element n of N such that nF (x) = G(x)n for all x ∈ M;

b) Let P and Q two preorders, regarded as categories. A functor P → Q is a monotone function, and there exists a unique natural transformation between two such, F ⇒ G, exactly if F (x) ≤ G(x) for all x ∈ P.

Exercise 21. In fact, show that if D is a preorder and the category C is small, i.e. the classes C_{0} and C_{1} are sets, then the functor category DC is a preorder.

c) Let U : Grp → Set denote the forgetful functor, and F : Set → Grp the free functor (see chapter 1). There are natural transformations ε : F U ⇒ id_{Grp} and η : id_{Set} ⇒ UF. Given a group G, ε_{G} takes the string σ = g_{1} … g_{n} to the product g_{1} ⋯ g_{n} (here, the “formal inverses” g_{i}^{−1} are interpreted as the real inverses in G!). Given a set A, η_{A}(a) is the singleton string a.

d) Let i : Abgp → Grp be the inclusion functor and r : Grp → Abgp the abelianization functor defined in example m) in chapter 1. There is ε : ri ⇒ id_{Abgp} and η : id_{Grp} ⇒ ir. The components η_{G} of η are the quotient maps G → G/[G, G]; the components of ε are isomorphisms.

e) There are at least two ways to associate a category to a set X: let F (X) be the category with as objects the elements of X, and as only arrows identities (a category of the form F (X) is called discrete; and G(X) the category with the same objects but with exactly one arrow f_{x,y} : x → y for each pair (x, y) of elements of X (We might call G(X) an indiscrete category).

Exercise 22. Check that F and G can be extended to functors: Set → Cat and describe the natural transformation μ : F ⇒ G which has, at each component, the identity function on objects.

f) Every class of arrows of a category C can be viewed as a natural transformation. Suppose S ⊆ C_{1}. Let F (S) be the discrete category on S as in the preceding example. There are the two functors dom, cod : F (S) → C, giving the domain and the codomain, respectively. For every f ∈ S we have f : dom(f) → cod(f), and the family (f|f ∈ S) defines a natural transformation: dom ⇒ cod.

g) Let A and B be sets. There are functors (−)×A : Set → Set and (−)×B : Set → Set. Any function f : A → B gives a natural transformation (−) × A ⇒ (−) × B. h) A category C is called a groupoid if every arrow of C is an isomorphism.

Let C be a groupoid, and suppose we are given, for each object X of C, an arrow μ_{X} in C with domain X.

Exercise 23. Show that there is a functor F : C → C in this case, which acts on objects by F (X) = cod(μ_{X}), and that μ = (μ_{X}|X ∈ C_{0}) is a natural transformation: idC ⇒ F.

i) Given categories C, D and an object D of D, there is the constant functor Δ_{D} : C → D which assigns D to every object of C and id_{D} to every arrow of C.

Every arrow f : D → D′ gives a natural transformation Δ_{f} : Δ_{D} ⇒ Δ_{D′} defined by (Δ_{f})_{C} = f for each C ∈ C_{0}.

j) Let P(X) denote the power set of a set X: the set of subsets of X. The powerset operation can be extended to a functor P : Set → Set. Given a function f : X → Y define P(f) by P(f)(A) = f[A], the image of A ⊆ X under f.

There is a natural transformation η : id_{Set} ⇒ P such that η_{X}(x) = {x} ∈ P(X) for each set X.

There is also a natural transformation μ : PP ⇒ P. Given A ∈ PP(X), so A is a set of subsets of X, we take its union ⋃(A) which is a subset of X. Put μ_{X}(A) = ⋃(A).

2.3 Equivalence of categories; an example

As will become clear in the following chapters, equality between objects plays only a minor role in category theory. The most important categorical notions are only defined “up to isomorphism”. This is in accordance with mathematical practice and with common sense: just renaming all elements of a group does not give you really another group.

We have already seen one example of this: the property of being a terminal object defines an object up to isomorphism. That is, any two terminal objects are isomorphic. There is, in the language of categories, no way of distinguishing between two isomorphic objects, so this is as far as we can get.

However, once we also consider functor categories, it turns out that there is another relation of “sameness” between categories, weaker than isomorphism of categories, and yet preserving all “good” categorical properties. Isomorphism of categories C and D requires the existence of functors F : C → D and G : D → C such that F G = idD and GF = idC; but bearing in mind that we can’t really say meaningful things about equality between objects, we may relax the requirement by just asking that F G is isomorphic to idD in the functor category DD (and the same for GF); doing this we arrive at the notion of equivalence of categories, which is generally regarded as the proper notion of sameness.

So two categories C and D are equivalent if there are functors F : C → D, G : D → C and natural transformations μ : idC ⇒ GF and ν : idD ⇒ FG whose components are all isomorphisms. F and G are called pseudo inverses of each other. A functor which has a pseudo inverse is also called an equivalence of categories.

Exercise 24. Show that a category is equivalent to a discrete category if and only if it is a groupoid and a preorder.

In this section I want to give an important example of an equivalence of categories: the so-called “Lindenbaum-Tarski duality between Set and Complete Atomic Boolean Algebras”. A duality between categories C and D is an equivalence between C^{op} and D (equivalently, between C and D^{op}).

We need some definitions. A lattice is a partially ordered set in which every two elements x, y have a least upper bound (or join) x ∨ y and a greatest lower bound (or meet) x ∧ y; moreover, there exist a least element 0 and a greatest element 1.

Such a lattice is called a Boolean algebra if every element x has a complement ¬x, that is, satisfying x ∨ ¬x = 1 and x ∧ ¬x = 0; and the lattice is distributive, which means that x ∧ (y ∨ z) = (x ∧ y) ∨ (x ∧ z) for all x, y, z.

In a Boolean algebra, complements are unique, for if both y and z are complements of x, then

y = y ∧ 1 = y ∧ (x ∨ z) = (y ∧ x) ∨ (y ∧ z) = 0 ∨ (y ∧ z) = y ∧ z

so y ≤ z; similarly, z ≤ y so y = z. This is a non-example:

[figure: 1; x; z; y; 0]

It is a lattice, and every element has a complement, but it is not distributive (check!).

A Boolean algebra B is complete if every subset A of B has a least upper bound ⋁ A and a greatest lower bound ⋀ A.

An atom in a Boolean algebra is an element x such that 0 < x but for no y we have 0 < y < x. A Boolean algebra is atomic if every x is the join of the atoms below it:

x = ⋁{a|a ≤ x and a is an atom}

The category CABool is defined as follows: the objects are complete atomic Boolean algebras, and the arrows are complete homomorphisms, that is: f : B → C is a complete homomorphism if for every A ⊆ B,

f(⋁ A) = ⋁{f(a)|a ∈ A} and f(⋀ A) = ⋀{f(a)|a ∈ A}

Exercise 25. Show that 1 = ⋀ ∅ and 0 = ⋁ ∅. Conclude that a complete homomorphism preserves 1, 0 and complements.

Exercise 26. Show that ⋀ A = ¬ ⋁{¬a|a ∈ A} and conclude that if a function preserves all ⋁’s, 1 and complements, it is a complete homomorphism.

Theorem 2.4 The category CABool is equivalent to Set^{op}.

Proof. For every set X, P(X) is a complete atomic Boolean algebra and if f : Y → X is a function, then f^{−1} : P(X) → P(Y) which takes, for each subset of X, its inverse image under f, is a complete homomorphism. So this defines a functor F : Set^{op} → CABool.

Conversely, given a complete atomic Boolean algebra B, let G(B) be the set of atoms of B. Given a complete homomorphism g : B → C we have a function G(g) : G(C) → G(B) defined by: G(g)(c) is the unique b ∈ G(B) such that c ≤ g(b). This is well-defined: first, there is an atom b with c ≤ g(b) because 1_{B} = ⋁ G(B) (B is atomic), so 1_{C} = g(1_{B}) = ⋁{g(b)|b is an atom} and:

Exercise 27. Prove: if c is an atom and c ≤ ⋁ A, then there is a ∈ A with c ≤ a (hint: prove for all a, b that a ∧ b = 0 ⇔ a ≤ ¬b, and prove for a, c with c atom: c ≰ a ⇔ a ≤ ¬c).

Secondly, the atom b is unique since c ≤ g(b) and c ≤ g(b′) means c ≤ g(b) ∧ g(b′) = g(b ∧ b′) = g(0) = 0.

So we have a functor G : CABool → Set^{op}.

Now the atoms of the Boolean algebra P(X) are exactly the singleton subsets of X, so GF (X) = {{x}|x ∈ X} which is clearly isomorphic to X. On the other hand, F G(B) = P({b ∈ B|b is an atom}). There is a map from F G(B) to B which sends each set of atoms to its least upper bound in B, and this map is an isomorphism in CABool.

Exercise 28. Prove the last statement: that the map from F G(B) to B, defined in the last paragraph of the proof, is an isomorphism.

3. (Co)cones and (co)limits

3 (Co)cones and (co)limits

3.1 Limits

Given a functor F : C → D, a cone for F consists of an object D of D together with a natural transformation μ : Δ_{D} ⇒ F (Δ_{D} is the constant functor with value D). In other words, we have a family (μ_{C} : D → F (C)|C ∈ C_{0}), and the naturality requirement in this case means that for every arrow f : C → C′ in C,

[figure: D; μ_{C}; μ_{C′}; F (C); F (f); F (C′)]

commutes in D (this diagram explains, I hope, the name “cone”). Let us denote the cone by (D, μ). D is called the vertex of the cone.

A map of cones (D, μ) → (D′, μ′) is a map g : D → D′ such that μ′_{C}g = μ_{C} for all C ∈ C_{0}.

Clearly, there is a category Cone(F) which has as objects the cones for F and as morphisms maps of cones.

A limiting cone for F is a terminal object in Cone(F). Since terminal objects are unique up to isomorphism, as we have seen, any two limiting cones are isomorphic in Cone(F) and in particular, their vertices are isomorphic in D.

A functor F : C → D is also called a diagram in D of type C, and C is the index category of the diagram.

Let us see what it means to be a limiting cone, in some simple, important cases.

i) A limiting cone for the unique functor ! : 0 → D (0 is the empty category) “is” a terminal object in D. For every object D of D determines, together with the empty family, a cone for !, and a map of cones is just an arrow in D. So Cone(!) is isomorphic to D.

ii) Let 2 be the discrete category with two objects x, y. A functor 2 → D is just a pair ⟨A, B⟩ of objects of D, and a cone for this functor consists of

an object C of D and two maps [figure: C; μ_{A}; μ_{B}; A; B] since there are no nontrivial

arrows in 2.

(C, (μ_{A}, μ_{B})) is a limiting cone for ⟨A, B⟩ iff the following holds: for any object D and arrows f : D → A, g : D → B, there is a unique arrow

h : D → C such that [figure: C; μ_{A}; μ_{B}; D; h; f; g; A; B]

commutes. In other words, there is, for any D, a 1-1 correspondence

between maps D → C and pairs of maps \xymatrix{ & D \ar[dl] \ar[dr] \\ A & & B} This is

the property of a product; a limiting cone for ⟨A, B⟩ is therefore called a product cone, and usually denoted:

[figure: A × B; π_{A}; π_{B}; A; B]

The arrows π_{A} and π_{B} are called projections.

iii) Let ˆ2 denote the category [figure: x; a; b; y]. A functor ˆ2 → D is the same thing

as a parallel pair of arrows [figure: A; f; g; B] in D; I write ⟨f, g⟩ for this functor.

A cone for ⟨f, g⟩ is:

[figure: D; μ_{A}; μ_{B}; A; f; g; B]

But μ_{B} = fμ_{A} = gμ_{A} is already defined from μ_{A}, so giving a cone is the same as giving a map μ_{A} : D → A such that fμ_{A} = gμ_{A}. Such a cone is limiting iff for any other map h : C → A with fh = gh, there is a unique k : C → D such that h = μ_{A}k.

We call μ_{A}, if it is limiting, an equalizer of the pair f, g, and the diagram

[figure: D; μ_{A}; A; f; g; B] an equalizer diagram.

In Sets, an equalizer of f, g is isomorphic (as a cone) to the inclusion of {a ∈ A|f(a) = g(a)} into A. In categorical interpretations of logical systems (see chapters 4 and 7), equalizers are used to interpret equality between terms.

Exercise 29. Show that every equalizer is a monomorphism.

Exercise 30. If [figure: E; e; X; f; g; Y] is an equalizer diagram, show that e

is an isomorphism if and only if f = g.

Exercise 31. Show that in Set, every monomorphism fits into an equalizer diagram.

iv) Let J denote the category [figure: y; b; x; a; z] A functor F : J → D is specified

by giving two arrows in D with the same codomain, say f : X → Z, g : Y → Z. A limit for such a functor is given by an object W together

with projections [figure: W; p_{Y}; p_{X}; Y; X] satisfying fp_{X} = gp_{Y}, and such that,

given any other pair of arrows: [figure: V; r; s; Y; X] with gr = fs, there is a

unique arrow V → W such that

[figure: V; s; r; W; p_{X}; p_{Y}; Y; g; X; f; Z]

commutes. The diagram

[figure: W; p_{X}; p_{Y}; Y; g; X; f; Z]

is called a pullback diagram. In Set, the pullback cone for f, g is isomorphic to

{(x, y) ∈ X × Y |f(x) = g(y)}

with the obvious projections.

We say that a category D has binary products (equalizers, pullbacks) iff every functor 2 → D (ˆ2 → D, J → D, respectively) has a limiting cone. Some dependencies hold in this context:

Proposition 3.1 If a category D has a terminal object and pullbacks, it has binary products and equalizers. If D has binary products and equalizers, it has pullbacks.

Proof. Let 1 be the terminal object in D; given objects X and Y, if [figure: C; p_{Y}; p_{X}; X; Y; 1]

is a pullback diagram, then [figure: C; p_{X}; p_{Y}; X; Y] is a product cone.

Given a product cone [figure: A × B; π_{A}; π_{B}; A; B] and maps [figure: X; f; g; A; B] we write

X →^{⟨f,g⟩} A × B for the unique factorization through the product. Write also δ : Y → Y × Y for ⟨id_{Y}, id_{Y}⟩.

Now given f, g : X → Y, if

[figure: E; e; X; ⟨f,g⟩; Y; δ; Y × Y]

is a pullback diagram, then [figure: E; e; X; f; g; Y] is an equalizer diagram. This

proves the first statement.

As for the second: given [figure: X; f; Y; g; Z] let [figure: E; e; X × Y; fπ_{X}; gπ_{Y}; Z] be an equalizer; then

[figure: E; π_{Y} e; π_{X}e; X; f; Y; g; Z]

is a pullback diagram. Exercise 32. Let

[figure: A; a; b; B; f; X; g; Y]

a pullback diagram with f mono. Show that a is also mono. Also, if f is iso (an isomorphism), so is a. Exercise 33. Given:

[figure: A; a; b; B; f; c; C; d; X; g; Y; h; Z]

a) if both squares are pullback squares, then so is the composite square

[figure: A; a; cb; C; d; X; hg; Z]

b) If the right hand square and the composite square are pullbacks, then so is the left hand square.

Exercise 34. f : A → B is a monomorphism if and only if

[figure: A; id_{A}; id_{A}; A; f; A; f; B]

is a pullback diagram.

\underline{Categories}

A monomorphism f : A → B which fits into an equalizer diagram

[figure: A; f; B; g; h; C]

is called a regular mono. Exercise 35. If

[figure: A; b; a; X; g; B; f; Y]

is a pullback and g is regular mono, so is b. Exercise 36. If f is regular mono and epi, f is iso. Every split mono is regular. Exercise 37. Give an example of a category in which not every mono is regular. Exercise 38. In Grp, every mono is regular [This is not so easy]. Exercise 39. In Pos, every mono is regular. Exercise 40. If a category D has binary products and a terminal object, it has all finite products, i.e. limiting cones for every functor into D from a finite discrete category. Exercise 41. Suppose C has binary products and suppose for every ordered

pair (A, B) of objects of C a product cone [figure: A × B; π_{B}; π_{A}; A; B] has been chosen.

a) Show that there is a functor: C × C →^{−×−} C (the product functor) which sends each pair (A, B) of objects to A × B and each pair of arrows (f : A → A′, g : B → B′) to f × g = ⟨fπ_{A}, gπ_{B}⟩.

b) From a), there are functors:

[figure: C × C × C; (−×−)×−; −×(−×−); C]

sending (A, B, C) to \begin{matrix}(A × B) × C \\ A × (B × C) \end{matrix} Show that there is a natural trans-

formation a = (a_{A,B,C}|A, B, C ∈ C_{0}) from (− × −) × − to − × (− × −) such that for any four objects A, B, C, D of C:

[figure: ((A × B) × C) × D; a_{A,B,C}×id_{D}; a_{A×B,C,D}; (A × B) × (C × D); a_{A,B,C×D}; (A × (B × C)) × D; a_{A,B×C,D}; A × (B × (C × D)); A × ((B × C) × D); id_{A}×a_{B,C,D}]

commutes (This diagram is called “MacLane’s pentagon”).

A functor F : C → D is said to preserve limits of type E if for all functors M : E → C, if (D, μ) is a limiting cone for M in C, then (F D, F μ = (F (μ_{E})|E ∈ E_{0})) is a limiting cone for F M in D.

So, a functor F : C → D preserves binary products if for every product dia-

gram [figure: A × B; π_{A}; π_{B}; B; A] its F -image [figure: F (A × B); F (π_{A}); F (π_{B}); F (B); F (A)] is again a product

diagram. Similarly for equalizers and pullbacks.

Some more terminology: F is said to preserve all finite limits if it preserves limits of type E for every finite E. A category which has all finite limits is called lex (left exact), cartesian or finitely complete.

A category is called complete if it has limits of type E for all small E.

In general, limits over large (i.e. not small) diagrams do not exist. For example in Set, there is a limiting cone for the identity functor Set → Set (its vertex is the empty set), but not for the inclusion functor of the subcategory of all nonempty sets into Set.

Exercise 42. If a category C has equalizers, it has all finite equalizers: for every category E of the form

[figure: X; f_{1}; f_{n}; ⋮; Y]

every functor E → C has a limiting cone.

Exercise 43. Suppose F : C → D preserves equalizers (and C has equalizers) and reflects isomorphisms. Then F is faithful.

Exercise 44. Let C be a category with finite limits. Show that for every object C of C, the slice category C/C (example j) of 1.1) has binary products: the vertex of a product diagram for two objects D → C, D′ → C is D′′ → C

where \xymatrix{D′′ \ar[d] \ar[r] & D \ar[d] \\ D′ \ar[r] & C}

is a pullback square in C.

3.2 Limits by products and equalizers

In Set, every small diagram has a limit; given a functor F : E → Set with E small, there is a limiting cone for F in Set with vertex

{(x_{E})_{E∈E_{0}} ∈ ∏_{E∈E_{0}} F (E)|∀E →^{f} E′ ∈ E_{1}(F (f)(x_{E}) = x_{E′})}

So in Set, limits are equationally defined subsets of suitable products. This holds in any category:

Proposition 3.2 Suppose C has all small products (including the empty product, i.e. a terminal object 1) and equalizers; then C has all small limits.

Proof. Given a set I and an I-indexed family of objects (A_{i}|i ∈ I) of C, we denote the product by ∏_{i∈I} A_{i} and projections by π_{i} : ∏_{i∈I} A_{i} → A_{i}; an arrow f : X → ∏_{i∈I} A_{i} which is determined by the compositions f_{i} = π_{i}f : X → A_{i}, is also denoted (f_{i}|i ∈ I).

Now given E → C with E_{0} and E_{1} sets, we construct

[figure: E; e; ∏_{i∈E_{0}} F (i); (π_{cod(u)}|u∈E_{1}); (F (u)π_{dom(u)}|u∈E_{1}); ∏_{u∈E_{1}} F (cod(u))]

in C as an equalizer diagram. The family (μ_{i} = π_{i}e : E → F (i)|i ∈ E_{0}) is a natural transformation Δ_{E} ⇒ F because, given an arrow u ∈ E_{1}, say u : i → j, we have that

[figure: E; π_{i}e; π_{j}e; F (i); F (u); F (j)]

commutes since F (u)π_{i}e = F (u)π_{dom(u)}e = π_{cod(u)}e = π_{j}e.

So (E, μ) is a cone for F, but every other cone (D, ν) for F gives a map d : D → ∏_{i∈E_{0}} F (i) equalizing the two horizontal arrows; so factors uniquely through E.

Exercise 45. Check that “small” in the statement of the proposition, can be replaced by “finite”: if C has all finite products and equalizers, C is finitely complete.

3.3 Colimits

The dual notion of limit is colimit. Given a functor F : E → C there is clearly a functor F^{op} : E^{op} → C^{op} which does “the same” as F. We say that a colimiting cocone for F is a limiting cone for F^{op}.

So: a cocone for F : E → C is a pair (ν, D) where ν : F ⇒ Δ_{D} and a colimiting cocone is an initial object in the category Cocone(F).

Examples

i) a colimiting cocone for ! : 0 → C “is” an initial object of C

ii) a colimiting cocone for ⟨A, B⟩ : 2 → C is a coproduct of A and B in C: usually denoted A + B or A ⊔ B; there are coprojections or coproduct inclusions

[figure: A; ν_{A}; B; ν_{B}; A ⊔ B]

with the property that, given any pair of arrows A →^{f} C, B →^{g} C there is a

unique map [ \begin{matrix}f \\ g \end{matrix} ] : A⊔B → C such that f = [ \begin{matrix}f \\ g \end{matrix} ] ν_{A} and g = [ \begin{matrix}f \\ g \end{matrix} ] ν_{B}

iii) a colimiting cocone for [figure: A; f; g; B] (as functor ˆ2 → C) is given by a map

B →^{c} C satisfying cf = cg, and such that for any B →^{h} D with hf = hg there is a unique C →^{h′} D with h = h′c. c is called a coequalizer for f and g; the diagram \xymatrix{A \ar[r] \ar[r] & B \ar[r] & C} a coequalizer diagram.

Exercise 46. Is the terminology “coproduct inclusions” correct? That is, it suggests they are monos. Is this always the case?

In Set, the coproduct of X and Y is the disjoint union ({0} × X) ∪ ({1} × Y) of X and Y. The coequalizer of [figure: X; f; g; Y] is the quotient map Y → Y/ ∼

where ∼ is the equivalence relation generated by

y ∼ y′ iff there is x ∈ X with f(x) = y and g(x) = y′

The dual notion of pullback is pushout. A pushout diagram is a colimiting

cocone for a functor Γ → C where Γ is the category \xymatrix{x \ar[d] \ar[r] & y \\ z}. Such a diagram

is a square

[figure: X; g; f; Y; a; Z; b; P]

which commutes and such that, given [figure: Y; α; Z; β; Q] with αf = βg, there is a

unique P →^{p} Q with α = pa and β = pb. In Set, the pushout of X →^{f} Y and X →^{g} Z is the coproduct Y ⊔ Z where the two images of X are identified:

[figure: X; Z; X; X; Y; X]

Exercise 47. Give yourself, in terms of X →^{f} Y and X →^{g} Z, a formal definition of a relation R on Y ⊔ Z such that the pushout of f and g is Y ⊔ Z/ ∼, ∼ being the equivalence relation generated by R.

One can now dualize every result and exercise from the section on limits:

Exercise 48. f is epi if and only if

[figure: f; f; id; id]

is a pushout diagram. Exercise 49. Every coequalizer is an epimorphism; if e is a coequalizer of f and g, then e is iso iff f = g Exercise 50. If C has an initial object and pushouts, C has binary coproducts and coequalizers; if C has binary coproducts and coequalizers, C has pushouts.

Exercise 51. If [figure: a; f] is a pushout diagram, then a epi implies f epi, and a regular epi (i.e. a coequalizer) implies f regular epi. Exercise 52. The composition of two puhout squares is a pushout; if both the first square and the composition are pushouts, the second square is. Exercise 53. If C has all small (finite) coproducts and coequalizers, C has all small (finite) colimits. Exercise 54. In Pos, X →^{f} Y is a regular epi if and only if for all y, y′ in Y:

y ≤ y′ ⇔ ∃x ∈ f^{−1}(y)∃x′ ∈ f^{−1}(y′).x ≤ x′

Show by an example that not every epi is regular in Pos. Exercise 55. In Grp, every epi is regular.

\underline{Categories}

28

4. A little piece of categorical logic

4 A little piece of categorical logic

One of the major achievements of category theory in mathematical logic and in computer science, has been a unified treatment of semantics for all kinds of logical systems and term calculi which are the basis for programming languages.

One can say that mathematical logic, seen as the study of classical first order logic, first started to be a real subject with the discovery, by Gödel, of the completeness theorem for set-theoretic interpretations: a sentence φ is provable if and only if φ is true in all possible interpretations. This unites the two approaches to logic: proof theory and model theory, makes logic accessible for mathematical methods and enables one to give nice and elegant proofs of proof theoretical properties by model theory (for example, the Beth and Craig definability and interpolation theorems).

However the completeness theorem needs generalization once one considers logics, such as intuitionistic logic (which does not admit the principle of excluded middle), minimal logic (which has no negation) or modal logic (where the logic has an extra operator, expressing “necessarily true”), for which the set-theoretic interpretation is not complete. One therefore comes with a general definition of “interpretation” in a category C of a logical system, which generalizes Tarski’s truth definition: this will then be the special case of classical logic and the category Set.

In this chapter I treat, for reasons of space, only a fragment of first order logic: coherent logic. On this fragment the valid statements of classical and intuitionistic logic coincide.

For an interpretation of a term calculus like the λ-calculus, which is of paramount importance in theoretical computer science, the reader is referred to chapter 7.

4.1 Regular categories and subobjects

Definition 4.1 A category C is called regular if the following conditions hold:

a) C has all finite limits;

b) For every arrow f, if

[figure: Z; p_{1}; p_{0}; X; f; X; f; Y]

is a pullback (then [figure: Z; p_{0}; p_{1}; X] is called the kernel pair of f), the coequal-

izer of p_{0}, p_{1} exists; c) Regular epimorphisms (coequalizers) are stable under pullback, that is: in

a pullback square

[figure: a; f]

if f is regular epi, so is a.

Exercise 56. Set is regular. Prove that Pos is regular. Show that Top is not regular [the case of Top may cause you some trouble; don’t worry].

Proposition 4.2 In a regular category, every arrow f : X → Y can be factored as f = me : X →^{e} E →^{m} Y where e is regular epi and m is mono; and this factorization is unique in the sense that if f is also m′e′ : X →^{e′} E′ →^{m′} Y with m′ mono and e′ regular epi, there is an isomorphism σ : E → E′ such that σe = e′ and m′σ = m.

Proof. Given f : X → Y we let X →^{e} E be the coequalizer of the kernel pair

[figure: Z; p_{0}; p_{1}; X] of f. Since fp_{0} = fp_{1} there is a unique m : E → Y such that

f = me. By construction e is regular epi; we must show that m is mono, and the uniqueness of the factorization.

Suppose mg = mh for g, h : W → E; we prove that g = h. Let

[figure: V; ⟨q_{0},q_{1}⟩; a; W; ⟨g,h⟩; X × X; e×e; E × E]

be a pullback square. Then

fq_{0} = meq_{0} = mga = mha = meq_{1} = fq_{1}

so there is a unique arrow V →^{b} Z such that ⟨q_{0}, q_{1}⟩ = ⟨p_{0}, p_{1}⟩b : V → X × X (because of the kernel pair property). It follows that

ga = eq_{0} = ep_{0}b = ep_{1}b = eq_{1} = ha

I claim that a is epi, so it follows that g = h. It is here that we use the requirement that regular epis are stable under pullback. Now e × e : X × X → E × E is the composite

X × X →^{e×id_{X}} E × X →^{id_{E}×e} E × E

and both maps are regular epis since both squares

[figure: X × X; π_{0}; e×id_{X}; E × X; π_{0}; X; e; E; and; E × X; π_{1}; id_{E}×e; E × E; π_{1}; X; e; E]

are pullbacks. The map a, being the pullback of a composite of regular epis, is then itself the composite of regular epis (check this!), so in particular epi.

This proves that m is mono, and we have our factorization.

As to uniqueness, suppose we had another factorization f = m′e′ with m′ mono and e′ regular epi. Then m′e′p_{0} = fp_{0} = fp_{1} = m′e′p_{1} so since m′ mono, e′p_{0} = e′p_{1}. Because e is the coequalizer of p_{0} and p_{1}, there is a unique σ:

[figure: e; e′; σ] Then m′σe = m′e′ = f = me so since e epi, m = m′σ.

Now e′ : X → E′ is a coequalizer; say [figure: U; k; l; X; e′; E′] is a coequalizer

diagram. Then it follows that ek = el (since mek = m′e′k = m′e′l = mel and

m mono) so there is a unique τ: [figure: e; e′; τ] Then mτσe = mτe′ = me; since m

mono and e epi, τσ = id_{E}. Similarly, στ = id_{E′}. So σ is the required isomorphism.

Exercise 57. Check this detail: in a regular category C, if [figure: a; b]is a

pullback diagram and b = c_{1}c_{2} with c_{1} and c_{2} regular epis, then a = a_{1}a_{2} for some regular epis a_{1}, a_{2}.

Subobjects. In any category C we define a subobject of an object X to be an equivalence class of monomorphisms Y →^{m} X, where Y →^{m} X is equivalent to Y′ →^{m′} X if there is an isomorphism σ : Y → Y′ with m′σ = m (then mσ^{−1} = m′

follws). We say that Y →^{m} X represents a smaller subobject than Y′ →^{m′} X if there is σ : Y → Y′ with m′σ = m (σ not necessarily iso; but check that σ is always mono).

The notion of subobject is the categorical version of the notion of subset in set theory. In Set, two injective functions represent the same subobject iff their images are the same; one can therefore identify subobjects with subsets. Note however, that in Set we have a “canonical” choice of representative for each subobject: the inclusion of the subset to which the subobject corresponds. This choice is not always available in general categories.

We have a partial order Sub(X) of subobjects of X, ordered by the smallerthan relation.

Proposition 4.3 In a category C with finite limits, each pair of elements of Sub(X) has a greatest lower bound. Moreover, Sub(X) has a largest element.

Proof. If Y →^{m} X and Y′ →^{m′} X represent two subobjects of X and [figure: Z; Y; m; Y′; m′; X]

is a pullback, then Z → X is mono, and represents the greatest lower bound (check!).

Of course, the identity X →^{id_{X}} X represents the top element of Sub(X). Because the factorization of X →^{f} Y as X →^{e} E →^{m} Y with e regular epi and m mono, in a regular category C, is only defined up to isomorphism, it defines rather a subobject of Y than a mono into Y; this defined subobject is called the image of f and denoted Im(f) (compare with the situation in Set).

Exercise 58. Im(f) is the smallest subobject of Y through which f factors: for a subobject represented by n : A → Y we have that there is X →^{a} A with f = na, if and only if Im(f) is smaller than the subobject represented by n.

Since monos and isos are stable under pullback, in any category C with pullbacks, any arrow f : X → Y determines an order preserving map f^{∗} : Sub(Y) → Sub(X) by pullback along f: if E →^{m} Y represents the subobject M of Y and

[figure: F; n; E; m; X; f; Y] is a pullback, F →^{n} X represents f^{∗}(M).

Exercise 59. Check that f^{∗} is well defined and order preserving.

Proposition 4.4 In a regular category, each f^{∗} preserves greatest lower bounds and images, that is: for f : X → Y,

i) for subobjects M, N of Y, f^{∗}(M ∧ N) = f^{∗}(M) ∧ f^{∗}(N);

ii) if [figure: g′; g; f] is a pullback, then f^{∗}(Im(g)) = Im(g′).

Exercise 60. Prove proposition 4.4.

4.2 Coherent logic in regular categories

The fragment of first order logic we are going to interpret in regular categories is the so-called coherent fragment.

The logical symbols are = (equality), ∧ (conjunction) and ∃ (existential quantification). A language consists of a set of sorts S, T, …; a denumerable collection of variables x_{1}^{S}, x_{2}^{S}, … of sort S, for each sort; and a collection of function symbols (f : S_{1}, …, S_{n} → S). The case n = 0 is not excluded (one thinks of constants of a sort), but not separately treated. We now define, inductively, terms of sort S and formulas.

Definition 4.5 Terms of sort S are defined by:

i) x^{S} is a term of sort S if x^{S} is a variable of sort S;

ii) if t_{1}, …, t_{n} are terms of sorts S_{1}, …, S_{n} respectively, and

(f : S_{1}, … S_{n} → S)

is a function symbol of the language, then f(t_{1}, …, t_{n}) is a term of sort S.

Formulas are defined by:

i) ⊤ is a formula (the formula “true”);

ii) if t and s are terms of the same sort, then t = s is a formula;

iii) if φ and ψ are formulas then (φ ∧ ψ) is a formula;

iv) if φ is a formula and x a variable of some sort, then ∃xφ is a formula.

An interpretation of such a language in a regular category C starts by choosing for each sort S an object [[ S]] of C, and for each function symbol (f : S_{1}, …, S_{n} → S) of the language, an arrow [[ f ]] : [[ S_{1} ]] × ⋯ × [[ S_{n}]] → [[ S]] in C.

Given this, we define interpretations [[ t]] for terms t and [[ φ]] for formulas φ, as follows.

Write F V (t) for the set of variables which occur in t, and F V (φ) for the set of free variables in φ.

We put [[ F V (t) ]] = [[ S_{1} ]] × ⋯ × [[ S_{n}]] if F V (t) = {x_{1}^{S_{1}}, …, x_{n}^{S_{n}}}; the same for [[ F V (φ) ]]. Note: in the products [[ F V (t) ]] and [[ F V (φ) ]] we take a copy of [[ S]] for every variable of sort S! Let me further emphasize that the empty product is 1, so if F V (t) (or F V (φ)) is ∅, [[ F V (t) ]] (or [[ F V (φ) ]]) is the terminal object of the category.

Definition 4.6 The interpretation of a term t of sort S is a morphism [[ t]] : [[ F V (t) ]] → [[ S]] and is defined by the clauses:

i) [[ x^{S} ]] is the identity on [[ S]], if x^{S} is a variable of sort S;

ii) Given [[ t_{i}]] : [[ F V (t_{i}) ]] → [[ S_{i}]] for i = 1, …, n and a function symbol (f : S_{1}, …, S_{n} → S) of the language, [[ f(t_{1}, …, t_{n}) ]] is the map

[figure: [[ F V (f(t_{1}, …, t_{n})) ]]; (t̃_{i}|i=1,...,n); ∏_{i=1}^{n}[[ S_{i}]]; [[ f ]]; [[ S]]]

where t̃_{i} is the composite

[figure: [[ F V (f(t_{1}, …, t_{n})) ]]; π_{i}; [[ F V (t_{i}) ]]; [[ t_{i} ]]; [[ S_{i}]]]

in which π_{i} is the appropriate projection, corresponding to the inclusion F V (t_{i}) ⊆ F V (f(t_{1}, …, t_{n})).

Finally, we interpret formulas φ as subobjects [[ φ]] of [[ F V (φ) ]]. You should try to keep in mind the intuition that [[ φ(x_{1}, …, x_{n}) ]] is the “subset”

{(a_{1}, …, a_{n}) ∈ A_{1} × ⋯ × A_{n}|φ[a_{1}, …, a_{n}]}

Definition 4.7 The interpretation [[ φ]] as subobject of [[ F V (φ) ]] is defined as follows:

i) [[ ⊤]] is the maximal subobject of [[ F V (⊤) ]] = 1;

ii) [[ t = s]] → [[ F V (t = s) ]] is the equalizer of

[figure: [[ F V (t = s) ]]; \begin{matrix}[[ F V (t) ]] \\ [[ F V (s) ]] \end{matrix}; [[ t]]; [[ s]]; [[ T ]]]

if t and s are of sort T; again, the left hand side maps are projections, corresponding to the inclusions of F V (t) and F V (s) into F V (t = s);

iii) if [[ φ]] → [[ F V (φ) ]] and [[ ψ]] → [[ F V (ψ) ]] are given and

[figure: [[ F V (φ ∧ ψ) ]]; π_{1}; π_{2}; [[ F V (φ) ]]; [[ F V (ψ) ]]]

are again the suitable projections, then [[ (φ ∧ ψ) ]] → [[ F V (φ ∧ ψ) ]] is the greatest lower bound in Sub([[ F V (φ ∧ ψ) ]]) of π_{1}^{∗}([[ φ]]) and π_{2}^{∗}([[ ψ]]); iv) if [[ φ]] → [[ F V (φ) ]] is given and π : [[ F V (φ) ]] → [[ F V (∃xφ) ]] the projec-

tion, let [[ F V′(φ) ]] be the product of the interpretations of the sorts of the variables in F V (φ) ∪ {x} (so [[ F V′(φ) ]] = [[ F V (φ) ]] if x occurs freely in φ; and [[ F V′(φ) ]] = [[ F V (φ) ]] × [[ S]] if x = x^{S} does not occur free in φ). Write π′ : [[ F V′(φ) ]] → [[ F V (φ) ]].

Now take [[ ∃xφ]] → [[ F V (∃xφ) ]] to be the image of the composition:

(π′)^{∗}([[ φ]]) → [[ F V′(φ) ]] →^{ππ′} [[ F V (∃xφ) ]]

We have now given an interpretation of formulas. Basically, a formula φ is true under this interpretation if [[ φ]] → [[ F V (φ) ]] is the maximal subobject; but since we formulate the logic in terms of sequents we rather define when a sequent is true under the interpretation.

Definition 4.8 A labelled sequent is an expression of the form ψ ⊢_{σ} φ or ⊢_{σ} φ where ψ and φ are the formulas of the sequent (but ψ may be absent), and σ is a finite set of variables which includes all the variables which occur free in a formula of the sequent.

Let [[ σ]] = [[ S_{1} ]] × ⋯ × [[ S_{n}]] if σ = {x_{1}^{S_{1}}, …, x_{n}^{S_{n}}}; there are projections [[ σ]] →^{π_{φ}} [[ F V (φ) ]] and (in case ψ is there) [[ σ]] →^{π_{ψ}} [[ F V (ψ) ]]; we say that the sequent ψ ⊢_{σ} φ is true for the interpretation if (π_{ψ})^{∗}([[ ψ]]) ≤ (π_{φ})^{∗}([[ φ]]) as subobjects of [[ σ]], and ⊢_{σ} φ is true if (π_{φ})^{∗}([[ φ]]) is the maximal subobject of [[ σ]].

Exercise 61. Show that the sequent ⊢ ∃x^{S}(x^{S} = x^{S}) is true if and only if the unique map [[ S]] → 1 is a regular epimorphism.

We now turn to the logic. Instead of giving deduction rules and axioms, I formulate a list of closure conditions which determine what sets of labelled sequents will be called a theory. I write ⊢_{x} for ⊢_{{x}} and ⊢ for ⊢_{∅}.

Definition 4.9 Given a language, a set T of labelled sequents of that language is called a theory iff the following conditions hold (the use of brackets around ψ caters in a, I hope, self-explanatory way for the case distiction as to whether ψ is or is not present):

i) ⊢ ⊤ is in T; ⊢_{x} x = x is in T for every variable x; x = y ∧ y = z ⊢_{{x,y,z}} x = z is in T for variables x, y, z of the same sort;

ii) if (ψ) ⊢_{σ} φ is in T then (ψ) ⊢_{τ} φ is in T whenever σ ⊆ τ;

iii) if (ψ) ⊢_{σ} φ is in T and F V (χ) ⊆ σ then (ψ∧)χ ⊢_{σ} φ and χ(∧ψ) ⊢_{σ} φ are in T; iv) if (ψ) ⊢_{σ} φ and (ψ) ⊢_{σ} χ are in T then (ψ) ⊢_{σ} φ ∧ χ and (ψ) ⊢_{σ} χ ∧ φ

are in T;

v) if ψ ⊢_{σ} φ is in T and x is a variable not occurring in φ then ∃xψ ⊢_{σ\{x}} φ is in T;

vi) if x occurs in φ and (ψ) ⊢_{σ} φ[t/x] is in T then (ψ) ⊢_{σ} ∃xφ is in T; if x does not occur in φ and (ψ) ⊢_{σ} φ and (ψ) ⊢_{σ} ∃x(x = x) are in T, then (ψ) ⊢_{σ} ∃xφ is in T;

vii) if (ψ) ⊢_{σ} φ is in T then (ψ[t/x]) ⊢_{σ\{x}∪F V (t)} φ[t/x] is in T;

viii) if (ψ) ⊢_{σ} φ[t/x] and (ψ) ⊢_{σ} t = s are in T then (ψ) ⊢_{σ} φ[s/x] is in T;

ix) if (ψ) ⊢_{σ} φ and φ ⊢ χ are in T then (ψ) ⊢_{σ} χ is in T

Exercise 62. Show that the sequent φ ⊢_{F V (φ)} φ is in every theory, for every formula φ of the language.

As said, the definition of a theory is a list of closure conditions: every item can be seen as a rule, and a theory is a set of sequents closed under every rule. Therefore, the intersection of any collection of theories is again a theory, and it makes sense to speak, given a set of sequents S, of the theory Cn(S) generated by S:

Cn(S) = ⋂{T |T is a theory and S ⊆ T }

We have the following theorem:

Theorem 4.10 (Soundness theorem) Suppose T = Cn(S) and all sequents of S are true under the interpretation in the category C. Then all sequents of T are true under that interpretation.

Before embarking on the proof, first a lemma:

Lemma 4.11 Suppose t is substitutable for x in φ. There is an obvious map

[t] : [[ F V (φ) \ {x} ∪ F V (t) ]] = [[ F V (φ[t/x]) ]] → [[ F V (φ) ]]

induced by [[ t]]; the components of [t] are projections except for the factor of [[ φ]] corresponding to x, where it is

[[ F V (φ[t/x]) ]] → [[ F V (t) ]] →^{[[ t]]} [[ {x}]]

There is a pullback diagram:

[figure: [[ φ[t/x] ]]; [[ F V (φ[t/x]) ]]; [t]; [[ φ]]; [[ F V (φ) ]]]

Exercise 63. Prove this lemma [not trivial. Use induction on φ and proposition 4.4].

Proof. (of theorem 4.10) The proof checks that for every rule in the list of definition 4.9, if the premiss is true then the conclusion is true; in other words, that the set of true sequents is a theory.

i) ⊢ ⊤ is true by the definition [[ ⊤]] = 1; [[ x^{S} = x^{S} ]] is the equalizer of two maps which are both the identity on [[ S]], so isomorphic to [[ S]]. For x = y ∧ y = z ⊢_{{x,y,z}} x = z, just observe that E_{12} ∧ E_{23} ≤ E_{13} if E_{ij} is the equalizer of the two projections π_{i}, π_{j} : [[ S]] × [[ S]] × [[ S]] → [[ S]]. ii) This is because if σ ⊆ τ and ρ : [[ τ ]] → [[ σ]] is the projection, ρ^{∗} is monotone. iii)-iv) By the interpretation of ∧ as the greatest lower bound of two subobjects, and proposition 4.4.

v) Let

[figure: [[ σ]]; μ; π; [[ σ \ {x}]]; ν; ρ; [[ F V (φ) ]]; [[ F V (ψ) ]]; [[ F V (∃xψ) ]]]

the projections. Since by assumption μ^{∗}([[ ψ]]) ≤ (ρπ)^{∗}([[ φ]]) there is a commutative diagram

[figure: μ^{∗}([[ ψ]]); [[ σ]]; π; ρ^{∗}([[ φ]]); [[ σ \ {x}]]]

By proposition 4.4, ν^{∗}([[ ∃xψ]]) is the image of the map μ^{∗}([[ ψ]]) → [[ σ \ {x}]], so ν^{∗}([[ ψ]]) ≤ ρ^{∗}([[ φ]]) in Sub([[ σ \ {x}]]). vi) Suppose x occurs free in φ. Consider the commutative diagram

[figure: [[ σ]]; π; π′; π′′; [[ F V (ψ) ]]; [[ F V (φ[t/x]) ]]; [t]; [[ F V (φ) ]]; ρ; [[ F V (φ) \ {x}]]]

with [t] as in lemma 4.11 and the other maps projections. Now [[ φ]] ≤ ρ^{∗}([[ ∃xφ]]) because [[ φ]] → [[ F V (φ) ]] →^{ρ} [[ F V (φ) \ {x}]] factors through [[ ∃xφ]] by definition; so if π^{∗}([[ ψ]]) ≤ π^{′∗}([[ φ[t/x] ]]) then with lemma 4.11,

π^{∗}([[ ψ]]) ≤ π^{′∗}([[ φ[t/x] ]]) = π^{′∗}[t]^{∗}([[ φ]]) ≤ π^{′∗}[t]^{∗}ρ^{∗}([[ ∃xφ]]) = π^{′′∗}([[ ∃xφ]])

in Sub([[ σ]]) and we are done.

The case of x not occurring in φ is left to you. vii) Direct application of lemma 4.11 viii-ix) Left to you.

Exercise 64. Fill in the “left to you” gaps in the proof.

4.3 The language L(C) and theory T (C) associated to a regular category C

Given a regular category C (which, to be precise, must be assumed to be small), we associate to C the language which has a sort C for every object of C, and a function symbol (f : C → D) for every arrow f : C → D of C.

This language is called L(C) and it has trivially an interpretation in C.

The theory T (C) is the set of sequents of L(C) which are true for this interpretation.

One of the points of categorical logic is now, that categorical statements about objects and arrows in C can be reformulated as statements about the truth of certain sequents in L(C). You should read the relevant sequents as expressing that we can “do as if the category were Set”.

Examples

a) C is a terminal object of C if and only if the sequents ⊢_{x,y} x = y and ⊢ ∃x(x = x) are valid, where x, y variables of sort C;

b) the arrow f : A → B is mono in C if and only if the sequent f(x) = f(y) ⊢_{x,y} x = y is true;

c) The square

[figure: A; g; f; B; h; C; d; D]

is a pullback square in C if and only if the sequents

h(x^{B}) = d(y^{C}) ⊢_{x,y} ∃z^{A}(f(z) = x ∧ g(z) = y)

and

f(z^{A}) = f(z^{′A}) ∧ g(z^{A}) = g(z^{′A}) ⊢_{z,z′} z = z′

are true; d) the fact that f : A → B is epi can not similarly be expressed! But: f is

regular epi if and only if

⊢_{x^{B}} ∃y^{A}(f(y) = x)

is true;

e) [figure: A; f; B; g; h; C] is an equalizer diagram iff f is mono (see b) and the

sequent

g(x^{B}) = h(x^{B}) ⊢_{x^{B}} ∃y^{A}(f(y) = x)

is true.

Exercise 65. Check (a number of) these statements. Give the sequent(s) cor-

responding to the statement that [figure: A; g; f; B; C] is a product diagram.

Exercise 66. Check that the formulas ∃xφ and ∃x(x = x ∧ φ) are equivalent, that is, every theory contains the sequents

∃xφ ⊢_{σ} ∃x(x = x ∧ φ)

and

∃x(x = x ∧ φ) ⊢_{σ} ∃xφ

for any σ containing the free variables of ∃xφ.

Exercise 67. Can you express: A →^{f} B is regular mono?

4.4 Example of a regular category

In this section, I treat an example of a type of regular categories which are important in categorical logic. They are categories of Ω-valued sets for some frame Ω. Let’s define some things.

Definition 4.12 A frame Ω is a partially ordered set which has suprema (least upper bounds) ⋁ B of all subsets B, and infima (meets) ⋀ A for finite subsets A (so, there is a top element ⊤ and every pair of elements x, y has a meet x ∧ y), and moreover, ∧ distributes over ⋁, that is,

x ∧ ⋁ B = ⋁{x ∧ b|b ∈ B}

for x ∈ Ω, B ⊆ Ω.

Given a frame Ω we define the category C_{Ω} as follows: Objects are functions X →^{E_{X}} Ω, X a set; Maps from (X, E_{X}) to (Y, E_{Y}) are functions X →^{f} Y satisfying the requirement that E_{X}(x) ≤ E_{Y} (f(x)) for all x ∈ X. It is easily seen that the identity function satisfies this requirement, and if two composable functions satisfy it, their composition does; so we have a category.

Proposition 4.13 C_{Ω} is a regular category.

Proof. Let {∗} be any one-element set, together with the function which sends ∗ to the top element of Ω. Then {∗} → Ω is a terminal object of C_{Ω}.

Given (X, E_{X}) and (Y, E_{Y}), a product of the two is the object (X×Y, E_{X×Y}) where E_{X×Y} (x, y) is defined as E_{X}(x) ∧ E_{Y} (y).

Given two arrows f, g : (X, E_{X}) → (Y, E_{Y}) their equalizer is (X′, E_{X′}) where X′ ⊆ X is {x ∈ X|f(x) = g(x)} and E_{X′} is the restriction of E_{X} to X′.

This is easily checked, and C_{Ω} is a finitely complete category.

An arrow f : (X, E_{X}) → (Y, E_{Y}) is regular epi if and only if the function f is surjective and for all y ∈ Y, E_{Y} (y) = ⋁ f^{−1}(y).

For suppose f is such, and g : (X, E_{X}) → (Z, E_{Z}) coequalizes the kernel pair of f. Then g(x) = g(x′) whenever f(x) = f(x′), and so for all y ∈ Y, since f(x) = y implies E_{X}(x) ≤ E_{Z}(g(x)), we have

E_{Y} (y) = ⋁{E_{X}(x)|f(x) = y} ≤ E_{Z}(g(x))

so there is a unique map h : (Y, E_{Y}) → (Z, E_{Z}) such that g = hf; that is f is the coequalizer of its kernel pair.

The proof of the converse is left to you.

Finally we must show that regular epis are stable under pullback. This is an exercise.

Exercise 68. Show that the pullback of [figure: X; f; Y; g; Z] (I suppress reference

to the E_{X} etc.) is (up to isomorphism) the set {(x, y)|f(x) = g(y)}, with E(x, y) = E_{X}(x) ∧ E_{Y} (y); and then, use the distributivity of Ω to show that regular epis are stable under pullback.

Exercise 69. Fill in the other gap in the proof: if f : (X, E_{X}) → (Y, E_{Y}) is a regular epi, then f satisfies the condition given in the proof.

Exercise 70. Given (X, E_{X}) →^{f} (Y, E_{Y}), give the interpretation of the formula ∃x(f(x) = y), as subobject of (Y, E_{Y}).

Exercise 71. Characterize those objects (X, E_{X}) for which the unique map to the terminal object is a regular epimorphism.

Exercise 72. Give a categorical proof of the statement: if f is the coequalizer of something, it is the coequalizer of its kernel pair.

Exercise 73. Characterize the regular monos in C_{Ω}.

\underline{Categories}

42

5. Adjunctions

5 Adjunctions

The following kind of problem occurs quite regularly: suppose we have a functor C →^{G} D and for a given object D of D, we look for an object G(C) which “best approximates” D, in the sense that there is a map D →^{η} G(C) with the property that any other map D →^{g} G(C′) factors uniquely as G(f)η for f : C → C′ in C.

We have seen, that if G is the inclusion of Abgp into Grp, the abelianization of a group is an example. Another example is the Čech-Stone compactification in topology: for an arbitrary topological space X one constructs a compact space βX out of it, and a map X → βX, such that any continuous map from X to a compact space factors uniquely through this map.

Of course, what we described here is a sort of “right-sided” approximation; the reader can define for himself what the notion for a left-sided approxiamtion would be.

The categorical description of this kind of phenomena goes via the concept of adjunction, which this chapter is about.

5.1 Adjoint functors

Let [figure: C; G; D; F] be a pair of functors between categories C and D.

We say that F is left adjoint to G, or G is right adjoint to F, notation: F ⊣ G, if there is a natural bijection:

[figure: C(F D, C); m_{D,C}; D(D, GC)]

for each pair of objects C ∈ C_{0}, D ∈ D_{0}. Two maps f : F D → C in C and g : D → GC in D which correspond to each other under this correspondence are called transposes of each other.

The naturality means that, given f : D → D′, g : C′ → C in D and C respectively, the diagram

[figure: C(F D, C); m_{D,C}; D(D, GC); C(F D′, C′); C(F f,g); m_{D′,C′}; D(D′, GC′); D(f,Gg)]

commutes in Set. Remind yourself that given α : F D′ → C′, C(F f, g)(α) : F D → C is the composite

[figure: F D; F f; F D′; α; C′; g; C]

Such a family m = (m_{D,C}|D ∈ D_{0}, C ∈ C_{0}) is then completely determined by the values it takes on identities; i.e. the values

m_{D,F D}(id_{FD}) : D → GFD

For, given α : F D → C, since α = C(id_{FD}, α)(id_{FD}),

m_{D,C}(α) = m_{D,C}(C(id_{FD}, α)(id_{FD}))  =
D(id_{D}, G(α))(m_{D,FD}(id_{FD}))

which is the composite

[figure: D; m_{D,F D}(id_{FD}); GF D; G(α); G(C)]

The standard notation for m_{D,F D}(id_{FD}) is η_{D} : D → GF (D).

Exercise 74. Show that (η_{D} : D ∈ D_{0}) is a natural transformation:

idD ⇒ GF

By the same reasoning, the natural family (m_{D,C}^{−1}|D ∈ D_{0}, C ∈ C_{0}) is completely determined by its actions on identities

m_{GC,C}^{−1}(id_{GC}) : FGC → C

Again, the family (m_{GC,C}^{−1}(id_{GC})|C ∈ C_{0}) is a natural transformation: F G ⇒ idC. We denote its components by ε_{C} and this is also standard notation.

We have that m_{D,C}^{−1}(β : D → GC) is the composite

[figure: F D; F β; F GC; ε_{C}; C]

Now making use of the fact that m_{D,C} and m_{D,C}^{−1} are each others inverse we get that for all α : F D → C and β : D → GC the diagrams

[figure: D; η_{D}; β; GC; GF D; GF (β); GF G(C); G(ε_{C}); and; F D; α; F (η_{D}); C; F GF D; F G(α); F GC; ε_{C}]

commute; applying this to the identities on F D and GC we find that we have commuting diagrams of natural transformations:

[figure: G; η⋆G; id_{G}; GF G; G∘ε; G; F; F ∘η; id_{F}; F GF; ε⋆F; F]

Here η ⋆ G denotes (η_{GC}|C ∈ C_{0}) and G ∘ ε denotes (G(ε_{C})|C ∈ C_{0}).

Conversely, given [figure: C; G; D; F] with natural transformations η : idD ⇒ GF

and ε : F G ⇒ idC which satisfy the above triangle equalities, we have that F ⊣ G.

The tuple (F, G, ε, η) is called an adjunction. η is the unit of the adjunction, ε the counit.

Exercise 75. Prove the last statement, i.e. given [figure: C; G; D; F] , η : idD ⇒ GF

and ε : F G ⇒ idC satisfying (G ∘ ε) · (η ⋆ G) = id_{G} and (ε ⋆ F) · (F ∘ η) = id_{F}, we have F ⊣ G.

Exercise 76. Given [figure: C; G_{1}; D; F_{1}; G_{2}; E; F_{2}] , if F_{1} ⊣ G_{1} and F_{2} ⊣ G_{2} then

F_{1}F_{2} ⊣ G_{2}G_{1}.

Examples. The world is full of examples of adjoint functors. We have met several:

a) Consider the forgetful functor U : Grp → Set and the free functor F : Set → Grp. Given a function from a set A to a group G (which is an arrow A → U(G) in Set) we can uniquely extend it to a group homomorphism from (Ã, ⋆) to G (see example e) of 1.1), i.e. an arrow F (A) → G in Grp, and conversely. This is natural in A and G, so F ⊣ U;

b) The functor Dgrph → Cat given in example f) of 1.1 is left adjoint to the forgetful functor Cat → Dgrph;

c) Given functors [figure: P; G; Q; F] between two preorders P and Q, F ⊣ G if and

only if we have the equivalence

y ≤ G(x) ⇔ F (y) ≤ x

for x ∈ P, y ∈ Q; if and only if we have F G(x) ≤ x and y ≤ GF (y) for all x, y; d) In example m) of 1.1 we did “abelianization” of a group G. We made

use of the fact that any homomorphism G → H with H abelian, factors uniquely through G/[G, G], giving a natural 1-1 correspondence

Grp(G, I(H)) →^{∼} Abgp(G/[G, G], H)

where I : Abgp → Grp is the inclusion. So abelianization is left adjoint to the inclusion functor of abelian groups into groups;

e) The free monoid F (A) on a set A is just the set of strings on the alphabet A. F : Set → Mon is a functor left adjoint to the forgetful functor from Mon to Set;

f) Given a set X we have seen (example g) of 2.2) the product functor (−) × X : Set → Set, assigning the product Y × X to a set Y.

Since there is a natural bijection between functions Y × X → Z and functions Y → Z^{X}, the functor (−)^{X} : Set → Set is right adjoint to (−) × X;

g) Example e) of 2.2 gives two functors F, G : Set → Cat. F and G are respectively left and right adjoint to the functor Cat →^{Ob} Set which assigns to a (small) category its set of objects (to be precise, for this example to work we have to take for Cat the category of small categories), and to a functor its action on objects.

h) Given a regular category C we saw in 4.1 that every arrow f : X → Y can be factored as a regular epi followed by a monomorphism. This gives rise to a monotone function: Sub(X) →^{Im_{f}} Sub(Y) defined as follows: if M ∈ Sub(X) is represented by m, Im_{f}(M) is the image of fm (see 4.1). We have seen that Im_{f}(M) ≤ N ⇔ M ≤ f^{∗}(N) for any subobject N of Y, so Im_{f} is left adjoint to f^{∗}.

We can also express this logically: in the logic developed in chapter 4, for any formulas M(x) and N(y), the sequents

∃x(f(x) = y ∧ M(x)) ⊢_{y} N(y)

and

M(x) ⊢_{x} N(f(x))

are equivalent.

One of the slogans of categorical logic is therefore, that “existential quantification is left adjoint to substitution”. i) Let C be a category with finite products; for C ∈ C_{0} consider the slice

category C/C. There is a functor C^{∗} : C → C/C which assigns to D the object C × D →^{π_{C}} C of C/C, and to maps D →^{f} D′ the map id_{C} × f.

C^{∗} has a left adjoint Σ_{C} which takes the domain: Σ_{C}(D → C) = D.

j) Let P : Set^{op} → Set be the functor which takes the powerset on objects, and for X →^{f} Y, P (f) : P (Y) → P (X) gives for each subset B of Y its inverse image under f.

Now P might as well be regarded as a functor Set → Set^{op}; let’s write P̄ for that functor. Since there is a natural bijection:

Set(X, P (Y)) →^{∼} Set(Y, P (X)) = Set^{op}(P̄(X), Y)

we have an adjunction P̄ ⊣ P.

Exercise 77. Suppose that C ←^{F} D is a functor and that for each object C of C there is an object GC of D and an arrow ε_{C} : F GC → C with the property that for every object D of D and any map F D →^{f} C, there is a unique f̃: D → GC such that

[figure: F D; F f̃; f; C; F GC; ε_{C}]

commutes.

Prove that G : C_{0} → D_{0} extends to a functor G : C → D which is right adjoint to F, and that (ε_{C} : F GC → C|C ∈ C_{0}) is the counit of the adjunction.

Construct also the unit of the adjunction.

Exercise 78. Given C →^{G} D, for each object D of D we let (D↓G) denote the category which has as objects pairs (C, g) where C is an object in C and g : D → GC is an arrow in D. An arrow (C, g) → (C′, g′) in (D↓G) is an arrow f : C → C′ in C which makes

[figure: D; g; g′; GC; Gf; GC′]

commute.

Show that G has a left adjoint if and only if for each D, the category (D↓G) has an initial object.

5.2 Expressing (co)completeness by existence of adjoints; preservation of (co)limits by adjoint functors

Given categories C and D, we defined for every functor F : C → D its limit (or limiting cone), if it existed, as a pair (D, μ) with μ : Δ_{D} ⇒ F, and (D, μ) terminal in the category of cones for F.

Any other natural transformation μ′ : Δ_{D′} ⇒ F factors uniquely through (D, μ) via an arrow D′ → D in D and conversely, every arrow D′ → D gives rise to a natural transformation μ′ : Δ_{D′} ⇒ F.

So there is a 1-1 correspondence between

D(D′, D) and DC(Δ_{D′}, F)

which is natural in D′.

Since every arrow D′ → D′′ in D gives a natural transformation Δ_{D′} ⇒ Δ_{D′′} (example i) of 2.2), there is a functor Δ_{(−)} : D → DC.

The above equation now means that:

Proposition 5.1 D has all limits of type C (i.e. every functor C →^{F} D has a limiting cone in D) if and only if Δ_{(−)} has a right adjoint.

Exercise 79. Give an exact proof of this proposition.

Exercise 80. Use duality to deduce the dual of the proposition: D has all colimits of type C if and only if Δ_{(−)} : D → DC has a left adjoint.

Exercise 81. (Uniqueness of adjoints) Any two left (or right) adjoints of a given functor are isomorphic as objects of the appropriate functor category.

Exercise 82. D → 1 has a right adjoint iff D has a terminal object, and a left adjoint iff D has an initial object.

Exercise 83. Suppose D has both an initial and a terminal object; denote by L the functor D → D which sends everything to the initial, and by R the one which sends everything to the terminal object. L ⊣ R.

Exercise 84. Let F ⊣ G with counit ε : F G ⇒ id. Show that ε is a natural isomorphism if and only if G is faithful.

A very important aspect of adjoint functors is their behaviour with respect to limits and colimits.

Theorem 5.2 Let [figure: C; G; D; F] such that F ⊣ G. Then: a) G preserves all limits which exist in C;

b) F preserves all colimits which exist in D.

Proof. Suppose M : E → C has a limiting cone (C, μ) in C. Now a cone (D, ν) for GM is a natural family D →^{ν_{E}} GM(E), i.e. such that

[figure: D; ν_{E}; ν_{E′}; GM(E); GM(e); GM(E′)]

commutes for every E →^{e} E′ in E.

This transposes under the adjunction to a family (F D →^{ν̃_{E}} ME|E ∈ E_{0}) and the naturality requirement implies that

[figure: F D; ν̃_{E}; ν̃_{E′}; ME; M(e); ME′]

commutes in C, in other words, that (F D, ν) is a cone for M in C. There is, therefore, a unique map of cones from (F D, ν̃) to (C, μ).

Transposing back again, we get a unique map of cones (D, ν) → (GC, G∘μ). That is to say that (GC, G ∘ μ) is terminal in Cone(GM), so a limiting cone for GM, which was to be proved.

The argument for the other statement is dual.

Exercise 85. Given [figure: C; G; D; F] , F ⊣ G and M : E → C. Show that the

functor Cone(M) → Cone(GM) induced by G has a left adjoint.

From the theorem on preservation of (co)limits by adjoint functors one can often conclude that certain functors cannot have a right or a left adjoint.

Examples

a) The forgetful functor Mon → Set does not preserve epis, as we have seen

in 1.2. In chapter 3 we’ve seen that f is epi iff [figure: id; id; f; f] is a pushout;

since left adjoints preserve identities and pushouts, they preserve epis; therefore the forgetful functor Mon → Set does not have a right adjoint; b) The functor (−) × X : Set → Set does not preserve the terminal object

unless X is itself terminal in Set; therefore, it does not have a left adjoint for non-terminal X.

c) The forgetful functor Pos → Set has a left adjoint, but it cannot have a right adjoint: it preserves all coproducts, including the initial object, but not all coequalizers.

Exercise 86. Prove the last example. Hint: think of the coequalizer of the following two maps ℚ → ℝ: one is the inclusion, the other is the constant zero map.

Another use of the theorem has to do with the computation of limits. Many categories, as we have seen, have a forgetful functor to Set which has a left adjoint. So the forgetful functor preserves limits, and since these can easily be computed in Set, one already knows the “underlying set” of the vertex of the limiting cone one wants to compute.

Does a converse to the theorem hold? I.e. given G : C → D which preserves all limits; does G have a left adjoint? In general no, unless C is sufficiently complete, and a rather technical condition, the “solution set condition” holds. The adjoint functor theorem (Freyd) tells that in that case there is a converse:

Definition 5.3 (Solution set condition) G : C → D satisfies the solution set condition (ssc) for an object D of D, if there is a set X_{D} of objects of C, such that every arrow D → GC factors as

[figure: D; GC; GC′; G(f)]

for some C′ ∈ X_{D} and f : C′ → C in C.

Theorem 5.4 (Adjoint Functor Theorem) Let C be a complete category and G : C → D a functor. G has a left adjoint if and only if G preserves all small limits and satisfies the ssc for every object D of D.

I won’t prove the theorem, but you may like to try yourself. It is a, not too trivial, exercise.

For small categories C, the ssc is of course irrelevant. But categories which are small and complete are rather special… they are complete preorders.

For preorders C, D we have: if C is complete, then G : C → D has a left adjoint if and only if G preserves all limits, that is: greatest lower bounds ⋀ B for all B ⊆ C. For, put

F (d) = ⋀{c|d ≤ G(c)}

Then F (d) ≤ c′ implies (since G preserves ⋀) ⋀{G(c)|d ≤ G(c)} ≤ G(c′) which implies d ≤ G(c′) since d ≤ ⋀{G(c)|d ≤ G(c)}; conversely, d ≤ G(c′) implies c′ ∈ {c|d ≤ G(c)} so F (d) = ⋀{c|d ≤ G(c)} ≤ c′.

\underline{Categories}

52

6. Monads and Algebras

6 Monads and Algebras

Given an adjunction (F, G, ε, η) : \xymatrix{C \ar[r] & D \ar[l]} let us look at the functor T = GF : D → D.

We have a natural transformation η : idD ⇒ T and a natural transformation μ : T^{2} ⇒ T. The components μ_{D} are

T^{2}(D) = GF GF D →^{G(ε_{F D})} GF D = T (D)

Furthermore the equalities

[figure: T^{3}; μT; T μ; T^{2}; μ; T^{2}; μ; T; and; T; ηT; =; T^{2}; μ; T; T η; =; T]

hold. Here (T μ)_{D} = T (μ_{D}) : T^{3}D → T D and (μT)_{D} = μ_{T D} : T^{3}D → T D (Similar for ηT and T η).

Exercise 87. Prove these equalities.

A triple (T, μ, η) satisfying these identities is called a monad. Try to see the formal analogy between the defining equalities for a monad and the axioms for a monoid: writing m(e, f) for ef in a monoid, and η for the unit element, we have

m(e, m(g, h)) = m(m(e, g), h) (associativity)
m(η, e) = m(e, η) = e  (unit)

Following this one calls μ the multiplication of the monad, and η its unit.

Example. The powerset functor P : Set → Set (example j) of 2.2, with η and μ indicated there) is a monad (check).

Dually, there is the notion of a comonad (L, δ, ε) on a category C, with equalities

[figure: L; δ; δ; L^{2}; Lδ; L^{2}; δL; L^{3}; L; =; δ; =; L; L^{2}; εL; Lε; L]

Given an adjunction (F, G, ε, η), (F G, δ = F ηG, ε) is a comonad on C. We call δ the comultiplication and ε the counit (this is in harmony with the unit-counit terminology for adjunctions).

Although, in many contexts, comonads and the notions derived from them are at least as important as monads, the treatment is dual so I concentrate on monads.

Every adjunction gives rise to a monad; conversely, every monad arises from an adjunction, but in more than one way. Essentially, there are a maximal and a minimal solution to the problem of finding an adjunction from which a given monad arises.

Example. A monad on a poset P is a monotone function T : P → P with the properties x ≤ T (x) and T^{2}(x) ≤ T (x) for all x ∈ P; such an operation is also often called a closure operation on P. Note that T^{2} = T because T is monotone.

In this situation, let Q ⊆ P be the image of T, with the ordering inherited from P. We have maps r : P → Q and i : Q → P such that ri is the identity on Q and ir = T : P → P.

For x ∈ P, y ∈ Q we have x ≤ i(y) ⇔ r(x) ≤ y (check); so r ⊣ i and the operation T arises from this adjunction.

6.1 Algebras for a monad

Given a monad (T, η, μ) on a category C, we define the category T -Alg of T - algebras as follows:

• Objects are pairs (X, h) where X is an object of C and h : T (X) → X is an arrow in C such that

[figure: T^{2}(X); μ_{X}; T (h); T (X); h; T (X); h; X; and; X; η_{X}; =; T (X); h; X]

commute;

• Morphisms: (X, h) → (Y, k) are morphisms X →^{f} Y in C for which

[figure: T (X); h; T (f); T (Y); k; X; f; Y]

commutes.

Theorem 6.1 There is an adjunction between T -Alg and C which brings about the given monad T.

Proof. There is an obvious forgetful functor U^{T} : T -Alg → C which takes (X, h) to X. I claim that U^{T} has a left adjoint F^{T}:

F^{T} assigns to an object X the T -algebra T^{2}(X) →^{μ_{X}} T (X); to X →^{f} Y the map T (f); this is an algebra map because of the naturality of μ. That T^{2}(X) →^{μ_{X}} T (X) is an algebra follows from the defining axioms for a monad T.

Now given any arrow g : X → U^{T} (Y, h) we let g̃ : (T (X), μ_{X}) → (Y, h) be

the arrow T (X) →^{T (g)} T (Y) →^{h} Y. This is a map of algebras since

[figure: T^{2}(X); μ_{X}; T^{2}(g); T^{2}(Y); μ_{Y}; T (h); Y; h; T (X); T (g); T (Y); h; Y]

commutes; the left hand square is the naturality of μ; the right hand square is because (Y, h) is a T -algebra.

Conversely, given f : (T X, μ_{X}) → (Y, h) we have an arrow f̄: X → Y by taking the composite X →^{η_{X}} T X →^{f} Y.

Now ˜ f̄: T X → Y is the composite

T X →^{T (η_{X})} T^{2}X →^{T (f)} T Y →^{h} Y

By naturality of η this is

T X →^{f} Y →^{η_{Y}} T Y →^{h} Y

which is f since (Y, h) is a T -algebra.

Conversely, ¯ g̃ : X → Y is the composite

X →^{η_{X}} T X →^{T (g)} T Y →^{h} Y

Again by naturality of η and the fact that (Y, h) is a T -algebra, we conclude that ¯ g̃ = g. So we have a natural 1-1 correspondence

C(X, U^{T} (Y, h)) ≃ T -Alg(F^{T} (X), (Y, h))

and our adjunction.

Note that the composite U^{T} F^{T} is the functor T, and that the unit η of the adjunction is the unit of T; the proof that for the counit ε of F^{T} ⊣ U^{T} we have that

T^{2} = U^{T} F^{T} U^{T} F^{T} →^{U^{T} εF^{T}} U^{T} F^{T} = T

is the original multiplication μ, is left to you.

Exercise 88. Complete the proof.

Example. The group monad. Combining the forgetful functor U : Grp → Set with the left adjoint, the free functor Set → Grp, we get the following monad on Set:

T (A) is the set of sequences on the alphabet A⊔A^{−1} (A^{−1} is the set {a^{−1}|a ∈ A} of formal inverses of elements of A, as in example e) of 1.1) in which no aa^{−1} or a^{−1}a occur. The unit A →^{η_{A}} T A sends a ∈ A to the string ⟨a⟩. The multiplication μ : T^{2}(A) → T (A) works as follows. Define (−)^{−} : A⊔A^{−1} → A⊔ A^{−1} by a^{−} = a^{−1} and (a^{−1})^{−} = a. Define also (−)^{−} on strings by (a_{1} … a_{n})^{−} = a_{n}^{−} … a_{1}^{−}. Now for an element of T T (A), which is a string on the alphabet T (A) ⊔ T (A)^{−1}, say σ_{1} … σ_{n}, we let μ_{A}(σ_{1} … σ_{n}) be the concatenation of the strings σ̃_{1}, …, σ̃_{n} on the alphabet A ⊔ A^{−1}, where σ̃_{i} = σ_{i} if σ_{i} ∈ T (A), and σ̃_{i} = (σ_{i})^{−} if σ_{i} ∈ T (A)^{−1}. Of course we still have to remove possible substrings of the form aa^{−1} etc.

Now let us look at algebras for the group monad: maps T (A) →^{h} A such that for a string of strings

α = σ_{1}, …, σ_{n} = ⟨⟨s_{1}^{1}, …, s_{1}^{k_{1}}⟩, …, ⟨s_{n}^{1}, …, s_{n}^{k_{n}}⟩⟩

we have that

h(⟨hσ_{1}, …, hσ_{n}⟩) = h(⟨s_{1}^{1}, …, s_{1}^{k_{1}}, …, s_{n}^{1}, …, s_{n}^{k_{n}}⟩)

and

h(⟨a⟩) = a for a ∈ A

I claim that this is the same thing as a group structure on A, with multiplication a · b = h(⟨a, b⟩).

The unit element is given by h(⟨⟩); the inverse of a ∈ A is h(⟨a^{−1}⟩) since

h(⟨a, h(⟨a^{−1}⟩)⟩) = h(⟨h(⟨a⟩), h(⟨a^{−1}⟩)⟩) =
h(⟨a, a^{−1}⟩) = h(⟨⟩), the unit element

Try to see for yourself how the associativity of the monad and its algebras transforms into associativity of the group law.

Exercise 89. Finish the proof of the theorem: for the group monad T, there is an equivalence of categories between T -Alg and Grp.

This situation is very important and has its own name:

Definition 6.2 Given an adjunction [figure: C; G; D; F] , F ⊣ G there is always a com-

parison functor K : C → T -Alg for T = GF, the monad induced by the adjunc-

tion. K sends an object C of C to the T -algebra GF G(C) →^{G(ε_{C})} G(C).

We say that C is monadic over D if K is an equivalence.

Exercise 90. Check that K(C) is a T -algebra. Complete the definition of K as a functor. Check that in the example of the group monad, the functor T -Alg → Grp defined there is a pseudo inverse to the comparison functor K.

In many cases however, the situation is not monadic. Take the forgetful functor U : Pos → Set. It has a left adjoint F which sends a set X to the discrete ordering on X (x ≤ y iff x = y). Of course, UF is the identity on Set and the UF -algebras are just sets. The comparison functor K is the functor U, and this is not an equivalence.

Exercise 91. Why not? [Hint: think of coproducts in both categories. Every equivalence reflects coproducts]

Another example of a monadic situation is of importance in domain theory. Let Pos_{⊥} be the category of partially ordered sets with a least element, and order preserving maps which also preserve the least element.

There is an obvious inclusion functor U : Pos_{⊥} → Pos, and U has a left adjoint F. Given a poset X, F (X) is X “with a bottom element added”:

[figure: X; ⊥]

Given f : X → Y in Pos, F (f) sends the new bottom element of X to the new bottom element of Y, and is just f on the rest. If f : X → Y in Pos is a map and Y has a least element, we have F (X) → Y in Pos_{⊥} by sending ⊥ to the least element of Y. So the adjunction is clear.

The monad UF : Pos → Pos, just adding a least element, is called the lifting monad. Unit and multiplication are:

[figure: η_{X} : X → T (X); μ_{X} : T^{2}(X) → T (X)]

A T -algebra h : T X → X is first of all a monotone map, but since hη_{X} = id_{X}, h is epi in Pos so surjective. It follows that X must have a least element h(⊥). From the axioms for an algebra one deduces that h must be the identity when restricted to X, and h(⊥) the least element of X.

Exercise 92. Given [figure: C; G; D; F] , F ⊣ G, T = GF. Prove that the com-

parison functor K : C → T -Alg satisfies U^{T} K = G and KF = F^{T} where

[figure: T -Alg; U^{T}; D; F^{T}] as in theorem 6.1.

Another poset example: algebras for the power set monad P on Set (example j);2.2). Such an algebra h : P(X) → X must satisfy h({x}) = x and for α ⊆ P(X):

h({h(A)|A ∈ α}) = h({x|∃A ∈ α(x ∈ A)}) = h(⋃ α)

Now we can, given an algebra structure on X, define a partial order on X by putting x ≤ y iff h({x, y}) = y.

Indeed, this is clearly reflexive and antisymmetric. As to transitivity, if x ≤ y and y ≤ z then

h({x, z})=h({x, h({y, z})})  =
h({h({x}), h({y, z})})=h({x} ∪ {y, z})  =
h({x, y} ∪ {z})=h({h({x, y}), h({z})})=
h({y, z})=z

so x ≤ z.

Furthermore this partial order is complete: least upper bounds for arbitrary subsets exist. For ⋁ B = h(B) for B ⊆ X: for x ∈ B we have h({x, h(B)}) = h({x} ∪ B) = h(B) so x ≤ ⋁ B; and if x ≤ y for all x ∈ B then

h({h(B), y})=h(B ∪ {y})  =
h(⋃_{x∈B}{x, y})=h({h({x, y})|x ∈ B})=
h({y})=y

so ⋁ B ≤ y.

We can also check that a map of algebras is a ⋁-preserving monotone function. Conversely, every ⋁-preserving monotone function between complete posets determines a P-algebra homomorphism.

We have an equivalence between the category of complete posets and ⋁- preserving functions, and P-algebras.

Exercise 93. Let P : Set^{op} → Set be the contravariant powerset functor, and P̄ its left adjoint, as in j) of 5.1. Let T : Set → Set the induced monad.

a) Describe unit and multiplication of this monad explicitly.

b) Show that Set^{op} is equivalent to T -Alg [Hint: if this proves hard, have a look at VI.4.3 of Johnstone’s “Stone Spaces”].

c) Conclude that there is an adjunction

\xymatrix{CABool \ar[r] & Set \ar[l]}

which presents CABool as monadic over Set.

6.2 T -Algebras at least as complete as D

Let T be a monad on D. The following exercise is meant to show that if D has all limits of a certain type, so does T -Alg. In particular, if D is complete, so is T -Alg; this is often an important application of a monadic situation.

Exercise 94. Let E be a category such that every functor M : E → D has a limiting cone. Now suppose M : E → T -Alg. For objects E of E, let M(E) be the T -algebra T (m_{E}) →^{h_{E}} m_{E}.

a) Let (D, (ν_{E}|E ∈ E_{0})) be a limiting cone for U^{T} M : E → D. Using the T -algebra structure on M(E) and the fact that U^{T} M(E) = m_{E}, show that there is also a cone (T D, (π_{E}|E ∈ E_{0})) for U^{T} M;

b) Show that the unique map of cones: (T D, π) → (D, ν) induces a T -algebra structure T D →^{h} D on D;

c) Show that T D →^{h} D is the vertex of a limiting cone for M in T -Alg.

6.3 The Kleisli category of a monad

I said before that for a monad T on a category D, there are a “maximal and a minimal solution” to the problem of finding an adjunction which induces the given monad.

We’ve seen the category T -Alg, which we now write as D^{T}; we also write G^{T} : T -Alg → D for the forgetful functor. In case T arises from an adjunction

[figure: C; G; D; F] , there was a comparison functor C →^{K} D^{T}. In the diagram

[figure: C; K; G; D_{T}; G^{T}; D; F; F^{T}]

we have that KF = F^{T} and G^{T} K = G.

Moreover, the functor K is unique with this property.

This leads us to define a category T -Adj of adjunctions [figure: C; G; D; F] such

that GF = T. A map of such T -adjunctions from [figure: C; G; D; F] to [figure: C′; G′; D; F′] is

a functor K : C → C′ satisfying KF = F′ and G′K = G.

What we have proved about T -Alg can be summarized by saying that the

adjunction [figure: D_{T}; G^{T}; D; F^{T}] is a terminal object in T -Adj. This was the “maximal”

solution.

T -Adj has also an initial object: the Kleisli category of T, called D_{T}. D_{T} has the same objects as D, but a map in D_{T} from X to Y is an arrow X →^{f} T (Y) in D. Composition is defined as follows: given X →^{f} T (Y) and Y →^{g} T (Z) in D, considered as a composable pair of morphisms in D_{T}, the composition gf in D_{T} is the composite

X →^{f} T (Y) →^{T (g)} T^{2}(Z) →^{μ_{Z}} T (Z)

in D.

Exercise 95. Prove that composition is associative. What are the identities of D_{T}?

The adjunction [figure: _{D_{T}}; G_{T}; D; F_{T}] is defined as follows: the functor G_{T} sends the

object X to T (X) and f : X → Y (f : X → T (Y) in D) to

T (X) →^{T (f)} T^{2}(Y) →^{μ_{Y}} T (Y)

The functor F_{T} is the identity on objects and sends X →^{f} Y to X →^{f} Y →^{η_{Y}} T (Y), considered as X → Y in D_{T}.

Exercise 96. Define unit and counit; check F_{T} ⊣ G_{T}.

Now for every adjunction [figure: C; G; D; F] with GF = T, there is a unique com-

parison functor L : D_{T} → C such that GL = G_{T} and LF_{T} = F.

L sends the object X to F (X) and f : X → Y (so f : X → T (Y) = GF (Y) in D) to its transpose f̃: F (X) → F (Y).

Exercise 97. Check the commutations. Prove the uniqueness of L w.r.t. these properties.

\underline{Categories}

62

7. Cartesian closed categories and the λ-calculus

7 Cartesian closed categories and the λ-calculus

Many set-theoretical constructions are completely determined (up to isomorphism, as always) by their categorical properties in Set. We are therefore tempted to generalize them to arbitrary categories, by taking the characteristic categorical property as a definition. Of course, this procedure is not really well-defined and it requires sometimes a real insight to pick the ‘right’ categorical generalization. For example, the category of sets has very special properties:

• f : X → Y is mono if and only if fg = fh implies g = h for any two maps g, h : 1 → X, where 1 is a terminal object (we say 1 is a generator);

• objects X and Y are isomorphic if there exist monos f : X → Y and g : Y → X (the Cantor-Bernstein theorem);

• every mono X →^{f} Y is part of a coproduct diagram

[figure: X; f; Z; g; Y]

And if you believe the axiom of choice, there is its categorical version:

• Every epi is split

None of these properties is generally valid, and categorical generalizations based on them are usually of limited value^{2}.

In this chapter we focus on a categorical generalization of a set-theoretical concept which has proved to have numerous applications: Cartesian closed categories as the generalization of “function space”.

In example f) of 5.1 we saw that the set of functions Z^{X} appears as the value at Z of the right adjoint to the product functor (−) × X. A category is called cartesian closed if such right adjoints always exist. In such categories we may really think of this right adjoint as giving the “object of functions (or arrows)”, as the treatment of the λ-calculus will make clear.

7.1 Cartesian closed categories (ccc’s); examples and basic facts

Definition 7.1 A category C is called cartesian closed or a ccc if it has finite products, and for every object X of C the product functor (−) × X has a right adjoint.

2Asperti, for example, restricts his interpretation of the λ-calculus to ccc’s where 1 is a generator. You might as well immediately restrict to Set, then.

Of course, “the” product functor only exists once we have chosen a product diagram for every pair of objects of C. In this chapter we assume that we have such a choice, as well as a distinguished terminal object 1; and we assume also that for each object X we have a specified right adjoint to the functor (−) × X, which we write as (−)^{X} (Many authors write X ⇒ (−), but I think that overloads the arrows notation too much). Objects of the form Z^{X} are called exponents.

We have the unit

Y →^{η_{Y,X}} (Y × X)^{X}

and counit

Y^{X} × X →^{ε_{Y,X}} Y

of the adjunction (−) × X ⊣ (−)^{X}. Anticipating the view of Y^{X} as the object of arrows X → Y, we call ε evaluation.

Examples

a) A preorder (or partial order) is cartesian closed if it has a top element 1, binary meets x∧y and for any two elements x, y an element x→y satisfying for each z:

z ≤ x→y iff z ∧ x ≤ y

b) Set is cartesian closed; Cat is cartesian closed (2.1);

c) Top is not cartesian closed, however the category of locally compact spaces and continuous maps is;

d) Pos is cartesian closed. The exponent Y^{X} is the set of all monotone maps X → Y, ordered pointwise (f ≤ g iff for all x ∈ X, fx ≤ gx in Y);

e) Grp and Abgp are not cartesian closed. In both categories, the initial object is the one-element group. Since for non-initial groups G, (−) × G does not preserve the initial object, it cannot have a right adjoint;

f) 1 is cartesian closed; 0 isn’t (why?);

g) Set^{C^{op}} is cartesian closed. Products and 1 are given “pointwise” (in fact all limits are), that is F × G(C) = F (C) × G(C) and 1(C) is the terminal 1 in Set, for all C ∈ C_{0}.

The construction of the exponent G^{F} is a nice application of the Yoneda lemma. Indeed, for G^{F} to be the right adjoint (at G) of (−) × F, we need for every object C of C:

Set^{C^{op}}(h_{C} × F, G) ≃ Set^{C^{op}}(h_{C}, G^{F}) ≃ G^{F} (C)

where the last isomorphism is by the Yoneda lemma.

Now the assignment C ↦ Set^{C^{op}}(h_{C} × F, G) defines a functor C^{op} → Set, which we denote by G^{F}. At the same time, this construction defines a functor (−)^{F} : Set^{C^{op}} → Set^{C^{op}}, which is right adjoint to (−) × F. It is a nice exercise to prove this.

h) A monoid is never cartesian closed unless it’s trivial.

Exercise 98. Show that every Boolean algebra is cartesian closed.

Exercise 99. Show that CABool is not cartesian closed [use 2.3].

Exercise 100. Show that a complete partial order is cartesian closed if and only if it’s a frame [see 4.4].

Exercise 101. Let Ω be a frame. By the preceding exercise, it is cartesian closed; denote by x→y the exponent in Ω. This exercise is meant to let you show that C_{Ω} is cartesian closed.

a) Show that Ω also has greatest lower bounds ⋀ B for all subsets B.

b) Given objects (X, E_{X}) and (Y, E_{Y}), define their exponent (Y, E_{Y})^{(X,E_{X})} as (Y^{X}, E) where Y^{X} is the set of all functions X → Y in Set, and

E(f) = ⋀{E_{X}(x)→E_{Y} (f(x))|x ∈ X}

Show that this defines a right adjoint (at (Y, E_{Y})) of (−) × (X, E_{X}).

Some useful facts:

• C is cartesian closed if and only if it has finite products, and for each pair of objects X, Y there is an object Y^{X} and an arrow ε : Y^{X} × X → Y such

that for every Z and map Z × X →^{f} Y there is a unique Z →^{f̃} Y^{X} such that

[figure: Z × X; f; f̃×id_{X}; Y; Y^{X} × X; ε]

commutes.

• In a ccc, there are natural isomorphisms 1^{X} ≃ 1; (Y × Z)^{X} ≃ Y^{X} × Z^{X}; (Y^{Z})^{X} ≃ Y^{Z×X}.

• If a ccc has coproducts, we have X × (Y + Z) ≃ (X × Y) + (X × Z) and Y^{Z+X} ≃ Y^{Z} × Y^{X}.

Exercise 102. Prove these facts.

Recall that two maps Z × X → Y and Z → Y^{X} which correspond to each other under the adjunction are calles each other’s transposes.

Exercise 103. In a ccc, prove that the transpose of a composite Z →^{g} W →^{f} Y^{X} is

Z × X ⟶^{g×id_{X}} W × X →^{f̃} Y

if f̃ is the transpose of f.

Lemma 7.2 In a ccc, given f : X′ → X let Y^{f} : Y^{X} → Y^{X′} be the transpose of

Y^{X} × X′ →^{id×f} Y^{X} × X →^{ε} Y

Then for each f : X′ → X and g : Y → Y′ the diagram

[figure: Y^{X}; Y^{f}; g^{X}; Y^{′X}; Y^{′f}; Y^{X′}; g^{X′}; Y^{′X′}]

commutes.

Proof. By the exercise, the transposes of both composites are the top and bottom composites of the following diagram:

[figure: Y^{′X} × X′; id×f; Y^{′X} × X; ε; Y^{X} × X′; g^{X}×id; id×f; Y^{f} ×id; Y^{X} × X; g^{X}×id; ε; Y; g; Y′; Y^{X′} × X′; ε; g^{X′} ×id; Y^{′X′} × X′; ε]

This diagram commutes because the right hand “squares” are naturality squares for ε, the lower left hand square commutes because both composites are the transpose of Y^{f}, and the upper left hand square commutes because both composites are g^{X} × f.

Proposition 7.3 For every ccc C there is a functor C^{op} ×C → C, assigning Y^{X} to (X, Y), and given g : Y → Y′ and f : X′ → X, g^{f} : Y^{X} → Y^{′X′} is either of the composites in the lemma.

Exercise 104. Prove the proposition.

7.2 Typed λ-calculus and cartesian closed categories

The λ-calculus is an extremely primitive formalism about functions. Basically, we can form functions (by λ-abstraction) and apply them to arguments; that’s all. Here I treat briefly the typed λ-calculus.

We start with a set S of type symbols S_{1}, S_{2}, …

Out of S we make the set of types as follows: every type symbol is a type, and if T_{1} and T_{2} are types then so is (T_{1}⇒T_{2}).

We have also terms of each type (we label the terms like t:T to indicate that t is a term of type T):

• we may have constants c:T of type T;

• for every type T we have a denumerable set of variables x_{1}:T, x_{2}:T, …;

• given a term t:(T_{1}⇒T_{2}) and a term s:T_{1}, there is a term (ts):T_{2};

• given t:T_{2} and a variable x:T_{1} there is a term λx.t:T_{1}⇒T_{2}.

Terms λx.t are said to be formed by λ-abstraction. This procedure binds the variable x in t. Furthermore we have the usual notion of substitution for free variables in a term t (types have to match, of course). Terms of form (ts) are said to be formed by application.

In the λ-calculus, the only statements we can make are equality statements about terms. Again, I formulate the rules in terms of theories. First, let us say that a language consists of a set of type symbols and a set of constants, each of a type generated by the set of type symbols.

An equality judgement is an expression of the form Γ|t = s:T (to be read: “Γ thinks that s and t are equal terms of type T ”), where Γ is a finite set of variables which includes all the variables free in either t or s, and t and s are terms of type T.

A theory is then a set T of equality judgements which is closed under the following rules:

i) Γ|t = s:T in T implies Δ|t = s:T in T for every superset Δ of Γ;

ii) F V (t)|t = t:T is in T for every term t:T of the language (again, F V (t) is the set of free variables of t); if Γ|t = s:T and Γ|s = u:T are in T then so is Γ|t = u:T; iii) if t(x_{1}, …, x_{n}):T is a term of the language, with free variables x_{1}:S_{1},…,x_{n}:S_{n},

and Γ|s_{1} = t_{1}:S_{1}, …, Γ|s_{n} = t_{n}:S_{n} are in T then

Γ|t[s_{1}/x_{1}, …, s_{n}/x_{n}] = t[t_{1}/x_{1}, …, t_{n}/x_{n}]:T

is in T ;

iv) if t and s are terms of type (T_{1}⇒T_{2}), x a variable of type T_{1} which does not occur in t or s, and Γ ∪ {x}|(tx) = (sx):T_{2} is in T , then Γ \ {x}|t = s:(T_{1}⇒T_{2}) is in T ;

v) if s:T_{1} and t:T_{2} are terms and x a variable of type T_{2}, then

F V (s) \ {x} ∪ F V (t)|((λx.s)t) = s[t/x]:T_{1}

is in T .

Given a language, an interpretation of it into a ccc C starts by choosing objects [[ S]] of C for every type symbol S. This then generates objects [[ T ]] for every type T by the clause

[[ T_{1}⇒T_{2} ]] = [[ T_{2} ]]^{[[ T_{1} ]]}

The interpretation is completed by choosing interpretations

1 →^{[[ c]]} [[ T ]]

for every constant c:T of the language.

Such an interpretation then generates, in much the same way as in chapter 4, interpretations of all terms. For a finite set Γ = {x_{1}:T_{1}, …, x_{n}:T_{n}} let’s again write [[ Γ ]] for the product [[ T_{1} ]] × ⋯ × [[ T_{n}]] (this is only defined modulo a permutation of the factors of the product, but that will cause us no trouble).

The interpretation of t:T will now be an arrow

[[ F V (t) ]] →^{[[ t]]} [[ T ]]

defined as follows:

• [[ x]] is the identity on [[ T ]] for every variable x:T;

• given [[ t]] : [[ F V (t) ]] → [[ T_{2} ]]^{[[ T_{1} ]]} and [[ s]] : [[ F V (s) ]] → [[ T_{1} ]] we let [[ (ts) ]] : [[ F V ((ts)) ]] → [[ T_{2} ]] be the composite

[[ F V ((ts)) ]] ⟶^{⟨[[ t]]π_{t},[[ s]]π_{s}⟩} [[ T_{2} ]]^{[[ T_{1} ]]} × [[ T_{1} ]] →^{ε} [[ T_{2} ]]

where π_{t} and π_{s} are the projections from [[ F V ((ts)) ]] to [[ F V (t) ]] and [[ F V (s) ]], respectively; • given [[ t]] : [[ F V (t) ]] → [[ T_{2} ]] and the variable x:T_{1} we let [[ λx.t]] : [[ F V (t)\

{x}]] → [[ T_{2} ]]^{[[ T_{1} ]]} be the transpose of

[[ F V (t) \ {x}]] × [[ T_{1} ]] →^{t̃} [[ T_{2} ]]

where, if x occurs free in t so [[ F V (t) \ {x}]] × [[ T_{1} ]] ≃ [[ F V (t) ]], t̃ is just [[ t]]; and if x doesn’t occur in t, t̃ is [[ t]] composed with the obvious projection.

We now say that an equality judgement Γ|t = s:T is true in this interpretation, if the diagram

[figure: [[ F V (t) ]]; [[ t]]; [[ Γ ]]; π_{t}; π_{s}; [[ T ]]; [[ F V (s) ]]; [[ s]]]

commutes (again, π_{s} and π_{t} projections).

Lemma 7.4 Let t(x_{1}, …, x_{n}):T have free variables x_{i}:T_{i} and let t_{i}:T_{i} be terms. Let

t̃_{i} : [[ F V (t[t_{1}/x_{1}, …, t_{n}/x_{n}]) ]] → [[ T_{i}]]

be the obvious composite of projection and [[ t_{i}]].

Then the composition

[[ F V (t[t_{1}/x_{1}, …, t_{n}/x_{n}]) ]] ⟶^{⟨t̃_{i}|i=1...n⟩} ∏_{i=1}^{n}[[ T_{i}]] = [[ F V (t) ]] →^{[[ t]]} [[ T ]]

is the interpretation [[ t[t_{1}/x_{1}, …, t_{n}/x_{n}] ]].

Exercise 105. Prove the lemma [take your time. This is not immediate].

Theorem 7.5 Let S be a set of equality judgements and T = Cn(S) be the least theory containing S. If every judgement of S is true in the interpretation, so is every judgement in T .

Proof. Again, we show that the set of true judgements is a theory, i.e. closed under the rules in the definition of a theory.

i) and ii) are trivial; iii) follows at once by lemma 7.4; iv) Since Γ ⊆ (Γ \ {x}) ∪ {x} and because of the inductive hypothesis, we have that

[figure: [[ F V (s) ]] × [[ T_{1} ]]; [[ s]]×id; [[ T_{1}⇒T_{2} ]] × [[ T_{1} ]]; ε; [[ Γ \ {x}]]; π_{s}×id; π_{t}×id; [[ T_{2} ]]; [[ F V (t) ]] × [[ T_{1} ]]; [[ t]]×id; [[ T_{1}⇒T_{2} ]] × [[ T_{1} ]]; ε]

commutes. Taking the transposes of both maps, we get the equality we want.

v) According to lemma 7.4, [[ F V (s[t/x]) ]] ⟶^{[[ s[t/x] ]]} [[ T_{1} ]] is

[[ F V (s[t/x]) ]] →^{t̃} [[ F V (s) ]] →^{[[ s]]} [[ T_{1} ]]

This is the same as

[[ F V (s[t/x]) ]] →^{⟨π,[[ t]]⟩} [[ F V (s) \ {x}]] × [[ T_{2} ]] ⟶^{[[ λx.s]]×id} [[ T_{2}⇒T_{1} ]] × [[ T_{2} ]] →^{ε} [[ T_{1} ]]

which is

[[ F V ((λx.s)t) ]] ⟶^{[[ ((λx.s)t) ]]} [[ T_{1} ]]

There is also a completeness theorem: if a judgement Γ|t = s:T is true in all possible interpretations, then every theory (in a language this judgement is in) contains it.

The relevant construction is that of a syntactic cartesian closed category out of a theory, and an interpretation into it which makes exactly true the judgements in the theory. The curious reader can find the, somewhat laborious, treatment in Lambek & Scott’s “Higher Order Categorical Logic”.

7.3 Representation of primitive recursive functions in ccc’s with natural numbers object

Dedekind observed, that in Set, the set ω is characterized by the following property: given any set X, any element x ∈ X and any function X →^{f} X, there is a unique function F : ω → X such that F (0) = x and F (x + 1) = f(F (x)).

Lawvere took this up, and proposed this categorical property as a definition (in a more general context) of a “natural numbers object” in a category.

Definition 7.6 In a category C with terminal object 1, a natural numbers object is a triple (0, N, S) where N is an object of C and 1 →^{0} N, N →^{S} N arrows in C, such that for any other such diagram

[figure: 1; x; X; f; X]

there is a unique map ϕ : N → X making

[figure: 1; 0; x; N; S; ϕ; N; ϕ; X; f; X]

commute.

Of course we think of 0 as the zero element, and of S as the successor map. The defining property of a natural numbers object enables one to “do recursion”, a weak version of which we show here: we show that every primitive recursive function can be represented in a ccc with natural numbers object.

Definition 7.7 Let C be a ccc with natural numbers object (0, N, S). We say that a number-theoretic function F : ℕ^{k} → ℕ is represented by an arrow f : N^{k} → N if for any k-tuple of natural numbers n_{1}, … n_{k}, the diagram

[figure: 1; 0; 0; N; ⟨S^{n_{1}} ,...,S^{n_{k}} ⟩; N^{k}; f; N; S^{F (n_{1},...,n_{k})}; N]

commutes.

Recall that the class of primitive recursive functions is given by the following clauses:

• The constant zero function λx⃗.0 : ℕ^{k} → ℕ, the function λx.x + 1 : ℕ → ℕ and the projections λx⃗.x_{i} : ℕ → ℕ are primitive recursive;

• The primitive recursive functions are closed under composition: if F_{1}, …, F_{k} : ℕ^{l} → ℕ and G : ℕ^{k} → ℕ are primitive recursive, then so is G(⟨F_{1}, …, F_{k}⟩) : ℕ^{l} → ℕ;

• The primitive recursive functions are closed under definition by primitive recursion: if G : ℕ^{k} → ℕ and H : ℕ^{k+2} → ℕ are primitive recursive, and F : ℕ^{k+1} → ℕ is defined by F (0, x⃗) = G(x⃗) and F (n + 1, x⃗) = H(n, F (n, x⃗), x⃗) then F is primitive recursive.

Proposition 7.8 In a ccc C with natural numbers object, every primitive recursive function is representable.

Proof. I do only the case for definition by primitive recursion. So by inductive hypothesis we have arrows G and H representing the homonymous functions. By interpretation of the λ-calculus, I use λ-terms: so there is an arrow

λx⃗.G(x⃗) : 1 → N^{(N^{k})}

and an arrow

λx⃗.H(n, ϕ(x⃗), x⃗) : N^{(N^{k})} × N → N^{(N^{k})}

which is the interpretation of a term with free variables ϕ:N^{(N^{k})} and n:N; this map is the exponential transpose of the map which intuitively sends (n, ϕ, x⃗) to (n, ϕ(x⃗), x⃗). Now look at

[figure: 1; ⟨λx⃗.G(x⃗),0⟩; N^{(N^{k})} × N; (λx⃗.H(n,ϕ(x⃗),x⃗))×S; N^{(N^{k})} × N]

By the natural numbers object property, there is now a unique map

F̄ = ⟨F̃, σ⟩ : N → N^{(N^{k})} × N

which makes the following diagram commute:

[figure: 1; 0; ⟨λx⃗.G(x⃗),0⟩; N; F̄; S; N; F̄; N^{(N^{k})} × N; (λx⃗.H(n,ϕ(x⃗),x⃗))×S; N^{(N^{k})} × N]

One verifies that σ is the identity, and that the composite

[figure: N^{k+1}; F̃×id; N^{(N^{k})} × N^{k}; ε; N]

represents F.

Exercise 106. Make these verifications.

That’s it!!

Index

abelianization, 5 adjoint functor theorem, 50 adjunction, 45 Alexandroff topology, 5 algebras for monad, 54 arrows, 1 associative, 1 atom in Boolean algebra, 16

Boolean algebra, 15 atomic, 16 complete, 15

category, 1 cartesian, 23 cartesian closed, 63 complete, 23 discrete, 13 finitely complete, 23 has binary products, 20 has equalizers, 20 has pullbacks, 20 indiscrete, 13 left exact, 23 lex, 23 locally small, 4 path, 3 quotient, 3 regular, 29 slice, 4 small, 13

ccc, 63 closure operation on poset, 54 cocone for a functor, 25 codomain, 1 coequalizer, 25 coequalizer diagram, 25 coherent logic, 33 colimiting cocone, 25 comonad, 53 comparison functor, 57 complement in a lattice, 15 composition, 1 comultiplication of comonad, 53 cone for a functor, 17 congruence relation, 3 coproduct, 25 coproduct inclusions, 25 coprojections, 25 counit of adjunction, 45 counit of comonad, 53

diagram commutes, 4 diagram of type C, 17 domain, 1 duality principle, 6

embedding, 10 epi, 6 epimorphism, 6 equality judgement in λ-calculus, 67 equalizer, 18 equalizer diagram, 18 equivalence of categories, 15 equivalent categories, 15 equivalent formulas, 39 evaluation in ccc, 64 exponents in ccc, 64

frame, 39 free group, 3 free monoid, 46 functor, 2

contravariant, 5 covariant, 5 faithful, 7 forgetful, 2 free, 3 full, 7 Hom, 5

\underline{INDEX}

preserving a property, 7 preserving limits, 23 reflecting a property, 7 representable, 4

generator, 63 group monad, 56 groupoid, 14 Grp, 2 Grph, 2

homotopy, 3

identity arrow, 1 image of a map, 32 index category of diagram, 17 initial object, 7 inverse of an arrow, 7 isomorphic objects, 8 isomorphism, 7

kernel pair of a map, 29 Kleisli category of monad, 60

labelled sequent, 35 λ-abstraction, 67 λ-calculus, 67 lattice, 15

distributive, 15 left adjoint functor, 43 lifting monad, 57 limiting cone, 17

MacLane’s pentagon, 23 map, 1 monad, 53 monadic, 57 mono, 6 monoid, 1 monomorphism, 6 morphism, 1 multiplication of monad, 53

natural

bijection, 10 natural numbers object, 71 natural transformation, 9

objects, 1

Pos, 2 preorder, 1 primitive recursive function, 71 product category, 2 product cone, 18 product in category, 18 projections, 18 pseudo inverse of a functor, 15 pullback along a map, 32 pullback diagram, 20 pushout, 26

regular epi, 27 regular mono, 22 retraction, 7 right adjoint functor, 43 Rng, 2

section, 7 solution set condition (ssc), 50 specialization ordering, 6 split epi, 7 split mono, 7 stable under pullback, 30 subobject, 31

terminal object, 7 theory in λ-calculus, 67 theory in coherent logic, 35 Top, 2 transpose of map, 43 triangle equalities, 45

unit of adjunction, 45 unit of monad, 53

vertex of a cone, 17

\underline{INDEX}

Yoneda embedding, 10 Yoneda lemma, 10