Introduction to Categories and Categorical Logic

Samson Abramsky, Nikos Tzevelekos

T

he aim of these notes is to provide a succinct, accessible introduction to some of the basic ideas of category theory and categorical logic. The notes are based on a lecture course given at Oxford over the past few years. They contain numerous exercises, and hopefully will prove useful for self-study by those seeking a first introduction to the subject, with fairly minimal prerequisites. The coverage is by no means comprehensive, but should provide a good basis for further study; a guide to further reading is included.

The main prerequisite is a basic familiarity with the elements of discrete mathematics: sets, relations and functions. An Appendix contains a summary of what we will need, and it may be useful to review this first. In addition, some prior exposure to abstract algebra — vector spaces and linear maps, or groups and group homomorphisms — would be helpful.

Why study categories — what are they good for? We can offer a range of answers for readers coming from different backgrounds:

For mathematicians: category theory organises your previous mathematical experience in a new and powerful way, revealing new connections and structure, and allows you to “think bigger thoughts”.

For computer scientists: category theory gives a precise handle on important notions such as compositionality, abstraction, representation-independence, genericity and more. Otherwise put, it provides the fundamental mathematical structures underpinning many key programming concepts.

For logicians: category theory gives a syntax-independent view of the fundamental structures of logic, and opens up new kinds of models and interpretations.

For philosophers: category theory opens up a fresh approach to structuralist foundations of mathematics and science; and an alternative to the traditional focus on set theory.

For physicists: category theory offers new ways of formulating physical theories in a structural form. There have inter alia been some striking recent applications to quantum information and computation.

Category theory can be seen as a “generalised theory of functions”, where the focus is shifted from the pointwise, set-theoretic view of functions, to an abstract view of functions as arrows.

Let us briefly recall the arrow notation for functions between sets.A review of basic ideas about sets, functions and relations, and some of the notation we will be using, is provided in Appendix A. A function ff with domain XX and codomain YY is denoted by: f:X→Yf:X\rightarrow Y.

The fundamental operation on functions is composition: if f:X→Yf:X\rightarrow Y and g:Y→Zg:Y\rightarrow Z, then we can define g∘f:X→Zg\circ f:X\rightarrow Z by g∘f(x):=g(f(x))g\circ f(x):=g(f(x)).We shall use the notation “:=” for “is defined to be” throughout these notes. Note that, in order for the composition to be defined, the codomain of ff must be the same as the domain of gg.

Moreover, for each set XX there is an identity function on XX, which is denoted by:

These operations are governed by the associativity law and the unit laws. For f:X→Yf:X\rightarrow Y, g:Y→Zg:Y\rightarrow Z, h:Z→Wh:Z\rightarrow W:

Notice that these equations are formulated purely in terms of the algebraic operations on functions, without any reference to the elements of the sets XX, YY, ZZ, WW. We will refer to any concept pertaining to functions which can be defined purely in terms of composition and identities as arrow-theoretic. We will now take a first step towards learning to “think with arrows” by seeing how we can replace some familiar definitions couched in terms of elements by arrow-theoretic equivalents; this will lead us towards the notion of category.

We say that a function f:X⟶Yf:X\longrightarrow Y is:

Note that injectivity and surjectivity are formulated in terms of elements, while epic and monic are arrow-theoretic.

Proof: We show 1. Suppose f:X→Yf:X\rightarrow Y is injective, and that f∘g=f∘hf\circ g=f\circ h, where g,h:Z→Xg,h:Z\rightarrow X. Then, for all z∈Zz\in Z:

Since ff is injective, this implies g(z)=h(z)g(z)=h(z). Hence we have shown that

and so we can conclude that g=hg=h. So ff injective implies ff monic. For the converse, fix a one-element set 1={∙}\boldsymbol{1}=\{\bullet\}. Note that elements x∈Xx\in X are in 1–1 correspondence with functions xˉ:1→X\bar{x}:\boldsymbol{1}\rightarrow X, where xˉ(∙):=x\bar{x}(\bullet):=x. Moreover, if f(x)=yf(x)=y then yˉ=f∘xˉ\bar{y}=f\circ\bar{x} . Writing injectivity in these terms, it amounts to the following.

Thus we see that being injective is a special case of being monic. ■\blacksquare

Show that f:X→Yf:X\rightarrow Y is surjective iff it is epic.

1.2 Categories Defined

A collection Ob(C)\mathsf{Ob}(\mathcal{C}) of objects. Objects are denoted by AA, BB, CC, etc.

A collection Ar(C)\mathsf{Ar}(\mathcal{C}) of arrows (or morphisms). Arrows are denoted by ff, gg, hh, etc.

Mappings dom,cod:Ar(C)→Ob(C)\mathsf{dom},\mathsf{cod}:\mathsf{Ar}(\mathcal{C})\rightarrow\mathsf{Ob}(\mathcal{C}), which assign to each arrow ff its domain dom(f)\mathsf{dom}(f) and its codomain cod(f)\mathsf{cod}(f). An arrow ff with domain AA and codomain BB is written f:A→Bf:A\rightarrow B. For each pair of objects AA, BB, we define the set

We refer to C(A,B)\mathcal{C}(A,B) as a hom-set. Note that distinct hom-sets are disjoint.

For any triple of objects AA, BB, CC, a composition map

cA,B,C(f,g)c_{A,B,C}(f,g) is written g∘ ⁣fg\circ\!f (or sometimes f;gf;g). Diagrammatically:

For each object AA, an identity arrow \mspace1.5muidA:A→A\mspace{1.5mu}\mathsf{id}_{A}:A\rightarrow A.

The above must satisfy the following axioms.

whenever the domains and codomains of the arrows match appropriately so that the compositions are well-defined. ▲\blacktriangle

1.3 Diagrams in Categories

Diagrammatic reasoning is an important tool in category theory. The basic cases are commuting triangles and squares. To say that the following triangle commutes

is exactly equivalent to asserting the equation g∘f=hg\circ f=h. Similarly, to say that the following square commutes

means exactly that g∘f=k∘hg\circ f=k\circ h. For example, the equations

can be expressed by saying that the following diagrams commute.

As these examples illustrate, most of the diagrams we shall use will be “pasted together” from triangles and squares: the commutation of the diagram as a whole will then reduce to the commutation of the constituent triangles and squares.

We turn to the general case. The formal definition is slightly cumbersome; we give it anyway for reference.

We define a graph to be a collection of vertices and directed edges, where each edge e:v→we:v\rightarrow w has a specified source vertex vv and target vertex ww. Thus graphs are like categories without composition and identities.This would be a “multigraph” in normal parlance, since multiple edges between a given pair of vertices are allowed. A diagram in a category C\mathcal{C} is a graph whose vertices are labelled with objects of C\mathcal{C} and whose edges are labelled with arrows of C\mathcal{C}, such that, if e:v→we:v\rightarrow w is labelled with f:A→Bf:A\rightarrow B, then we must have vv labelled by AA and ww labelled by BB. We say that such a diagram commutes if any two paths in it with common source and target, and at least one of which has length greater than 1, are equal. That is, given paths

To illustrate this definition, to say that the following diagram commutes

amounts to the assertion that f∘e=g∘ef\circ e=g\circ e ; it does not imply that f=gf=g.

1.4 Examples

Before we proceed to our first examples of categories, we shall present some background material on partial orders, monoids and topologies, which will provide running examples throughout these notes.

A partial order is a structure (P,≤)(P,\leq) where PP is a set and ≤\leq is a binary relation on PP satisfying:

x≤y  ∧y≤x    ⇒    x=yx\leq y\;\wedge y\leq x\;\;\Rightarrow\;\;x=y (Antisymmetry)

x≤y  ∧  y≤z    ⇒    x≤zx\leq y\;\wedge\;y\leq z\;\;\Rightarrow\;\;x\leq z (Transitivity)

If PP, QQ are partial orders, a map h:P→Qh:P\rightarrow Q is a partial order homomorphism (or monotone function) if:

Note that homomorphisms are closed under composition, and that identity maps are homomorphisms.

A monoid is a structure (M,⋅,1)(M,\cdot,1) where MM is a set,

is a binary operation, and 1∈M1\in M, satisfying the following axioms.

If MM, NN are monoids, a map h:M→Nh:M\rightarrow N is a monoid homomorphism if

Suppose that GG and HH are groups (and hence monoids), and that h:G→Hh:G\rightarrow H is a monoid homomorphism. Prove that hh is a group homomorphism.

A topological space is a pair (X,TX)(X,T_{X}) where XX is a set, and TXT_{X} is a family of subsets of XX such that

if U,V∈TXU,V\in T_{X} then U∩V∈TXU\cap V\in T_{X},

if {Ui}i∈I\{U_{i}\}_{i\in I} is any family in TXT_{X}, then ⋃i∈IUi∈TX\bigcup_{i\in I}U_{i}\in T_{X} .

A continuous map f:(X,TX)→(Y,TY)f:(X,T_{X})\rightarrow(Y,T_{Y}) is a function f:X→Yf:X\rightarrow Y such that, for all U∈TYU\in T_{Y}, f−1(U)∈TXf^{-1}(U)\in T_{X}. Let us now see some first examples of categories.

Any kind of mathematical structure, together with structure preserving functions, forms a category. E.g.

Vectk\text{{Vect}}_{k} (vector spaces over a field kk, and linear maps)

Pos (partially ordered sets and monotone functions)

Top (topological spaces and continuous functions)

Rel: objects are sets, arrows R:X→YR:X\rightarrow Y are relations R⊆X×YR\subseteq X\times Y. Relational composition:

Let kk be a field (for example, the real or complex numbers). Consider the following category Matk\text{{Mat}}_{k}. The objects are natural numbers. A morphism M:n→mM:\mathbf{n}\rightarrow\mathbf{m} is an n×m\mathbf{n}\times\mathbf{m} matrix with entries in kk. Composition is matrix multiplication, and the identity on n\mathbf{n} is the n×n\mathbf{n}\times\mathbf{n} diagonal matrix.

Monoids are one-object categories. Arrows correspond to the elements of the monoid, with the monoid operation being arrow-composition and the monoid unit being the identity arrow.

A category in which for each pair of objects AA, BB there is at most one morphism from AA to BB is the same thing as a preorder, i.e. a reflexive and transitive relation.

Note that our first class of examples illustrate the idea of categories as mathematical contexts; settings in which various mathematical theories can be developed. Thus for example, Top is the context for general topology, Grp is the context for group theory, etc.

On the other hand, the last two examples illustrate that many important mathematical structures themselves appear as categories of particular kinds. The fact that two such different kinds of structures as monoids and posets should appear as extremal versions of categories is also rather striking.

This ability to capture mathematics both “in the large” and “in the small” is a first indication of the flexibility and power of categories.

Check that Mon, Vectk\textbf{Vect}_{k}, Pos and Top are indeed categories.

Check carefully that monoids correspond exactly to one-object categories. Make sure you understand the difference between such a category and Mon. (For example: how many objects does Mon have?)

Check carefully that preorders correspond exactly to categories in which each homset has at most one element. Make sure you understand the difference between such a category and Pos. (For example: how big can homsets in Pos be?)

1.5 First Notions

Many important mathematical notions can be expressed at the general level of categories.

Let C\mathcal{C} be a category. A morphism f:X→Yf:X\rightarrow Y in C\mathcal{C} is: ∙\bullet monic (or a monomorphism) if f∘g=f∘h  ⟹  g=hf\circ g=f\circ h\;\Longrightarrow\;g=h , ∙\bullet epic (or an epimorphism) if g∘f=h∘f  ⟹  g=hg\circ f=h\circ f\;\Longrightarrow\;g=h . An isomorphism in C\mathcal{C} is an arrow i:A→Bi:A\rightarrow B such that there exists an arrow j:B→Aj:B\rightarrow A — the inverse of ii — satisfying

We denote isomorphisms by i:A→≅Bi:A\xrightarrow{\cong}B, and write i−1i^{-1} for the inverse of ii. We say that AA and BB are isomorphic, A≅BA\cong B, if there exists some i:A→≅Bi:A\xrightarrow{\cong}B.

Show that the inverse, if it exists, is unique.

Show that ≅\cong is an equivalence relation on the objects of a category.

As we saw previously, in Set monics are injections and epics are surjections. On the other hand, isomorphisms in Set correspond exactly to bijections, in Grp to group isomorphisms, in Top to homeomorphisms, in Pos to order isomorphisms, etc.

Thus we have at one stroke captured the key notion of isomorphism in a form which applies to all mathematical contexts. This is a first taste of the level of generality which category theory naturally affords.

We have already identified monoids as one-object categories. We can now identify groups as exactly those one-object categories in which every arrow is an isomorphism. This also leads to a natural generalisation, of considerable importance in current mathematics: a groupoid is a category in which every morphism is an isomorphism.

The directionality of arrows within a category C\mathcal{C} can be reversed without breaking the conditions of being a category; this yields the notion of opposite category.

Given a category C\mathcal{C}, the opposite category Cop\mathcal{C}^{\mathsf{op}} is given by taking the same objects as C\mathcal{C}, and

Composition and identities are inherited from C\mathcal{C}. ▲\blacktriangle

in Cop\mathcal{C}^{\mathsf{op}}, this means

in C\mathcal{C}, so composition g∘fg\circ f in Cop\mathcal{C}^{\mathsf{op}} is defined as f∘gf\circ g in C\mathcal{C}!

Consideration of opposite categories leads to a principle of duality: a statement SS is true about C\mathcal{C} if and only if its dual (i.e. the one obtained from SS by reversing all the arrows) is true about Cop\mathcal{C}^{\mathsf{op}}. For example,

Indeed, ff is monic in Cop\mathcal{C}^{\mathsf{op}} iff for all g,h:C→Bg,h:C\rightarrow B in Cop\mathcal{C}^{\mathsf{op}},

iff for all g,h:B→Cg,h:B\rightarrow C in C\mathcal{C},

iff ff is epic in C\mathcal{C}. We say that monic and epic are dual notions.

Another way to obtain new categories from old ones is by restricting their objects or arrows.

Let C\mathcal{C} be a category. Suppose that we are given collections

We say that D\mathcal{D} is a subcategory of C\mathcal{C} if

and hence D\mathcal{D} itself is a category. In particular, D\mathcal{D} is:

A full subcategory of C\mathcal{C} if for any A,B∈Ob(D)A,B\in\mathsf{Ob}(\mathcal{D}), D(A,B)=C(A,B)\mathcal{D}(A,B)=\mathcal{C}(A,B).

A lluf subcategory of C\mathcal{C} if Ob(D)=Ob(C)\mathsf{Ob}(\mathcal{D})=\mathsf{Ob}(\mathcal{C}). ▲\blacktriangle

For example, Grp is a full subcategory of Mon (by Exercise 0.1.5), and Set is a lluf subcategory of Rel.

We close this section with some very basic examples of categories.

How many categories C\mathcal{C} with Ob(C)={∙}\mathsf{Ob}(\mathcal{C})=\{\bullet\} are there? (Hint: what do such categories correspond to?)

1.6 Exercises

Consider the following properties of an arrow ff in a category C\mathcal{C}.

ff is split monic if for some gg, g∘fg\circ f is an identity arrow.

ff is split epic if for some gg, f∘gf\circ g is an identity arrow.

Prove that if ff and gg are arrows such that g∘fg\circ f is monic, then ff is monic.

Prove that, if ff is split epic then it is epic.

Prove that, if ff and g∘fg\circ f are iso then gg is iso.

Prove that, if ff is monic and split epic then it is iso.

In the category Mon\mathbf{Mon} of monoids and monoid homomorphisms, consider the inclusion map

of natural numbers into the integers. Show that this arrow is both monic and epic. Is it an iso?

The Axiom of Choice in Set Theory states that, if {Xi}i∈I\{X_{i}\}_{i\in I} is a family of non-empty sets, we can form a set X={xi∣i∈I}X=\{x_{i}\mid i\in I\} where xi∈Xix_{i}\in X_{i} for all i∈Ii\in I.

Show that in Set\mathbf{Set} an arrow which is epic is split epic. Explain why this needs the Axiom of Choice.

Is it always the case that an arrow which is epic is split epic? Either prove that it is, or give a counter-example.

Give a description of partial orders as categories of a special kind.

2 Some Basic Constructions

We shall now look at a number of basic constructions which appear throughout mathematics, and which acquire their proper general form in the language of categories.

A first such example is that of initial and terminal objects. While apparently trivial, they are actually both important and useful, as we shall see in the sequel.

An object II in a category C\mathcal{C} is initial if, for every object AA, there exists a unique arrow from II to AA, which we write ιA:I→A\iota_{A}:I\rightarrow A. A terminal object in C\mathcal{C} is an object TT such that, for every object AA, there exists a unique arrow from AA to TT, which we write τA:A→T\tau_{A}:A\rightarrow T. ▲\blacktriangle

Note that initial and terminal objects are dual notions: TT is terminal in C\mathcal{C} iff it is initial in Cop\mathcal{C}^{\mathsf{op}}. We sometimes write 1\mathbf{1} for the terminal object and 0\mathbf{0} for the initial one. Note also the assertions of unique existence in the definitions. This is one of the leitmotifs of category theory; we shall encounter it again in a conceptually deeper form in section 0.5.

Let us examine initial and terminal objects in our standard example categories.

In Set, the empty set is an initial object while any one-element set {∙}\{\bullet\} is terminal.

In Pos, the poset (∅,∅)(\varnothing,\varnothing) is an initial object while ({∙},{(∙,∙)})(\{\bullet\},\{(\bullet,\bullet)\}) is terminal.

In Top, the space (∅,{∅})(\varnothing,\{\varnothing\}) is an initial object while ({∙},{∅,{∙}})(\{\bullet\},\{\varnothing,\{\bullet\}\}) is terminal.

In Vectk\text{{Vect}}_{k}, the one-element space {0}\{0\} is both initial and terminal.

In a poset, seen as a category, an initial object is a least element, while a terminal object is a greatest element.

Verify these claims. In each case, identify the canonical arrows.

Identify the initial and terminal objects in Rel.

Suppose that a monoid, viewed as a category, has either an initial or a terminal object. What must the monoid be?

We shall now establish a fundamental fact: initial and terminal objects are unique up to (unique) isomorphism. As we shall see, this is characteristic of all such “universal” definitions. For example, the apparent arbitrariness in the fact that any singleton set is a terminal object in Set is answered by the fact that what counts is the property of being terminal; and this suffices to ensure that any two concrete objects having this property must be isomorphic to each other.

The proof of the proposition, while elementary, is a first example of distinctively categorical reasoning.

If II and I′I^{\prime} are initial objects in the category C\mathcal{C} then there exists a unique isomorphism I⟶≅I′I\stackrel{{\scriptstyle\cong}}{{\longrightarrow}}I^{\prime}.

Proof: Since II is initial and I′I^{\prime} is an object of C\mathcal{C}, there is a unique arrow ιI′:I→I′\iota_{I^{\prime}}:I\rightarrow I^{\prime}. We claim that ιI′\iota_{I^{\prime}} is an isomorphism. Since I′I^{\prime} is initial and II is an object in C\mathcal{C}, there is an arrow ιI′:I′→I\iota^{\prime}_{I}:I^{\prime}\rightarrow I. Thus we obtain ιI′;ιI′:I→I\iota_{I^{\prime}};\iota^{\prime}_{I}:I\rightarrow I, while we also have the identity morphism \mspace1.5muidI:I→I\mspace{1.5mu}\mathsf{id}_{I}:I\rightarrow I. But II is initial and therefore there exists a unique arrow from II to II, which means that ιI′;ιI′=\mspace1.5muidI\iota_{I^{\prime}};\iota^{\prime}_{I}=\mspace{1.5mu}\mathsf{id}_{I}. Similarly, ιI′;ιI′=\mspace1.5muidI′\iota^{\prime}_{I};\iota_{I^{\prime}}=\mspace{1.5mu}\mathsf{id}_{I^{\prime}}, so ιI′\iota_{I^{\prime}} is indeed an isomorphism. ■\blacksquare Hence, initial objects are “unique up to (unique) isomorphism”, and we can (and do) speak of the initial object (if any such exists). Similarly for terminal objects.

Let C\mathcal{C} be a category with an initial object 0\mathbf{0}. For any object AA, show the following.

If A≅0A\cong\mathbf{0} then AA is an initial object.

If there exists a monomorphism f:A→0f:A\rightarrow\mathbf{0} then ff is an iso, and hence AA is initial.

2.2 Products and Coproducts

We now consider one of the most common constructions in mathematics: the formation of “direct products”. Once again, rather than giving a case-by-case construction of direct products in each mathematical context we encounter, we can express once and for all a general notion of product, meaningful in any category — and such that, if a product exists, it is characterised uniquely up to unique isomorphism, just as for initial and terminal objects. Given a particular mathematical context, i.e. a category, we can then verify whether on not the product exists in that category. The concrete construction appropriate to the context will enter only into the proof of existence; all of the useful properties of the product follow from the general definition. Moreover, the categorical notion of product has a normative force; we can test whether a concrete construction works as intended by verifying that it satisfies the general definition.

In set theory, the cartesian product is defined in terms of the ordered pair:

It turns out that ordered pairs can be defined in set theory, e.g. as

Note that in no sense is such a definition canonical. The essential properties of ordered pairs are:

We can retrieve the first and second components xx, yy of the ordered pair (x,y)(x,y), allowing projection functions to be defined:

The information about first and second components completely determines the ordered pair:

The categorical definition expresses these properties in arrow-theoretic terms, meaningful in any category.

Let AA, BB be objects in a category C\mathcal{C}. An AA,BB–pairing is a triple (P,p1,p2)(P,p_{1},p_{2}) where PP is an object, p1:P→Ap_{1}:P\rightarrow A and p2:P→Bp_{2}:P\rightarrow B. A morphism of AA,BB–pairings

is a morphism f:P→Qf:P\rightarrow Q in C\mathcal{C} such that q1∘f=p1q_{1}\circ f=p_{1} and q2∘f=p2q_{2}\circ f=p_{2} , i.e. the following diagram commutes.

The AA,BB–pairings form a category Pair(A,B)\mathbf{Pair}(A,B). We say that (A×B,π1,π2)(A\times B,\pi_{1},\pi_{2}) is a product of AA and BB if it is terminal in Pair(A,B)\mathbf{Pair}(A,B). ▲\blacktriangle

Verify that Pair(A,B)\mathbf{Pair}(A,B) is a category.

Note that products are specified by triples A⟵π1A×B⟶π2BA\overset{\pi_{1}}{\longleftarrow}A\times B\overset{\pi_{2}}{\longrightarrow}B, where πi\pi_{i}’s are called projections. For economy (and if projections are obvious) we may say that A×BA\times B is the product of AA and BB. We say that C\mathcal{C} has (binary) products if each pair of objects A,BA,B has a product in C\mathcal{C}. A direct consequence of the definition, by Proposition 0.2.5, is that if products exist, they are unique up to (unique) isomorphism.

Unpacking the uniqueness condition from Pair(A,B)\mathbf{Pair}(A,B) back to C\mathcal{C} we obtain a more concise definition of products which we use in practice.

Let A,BA,B be objects in a category C\mathcal{C}. A product of AA and BB is an object A×BA\times B together with a pair of arrows A⟵π1A×B⟶π2BA\overset{\pi_{1}}{\longleftarrow}A\times B\overset{\pi_{2}}{\longrightarrow}B such that for every triple A⟵fC⟶gBA\overset{f}{\longleftarrow}C\overset{g}{\longrightarrow}B there exists a unique morphism

such that the following diagram commutes.

We call ⟨f,g⟩\langle f,g\rangle the pairing of ff and gg.

Note that the above diagram features a dashed arrow. Our intention with such diagrams is always to express the following idea: if the undashed part of the diagram commutes, then there exists a unique arrow (the dashed one) such that the whole diagram commutes. In any case, we shall always spell out the intended statement explicitly.

We look at how this definition works in our standard example categories.

In Set, products are the usual cartesian products.

In Pos, products are cartesian products with the pointwise order.

In Top, products are cartesian products with the product topology.

In Vectk\text{{Vect}}_{k}, products are direct sums.

In a poset, seen as a category, products are greatest lower bounds.

The following proposition shows that the uniqueness of the pairing arrow can be specified purely equationally, by the equation:

For any triple A⟵π1A×B⟶π2BA\overset{\pi_{1}}{\longleftarrow}A\times B\overset{\pi_{2}}{\longrightarrow}B the following statements are equivalent.

For any triple A⟵fC⟶gBA\overset{f}{\longleftarrow}C\overset{g}{\longrightarrow}B there exists a unique morphism ⟨f,g⟩:C→A×B\langle f,g\rangle:C\rightarrow A\times B such that π1∘⟨f,g⟩=f\pi_{1}\circ\langle f,g\rangle=f and π2∘⟨f,g⟩=g\pi_{2}\circ\langle f,g\rangle=g.

For any triple A⟵fC⟶gBA\overset{f}{\longleftarrow}C\overset{g}{\longrightarrow}B there exists a morphism ⟨f,g⟩:C→A×B\langle f,g\rangle:C\rightarrow A\times B such that π1∘⟨f,g⟩=f\pi_{1}\circ\langle f,g\rangle=f and π2∘⟨f,g⟩=g\pi_{2}\circ\langle f,g\rangle=g, and moreover, for any h:C→A×Bh:C\rightarrow A\times B, h=⟨π1∘h,π2∘h⟩h=\langle\pi_{1}\circ h,\pi_{2}\circ h\rangle.

Proof: For (I)⇒\Rightarrow(II), take any h:C→A×Bh:C\rightarrow A\times B ; we need to show h=⟨π1∘h,π2∘h⟩h=\langle\pi_{1}\circ h,\pi_{2}\circ h\rangle. We have

and hence, by (I), there exists unique k:C→A×Bk:C\rightarrow A\times B such that

Note now that (∗*) holds both for k:=hk:=h and k:=⟨π1∘h,π2∘h⟩k:=\langle\pi_{1}\circ h,\pi_{2}\circ h\rangle, the latter because of (I). Hence, h=⟨π1∘h,π2∘h⟩h=\langle\pi_{1}\circ h,\pi_{2}\circ h\rangle. For (II)⇒\Rightarrow(I), take any triple A⟵fC⟶gBA\overset{f}{\longleftarrow}C\overset{g}{\longrightarrow}B. By (II), we have that there exists an arrow ⟨f,g⟩:C→A×B\langle f,g\rangle:C\rightarrow A\times B such that π1∘⟨f,g⟩=f\pi_{1}\circ\langle f,g\rangle=f and π2∘⟨f,g⟩=g\pi_{2}\circ\langle f,g\rangle=g. We need to show it is the unique such. Let k:C→A×Bk:C\rightarrow A\times B s.t.

as required. ■\blacksquare In the following proposition we give some useful properties of products. First, let us introduce some notation for arrows: given f1:A1→B1f_{1}:A_{1}\rightarrow B_{1}, f2:A2→B2f_{2}:A_{2}\rightarrow B_{2}, define

For any f:A→Bf:A\rightarrow B, g:A→Cg:A\rightarrow C, h:A′→Ah:A^{\prime}\rightarrow A, and any p:B→B′p:B\rightarrow B^{\prime}, q:C→C′q:C\rightarrow C^{\prime},

⟨f,g⟩∘h=⟨f∘h,g∘h⟩\langle f,g\rangle\circ h=\langle f\circ h,g\circ h\rangle,

(p×q)∘⟨f,g⟩=⟨p∘f,q∘g⟩.(p\times q)\circ\langle f,g\rangle=\langle p\circ f,q\circ g\rangle.

The notion of products can be generalised to arbitrary arities as follows. A product for a family of objects {Ai}i∈I\{A_{i}\}_{i\in I} in a category C\mathcal{C} is an object PP and morphisms

such that, for all objects BB and arrows

such that, for all i∈Ii\in I, the following diagram commutes.

g<spanclass="katex−display"><spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"display="block"><semantics><mrow><mstylescriptlevel="1"displaystyle="false"><msub><mi>f</mi><mi>i</mi></msub></mstyle></mrow><annotationencoding="application/x−tex">fi</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.6222em;vertical−align:−0.1361em;"></span><spanclass="mordmtightsizingreset−size6size3"><spanclass="mordmtight"><spanclass="mordmathnormalmtight"style="margin−right:0.1076em;">f</span><spanclass="msupsub"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.3281em;"><spanstyle="top:−2.357em;margin−left:−0.1076em;margin−right:0.0714em;"><spanclass="pstrut"style="height:2.5em;"></span><spanclass="sizingreset−size3size1mtight"><spanclass="mordmtight"><spanclass="mordmathnormalmtight">i</span></span></span></span></span><spanclass="vlist−s">​</span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span></span>P\ignorespaces\ignorespaces\ignorespaces\ignorespaces<spanclass="katex−display"><spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"display="block"><semantics><mrow><mstylescriptlevel="1"displaystyle="false"><msub><mi>p</mi><mi>i</mi></msub></mstyle></mrow><annotationencoding="application/x−tex">pi</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.4375em;vertical−align:−0.1361em;"></span><spanclass="mordmtightsizingreset−size6size3"><spanclass="mordmtight"><spanclass="mordmathnormalmtight">p</span><spanclass="msupsub"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.3281em;"><spanstyle="top:−2.357em;margin−left:0em;margin−right:0.0714em;"><spanclass="pstrut"style="height:2.5em;"></span><spanclass="sizingreset−size3size1mtight"><spanclass="mordmtight"><spanclass="mordmathnormalmtight">i</span></span></span></span></span><spanclass="vlist−s">​</span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span></span>Ai\scriptstyle{g}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><msub><mi>f</mi><mi>i</mi></msub></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{f_{i}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6222em;vertical-align:-0.1361em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.1076em;">f</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3281em;"><span style="top:-2.357em;margin-left:-0.1076em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span></span>\textstyle{P\ignorespaces\ignorespaces\ignorespaces\ignorespaces}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><msub><mi>p</mi><mi>i</mi></msub></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{p_{i}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4375em;vertical-align:-0.1361em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mtight"><span class="mord mathnormal mtight">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3281em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span></span>\textstyle{A_{i}} As before, if such a product exists, it is unique up to (unique) isomorphism. We write P=∏i∈IAiP=\prod_{i\in I}A_{i} for the product object, and g=⟨fi∣i∈I⟩g=\langle f_{i}\mid i\in I\rangle for the unique morphism in the definition.

Show that if a category has binary and nullary products then it has all finite products.

We now investigate the dual notion to products: namely coproducts. Formally, coproducts in C\mathcal{C} are just products in Cop\mathcal{C}^{\mathsf{op}}, interpreted back in C\mathcal{C} . We spell out the definition.

Let A,BA,B be objects in a category C\mathcal{C}. A coproduct of AA and BB is an object A+BA+B together with a pair of arrows A⟶\mspace1.5muin1A+B⟵\mspace1.5muin2BA\overset{\mspace{1.5mu}\mathsf{in}_{1}}{\longrightarrow}A+B\overset{\mspace{1.5mu}\mathsf{in}_{2}}{\longleftarrow}B such that for every triple A⟶fC⟵gBA\overset{f}{\longrightarrow}C\overset{g}{\longleftarrow}B there exists a unique morphism

such that the following diagram commutes.

We call the \mspace1.5muini\mspace{1.5mu}\mathsf{in}_{i}’s injections and [f,g][f,g] the copairing of ff and gg. As with pairings, uniqueness of copairings can be specified by an equation:

This is given by disjoint union of sets, which can be defined concretely e.g. by

Also, given functions f:X⟶Zf:X\longrightarrow Z and g:Y⟶Zg:Y\longrightarrow Z, we can define

Check that this construction does yield coproducts in Set.

Note that this example suggests that coproducts allow for definition by cases.

Let us examine coproducts for some of our other standard examples.

In Pos, disjoint unions (with the inherited orders) are coproducts.

In Top, topological disjoint unions are coproducts.

In Vectk\text{{Vect}}_{k}, direct sums are coproducts.

In a poset, least upper bounds are coproducts.

Dually to products, express coproducts as initial objects of a category Copair(A,B)\mathbf{Copair}(A,B) of AA,BB–copairings.

2.3 Pullbacks and Equalisers

We shall consider two further constructions of interest: pullbacks and equalisers.

Consider a pair of morphisms A⟶fC⟵gBA\overset{f}{\longrightarrow}C\overset{g}{\longleftarrow}B. The pull-back of ff along gg is a pair A⟵pD⟶qBA\overset{p}{\longleftarrow}D\overset{q}{\longrightarrow}B such that f∘p=g∘qf\circ p=g\circ q and, for any pair A⟵p′D′⟶q′BA\overset{p^{\prime}}{\longleftarrow}D^{\prime}\overset{q^{\prime}}{\longrightarrow}B such that f∘p′=g∘q′f\circ p^{\prime}=g\circ q^{\prime}, there exists a unique h:D′→Dh:D^{\prime}\rightarrow D such that p′=p∘hp^{\prime}=p\circ h and q′=q∘hq^{\prime}=q\circ h. Diagrammatically,

\scriptstyle{h}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><msup><mi>q</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{q^{\prime}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7156em;vertical-align:-0.1361em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.0359em;">q</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8278em;"><span style="top:-2.931em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span></span></span>\scriptstyle{p^{\prime}}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mrow><mi>D</mi><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle></mrow></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{D\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0278em;">D</span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span></span></span></span></span></span>\scriptstyle{q}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mi>p</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{p}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4375em;vertical-align:-0.1361em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight">p</span></span></span></span></span></span>\textstyle{B\ignorespaces\ignorespaces\ignorespaces\ignorespaces}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mi>g</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{g}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4375em;vertical-align:-0.1361em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight" style="margin-right:0.0359em;">g</span></span></span></span></span></span>\textstyle{A\ignorespaces\ignorespaces\ignorespaces\ignorespaces}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mi>f</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{f}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6222em;vertical-align:-0.1361em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight" style="margin-right:0.1076em;">f</span></span></span></span></span></span>\textstyle{C} ▲\blacktriangle

In Set the pullback of A⟶fC⟵gBA\overset{f}{\longrightarrow}C\overset{g}{\longleftarrow}B is defined as a subset of the cartesian product:

For example, consider a category C\mathcal{C} with

Then the pullback of dom\mathsf{dom} along cod\mathsf{cod} is the set of composable morphisms, i.e. pairs of morphisms (f,g)(f,g) in C\mathcal{C} such that f∘gf\circ g is well-defined.

In Set again, subsets (i.e. inclusion maps) pull back to subsets:

Let C\mathcal{C} be a category with a terminal object 1\mathbf{1}. Show that, for any A,B∈Ob(C)A,B\in Ob(\mathcal{C}), the pullback of A→τA1←τBBA\xrightarrow{\tau_{A}}\mathbf{1}\xleftarrow{\tau_{B}}B is the product of AA and BB, if it exists.

Just as for products, pullbacks can equivalently be described as terminal objects in suitable categories. Given a pair of morphisms A⟶fC⟵gBA\overset{f}{\longrightarrow}C\overset{g}{\longleftarrow}B, we define an (f,g)(f,g)–cone to be a triple (D,p,q)(D,p,q) such that the following diagram commutes.

A morphism of (f,g)(f,g)–cones h:(D1,p1,q1)→(D2,p2,q2)h:(D_{1},p_{1},q_{1})\rightarrow(D_{2},p_{2},q_{2}) is a morphism h:D1→D2h:D_{1}\rightarrow D_{2} such that the following diagram commutes.

We can thus form a category Cone(f,g)(f,g). A pull-back of ff along gg, if it exists, is exactly a terminal object of Cone(f,g)(f,g). Once again, this shows the uniqueness of pullbacks up to unique isomorphism.

Consider a pair of parallel arrows A \ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces<spanclass="katex−display"><spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"display="block"><semantics><mrow><mstylescriptlevel="1"displaystyle="false"><mi>g</mi></mstyle></mrow><annotationencoding="application/x−tex">g</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.4375em;vertical−align:−0.1361em;"></span><spanclass="mordmtightsizingreset−size6size3"><spanclass="mordmathnormalmtight"style="margin−right:0.0359em;">g</span></span></span></span></span></span>f\textstyle{A\ \ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mi>g</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{g}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4375em;vertical-align:-0.1361em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight" style="margin-right:0.0359em;">g</span></span></span></span></span></span>\scriptstyle{f} B\textstyle{\ B}. An equaliser of (f,g)(f,g) is an arrow e:E→Ae:E\rightarrow A such that f∘e=g∘ef\circ e=g\circ e and, for any arrow h:D→Ah:D\rightarrow A such that f∘h=g∘hf\circ h=g\circ h, there is a unique h^:D→E\hat{h}:D\rightarrow E so that h=e∘h^h=e\circ\hat{h}. Diagrammatically,

\scriptstyle{e}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mrow><mi>A</mi><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle></mrow></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{A\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span></span></span></span></span></span>\scriptstyle{g}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mi>f</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{f}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6222em;vertical-align:-0.1361em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight" style="margin-right:0.1076em;">f</span></span></span></span></span></span>\textstyle{B}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mrow><mi>D</mi><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle></mrow></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{D\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0278em;">D</span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span></span></span></span></span></span>\scriptstyle{h}h^\scriptstyle{\hat{h}} ▲\blacktriangle

As for products, uniqueness of the arrow from DD to EE can be expressed equationally:

Why is e∘k^\widehat{e\circ k} well-defined for any k:D→Ek:D\rightarrow E? Prove that the above equation is equivalent to the uniqueness requirement.

In Set, the equaliser of f,gf,g is given by the inclusion

2.4 Limits and Colimits

The notions we have introduced so far are all special cases of a general notion of limits in categories, and the dual notion of colimits.

An important aspect of studying any kind of mathematical structure is to see what limits and colimits the category of such structures has. We shall return to these ideas shortly.

2.5 Exercises

Give an example of a category where some pair of objects lacks a product or coproduct.

(Pullback lemma) Consider the following commutative diagram.

Given that the right hand square BCEFBCEF and the outer square ACDFACDF are pullbacks, prove that the left hand square ABDEABDE is a pullback.

Consider A⟶fC⟵gBA\overset{f}{\longrightarrow}C\overset{g}{\longleftarrow}B with pullback A⟵pD⟶qBA\overset{p}{\longleftarrow}D\overset{q}{\longrightarrow}B. For each A⟵p′D′⟶q′B′A\overset{p^{\prime}}{\longleftarrow}D^{\prime}\overset{q^{\prime}}{\longrightarrow}B^{\prime} with f∘p′=g∘q′f\circ p^{\prime}=g\circ q^{\prime}, let ϕ(p′,q′):D′→D\phi(p^{\prime},q^{\prime}):D^{\prime}\rightarrow D be the arrow dictated by the pullback condition. Express uniqueness of ϕ(p′,q′)\phi(p^{\prime},q^{\prime}) equationally.

3 Functors

Don’t just look at the objects; take the morphisms into account too.

A functor F:C→DF:\mathcal{C}\rightarrow\mathcal{D} is given by:

An object-map, assigning an object FAFA of D\mathcal{D} to every object AA of C\mathcal{C}.

An arrow-map, assigning an arrow Ff:FA→FBFf:FA\rightarrow FB of D\mathcal{D} to every arrow f:A→Bf:A\rightarrow B of C\mathcal{C}, in such a way that composition and identities are preserved:

Note that we use the same symbol to denote the object- and arrow-maps; in practice, this never causes confusion. Since functors preserve domains and codomains of arrows, for each pair of objects AA, BB of C\mathcal{C}, there is a well-defined map

The conditions expressing preservation of composition and identities are called functoriality.

Let (P,≤)(P,\leq), (Q,≤)(Q,\leq) be preorders (seen as categories). A functor F:(P,≤)⟶(Q,≤)F:(P,\leq)\longrightarrow(Q,\leq) is specified by an object-map, say F:P→QF:P\rightarrow Q, and an appropriate arrow-map. The arrow-map corresponds to the condition

i.e. to monotonicity of FF. Moreover, the functoriality conditions are trivial since in the codomain (Q,≤)(Q,\leq) all hom-sets are singletons. Hence, a functor between preorders is just a monotone map.

Let (M,⋅,1)(M,\cdot,1), (N,⋅,1)(N,\cdot,1) be monoids. A functor F:(M,⋅,1)⟶(N,⋅,1)F:(M,\cdot,1)\longrightarrow(N,\cdot,1) is specified by a trivial object map (monoids are categories with a single object) and an arrow-map, say F:M→NF:M\rightarrow N. The functoriality conditions correspond to

i.e. to FF being a monoid homomorphism. Hence, a functor between monoids is just a monoid homomorphism.

Inclusion of a sub-category, C↪D\mathcal{C}\hookrightarrow\mathcal{D}, is a functor (by taking the identity map for object- and arrow-map).

The covariant powerset functor P:Set→Set\mathcal{P}:\mathbf{Set}\rightarrow\mathbf{Set}:

U:Mon→SetU:\textbf{Mon}\rightarrow\textbf{Set} is the ‘forgetful’ or ‘underlying’ functor which sends a monoid to its set of elements, ‘forgetting’ the algebraic structure, and sends a homomorphism to the corresponding function between sets. There are similar forgetful functors for other categories of structured sets. Why are these trivial-looking functors useful? — We shall see!

Group theory examples. The assignment of the commutator sub-group of a group extends to a functor from Group to Group; and the assignment of the quotient by this normal subgroup extends to a functor from Group to AbGroup. The assignment of the centraliser of a group does not!

More sophisticated examples: e.g. homology. The basic idea of algebraic topology is that there are functorial assignments of algebraic objects (e.g. groups) to topological spaces, and variants of this idea (‘(co)homology theories’) are pervasive throughout modern pure mathematics.

We can generalise the notion of a functor to a mapping from several domain categories to a codomain category. For this we need the following definition.

For categories C,D\mathcal{C},\mathcal{D} define the product category C×D\mathcal{C}\times\mathcal{D} as follows. An object in C×D\mathcal{C}\times\mathcal{D} is a pair of objects from C\mathcal{C} and D\mathcal{D}, and an arrow in C×D\mathcal{C}\times\mathcal{D} is a pair of arrows from C\mathcal{C} and D\mathcal{D}. Identities and arrow composition are defined componentwise:

A functor ‘of two variables’, with domains C\mathcal{C} and D\mathcal{D}, to E\mathcal{E} is simply a functor:

For example, there are evident projection functors

3.2 Further Examples

Many important constructions arise as functors F:C→SetF:\mathcal{C}\rightarrow\textbf{Set}. For example:

If GG is a group, a functor F:G→SetF:G\rightarrow\textbf{Set} is an action of GG on a set.

If PP is a poset representing time, a functor F:P→SetF:P\rightarrow\textbf{Set} is a notion of set varying through time. This is related to Kripke semantics, and to forcing arguments in set theory.

Let us examine the first example in more detail. For a group (G,⋅,1)(G,\cdot,1), a functor F:G→SetF:G\rightarrow\textbf{Set} is specified by a set XX (to which the unique object of GG is mapped), and by an arrow-map sending each element mm of GG to an endofunction on XX, say m ∙_ ⁣_:X→X\mathop{m\,_{{}^{\bullet}}}\_\!\_:X\rightarrow X. Then, functoriality amounts to the conditions

that is, for all m1,m2∈Gm_{1},m_{2}\in G and all x∈Xx\in X,

We therefore see that FF defines an action of GG on XX.

Data-type constructors are functors. As a basic example, we consider lists. There is a functor

which takes a set XX to the set of all finite lists (sequences) of elements of XX. List\mathsf{List} is functorial: its action on morphisms (i.e. functions, i.e. (functional) programs) is given by maplist:

We can upgrade List\mathsf{List} to a functor MList:Set→Mon\mathsf{MList}:\textbf{Set}\rightarrow\textbf{Mon} by mapping each set XX to the monoid (List(X),∗,ϵ)(\mathsf{List}(X),*,\epsilon) and f:X→Yf:X\rightarrow Y to List(f)\mathsf{List}(f), as above. The monoid operation ∗:List(X)×List(X)→List(X)*:\mathsf{List}(X)\times\mathsf{List}(X)\rightarrow\mathsf{List}(X) is list concatenation, and ϵ\epsilon is the empty list. We call MList(X)\mathsf{MList}(X) the free monoid over XX. This terminology will be justified in Chapter 5.

If a category C\mathcal{C} has binary products, then there is automatically a functor

which takes each pair (A,B)(A,B) to the product A×BA\times B, and each (f,g)(f,g) to

Functoriality is shown as follows, using proposition 0.2.12 and uniqueness of pairings in its equational form.

There is a category Cat whose objects are categories, and whose arrows are functors. Identities in Cat are given by identity functors:

Composition of functors is defined in the evident fashion. Note that if F:C→DF:\mathcal{C}\rightarrow\mathcal{D} and G:D→EG:\mathcal{D}\rightarrow\mathcal{E} then, for f:A→Bf:A\rightarrow B in C\mathcal{C},

so the types work out. A category of categories sounds (and is) circular, but in practice is harmless: one usually makes some size restriction on the categories, and then Cat will be too ‘big’ to be an object of itself. See Appendix A.

Note that product categories are products in Cat! For any pair of categories C,D\mathcal{C},\mathcal{D}, set

where C×D\mathcal{C}\times\mathcal{D} the product category (defined previously) and πi\boldsymbol{\pi}_{i}’s the obvious projection functors. For any pair of functors C⟵FE⟶GD\mathcal{C}\overset{F}{\longleftarrow}\mathcal{E}\overset{G}{\longrightarrow}\mathcal{D}, set

It is easy to see that ⟨F,G⟩\langle F,G\rangle is indeed a functor. Moreover, satisfaction of the product diagram and uniqueness are shown exactly as in Set.

3.3 Contravariance

By definition, the arrow-map of a functor FF is covariant: it preserves the direction of arrows, so if f:A→Bf:A\rightarrow B then Ff:FA→FBFf:FA\rightarrow FB. A contravariant functor GG does exactly the opposite: it reverses arrow-direction, so if f:A→Bf:A\rightarrow B then Gf:GB→GAGf:GB\rightarrow GA. A concise way to express contravariance is as follows.

Let C,D\mathcal{C},\mathcal{D} be categories. A contravariant functor GG from C\mathcal{C} to D\mathcal{D} is a functor G:Cop→DG:\mathcal{C}^{\mathsf{op}}\rightarrow\mathcal{D}. (Equivalently, a functor G:C→DopG:\mathcal{C}\rightarrow\mathcal{D}^{\mathsf{op}}.) ▲\blacktriangle

Explicitly, a contravariant functor GG is given by an assignment of:

an object GAGA in D\mathcal{D} to every object AA in C\mathcal{C},

an arrow Gf:GB→GAGf:GB\rightarrow GA in D\mathcal{D} to every arrow f:A→Bf:A\rightarrow B in C\mathcal{C}, such that (notice the change of order in composition):

Note that functors of several variables can be covariant in some variables and contravariant in others, e.g.

The contravariant powerset functor, Pop:Setop→Set\mathcal{P}^{\mathsf{op}}:\textbf{Set}^{\mathsf{op}}\rightarrow\textbf{Set} , is given by:

Note that these are both examples of the following idea: send an object AA into functions from AA into some fixed object. For example, the powerset can be written as P(X)=2X\mathcal{P}(X)=2^{X}, where we think of a subset in terms of its characteristic function.

We now consider some fundamental examples of Set-valued functors. Given a category C\mathcal{C} and an object AA of C\mathcal{C}, two functors to Set can be defined:

which is given by (recall that each C(A,B)\mathcal{C}(A,B) is a set):

We usually write C(A,_ ⁣_)(f)\mathcal{C}(A,\_\!\_)(f) as C(A,f)\mathcal{C}(A,f). Functoriality reduces directly to the basic category axioms: associativity of composition and the unit laws for the identity.

There is also a contravariant Hom-functor,

Generalising both of the above, we obtain a bivariant Hom-functor,

Spell out the definition of C(_ ⁣_ ,_ ⁣_):Cop×C⟶Set\mathcal{C}(\_\!\_\,,\_\!\_):\mathcal{C}^{\mathsf{op}}\times\mathcal{C}\longrightarrow\textbf{Set}. Verify carefully that it is a functor.

3.4 Properties of Functors

A functor F:C→DF:\mathcal{C}\rightarrow\mathcal{D} is said to be:

faithful if each map FA,B:C(A,B)→D(FA,FB)F_{A,B}:\mathcal{C}(A,B)\rightarrow\mathcal{D}(FA,FB) is injective;

full if each map FA,B:C(A,B)→D(FA,FB)F_{A,B}:\mathcal{C}(A,B)\rightarrow\mathcal{D}(FA,FB) is surjective;

an embedding if FF is full, faithful, and injective on objects;

an equivalence if FF is full, faithful, and essentially surjective: i.e. for every object BB of D\mathcal{D} there is an object AA of C\mathcal{C} such that F(A)≅BF(A)\cong B;

an isomorphism if there is a functor G:D→CG:\mathcal{D}\rightarrow\mathcal{C} such that

We say that categories C\mathcal{C} and D\mathcal{D} are isomorphic, C≅D\mathcal{C}\cong\mathcal{D}, if there is an isomorphism between them. Note that this is just the usual notion of isomorphism applied to Cat. Examples:

The forgetful functor U:Mon→SetU:\textbf{Mon}\rightarrow\textbf{Set} is faithful, but not full. For the latter, note that not all functions f:M→Nf:M\rightarrow N yield an arrow f:(M,⋅,1)→(N,⋅,1)f:(M,\cdot,1)\rightarrow(N,\cdot,1). Similar properties hold for other forgetful functors.

The free monoid functor MList:Set→Mon\mathsf{MList}:\textbf{Set}\rightarrow\textbf{Mon} is faithful, but not full.

There is an equivalence between FDVectk\text{{FDVect}}_{k} the category of finite dimensional vector spaces over the field kk, and Matk\text{{Mat}}_{k}, the category of matrices with entries in kk. Note that these categories are very far from isomorphic! This example is elaborated in exercise 0.3.5(1).

Let PP be a property of arrows. We say that a functor F:C→DF:\mathcal{C}\rightarrow\mathcal{D} preserves PP if whenever ff satisfies PP, so does F(f)F(f). We say that FF reflects PP if whenever F(f)F(f) satisfies PP, so does ff. For example:

All functors preserve isomorphisms, split monics and split epics.

Faithful functors reflect monics and epics.

Full and faithful functors reflect isomorphisms.

The forgetful functor U:Mon→SetU:\textbf{Mon}\rightarrow\textbf{Set} preserves products.

Let us show c; the rest are given as exercises below. So let f:A→Bf:A\rightarrow B in C\mathcal{C} be such that FfFf is an iso, that is, it has an inverse g′:FB→FAg^{\prime}:FB\rightarrow FA. Then, by fullness, there exists some g:B→Ag:B\rightarrow A so that g′=Fgg^{\prime}=Fg. Thus,

By faithfulness we obtain g∘f=\mspace1.5muidAg\circ f=\mspace{1.5mu}\mathsf{id}_{A} . Similarly, f∘g=\mspace1.5muidBf\circ g=\mspace{1.5mu}\mathsf{id}_{B} and therefore ff is an isomorphism.

Functors do not in general reflect monics or epics.

Faithful functors do not in general reflect isomorphisms.

Full and faithful functors do not in general preserve monics or epics.

3.5 Exercises

Let C\mathcal{C} be a category with binary products such that, for each pair of objects A,BA,B,

Show that the product functor F:C×C→CF:\mathcal{C}\times\mathcal{C}\rightarrow\mathcal{C} is faithful. Would FF still be faithful in the absence of condition (∗* ‣ 2)?

4 Natural Transformations

“Categories were only introduced to allow functors to be defined; functors were only introduced to allow natural transformations to be defined.”

Just as categories have morphisms between them, namely functors, so functors have morphisms between them too — natural transformations.

Let F,G:C→DF,G:\mathcal{C}\rightarrow\mathcal{D} be functors. A natural transformation

is a family of morphisms in D\mathcal{D} indexed by objects AA of C\mathcal{C},

such that, for all f:A→Bf:A\rightarrow B, the following diagram commutes.

This condition is known as naturality. If each tAt_{A} is an isomorphism, we say that tt is a natural isomorphism:

Let Id\mathsf{Id} be the identity functor on Set, and ×∘⟨Id,Id⟩\times\circ\langle\mathsf{Id},\mathsf{Id}\rangle be the functor taking each set XX to X×XX\times X and each function ff to f×ff\times f. Then, there is a natural transformation Δ:Id⟶×∘⟨Id,Id⟩\Delta:\mathsf{Id}\longrightarrow\times\circ\langle\mathsf{Id},\mathsf{Id}\rangle given by:

Naturality amounts to asserting that, for any function f:X→Yf:X\rightarrow Y, the following diagram commutes.

We call Δ\Delta the diagonal transformation on Set. In fact, it is the only natural transformation between these functors.

The diagonal transformation can be defined for any category C\mathcal{C} with binary products by setting, for each object AA in C\mathcal{C},

Projections also yield natural transformations. For example the arrows

specify a natural transformation π1:×→π1\pi_{1}:\times\rightarrow\boldsymbol{\pi}_{1} . Note that ×,π1:C×C→C\times,\boldsymbol{\pi}_{1}:\mathcal{C}\times\mathcal{C}\rightarrow\mathcal{C} are the functors for product and first projection respectively.

Let C\mathcal{C} be a category with terminal object TT, and let KT:C→CK_{T}:\mathcal{C}\rightarrow\mathcal{C} be the functor mapping all objects to TT and all arrows to \mspace1.5muidT\mspace{1.5mu}\mathsf{id}_{T}. Then, the canonical arrows

specify a natural transformation τ:Id→KT\tau:\mathsf{Id}\rightarrow K_{T} (where Id\mathsf{Id} the identity functor on C\mathcal{C}).

Recall the functor List:Set→Set\mathsf{List}:\textbf{Set}\rightarrow\textbf{Set} which takes a set XX to the set of finite lists with elements in XX. We can define (amongst others) the following natural transformations,

Consider the functor P:=×∘⟨U,U⟩P:=\times\circ\langle U,U\rangle with U:Mon→SetU:\textbf{Mon}\rightarrow\textbf{Set}, i.e.

Then, the monoid operation yields a natural transformation t:P→Ut:P\rightarrow U defined by:

Naturality corresponds to asserting that, for any f:(M,⋅,1)→(N,⋅,1)f:(M,\cdot,1)\rightarrow(N,\cdot,1), the following diagram commutes,

that is, for any m1,m2∈Mm_{1},m_{2}\in M, f(m1)⋅f(m2)=f(m1⋅m2)f(m_{1})\cdot f(m_{2})=f(m_{1}\cdot m_{2}).

If VV is a finite dimensional vector space, then VV is isomorphic to both its first dual V∗V^{\ast} and to its second dual V∗∗V^{\ast\ast}. However, while it is naturally isomorphic to its second dual, there is no natural isomorphism to the first dual. This was actually the original example which motivated Eilenberg and Mac Lane to define the concept of natural transformation; here naturality captures basis independence.

Verify naturality of diagonal transformations, projections and terminals for a category C\mathcal{C} with finite products.

Prove that the diagonal is the only natural transformation Id⟶×∘⟨Id,Id⟩\mathsf{Id}\longrightarrow\times\circ\langle\mathsf{Id},\mathsf{Id}\rangle on Set. Similarly, prove that the first projection is the only natural transformation ×→π1\times\rightarrow\boldsymbol{\pi}_{1} on Set.

4.2 Further Examples

Let C\mathcal{C} be a category with finite products, i.e. binary products and a terminal object 1\mathbf{1}. Then, we have the following canonical natural isomorphisms.

The first two isomorphisms are meant to assert that the product is associative and symmetric, and the last two that 1\mathbf{1} is its unit. In later sections we will see that these conditions form part of the definition of symmetric monoidal categories.

These natural isomorphisms are defined explicitly by:

Since natural isomorphisms are a self-dual notion, similar natural isomorphisms can be defined if C\mathcal{C} has binary coproducts and an initial object.

Verify that these families of arrows are natural isomorphisms.

Let f:A→Bf:A\rightarrow B in a category C\mathcal{C}. Then, this induces a natural transformation

Note that C(f,_ ⁣_)C\mathcal{C}(f,\_\!\_)_{C} is the same as C(f,C)\mathcal{C}(f,C), the result of applying the contravariant functor C(_ ⁣_ ,C)\mathcal{C}(\_\!\_\,,C) to ff. Hence, naturality amounts to asserting that, for each h:C→Dh:C\rightarrow D, the following diagram commutes.

Starting from a g:B→Cg:B\rightarrow C, we compute:

The natural transformation C(_ ⁣_ ,f):C(_ ⁣_ ,A)→C(_ ⁣_ ,B)\mathcal{C}(\_\!\_\,,f):\mathcal{C}(\_\!\_\,,A)\rightarrow\mathcal{C}(\_\!\_\,,B) is defined similarly.

Define the natural transformation C(_ ⁣_ ,f)\mathcal{C}(\_\!\_\,,f) and verify its naturality.

There is a remarkable result, the Yoneda Lemma, which says that every natural transformation between Hom-functors comes from a (unique) arrow in C\mathcal{C} in the fashion described above.

Let A,BA,B be objects in a category C\mathcal{C}. For each natural transformation t:C(A,_ ⁣_)→C(B,_ ⁣_)t:\mathcal{C}(A,\_\!\_)\rightarrow\mathcal{C}(B,\_\!\_), there is a unique arrow f:B→Af:B\rightarrow A such that

Proof: Take any such A,BA,B and tt and let

We want to show that t=C(f,_ ⁣_)t=\mathcal{C}(f,\_\!\_). For any object CC and any arrow g:A→Cg:A\rightarrow C, naturality of tt means that the following commutes.

Starting from \mspace1.5muidA\mspace{1.5mu}\mathsf{id}_{A} we have that:

Hence, noting that C(f,C)(g)=g∘f\mathcal{C}(f,C)(g)=g\circ f, we obtain t=C(f,_ ⁣_)t=\mathcal{C}(f,\_\!\_). For uniqueness we have that, for any f,f′:B→Af,f^{\prime}:B\rightarrow A, if C(f,_ ⁣_)=C(f′,_ ⁣_)\mathcal{C}(f,\_\!\_)=\mathcal{C}(f^{\prime},\_\!\_) then

Prove a similar result for contravariant hom-functors.

Another way of defining equivalence of categories is as follows.

We say that categories C\mathcal{C} and D\mathcal{D} are equivalent, C≃D\mathcal{C}\simeq\mathcal{D}, if there are functors F:C→DF:\mathcal{C}\rightarrow\mathcal{D}, G:D→CG:\mathcal{D}\rightarrow\mathcal{C} and natural isomorphisms

4.3 Functor Categories

Suppose we have functors F,G,H:C→DF,G,H:\mathcal{C}\rightarrow\mathcal{D} and natural transformations

Then, we can compose these natural transformations, yielding u∘t:F→Hu\circ t:F\rightarrow H:

Composition is associative, and has as identity the natural transformation

These observations lead us to the following.

For categories C,D\mathcal{C},\mathcal{D} define the functor category Func(C,D)\mathsf{Func}(\mathcal{C},\mathcal{D}) by taking:

Objects: functors F:C→DF:\mathcal{C}\rightarrow\mathcal{D}.

Arrows: natural transformations t:F→Gt:F\rightarrow G.

Composition and identities are given as above. ▲\blacktriangle

We see that in the category Cat of categories and functors, each hom-set Cat(C,D)\textbf{Cat}(\mathcal{C},\mathcal{D}) itself has the structure of a category. In fact, Cat is the basic example of a “2-category”, i.e. of a category where hom-sets are themselves categories.

Note that a natural isomorphism is precisely an isomorphism in the functor category. Let us proceed to some examples of functor categories.

Recall that, for any group GG, functors from GG to Set are GG-actions on sets. Then, Func(G,Set)\mathsf{Func}(G,\textbf{Set}) is the category of GG-actions on sets and equivariant functions: f:X→Yf:X\rightarrow Y such that f(m ∙x)=m ∙f(x)f(\mathop{m\,_{{}^{\bullet}}}x)=\mathop{m\,_{{}^{\bullet}}}f(x).

If F,G:P→QF,G:P\rightarrow Q are monotone maps between posets, then t:F→Gt:F\rightarrow G means that

Note that in this case naturality is trivial (hom-sets are singletons in QQ).

The composition of natural transformations defined above is called vertical composition. The reason for this terminology is depicted below.

As expected, there is also a horizontal composition, which is given as follows.

4.4 Exercises

By identifying the relevant functors, express pairing ⟨_ ⁣_,_ ⁣_⟩\langle\_\!\_,\_\!\_\rangle as a natural transformation. What does naturality correspond to explicitly?

Show that the two definitions of equivalence of categories, namely

C\mathcal{C} and D\mathcal{D} are equivalent if there is an equivalence F:C→DF:\mathcal{C}\rightarrow\mathcal{D} (definition 0.3.8),

C\mathcal{C} and D\mathcal{D} are equivalent if there are F:C→DF:\mathcal{C}\rightarrow\mathcal{D}, G:D→CG:\mathcal{D}\rightarrow\mathcal{C}, and isomorphisms F∘G≅IdDF\circ G\cong\mathsf{Id}_{\mathcal{D}}, G∘F≅IdCG\circ F\cong\mathsf{Id}_{\mathcal{C}} (definition 0.4.7),

are: equivalent! Note that this will need the Axiom of Choice.

Define a relation on objects in a category C\mathcal{C} by: A≅BA\cong B iff AA and BB are isomorphic.

Show that this relation is an equivalence relation.

Define a skeleton of C\mathcal{C} to be the (full) subcategory obtained by choosing one object from each equivalence class of ≅\cong (note that this involves choices, and is not uniquely defined).

Show that C\mathcal{C} is equivalent to any skeleton.

Show that any two skeletons of C\mathcal{C} are isomorphic.

Give an example of a category whose objects form a proper class, but whose skeleton is finite.

Given a category C\mathcal{C}, we can define a functor

Prove carefully that this is indeed a functor. Use exercise 0.4.6 to conclude that yy is full and faithful. Prove that it is also injective on objects, and hence an embedding. It is known as the Yoneda embedding.

Define the horizontal composition u∙tu\bullet t of natural transformations explicitly. Prove that it is associative.

5 Universality and Adjoints

There is a fundamental triad of categorical notions:

We have studied the first two notions explicitly. We have also seen many examples of universal definitions, notably the various notions of limits and colimits considered in section 0.2. It is now time to consider universality in general; the proper formulation of this fundamental and pervasive notion is one of the major achievements of basic category theory.

Universality arises when we are interested in finding canonical solutions to problems of construction: that is, we are interested not just in the existence of a solution but in its canonicity. This canonicity should guarantee uniqueness, in the sense we have become familiar with: a canonical solution should be unique up to (unique) isomorphism.

The notion of canonicity has a simple interpretation in the case of posets, as an extremal solution: one that is the least or the greatest among all solutions. Such an extremal solution is obviously unique. For example, consider the problem of finding a lower bound of a pair of elements AA, BB in a poset PP: a greatest lower bound of AA and BB is an extremal solution to this problem. As we have seen, this is the specialisation to posets of the problem of constructing a product:

A product of AA, BB in a poset is an element CC such that C≤AC\leq A and C≤BC\leq B, (CC is a lower bound);

and for any other solution C′C^{\prime}, i.e. C′C^{\prime} such that C′≤AC^{\prime}\leq A and C′≤BC^{\prime}\leq B, we have C′≤CC^{\prime}\leq C. ( CC is a greatest lower bound.)

Because the ideas of universality and adjunctions have an appealingly simple form in posets, which is, moreover, useful in its own right, we will develop the ideas in that special case first, as a prelude to the general discussion for categories.

Suppose g:Q→Pg:Q\rightarrow P is a monotone map between posets. Given x∈Px\in P, a gg-approximation of xx (from above) is an element y∈Qy\in Q such that x≤g(y)x\leq g(y). A best gg-approximation of xx is an element y∈Qy\in Q such that

If a best gg-approximation exists then it is clearly unique.

It is worth clarifying the notion of best gg-approximation. If yy is a best gg-approximation to xx, then in particular, by monotonicity of gg, g(y)g(y) is the least element of the set of all g(z)g(z) where z∈Qz\in Q and x≤g(z)x\leq g(z). However, the property of being a best approximation is much stronger than the mere existence of a least element of this set. We are asking for yy itself to be the least, in QQ, among all elements zz such that x≤g(z)x\leq g(z). Thus, even if gg is surjective, so that for every xx there is a y∈Qy\in Q such that g(y)=xg(y)=x, there need not exist a best gg-approximation to xx. This is exactly the issue of having a canonical choice of solution.

Give an example of a surjective monotone map g:Q→Pg:Q\rightarrow P and an element x∈Px\in P such that there is no best gg-approximation to xx in QQ.

If such a best gg-approximation f(x)f(x) exists for all x∈Px\in P then we have a function f:P→Qf:P\rightarrow Q such that, for all x∈Px\in P, z∈Qz\in Q:

We say that ff is the left adjoint of gg, and gg is the right adjoint of ff. It is immediate from the definitions that the left adjoint of gg, if it exists, is uniquely determined by gg.

If such a function ff exists, then it is monotone. Moreover,

Proof: If we take z=f(x)z=f(x) in equation (1), then since f(x)≤f(x)f(x)\leq f(x), x≤g∘f(x)x\leq g\circ f(x). Similarly, taking x=g(z)x=g(z) we obtain f∘g(z)≤zf\circ g(z)\leq z. Now, the ordering on functions h,k:P⟶Qh,k:P\longrightarrow Q is the pointwise order:

Now, if x≤Px′x\leq_{P}x^{\prime} then x≤x′≤g∘f(x′)x\leq x^{\prime}\leq g\circ f(x^{\prime}), so f(x′)f(x^{\prime}) is a gg-approximation of xx, and hence f(x)≤f(x′)f(x)\leq f(x^{\prime}). Thus, ff is monotone.

Finally, using the fact that composition is monotone with respect to the pointwise order on functions, and the first two equations:

and hence g=g∘f∘gg=g\circ f\circ g. The other equation is proved similarly. ■\blacksquare Examples:

We see from these defining properties that the right adjoint maps a real rr to the greatest integer below it (the extremal solution to finding an integer below a given real). This is the standard floor function. Similarly, the left adjoint maps a real to the least integer above it yielding the ceiling function. Thus:

Consider a relation R⊆X×YR\subseteq X\times Y. RR induces a function:

This has a right adjoint [R]:P(Y)⟶P(X)[R]:\mathcal{P}(Y)\longrightarrow\mathcal{P}(X):

The definition of [R][R] which satisfies this condition is:

If we consider a set of worlds WW with an accessibility relation R⊆W×WR\subseteq W\times W as in Kripke semantics for modal logic, we see that [R][R] gives the usual Kripke semantics for the modal operator □\Box, seen as a propositional operator mapping the set of worlds satisfied by a formula ϕ\phi to the set of worlds satisfied by □ϕ\Box\phi. On the other hand, if we think of the relation RR as the denotation of a (possibly non-deterministic) program, and TT as a predicate on states, then [R]T[R]T is exactly the weakest precondition wp(R,T)\mathbf{wp}(R,T). In Dynamic Logic, the two settings are combined, and we can write expressions such as [R]T[R]T directly, where TT will be (the denotation of) some formula, and RR the relation corresponding to a program.

Consider a function f:X→Yf:X\rightarrow Y. This induces a function:

This function f−1f^{-1} has both a left adjoint ∃(f):P(X)⟶P(Y)\exists(f):\mathcal{P}(X)\longrightarrow\mathcal{P}(Y), and a right adjoint ∀(f):P(X)⟶P(Y)\forall(f):\mathcal{P}(X)\longrightarrow\mathcal{P}(Y). For all S⊆XS\subseteq X, T⊆YT\subseteq Y:

How can we define ∀(f)\forall(f) and ∃(f)\exists(f) explicitly so as to fulfil these defining conditions? – As follows:

If R⊆X×YR\subseteq X\times Y, which we write in logical notation as R(x,y)R(x,y), and we take the projection function π1:X×Y⟶X\pi_{1}:X\times Y\longrightarrow X, then:

This extends to an algebraic form of the usual Tarski model-theoretic semantics for first-order logic, in which:

We can dualise the discussion, so that starting with a monotone map f:P→Qf:P\rightarrow Q and y∈Qy\in Q, we can ask for the best PP-approximation to yy from below: x∈Px\in P such that f(x)≤yf(x)\leq y, and for all z∈Pz\in P:

If such a best approximation g(y)g(y) exists for all y∈Qy\in Q, we obtain a monotone map g:Q→Pg:Q\rightarrow P such that gg is right adjoint to ff. From the symmetry of the definition, it is clear that:

ff is the left adjoint of gg     ⟺    \;\;\Longleftrightarrow\;\; gg is the right adjoint of ff

5.2 Universal Arrows and Adjoints

Our discussion of best approximations for posets is lifted to general categories as follows.

Let G:D→CG:\mathcal{D}\rightarrow\mathcal{C} be a functor, and CC an object of C\mathcal{C}. A universal arrow from CC to GG is a pair (D,η)(D,\eta) where DD is an object of D\mathcal{D} and

such that, for any object D′D^{\prime} of D\mathcal{D} and morphism f:C→G(D′)f:C\rightarrow G(D^{\prime}), there exists a unique morphism f^:D→D′\hat{f}:D\rightarrow D^{\prime} in D\mathcal{D} such that f=G(f^)∘ηf=G(\hat{f})\circ\eta . Diagrammatically:

As in previous cases, uniqueness can be given a purely equational specification:

Show that if (D,η)(D,\eta) and (D′,η′)(D^{\prime},\eta^{\prime}) are universal arrows from CC to GG then there is a unique isomorphism D≅D′D\cong D^{\prime}.

Check that the equational specification of uniqueness (2) is valid.

Take U:Mon→SetU:\textbf{Mon}\rightarrow\textbf{Set}. Given a set XX, the universal arrow is

Indeed, for any monoid (M,⋅,1)(M,\cdot,1) and any function f:X→Mf:X\rightarrow M, set

It is easy to see that f^\hat{f} is a monoid homomorphism, and that U(f^)∘ηX=fU(\hat{f})\circ\eta_{X}=f. Moreover, for uniqueness we have that, for any h:MList(X)→(M,⋅,1)h:\mathsf{MList}(X)\rightarrow(M,\cdot,1),

Consider the functor ⟨IdC,IdC⟩:C→C×C\langle\mathsf{Id}_{\mathcal{C}},\mathsf{Id}_{\mathcal{C}}\rangle:\mathcal{C}\rightarrow\mathcal{C}\times\mathcal{C}, taking each object AA to (A,A)(A,A) and each arrow ff to (f,f)(f,f). A universal arrow from an object (A,B)(A,B) of C×C\mathcal{C}\times\mathcal{C} to ⟨IdC,IdC⟩\langle\mathsf{Id}_{\mathcal{C}},\mathsf{Id}_{\mathcal{C}}\rangle corresponds to a coproduct of AA and BB.

Verify the description of coproducts as universal arrows.

As in the case of posets, a related notion to universal arrows is that of adjunction.

Let C,D\mathcal{C},\mathcal{D} be categories. An adjunction from C\mathcal{C} to D\mathcal{D} is a triple (F,G,θ)(F,G,\theta), where FF and GG are functors

for each A∈Ob(C)A\in Ob(\mathcal{C}) and B∈Ob(D)B\in Ob(\mathcal{D}), natural in AA and BB. We say that FF is left adjoint to GG, and GG is right adjoint to FF. ▲\blacktriangle

Note that θ\theta should be understood as the “witnessed” form — i.e. arrows instead of mere relations — of the defining condition for adjunctions in the case of posets:

This is often displayed as a two-way ‘inference rule’:

Naturality of θ\theta is expressed as follows: for any f:A→G(B)f:A\rightarrow G(B) and any g:A′→Ag:A^{\prime}\rightarrow A, h:B→B′h:B\rightarrow B^{\prime},

Note that f,gf,g are in C\mathcal{C}, and hh is in D\mathcal{D}. In one line:

Thus, θ\theta is in fact a natural isomorphism

where C(_ ⁣_ ,G(_ ⁣_)):Cop×D→Set\mathcal{C}(\_\!\_\,,G(\_\!\_)):\mathcal{C}^{\mathsf{op}}\times\mathcal{D}\rightarrow\textbf{Set} is the result of composing the bivariant hom-functor C(_ ⁣_ ,_ ⁣_)\mathcal{C}(\_\!\_\,,\_\!\_) with IdCop×G\mathsf{Id}_{\mathcal{C}^{\mathsf{op}}}\times G, and D(F(_ ⁣_),_ ⁣_)\mathcal{D}(F(\_\!\_),\_\!\_) is similar.

In the next propositions we show that universal arrows and adjunctions are equivalent notions.

Let G:D→CG:\mathcal{D}\rightarrow\mathcal{C}. If for every object CC of C\mathcal{C} there exists a universal arrow ηC:C→G(F(C))\eta_{C}:C\rightarrow G(F(C)), then:

FF uniquely extends to a functor F:C→DF:\mathcal{C}\rightarrow\mathcal{D} such that η:IdC→G∘F\eta:\mathsf{Id}_{\mathcal{C}}\rightarrow G\circ F is a natural transformation.

FF is uniquely determined by GG (up to unique natural isomorphism), and vice versa.

For each pair of objects CC of C\mathcal{C} and DD of D\mathcal{D}, there is a natural bijection:

Proof: For 1, we extend FF to a functor as follows. Given f:C→C′f:C\rightarrow C^{\prime} in C\mathcal{C}, we consider the composition

By the universal property of ηC\eta_{C}, there exists a unique arrow Ff:FC→FC′Ff:FC\rightarrow FC^{\prime} such that the following diagram commutes.

Note that the above is the naturality diagram for η\eta on CC, hence the arrow-map thus defined for FF is the unique candidate that makes η\eta a natural transformation. It remains to verify the functoriality of FF. To show that FF preserves composition, consider g:C′→C′′g:C^{\prime}\rightarrow C^{\prime\prime}. We have the following commutative diagram,

where the last equality above holds because of (2). The verification that FF preserves identities is similar. For 2, we have that each FCFC is determined uniquely up to unique isomorphism, by the universal property, and once the object part of FF is fixed, the arrow part is uniquely determined. For 3, we need to define a natural isomorphism θC,D:C(C,G(D))≅D(F(C),D)\theta_{C,D}:\mathcal{C}(C,G(D))\cong\mathcal{D}(F(C),D). Given f:C→GDf:C\rightarrow GD, θC,D(f)\theta_{C,D}(f) is defined to be the unique arrow FC→DFC\rightarrow D such that the following commutes, as dictated by universality.

Suppose that θC,D(f)=θC,D(g)\theta_{C,D}(f)=\theta_{C,D}(g). Then

Thus θC,D\theta_{C,D} is injective. Moreover, given h:FC→Dh:FC\rightarrow D, by the equational formulation of uniqueness (2) we have:

Thus θC,D\theta_{C,D} is surjective. We are left to show naturality, i.e. that the following diagram commutes, for all h:C′→Ch:C^{\prime}\rightarrow C and g:D→D′g:D\rightarrow D^{\prime}.

We chase around the diagram, starting from f:C→GDf:C\rightarrow GD.

Let G:D→CG:\mathcal{D}\rightarrow\mathcal{C} be a functor, D∈Ob(D)D\in Ob(\mathcal{D}) and C∈Ob(C)C\in Ob(\mathcal{C}). If, for any D′∈Ob(D)D^{\prime}\in Ob(\mathcal{D}), there is a bijection

natural in D′D^{\prime} then there is a universal arrow η:C→G(D)\eta:C\rightarrow G(D).

Proof: Take η:C→G(D):=ϕD−1(\mspace1.5muidD)\eta:C\rightarrow G(D):=\phi_{D}^{-1}(\mspace{1.5mu}\mathsf{id}_{D}) and, for any g:C→G(D′)g:C\rightarrow G(D^{\prime}), take g^:D→D′:=ϕD′(g)\hat{g}:D\rightarrow D^{\prime}:=\phi_{D^{\prime}}(g). We have that

Moreover, for any h:D→D′h:D\rightarrow D^{\prime},

where equalities labelled with “nat” hold because of naturality of ϕ\phi. ■\blacksquare

Let (F,G,θ)(F,G,\theta) be an adjunction with F:C→DF:\mathcal{C}\rightarrow\mathcal{D}. Then, for each C∈Ob(C)C\in Ob(\mathcal{C}) there is a universal arrow η:C→G(F(C))\eta:C\rightarrow G(F(C)). ■\blacksquare

Thus we see that the following two situations are equivalent, in the sense that each determines the other uniquely.

We are given a functor G:D→CG:\mathcal{D}\rightarrow\mathcal{C}, and for each object CC of C\mathcal{C} a universal arrow from CC to GG.

We are given functors F:C→DF:\mathcal{C}\rightarrow\mathcal{D} and G:D→CG:\mathcal{D}\rightarrow\mathcal{C}, and a natural bijection

Let F:C→DF:\mathcal{C}\rightarrow\mathcal{D} be a functor, and DD an object of D\mathcal{D}. A couniversal arrow from FF to DD is an object CC of C\mathcal{C} and a morphism

such that, for every object C′C^{\prime} of C\mathcal{C} and morphism g:F(C′)→Dg:F(C^{\prime})\rightarrow D, there exists a unique morphism gˉ:C′→C\bar{g}:C^{\prime}\rightarrow C in C\mathcal{C} such that g=ϵ∘F(gˉ)g=\epsilon\circ F(\bar{g}). Diagrammatically:

ϵ<spanclass="katex−display"><spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"display="block"><semantics><mrow><mstylescriptlevel="0"displaystyle="false"><mi>D</mi></mstyle></mrow><annotationencoding="application/x−tex">D</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.6833em;"></span><spanclass="mord"><spanclass="mordmathnormal"style="margin−right:0.0278em;">D</span></span></span></span></span></span>C′\ignorespaces\ignorespaces\ignorespaces\ignorespaces<spanclass="katex−display"><spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"display="block"><semantics><mrow><mstylescriptlevel="1"displaystyle="false"><moveraccent="true"><mi>g</mi><mo>ˉ</mo></mover></mstyle></mrow><annotationencoding="application/x−tex">gˉ</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.5336em;vertical−align:−0.1361em;"></span><spanclass="mordmtightsizingreset−size6size3"><spanclass="mordaccentmtight"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.5678em;"><spanstyle="top:−2.7em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="mordmathnormalmtight"style="margin−right:0.0359em;">g</span></span><spanstyle="top:−2.7em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="accent−body"style="left:−0.2222em;"><spanclass="mordmtight">ˉ</span></span></span></span><spanclass="vlist−s">​</span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.1944em;"><span></span></span></span></span></span></span></span></span></span></span>F(C′)\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces<spanclass="katex−display"><spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"display="block"><semantics><mrow><mstylescriptlevel="1"displaystyle="false"><mrow><mi>F</mi><mostretchy="false">(</mo><moveraccent="true"><mi>g</mi><mo>ˉ</mo></mover><mostretchy="false">)</mo></mrow></mstyle></mrow><annotationencoding="application/x−tex">F(gˉ)</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.7em;vertical−align:−0.175em;"></span><spanclass="mordmtightsizingreset−size6size3"><spanclass="mordmathnormalmtight"style="margin−right:0.1389em;">F</span><spanclass="mopenmtight">(</span><spanclass="mordaccentmtight"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.5678em;"><spanstyle="top:−2.7em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="mordmathnormalmtight"style="margin−right:0.0359em;">g</span></span><spanstyle="top:−2.7em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="accent−body"style="left:−0.2222em;"><spanclass="mordmtight">ˉ</span></span></span></span><spanclass="vlist−s">​</span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.1944em;"><span></span></span></span></span></span><spanclass="mclosemtight">)</span></span></span></span></span></span>g\scriptstyle{\epsilon}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mi>D</mi></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{D}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0278em;">D</span></span></span></span></span></span>\textstyle{C^{\prime}\ignorespaces\ignorespaces\ignorespaces\ignorespaces}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mover accent="true"><mi>g</mi><mo>ˉ</mo></mover></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{\bar{g}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5336em;vertical-align:-0.1361em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord accent mtight"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mathnormal mtight" style="margin-right:0.0359em;">g</span></span><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span class="accent-body" style="left:-0.2222em;"><span class="mord mtight">ˉ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span></span></span></span></span></span>\textstyle{F(C^{\prime})\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mrow><mi>F</mi><mo stretchy="false">(</mo><mover accent="true"><mi>g</mi><mo>ˉ</mo></mover><mo stretchy="false">)</mo></mrow></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{F(\bar{g})}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;vertical-align:-0.175em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight" style="margin-right:0.1389em;">F</span><span class="mopen mtight">(</span><span class="mord accent mtight"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mathnormal mtight" style="margin-right:0.0359em;">g</span></span><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span class="accent-body" style="left:-0.2222em;"><span class="mord mtight">ˉ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span><span class="mclose mtight">)</span></span></span></span></span></span>\scriptstyle{g} By exactly similar (but dual) reasoning to the previous propositions, an adjunction implies the existence of couniversal arrows, and the existence of the latter implies the existence of the adjunction. Hence,

Let AA, BB be objects of C\mathcal{C}. A product of AA and BB is a couniversal arrow from ⟨IdC,IdC⟩:C→C×C\langle\mathsf{Id}_{\mathcal{C}},\mathsf{Id}_{\mathcal{C}}\rangle:\mathcal{C}\rightarrow\mathcal{C}\times\mathcal{C} to (A,B)(A,B).

5.3 Limits and Colimits

Let C\mathcal{C} be a category and I\mathcal{I} be another category, thought of as an “index category”. A diagram of shape I\mathcal{I} in C\mathcal{C} is just a functor F:I→CF:\mathcal{I}\rightarrow\mathcal{C}. Consider the functor category CI\mathcal{C}^{\mathcal{I}} with objects the functors from I\mathcal{I} to C\mathcal{C}, and natural transformations as morphisms. There is a diagonal functor

taking each object CC of C\mathcal{C} to the constant functor KC:I→CK_{C}:\mathcal{I}\rightarrow\mathcal{C}, which maps every object of I\mathcal{I} to CC. A limit for the diagram FF is a couniversal arrow from Δ\Delta to FF. ▲\blacktriangle

A couniversal arrow from Δ\Delta to FF corresponds to the following situation,

\scriptstyle{e}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mrow><mi>A</mi><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle></mrow></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{A\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span></span></span></span></span></span>\scriptstyle{f}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mi>g</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{g}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4375em;vertical-align:-0.1361em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight" style="margin-right:0.0359em;">g</span></span></span></span></span></span>\textstyle{B}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mrow><mi>C</mi><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle></mrow></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{C\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0715em;">C</span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span></span></span></span></span></span>\scriptstyle{\hat{h}}h\scriptstyle{h} i.e. to an equaliser!

By dualising limits we obtain colimits. Some important examples are coproducts, coequalisers, pushouts and ω\omega-colimits.

Verify that pullbacks are limits by taking:

Consider Δ:C→CI\Delta:\mathcal{C}\rightarrow\mathcal{C}^{\mathcal{I}} and F:I→CF:\mathcal{I}\rightarrow\mathcal{C}. A cone to FF is an object CC of C\mathcal{C} and family of arrows γ\gamma,

such that, for any f:I→Jf:I\rightarrow J, the following triangle commutes.

Ff<spanclass="katex−display"><spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"display="block"><semantics><mrow><mstylescriptlevel="0"displaystyle="false"><mrow><mi>F</mi><mi>J</mi></mrow></mstyle></mrow><annotationencoding="application/x−tex">FJ</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.6833em;"></span><spanclass="mord"><spanclass="mordmathnormal"style="margin−right:0.1389em;">F</span><spanclass="mordmathnormal"style="margin−right:0.0962em;">J</span></span></span></span></span></span>C\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces<spanclass="katex−display"><spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"display="block"><semantics><mrow><mstylescriptlevel="1"displaystyle="false"><msub><mi>γ</mi><mi>I</mi></msub></mstyle></mrow><annotationencoding="application/x−tex">γI</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.4375em;vertical−align:−0.1361em;"></span><spanclass="mordmtightsizingreset−size6size3"><spanclass="mordmtight"><spanclass="mordmathnormalmtight"style="margin−right:0.0556em;">γ</span><spanclass="msupsub"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.3448em;"><spanstyle="top:−2.3567em;margin−left:−0.0556em;margin−right:0.0714em;"><spanclass="pstrut"style="height:2.5em;"></span><spanclass="sizingreset−size3size1mtight"><spanclass="mordmtight"><spanclass="mordmathnormalmtight"style="margin−right:0.0785em;">I</span></span></span></span></span><spanclass="vlist−s">​</span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.1433em;"><span></span></span></span></span></span></span></span></span></span></span></span>γJ\scriptstyle{Ff}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mrow><mi>F</mi><mi>J</mi></mrow></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{FJ}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1389em;">F</span><span class="mord mathnormal" style="margin-right:0.0962em;">J</span></span></span></span></span></span>\textstyle{C\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><msub><mi>γ</mi><mi>I</mi></msub></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{\gamma_{I}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4375em;vertical-align:-0.1361em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.0556em;">γ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3567em;margin-left:-0.0556em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.0785em;">I</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1433em;"><span></span></span></span></span></span></span></span></span></span></span></span>\scriptstyle{\gamma_{J}} Thus a cone is exactly a natural transformation γ:ΔC→F\gamma:\Delta C\rightarrow F. A morphism of cones (‘mediating morphism’) (C,γ)⟶(D,δ)(C,\gamma)\longrightarrow(D,\delta) is an arrow g:C→Dg:C\rightarrow D such that each of the following triangles commutes.

We obtain a category Cone(F)\mathbf{Cone}(F) whose objects are cones to FF and whose arrows are mediating morphisms. Then, a limit of FF is a terminal object in Cone(F)\mathbf{Cone}(F).

5.4 Exponentials

In Set, given sets AA, BB, we can form the set of functions BA:=Set(A,B)B^{A}:=\textbf{Set}(A,B), which is again a set, i.e. an object of Set. This closure of Set under forming “function spaces” is one of its most important properties.

How can we axiomatise this situation? Once again, rather than asking what the elements of a function space are, we ask instead what we can do with them operationally. The answer is simple: apply functions to their arguments. That is, there is a map

We can think of the function as a ‘black box’: we can feed it inputs and observe the outputs.

Evaluation has the following couniversal property. For any g:C×A→Bg:C\times A\rightarrow B, there is a unique map Λ(g):C→BA\Lambda(g):C\rightarrow B^{A} such that the following diagram commutes.

\scriptstyle{\mathsf{ev}_{A,B}}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{B}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0502em;">B</span></span></span></span></span></span>\textstyle{C\times A\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mrow><mi mathvariant="normal">Λ</mi><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>×</mo><mstyle mathcolor="#cc0000"><mtext>\mspace</mtext></mstyle><mrow><mn>1.5</mn><mi>m</mi><mi>u</mi></mrow><msub><mrow><mi mathvariant="sans-serif">i</mi><mi mathvariant="sans-serif">d</mi></mrow><mi>A</mi></msub></mrow></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{\Lambda(g)\times\mspace{1.5mu}\mathsf{id}_{A}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;vertical-align:-0.175em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mtight">Λ</span><span class="mopen mtight">(</span><span class="mord mathnormal mtight" style="margin-right:0.0359em;">g</span><span class="mclose mtight">)</span><span class="mbin mtight">×</span><span class="mord text mtight" style="color:#cc0000;"><span class="mord mtight" style="color:#cc0000;">\mspace</span></span><span class="mord mtight"><span class="mord mtight">1.5</span><span class="mord mathnormal mtight">m</span><span class="mord mathnormal mtight">u</span></span><span class="mord mtight"><span class="mord mtight"><span class="mord mathsf mtight">id</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3567em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">A</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1433em;"><span></span></span></span></span></span></span></span></span></span></span></span>\scriptstyle{g} In Set, this is defined by:

This process of transforming a function of two arguments into a function-valued function of one argument is known as currying, after H. B. Curry. It is an algebraic form of λ\lambda-abstraction.

We are now led to the general definition of exponentials. Note that, for each object AA of a category C\mathcal{C} with products, we can define a functor

Let C\mathcal{C} be a category with binary products. We say that C\mathcal{C} has exponentials if for all objects AA and BB of C\mathcal{C} there is a couniversal arrow from _ ⁣_×A\_\!\_\times A to BB, i.e. an object BAB^{A} of C\mathcal{C} and a morphism

with the couniversal property: for every g:C×A→Bg:C\times A\rightarrow B, there is a unique morphism Λ(g):C→BA\Lambda(g):C\rightarrow B^{A} such that the following diagram commutes.

\scriptstyle{\mathsf{ev}_{A,B}}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{B}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0502em;">B</span></span></span></span></span></span>\textstyle{C\times A\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mrow><mi mathvariant="normal">Λ</mi><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>×</mo><mstyle mathcolor="#cc0000"><mtext>\mspace</mtext></mstyle><mrow><mn>1.5</mn><mi>m</mi><mi>u</mi></mrow><msub><mrow><mi mathvariant="sans-serif">i</mi><mi mathvariant="sans-serif">d</mi></mrow><mi>A</mi></msub></mrow></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{\Lambda(g)\times\mspace{1.5mu}\mathsf{id}_{A}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;vertical-align:-0.175em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mtight">Λ</span><span class="mopen mtight">(</span><span class="mord mathnormal mtight" style="margin-right:0.0359em;">g</span><span class="mclose mtight">)</span><span class="mbin mtight">×</span><span class="mord text mtight" style="color:#cc0000;"><span class="mord mtight" style="color:#cc0000;">\mspace</span></span><span class="mord mtight"><span class="mord mtight">1.5</span><span class="mord mathnormal mtight">m</span><span class="mord mathnormal mtight">u</span></span><span class="mord mtight"><span class="mord mtight"><span class="mord mathsf mtight">id</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3567em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">A</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1433em;"><span></span></span></span></span></span></span></span></span></span></span></span>\scriptstyle{g} ▲\blacktriangle

As before, the couniversal property can be given in purely equational terms, as follows. For every h:C→BAh:C\rightarrow B^{A},

Equivalently, C\mathcal{C} has exponentials if, for every object AA, the functor _ ⁣_×A\_\!\_\times A has a right adjoint, that is, there exists a functor _ ⁣_A:C→C\_\!\_^{A}:\mathcal{C}\rightarrow\mathcal{C} and a bijection

natural in B,CB,C. In that case, evA,B:=Λ−1(\mspace1.5muidBA)\mathsf{ev}_{A,B}:=\Lambda^{-1}(\mspace{1.5mu}\mathsf{id}_{B^{A}}).

Derive _ ⁣_A\_\!\_^{A} and Λ−1\Lambda^{-1} of the above description from ev\mathsf{ev} and Λ\Lambda of definition 0.5.13.

Show that C\mathcal{C} has exponentials iff, for every A,B,C∈Ob(C)A,B,C\in\mathsf{Ob}(\mathcal{C}), there is an object BAB^{A} and a bijection

The notation BAB^{A} for exponential objects is standard in the category theory literature. For our purposes, however, it will be more convenient to write A⇒BA\Rightarrow B.

Exponentials bring us to another fundamental notion, this time for understanding functional types, models of λ\lambda-calculus, and the structure of proofs.

A category with a terminal object, products and exponentials is called a Cartesian Closed Category (CCC). ▲\blacktriangle

For example, Set is a CCC. Another class of examples are Boolean algebras, seen as categories:

Products are given by conjunctions A∧BA\wedge B. We define exponentials as implications:

while couniversality is the Deduction Theorem,

5.5 Exercises

Suppose that U:C→DU:\mathcal{C}\rightarrow\mathcal{D} has a left adjoint F1F_{1}, and V:D→EV:\mathcal{D}\rightarrow\mathcal{E} has a left adjoint F2F_{2}. Show that V∘U:C→EV\circ U:\mathcal{C}\rightarrow\mathcal{E} has a left adjoint.

A sup-lattice is a poset PP in which every subset S⊆PS\subseteq P has a supremum (least upper bound) ⋁S\bigvee S. Let PP, QQ be sup-lattices, and f:P→Qf:P\rightarrow Q be a monotone map.

Show that if ff has a right adjoint then ff preserves least upper bounds:

Show that if ff preserves least upper bounds then it has a right adjoint gg, given by:

Dualise to get a necessary and sufficient condition for the existence of left adjoints.

Let F:C→DF:\mathcal{C}\rightarrow\mathcal{D}, G:D→CG:\mathcal{D}\rightarrow\mathcal{C} be functors such that FF is left adjoint to GG, with natural bijection θC,D:C(C,GD)⟶≅D(FC,D)\theta_{C,D}:\mathcal{C}(C,GD)\overset{\cong}{\longrightarrow}\mathcal{D}(FC,D). Show that there is a natural transformation ε:F∘G→IdD\varepsilon:F\circ G\rightarrow\mathsf{Id}_{\mathcal{D}}, the counit of the adjunction. Describe this counit explicitly in the case where the right adjoint is the forgetful functor U:Mon→SetU:\textbf{Mon}\rightarrow\textbf{Set}.

Let F:C→DF:\mathcal{C}\rightarrow\mathcal{D} and G:D→CG:\mathcal{D}\rightarrow\mathcal{C} be functors, and assume FF is left adjoint to GG with natural bijection θ\theta.

Show that FF is faithful if and only if, for every object AA of C\mathcal{C}, ηA:A→GF(A)\eta_{A}:A\rightarrow GF(A) is monic.

Show that if, for each object AA of C\mathcal{C}, there is a morphism sA:GF(A)→As_{A}:GF(A)\rightarrow A such that ηA∘sA=\mspace1.5muidGF(A)\eta_{A}\circ s_{A}=\mspace{1.5mu}\mathsf{id}_{GF(A)} then FF is full.

6 The Curry-Howard Correspondence

We shall now study a beautiful three-way connection between logic, computation and categories:

This connection has been known since the 1970’s, and is widely used in Computer Science — it is also beginning to be used in Quantum Informatics! It is the upper link (Logic – Computation) that is usually attributed to Haskell B. Curry and William A. Howard, although the idea is related to the operational interpretation of intuitionistic logic given in various formulations by Brouwer, Heyting and Kolmogorov. The link to Categories is mainly due to the pioneering work of Joachim Lambek.

Suppose we ask ourselves the question: What is Logic about? There are two main kinds of answer: one focuses on Truth, and the other on Proof. We focus on the latter, that is, on:

Traditional introductions to logic focus on Hilbert-style proof systems, that is, on generating the set of theorems of a system from a set of axioms by applying rules of inference (e.g. Modus Ponens).

A key step in logic took place in the 1930’s with the advent of Gentzen-style systems. Instead of focusing on theorems, we look more generally and symmetrically at What follows from what: in these systems the primary focus is on proofs from assumptions. We will examine two such kinds of systems: Natural Deduction systems and Gentzen sequent calculi.

Consider the fragment of propositional logic with logical connectives ∧\wedge and ⊃\supset. The assertion that a formula AA can be proved from assumptions A1,...,AnA_{1},...,A_{n} is expressed by a sequent:

We use Γ\Gamma, Δ\Delta to range over finite sets of formulas, and write Γ,A\Gamma,A for Γ∪{A}\Gamma\cup\{A\}. Proofs are built using the proof rules of table 3; the resulting proof system is called the Natural Deduction system for ∧\wedge,⊃\supset. ▲\blacktriangle

\begin{array}[]{@{\;\;}c@{\;\;}|@{\;\;}c@{\;\;}|@{\;\;}c@{\;\;}}&&\\ \textbf{Identity}&\textbf{Conjunction}&\textbf{Implication}\\ &&\\ \hline\cr\hline\cr&&\\ \Gamma,A\vdash A&\Gamma\vdash A\wedge B\Gamma\vdash A\qquad\Gamma\vdash B&\Gamma\vdash A\supset B\Gamma,A\vdash B\\ &&\\ &&\\ &\Gamma\vdash A\Gamma\vdash A\wedge B&\Gamma\vdash B\Gamma\vdash A\supset B\qquad\Gamma\vdash A\\ &&\\ &&\\ &\Gamma\vdash B\Gamma\vdash A\wedge B\\ &&\\ \end{array}

For example, we have the following proof of ⊃\supset-transitivity.

An important feature of Natural Deduction is the systematic pattern it exhibits in the structure of the inference rules. For each connective □\Box there are introduction rules, which show how formulas A□BA\Box B can be derived, and elimination rules, which show how such formulas can be used to derive other formulas.

is admissible in Natural Deduction if, whenever there are proofs of Γi⊢Ai\Gamma_{i}\vdash A_{i} then there is also a proof of Δ⊢B\Delta\vdash B. For example, the following Cut rule is admissible.

Show that the following rules are admissible in Natural Deduction.

Our focus will be on Structural Proof Theory, that is studying the “space of formal proofs” as a mathematical structure in its own right, rather than focussing only on

(i.e. the usual notions of “soundness and completeness”). One motivation for this approach comes from trying to understand and use the computational content of proofs, epitomised in the “Curry-Howard correspondence”.

6.2 Computation

Our starting point in computation is the pure calculus of functions called the λ\lambda-calculus.

Assume a countably infinite set of variables, ranged over by x,y,zx,y,z and variants. λ\lambda-calculus terms, ranged over by t,u,vt,u,v etc, are constructed from the following inductive definition.

If tt and uu are terms, then t ut\,u is a term (application).

If xx is a variable and tt is a term, then λx. t\lambda x.\,t is a term (λ\lambda-abstraction). ▲\blacktriangle

The above definition can be given in the following compact form, which will be followed in similar definitions in the sequel.

The computational content of the calculus is exhibited in the following examples. Note that the first example is not part of our formal syntax: it presupposes some encoding of numerals and successors.

What we also note above is the use of parentheses in order to disambiguate the structure of terms (i.e. the precedence of term constructors). To avoid notational clutter we also use the following conventions.

Applications associate to the left. For example, f x yf\,x\,y stands for (fx) y(fx)\,y .

The scope of an abstractions goes as far to the right as possible. For example,

The free variables of a term are those that are not bound by any λ\lambda; they can be seen as the assumptions of the term.

The set of free variables of a term tt, fv(t)\textsf{fv}(t), is given by:

The notation λx.t\lambda x.t is meant to serve the purpose of expressing formally

Thus, λ\lambda is a binder, that is, it binds the variable xx in the ‘function’ λx.t\lambda x.t, in the same way that e.g. ∫\int binds xx in ∫f(x) dx\int f(x)\,dx . This means that there should be no difference between λx.t\lambda x.t and λx′.t′\lambda x^{\prime}.t^{\prime}, where t′t^{\prime} is obtained from tt by swapping xx with some fresh variable x′x^{\prime} (i.e. with some x′x^{\prime} not appearing free in tt). For example, the terms

should be ‘equal’, as they both stand for the identity function. We formalise this by stipulating that

where we say that two terms are α\alpha-equivalent iff they differ solely in the choice of variables appearing in binding positions. This is formally defined in two steps, as follows.

We define variable-swapping on terms recursively as follows.

Then, α\alpha-equivalence, =α=_{\alpha}, is the relation on terms defined inductively by:The last clause can be replaced by any of the following: • …if, for some yy not appearing in t t′t\,t^{\prime}, (y x) ∙t=α(y x′) ∙t′\mathop{\boldsymbol{(}y\ x\boldsymbol{)}\,_{{}^{\bullet}}}t=_{\alpha}\mathop{\boldsymbol{(}y\ x^{\prime}\boldsymbol{)}\,_{{}^{\bullet}}}t^{\prime} . • …if, for all yy not appearing free in t t′t\,t^{\prime}, (y x) ∙t=α(y x′) ∙t′\mathop{\boldsymbol{(}y\ x\boldsymbol{)}\,_{{}^{\bullet}}}t=_{\alpha}\mathop{\boldsymbol{(}y\ x^{\prime}\boldsymbol{)}\,_{{}^{\bullet}}}t^{\prime} . • …if, for some yy not appearing free in t t′t\,t^{\prime}, (y x) ∙t=α(y x′) ∙t′\mathop{\boldsymbol{(}y\ x\boldsymbol{)}\,_{{}^{\bullet}}}t=_{\alpha}\mathop{\boldsymbol{(}y\ x^{\prime}\boldsymbol{)}\,_{{}^{\bullet}}}t^{\prime} .

t u=αt′ u′t\,u=_{\alpha}t^{\prime}\,u^{\prime} if t=αt′t=_{\alpha}t^{\prime} and u=αu′u=_{\alpha}u^{\prime},

λx.t=αλx′.t′\lambda x.t=_{\alpha}\lambda x^{\prime}.t^{\prime} if, for all yy not appearing in t t′t\,t^{\prime}, (y x) ∙t=α(y x′) ∙t′\mathop{\boldsymbol{(}y\ x\boldsymbol{)}\,_{{}^{\bullet}}}t=_{\alpha}\mathop{\boldsymbol{(}y\ x^{\prime}\boldsymbol{)}\,_{{}^{\bullet}}}t^{\prime} . ▲\blacktriangle

Prove the following α\alpha-equivalences.

Show that, for all raw terms t,t′t,t^{\prime} and variables x,x′x,x^{\prime}, if t=αt′t=_{\alpha}t^{\prime} then fv(t)=fv(t′)\textsf{fv}(t)=\textsf{fv}(t^{\prime}) and (x x′) ∙t=α(x x′) ∙t′\mathop{\boldsymbol{(}x\ x^{\prime}\boldsymbol{)}\,_{{}^{\bullet}}}t=_{\alpha}\mathop{\boldsymbol{(}x\ x^{\prime}\boldsymbol{)}\,_{{}^{\bullet}}}t^{\prime}. Moreover, show that, for any x,x′∉fv(t)x,x^{\prime}\not\in\textsf{fv}(t), t=α(x x′) ∙tt=_{\alpha}\mathop{\boldsymbol{(}x\ x^{\prime}\boldsymbol{)}\,_{{}^{\bullet}}}t . Hence infer that, for any x′∉fv(t)x^{\prime}\not\in\textsf{fv}(t), λx. t=αλx′.(x x′) ∙t\lambda x.\,t=_{\alpha}\lambda x^{\prime}.\mathop{\boldsymbol{(}x\ x^{\prime}\boldsymbol{)}\,_{{}^{\bullet}}}t .

Since λ\lambda-abstractions stand for functions, an application of a λ\lambda-abstraction on another term should result to a substitution of the latter inside the body of the abstraction.

Define the substitution of a term tt for a variable xx inside a term inductively by:

where (∗*) indicates the condition that z∉fv(x t)z\not\in\textsf{fv}(x\,t). ▲\blacktriangle

Note that, due to identification of α\alpha-equivalent (raw) terms, it is always possible to rename bound variables so that condition (∗*) be satisfied: for example,

Show that, for all λ\lambda-terms u,t,t′u,t,t^{\prime} and variables x,x′x,x^{\prime} such that x′∉fv(u)∖{x}x^{\prime}\notin\textsf{fv}(u)\setminus\{x\},

We proceed to the definition of β\beta-reduction and β\beta-conversion. These are relations defined on pairs of terms and express the computational content of the calculus.

We take β\beta-reduction, ⟶β\longrightarrow_{\beta}, to be the relation defined by:

This extends to arbitrary terms as follows. If t⟶βt′t\longrightarrow_{\beta}t^{\prime} then:

We take β\beta-conversion, =β=_{\beta}, to be the symmetric reflexive transitive closure of β\beta-reduction, that is, the equivalence relation induced by:

With β\beta-reduction we obtain a notion of “computational dynamics”. For example:

Note that in the sequel we will usually write β\beta-reduction simply by “⟶\longrightarrow”.

6.3 Simply-Typed λ𝜆\lambda-calculus

The ‘pure’ λ\lambda-calculus we have discussed so far is very unconstrained. For example, it allows self-application, i.e. terms like xxxx are perfectly legal. On the one hand, this means that the calculus very expressive: for example, we can encode recursion by setting

However, self-application leads also to divergences. The most characteristic example is the following. Setting Ω:=(λx.xx) λx.xx\Omega:=(\lambda x.xx)\,\lambda x.xx, we have:

Historically, Curry extracted Y\mathbf{Y} from an analysis of Russell’s Paradox, so it should come as no surprise that it too leads to divergences: setting t′t^{\prime} to be λx. t(xx)\lambda x.\,t(xx),

The solution is to introduce types. The original idea, due to Church following Russell, was that:

However, it has turned out that types constitute one of the most fruitful positive ideas in Computer Science, and provide one of the key disciplines of programming.

Let us assume a set of base types, ranged over by bb. The simply-typed λ\lambda-calculus is defined as follows.

A typing judgement is a triple of the form

which is to be understood as the assertion that term tt has the type TT under the assumptions that x1x_{1} has type T1T_{1}, …, xkx_{k} has type TkT_{k}, if Γ=x1:T1,…,xk:Tk\Gamma=x_{1}:T_{1},\ldots,x_{k}:T_{k}. A typed term is a term tt accompanied with a type TT and a context Γ\Gamma, such that the judgement Γ⊢t:T\Gamma\vdash t:T is derivable by use of the typing rules of table 5. ▲\blacktriangle

\begin{array}[]{@{\;\;}c@{\;\;}|@{\;\;}c@{\;\;}|@{\;\;}c@{\;\;}}&&\\ \textbf{Variable}&\textbf{Product}&\textbf{Function}\\ &&\\ \hline\cr\hline\cr&&\\ \Gamma,x:T\vdash x:T&\Gamma\vdash\langle t,u\rangle:T\times U\Gamma\vdash t:T\qquad\Gamma\vdash u:U&\Gamma\vdash\lambda x.\,t:U\rightarrow T\Gamma,x:U\vdash t:T\\ &&\\ &&\\ &\Gamma\vdash\pi_{1}v:T\Gamma\vdash v:T\times U&\Gamma\vdash t\,u:T\Gamma\vdash t:U\rightarrow T\qquad\Gamma\vdash u:U\\ &&\\ &&\\ &\Gamma\vdash\pi_{2}v:U\Gamma\vdash v:T\times U\\ &&\\ \end{array}

Note that contexts are sets, and so x:T,Γx:T,\Gamma stands for {x:T}∪Γ\{x:T\}\cup\Gamma with xx not appearing in Γ\Gamma. As before, terms are identified up to α\alpha-equivalence.

From the definition of types we see that the simply-typed λ\lambda-calculus is a calculus of functions and products. For example:

Show that Weakening and Cut are admissible in the typing system of the simply-typed λ\lambda-calculus:

We proceed to the rules for reduction and conversion. These are given as in the untyped case, with the addition of η\eta-rules, which are essentially extensionality principles.

We define β\beta-reduction, ⟶β\longrightarrow_{\beta}, by the following rules, and let β\beta-conversion, =β=_{\beta}, be its symmetric reflexive transitive closure.

Moreover, η\eta-conversion, =η=_{\eta}, is the symmetric reflexive transitive relation obtained by the following rules,

and λ\lambda-conversion, =λ=_{\lambda}, is the transitive closure of =β∪=η=_{\beta}\cup=_{\eta} . ▲\blacktriangle

Implicit in the above definition is the fact that η\eta-rules relate typed terms. For example, t=ηλx. txt=_{\eta}\lambda x.\,tx has as side condition that tt be of function type, i.e. that tt be a typed term Γ⊢t:T→U\Gamma\vdash t:T\rightarrow U. Now, following our intuitive interpretation of arrows as functions, we can read this η\eta-rule as:

Note that the above statement is in fact the couniversal property of currying in Set; we will see more on this in the next sections!

Show that, for any typed term Γ⊢t:T\Gamma\vdash t:T, if t⟶βt′t\longrightarrow_{\beta}t^{\prime} then Γ⊢t′:T\Gamma\vdash t^{\prime}:T is derivable.

Term reduction results in a normal form: an explicit but much longer expression in which no more reductions are applicable. Formally, a λ\lambda-term is called a redex if it is in one of forms of the left-hand-side of the β\beta-reduction rules, and therefore β\beta-reduction can be applied to it. A term is in normal form if it contains no redexes. In the light of the correspondence presented in the next paragraph, a term in normal form corresponds to a proof in which all lemmas have been eliminated.

For every term tt, there is no infinite sequence of β\beta-reductions:

The above result states that every reduction sequence leads eventually to a term in normal form. Note, though, that reduction to normal form has enormous (non-elementary) complexity.

then they are the same! This is the Logic–Computation part of the Curry-Howard correspondence (sometimes: “Curry-Howard isomorphism”). It works on three levels:

Natural Deduction System Simply-Typed λ\lambda-calculus Formulas Types Proofs Terms Proof transformations Term reductions

The view of proofs as containing computational content can also be detected in the Brouwer-Heyting-Kolmogorov interpretation of intuitionistic logic:

A proof of an implication A⊃BA\supset B is a procedure which transforms any proof of AA into a proof of BB.

A proof of A∧BA\wedge B is a pair consisting of a proof of AA and a proof of BB.

These readings motivate identifying A∧BA\wedge B with A×BA\times B, and A⊃BA\supset B with A→BA\rightarrow B. Moreover, these ideas have strong connections to computing. The λ\lambda-calculus is a ‘pure’ version of functional programming languages such as Haskell and SML. So we get a reading of:

6.4 Categories

We now have our link between Logic and Computation. We now proceed to complete the triangle of the Curry-Howard correspondence by showing the connection to Categories.

We establish the link from Logic (and Computation) to Categories. Let C\mathcal{C} be a cartesian closed category. We shall interpret formulas (or types) as objects of C\mathcal{C}. A morphism f:A→Bf:A\rightarrow B will then correspond to a proof of BB from assumption AA, i.e. a proof of A⊢BA\vdash B (a typed term x:A⊢t:Bx:A\vdash t:B). Note that the bare structure of a category only supports proofs from a single assumption. Since C\mathcal{C} has finite products, a proof of

The correspondence is depicted in the next table.

\begin{array}[]{c||@{\;\;}c@{\;\;}|@{\;\;}c@{\;\;}}&&\\ \textbf{Axiom}&\Gamma,A\vdash A&\pi_{2}:\Gamma\times A\longrightarrow A\\ &&\\ \hline\cr&&\\ \textbf{Conjunction}&\Gamma\vdash A\wedge B\Gamma\vdash A\qquad\Gamma\vdash B&\langle f,g\rangle:\Gamma\longrightarrow A\times Bf:\Gamma\longrightarrow A\qquad g:\Gamma\longrightarrow B\\ &&\\ &\Gamma\vdash A\Gamma\vdash A\wedge B&\pi_{1}\circ f:\Gamma\longrightarrow Af:\Gamma\longrightarrow A\times B\\ &&\\ &\Gamma\vdash B\Gamma\vdash A\wedge B&\pi_{2}\circ f:\Gamma\longrightarrow Bf:\Gamma\longrightarrow A\times B\\ &&\\ \hline\cr&&\\ \textbf{Implication}&\Gamma\vdash A\supset B\Gamma,A\vdash B&\Lambda(f):\Gamma\longrightarrow(A\Rightarrow B)f:\Gamma\times A\longrightarrow B\\ &&\\ &\Gamma\vdash B\Gamma\vdash A\supset B\quad\Gamma\vdash A&\mathsf{ev}_{A,B}\circ\langle f,g\rangle:\Gamma\longrightarrow Bf:\Gamma\longrightarrow(A\Rightarrow B)\quad g:\Gamma\rightarrow A\\ &&\\ \end{array}

Moreover, the rules for β\beta- and η\eta-conversion are all then derivable from the equations of cartesian closed categories. So cartesian closed categories are models of ∧\wedge,⊃\supset-logic at the level of proofs and proof-transformations, and of simply typed λ\lambda-calculus at the level of terms and term-conversions. The connection to computation is examined in more detail below.

In our translation of Logic sequents there is an implicit ordering of assumptions: a set of assumptions is mapped to an assumption product,

In practice, since for any permutation A1′,…,An′A_{1}^{\prime},\dots,A_{n}^{\prime} of A1,…,AnA_{1},\dots,A_{n} we have

6.5 Categorical Semantics of Simply-Typed λ𝜆\lambda-calculus

We translate the simply-typed λ\lambda-calculus into a cartesian closed category C\mathcal{C}, so that to each typed term x1:T1,...,xk:Tk⊢t:Tx_{1}:T_{1},...,x_{k}:T_{k}\vdash t:T corresponds an arrow

The translation if given by the function ⟦_ ⁣_ ⟧\llbracket\_\!\_\,\rrbracket defined below (“semantic brackets”).

Our aim now is to verify that λ\lambda-conversion (induced by β\beta- and η\eta-rules) is preserved by the translation, i.e. that, for any t,ut,u,

This would mean that our categorical semantics is sound.

Let us recall some structures from CCC’s. Given f1:D1→E1f_{1}:D_{1}\rightarrow E_{1}, f2:D2→E2f_{2}:D_{2}\rightarrow E_{2}, we defined

and we showed that (f1×f2)∘⟨h1,h2⟩=⟨f1∘h1,f2∘h2⟩(f_{1}\times f_{2})\circ\langle h_{1},h_{2}\rangle=\langle f_{1}\circ h_{1},f_{2}\circ h_{2}\rangle . Moreover, exponentials are given by the following natural bijection.

where Λ(f)\Lambda(f) is the unique arrow D→(E⇒F)D\rightarrow(E\Rightarrow F) satisfying this equation, with uniqueness being specified by:

Naturality of Λ\Lambda is then proven as follows.

For any f:A×B→Cf:A\times B\rightarrow C and g:A′→Ag:A^{\prime}\rightarrow A ,

We consider a simultaneous substitution for all the free variables in a term.

Let Γ=x1:T1,…,xk:Tk\Gamma=x_{1}:T_{1},\ldots,x_{k}:T_{k} . Given typed terms

we define t[t⃗/x⃗]≡t[t1/x1,…,tk/xk]t[\vec{t}/\vec{x}]\equiv t[t_{1}/x_{1},\ldots,t_{k}/x_{k}] recursively by:

Note that, in contrast to ordinary substitution, simultaneous substitution can be defined directly on raw terms, that is, prior to equating them modulo α-equivalence\alpha\text{-equivalence}. Moreover, we can show that:

We can now show the following Substitution Lemma.

For t,t1,…,tkt,t_{1},\ldots,t_{k} as in the previous definition,

Proof: By induction on the structure of tt. (1) If t=xit=x_{i}:

(2) If t=uvt=uv then, abbreviating ⟨⟦t1⟧,…,⟦tk⟧⟩\langle\llbracket t_{1}\rrbracket,\ldots,\llbracket t_{k}\rrbracket\rangle to ⟨⟦t⃗⟧⟩\langle\llbracket\vec{t}\rrbracket\rangle we have:

(4,5) The cases of projections and pairs are left as exercise. ■\blacksquare

Complete the proof of the above proposition.

We can now show that the conversion rules of the λ\lambda-calculus are preserved by the translation, and hence the interpretation is sound. Observe the correspondence between η\eta-rules and uniqueness (couniversality) principles.

For β\beta-conversion: \big{[}\text{\small(\lambda x.\,t)u=t[u/x]\,,\ \pi_{1}\langle t,u\rangle=t\,,\ \pi_{2}\langle t,u\rangle=u}\big{]}

For η\eta-conversion: \big{[}\text{\smallt=\lambda x.\,tx\,,\ \langle\pi_{1}t,\pi_{2}t\rangle=t}\big{]}

6.6 Completeness?

It is the case that, in a general CCC C\mathcal{C}, there may be equalities which are not reflected by the semantic translation, i.e.

In the rest of this section, we show how to construct a CCC Cλ\mathcal{C}_{\lambda} in which equalities between arrows correspond precisely to λ\lambda-conversions between terms. We call Cλ\mathcal{C}_{\lambda} a term model, due to its dependence on the syntax.

We define a family of relations on variable-term pairs by setting (x,t)∼T,U(y,u)(x,t)\sim_{T,U}(y,u) if x:T⊢t:Ux:T\vdash t:U and y:T⊢u:Uy:T\vdash u:U are derivable and

These are equivalence relations, so we set:

Similarly, ( ⋅ ,t)∼ ⋅ ,U( ⋅ ,u)(\,\centerdot\,,t)\sim_{\,\centerdot\,,U}(\,\centerdot\,,u) if ⊢t:U\vdash t:U and ⊢u:U\vdash u:U are derivable and t=λut=_{\lambda}u. Moreover,

We denote [(x,t)]T,U[(x,t)]_{T,U} simply by [x,t][x,t] , and [( ⋅ ,t)] ⋅ ,U[(\,\centerdot\,,t)]_{\,\centerdot\,,U} simply by [ ⋅ ,t][\,\centerdot\,,t] (these are not to be confused with copairings!). We proceed with Cλ\mathcal{C}_{\lambda}.

The category Cλ\mathcal{C}_{\lambda} is defined as follows. We take as set of objects the set of λ\lambda-types augmented with a terminal object 1\mathbf{1}:

Note that, for each variable x′x^{\prime}, any arrow [x,t]:T~→U~[x,t]:\widetilde{T}\rightarrow\widetilde{U} can be written in the form [x′,t′][x^{\prime},t^{\prime}], since t=(t[x′/x])[x/x′]t=(t[x^{\prime}/x])[x/x^{\prime}] and therefore [x,t]=[x′,t[x′/x]][x,t]=[x^{\prime},t[x^{\prime}/x]].

Proof: It is not difficult to see that \mspace1.5muid\mspace{1.5mu}\mathsf{id}’s are identities. For associativity, we show the most interesting case (and leave the rest as an exercise):

By exercise 0.6.9, the above are equal. ■\blacksquare

Cλ\mathcal{C}_{\lambda} has finite products.

Proof: Clearly, 1\mathbf{1} is terminal with canonical arrows τA:A→1\tau_{A}:A\rightarrow\mathbf{1}. For (binary) products, 1×A=A×1=A\mathbf{1}\times A=A\times\mathbf{1}=A. Otherwise, define T~⟵π1T~×U~⟶π2U~\widetilde{T}\overset{\pi_{1}}{\longleftarrow}\widetilde{T}\times\widetilde{U}\overset{\pi_{2}}{\longrightarrow}\widetilde{U} by:

Given T~⟵[x,t]V~⟶[x,u]U~\widetilde{T}\overset{[x,t]}{\longleftarrow}\widetilde{V}\overset{[x,u]}{\longrightarrow}\widetilde{U} , take ⟨[x,t],[x,u]⟩:V~→T~×U~:=[x,⟨t,u⟩]\langle[x,t],[x,u]\rangle:\widetilde{V}\rightarrow\widetilde{T}\times\widetilde{U}:=[x,\langle t,u\rangle] . Then:

Uniqueness left as exercise. The case of T~⟵[ ⋅ ,t]1⟶[ ⋅ ,u]U~\widetilde{T}\overset{[\,\centerdot\,,t]}{\longleftarrow}\mathbf{1}\overset{[\,\centerdot\,,u]}{\longrightarrow}\widetilde{U} is similar. ■\blacksquare

Cλ\mathcal{C}_{\lambda} has exponentials.

Proof: We have that 1⇒A=A\mathbf{1}\Rightarrow A=A and A⇒1=1A\Rightarrow\mathbf{1}=\mathbf{1}, with obvious evaluation arrows. Otherwise,

Given [x,t]:V~×U~→T~[x,t]:\widetilde{V}\times\widetilde{U}\rightarrow\widetilde{T} , take Λ([x,t]):=[x1,λx2.t[⟨x1,x2⟩/x]]\Lambda([x,t]):=[x_{1},\lambda x_{2}.t[\langle x_{1},x_{2}\rangle/x]] . Then,

Uniqueness left as exercise. The case of [x,t]:1×U~→T~[x,t]:\mathbf{1}\times\widetilde{U}\rightarrow\widetilde{T} is similar. ■\blacksquare

Complete the proof of the previous propositions.

Hence, Cλ\mathcal{C}_{\lambda} is a CCC and a sound model of the simply-typed λ\lambda-calculus. Moreover, applying our translation from the λ\lambda-calculus to a CCC (definition 0.6.18) we can show that we have

where Γ={x1:T1,...,xn:Tn}\Gamma=\{x_{1}:T_{1},...,x_{n}:T_{n}\}, x∉Γx\notin\Gamma and x:∏i=1nTix:\prod_{i=1}^{n}T_{i} . Then,

This means that our term model is complete.

6.7 Exercises

Give Natural Deduction proofs of the following sequents.

⊢(A⊃B)⊃((B⊃C)⊃(A⊃C))\vdash(A\supset B)\supset((B\supset C)\supset(A\supset C))

⊢(A⊃(A⊃B))⊃(A⊃B)\vdash(A\supset(A\supset B))\supset(A\supset B)

⊢(C⊃A)⊃((C⊃B)⊃(C⊃(A∧B)))\vdash(C\supset A)\supset((C\supset B)\supset(C\supset(A\wedge B)))

⊢(A⊃(B⊃C))⊃((A⊃B)⊃(A⊃C))\vdash(A\supset(B\supset C))\supset((A\supset B)\supset(A\supset C))

In each case, give the corresponding λ\lambda-term and the corresponding arrow in a CCC C\mathcal{C}.

For each of the following λ\lambda-terms, find a type for it. Try to find the ‘most general’ type, built from ‘type variables’ α\alpha, β\beta etc. For example, the most general type for the identity λx. x\lambda x.\,x is α→α\alpha\rightarrow\alpha. In each case, give the derivation of the type for this term (where you may assume that types can be built up from type variables as well as base types).

λx. λy. λz. x(yz)\lambda x.\,\lambda y.\,\lambda z.\,x(yz)

λx. λy. λz. xzy\lambda x.\,\lambda y.\,\lambda z.\,xzy

λx. λy. λz. xz(yz)\lambda x.\,\lambda y.\,\lambda z.\,xz(yz)

Reflect a little on the methods you used to do this exercise. Could they be made algorithmic?

7 Linearity

In the system of Natural Deduction, implicit in our treatment of assumptions in sequents

is that we can use them as many times as we want (including not at all). In this section we will explore the field that is opened once we apply restrictions to this approach, and thus render our treatment of assumptions more linear (or resource sensitive).

In order to make the manipulation of assumptions more visible, we now represent the assumptions as a list (possibly with repetitions) rather than a set, and use explicit structural rules to control copying, deletion and interchange of assumptions.

The structural rules for Logic are given in the following table. ▲\blacktriangle

\begin{array}[]{@{\quad}c@{\quad}|@{\quad}c@{\quad}}&\\ A\vdash A&\Gamma,B,A,\Delta\vdash C\Gamma,A,B,\Delta\vdash C\\ &\\ \hline\cr&\\ \Gamma,A\vdash B\Gamma,A,A\vdash B&\Gamma,A\vdash B\Gamma\vdash B\\ \end{array}

If we think of using proof rules backwards to reduce the task of proving a given sequent to various sub-tasks, then we see that the Contraction rule lets us duplicate premises, and the Weakening rule lets us discard them, while the Exchange rule merely lets us re-order them. The Identity axiom as given here is equivalent to the one with auxiliary premises given previously in the presence of Weakening.

The structural rules have clear categorical meanings in a category C\mathcal{C} with products. Recalling the diagonal transformation ΔA:=⟨\mspace1.5muidA,\mspace1.5muidA⟩\Delta_{A}:=\langle\mspace{1.5mu}\mathsf{id}_{A},\mspace{1.5mu}\mathsf{id}_{A}\rangle and the symmetry transformation sA,B:=⟨π2,π1⟩s_{A,B}:=\langle\pi_{2},\pi_{1}\rangle, the meanings are as follows.

In order to analyse Natural Deduction, Gentzen introduced sequent calculi based on Left and Right rules, instead of Introduction and Elimination rules. These kind of systems are more adequate for our discussion on linearity.

We define the Gentzen sequent calculus for ∧\wedge,⊃\supset as the proof system obtained by the structural rules (def. 0.7.1) and the rules in table 9 for connectives. ▲\blacktriangle

\begin{array}[]{@{\;\;}c@{\;\;}|@{\;\;}c@{\;\;}|@{\;\;}c@{\;\;}}&&\\ \textbf{Conjunction}&\textbf{Implication}&\textbf{Cut}\\ &&\\ \hline\cr\hline\cr&&\\ \Gamma,\Delta\vdash A\wedge B\Gamma\vdash A\qquad\Delta\vdash B&\Gamma\vdash A\supset B\Gamma,A\vdash B&\Gamma,\Delta\vdash B\Gamma\vdash A\qquad A,\Delta\vdash B\\ &&\\ &&\\ \Gamma,A\wedge B\vdash C\Gamma,A,B\vdash C&\Gamma,A\supset B,\Delta\vdash C\Gamma\vdash A\qquad B,\Delta\vdash C&\\ &&\\ \end{array}

For example, the proof of ⊃\supset-transitivity is now given as follows.

Show that the Gentzen-rules are admissible in Natural Deduction. Moreover, show that the Natural Deduction rules are admissible in the Gentzen sequent calculus.

The Cut\mathsf{Cut} rule allows the use of lemmas in proofs. It also yields a dynamics of proofs via Cut Elimination, that is, a dynamics of proof transformations towards the goal of eliminating the uses of the Cut rule in a proof, i.e. removing all lemmas and making the proof completely ‘explicit’, meaning Cut-free. Such transformations are always possible, as is shown in the following seminal result of Gentzen (Hauptsatz).

The Cut\mathsf{Cut} rule is admissible in the Gentzen sequent calculus without Cut\mathsf{Cut}.

7.2 Linear Logic

In the presence of the structural rules, the Gentzen sequent calculus is entirely equivalent to the Natural Deduction system we studied earlier. Nevertheless:

What happens if we drop the Contraction and Weakening rules (but keep the Exchange rule)?

It turns out we can still make good sense of the resulting proofs, terms and categories, but now in the setting of a different, ‘resource-sensitive’ logic.

Multiplicative Linear logic is a variant of standard logic with linear logical connectives. The multiplicative connectives for conjunction and implication are ⊗\otimes and ⊸\multimap. Proof sequents are of the form Γ⊢A\Gamma\vdash A, where Γ\Gamma is now a multiset. The proof rules for ⊗\otimes,⊸\multimap-Linear Logic, given in table 10, are the multiplicative versions of the Gentzen rules. ▲\blacktriangle

\begin{array}[]{@{\;\;}c@{\;\;}|@{\;\;}c@{\;\;}|@{\;\;}c@{\;\;}}&&\\ \textbf{Conjunction}&\textbf{Implication}&\textbf{Cut}\\ &&\\ \hline\cr\hline\cr&&\\ \Gamma,\Delta\vdash A\otimes B\Gamma\vdash A\qquad\Delta\vdash B&\Gamma\vdash A\multimap B\Gamma,A\vdash B&\Gamma,\Delta\vdash B\Gamma\vdash A\qquad A,\Delta\vdash B\\ &&\\ &&\\ \Gamma,A\otimes B\vdash C\Gamma,A,B\vdash C&\Gamma,A\multimap B,\Delta\vdash C\Gamma\vdash A\qquad B,\Delta\vdash C&\\ &&\\ \end{array}

Multiplicativity here means the use of disjoint (i.e. non-overlapping) contexts. The use of multisets allows us to omit explicit use of the Exchange rule in our proof system.

Note that the given system satisfies Cut-elimination, and this leans heavily on the ⊸ L\mathsf{\mathnormal{\multimap}\,L} rule. We could have used instead the following rule,

which is more intuitive computationally, but then cut-elimination would fail. Note, though, that:

Γ,A⊸B,Δ⊢CΓ,A⊸B⊢BΓ⊢AA⊸B⊢A⊸BB,Δ⊢C    Γ,Δ⊢BΓ⊢A⊸BA⊸B,Δ⊢BΔ⊢AB⊢B\Gamma,A\multimap B,\Delta\vdash C\Gamma,A\multimap B\vdash B\Gamma\vdash A\quad A\multimap B\vdash A\multimap B\quad B,\Delta\vdash C\quad\quad\quad\quad\;\;\Gamma,\Delta\vdash B\Gamma\vdash A\multimap B\quad A\multimap B,\Delta\vdash B\Delta\vdash A\quad B\vdash B

The resource-sensitive nature of Linear Logic is reflected in the following exercise.

Can you construct proofs in Linear Logic of the following sequents? (Hint: Use the Cut Elimination property.)

(A⊗A)⊸B⊢A⊸B(A\otimes A)\multimap B\vdash A\multimap B

Related to linear logic is the linear λ\lambda-calculus, which is a linear version of the simply-typed λ\lambda-calculus.

The linear λ\lambda-calculus is defined as follows.

Terms are typed by use of the typing rules of table 11. Finally, the rules for β\beta-reduction are:

▲\blacktriangle Note here that, again, x:T,Γx:T,\Gamma stands for {x:T}∪Γ\{x:T\}\cup\Gamma with xx not appearing in Γ\Gamma. Note also that Cut-free proofs always yield terms in normal form.

\begin{array}[]{|@{\;}l@{\;}||@{\;\;}c@{\;\;}|@{\;\;}c@{\;\;}|}\hline\cr&&\\ &&\\ &&\\ \parbox{42.67912pt}{Variable\\ /\,Cut\\ }&x:T\vdash x:T&\Gamma,\Delta\vdash u[t/x]:U\Gamma\vdash t:T\qquad x:T,\Delta\vdash u:U\\ \hline\cr&&\\ &&\\ &&\\ \parbox{42.67912pt}{Linear\\ Tensor\\ }&\Gamma,\Delta\vdash t\otimes u:T\otimes U\Gamma\vdash t:T\qquad\Delta\vdash u:U&\Gamma,z:T\otimes U\vdash\mathsf{let}\;z\;\mathsf{be}\;x\otimes y\;\mathsf{in}\;v:V\Gamma,x:T,y:U\vdash v:V\\ \hline\cr&&\\ &&\\ &&\\ \parbox{42.67912pt}{Linear\\ Function\\ }&\Gamma\vdash\lambda x.\,t:U\multimap T\Gamma,x:U\vdash t:T&\Gamma,f:T\multimap U,\Delta\vdash u[ft/x]:V\Gamma\vdash t:T\qquad x:U,\Delta\vdash u:V\\ \hline\cr\end{array}

Term formation is now highly constrained by the form of the typing judgements. In particular,

now implies that each xix_{i} occurs exactly once (free) in tt.

Moreover, note that, for function application, instead of the rule on the LHS below, we could have used the more intuitive rule on the RHS.

As we did in the logic, we can show that the typing systems with one or the other rule are equivalent.

7.3 Linear Logic in Monoidal Categories

We proceed to give a categorical counterpart to linearity by providing a categorical interpretation of linear logic. Note that CCC’s are no longer adequate for this task as they contain arrows

which violate linearity. It turns out that the right setting is that of symmetric monoidal closed categories.

A monoidal category is a structure (C,⊗,I,a,l,r)(\mathcal{C},\otimes,I,a,l,r) where:

⊗:C×C→C\otimes:\mathcal{C}\times\mathcal{C}\rightarrow\mathcal{C} is a functor (tensor),

II is a distinguished object of C\mathcal{C} (unit),

aa, ll, rr are natural isomorphisms (structural isos) with components:

such that lI=rI:I⊗I→Il_{I}=r_{I}:I\otimes I\rightarrow I and the following diagrams commute.

\scriptstyle{a}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mrow><mstyle mathcolor="#cc0000"><mtext>\mspace</mtext></mstyle><mrow><mn>1.5</mn><mi>m</mi><mi>u</mi></mrow><mrow><mi mathvariant="sans-serif">i</mi><mi mathvariant="sans-serif">d</mi></mrow><mo>⊗</mo><mi>l</mi></mrow></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{\mspace{1.5mu}\mathsf{id}\otimes l}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;vertical-align:-0.175em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord text mtight" style="color:#cc0000;"><span class="mord mtight" style="color:#cc0000;">\mspace</span></span><span class="mord mtight"><span class="mord mtight">1.5</span><span class="mord mathnormal mtight">m</span><span class="mord mathnormal mtight">u</span></span><span class="mord mtight"><span class="mord mathsf mtight">id</span></span><span class="mbin mtight">⊗</span><span class="mord mathnormal mtight" style="margin-right:0.0197em;">l</span></span></span></span></span></span>\textstyle{(A\otimes I)\otimes B\ignorespaces\ignorespaces\ignorespaces\ignorespaces}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mrow><mi>r</mi><mo>⊗</mo><mstyle mathcolor="#cc0000"><mtext>\mspace</mtext></mstyle><mrow><mn>1.5</mn><mi>m</mi><mi>u</mi></mrow><mrow><mi mathvariant="sans-serif">i</mi><mi mathvariant="sans-serif">d</mi></mrow></mrow></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{r\otimes\mspace{1.5mu}\mathsf{id}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;vertical-align:-0.175em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight" style="margin-right:0.0278em;">r</span><span class="mbin mtight">⊗</span><span class="mord text mtight" style="color:#cc0000;"><span class="mord mtight" style="color:#cc0000;">\mspace</span></span><span class="mord mtight"><span class="mord mtight">1.5</span><span class="mord mathnormal mtight">m</span><span class="mord mathnormal mtight">u</span></span><span class="mord mtight"><span class="mord mathsf mtight">id</span></span></span></span></span></span></span>\textstyle{A\otimes B}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mrow><mo stretchy="false">(</mo><mi>A</mi><mo>⊗</mo><mi>B</mi><mo stretchy="false">)</mo><mo>⊗</mo><mo stretchy="false">(</mo><mi>C</mi><mo>⊗</mo><mi>D</mi><mo stretchy="false">)</mo><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle></mrow></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{(A\otimes B)\otimes(C\otimes D)\ignorespaces\ignorespaces\ignorespaces\ignorespaces}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mopen">(</span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.0502em;">B</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0715em;">C</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.0278em;">D</span><span class="mclose">)</span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span></span></span></span></span></span>\scriptstyle{a}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mrow><mi>A</mi><mo>⊗</mo><mo stretchy="false">(</mo><mi>B</mi><mo>⊗</mo><mo stretchy="false">(</mo><mi>C</mi><mo>⊗</mo><mi>D</mi><mo stretchy="false">)</mo><mo stretchy="false">)</mo><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle></mrow></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{A\otimes(B\otimes(C\otimes D))\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0502em;">B</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0715em;">C</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.0278em;">D</span><span class="mclose">))</span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span></span></span></span></span></span>\scriptstyle{a}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mrow><mstyle mathcolor="#cc0000"><mtext>\mspace</mtext></mstyle><mrow><mn>1.5</mn><mi>m</mi><mi>u</mi></mrow><mrow><mi mathvariant="sans-serif">i</mi><mi mathvariant="sans-serif">d</mi></mrow><mo>⊗</mo><mi>a</mi></mrow></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{\mspace{1.5mu}\mathsf{id}\otimes a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;vertical-align:-0.175em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord text mtight" style="color:#cc0000;"><span class="mord mtight" style="color:#cc0000;">\mspace</span></span><span class="mord mtight"><span class="mord mtight">1.5</span><span class="mord mathnormal mtight">m</span><span class="mord mathnormal mtight">u</span></span><span class="mord mtight"><span class="mord mathsf mtight">id</span></span><span class="mbin mtight">⊗</span><span class="mord mathnormal mtight">a</span></span></span></span></span></span>\textstyle{((A\otimes B)\otimes C)\otimes D}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mrow><mi>A</mi><mo>⊗</mo><mo stretchy="false">(</mo><mo stretchy="false">(</mo><mi>B</mi><mo>⊗</mo><mi>C</mi><mo stretchy="false">)</mo><mo>⊗</mo><mi>D</mi><mo stretchy="false">)</mo><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle></mrow></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{A\otimes((B\otimes C)\otimes D)\ignorespaces\ignorespaces\ignorespaces\ignorespaces}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mopen">((</span><span class="mord mathnormal" style="margin-right:0.0502em;">B</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.0715em;">C</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.0278em;">D</span><span class="mclose">)</span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span></span></span></span></span></span>\scriptstyle{a}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mrow><mo stretchy="false">(</mo><mi>A</mi><mo>⊗</mo><mo stretchy="false">(</mo><mi>B</mi><mo>⊗</mo><mi>C</mi><mo stretchy="false">)</mo><mo stretchy="false">)</mo><mo>⊗</mo><mi>D</mi><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle><mstyle mathcolor="#cc0000"><mtext>\ignorespaces</mtext></mstyle></mrow></mstyle></mrow><annotation encoding="application/x-tex">\textstyle{(A\otimes(B\otimes C))\otimes D\ignorespaces\ignorespaces\ignorespaces\ignorespaces}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mopen">(</span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0502em;">B</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.0715em;">C</span><span class="mclose">))</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.0278em;">D</span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\ignorespaces</span></span></span></span></span></span></span>\scriptstyle{a\otimes\mspace{1.5mu}\mathsf{id}} ▲\blacktriangle

The monoidal diagrams ensure coherence, described by the slogan:

“…‘all’ diagrams involving a,la,l and rr must commute.”

Both products and coproducts give rise to monoidal structures — which are the common denominator between them. (But in addition, products have diagonals and projections, and coproducts have codiagonals and injections.)

Rel, the category of sets and relations, with cartesian product (which is not the categorical product).

Vectk\textbf{Vect}_{k} with the tensor product.

Let us examine the example of Rel in some detail. We take ⊗\otimes to be the cartesian product, which is defined on relations R:X→X′R:X\rightarrow X^{\prime} and S:Y→Y′S:Y\rightarrow Y^{\prime} as follows.

It is not difficult to show that this is indeed a functor. Note that, in the case that R,SR,S are functions, R⊗SR\otimes S is the same as R×SR\times S in Set. Moreover, we take each aA,B,Ca_{A,B,C} to be the associativity function for products (in Set), which is an iso in Set and hence also in Rel. Finally, we take II to be the one-element set, and lA,rAl_{A},r_{A} to be the projection functions: their relational converses are their inverses in Rel. The monoidal diagrams commute simply because they commute in Set.

As we mentioned earlier, products are tensors with extra structure: natural diagonals and projections. This fact, which reflects no-cloning and no-deleting of Linear Logic, is shown as follows.

Let C\mathcal{C} be a monoidal category (C,⊗,I,a,l,r)(\mathcal{C},\otimes,I,a,l,r). ⊗\otimes induces a product structure iff there exist natural diagonals and projections, i.e. natural transformations given by arrows

such that the following diagrams commute.

Proof: The “only if” direction is straightforward. For the converse, let C\mathcal{C} be monoidal with natural projections and diagonals. Then, we take product pairs to be pairs of the form

Moreover, for any pair of arrows B⟵fA⟶gCB\overset{f}{\longleftarrow}A\overset{g}{\longrightarrow}C , define

Then the product diagram commutes. For example:

For uniqueness, if h:A→B⊗Ch:A\rightarrow B\otimes C then the following diagram commutes,

so h=⟨π1∘h,π2∘h⟩h=\langle\pi_{1}\circ h,\pi_{2}\circ h\rangle. ■\blacksquare

Linear Logic is interpreted in monoidal categories with two more pieces of structure: monoidal symmetry and closure. The former allows the Exchange rule to be interpreted, while the latter realises linear implication.

A symmetric monoidal category is a monoidal category (C,⊗,I,a,l,r)(\mathcal{C},\otimes,I,a,l,r) with an additional natural isomorphism (symmetry),

such that sB,A=sA,B−1s_{B,A}=s_{A,B}^{-1} and the following diagrams commute.

A symmetric monoidal closed category (SMCC) is a symmetric monoidal category (C,⊗,I,a,l,r,s)(\mathcal{C},\otimes,I,a,l,r,s) such that, for each object AA, there is a couniversal arrow to the functor

That is, for all pairs A,BA,B, there is an object A⊸BA\multimap B and a morphism

such that, for every morphism f:C⊗A→Bf:C\otimes A\rightarrow B, there is a unique morphism Λ(f):C→(A⊸B)\Lambda(f):C\rightarrow(A\multimap B) such that

▲\blacktriangle Note that, although we use notation borrowed from CCC’s (ev,Λ\mathsf{ev},\Lambda), these are different structures! Examples of symmetric monoidal closed categories are Rel, Vectk\textbf{Vect}_{k}, and (a fortiori) cartesian closed categories.

Show that Rel is a symmetric monoidal closed category.

Just as cartesian closed categories correspond to ∧\wedge,⊃\supset-logic (and simply-typed λ-calculus\lambda\text{-calculus}), so do symmetric monoidal closed categories correspond to ⊗\otimes,⊸\multimap-logic (and linear λ\lambda-calculus).

So let C\mathcal{C} be a symmetric monoidal closed category. The interpretation of a linear sequent

To be precise in our interpretation, we will again treat contexts as lists of formulas, and explicitly interpret the Exchange rule by:

The rest of the rules are translated as follows.

\begin{array}[]{@{\qd}c@{\qd}|@{\qd}c@{\qd}}\quad\lx@intercol\hfil\hfil\quad\vrule\quad&\hfil\quad\\ \quad\lx@intercol\hfil A\vdash A\hfil\quad\vrule\quad&\mspace{1.5mu}\mathsf{id}_{A}:A\longrightarrow A\hfil\quad\\ \quad\lx@intercol\hfil\hfil\quad\vrule\quad&\hfil\quad\\ \hline\cr\quad\lx@intercol\hfil\hfil\quad\vrule\quad&\hfil\quad\\ \quad\lx@intercol\hfil\Gamma,\Delta\vdash B\Gamma\vdash A\qquad A,\Delta\vdash B\hfil\quad\vrule\quad&g\circ(f\otimes\mspace{1.5mu}\mathsf{id}_{\Delta}):\Gamma\otimes\Delta\longrightarrow Bf:\Gamma\longrightarrow A\qquad g:A\otimes\Delta\longrightarrow B\hfil\quad\\ \quad\lx@intercol\hfil\hfil\quad\vrule\quad&\hfil\quad\\ \hline\cr\quad\lx@intercol\hfil\hfil\quad\vrule\quad&\hfil\quad\\ \quad\lx@intercol\hfil\Gamma,\Delta\vdash A\otimes B\Gamma\vdash A\qquad\Delta\vdash B\hfil\quad\vrule\quad&f\otimes g:\Gamma\otimes\Delta\longrightarrow A\otimes Bf:\Gamma\longrightarrow A\qquad g:\Delta\longrightarrow B\hfil\quad\\ \quad\lx@intercol\hfil\hfil\quad\vrule\quad&\hfil\quad\\ \quad\lx@intercol\hfil\Gamma,A\otimes B\vdash C\Gamma,A,B\vdash C\hfil\quad\vrule\quad&f\circ a_{\Gamma,A,B}:\Gamma\otimes(A\otimes B)\longrightarrow Cf:(\Gamma\otimes A)\otimes B\longrightarrow C\hfil\quad\\ \quad\lx@intercol\hfil\hfil\quad\vrule\quad&\hfil\quad\\ \hline\cr\quad\lx@intercol\hfil\hfil\quad\vrule\quad&\hfil\quad\\ \quad\lx@intercol\hfil\Gamma\vdash A\multimap B\Gamma,A\vdash B\hfil\quad\vrule\quad&\Lambda(f):\Gamma\longrightarrow(A\multimap B)f:\Gamma\otimes A\longrightarrow B\hfil\quad\\ \quad\lx@intercol\hfil\hfil\quad\vrule\quad&\hfil\quad\\ \quad\lx@intercol\hfil\Gamma,\Delta\vdash B\Gamma\vdash A\multimap B\qquad\Delta\vdash A\hfil\quad\vrule\quad&\mathsf{ev}_{A,B}\circ(f\otimes g):\Gamma\otimes\Delta\longrightarrow Bf:\Gamma\longrightarrow(A\multimap B)\qquad g:\Delta\longrightarrow A\hfil\quad\\ \quad\lx@intercol\hfil\hfil\quad\vrule\quad&\hfil\quad\\ \end{array}

Note that, because of coherence in monoidal categories, we will not be scholastic with associativity arrows aa in our translations and will usually omit them. For the same reason, consecutive applications of tensor will be written without specifying associativity, e.g. A1⊗⋯⊗AnA_{1}\otimes\cdots\otimes A_{n}.

Let C\mathcal{C} be a symmetric monoidal closed category. Give the interpretation of the ⊸\multimap-left rule in C\mathcal{C}:

Is it possible to translate ⊗\otimes,⊸\multimap-logic into a CCC C\mathcal{C}? Is this in accordance with linearity of ⊗\otimes,⊸\multimap-logic?

7.4 Beyond the Multiplicatives

Linear Logic has three ‘levels’ of connectives, each describing a different aspect of standard logic:

The multiplicatives: e.g. ⊗\otimes, ⊸\multimap,

The additives: additive conjunction &\mathbin{\&} and disjunction ⊕\oplus,

The exponentials, allowing controlled access to copying and discarding.

We focus on additive conjunction and the exponential “ !\mspace1.0mu\boldsymbol{!}\mspace{1.0mu} ”, which will allow us to recover the ‘expressive power’ of standard ∧\wedge,⊃\supset-logic.

The logical connective for additive disjunction is &\mathbin{\&}, and the related proof rules are the following.

▲\blacktriangle So additive conjunction has proof rules that are identical to those of standard conjunction (∧\wedge). Note though that, since by linearity an argument of type A&BA\mathbin{\&}B can only be used once, each use of a left rule for &\mathbin{\&} makes a once-and-for-all choice of a projection. On the other hand, A⊗BA\otimes B represents a conjunction where both projections must be available.

Additive conjunction can be interpreted in any symmetric monoidal category with products, i.e. a category C\mathcal{C} with structure (⊗,×)(\otimes,\times) where ⊗\otimes is a symmetric monoidal tensor and ×\times is a product.

Moreover, we can extend the linear λ\lambda-calculus with term constructors for additive conjunction as follows.

The β\beta-reduction rules related to these constructs are:

Finally, we can gain back the lost structural rules, in disciplined versions, by introducing an exponential bang operator !! which is a kind of modality enabling formulas to participate in structural rules.

The logical connective for bang is !\mspace1.0mu\boldsymbol{!}\mspace{1.0mu}, and the related proof rules are the following.

Note that !\mspace1.0mu{A1,...,An}:=!\mspace1.0muA1,...,!\mspace1.0muAn\boldsymbol{!}\mspace{1.0mu}\{A_{1},...,A_{n}\}:=\boldsymbol{!}\mspace{1.0mu}A_{1},...,\boldsymbol{!}\mspace{1.0mu}A_{n} . ▲\blacktriangle

We can now see the discipline imposed on structural rules: in order for the rules to be applied, the participating formulas need to be tagged with a bang.

We are now in position to recover the standard logical connectives ∧\wedge, ⊃\supset within Linear Logic. If we interpret

and each ∧\wedge,⊃\supset-sequent Γ⊢A\Gamma\vdash A as !\mspace1.0muΓ⊢A\boldsymbol{!}\mspace{1.0mu}\Gamma\vdash A , then each proof rule of the Gentzen system for ∧\wedge,⊃\supset is admissible in the proof system of Linear Logic for ⊗\otimes,⊸\multimap,&\mathbin{\&},!\mspace1.0mu\boldsymbol{!}\mspace{1.0mu} .

Note in particular that the interpretation

decomposes the fundamental notion of implication into finer notions — like ‘splitting the atom of logic’!

7.5 Exercises

Give proofs of the following sequents in Linear Logic.

A⊸B,B⊸C⊢A⊸CA\multimap B,B\multimap C\vdash A\multimap C

⊢(A⊸B⊸C)⊸(B⊸A⊸C)\vdash(A\multimap B\multimap C)\multimap(B\multimap A\multimap C)

A⊗(B⊗C)⊢(A⊗B)⊗CA\otimes(B\otimes C)\vdash(A\otimes B)\otimes C

Consider a symmetric monoidal closed category C\mathcal{C}.

Suppose the sequents Γ1⊢A\Gamma_{1}\vdash A, Γ2⊢B\Gamma_{2}\vdash B and A,B,Δ⊢CA,B,\Delta\vdash C are provable and let their interpretations (i.e. the interpretations of their proofs) in C\mathcal{C} be f1:Γ1→Af_{1}:\Gamma_{1}\rightarrow A, f2:Γ2→Bf_{2}:\Gamma_{2}\rightarrow B and g:A⊗B⊗Δ→Cg:A\otimes B\otimes\Delta\rightarrow C respectively. Find then the interpretations h1,h2h_{1},h_{2} of the following proofs.

Γ1,Γ2,Δ⊢CΓ1,Γ2⊢A⊗BΓ1⊢A⋮Γ2⊢B⋮A⊗B,Δ⊢CA,B,Δ⊢C⋮Γ1,Γ2,Δ⊢CΓ2⊢B⋮Γ1,B,Δ⊢CΓ1⊢A⋮A,B,Δ⊢C⋮\Gamma_{1},\Gamma_{2},\Delta\vdash C\Gamma_{1},\Gamma_{2}\vdash A\otimes B\Gamma_{1}\vdash A\vdots\quad\Gamma_{2}\vdash B\vdots\quad A\otimes B,\Delta\vdash CA,B,\Delta\vdash C\vdots\Gamma_{1},\Gamma_{2},\Delta\vdash C\quad\quad\Gamma_{2}\vdash B\vdots\quad\Gamma_{1},B,\Delta\vdash C\Gamma_{1}\vdash A\vdots\quad A,B,\Delta\vdash C\vdots

Suppose now C\mathcal{C} has also binary products, given by ×\times. Given that the sequents Γ⊢A\Gamma\vdash A, Γ⊢B\Gamma\vdash B and A,Δ⊢CA,\Delta\vdash C are provable, and that their interpretations in C\mathcal{C} are f1:Γ→Af_{1}:\Gamma\rightarrow A, f2:Γ→Bf_{2}:\Gamma\rightarrow B and g:A⊗Δ→Cg:A\otimes\Delta\rightarrow C respectively, find the interpretations h1,h2h_{1},h_{2} of the following proofs.

Show that the condition lI=rIl_{I}=r_{I} in the definition of monoidal categories is redundant

Moreover, show that the condition \mspace1.5muidA⊗lB=aA,I,B∘rA⊗\mspace1.5muidB\mspace{1.5mu}\mathsf{id}_{A}\otimes l_{B}=a_{A,I,B}\circ r_{A}\otimes\mspace{1.5mu}\mathsf{id}_{B} in the definition of symmetric monoidal categories is redundant.

8 Monads and Comonads

Recall that an adjunction is given by a triple ⟨F,G,θ⟩\langle F,G,\theta\rangle, with F:C→DF:\mathcal{C}\rightarrow\mathcal{D} and G:D→CG:\mathcal{D}\rightarrow\mathcal{C} being functors, and θ\theta a natural bijection between homsets. By composing the two functors we obtain endofunctors

These can be seen as encapsulating the effect of the adjunction inside their domain category. For example, if we consider the functors

then U∘MListU\circ\mathsf{MList} encodes the free monoid construction inside Set.

The study of such endofunctors on their own right gave rise to the notions of monad and comonad, which we examine in this section.

A monad over a category C\mathcal{C} is a triple (T,η,μ)(T,\eta,\mu) where TT is an endofunctor on C\mathcal{C} and η:IdC→T\eta:\mathsf{Id}_{\mathcal{C}}\rightarrow T, μ:T2 ⁣→T\mu:T^{2}\!\rightarrow T are natural transformations such that the following diagrams commute. (Note that T2 ⁣:=T∘TT^{2}\!:=T\circ T, etc.).

▲\blacktriangle We call η\eta the unit of the monad, and μ\mu its multiplication; the whole terminology comes from monoids. Let us now proceed to some examples.

Let C\mathcal{C} be a category with coproducts and let EE be an object in C\mathcal{C}. We can define a monad (T,η,μ)(T,\eta,\mu) of EE-coproducts (computationally, EE-exceptions) by taking T:C→CT:\mathcal{C}\rightarrow\mathcal{C} to be the functor _ ⁣_+E\_\!\_+E , and η,μ\eta,\mu as follows.

As an injection, η\eta is a natural transformation. For μ\mu, we can use the properties of the coproduct. For f:A→Bf:A\rightarrow B,

The monadic diagrams follow in a similar manner. For example,

Now let C\mathcal{C} be a cartesian closed category and let ξ\xi be some object in C\mathcal{C}. We can define a monad of ξ\xi-side-effects by taking TT to be the functor ξ⇒(_ ⁣_×ξ)\xi\Rightarrow(\_\!\_\times\xi), and η,μ\eta,\mu as follows.

Naturality of η,μ\eta,\mu follows from naturality of Λ\Lambda: for any f:A→A′f:A\rightarrow A^{\prime},

The monadic diagrams are shown in a similar manner.

Our third example employs the functor U:Mon→SetU:\textbf{Mon}\rightarrow\textbf{Set}. In particular, we take T:=U∘MListT:=U\circ\mathsf{MList} and η,μ\eta,\mu as follows.

Naturality of η,μ\eta,\mu is obvious — besides, η\eta is the unit of the corresponding adjunction. The monadic diagrams are also straightforward: they correspond to the following equalities of mappings (we use x⃗\vec{x} for x1,…,xnx_{1},\dots,x_{n}).

Show that the EE-coproduct monad and the ξ\xi-side-effect monads are indeed monads.

Our discussion on monads can be dualised, leading us to comonads.

A comonad over a category C\mathcal{C} is a triple (Q,ε,δ)(Q,\varepsilon,\delta) where QQ is an endofunctor on C\mathcal{C} and ε:Q→IdC\varepsilon:Q\rightarrow\mathsf{Id}_{\mathcal{C}}, δ:Q→Q2 ⁣\delta:Q\rightarrow Q^{2}\! are natural transformations such that the following diagrams commute.

▲\blacktriangle ε\varepsilon is the counit of the comonad, and δ\delta its comultiplication. Two of our examples from monads dualise to comonads.

If C\mathcal{C} has finite products then, for any object SS, we can define the SS-product comonad with functor Q:=S×_ ⁣_Q:=S\times\_\!\_ .

We can form a comonad on Mon with functor Q:=MList∘UQ:=\mathsf{MList}\circ U (and counit that of the corresponding adjunction).

Give an explicit description of the comonad on Mon with functor Q:=MList∘UQ:=\mathsf{MList}\circ U described above. Verify it is a comonad.

8.2 (Co)Monads of an Adjunction

In the previous section, we saw that an adjunction between Mon and Set yielded a monad on Set (and a comonad on Mon), with its unit being the unit of the adjunction. We now show that this observation generalises to any adjunction. Recall that an adjunction is specified by:

a pair of functors C \ignorespaces\ignorespaces\ignorespaces\ignorespaces<spanclass="katex−display"><spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"display="block"><semantics><mrow><mstylescriptlevel="1"displaystyle="false"><mi>F</mi></mstyle></mrow><annotationencoding="application/x−tex">F</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.4783em;"></span><spanclass="mordmtightsizingreset−size6size3"><spanclass="mordmathnormalmtight"style="margin−right:0.1389em;">F</span></span></span></span></span></span> D\ignorespaces\ignorespaces\ignorespaces\ignorespaces\textstyle{{\mathcal{C}\ }\ignorespaces\ignorespaces\ignorespaces\ignorespaces}<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mi>F</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle{F}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4783em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight" style="margin-right:0.1389em;">F</span></span></span></span></span></span>\textstyle{{\ \mathcal{D}}\ignorespaces\ignorespaces\ignorespaces\ignorespaces}G\scriptstyle{G},

for each A∈Ob(C),B∈Ob(D)A\in Ob(\mathcal{C}),B\in Ob(\mathcal{D}), a bijection θA,B:C(A,GB)≅D(FA,B)\theta_{A,B}:\mathcal{C}(A,GB)\cong\mathcal{D}(FA,B) natural in A,BA,B.

For such an adjunction we build a monad on C\mathcal{C}: the functor of the monad is simply T:=G∘FT:=G\circ F, and unit and multiplication are defined by setting

Observe that η\eta is the unit of the adjunction.

Let (F,G,η)(F,G,\eta) be an adjunction. Then the triple (T,η,μ)(T,\eta,\mu) defined above is a monad on C\mathcal{C}.

Proof: Recall that naturality of θ\theta means concretely that, for any f:A→GBf:A\rightarrow GB, g:A′→Ag:A^{\prime}\rightarrow A and h:B→B′h:B\rightarrow B^{\prime},

η\eta is the unit of the adjunction and hence natural. We show naturality of μ\mu:

The monoidal condition for μ\mu also follows from naturality of θ\theta:

Finally, for the η\eta-μ\mu conditions we also use the universality diagram for η\eta and the uniqueness property (in equational form).

■\blacksquare Hence, every adjunction gives rise to a monad. It turns out that the converse is also true: every monad is described by means of an adjunction in this way. In particular, there are two canonical constructions of adjunctions from a given monad: the Kleisli construction, and the Eilenberg-Moore construction. These are in a sense minimal and maximal solutions to describing a monad via an adjunction. We describe the former one in the next section.

Finally, note that — because of the symmetric definition of adjunctions — the whole discussion can be dualised to comonads. That is, every adjunction gives rise to a comonad with counit that of the adjunction, and also every comonad can be derived from an adjunction in this manner.

8.3 The Kleisli Construction

The Kleisli construction starts from a monad (T,η,μ)(T,\eta,\mu) on a category C\mathcal{C} and builds a category CT\mathcal{C}_{T} of TT-computations, as follows.

Let (T,η,μ)(T,\eta,\mu) be a monad on a category C\mathcal{C}. Construct the Kleisli category CT\mathcal{C}_{T} by taking the same objects as C\mathcal{C}, and by including an arrow f.T:A→Bf_{.T}:A\rightarrow B in CT\mathcal{C}_{T} for each f:A→TBf:A\rightarrow TB in C\mathcal{C}. That is,

The identity arrow for AA in CT\mathcal{C}_{T} is ηA.T\eta_{A.T} , while the composite of f.T:A→Bf_{.T}:A\rightarrow B and g.T:B→Cg_{.T}:B\rightarrow C is h.Th_{.T} , where:

▲\blacktriangle The conditions for CT\mathcal{C}_{T} being a category follow from the monadic conditions. For composition with identity, for any f:A→TBf:A\rightarrow TB,

For associativity of composition, for any f:A→TBf:A\rightarrow TB, g:B→TCg:B\rightarrow TC and h:C→TDh:C\rightarrow TD,

Let us now proceed to build the adjunction between C\mathcal{C} and CT\mathcal{C}_{T} that will eventually give us back the monad TT. Construct the functors F:C→CTF:\mathcal{C}\rightarrow\mathcal{C}_{T} and G:CT→CG:\mathcal{C}_{T}\rightarrow\mathcal{C} as follows.

Functoriality of F,GF,G follows from the monad laws and the definition of CT\mathcal{C}_{T}. Moreover, for each A,B∈Ob(C)A,B\in Ob(\mathcal{C}), construct the following bijection of arrows.

To establish that (F,G,θ)(F,G,\theta) is an adjunction we need only show that θ\theta is natural in A,BA,B. So take f:A→TBf:A\rightarrow TB, g:A′→Ag:A^{\prime}\rightarrow A and h.T:B→B′h_{.T}:B\rightarrow B^{\prime}. We then have:

The final step in this section is to verify that the monad (T′,η′,μ′)(T^{\prime},\eta^{\prime},\mu^{\prime}) arising from this adjunction is the one we started from. The construction of T′T^{\prime} follows the recipe given in the previous section, that is:

T′:C→C:=G∘FT^{\prime}:\mathcal{C}\rightarrow\mathcal{C}:=G\circ F . Thus, T′T^{\prime} maps each object AA to TATA, and each arrow f:A→Bf:A\rightarrow B to μB∘TηA∘Tf=Tf\mu_{B}\circ T\eta_{A}\circ Tf=Tf.

ηA′:A→TA:=θA,FA−1(\mspace1.5muidFA(CT))=θ−1(ηA.T)=ηA\eta^{\prime}_{A}:A\rightarrow TA:=\theta_{A,FA}^{-1}(\mspace{1.5mu}\mathsf{id}_{FA}^{(\mathcal{C}_{T})})=\theta^{-1}(\eta_{A.T})=\eta_{A} .

μA′:T2 ⁣A→TA:=GθGFA,FA(\mspace1.5muidGFA(C))=Gθ(\mspace1.5muidTA)=μA∘T\mspace1.5muidTA=μA\mu^{\prime}_{A}:T^{2}\!A\rightarrow TA:=G\theta_{GFA,FA}(\mspace{1.5mu}\mathsf{id}_{GFA}^{(\mathcal{C})})=G\theta(\mspace{1.5mu}\mathsf{id}_{TA})=\mu_{A}\circ T\mspace{1.5mu}\mathsf{id}_{TA}=\mu_{A} .

Thus, we have indeed obtained the initial (T,η,μ)(T,\eta,\mu).

Dually to the Kleisli category of a monad we can construct the Kleisli category of a comonadIn some texts, this is called a coKleisli category. — and reobtain the comonad through an adjunction between the Kleisli category and the original one. Specifically, given a category C\mathcal{C} and a comonad (Q,ε,δ)(Q,\varepsilon,\delta) on C\mathcal{C}, we define the category CQ\mathcal{C}_{Q} as follows.

The Kleisli category of a comonad will be of use in the next sections, where comonads will be considered for modelling bang of Linear Logic. We end this section by showing a result that will be of use then.

Let C\mathcal{C} be a category and (Q,ε,δ)(Q,\varepsilon,\delta) be a comonad on C\mathcal{C}. If C\mathcal{C} has binary products then so does CQ\mathcal{C}_{Q}.

Proof: Let A,BA,B be objects in C,CQ\mathcal{C},\mathcal{C}_{Q}. We claim that their product in CQ\mathcal{C}_{Q} is given by (A×B,p1,p2)(A\times B,p_{1},p_{2}), where

and similarly for p2p_{2}. Now, for each f.Q:C→Af_{.Q}:C\rightarrow A and g.Q:C→Bg_{.Q}:C\rightarrow B, setting ⟨f.Q,g.Q⟩:=⟨f,g⟩.Q\langle f_{.Q},g_{.Q}\rangle:=\langle f,g\rangle_{.Q} we have:

and similarly p2∘⟨f.Q,g.Q⟩=g.Qp_{2}\circ\langle f_{.Q},g_{.Q}\rangle=g_{.Q} . Finally, for any h.Q:C→A×Bh_{.Q}:C\rightarrow A\times B,

Show that the Kleisli category CQ\mathcal{C}_{Q} of a comonad (Q,ε,δ)(Q,\varepsilon,\delta) has a terminal object when C\mathcal{C} does.

8.4 Modelling of Linear Exponentials

In this section we employ comonads in order to model the exponential bang operator, !\mspace1.0mu\boldsymbol{!}\mspace{1.0mu} , of Linear Logic. Let us start by modelling a weak bang operator, !^\mspace1.0mu\boldsymbol{\hat{!}}\mspace{1.0mu} , which involves solely the following proof rules.

Observe that, compared to !\mspace1.0mu\boldsymbol{!}\mspace{1.0mu} , !^\mspace1.0mu\boldsymbol{\hat{!}}\mspace{1.0mu} is weak in its Right rule, and it also misses Contraction and Weakening.

Let us now assume as given a symmetric monoidal closed category C\mathcal{C} along with a comonad (Q,ε,δ)(Q,\varepsilon,\delta) on C\mathcal{C}. As seen previously, C\mathcal{C} is a model of (⊗\otimes⊸\multimap)-Linear Logic. Moreover, (C,Q)(\mathcal{C},Q) yields a model of (⊗<spanclass="katex−display"><spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"display="block"><semantics><mrow><mo>⊸</mo></mrow><annotationencoding="application/x−tex">⊸</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.5499em;"></span><spanclass="mrelamsrm">⊸</span></span></span></span></span>!^\mspace1.0mu\otimes<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo>⊸</mo></mrow><annotation encoding="application/x-tex">\multimap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">⊸</span></span></span></span></span>\boldsymbol{\hat{!}}\mspace{1.0mu})-Linear Logic by modelling each formula !^\mspace1.0muA\boldsymbol{\hat{!}}\mspace{1.0mu}A by QAQA (i.e. QQ applied to the translation of AA). The rules for weak bang are then interpreted as follows.

We know that arrow-equalities in C\mathcal{C} correspond to proof-transformations in the proof system. Thus, the comonadic law εQA∘δA=\mspace1.5muidQA=QεA∘δA\varepsilon_{QA}\circ\delta_{A}=\mspace{1.5mu}\mathsf{id}_{QA}=Q\varepsilon_{A}\circ\delta_{A} corresponds to the following transformations.

Find a proof-transformation corresponding to the comonadic law δQA∘δA=QδA∘δA\delta_{QA}\circ\delta_{A}=Q\delta_{A}\circ\delta_{A} .

In order to extend our translation to the general !\mspace1.0muR\mathsf{\boldsymbol{!}\mspace{1.0mu}R} rule, we need arrows in C\mathcal{C} of the form

Hence, we need to impose (a coherent) distributivity of the tensor — either binary (⊗\otimes) or nullary (II) — over the comonad QQ. This can be formalised by stipulating that QQ be a symmetric monoidal endofunctor.

Let (C,⊗,I,a,l,r,s)(\mathcal{C},\otimes,I,a,l,r,s) and (C′,⊗′,I′,a′,l′,r′,s′)(\mathcal{C}^{\prime},\otimes^{\prime},I^{\prime},a^{\prime},l^{\prime},r^{\prime},s^{\prime}) be symmetric monoidal categories. A functor F:C→C′F:\mathcal{C}\rightarrow\mathcal{C}^{\prime} is called symmetric monoidal if there exist:

a morphism m0:I′→F(I)m_{0}:I^{\prime}\rightarrow F(I) ,

a natural transformation m2:F(_ ⁣_)⊗′F(_ ⁣_)→F(_ ⁣_⊗_ ⁣_)m_{2}:F(\_\!\_)\otimes^{\prime}F(\_\!\_)\rightarrow F(\_\!\_\otimes\_\!\_) ,

such that the following diagrams commute.

We may write such an FF as (F,m)(F,m). Moreover, if (F,m),(G,n):C→C′(F,m),(G,n):\mathcal{C}\rightarrow\mathcal{C}^{\prime} are (symmetric) monoidal functors then a natural transformation ϕ:F→G\phi:F\rightarrow G is called monoidal whenever the following diagrams commute.

▲\blacktriangle For example, the identity functor is symmetric monoidal. Moreover, if FF and GG are symmetric monoidal functors then so is G∘FG\circ F. Other examples are the following.

The constant endofunctor KIK_{I}, which maps each object to II and each arrow to \mspace1.5muidI\mspace{1.5mu}\mathsf{id}_{I}, is symmetric monoidal with structure maps:

The endofunctor ⊗∘⟨IdC,IdC⟩\otimes\circ\langle\mathsf{Id}_{\mathcal{C}},\mathsf{Id}_{\mathcal{C}}\rangle, which maps each object AA to A⊗AA\otimes A and each arrow ff to f⊗ff\otimes f, is symmetric monoidal with:

the latter given by use of structural transformations.

Verify that if F:C→DF:\mathcal{C}\rightarrow\mathcal{D}, G:D→EG:\mathcal{D}\rightarrow\mathcal{E} are symmetric monoidal functors then so is G∘FG\circ F.

A comonad (Q,ε,δ)(Q,\varepsilon,\delta) on a SMCC C\mathcal{C} is called a monoidal comonad if QQ is a symmetric monoidal functor, say (Q,m)(Q,m), and ε,δ\varepsilon,\delta are monoidal natural transformations. We write QQ as (Q,ε,δ,m)(Q,\varepsilon,\delta,m). ▲\blacktriangle

Now let us assume C\mathcal{C} is a SMCC and (Q,ε,δ,m)(Q,\varepsilon,\delta,m) is a monoidal comonad on C\mathcal{C}. The coherence of m2m_{2} with aa, expressed by the first diagram of symmetric monoidal functors, allows us to generalise m0m_{0} and m2m_{2} to arbitrary arities and assume arrows:

We can give the interpretation of the Right rule for bang as follows.

Our discussion on the categorical modelling of linear exponentials has only touched the issues of Right and Left rules. However, we also need adequate structure for translating Contraction and Weakening.

For these rules we can use appropriate (monoidal) natural transformations. For Contraction, we stipulate a transformation with components dA:QA→QA⊗QAd_{A}:QA\rightarrow QA\otimes QA , i.e.

For Weakening, a transformation with components eA:QA→Ie_{A}:QA\rightarrow I, i.e.

Although the above allow the categorical interpretation of the proof-rules, they do not necessarily preserve the intended proof-transformations. For that, we need to impose some further coherence conditions, which are epitomised in the following notion.

Let C\mathcal{C} be a SMCC. A monoidal comonad (Q,ε,δ,m)(Q,\varepsilon,\delta,m) on C\mathcal{C} is called a linear exponential comonad if there exist monoidal natural transformations

for each object AA, the triple (QA,dA,eA)(QA,d_{A},e_{A}) is a commutative comonoid in C\mathcal{C}, i.e. the following diagrams commute,

for each object AA, the following diagrams commute.

We write QQ as (Q,ε,δ,m,d,e)(Q,\varepsilon,\delta,m,d,e). ▲\blacktriangle

Express what it means concretely for d,ed,e to be monoidal natural transformations.

Give the categorical interpretation of Contraction and Weakening in a SMCC C\mathcal{C} with a linear exponential comonad.

We now consider the fragment of Linear Logic which includes all four linear connectives we have seen thus far, i.e. ⊗⊸!\mspace1.0mu&\otimes\multimap\boldsymbol{!}\mspace{1.0mu}\mathbin{\&}, and their respective proof rules (see definitions 0.7.16, 0.7.17). The categorical modelling of (⊗⊸!\mspace1.0mu&\otimes\multimap\boldsymbol{!}\mspace{1.0mu}\mathbin{\&})-Linear Logic requires:

a symmetric monoidal closed category C\mathcal{C},

a linear exponential comonad (Q,ε,δ,m,d,e)(Q,\varepsilon,\delta,m,d,e) on C\mathcal{C},

The above structure is adequate for modelling the proof rules as we have seen previously. Moreover, it provides rich structure for the Kleisli category CQ\mathcal{C}_{Q}. The next result and its proof demonstrate categorically the ‘interpretation’ of ordinary logic within Linear Logic given by:

Let C\mathcal{C} be a SMCC with finite products and let (Q,ε,δ,m,d,e)(Q,\varepsilon,\delta,m,d,e) be a linear exponential comonad on C\mathcal{C}. Then:

The Kleisli category CQ\mathcal{C}_{Q} has finite products.

There exists an isomorphism i:Q1→Ii:Q\mathbf{1}\rightarrow I and a natural isomorphism j:Q(_ ⁣_×_ ⁣_)→Q(_ ⁣_)⊗Q(_ ⁣_)j:Q(\_\!\_\times\_\!\_)\rightarrow Q(\_\!\_)\otimes Q(\_\!\_).

CQ\mathcal{C}_{Q} is cartesian closed, with the exponential of objects B,CB,C being QB⊸CQB\multimap C.

Proof: Part (a) has been shown previously (proposition 0.8.7, exercise 0.8.8), and part (b) is left as exercise. For (c), we have the following isomorphisms:

Concretely, we obtain θA:CQ(A×B,C)→≅CQ(A,QB⊸C)\theta_{A}:\mathcal{C}_{Q}(A\times B,C)\xrightarrow{\cong}\mathcal{C}_{Q}(A,QB\multimap C) by:

Clearly, θA\theta_{A} is a bijection. In order to establish couniversality of the exponential, we need also show naturality in AA (see exercise 0.5.15). So take f.Q:A×B→Cf_{.Q}:A\times B\rightarrow C and h.Q:A′→Ah_{.Q}:A^{\prime}\rightarrow A. Note first that the following commutes.

Note also that, for any hi.Q:Ai′→Ai{h_{i}}_{.Q}:A_{i}^{\prime}\rightarrow A_{i} in CQ\mathcal{C}_{Q}, i=1,2i=1,2, we have:

Thus, noting that \mspace1.5muidB(CQ)=εB.Q\mspace{1.5mu}\mathsf{id}_{B}^{(\mathcal{C}_{Q})}=\varepsilon_{B.Q},

Show part (b) of proposition 0.8.16. For the defined jj, show commutativity of (∗)(*).

8.5 Exercises

We say that a category C\mathcal{C} is well-pointed if it contains a terminal object 1\mathbf{1} and, for any pair of arrows f,g:A→Bf,g:A\rightarrow B,

Let now C\mathcal{C} be a well-pointed category with a terminal object 1\mathbf{1} and binary coproducts, and consider the functor G:C→CG:\mathcal{C}\rightarrow\mathcal{C} given by:

If C(1,1+1)={\mspace1.5muin1,\mspace1.5muin2}\mathcal{C}(\mathbf{1},\mathbf{1}+\mathbf{1})=\{\mspace{1.5mu}\mathsf{in}_{1},\mspace{1.5mu}\mathsf{in}_{2}\} with \mspace1.5muin1≠\mspace1.5muin2\mspace{1.5mu}\mathsf{in}_{1}\neq\mspace{1.5mu}\mathsf{in}_{2}, show that if (G,η,μ)(G,\eta,\mu) is a monad on C\mathcal{C} then, for each object AA:

Let C\mathcal{C} be a SMCC and let (Q,ε,δ)(Q,\varepsilon,\delta) be a comonad on C\mathcal{C}.

Suppose that the sequents !^\mspace1.0muA⊢B\boldsymbol{\hat{!}}\mspace{1.0mu}A\vdash B and !^\mspace1.0muB⊢C\boldsymbol{\hat{!}}\mspace{1.0mu}B\vdash C are provable and let f:QA→Bf:QA\rightarrow B and g:QB→Cg:QB\rightarrow C be their interpretations (i.e. the interpretations of their proofs) in C\mathcal{C}. Find the interpretations of the sequent !^\mspace1.0muA⊢!^\mspace1.0muC\boldsymbol{\hat{!}}\mspace{1.0mu}A\vdash\boldsymbol{\hat{!}}\mspace{1.0mu}C which correspond to each of the following proofs and show that the two interpretations are equal.

Find the interpretations in C\mathcal{C} of the following proofs; are the interpretations equal?

Show that a symmetric monoidal category C\mathcal{C} has finite products (given by ⊗,I\otimes,I, etc.) iff there are monoidal natural transformations

such that the following diagram commutes, for any A∈Ob(C)A\in Ob(\mathcal{C}).

.9 Review of Sets, Functions and Relations

Our aim in this Appendix is to provide a brief review of notions we will assume in the notes. If the first paragraph is not familiar to you, you will need to acquire more background before being ready to read the notes.

Given sets XX and YY, their cartesian product is

A relation RR from XX to YY, written R:X→YR:X\rightarrow Y, is a subset R⊆X×YR\subseteq X\times Y. Given such a relation, we write (x,y)∈R(x,y)\in R, or equivalently R(x,y)R(x,y). We compose relations as follows: if R:X→YR:X\rightarrow Y and S:Y→ZS:Y\rightarrow Z, then for all x∈Xx\in X and z∈Zz\in Z:

A relation f:X→Yf:X\rightarrow Y is a function if it satisfies the following two properties:

(single-valuedness): if (x,y)∈f(x,y)\in f and (x,y′)∈f(x,y^{\prime})\in f, then y=y′y=y^{\prime}.

(totality): for all x∈Xx\in X, for some y∈Yy\in Y, (x,y)∈f(x,y)\in f.

If ff is a function, we write f(x)=yf(x)=y or f:x↦yf:x\mapsto y for (x,y)∈f(x,y)\in f. Function composition is written as follows: if f:X→Yf:X\rightarrow Y and g:Y→Zg:Y\rightarrow Z,

It is easily checked that g∘f=f;gg\circ f=f;g, viewing functions as relations.

Two functions f,g:X→Yf,g:X\rightarrow Y are equal if they are equal as relations, i.e. as sets of ordered pairs. Equivalently, but more conveniently, we can write:

The right-to-left implication is the standard tool for proving equality of functions on sets. As we shall see, when we enter the world of category theory, which takes a more general view of “arrows” f:X→Yf:X\rightarrow Y, for most purposes we have to leave this familiar tool behind!

Our definitions of functions and relations, as they stand, have an unfortunate ambiguity. Given a relation R:X→YR:X\rightarrow Y, we cannot uniquely recover its “domain” XX and “codomain” YY. In the case of a function, we can recover the domain, because of totality, but not the codomain.

We wish to have unambiguous notions of domain and codomain for functions, and more generally relations. Thus we modify our official definition of a relation from XX to YY to be an ordered triple (X,R,Y)(X,R,Y), where R⊆X×YR\subseteq X\times Y. We then define composition of (X,R,Y)(X,R,Y) and (Y,S,Z)(Y,S,Z) in the obvious fashion, as (X,R;S,Z)(X,R;S,Z). We treat functions similarly. We shall not belabour this point in the notes, but it is implicit when we set up perhaps the most fundamental example of a category, namely the category of sets.

We shall avoid explicit discussion of set-theoretical foundations in the text, but we include a few remarks for the interested reader. Occasionally, distinctions of set-theoretic size do matter in category theory. One example which does arise in the notes is when we consider Cat, the category of “all” categories. Does this category belong to (is it an object of) itself, at the risk of a Russell-type paradox? The way we avoid this is to impose some set-theoretic limitation of size on the categories gathered into Cat. Cat will then be too big to fit into itself. For example, we can limit Cat to those categories whose collections of objects and arrows form sets in the sense of some standard set theory such as ZFC. Cat will then be a proper class, and will not be an object of itself. One assumption we do make throughout the notes is that the categories we deal with are “locally small”, i.e. that all hom-sets are indeed sets. Another place where some technical caveat would be in order is when we form functor categories. In practice, these issues never (well, hardly ever) cause problems, because of the strongly-typed nature of category theory. We leave the interested reader to delve further into these issues by consulting some of the standard texts.

.10 Guide to Further Reading

Of the many texts on category theory, we shall only mention a few, which may be particularly useful to someone who has read these notes and wishes to learn more.

The short text Pie is very nicely written and gently paced; it is probably a little easier going than these notes. A text which is written with a clarity and at a level which makes it ideal as a next step after these notes is HS . A text particularly useful for its large number of exercises with solutions is BW .

Another very nicely written text, focussing on the connections between categories and logic, and especially topos theory, is Gol , recently reissued by Dover Books. A classic text on categorical logic is LS . A more advanced text on topos theory is MacM .

The text Mac is a classic by one of the founders of category theory. It assumes considerable background knowledge of mathematics to fully appreciate its wide-ranging examples, but it provides invaluable coverage of the key topics.

A stimulating text on the correspondence between computation and logic is PT ; it is out of print, but available online. A more recent text on this topic is CH .

The 3-volume handbook Bor provides coverage of a broad range of topics in category theory. The book LS2 is somewhat idiosyncratic in style, but offers insights by one of the key contributors to category theory.

References