0% found this document useful (0 votes)
12 views95 pages

Cmu Categorical Semantics T Theory

Uploaded by

Serious Buddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views95 pages

Cmu Categorical Semantics T Theory

Uploaded by

Serious Buddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 95

Introduction to

Categorical Semantics
for Proof Theory
(OPLSS 2015)

Edward Morehouse
Carnegie Mellon University

June 2015
(revised June 15, 2015)
Contents

1 Basic Categories 3
1.1 Definition of a Category . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Structured Sets as Categories . . . . . . . . . . . . . . . . . . . . 6
1.3.1 Discrete Categories . . . . . . . . . . . . . . . . . . . . . . 6
1.3.2 Preorder Categories . . . . . . . . . . . . . . . . . . . . . 6
1.3.3 Monoid Categories . . . . . . . . . . . . . . . . . . . . . . 7
1.3.4 Categories of Propositions and Derivations . . . . . . . . 8
1.4 Categories of Structured Sets . . . . . . . . . . . . . . . . . . . . 9
1.4.1 The Category of Sets . . . . . . . . . . . . . . . . . . . . . 9
1.4.2 The Category of Preorders . . . . . . . . . . . . . . . . . 9
1.4.3 The Category of Monoids . . . . . . . . . . . . . . . . . . 9
1.5 Categories of Categories . . . . . . . . . . . . . . . . . . . . . . . 10
1.5.1 Functors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5.2 The Special Role of Sets . . . . . . . . . . . . . . . . . . . 12
1.6 New Categories from Old . . . . . . . . . . . . . . . . . . . . . . 14
1.6.1 Product Categories . . . . . . . . . . . . . . . . . . . . . . 14
1.6.2 Subcategories . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.6.3 Opposite Categories . . . . . . . . . . . . . . . . . . . . . 15
1.6.4 Arrow Categories . . . . . . . . . . . . . . . . . . . . . . . 16
1.6.5 Slice Categories . . . . . . . . . . . . . . . . . . . . . . . . 18

2 Behavioral Reasoning 21
2.1 Monic and Epic Morphisms . . . . . . . . . . . . . . . . . . . . . 21
2.1.1 Monomorphisms . . . . . . . . . . . . . . . . . . . . . . . 21
2.1.2 Epimorphisms . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2 Split Monic and Epic Morphisms . . . . . . . . . . . . . . . . . . 24
2.3 Isomorphisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

3 Universal Constructions 27
3.1 Terminal and Initial Objects . . . . . . . . . . . . . . . . . . . . . 27
3.1.1 Terminal Objects . . . . . . . . . . . . . . . . . . . . . . . 27
3.1.2 Preliminary Interpretation of Truth . . . . . . . . . . . . 29
3.1.3 Global and Generalized Elements . . . . . . . . . . . . . . 29

i
ii CONTENTS

3.1.4 Initial Objects . . . . . . . . . . . . . . . . . . . . . . . . 30


3.1.5 Preliminary Interpretation of Falsehood . . . . . . . . . . 31
3.2 Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.2.1 Products of Objects . . . . . . . . . . . . . . . . . . . . . 31
3.2.2 Product Functors . . . . . . . . . . . . . . . . . . . . . . . 35
3.2.3 Preliminary Interpretation of Conjunction . . . . . . . . . 37
3.2.4 Finite Products . . . . . . . . . . . . . . . . . . . . . . . . 37
3.2.5 Preliminary Interpretation of Contexts . . . . . . . . . . . 41
3.3 Coproducts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.3.1 Coproducts of Objects . . . . . . . . . . . . . . . . . . . . 43
3.3.2 Coproduct Functors . . . . . . . . . . . . . . . . . . . . . 44
3.3.3 Preliminary Interpretation of Disjunction . . . . . . . . . 46
3.3.4 Finite Coproducts . . . . . . . . . . . . . . . . . . . . . . 47
3.4 Exponentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.4.1 Exponentials of Objects . . . . . . . . . . . . . . . . . . . 48
3.4.2 Exponential Functors . . . . . . . . . . . . . . . . . . . . 51
3.4.3 Preliminary Interpretation of Implication . . . . . . . . . 53
3.5 Bicartesian Closed Categories . . . . . . . . . . . . . . . . . . . . 54
3.5.1 Context Distributivity . . . . . . . . . . . . . . . . . . . . 54
3.5.2 On Classical Proof Theory . . . . . . . . . . . . . . . . . . 55

4 Two Dimensional Structure 57


4.1 Naturality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.1.1 Natural Transformations . . . . . . . . . . . . . . . . . . . 57
4.1.2 Functor Categories . . . . . . . . . . . . . . . . . . . . . . 58
4.2 2-Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.2.1 2-Dimensional Categorical Structure . . . . . . . . . . . . 59
4.2.2 String Diagrams . . . . . . . . . . . . . . . . . . . . . . . 62
4.3 Adjunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.3.1 Behavioral Characterization . . . . . . . . . . . . . . . . . 64
4.3.2 Structural Characterizations . . . . . . . . . . . . . . . . 65
4.3.3 Harmony of the Propositional Connectives . . . . . . . . . 69
4.3.4 Context Distributivity Revisited . . . . . . . . . . . . . . 77

5 Dependency 79
5.1 Indexed Categories . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.1.1 Set Indexed Set Families . . . . . . . . . . . . . . . . . . . 79
5.1.2 Catgory Indexed Set Families . . . . . . . . . . . . . . . . 79
5.1.3 Catgory Indexed Category Families . . . . . . . . . . . . . 80
5.2 Interpretation of Predicate Logic . . . . . . . . . . . . . . . . . . 81
5.2.1 Interpretation of Terms . . . . . . . . . . . . . . . . . . . 81
5.2.2 Interpretation of Predicates . . . . . . . . . . . . . . . . . 83
5.3 Interpretation of Quantification . . . . . . . . . . . . . . . . . . . 84
5.3.1 Universal Quantification . . . . . . . . . . . . . . . . . . . 85
5.3.2 Existential Quantification . . . . . . . . . . . . . . . . . . 87
5.3.3 Substitution Compatibility . . . . . . . . . . . . . . . . . 90
Introduction

Category theory can be thought of as a sort of generalized set theory, where the
primitive concepts are those of set and function, rather than set and member-
ship. This shift of perspective allows categories to more directly describe many
structures, even those that are not particularly set-like. The primitive concept
of set generalizes to that of object, and function to morphism.
The only assumption that we make about these generalized functions is that
they support a composition structure, whereby any configuration of compatible
morphisms can be combined to yield a new morphism, and this operation is
associative in the sense that the details of how we go about combining parts
into a whole doesn’t matter, only the configuration of those parts does.
This is reminiscent of many aspects of our physical world. When we build
a castle out of Lego bricks, the order in which we assembled the bricks is not
recorded anywhere in the finished product, only their configuration with respect
to one another remains.
By beginning from very few assumptions, category theory permits a great deal
of axiomatic freedom. Additional postulates (e.g. the axiom of choice) can then
be selectively reintroduced in order to characterize a particular object theory of
interest (e.g. set theory).
Because categorical characterizations are based on the concepts of object and
morphism, they must describe their subjects behaviorally or externally, rather
than structurally or internally: in category theory we can’t pin down what the
objects of our study actually are, only how they relate to one another. In this
sense, category theory is the sociology of formal systems.
For example, we will see how we can characterize the cartesian product once and
for all using a universal property. This allows us to describe cartesian products of
sets, of groups, of topological spaces, of types, of propositions, and of countless
other things, all in one fell swoop, rather than on a tedious case-by-case basis.

Proof theory itself is a formal system, and it has an associative composition


structure: the order in which we build up the various sub-derivations of a proof
does not affect the result. In this course, we will see how we can interpret

1
2 CONTENTS

the derivations of proof theory as the morphisms of a category, and how the
meta-theory of that proof theory – which depends on the type of logic under
consideration – determines the type of category in which these morphisms live.
It will emerge that there is a structural isomorphism, similar to the celebrated
Curry-Howard correspondence, between proof theory and category theory (as
well as between type theory and category theory, but that’s a story for another
time). Further, we will see that category theory provides the means to unify
the proof theoretic behavior of the various logical connectives within a common
algebraic framework.
Chapter 1

Basic Categories

1.1 Definition of a Category


Definition 1.1.0.1 (category) A category ℂ consists of the following data:
• A collection of objects, ℂ0 .
We write “A ∶ ℂ” to indicate that A ∈ ℂ0 .
• A collection of morphisms or “arrows”, ℂ1 .
We write “𝑓 ∶∶ ℂ” to indicate that 𝑓 ∈ ℂ1 .
• Two boundary functions, domain, “∂− ”, and codomain, “∂+ ”, each map-
ping arrows to objects.
For ℂ-objects A and B, we indicate the collection of ℂ-arrows with domain
A and codomain B by “ℂ (A → B)”, and call this collection “hom”. When
the category in question is obvious or irrelevant, we just write “A ⟶ B”.
We indicate that an arrow 𝑓 is a member of this collection by writing
“𝑓 ∶ ℂ (A → B)” or “𝑓 ∶ A ⟶ B”.
• A function, identity, “id”, mapping objects to arrows such that for any
object A, id(A) ∶ A ⟶ A.
• A partial function, composition, “– ⋅ –”, for pairs of arrows that is de-
fined just in case the codomain of the first is equal to the domain of the
second, in which case the composite arrow has the domain of the first and
codomain of the second:
if 𝑓 ∶ A ⟶ B and 𝑔 ∶ B ⟶ C then 𝑓 ⋅ 𝑔 ∶ A ⟶ C

This data is required to respect the following relations.


• composition left unit law: for an arrow 𝑓 ∶ A ⟶ B,
id(A) ⋅ 𝑓 = 𝑓

3
4 CHAPTER 1. BASIC CATEGORIES

• composition right unit law: for an arrow 𝑓 ∶ A ⟶ B,

𝑓 ⋅ id(B) = 𝑓

• composition associative law: for arrows 𝑓 ∶ A ⟶ B, 𝑔 ∶ B ⟶ C and


ℎ ∶ C ⟶ D,
(𝑓 ⋅ 𝑔) ⋅ ℎ = 𝑓 ⋅ (𝑔 ⋅ ℎ)

By the associative law we may unambiguously write compositions without using


brackets.
Definition 1.1.0.2 In order to avoid having to gratuitously name the bound-
aries of arrows, we will call a pair of arrows 𝑓 , 𝑔 ∶∶ ℂ:
• coinitial or a “span” if ∂− (𝑓) = ∂− (𝑔),
• coterminal or a “cospan” if ∂+ (𝑓) = ∂+ (𝑔),
• composable if ∂+ (𝑓) = ∂− (𝑔),
• parallel if both coinitial and coterminal, and
• anti-parallel if composable in both orders.
Additionally, we will call an arrow an endomorphism if it is composable with
itself, and a list of arrows a path if they are serially composable, that is if
∂+ (𝑓𝑖 ) = ∂− (𝑓𝑖+1 ) for the list [𝑓0 , ⋯ , 𝑓𝑛 ].
Remark 1.1.0.3 (applicative order composition) It is common to see the com-
position 𝑓 ⋅ 𝑔 written as “𝑔 ∘ 𝑓”. This can be useful when we want to apply a
composite morphism to an argument in a category where a morphism is some
sort of function. Then (𝑔 ∘ 𝑓)(𝑥) = 𝑔(𝑓(𝑥)), which coincides with our custom to
write function application with the argument on the right. It may help to read
“𝑓 ⋅ 𝑔” as “𝑓 then 𝑔”, and to read “𝑔 ∘ 𝑓” as “𝑔 after 𝑓”.
Remark 1.1.0.4 (dimensional promotion) It is often convenient to call the
identity arrow on an object by the same name as the object, e.g. to write “A”
in place of id(A). This will become useful later as we introduce more complex
arrow constructions and concision becomes more of an issue.
Remark 1.1.0.5 (unbiased presentation) There is an equivalent presentation of
categories in terms of unbiased composition. There, instead of a single binary
composition operation acting on a compatible pair of arrows, we have a length-
indexed composition operation for paths of arrows (still with unit and associative
laws). In this presentation, an identity morphism is a nullary composition, a
morphism itself is a unary composition, and in general, any length 𝑛 path of
arrows has a unique composite. Although more cumbersome to axiomatize, an
unbiased presentation of categories makes it easier to appreciate the idea at the
heart of the definition: every composable configuration of things should have a
unique composite.
1.2. DIAGRAMS 5

1.2 Diagrams

We think of an arrow as eminating from its domain and proceeding to its


codomain. We may represent configurations of arrows in an intuitive graph-
ical fashion using a diagram, such as:

𝑓 𝑔
A B C

We may represent equations between arrows using diagrams as well. We say that
a diagram is commuting or “commutes” if the composites of parallel paths
depicted in the diagram are equal. For example, the fact that all pairs of
composable arrows have a unique composite gives us commuting composition
triangles, such as:
𝑓 B 𝑔

A C
𝑓 ⋅𝑔

Commuting diagrams may be extended by pre- or post-composition of arrows,


called whiskering, depicting the fact that equality of morphisms is a congruence
with respect to composition: if 𝑔1 = 𝑔2 then 𝑓 ⋅ 𝑔1 = 𝑓 ⋅ 𝑔2 and 𝑔1 ⋅ ℎ = 𝑔2 ⋅ ℎ
whenever the composites are defined. The name comes from the fact that the
arrows pre- or post-composed to the diagram look like whiskers:

𝑔1
𝑓 ℎ
A B C D
𝑔2

Pairs of commuting diagrams may also be combined along a common edge,


called pasting, depicting the transitivity of equality: if 𝑓1 = 𝑓2 and 𝑓2 = 𝑓3
then 𝑓1 = 𝑓3 .
We may express the unit and associative laws for composition with commuting
diagrams as:

A 𝑓 ⋅𝑔
id 𝑓 A C

A 𝑓 B and 𝑔
𝑓
𝑓 id B D
B 𝑔⋅ℎ
6 CHAPTER 1. BASIC CATEGORIES

In the diagram for unitality (left), the triangles representing the left and right
unit laws have been pasted along a common edge. In the diagram for associa-
tivity (right), each of the two composition triangles is whiskered by an arrow (ℎ
and 𝑓, respectively), and the resulting diagrams are pasted together along their
common boundary (𝑓 ⋅ 𝑔 ⋅ ℎ).
In the graphical language of diagrams, any node representing an object may be
duplicated and the two copies joined by an edge representing the appropriate
identity morphism. Conversely, any edge representing an identity morphism
may be collapsed, identifying the two nodes at its boundary, which necessarily
represent the same object.
Except for the sake of emphasis, we generally omit composite arrows (including
identitites, which are nullary composites) when drawing diagrams, because their
existence may always be inferred. Notice that the associative law for composi-
tion is built into the graphical language of diagrams by the fact that there is no
graphical representation for the bracketing of the arrows in a path.
In order to avoid gratuitously naming objects in diagrams, we will represent an
anonymous object as a dot (“●”). Two such dots occurring in a diagram need
not represent the same object.

1.3 Structured Sets as Categories

1.3.1 Discrete Categories

The most trivial possible category has nothing in it. It is called the empty
category, and written “𝟘”. Despite having completely uninteresting structure,
we will see that this category nevertheless has a very interesting property.
Only slightly less trivially, we can consider a category with just a single object,
call it “⋆”, and no arrows other than the required identity. This describes a
singleton category, typically written “𝟙”. This category will turn out to have
a very interesting property as well.
Generalizing a bit, we can regard any set as a category. As a category, a set has
its members as objects and no arrows other than the required identities. Such
categories are called discrete.

1.3.2 Preorder Categories

A preorder is a reflexive and transitive binary relation on a set, typically writ-


ten “– ≤ –”. We can interpret a preordered set (P, ≤) as a preorder category
ℙ in the following way:
objects ℙ0 ≔ P
1.3. STRUCTURED SETS AS CATEGORIES 7

{𝑥 ≤ 𝑦} if 𝑥 ≤ 𝑦
arrows ℙ (𝑥 → 𝑦) ≔ {
∅ otherwise
identities id(𝑥) ≔ 𝑥≤𝑥
composition 𝑥 ≤ 𝑦 ⋅ 𝑦 ≤ 𝑧 ≔ 𝑥≤𝑧
In other words, a preordered set is a category in which each hom collection is
either empty, or else a singleton; and a hom is inhabited just in case its domain
is less than or equal to its codomain according to the order relation.
A preorder need not have anything to do with our usual notion of order on a
set. For example, the integers with the “divides” relation, (ℤ, |) is a perfectly
good preordered set in which 2 ≤ −2, and also −2 ≤ 2, and yet 2 ≠ −2.
In a preorder category the unit and associative laws of composition are trivially
satisfied by the fact that all elements of a singleton or empty set are equal. In
fact, every diagram in a preorder category must commute! Preorder categories
are sometimes called “thin”.
The simplest preorder category that is not discrete has two distinct objects and
a single non-identity arrow from one to the other. It looks like this:

● ●

This category is called the interval category, and written “𝕀”.

1.3.3 Monoid Categories

A monoid is a set M together with an associative binary operation “– ∗ –” with


neutral element “ε”. We can interpret a monoid (M,∗,ε) as a monoid category
𝕄 in the following way:
objects 𝕄0 ≔ {⋆}
arrows 𝕄 (⋆ → ⋆) ≔ M
identities id(⋆) ≔ ε
composition 𝑥 ⋅ 𝑦 ≔ 𝑥∗𝑦
Thus, a monoid becomes a category by “suspending” its elements into the hom
collection of endomorphisms of an anonymous object, which I imagine looks
something like this:
𝑦

𝑥 ⋆ 𝑧


8 CHAPTER 1. BASIC CATEGORIES

The unit and associative laws of composition are satisfied by the corresponding
laws for the monoid operation.
If we wanted to make the simplest possible monoid category that is not discrete,
we would have to think about what it means to be simple. We can begin
by postulating a single non-identity arrow, 𝑠 ∶ ⋆ ⟶ ⋆. But because 𝑠 is an
endomorphism, we must say what 𝑠 ⋅ 𝑠, 𝑠 ⋅ 𝑠 ⋅ 𝑠, and in general, 𝑠(𝑛) are. One
possibility is to introduce no relations. This gives us the free monoid on one
generator, better known as (ℕ , + , 0).

1.3.4 Categories of Propositions and Derivations

Although we are not yet in a position to give the details, we can sketch the
outline of the sort of category we will use to interpret aspects of proof the-
ory. The objects of such a category will be interpretations of propositions, and
more generally, of propositional contexts. The arrows will be interpretations of
derivations. For a derivation,
Γ
𝒟
A
we will have ⟦𝒟⟧ ∶ ⟦Γ⟧ ⟶ ⟦A⟧.
Identity morphisms will be interpretations of identity derivations. These are
derivations in which the inhabitant of a singleton set of premises is identically
the conclusion; in other words, derivations comprised of no inference rules at
all. Syntactically, they look just like propositions.

id(⟦A⟧) ≔ ⟦A⟧

Compositions of morphisms will be interpretations of compositions of deriva-


tions, that is, of identifications of the conclusion of one derivation with a premise
of another. We are not yet in a position to explain how this works in general,
but schematically, the idea is this:

Γ
𝒟

⟦𝒟⟧ ⋅ ⟦ℰ⟧ ≔ interpretation of A

We will fill in the details of how the interpretations of contexts and connectives
work as we go along.
In addition to (structured) sets as categories, we also have categories of (struc-
tured) sets.
1.4. CATEGORIES OF STRUCTURED SETS 9

1.4 Categories of Structured Sets

1.4.1 The Category of Sets

There is a category of sets, called “Set”, whose objects are sets and whose
arrows are functions between them. Not surprisingly, we take function com-
position for the composition of arrows and identity functions for the identity
arrows. That is, given composable functions 𝑓 and 𝑔,

𝑓 ⋅𝑔 ≔ λ𝑥 . 𝑔(𝑓(𝑥)) and id ≔ λ𝑥 . 𝑥

Composition of Set-morphisms is associative and unital precisely because com-


position of functions is (check this!).

1.4.2 The Category of Preorders

There is a category of preorders, called “PreOrd”, that has preordered sets as


objects and monotone (i.e. order-preserving) functions as arrows. Arrow com-
position is again function composition and the identity arrows are the identity
functions.

In order to conclude that this is a category we (i.e. you) must check that the
composition of monotone functions is again monotone, and that the identity
functions are monotone. You just checked that function composition is asso-
ciative and has identity functions as units, so since monotone functions are
functions, you need not check associativity and unitality again for the special
case.

1.4.3 The Category of Monoids

The category of monoids, Mon, has monoids as objects and monoid homo-
morphisms as arrows. A monoid homomorphism is a function between the
underlying sets of the monoids that respects the operations and units:

𝑓 ∶ Mon ((M , ∗ , ε) → (N , ∗′ , ε′ )) ≔ 𝑓 ∶ Set (M → N)


such that 𝑓(𝑥 ∗ 𝑦) = 𝑓(𝑥) ∗′ 𝑓(𝑦) and 𝑓(ε) = ε′

Abstract algebra provides a rich source of categories. Such categories gener-


ally have sets with some form of algebraic structure as objects and structure-
preserving functions as arrows. In addition to that of monoids, we have the
category of groups (Grp), of rings (Rng), of modules over a ring, and so on.
10 CHAPTER 1. BASIC CATEGORIES

1.5 Categories of Categories


You may have noticed that we have interpreted some (hopefully) familiar math-
ematical structures (sets, preordered sets, monoids) as categories, but we have
also described categories of these structures (Set, PreOrd, Mon). So these are
in fact categories of categories! In each case, the objects comprise a sort of
structured collection, and the arrows a mapping between these that respects
the relevant structure.
Since categories themselves comprise a sort of structured collection, we may
wonder whether we can identify a reasonable notion of arrow between categories,
and thus define a category of categories. Indeed we can, so long as we heed a
broad foundational restriction and avoid allowing a category of categories to be
a member of itself. Otherwise, we leave ourselves open to paradoxes.

1.5.1 Functors

Recall that a category has collections of objects and arrows, together with an
(associative and unital) composition structure. It is precisely this composition
structure that we want an arrow between categories to preserve.
Definition 1.5.1.1 (functor) Given two categories ℂ and 𝔻, a functor F with
domain ℂ and codomain 𝔻 consists of:
• a function on objects, F0 ∶ ℂ0 ⟶ 𝔻0 ,
• a function on arrows, F1 ∶ ℂ1 ⟶ 𝔻1 ,
which respects the boundaries of arrows:

𝑓 ∶ ℂ (A → B) ⟼ F1 (𝑓) ∶ 𝔻 (F0 (A) → F0 (B))

and which furthermore respects the composition structure:


nullary composition F1 (id(A)) = id(F0 (A))
binary composition F1 (𝑓 ⋅ 𝑔) = F1 (𝑓) ⋅ F1 (𝑔)
It is customary to drop the dimension subscripts on the constituent functions
of a functor. We can represent the composition structure-preserving aspect of
a functor diagrammatically as follows:
F
ℂ ⟶ 𝔻
F
id ⟼ id
A A F(A) F(A)

B F(B)
𝑓 𝑔 F F(𝑓) F(𝑔)

A C F(A) F(C)
𝑓 ⋅𝑔 F(𝑓 ⋅ 𝑔)
1.5. CATEGORIES OF CATEGORIES 11

Equivalently, we could take the unbiased point of view and say that a functor
respects the composition of arbitrary paths of arrows.
Functors provide a notion of morphism of categories. So we can ask about
their composition structure as well. Because functors are defined in terms of
functions, their composition structure is easy to define.
Definition 1.5.1.2 (identity functor) Given any category ℂ we can define the
identity functor on ℂ, id(ℂ) ∶ ℂ ⟶ ℂ, comprising identity functions on both
objects and arrows:

(id(ℂ))0 ≔ id(ℂ0 ) and (id(ℂ))1 ≔ id(ℂ1 )

I imagine this as:

ℂ∶ id ℂ∶
A A

𝑓 𝑓

B B

Definition 1.5.1.3 (functor composition) Given functors F from ℂ to 𝔻 and


G from 𝔻 to 𝔼, we can define the composition F ⋅ G from ℂ to 𝔼, using the
respective compositions on its object and arrow functions:

(F ⋅ G)0 ≔ F0 ⋅ G0 and (F ⋅ G)1 ≔ F1 ⋅ G 1

I imagine this as:

ℂ∶ F 𝔻∶ G
𝔼∶
A F(A) (G ∘ F)(A)

𝑓 F(𝑓) (G ∘ F)(𝑓)

B F(B) (G ∘ F)(B)

Example 1.5.1.4 (forgetful functors) For a category of structured sets (such as


a monoids, groups, ring or topological spaces) there is a forgetful functor to the
category of sets, which disregards the structure and just retains the underlying
set.
For instance, there is a forgetful functor U ∶ Mon ⟶ Set that maps the monoid
(ℕ , + , 0) to the set ℕ, and maps the monoid inclusion (ℕ , + , 0) ↪ (ℤ , + , 0)
to the set inclusion ℕ ↪ ℤ.
Lemma 1.5.1.5 (categories of categories) Given a collection of categories and
functors between them, we can form the category having:
• the categories as objects
12 CHAPTER 1. BASIC CATEGORIES

• paths in the functors as arrows


• identity functors as identity arrows
• functor composition as arrow composition
It is easy to check that the associative and unit laws of composition are satisfied.
Exercise 1.5.1.6 What is a functor:
• between discrete categories?
• between preorder categories?
• between monoid categories?

1.5.2 The Special Role of Sets

A collection is called “small” if it is a set. A category is called small if its


collection of arrows – and hence, of objects – is small. There is a category
of small categories and functors between them, called “Cat”. Observe that
it is not the case that Cat ∶ Cat, because Cat0 contains all the small discrete
categories, i.e. the sets, and the collection of all sets is too large to be a set.
Often we don’t care whether a category is (globally) small, but only that each
of its hom collections is. A category is called locally small if for any pair of its
objects, A , B ∶ ℂ, the collection of arrows, ℂ (A → B) is small. Many categories
of interest are locally small. In particular, Set and Cat are locally small (why?).
Unless otherwise specified, the categories that we encounter in this course will
be locally small. Thus, we will stop being coy about what sort of “collection” a
hom is, and refer instead to hom sets.
The fact that the collections of parallel arrows in a locally small category are
sets puts the category Set in a privileged position. For example, if we fix an
object X ∶ ℂ, then we can define a function that, given any object A ∶ ℂ, returns
the set of arrows ℂ (X → A). This function extends to a functor:
Lemma 1.5.2.1 (representable functors) For each object of a locally small cat-
egory, X ∶ ℂ, there is a functor,

ℂ (X → –)
ℂ ⟶ Set
A ⟼ ℂ (X → A)
𝑓 ∶A⟶B ⟼ ℂ (X → 𝑓) ≔ – ⋅ 𝑓 ∶ ℂ (X → A) ⟶ ℂ (X → B)

known as a representable functor.


Unpacking this, it says that “ℂ (X → –)” is the name of a functor from ℂ to Set,
that maps an object A ∶ ℂ to the set of arrows, ℂ (X → A), and maps an arrow
𝑓 ∶ ℂ (A → B) to the function that post-composes 𝑓 to any arrow in ℂ (X → A),
1.5. CATEGORIES OF CATEGORIES 13

yielding an arrow in ℂ (X → B). The notation “– ⋅ 𝑓” is just syntactic sugar for


λ (𝑎 ∶ X ⟶ A) . 𝑎 ⋅ 𝑓. The object X ∶ ℂ is known as the “representing object”
of this functor.

Proof. In order to show that ℂ (X → –) is indeed a functor we must confirm


that it preserves the composition structure:

nullary composition The idea is that post-composing an identity arrow does


nothing, that is, it applies the identity function to the hom set. For A ∶ ℂ:

ℂ (X → id(A))
= [definition of representable functor]
λ 𝑎 . 𝑎 ⋅ id(A)
= [composition unit law]
λ𝑎.𝑎
= [definition of identity function]
id(ℂ (X → A))

binary composition Here, the idea is that post-composing a composite of ar-


rows post-composes the first, and then post-composes the second to the
result, that is, it composes the post-compositions. For 𝑓 ∶ ℂ (A → B) and
𝑔 ∶ ℂ (B → C):

ℂ (X → 𝑓 ⋅ 𝑔)
= [definition of representable functor]
λ𝑎.𝑎⋅𝑓 ⋅𝑔
= [β-expansion]
λ 𝑎 . (λ 𝑏 . 𝑏 ⋅ 𝑔)(𝑎 ⋅ 𝑓)
= [β-expansion]
λ 𝑎 . (λ 𝑏 . 𝑏 ⋅ 𝑔)((λ 𝑎 . 𝑎 ⋅ 𝑓)(𝑎))
= [definition of function composition]
(λ 𝑎 . 𝑎 ⋅ 𝑓) ⋅ (λ 𝑏 . 𝑏 ⋅ 𝑔)
= [definition of representable functor]
ℂ (X → 𝑓) ⋅ ℂ (X → 𝑔)

Because of the special role of the category of sets, the study of representable
functors provides one of several, ultimately equivalent, ways of understanding
categories. Due to our choice of emphasis and time constraints, it is not the one
we will pursue here, but it is worth being aware of.
14 CHAPTER 1. BASIC CATEGORIES

1.6 New Categories from Old

Now that we have met a few categories, let’s look at some ways to create new
categories out of them.

1.6.1 Product Categories

Given two categories, we may construct from them a new category whose con-
stituent parts are just ordered pairs of the respective parts of the original cate-
gories.
Definition 1.6.1.1 (product category) For categories ℂ0 and ℂ1 , define the
product category ℂ0 × ℂ1 to have the following structure:
objects (ℂ0 × ℂ1 )0 ≔ {(A0 , A1 ) | A𝑖 ∶ ℂ𝑖 }
arrows (ℂ0 × ℂ1 ) ((A0 , A1 ) → (B1 , B1 )) ≔ {(𝑓0 , 𝑓1 ) | 𝑓𝑖 ∶ ℂ𝑖 (A𝑖 → B𝑖 )}
identities id((A0 , A1 )) ≔ (id(A0 ) , id(A1 ))
composition (𝑓0 , 𝑓1 ) ⋅ (𝑔0 , 𝑔1 ) ≔ (𝑓0 ⋅ 𝑔0 , 𝑓1 ⋅ 𝑔1 )
Note that we have not broken our promise to define products behaviorally,
we have merely introduced a purely formal gadget called the “product of two
categories” that we will make use of in subsequent constructions. Soon, however,
we will be in a position to prove that this gadget does in fact have the universal
property of a product.

1.6.2 Subcategories

Just as we may restrict our attention to a subset of a given set, we may single
out a substructure of a category as well. However, since a category has more
structure than a set, we must check that the substructure in question remains
a category.
Definition 1.6.2.1 (subcategory) Given a category ℂ, we may take a subcat-
egory 𝔻 of ℂ, written “𝔻 ⊆ ℂ” by taking for 𝔻0 a subcollection of ℂ0 and for
𝔻1 a subcollection of ℂ1 , subject to the restrictions:
• if 𝑓 ∶∶ ℂ is in 𝔻1 then ∂− (𝑓) and ∂+ (𝑓) are in 𝔻0 .
• if 𝑓 , 𝑔 ∶∶ ℂ are in 𝔻1 and are composable in ℂ then 𝑓 ⋅ 𝑔 is in 𝔻1 .
• if A ∶ ℂ is in 𝔻0 then id(A) is in 𝔻1 .
The composition structure of arrows when interpreted in 𝔻 is the same as in ℂ.
The restrictions are necessary to ensure that the subcollections of ℂ0 and ℂ1
we choose do, in fact, form a category.
1.6. NEW CATEGORIES FROM OLD 15

Whenever we have a subcategory 𝔻 ⊆ ℂ, we have also an inclusion functor


𝑖 ∶ 𝔻 ⟶ ℂ, written “𝔻 ↪ ℂ”, sending each object and arrow of 𝔻 to itself, but
now viewed as an object or arrow of ℂ.

1.6.3 Opposite Categories

Recall that each arrow in a category has two boundary objects, its domain and
codomain. Systematically swapping these gives rise to an involutive relation on
categories.
Definition 1.6.3.1 (opposite category) To any category ℂ, there corresponds
an opposite category, ℂ° (pronounced “ℂ-op”), having:

objects ℂ°0 ≔ ℂ0

arrows ℂ° (A → B) ≔ ℂ (B → A)

identities id(A) ∶∶ ℂ° ≔ id(A) ∶∶ ℂ

composition 𝑓 ⋅ 𝑔 ∶∶ ℂ° ≔ 𝑔 ⋅ 𝑓 ∶∶ ℂ
Exercise 1.6.3.2 Check that an opposite category satisfies the unit and asso-
ciative laws of composition, and that the opposite of an opposite category is
just the original category.

Despite being simple and purely formal, the op-construction is very useful. Be-
cause it is an involution (for any category ℂ, we have that (ℂ°)° = ℂ), op is
called a duality.

For any categorical construction that we may perform, we can perform it in


the opposite of a particular category. When viewed from the perspective of
the original category, this gives rise to a dual construction. In many cases
(including that of categorical logic) a construction and its dual may arise in the
same category and interact in interesting ways.

Furthermore, any theorem that is true of a given category automatically has a


dual theorem that is true of its opposite category. As a consequence, the dual
of a theorem that is true of all categories is itself true of all categories!

Functors respect the op duality in the sense that whenever we have a functor
F ∶ ℂ ⟶ 𝔻, we automatically also have the functor F° ∶ ℂ° ⟶ 𝔻°. F° is really
just the same functor as F, it merely lets the categories on its boundary imagine
that their arrows are going the other way round.

A functor F ∶ ℂ° ⟶ 𝔻 is called a contravariant functor from ℂ to 𝔻. Among


the most important contravariant functors one encounters are the contravariant
representable functors:
Lemma 1.6.3.3 (contravariant representable functors) For any object of a lo-
16 CHAPTER 1. BASIC CATEGORIES

cally small category, X ∶ ℂ, there is a functor,


ℂ (– → X)
ℂ° ⟶ Set
A ⟼ ℂ (A → X)
𝑓 ∶A⟶B ⟼ ℂ (𝑓 → X) ≔ 𝑓 ⋅ – ∶ ℂ (B → X) ⟶ ℂ (A → X)

This is just an ordinary representable functor on the opposite category: ℂ (– →


X) = ℂ° (X → –), because pre-composition in ℂ is the same thing as post-
composition in ℂ°. For reasons that we won’t dwell on, a contravariant repre-
sentable functor is also known as a representable presheaf .

1.6.4 Arrow Categories

Definition 1.6.4.1 (arrow category) Given a category ℂ, we may derive from it


another category, “ℂ→ ”, known as the arrow category of ℂ with the following
structure:
objects ℂ→ 0 ≔ ℂ1
arrows ℂ→ (𝑓 → 𝑔) ≔ {(𝑖 , 𝑗) | 𝑖 ∶ ℂ (∂− (𝑓) → ∂− (𝑔)) and 𝑗 ∶ ℂ (∂+ (𝑓) →
∂+ (𝑔)) such that 𝑖 ⋅ 𝑔 = 𝑓 ⋅ 𝑗}
identities id(𝑓) ≔ (id(∂− (𝑓)) , id(∂+ (𝑓)))
composition (𝑖 , 𝑗) ⋅ (𝑘 , 𝑙) ≔ (𝑖 ⋅ 𝑘 , 𝑗 ⋅ 𝑙)
In a bit more detail, the objects of ℂ→ are the arrows of ℂ. Given ℂ→ -objects,
𝑓 ∶ ℂ (A → B) and 𝑔 ∶ ℂ (C → D), a ℂ→ -arrow from 𝑓 to 𝑔 is a pair of ℂ-arrows,
𝑖 ∶ ℂ (A → C) and 𝑗 ∶ ℂ (B → D) that form a commuting square with 𝑓 and 𝑔
in ℂ:
𝑖
A C
𝑓 𝑔 (1.1)
B D
𝑗

Identity ℂ→ -arrows are the commuting ℂ-squares with two opposite sides the
same arrow and the other two opposite sides identity arrows. Composition in
ℂ→ is the pasting of commuting squares in ℂ:
id 𝑖 𝑘
A A A C E
𝑓 𝑓 𝑓 𝑔 ℎ
B B B D F
id 𝑗 𝑙

The unit and associativity laws of composition are satisfied in ℂ→ as a conse-


quence of their holding in ℂ (you should check this). So the arrows of ℂ→ are
1.6. NEW CATEGORIES FROM OLD 17

the commuting squares of ℂ (with each commuting ℂ-square represented twice).


This tells us something about the 2-dimensional structure of ℂ, namely, which
of its squares commute.
We can iterate this construction to explore yet higher-dimensional structure
of ℂ. One dimension up, the category (ℂ→ )→ has as objects ℂ→ -arrows (i.e.
ℂ-commuting squares) and as arrows ℂ→ -commuting squares. Let’s see what
these ought to be. A nice way to think about it is to take diagram (1.1) and
imagine that it’s actually a 3-dimensional cube that we happen to be seeing
orthographically along one face. If we shift our perspective slightly, we will see
the following:
𝑖0
● ● 𝑐
𝑎 𝑖1
● ●
𝑓0 𝑔0
(1.2)
𝑓1 𝑔1
● ● 𝑑
𝑗0
𝑏 ● ●
𝑗1

We begin with (ℂ→ )→ -objects 𝑓 and 𝑔, which are actually the ℂ→ -arrows from 𝑎
to 𝑏 and from 𝑐 to 𝑑, respectively. These, in turn, are the ℂ-commuting squares
shown on the left and right of diagram (1.2). Now (ℂ→ )→ -arrows between these
will be ℂ→ -arrows between their domains and codomains, 𝑖 and 𝑗, which are
the ℂ-commuting squares shown on the top and bottom. But there is also the
condition that 𝑖⋅𝑔 = 𝑓 ⋅𝑗 in ℂ→ . Composition in ℂ→ is pasting in ℂ, and equality
of arrows in ℂ→ is just pairwise equality in ℂ. So we need that 𝑖0 ⋅𝑔0 = 𝑓0 ⋅𝑗0 and
𝑖1 ⋅ 𝑔1 = 𝑓1 ⋅ 𝑗1 in ℂ, making the back and front faces commute. In other words,
the top and bottom commuting ℂ-squares form a (ℂ→ )→ -arrow between the
left and right commuting ℂ-squares just in case the front and back ℂ-squares
commute as well. Then all the paths shown in diagram (1.2) commute. So
(ℂ→ )→ -arrows are ℂ-commuting cubes.
The arrow category construction provides us with three important functors, that
in a sense “mediate between dimensions”. These are the domain, codomain
and reflexivity functors:

𝑑𝑜𝑚 𝑐𝑜𝑑
ℂ→ ⟶ ℂ ℂ→ ⟶ ℂ
𝑓 ∶∶ ℂ ⟼ ∂− (𝑓) 𝑓 ∶∶ ℂ ⟼ ∂+ (𝑓)
(𝑖 , 𝑗) ⟼ 𝑖 (𝑖 , 𝑗) ⟼ 𝑗

𝑟𝑒𝑓𝑙
ℂ ⟶ ℂ→
A ⟼ id(A)
𝑓 ⟼ (𝑓 , 𝑓)
18 CHAPTER 1. BASIC CATEGORIES

We will see later that these functors play an important role in the higher-
dimensional structure of categories, but for now we will use the codomain functor
to construct another important new category from old.

1.6.5 Slice Categories

Definition 1.6.5.1 (slice category) Given a category ℂ and object A ∶ ℂ, there


is a category, “ℂ/A” called the slice category of ℂ over A, with the following
structure:
objects (ℂ/A)0 ≔ {𝑓 ∶∶ ℂ | ∂+ (𝑓) = A}
arrows ℂ/A (𝑓 → 𝑔) ≔ {𝑖 ∶ ℂ (∂− (𝑓) → ∂− (𝑔)) | 𝑖 ⋅ 𝑔 = 𝑓}
Identities and composition are inherited from ℂ.
The slice category ℂ/A is a subcategory of the arrow category ℂ→ . It contains
just those objects and arrows that the 𝑐𝑜𝑑 functor sends to A and to id(A),
respectively.
I imagine the arrows of ℂ/A as the bases of inverted triangles with their vertices
anchored at A:
𝑝
X Y

𝑥 𝑦

Composing the sides of such triangles with an arrow 𝑓 ∶ A ⟶ B lets us move


the anchor to B:
𝑝 𝑝
X Y X Y

𝑥 𝑦 𝑥⋅𝑓 𝑦⋅𝑓
A B
𝑓

Lemma 1.6.5.2 (post-composition functor) Every arrow 𝑓 ∶ ℂ (A → B) deter-


mines a functor:
𝑓!
ℂ/A ⟶ ℂ/B
𝑥 ∶ ℂ (X → A) ⟼ 𝑥 ⋅ 𝑓
𝑝 ∶ ℂ (X → Y) ⟼ 𝑝
Chapter 2

Behavioral Reasoning

A fundamental question we must address when studying any kind of formal


system is when two objects with distinct presentations should be considered to
be essentially the same. We can ask this question about sets, groups, topological
spaces, λ-terms, and even categories.
Certainly, whatever relation we choose should be an equivalence relation and
should be a congruence for certain operations, but beyond that, general guide-
lines are hard to come by.
For example, we consider two sets to be essentially the same if there is a bi-
jection between them, that is, if there is an injective and surjective function
from one to the other. Recall that a function 𝑝 ∶ X ⟶ Y is an injection if it
“doesn’t collapse any elements of its domain”:
∀ 𝑥 , 𝑦 ∈ X . 𝑝(𝑥) = 𝑝(𝑦) ⊃ 𝑥 = 𝑦
and is a surjection if it “doesn’t miss any elements of its codomain”:
∀ 𝑦 ∈ Y . ∃ 𝑥 ∈ X . 𝑝(𝑥) = 𝑦

We can’t translate such element-wise definitions directly to the language of


categories because the objects of a category need not be structured sets. So we
must find equivalent behavioral characterizations.

2.1 Monic and Epic Morphisms

2.1.1 Monomorphisms

In the case of injections, we can do this by rephrasing the property so that


instead of talking about the image under 𝑝 of two points of X, we talk about

19
20 CHAPTER 2. BEHAVIORAL REASONING

the composition with 𝑝 of two parallel functions into X. So a function 𝑝 is monic


if:

∀ 𝑓 , 𝑔 ∶ W → X . ∀ 𝑤 ∈ W . (𝑝 ∘ 𝑓)(𝑤) = (𝑝 ∘ 𝑔)(𝑤) ⊃ 𝑓(𝑤) = 𝑔(𝑤)

It may seem that we’ve just made things worse by introducing two extraneous
functions, but now we can use the fact that two functions are equal just in
case they agree on all points to rephrase this again, doing away with the points
entirely. So a function 𝑝 is monic if:

∀ 𝑓 ,𝑔 ∶W→X.𝑓 ⋅𝑝 =𝑔⋅𝑝 ⊃ 𝑓 =𝑔

This is a behavioral characterization of injective function that can be stated for


any category.
Definition 2.1.1.1 (monomorphism) An arrow 𝑚 ∶∶ ℂ is a monomorphism
(or “monic”) if it is post-cancelable. That is, if for any arrows 𝑓 , 𝑔 ∶∶ ℂ,

𝑓 ⋅𝑚 = 𝑔⋅𝑚 implies 𝑓 = 𝑔

Notice that we are being a bit economical here: in order for 𝑓 and 𝑔 to be
composable with 𝑚, they must be coterminal, and in order for their composites
with 𝑚 to be equal, they must also be coinitial. So the definition is only applical
to parallel 𝑓 and 𝑔 composable with 𝑚, but all that can be inferred.
In diagrams, monomorphisms are conventionally drawn with a tailed arrow:
“↣”.
Lemma 2.1.1.2 (monics and composition)
• Identity morphisms are monic.
• Composites of monics are monic.
• If the composite 𝑚 ⋅ 𝑛 is monic then so is 𝑚.

Proof.

𝑓 ⋅𝑚⋅𝑛 = 𝑔⋅𝑚⋅𝑛 𝑓 ⋅𝑚 = 𝑔⋅𝑚


𝑓 ⋅ id = 𝑔 ⋅ id ⇒ [𝑛 is monic] ⇒ [whiskering]
⇒ [unit law] 𝑓 ⋅𝑚 = 𝑔⋅𝑚 𝑓 ⋅𝑚⋅𝑛 = 𝑔⋅𝑚⋅𝑛
𝑓 = 𝑔 ⇒ [𝑚 is monic] ⇒ [𝑚 ⋅ 𝑛 is monic]
𝑓 = 𝑔 𝑓 = 𝑔

Remark 2.1.1.3 (subobjects) If we take the subcategory of a slice category


containing just the monomorphisms then we get a preorder: given monics 𝑚 , 𝑛 ∶
2.1. MONIC AND EPIC MORPHISMS 21

ℂ/A, we say that 𝑚 ≤ 𝑛 just in case there is an 𝑓 ∶ ℂ/A (𝑚 → 𝑛).

𝑓
M N

𝑚 𝑛
A

Such an 𝑓, if it exists, is unique because 𝑛 is monic, and is itself monic by the


preceding lemma.
The monics into an object behave very much like the partial order of subsets
of a set, in fact, they are known as (representatives of) subobjects. This is
the beginning of a branch of categorical logic known as topos theory, where
subobjects are used to interpret predicates. However, it is not the approach
that we will pursue here because by using a preorder to interpret the entailment
relation on propositions we would sacrifice proof relevance: we could say that
one proposition entails another, but not why it does so.

2.1.2 Epimorphisms

Using the op duality, we can define the property dual to that of being monic.
You should check that this amounts to the following:
Definition 2.1.2.1 (epimorphism) An arrow 𝑒 ∶∶ ℂ is an epimorphism (or
“epic”) if it is pre-cancelable. That is, if for any arrows 𝑓 , 𝑔 ∶∶ ℂ,

𝑒⋅𝑓 = 𝑒⋅𝑔 implies 𝑓 = 𝑔

This corresponds to the fact that a surjective function doesn’t miss any points in
its codomain, so if 𝑝 ∶ X ⟶ Y is surjective then for any parallel 𝑓 , 𝑔 ∶ Y ⟶ Z,

(∀𝑥 ∈ X . (𝑓 ∘ 𝑝)(𝑥) = (𝑔 ∘ 𝑝)(𝑥)) ⊃ (∀𝑦 ∈ Y . 𝑓(𝑦) = 𝑔(𝑦))

Eliminating the points gives us the definition of epimorphism.


In diagrams, epimorphisms are conventionally drawn with a double-headed ar-
row: “↠”.
Exercise 2.1.2.2 State and prove the dual theorems to those in lemma 2.1.1.2.
In the category Set a function is injective just in case it is monic, and surjective
just in case it is epic. In many categories of “structured sets” (e.g. Mon) the
monomorphisms are exactly the injective homomorphisms. For instance, the
inclusion (ℕ , + , 0) ↪ (ℤ , + , 0) in the category Mon is a monomorphism.
It turns out to be an epimorphism as well, despite not being surjective on its
underlying set. So, unlike the situation in Set, in an arbitrary category the
existence of a monic and epic morphism between two objects does not suffice to
ensure that they are essentially the same.
22 CHAPTER 2. BEHAVIORAL REASONING

Monic and epic morphisms have other unsatisfactory properties, for example,
they are not necessarily preserved by functors (the existence of a forgetful functor
from monoids to sets, together with the last result implies this).

2.2 Split Monic and Epic Morphisms

Definition 2.2.0.3 (split monomorphism) An arrow 𝑠 is a split monomor-


phism (or “split monic”) if it is post-(semi-)invertible. That is, if there exists
an arrow 𝑟 such that 𝑠 ⋅ 𝑟 = id.

The dual notion is that of:


Definition 2.2.0.4 (split epimorphism) An arrow 𝑟 is a split epimorphism
(or “split epic”) if it is pre-(semi-)invertible. That is, if there exists an arrow 𝑠
such that 𝑠 ⋅ 𝑟 = id.

It would be perverse to name them this way unless split monics were monic and
split epics were epic, which indeed they are.
Lemma 2.2.0.5 A split monomorphism is a monomorphism (and a split epi-
morphism is an epimorphism).

Proof. Suppose 𝑠 is split-monic with 𝑠 ⋅ 𝑟 = id,

𝑓 ⋅𝑠=𝑔⋅𝑠
⟹ [whiskering]
𝑓 ⋅𝑠⋅𝑟 =𝑔⋅𝑠⋅𝑟
⟹ [assumption]
𝑓 ⋅ id = 𝑔 ⋅ id
⟹ [composition unit law]
𝑓 =𝑔

The other case is dual.

Because functors must preserve the composition structure of categories, they


must preserve split monics and epics as well.
Lemma 2.2.0.6 The functor-image of a split monic (split epic) is itself split
monic (split epic).
2.2. SPLIT MONIC AND EPIC MORPHISMS 23

Proof. Suppose 𝑠 is split-monic with 𝑠 ⋅ 𝑟 = id,

F(𝑠) ⋅ F(𝑟)
= [functors preserve composition]
F(𝑠 ⋅ 𝑟)
= [assumption]
F(id)
= [functors preserve identities]
id

So F(𝑠) is split-monic.

Before moving on, let’s consider a particularly pretty application of behavioral


reasoning to the axiom of choice. This proposition states that given a family of
non-empty sets, there is a function that chooses an element from each one.
We can represent any family of sets with an ordinary function in the following
way. Given a function 𝑓 ∶ Set (E → B), we can define a function,

𝑓∗
B ⟶ ℘(E) ↪ Set
𝑏 ⟼ {𝑒 ∈ E | 𝑓(𝑒) = 𝑏}

And given a family of sets, {E𝑏 }𝑏∈B , which is just an function B ⟶ Set, we can
define a function ∫ E𝑏 ⟶ B mapping 𝑒 ∈ E𝑏 ⟼ 𝑏. These two constructions
𝑏∈B
are inverse, they both just sort the elements of E by those in B:

E ● ● ● ● ● ℘(E)

𝑓 𝑓∗

B ● ● ● B

The axiom of choice states that if for each 𝑏 ∈ B the set 𝑓 ∗ (𝑏) is non-empty
then there is a way to choose from E a family of elements {𝑒𝑏 }𝑏∈B such that
∀𝑏 ∈ B . 𝑓(𝑒𝑏 ) = 𝑏 – i.e. such that there is a function 𝑠 ∶ B ⟶ E with
𝑠 ⋅ 𝑓 = id(B). Notice that the condition that the sets 𝑓 ∗ (𝑏) be non-empty is
equivalent to the requirement that 𝑓 be a surjection. So the axiom of choice
asserts that in the category Set, every epimorphism is split!
This is a behavioral characterization of a property that we may ask whether a
given category satisfies. For example, because the inclusion (ℕ,+,0) ↪ (ℤ,+,0)
is epic in the category Mon, it fails to hold there.
24 CHAPTER 2. BEHAVIORAL REASONING

2.3 Isomorphisms
When we have arrows 𝑠 ∶ A ⟶ B and 𝑟 ∶ B ⟶ A such that 𝑠 ⋅ 𝑟 = id(A) we say
that 𝑠 is a section of 𝑟 and that 𝑟 is a retraction of 𝑠. So being split monic
means having a retraction, and being split epic means having a section.
Lemma 2.3.0.7 If a morphism has both a section and a retraction then the
section and the retraction are identical.

Proof. Given arrow 𝑓 ∶ A ⟶ B with section 𝑠 and retraction 𝑟, by pasting,


𝑠 = 𝑟:
𝑠

id

𝑠
B A 𝑓 B A
𝑟

id

If 𝑓 ∶ A ⟶ B has section-and-retraction 𝑔, then 𝑔 ∶ B ⟶ A necessarily has


retraction-and-section 𝑓. In other words, 𝑓 and 𝑔 are (two-sided) inverses for
one another. This leads us to a good behavioral characterization of what it
means for objects to be essentially the same in any category.
Definition 2.3.0.8 (isomorphism) An arrow 𝑓 ∶ A ⟶ B is an isomorphism
if there exists an anti-parallel arrow 𝑔 ∶ B ⟶ A, called an inverse of 𝑓, such
that:
𝑓 ⋅ 𝑔 = id(A) and 𝑔 ⋅ 𝑓 = id(B)

It follows from lemma 2.3.0.7 that an inverse of 𝑓 is unique, so we can write


it unambiguously as “𝑓 −1 ”. To indicate the existence of an unspecified iso-
morphism between objects A and B, we write “A ≅ B” and call the objects
isomorphic.
Isomorphism is the right notion of “essentially the same” for category theory
because in categories we must characterize objects behaviorally, and there is
often no effective way to distinguish between objects that behave identically.
Exercise 2.3.0.9 Show that isomorphism of objects is an equivalence relation;
that is, for any objects A, B and C,
reflexivity A ≅ A
symmetry A ≅ B implies B ≅ A
transitivity A ≅ B and B ≅ C implies A ≅ C
Chapter 3

Universal Constructions

A universal construction is a description of a construction within a category


that determines it uniquely up to a canonical isomorphism. This is the best
kind of description we can hope for in a behavioral setting, where we do not
have direct access to the internal structure of the objects we are working with.
Universal constructions are defined using universal properties that assert that
the construction itself has some property, and that if any other construction has
the same property then there is a canonical relationship between the two.
In this chapter we introduce the universal constructions needed for the cate-
gorical interpretation of intuitionistic propositional proof theory. We do this
in a deliberately methodical way, in order to emphasize the similarities in the
constructions.

3.1 Terminal and Initial Objects

3.1.1 Terminal Objects

In the category Set, a singleton set S has the property that given any set X
there is a unique function from X to S, namely, the constant function on the
only element of S. This is a behavioral characterization that we may state in
an arbitrary category.
Definition 3.1.1.1 (terminal object) In any category, a terminal object is an
object T with the property that for any object X there is a unique morphism
𝑥 ∶ X ⟶ T.
We write “!(X)” for the unique map from an object X to a terminal object and
refer to it as a bang map.

25
26 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

Whenever some construction has a certain relationship to all constructions of


the same kind within a category, it must, in particular, have this relationship
to itself. Socrates’ dictum to “know thyself” is as important in category theory
as it is in life. Consequently, whenever we encounter a universal construction
we will see what we can learn about it by “probing it with itself”. In the case
of a terminal object, this means choosing X ≔ T in the definition.
Lemma 3.1.1.2 (identity expansion for terminals) If T is a terminal object
then !(T) = id(T).

Proof. By definition, !(T) is the unique map 𝑡 ∶ T ⟶ T, but id(T) is necessarily


in the same hom set.

Universal constructions are each unique up to a unique structure-preserving


isomorphism. In the case of a terminal object, there is no structure to be
preserved: it’s just a single object. Consequently, we obtain an especially strong
uniqueness property.
Lemma 3.1.1.3 (uniqueness of terminals) When they exist, terminal objects
are unique up to a unique isomorphism.

Proof. Suppose that T and R are two terminal objects in a category. By as-
sumption, there are unique arrows 𝑡 ∶ T ⟶ R and 𝑟 ∶ R ⟶ T and:

𝑡⋅𝑟 ∶T⟶T
= [T is terminal]
!(T) ∶ T ⟶ T
= [identity expansion for terminals]
id(T) ∶ T ⟶ T

R
𝑡 𝑟

!
T T

id

Symmetrically, we have that 𝑟 ⋅ 𝑡 = id(R). So 𝑡 is an isomorphism. By the


universal property of R, the hom set T ⟶ R is a singleton, so it must be the
only such isomorphism.

Because terminal objects are unique up to unique isomorphism, we write “1” to


refer to an arbitrary terminal object of a category.
3.1. TERMINAL AND INITIAL OBJECTS 27

Exercise 3.1.1.4 (pre-composing with a bang) Use the universal property of a


terminal object to prove the following:
For a terminal object 1 and arrow 𝑖 ∶ Y ⟶ X,

𝑖 ⋅ !(X) = !(Y) ∶ Y⟶1

𝑖
Y X

! !
1

As mentioned, in SET, any singleton set is terminal. Likewise, in Cat, any


singleton category is. In Mon, the trivial monoid (having only the identity
element) is terminal.
Exercise 3.1.1.5 Work out what a terminal object is in the category PreOrd,
and determine when a preordered set, as a category, has a terminal object.

3.1.2 Preliminary Interpretation of Truth

The terminal object universal construction provides the categorical interpreta-


tion of the logical propositional constant truth,

⟦⊤⟧ ≔ 1

The natural deduction introduction rule for truth,


⊤+

is interpreted by the unique map to the terminal object:

⟦⊤+⟧ ≔ !(⟦–⟧)

Truth has no elimination rule. We will interpret the rest of the proof theoretic
features of truth, and of the other connectives of intuitionistic first-order logic, in
a uniform way once we have established some more category theoretic machinery.

3.1.3 Global and Generalized Elements

In Set, there is a bijection between the elements of a set X and the functions
from a singleton set to X: to each 𝑥 ∈ X there corresponds the unique function
⌜𝑥⌝ ∶ 1 ⟶ X mapping ⋆ ⟼ 𝑥. We can use this behavioral characterization to
define an analogue for set membership.
28 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

Definition 3.1.3.1 (global element) In a category with a terminal object, a


global element (or “point”) of an object X is an element of the hom set 1 ⟶ X.
Definition 3.1.3.2 (generalized element) In contrast, a generalized element
of an object X is just a morphism with codomain X; in other words, an object
of the slice category over X.

In Set, we can determine whether or not two functions are the same by probing
them with points because two parallel functions 𝑓 , 𝑔 ∶ Set (X → Y) are defined
to be the same if ∀𝑥 ∈ X . 𝑓(𝑥) = 𝑔(𝑥). This is the principle of function
extensionality. Here is a categorical analogue:
Definition 3.1.3.3 (well-pointed category) A category with a terminal object
is well-pointed if for every 𝑓 , 𝑔 ∶ A ⟶ B, and global element 𝑎 ∶ 1 ⟶ A ,

𝑎⋅𝑓 =𝑎⋅𝑔 implies 𝑓 =𝑔

Notice the similarity to the definition of an epimorphism. In fact, we can say


that the category is well-pointed if its points are jointly epic.
Exercise 3.1.3.4 In contrast to the case with global elements, in any category
we can determine whether or not two parallel arrows are the same by probing
them with generalized elements. Prove this.

3.1.4 Initial Objects

The concept dual to that of a terminal object is of an initial object.


Definition 3.1.4.1 (initial object) In any category, an initial object is an
object S with the property that for any object X there is a unique morphism
𝑥∶S⟶X

We write “¡(X)” for the unique map in S ⟶ X and refer to it as a cobang


map. By probing an initial object with itself we obtain a result dual to lemma
3.1.1.2:
Lemma 3.1.4.2 (identity expansion for initials) If S is an initial object then
¡(S) = id(S).
Exercise 3.1.4.3 (uniqueness of initials) Check that when they exist, initial
objects are unique up to a unique isomorphism.

We write “0” to refer to an arbitrary initial object of a category.


Lemma 3.1.4.4 (post-composing with a cobang) dual to exercise 3.1.1.4:

For an initial object 0 and arrow 𝑖 ∶ X ⟶ Y,

¡(X) ⋅ 𝑖 = ¡(Y) ∶ 0⟶Y


3.2. PRODUCTS 29

0
¡ ¡

X Y
𝑖

In Set, the empty set is initial. Likewise, in Cat, the empty category is. In
Mon, the trivial monoid is initial as well as terminal. (An object which is both
terminal and initial is known as a null object.)
Exercise 3.1.4.5 Dualize exercise 3.1.1.5 by working out what an initial object
is in the category PreOrd, and determine when a preordered set, as a category,
has an initial object.

3.1.5 Preliminary Interpretation of Falsehood

The initial object universal construction provides the categorical interpretation


of the logical propositional constant falsehood,

⟦⊥⟧ ≔ 0

The natural deduction elimination rule for falsehood,



⊥−†
A

is interpreted by the unique map from the initial object1 :

⟦⊥−† ⟧ ≔ ¡(⟦–⟧)

Dual to truth, there is no introduction rule.

3.2 Products

3.2.1 Products of Objects

The cartesian product of two sets is defined to be the set of their ordered pairs:

A×B ≔ {(𝑎 , 𝑏) | 𝑎 ∈ A and 𝑏 ∈ B}

This gives us two projection functions,

π0 ∶ A × B ⟶ A and π1 ∶ A × B ⟶ B
1 Actually, we are brushing something under the rug here having to do with contexts. But

since we haven’t talked about those yet, we’ll just leave it lurking there for now, and revisit
the issue later.
30 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

such that
π0 (𝑎 , 𝑏) = 𝑎 and π1 (𝑎 , 𝑏) = 𝑏

and further, for any 𝑐 ∈ A × B,

𝑐 = (π0 𝑐 , π1 𝑐)

So having a pair of elements, one from the set A and one from the set B, is the
same thing as having a single element of the set A × B: given an 𝑎 ∈ A and
𝑏 ∈ B we make an element of A × B by forming the tuple (𝑎 , 𝑏), and given an
element 𝑐 ∈ A × B we recover an A and a B by taking the projections.
Because not every category is well-pointed – or for that matter, even has a
terminal object – to obtain a behavioral characterization of a product we need
to generalize this description using, appropriately, generalized elements.
Definition 3.2.1.1 (product of objects) In any category, a (cartesian) product
of objects A and B is a span on A and B,
𝑝0 𝑝1
A⟵P⟶B

with the property that for any span on A and B,


𝑥0 𝑥1
A⟵X⟶B

there is a unique map 𝑡 ∶ X ⟶ P such that 𝑡 ⋅ 𝑝0 = 𝑥0 and 𝑡 ⋅ 𝑝1 = 𝑥1 :

𝑥0 𝑥1
𝑡

A P B
𝑝0 𝑝1

This says that there is a bijection between ordered pairs of maps (𝑥0 , 𝑥1 ) and
single maps 𝑡 such that the diagram commutes. We call A and B the factors of
the product, 𝑝0 and 𝑝1 its (coordinate) projections and 𝑡 the tuple of 𝑥0 and
𝑥1 and write it as “⟨𝑥0 , 𝑥1 ⟩”.
Let’s see what we can learn by probing a product with itself by choosing X ≔ P
and (𝑥0 , 𝑥1 ) ≔ (𝑝0 , 𝑝1 ).
Lemma 3.2.1.2 (identity expansion for products) If P is a product of A and B
with projections 𝑝0 and 𝑝1 , then ⟨𝑝0 , 𝑝1 ⟩ = id(P).

Proof. By assumption, ⟨𝑝0 , 𝑝1 ⟩ is the unique map 𝑡 ∶ P ⟶ P with the property


3.2. PRODUCTS 31

that, 𝑡 ⋅ 𝑝0 = 𝑝0 and 𝑡 ⋅ 𝑝1 = 𝑝1 :

𝑝0 𝑝1
⟨𝑝0 , 𝑝1 ⟩

A P B
𝑝0 𝑝1

but by the left unit law of composition, id(P) has this property.

Because products are structures characterized by a universal property, we ex-


pect them to be uniquely determined up to a unique structure-preserving iso-
morphism. This is indeed the case:
Lemma 3.2.1.3 (uniqueness of products) When they exist, products of objects
are unique up to a unique projection-preserving isomorphism.

Proof. Suppose that the spans:


𝑝0 𝑝1 𝑞0 𝑞1
A⟵P⟶B and A⟵Q⟶B

are both products of A and B. Because Q is a product there is a unique 𝑠 ∶


P ⟶ Q such that 𝑠 ⋅ 𝑞0 = 𝑝0 and 𝑠 ⋅ 𝑞1 = 𝑝1 . Likewise, because P is a product
there is a unique 𝑡 ∶ Q ⟶ P such that 𝑡 ⋅ 𝑝0 = 𝑞0 and 𝑡 ⋅ 𝑝1 = 𝑞1 :

𝑝0 𝑝1
𝑠

A Q B
𝑞0 𝑞1

𝑡
𝑝0 𝑝1

Then for 𝑖 ∈ {0 , 1}:


𝑠 ⋅ 𝑡 ⋅ 𝑝𝑖
= [P is a product]
𝑠 ⋅ 𝑞𝑖
= [Q is a product]
𝑝𝑖
32 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

Thus 𝑠 ⋅ 𝑡 = ⟨𝑝0 , 𝑝1 ⟩ ∶ P ⟶ P. By identity expansion for products, 𝑠 ⋅ 𝑡 = id(P).


Reversing the roles of P and Q, we get that 𝑡 ⋅ 𝑠 = id(Q) as well. So 𝑠 is an
isomorphism. By the universal property of Q, it is the only one that respects
the coordinate projections.

Because products are determined as uniquely as is possible by a behavioral


characterization, we write “A × B” to refer to an arbitrary product of A and
B. When the product in question is clear from context, we refer to the two
coordinate projections generically as “π0 ” and “π1 ”.

Note that unlike the case with terminal objects, there is not necessarily a unique
isomorphism between two products of the same factors. For example, in Set the
identity function, (𝑥 , 𝑦) ⟼ (𝑥 , 𝑦), and swap map, (𝑥 , 𝑦) ⟼ (𝑦 , 𝑥), are both
isomorphisms A × A ⟶ A × A. But only the former respects the coordinate
projections.
Definition 3.2.1.4 (diagonal map) For every object A, the universal property
of the product gives a canonical diagonal map, which duplicates its argument:

∆(A) ≔ ⟨id(A) , id(A)⟩ ∶ A⟶A×A

id id

A π0
A×A π1
A

Exercise 3.2.1.5 (pre-composing with a tuple) Use the diagram below and the
universal property of a product of objects to prove the following:

For a product A × B, a tuple ⟨𝑓 , 𝑔⟩ ∶ X ⟶ A × B and an arrow 𝑖 ∶ Y ⟶ X,

𝑖 ⋅ ⟨𝑓 , 𝑔⟩ = ⟨𝑖 ⋅ 𝑓 , 𝑖 ⋅ 𝑔⟩ ∶ Y ⟶ A × B

𝑖
𝑖⋅𝑓 𝑖⋅𝑔

X
𝑓 𝑔
⟨𝑓 , 𝑔⟩

A π0
A×B π1
B
3.2. PRODUCTS 33

3.2.2 Product Functors

We can use the universal property of a product of objects to define a product


of arrows as well:
Definition 3.2.2.1 (product of arrows) Given a pair of arrows 𝑓 ∶ X ⟶ A and
𝑔 ∶ Y ⟶ B, and cartesian products X × Y and A × B, we define the product
of arrows by:
𝑓 ×𝑔 ∶ X×Y ⟶A×B
𝑓 × 𝑔 ≔ ⟨π0 ⋅ 𝑓 , π1 ⋅ 𝑔⟩
That is, 𝑓 × 𝑔 is the unique arrow making the two squares commute:

X π0
X×Y π1
Y

𝑓 𝑓 ×𝑔 𝑔

π0 π1
A A×B B

This allows us to characterize the cartesian product as a functor:


Lemma 3.2.2.2 (functoriality of products) If a category ℂ has products for
each pair of objects, then the given definition of products for arrows yields a
functor,
–×– ∶ ℂ×ℂ⟶ℂ
called the product functor.
Before giving the proof, we pause to explain this statement, as it is easy to be
confused about what is being asserted. In the theorem, “ℂ × ℂ” is the product
category (definition 1.6.1.1). This is indeed a product in the category Cat (as
you should check). In contrast, “– × –” is the name of an alleged functor having
as domain the category ℂ × ℂ and as codomain the category ℂ.

Proof. In order to prove that – × – is a functor, we must show that it preserves


the composition structure.
nullary composition We must show that
id(A0 ) × id(A1 ) = id(A0 × A1 )
In the diagram,
π0 π1
A0 A0 × A1 A1

id id id

A0 π0
A0 × A1 π1
A1
34 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

the arrow id(A0 × A1 ) makes both squares commute, so the result follows
by the definition of product of arrows.
binary composition We must show that

(𝑓0 ⋅ 𝑔0 ) × (𝑓1 ⋅ 𝑔1 ) = (𝑓0 × 𝑓1 ) ⋅ (𝑔0 × 𝑔1 )

In the diagram,
π0 π1
A0 A0 × A 1 A1

𝑓0 𝑓0 × 𝑓 1 𝑓1

π0 π1
B0 B 0 × B1 B1

𝑔0 𝑔0 × 𝑔 1 𝑔1

C0 π0
C0 × C 1 π1
C1

the top two squares commute by the definition of 𝑓0 × 𝑓1 and the bottom
two squares commute by the definition of 𝑔0 × 𝑔1 . By pasting, the rectan-
gle comprising the two left squares commutes, and likewise the rectangle
comprising the two right squares. By definition, (𝑓0 ⋅ 𝑔0 ) × (𝑓1 ⋅ 𝑔1 ) is the
unique arrow from A0 × A1 to C0 × C1 making the outer square commute.

Exercise 3.2.2.3 (post-composing a product of arrows) Use the universal prop-


erty of a product of objects to prove the following:
For arrows ⟨𝑓0 , 𝑓1 ⟩ ∶ X ⟶ A0 × A1 and 𝑔0 × 𝑔1 ∶ A0 × A1 ⟶ B0 × B1 ,

⟨𝑓0 , 𝑓1 ⟩ ⋅ (𝑔0 × 𝑔1 ) = ⟨𝑓0 ⋅ 𝑔0 , 𝑓1 ⋅ 𝑔1 ⟩

X
𝑓0 𝑓1
⟨𝑓0 , 𝑓1 ⟩

A0 π0
A0 × A 1 π1
A1

𝑔0 𝑔0 × 𝑔1 𝑔1

B0 π0
B0 × B1 π1
B1

Corollary 3.2.2.4 (tuple factorization) A tuple ⟨𝑓 , 𝑔⟩ ∶ X ⟶ A × B factors


through the diagonal as,

⟨𝑓 , 𝑔⟩ = ∆(X) ⋅ (𝑓 × 𝑔)
3.2. PRODUCTS 35

X
id id

X π0
X×X π1
X

𝑓 𝑓 ×𝑔 𝑔

A π0
A×B π1
B

3.2.3 Preliminary Interpretation of Conjunction

The product universal construction provides the categorical interpretation of


the logical propositional connective conjunction,

⟦A ∧ B⟧ ≔ ⟦A⟧ × ⟦B⟧

The natural deduction introduction rule for conjunction,


A B
∧+
A∧B

which we will write as follows to emphasize that A and B are being proved from
the same assumptions,
Γ Γ
𝒟0 𝒟1
Γ A B
∧+
A∧B
is interpreted by the tuple construction:

⟦∧+⟧ ≔ ⟨⟦–⟧ , ⟦–⟧⟩

and the natural deduction elimination rules for conjunction,


A∧B A∧B
∧−0 ∧−1
A B

are interpreted by the coordinate projections:

⟦∧−0 ⟧ ≔ π0 and ⟦∧−1 ⟧ ≔ π1

3.2.4 Finite Products

Returning to our theme of unbiased presentations, we would like to define an


𝑛-ary product for each 𝑛 ∈ ℕ. Let’s think about what the universal property of
36 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

such a construction would be. A product of 𝑛 factors would consist of an object


P, together with a coordinate projection, 𝑝𝑖 ∶ P ⟶ A𝑖 for each factor such that
for any 𝑛-ary span 𝑥𝑖 ∶ X ⟶ A𝑖 over the same factors there is a unique 𝑛-tuple
map 𝑡 ∶ X ⟶ P with 𝑡 ⋅ 𝑝𝑖 = 𝑥𝑖 .

𝑡
𝑥0 𝑥1
P

𝑝0 ⋯ 𝑝𝑛−1

A0 ⋯ A𝑛−1

For 𝑛 ≔ 0, a nullary product is an object P (requiring no coordinate projec-


tions) such that for any object X (requiring no maps to the zero factors) there
is a unique null-tuple ⟨ ⟩ ∶ X ⟶ P (satisfying no conditions):

⟨⟩

But this is just a terminal object!


For 𝑛 ≔ 1, a unary product of an object A is an object P with a single
coordinate projection, π ∶ P ⟶ A such that for any arrow 𝑥 ∶ X ⟶ A there is
a unique one-tuple ⟨𝑥⟩ ∶ X ⟶ P with ⟨𝑥⟩ ⋅ π = 𝑥:

𝑥
⟨𝑥⟩

A π
P

A moment’s thought confirms that the choice of P ≔ A and π ≔ id(A) (and


thus ⟨𝑥⟩ ≔ 𝑥) satisfies this property. So any object is a unary product of itself.
Binary products have already been defined, so we have left to consider products
of three or more factors. A ternary product is an object A × B × C, equipped
with three coordinate projection maps such that for any 3-legged span over its
factors there is a unique map from the apex to A × B × C commuting with
3.2. PRODUCTS 37

the coordinate projections. But this is the same universal property enjoyed by
(A × B) × C, which has projections π0 ⋅ π0 to A, π0 ⋅ π1 to B and π1 to C. Any
span over A, B and C contains a subspan over A and B, so by the universal
property of A × B, has a unique map from the apex to this product, which
together with the C leg of the span gives us a unique map from the apex to
(A × B) × C. The product of four or more factors is analogous.

Of course, there is nothing special about the choice of bracketing:


Lemma 3.2.4.1 The cartesian product is associative, up to isomorphism:

A × (B × C) ≅ (A × B) × C

Proof. The maps back and forth,

𝑠 ∶ A × (B × C) ⟶ (A × B) × C and 𝑡 ∶ (A × B) × C ⟶ A × (B × C)

become clear when we draw the diagram showing how each compound product
projects to the three factors, A, B and C:

(A × B) × C
π0

π1
A×B
π0 π1

A B C

π0 π1

π0
B×C

π1
A × (B × C)

From this we can simply read off:

𝑠 ≔ ⟨⟨π0 , π1 ⋅ π0 ⟩ , π1 ⋅ π1 ⟩ ∶ A × (B × C) ⟶ (A × B) × C

𝑡 ≔ ⟨π0 ⋅ π0 , ⟨π0 ⋅ π1 , π1 ⟩⟩ ∶ (A × B) × C ⟶ A × (B × C)
38 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

And then we check:


𝑠⋅𝑡
= [definition 𝑡]
𝑠 ⋅ ⟨π0 ⋅ π0 , ⟨π0 ⋅ π1 , π1 ⟩⟩
= [precomposing with a tuple]
⟨𝑠 ⋅ π0 ⋅ π0 , ⟨𝑠 ⋅ π0 ⋅ π1 , 𝑠 ⋅ π1 ⟩⟩
= [definition 𝑠]
⟨π0 , ⟨π1 ⋅ π0 , π1 ⋅ π1 ⟩⟩
= [precomposing with a tuple]
⟨π0 , π1 ⋅ ⟨π0 , π1 ⟩⟩
= [identity expansion for products]
⟨π0 , π1 ⋅ id⟩
= [composition unit law]
⟨π0 , π1 ⟩
= [identity expansion for products]
id

Similarly, 𝑡 ⋅ 𝑠 = id.

Up to isomorphism, the cartesian product has the structure of a monoid:


Lemma 3.2.4.2 A terminal object is a unit for the cartesian product, up to
isomorphism:
A×1 ≅ A ≅ 1×A

Proof. The projection π0 ∶ A × 1 ⟶ A is an isomorphism, with inverse ⟨id(A) ,


!(A)⟩ ∶ A ⟶ A × 1.
• By the universal property of the product,

⟨id(A) , !(A)⟩ ⋅ π0 = id(A) ∶ A ⟶ A

• Going the other way,

π0 ⋅ ⟨id(A) , !(A)⟩ ∶ A × 1 ⟶ A × 1
= [pre-composing with a tuple]
⟨π0 ⋅ id(A) , π0 ⋅ !(A)⟩
= [composition unit law and pre-composing with a bang]
⟨π0 , !(A × 1)⟩
= [universal property of a terminal object]
⟨π0 , π1 ⟩
= [identity expansion for products]
id(A × 1)
3.2. PRODUCTS 39

And furthermore, this monoid is commutative:


Lemma 3.2.4.3 The cartesian product is symmetric, up to isomorphism:
A×B ≅ B×A

Proof. The swap map, σA,B ≔ ⟨π1 , π0 ⟩ ∶ A × B ⟶ B × A is an isomorphism,


with inverse the swap map, σB,A ≔ ⟨π1 , π0 ⟩ ∶ B × A ⟶ A × B:
σA,B ⋅ σB,A
= [definition]
⟨π1 , π0 ⟩ ⋅ ⟨π1 , π0 ⟩
= [pre-composing with a tuple]
⟨⟨π1 , π0 ⟩ ⋅ π1 , ⟨π1 , π0 ⟩ ⋅ π0 ⟩
= [universal property of a product]
⟨π0 , π1 ⟩
= [identity expansion for products]
id(A × B)

and symmetrically σB,A ⋅ σA,B = id(B × A)

To have finite products – that is, 𝑛-ary products for all 𝑛 ∈ ℕ, it suffices to
have binary products and a terminal object. A category with all finite products
is called a cartesian category.

3.2.5 Preliminary Interpretation of Contexts

Finite products provide the categorical structure needed to interpret (non-


dependent, structural) contexts. We interpret the empty context with a ter-
minal object:
⟦∅⟧ ≔ 1
And we interpret context extension with a cartesian product:
⟦Γ , A⟧ ≔ ⟦Γ⟧ × ⟦A⟧
Finite products give us just the right structure to inplement what are commonly
called the “structural rules” of proof theory. These are most easily described
using a local, or sequent, presentation, in which contexts are recorded explicitly
in each inference rule. In such a presentation, a sequent is interpreted as a hom
set:
⟦Γ ⊢ A⟧ ≔ ⟦Γ⟧ ⟶ ⟦A⟧
and an inference rule is interpreted as a function that builds a member of the
hom set in the conclusion, given a member of each hom set in the premises. For
example, the introduction (or right) rule for conjunction,
Γ ⊢ A Γ ⊢ B
∧R
Γ ⊢ A∧B
40 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

is interpreted by the tupling operation, which takes arrows 𝑓 ∶ ⟦Γ ⊢ A⟧ and


𝑔 ∶ ⟦Γ ⊢ B⟧ and returns ⟨𝑓 , 𝑔⟩ ∶ ⟦Γ ⊢ A ∧ B⟧.
The structural rules of context weakening, contraction and exchange specify
the properties of contexts. Because contexts are interpreted as the domains of
arrows, we expect their interpretations to behave contravariantly.
The rule of context weakening says,

Γ ⊢ B
𝑐𝑤
Γ,A ⊢ B

Its categorical interpretation must be some means of constructing a member of


⟦Γ⟧ × ⟦A⟧ ⟶ ⟦B⟧ from a member of ⟦Γ⟧ ⟶ ⟦B⟧. We can do this by simply
pre-composing the projection π0 ∶ ⟦Γ⟧ × ⟦A⟧ ⟶ ⟦Γ⟧, or equivalently, (up to
the unit isomorphism for products) the product of id(⟦Γ⟧) and the bang map
!(⟦A⟧) ∶ ⟦A⟧ ⟶ ⟦∅⟧:

id × !
⟦Γ⟧ × ⟦A⟧ ⟦Γ⟧ ⟦B⟧

The rule of context contraction says,

Γ,A,A ⊢ B
𝑐𝑐
Γ,A ⊢ B

Its categorical interpretation must be some means of constructing a member of


⟦Γ⟧ × ⟦A⟧ ⟶ ⟦B⟧ from a member of ⟦Γ⟧ × ⟦A⟧ × ⟦A⟧ ⟶ ⟦B⟧. We can do this
(up to the associativity isomorphism for products) by simply pre-composing the
product of id(⟦Γ⟧) and the diagonal map ∆(⟦A⟧) ∶ ⟦A⟧ ⟶ ⟦A⟧ × ⟦A⟧:

id × ∆
⟦Γ⟧ × ⟦A⟧ ⟦Γ⟧ × ⟦A⟧ × ⟦A⟧ ⟦B⟧

The rule of context exchange says,

Γ,B,A ⊢ C
𝑐𝑥
Γ,A,B ⊢ C

Its categorical interpretation must be some means of constructing a member of


⟦Γ⟧ × ⟦A⟧ × ⟦B⟧ ⟶ ⟦C⟧ from a member of ⟦Γ⟧ × ⟦B⟧ × ⟦A⟧ ⟶ ⟦C⟧. We can do
this (up to the associativity isomorphism for products) by simply pre-composing
the product of id(⟦Γ⟧) and the swap map σ(⟦A⟧,⟦B⟧) ∶ ⟦A⟧ × ⟦B⟧ ⟶ ⟦B⟧ × ⟦A⟧:

id × σ
⟦Γ⟧ × ⟦A⟧ × ⟦B⟧ ⟦Γ⟧ × ⟦B⟧ × ⟦A⟧ ⟦C⟧
3.3. COPRODUCTS 41

So a system that a proof theorist might call “structural”, a category theorist


would call “cartesian”: it is one in which we may freely duplicate and delete (as
well as swap the order of) the assumptions in our contexts, without the need
for explicit justification.
Exercise 3.2.5.1 The initial sequent and cut structural rules, say, respec-
tively,
Γ ⊢ A Γ,A ⊢ B
𝑖𝑛𝑖𝑡 𝑐𝑢𝑡
Γ,A ⊢ A and Γ ⊢ B
Use the structure of a cartesian category to define interpretations for these rules.

3.3 Coproducts
A coproduct is the dual construction to a product. Categorically, that is all
there is to say about the matter. But because of the asymmetry of proof-
theoretic derivations – proceeding from a collection of assumptions, interpreted
conjunctively, to a single conclusion – we will have to say a bit more when it
comes to our categorical semantics for proof theory.
First, we record for convenience, but without further comment, the duals of our
main results about products. If you’re new to all this, it would be an excellent
exercise first to go back and see why these are the respective dual theorems,
and then to prove each one explicitly – that is, by actually going through the
argument, rather than by just saying, “by duality, Qed”.

3.3.1 Coproducts of Objects

Definition 3.3.1.1 (coproduct of objects) In any category, a coproduct of


objects A and B is a cospan on A and B,
𝑞0 𝑞1
A⟶Q⟵B

with the property that for any cospan on A and B,


𝑥0 𝑥1
A⟶X⟵B

there is a unique map 𝑠 ∶ Q ⟶ X such that 𝑞0 ⋅ 𝑠 = 𝑥0 and 𝑞1 ⋅ 𝑠 = 𝑥1 :


𝑞0 𝑞1
A Q B

𝑠
𝑥0 𝑥1

X
42 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

We call A and B the cases of the coproduct, 𝑞0 and 𝑞1 its insertions and 𝑠 the
cotuple of 𝑥0 and 𝑥1 , and write it as “[𝑥0 , 𝑥1 ]”.
Probing a coproduct with itself by choosing X ≔ Q and (𝑥0 , 𝑥1 ) ≔ (𝑞0 , 𝑞1 ),
we learn:
Lemma 3.3.1.2 (identity expansion for coproducts) If Q is a coproduct of A
and B with insertions 𝑞0 and 𝑞1 , then [𝑞0 , 𝑞1 ] = id(Q).
And being characterized by a universal property, we expect:
Lemma 3.3.1.3 (uniqueness of coproducts) When they exist, coproducts of
objects are unique up to a unique insertion-preserving isomorphism.
We write “A + B” to refer to an arbitrary coproduct of A and B, When the
coproduct in question is clear from context, we refer to the two case insertions
generically as “ι0 ” and “ι1 ”.
Definition 3.3.1.4 (codiagonal map) For every object A, the universal property
of the coproduct gives a canonical codiagonal map, which forgets about case
distinction:
∇(A) ≔ [id(A) , id(A)] ∶ A + A ⟶ A
ι0 ι1
A A+A A


id id

Lemma 3.3.1.5 (post-composing with a cotuple) For a coproduct A + B, a


cotuple [𝑓 , 𝑔] ∶ A + B ⟶ X and an arrow 𝑗 ∶ X ⟶ Y,

[𝑓 , 𝑔] ⋅ 𝑗 = [𝑓 ⋅ 𝑗 , 𝑔 ⋅ 𝑗] ∶ A + B ⟶ Y
ι0 ι1
A A+B B

[𝑓 , 𝑔]
𝑓 𝑔

X
𝑓 ⋅𝑗 𝑔⋅𝑗
𝑗

3.3.2 Coproduct Functors

Definition 3.3.2.1 (coproduct of arrows) Given a pair of arrows 𝑓 ∶ A ⟶ X


and 𝑔 ∶ B ⟶ Y, and coproducts A + B and X + Y, we define the coproduct of
3.3. COPRODUCTS 43

arrows 𝑓 + 𝑔 ∶ A + B ⟶ X + Y by:

𝑓 +𝑔 ∶ A+B⟶X+Y
𝑓 +𝑔 ≔ [𝑓 ⋅ ι0 , 𝑔 ⋅ ι1 ]

That is, 𝑓 + 𝑔 is the unique arrow making the two squares commute:

A A+B B
ι0 ι1

𝑓 𝑓 +𝑔 𝑔

ι0 ι1
X X+Y Y

This allows us to characterize the coproduct as a functor:


Lemma 3.3.2.2 (functoriality of coproducts) If a category ℂ has coproducts
for each pair of objects, then the given definition of coproducts for arrows yields
a functor,
–+– ∶ ℂ×ℂ⟶ℂ

called the coproduct functor.


Lemma 3.3.2.3 (pre-composing a coproduct of arrows) For arrows 𝑓0 + 𝑓1 ∶
A0 + A1 ⟶ B0 + B1 and [𝑔0 , 𝑔1 ] ∶ B0 + B1 ⟶ X,

(𝑓0 + 𝑓1 ) ⋅ [𝑔0 , 𝑔1 ] = [𝑓0 ⋅ 𝑔0 , 𝑓1 ⋅ 𝑔1 ]

ι0 ι1
A0 A0 + A 1 A1

𝑓0 𝑓0 + 𝑓 1 𝑓1
ι0 ι1
B0 B0 + B 1 B1

[𝑔0 , 𝑔1 ]
𝑔0 𝑔1

Corollary 3.3.2.4 (cotuple factorization) A cotuple [𝑓 ,𝑔] ∶ A + B ⟶ X factors


through the codiagonal as,

[𝑓 , 𝑔] = (𝑓 + 𝑔) ⋅ ∇(X)
44 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

ι0 ι1
A A+B B

𝑓 𝑓 +𝑔 𝑔
ι0 ι1
X X+X X


id id
X

3.3.3 Preliminary Interpretation of Disjunction

The coproduct universal construction provides the categorical interpretation of


the logical propositional connective disjunction,

⟦A ∨ B⟧ ≔ ⟦A⟧ + ⟦B⟧

The natural deduction introduction rules for disjunction,


A B
∨+0 ∨+1
A∨B A∨B

are interpreted by the case insertions:

⟦∨+0 ⟧ ≔ ι0 and ⟦∨+1 ⟧ ≔ ι1

Using the cotuple construction, we are able to interpret the restricted case of
disjunction elimination in which there is no ambient context:

A B
𝒟1 𝒟2
A∨B C C
∨−†
C

in which case we have:


⟦∨−† ⟧ ≔ [⟦–⟧ , ⟦–⟧]
But in order to interpret the full rule for disjunction elimination,

Γ A Γ B
𝒟1 𝒟2
Γ A∨B C C
∨−
C

we need a categorical setting in which the distributive law holds:

𝑑𝑖𝑠𝑡 ∶ X × (A + B) ≅ (X × A) + (X × B)
3.3. COPRODUCTS 45

since, in this setting we could define

⟦∨−⟧ ≔ 𝑑𝑖𝑠𝑡 ⋅ [– , –]

or
X × (A + B)
𝑑𝑖𝑠𝑡 ≅
𝑞0 𝑞1
X×A (X × A) + (X × B) X×B

[𝑓 , 𝑔]
𝑓 𝑔
C

We do not yet have a justification for why the distributive law should hold in our
(admittedly underspecified) categorical setting, but we will remedy this soon.2

3.3.4 Finite Coproducts

Dual to the case for products, we can give an unbiased description of finite co-
products, where the nullary coproduct is an initial object, a unary coproduct
is just the identity function, and for any 𝑛 ≥ 3, the 𝑛-ary coproduct is just the
iterated binary coproduct bracketed any way you like since,
Lemma 3.3.4.1 The coproduct is associative, up to isomorphism:

A + (B + C) ≅ (A + B) + C

Furthermore, it forms a monoid:


Lemma 3.3.4.2 An initial object is a unit for the coproduct, up to isomorphism:

A+0 ≅ A ≅ 0+A

And that monoid is commutative:


Lemma 3.3.4.3 The coproduct is symmetric, up to isomorphism:

A+B ≅ B+A

To have finite coproducts – that is, 𝑛-ary coproducts for all 𝑛 ∈ ℕ, it suffices
to have binary coproducts and an initial object. A category with all finite
coproducts is called a cocartesian category. A category with all finite products
and coproducts is known as bicartesian.
2 If you feel so inclined, you may go back and peak under the rug now.
46 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

3.4 Exponentials

As functional programmers, we are familiar with the idea of function currying,


that is, of viewing a function of two arguments as a higher-order function that
takes the first argument and returns a new function, which, when provided the
second argument, computes the same result as the original function when given
both arguments at once. Once we get used to working with high-order functions,
we wonder how we ever managed to program any other way.

3.4.1 Exponentials of Objects

Exponential objects are the categorical analogue of set-theoretic function space,


allowing us to characterize function currying and λ-abstraction.
Definition 3.4.1.1 (exponential object) In a category with binary products,
an exponential of objects A and B is an object E together with an arrow ε ∶
E × A ⟶ B with the property that for any object X and arrow 𝑓 ∶ X × A ⟶ B
there is a unique arrow λ(𝑓) ∶ X ⟶ E such that λ(𝑓) × A ⋅ ε = 𝑓:

λ(𝑓)
X E

𝑓
X×A B

ε
λ(𝑓) × A
E×A

We call ε the evaluation map of the exponential, and λ(𝑓) the exponential
transpose or “curry” of 𝑓.
Notice that uniqueness together with the “such that” clause lets us recover 𝑓
from λ(𝑓): just take the product with id(A) and compose with ε. This is just
“uncurrying” to functional programmers. If this isn’t clear to you, go back to
the definitions of product and coproduct and see how the same principle allows
us to recover 𝑓 and 𝑔 from ⟨𝑓 , 𝑔⟩ and from [𝑓 , 𝑔], respectively.
Let’s see what we learn by probing an exponential with itself by choosing X ≔ E
and 𝑓 ≔ ε.
Lemma 3.4.1.2 (identity expansion for exponentials) If E is an exponential of
A and B then λ(ε) = id(E).

Proof. By assumption, λ(ε) is the unique map in the hom set E ⟶ E with the
3.4. EXPONENTIALS 47

property that λ(ε) × A ⋅ ε = ε:

λ(ε)
E E

ε
E×A B

ε
λ(ε) × A
E×A

By the left unit law of composition, id(E × A) ⋅ ε = ε, and by the definition of


a product of arrows, id(E × A) = id(E) × id(A). Since id(E) has the desired
property, the result follows from uniqueness.

To summarize:
• currying the evaluation map yields the identity on the exponential, and
• uncurrying the identity on the exponential yields the evaluation map.
Because exponentials are structures characterized by a universal property, we
expect them to be unique up to a structure-preserving isomorphism. This should
be familiar by now.
Lemma 3.4.1.3 (uniqueness of expoentials) When they exist, exponentials are
unique up to a unique evaluation-preserving isomorphism.

Proof. Suppose that (E , ε , λ) and (E′ , ε′ , λ ′ ) are both exponentials of A and


B. By setting X ≔ E′ and 𝑓 ≔ ε′ in the universal property of E, we have:

λ(ε′ )
E′ E

ε′
E′ × A B

ε
λ(ε′ ) × A
E×A

That is, λ(ε′ ) × A ⋅ ε = ε′ . Symmetrically, by the universal property of E′ , we


have λ ′ (ε) × A ⋅ ε′ = ε.
We want to show that λ ′ (ε) ⋅ λ(ε′ ) ∶ E ⟶ E is the identity map. We do so by
48 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

uncurrying it:
(λ ′ (𝑒) ⋅ λ(ε′ )) × id(A) ⋅ ε
= [product functor]
λ ′ (𝑒) × id(A) ⋅ λ(ε′ ) × id(A) ⋅ ε
= [universal property of E]
λ ′ (𝑒) × id(A) ⋅ ε′
= [universal property of E′ ]
ε

So by identity expansion for exponentials, λ ′ (ε) ⋅ λ(ε′ ) = id(E).


λ ′ (ε) λ(ε′ )
E E′ E
id

ε
λ ′ (ε) × A ε′
E×A E′ × A B

λ(ε′ ) × A ε
(λ ′ (ε) ⋅ λ(ε′ )) × A

E×A

Similarly, we have λ(ε′ ) ⋅ λ ′ (ε) = id(E′ ).


So λ ′ (ε) ∶ E ⟶ E′ is an isomorphism. By the universal property of E′ , it is
the only one that respects the evaluation ε′ .

Because exponentials are determined as uniquely as is possible by a behavioral


characterization, we write “A ⊃ B” to refer to an arbitrary exponential of A and
B. The notation “BA ” is also common, and we will use it occasionally, in cases
where the pun is a useful mnemonic.
Definition 3.4.1.4 (pairing map) For every object A, the universal property of
the exponential gives a canonical pairing map, which is a higher-order function
that pairs an argument with a given parameter:
η(X) ≔ λ(id(X × A)) ∶ X ⟶ A ⊃ (X × A)
η
X A ⊃ (X × A)

id
X×A X×A

ε
η×A
(A ⊃ (X × A)) × A
3.4. EXPONENTIALS 49

Exercise 3.4.1.5 (pre-composing with a curry) Use the diagram and the uni-
versal property of an exponential object to prove the following:
For a exponential A ⊃ B, a curry λ𝑓 ∶ X ⟶ A ⊃ B and an arrow 𝑖 ∶ Y ⟶ X,

𝑖 ⋅ λ𝑓 = λ(𝑖 × A ⋅ 𝑓) ∶ Y ⟶ A ⊃ B

𝑖 λ(𝑓)
Y X A⊃B

𝑖×A 𝑓
Y×A X×A B

λ(𝑓) × A ε
(𝑖 ⋅ λ(𝑓)) × A

(A ⊃ B) × A

3.4.2 Exponential Functors

We can use the universal property of exponential objects to define a covariant


exponential functor.
Definition 3.4.2.1 (covariant exponential of an arrow) For a fixed object A,
we define the exponential of an arrow 𝑔 ∶ B ⟶ C to be:

A⊃𝑔 ≔ λ(εB ⋅ 𝑔) ∶ A⊃B⟶A⊃C

By the universal property of exponentials, A ⊃ 𝑔 is the unique arrow making


the triangle commute:

A⊃𝑔
A⊃B A⊃C

εB 𝑔
(A ⊃ B) × A B C

εC
(A ⊃ 𝑔) × A
(A ⊃ C) × A

If this definition seems rather unmotivated, it may help to recall that the curry
of an evaluation map is the identity (lemma 3.4.1.2) and to keep in mind that
the idea behind an exponential of an arrow, A ⊃ 𝑔, is to “post-compose 𝑔”.
50 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

Lemma 3.4.2.2 (functoriality of exponentials) In a category ℂ with finite prod-


ucts and a fixed object A, the given definition of exponential of arrows yields a
functor,
A⊃– ∶ ℂ⟶ℂ

Proof. In order to prove that A ⊃ – is a functor, we must show that it preserves


the composition structure.
nullary composition We must show that

A ⊃ id(B) = id(A ⊃ B)

A ⊃ id(B)
= [definition of A ⊃ – on arrows]
λ(εB ⋅ id(B))
= [composition unit law]
λ(εB )
= [identity expansion for exponentials]
id(A ⊃ B)

binary composition We must show that

A ⊃ (𝑔 ⋅ ℎ) = A ⊃ 𝑔 ⋅ A ⊃ ℎ

In the diagram,

A ⊃ (𝑔 ⋅ ℎ)

A⊃B A⊃C A⊃D


A⊃𝑔 A⊃ℎ
𝑔⋅ℎ

B C D
𝑔 ℎ

εB (I) εC (II) εD

(A ⊃ 𝑔) × A (A ⊃ ℎ) × A
(A ⊃ B) × A (A ⊃ C) × A (A ⊃ D) × A

(A ⊃ (𝑔 ⋅ ℎ)) × A

the outer square commutes by the definition of A ⊃ (𝑔 ⋅ ℎ) and the inner


squares (I) and (II) commute by the definitions of A ⊃ 𝑔 and A ⊃ ℎ,
respectively. By the functoriality of the cartesian product,

(A ⊃ 𝑔) × A ⋅ (A ⊃ ℎ) × A = (A ⊃ 𝑔 ⋅ A ⊃ ℎ) × A
3.4. EXPONENTIALS 51

By pasting squares (I) and (II), we see that:

εB ⋅ (𝑔 ⋅ ℎ) = (A ⊃ 𝑔) × A ⋅ (A ⊃ ℎ) × A ⋅ εD

The result follows by the uniqueness clause of the universal property of


exponentials.

3.4.3 Preliminary Interpretation of Implication

The exponential universal construction provides the categorical interpretation


of the logical propositional connective implication,

⟦A ⊃ B⟧ ≔ ⟦A⟧ ⊃ ⟦B⟧

Depending on your point of view, it is an either happy or unhappy coincidence


that we have overloaded the symbol “⊃” in this way.
The natural deduction introduction rule for implication,

[A]
𝒟
B
⊃+
A⊃B

which we will write with explicit context as,

Γ A
𝒟
Γ B
⊃+
A⊃B

is interpreted by currying:

⟦⊃+⟧ ≔ λ(⟦–⟧)

and the natural deduction elimination rule for implication,

A⊃B A
⊃−
B

is interpreted by the evaluation map:

⟦⊃−⟧ ≔ ε
52 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

3.5 Bicartesian Closed Categories

We have now met all of the universal constructions needed to interpret intu-
itionistic propositional proof theory.
A category having all finite products (i.e. a terminal object and binary prod-
ucts), as well as all exponentials is known as a cartesian closed category. A
category that is both bicartesian and cartesian closed is called a bicartesian
closed category. We will call the subcategory of Cat consisting of bicartesian
closed categories, their (bicartesian closed) structure-preserving functors “BCC”.
So far, we have introduced the interpretations of the introduction and elimi-
nation rules of the propositional connectives in a bicartesian closed category.
However, we have not yet introduced interpretations for the rest of the proof-
theoretical structure (i.e. local reductions and expansions and permutation
conversions).
If we were interested in studying only provability, rather than proofs themselves,
we could stop here. In that case, we could interpret intuitionistic propositional
logic in a bicartesian closed preorder (or poset). These structures are well-known
in lattice theory, where they are called Heyting algebras.
However, because we are interested in proof theory we will ultimately want to
interpret intuitionistic propositional logic into free bicartesian closed categories
– those whose arrows, as well as the equations between them, are exactly the
ones required by the bicartesian closed structure, with no “junk” (additional
arrows) and no “confusion” (additional equations between them).

3.5.1 Context Distributivity

We still have pending the issue of context distributivity. For the propositional
connective disjunction, in order to recover the proof theoretic elimination rule
from the special case of the cotuple, we need to know that the distributive
law holds. Likewise, for the propositional constant falsehood, we need nullary
context distributivity or absorption law,

𝑎𝑏𝑠 ∶ X×0 ≅ 0

It turns out that in any bicartesian closed category these isomorphisms hold.
We don’t have time to give a full explanation of why this is the case, but
the short version is that they’re consequences of the Yoneda principle, which
says essentially that for given objects X , Y ∶ ℂ, if for all objects Z, we have
ℂ (X → Z) ≅ ℂ (Y → Z) in Set then X ≅ Y in ℂ. You should think of this as
generalizing the following statement in a preordered set:

(∀Z . X ≤ Z ⟺ Y ≤ Z) implies X ≅ Y
3.5. BICARTESIAN CLOSED CATEGORIES 53

Using this principle, the (nullary and binary) distributive laws follow from:

ℂ (X × (A + B) → Z)
≅ [product symmetry]
ℂ ((A + B) × X → Z)
ℂ (X × 0 → Z) ≅ [currying]
≅ [product symmetry] ℂ (A + B → X ⊃ Z)
ℂ (0 × X → Z) ≅ [uncotupling]
≅ [currying] ℂ (A → X ⊃ Z) × ℂ (B → X ⊃ Z)
ℂ (0 → X ⊃ Z) ≅ [uncurrying]
≅ [universal property of 0] ℂ (A × X → Z) × ℂ (B × X → Z)
ℂ (0 → Z) ≅ [product symmetry]
ℂ (X × A → Z) × ℂ (X × B → Z)
≅ [cotupling]
ℂ ((X × A) + (X × B) → Z)

3.5.2 On Classical Proof Theory

Bicartesian closed categories are ideally suited to interpreting intuitionistic


propositional logic. However, if we try to use them to interpret classical propo-
sitional logic, things begin to collapse.
Lemma 3.5.2.1 In a bicartesian closed category, if there is an arrow 𝑓 ∶ A ⟶ 0
then A ≅ 0.

Proof. Because A × 0 ≅ 0, the object A × 0 is initial and the hom set A × 0 ⟶


A × 0 is a singleton. In particular, the following diagram must commute:

π1 ¡
A×0 0 A×0

id

By pasting, we get 𝑓 ⋅ ¡(A) = id(A):

𝑓 ¡
A 0 A

⟨id , 𝑓⟩ π1 ¡ π0

A×0 id A×0

id
54 CHAPTER 3. UNIVERSAL CONSTRUCTIONS

And by the universal property of 0, we also have ¡(A) ⋅ 𝑓 = id(0). So A ≅ 0.


Corollary 3.5.2.2 In a bicartesian closed category, there is at most one arrow
in the hom set X × A ⟶ 0, and hence in X ⟶ A ⊃ 0.
This means that if we interpret the proofs of propositional logic as arrows of
a bicartesian closed category, then there is at most one proof of a negated
proposition.
If we were to adopt the boolean axiom ¬¬A ⊢ A, then every proposition
would be equivalent to a negated one so there would be at most one proof of
any proposition!
In other words, a “boolean category”, that is, a bicartesian closed category
where A ≅ (A ⊃ 0) ⊃ 0 must be a preorder category. Such a category is known
as a boolean algebra.
Chapter 4

Two Dimensional Structure

We have deliberately presented the universal constructions of a bicartesian


closed category in such a way as to highlight the parallels between them. The
reader may be wondering whether there is some more general construction lurk-
ing in the wings, in terms of which terminal and initial objects, products, co-
products and exponentials can all be described. This is indeed the case: the
mystery construction is called an adjunction. But in order to describe it we will
need to first understand some 2-dimensional category theory.

4.1 Naturality
Naturality is the carrier of the two-dimensional structure of categories of cate-
gories. It is a sort of coherence or uniformity property that allows us to interpret
a family of features within a particular category as a single feature in the am-
bient category of categories.

4.1.1 Natural Transformations

Definition 4.1.1.1 (natural transformation) For parallel functors, F , G ∶ ℂ ⟶


𝔻, a natural transformation, φ from F to G is a functor φ ∶ ℂ ⟶ 𝔻→ such
that
φ ⋅ dom = F and φ ⋅ cod = G

Explicitly, this means that,


• for each object A ∶ ℂ there is an arrow,
φ(A) ∶ 𝔻 (F(A) → G(A))
called the component of φ at A, and

55
56 CHAPTER 4. TWO DIMENSIONAL STRUCTURE

• for each arrow 𝑓 ∶ ℂ (A → B) there is a naturality square witnessing,

F(𝑓) ⋅ φ(B) = φ(A) ⋅ G(𝑓)

ℂ∶ 𝔻∶

𝑓 F(𝑓)
A B F(A) F(B)

ϕ(A) ϕ(B)

G(A) G(B)
G(𝑓)

One way to think about this is that a functor “projects” an image of its domain
category into its codomain category. In this sense, a functor acts as a lens,
which may “distort” the structure of the source category by identifying distinct
objects or arrows. Under this interpretation, a component of a natural trans-
formation acts as a “homotopy” between the images of an object cast by two
parallel functors, and a naturality square ensures that these object homotopies
are consistent with the images of arrows.
You may also think of the naturality square above as a “2-dimensional arrow”
from the 1-dimensional arrow F(𝑓) to the 1-dimensional arrow G(𝑓), acting as
the “component” of φ at 𝑓. But in an ordinary (1-dimensional) category, the
only “2-dimensional arrows” available are the trivial ones – i.e. equalities.

4.1.2 Functor Categories

Natural transformations provide a notion of arrows for a collection of parallel


functors, turning a hom set into a hom category:
Definition 4.1.2.1 (functor category) For categories ℂ and 𝔻, define the func-
tor category, “Fun(ℂ , 𝔻)”, to have the following structure:
objects Fun(ℂ , 𝔻)0 ≔ functors from ℂ to 𝔻
arrows Fun(ℂ , 𝔻) (F → G) ≔ natural transformations from F to G
identities id(F)(A) ≔ id(F(A))
(A component of an identity natural transformation is an identity arrow.)
composition (φ ⋅ ψ)(A) ≔ φ(A) ⋅ ψ(A)
(A component of a composite natural transformation is the composition
of the constituent components.)
Composition of natural transformations in the functor category Fun(ℂ , 𝔻) is
associative and unital just because composition of morphisms is so in 𝔻.
4.2. 2-CATEGORIES 57

An important class of natural transformations is the natural isomorphisms. A


natural isomorphism is simply an isomorphism in a functor category. Un-
packing this a bit, for parallel functors, F , G ∶ ℂ ⟶ 𝔻, a natural transfor-
mation φ ∶ Fun(ℂ , 𝔻) (F → G) is a natural isomorphism if it has an inverse
φ−1 ∶ Fun(ℂ , 𝔻) (G → F).
Exercise 4.1.2.2 Show that a natural transformation is a (natural) isomor-
phism in the functor category Fun(ℂ , 𝔻) just in case each of its components is
an isomorphism in 𝔻.

An exponential object A ⊃ B in a category ℂ is an object representing the


collection of morphisms ℂ (A → B). If ℂ is a category of categories, then an
object in ℂ is a category and the morphisms between any two such are functors.
So it is natural to wonder whether functor categories are exponential objects
in categories of categories. This is generally the case when such exponential
categories exist. In particular, it is true in the category of small categories:
Fact 4.1.2.3 (exponential categories) The category Cat has functor categories
as exponential objects. That is, for 𝔸 , 𝔹 ∶ Cat,

𝔸⊃𝔹 = Fun(𝔸 , 𝔹)

From now on we will use exponential notation for functor categories.

4.2 2-Categories

4.2.1 2-Dimensional Categorical Structure

Something subtle and profound has just happened, so let’s go through it care-
fully. Recall that when we introduced categories, we gave them structure at two
different dimensions:

• at dimension 0, we have “points”, in the form of objects,

• and at dimension 1, we have “lines”, in the form of arrows.

But in introducing natural transformations, we just said that for any two fixed
objects, we have a whole category of functors and natural transformations be-
tween them, so the hom collections in Cat are not 0-dimensional sets, but rather
1-dimensional categories. This gives the category Cat structure at dimension 2
as well!

For fixed categories 𝔸 and 𝔹, and parallel functors F1 , F2 ∶ 𝔸 ⟶ 𝔹, we can


draw a natural transformation α ∶ F1 ⟶ F2 as a “surface” in a 2-dimensional
58 CHAPTER 4. TWO DIMENSIONAL STRUCTURE

diagram in Cat:
F1

𝔸 ⇓α 𝔹

F2

And if we have another parallel functor F3 ∶ 𝔸 ⟶ 𝔹 and natural transformation


β ∶ F2 ⟶ F3 , we can draw the composite natural transformation α ⋅ β ∶ F1 ⟶
F3 as:
F1
⇓α
𝔸 F2 𝔹
⇓β
F3

Now we come to the question of what happens if we don’t require the pair
of objects under consideration to remain fixed. Consider the following pair of
natural transformations:
F1 G1

𝔸 ⇓α 𝔹 ⇓β ℂ

F2 G2

We have the composite parallel functors,


(F1 ⋅ G1 ) , (F2 ⋅ G2 ) ∶ 𝔸 ⟶ ℂ
Is there some way to form a composite natural transformation, α⋅⋅β ∶ F1 ⋅ G1 ⟶
F2 ⋅ G2 ? 1 Well, given an object A ∶ 𝔸, we know that the component of such a
composite natural transformation at A should be an arrow,
(α ⋅ ⋅β)(A) ∶ ℂ ((G1 ∘ F1 )(A) → (G2 ∘ F2 )(A))
Here is how we can define it:
Lemma 4.2.1.1 (horizontal composition of natural transformations) In the sit-
uation just described, there is a natural transformation
α ⋅ ⋅β ∶ F1 ⋅ G1 ⟶ F2 ⋅ G2
called the horizontal composition of α and β, with components,
(α ⋅ ⋅β)(A) ≔ G1 (α(A)) ⋅ β(F2 (A)) = β(F1 (A)) ⋅ G2 (α(A))
1 Read “α ⋅ ⋅β” as “α beside β” – that is, composed along their common boundary two

dimensions down, rather than the usual one dimension down with “– ⋅ –”. The reader may
amuse herself thinking about how to extend this pattern to still higher dimensions.
4.2. 2-CATEGORIES 59

Proof. To see that the two composites are indeed equal consider the component
of α at A in 𝔹. This determines a naturality square for β at α(A) in ℂ:

𝔹∶ ℂ∶

α(A) G1 (α(A))
F1 (A) F2 (A) G1 (F1 (A)) G1 (F2 (A))

β(F1 (A)) β(F2 (A))

G2 (F1 (A)) G2 (F2 (A))


G2 (α(A))
(4.1)
establishing that the two expressions for the putative components of α ⋅ ⋅β co-
incide.
Now we must show that this definition of components respects arrows in 𝔸. Let
𝑓 ∶ 𝔸 (A → B). Then in the diagram in ℂ,

G1 (F1 (A)) G1 (F1 (𝑓)) G1 (F1 (B))

G1 (α(A)) G1 (α(B))

G1 (F2 (A)) G1 (F2 (𝑓)) G1 (F2 (B))


β(F1 (A))
β(F1 (B))

β(F2 (A))
β(F2 (B))
G2 (F1 (A)) G2 (F1 (𝑓)) G2 (F1 (B))
G2 (α(A)) G2 (α(B))

G2 (F2 (A)) G2 (F2 (𝑓)) G2 (F2 (B))

• the left and right squares are the naturality squares of β at α(A) and α(B),
• the top and bottom squares are G1 and G2 functor-images of the natu-
rality squares of α at 𝑓,
• and the back and front squares are the naturality squares of β at F1 (𝑓)
and F2 (𝑓).
Pasting the top and front – or equivalently, of the back and bottom – squares
establishes the naturality of α ⋅ ⋅β at 𝑓.
Remark 4.2.1.2 (connection to arrow categories) The construction in the pre-
ceding proof should remind you of the double arrow category construction. This
is because the arrow category 𝔻→ is equivalent to the functor category 𝕀 ⊃ 𝔻,
where 𝕀 is the interval category.
Exercise 4.2.1.3 Check that horizontal composition respects the composition
structure of each functor category by pasting squares onto diagram 4.1.
60 CHAPTER 4. TWO DIMENSIONAL STRUCTURE

Mercifully, we do not need to reason about natural transformations in this cum-


bersome, component-wise manner. After all, the whole point of the categorical
approach is to allow us to reason behaviorally rather than structurally. The
component-wise definition of natural transformations is reminiscent of Plato’s
Allegory of the Cave: the components and naturality squares in the codomain
category are mere shadows cast by the flesh-and-blood natural transformations,
which are two-dimensional morphisms between parallel one-dimensional mor-
phisms living in a 2-dimensional category. Let us turn our heads and stumble
into the light.
A strict 2-dimensional globular category, or 2-category, has:
• 0-dimensional structure in the form of objects or 0-cells,
• 1-dimensional structure in the form of arrows or 1-cells between 0-cells.
These compose along their 0-dimensional boundaries such that any path
of 1-cells has a unique composite.
• 2-dimensional structure in the form of surfaces or 2-cells between parallel
1-cells. These compose along both their 1- and 0-dimensional boundaries
such that any 2-dimensional pasting diagram has a unique composite.
The category Cat with its categories, functors and natural transformations, is
a 2-category. In particular, this implies the interchange law, which says that
in the situation,
F I
⇓α ⇓γ
𝔸 G 𝔹 J ℂ
⇓β ⇓δ
H K

we have:
(α ⋅ β) ⋅ ⋅(γ ⋅ δ) = (α ⋅ ⋅γ) ⋅ (β ⋅ ⋅δ) ∶ F ⋅ I ⟶ H ⋅ K

There are several equivalent ways to axiomatize the notion of 2-category, but
for our purposes, this informal description will suffice.

4.2.2 String Diagrams

If we take the Poincaré (or graph) dual of the 2-dimensional diagrams we have
been drawing, we obtain a very useful graphical language for 2-categories, called
string diagrams. Specifically, we will use “planar progressive” string diagrams
to represent configurations of 0-, 1-, and 2-cells.
In the graphical language of string diagrams,
0-cells (e.g. ℂ ∶ Cat) are represented as regions in the plane,
4.2. 2-CATEGORIES 61

1-cells (e.g. F ∶ ℂ ⟶ 𝔻) are represented by lines or “strings” or “wires”, (in


our convention) progressing from top to bottom,
2-cells (e.g. α ∶ F ⟶ G) are represented by points, fattened up into “nodes”
or “beads” with the wires representing their domain 1-cells entering from
above, and those representing their codomain 1-cells exiting from below.
identity 1-cells (e.g. id(ℂ)) are represented by a “ghost wire”, or usually, not
at all,
1-cell composition (e.g. F ⋅ I) is represented by juxtaposing wires side-by-side,
separated by the region representing their common boundary,
identity 2-cells (e.g. id(F)) are represented by a “ghost node”, or usually, not
at all,
2-cell vertical composition (e.g. α ⋅ β) is represented by wiring the output
sockets of the first node to the input sockets of the second,
2-cell horizontal composition (e.g. α ⋅ ⋅γ) is represented juxtaposing nodes ,
together with their wires, side-by-side,
As an example, the pasting diagram for the interchange law becomes the string
diagram:
F I

α γ
𝔸 G 𝔹 J ℂ
β δ

H K

Typically, we omit labeling the regions as their identities can always be inferred.
The commuting of diagram 4.1 in the definition of horizontal composition of 2-
cells represents the notion of naturality as independence, depicted in string
diagrams by the property that two beads without an output-to-input connection
between them may freely “slide” past one another along their wires, and it makes
no difference which is above or below the other.

F1 F1 G1 G1

α G1 F1 β
= α β =
F2 β α G2

G2 F2 G2 F2

The idea of independence is the heart of naturality; the rest of its properties
can be recovered from this.
62 CHAPTER 4. TWO DIMENSIONAL STRUCTURE

There is a handy “trick” for transforming diagrams within a category into string
diagrams using global elements. Notice that for any object A ∶ ℂ there is a func-
tor (which we typically overload with the same name) A ∶ 𝟙 ⟶ ℂ picking out
that object, and for any arrow 𝑓 ∶ ℂ (A → B) there is a natural transformation
between the respective functors, which we can represent as the string diagram:

𝟙 𝑓 ℂ

Exercise 4.2.2.1 Show how the commuting of naturality squares is a conse-


quence of naturality as independence.

4.3 Adjunctions

Adjunctions are constructions that may exist in the context of a 2-dimensional


category. In any 2-category adjunctions have a behavioral or “external” char-
acterization. In the 2-category Cat they also have structural or “internal” char-
acterizations. While the behavioral characterization is more perspicuous, the
structural ones will be important for the semantics of proof theory.

4.3.1 Behavioral Characterization

For our primary definition of adjunction we adopt the following behavioral one,
which we call the “zigzag characterization”:
Definition 4.3.1.1 (adjunction – zigzag characterization) Anti-parallel func-
tors F ∶ ℂ ⟶ 𝔻 and G ∶ 𝔻 ⟶ ℂ form an adjunction, written “F ⊣ G”, if there
exist natural transformations:

• η ∶ id(ℂ) ⟶ F ⋅ G, called the adjunction’s unit, and

• ε ∶ G ⋅ F ⟶ id(𝔻), called the adjunction’s counit,

satisfying the relations:

• left zigzag law: (η ⋅ ⋅F) ⋅ (F ⋅ ⋅ε) = id(F)

• right zigzag law: (G ⋅ ⋅η) ⋅ (ε ⋅ ⋅G) = id(G)


4.3. ADJUNCTIONS 63

The reason for the name “zigzag” becomes apparent when the laws are drawn
as string diagrams:

η F
G = F
F ε

G η
F = G
ε G

The chirality of the zigzag laws comes from the fact that when F ⊣ G, F is
called left adjoint to G, and G is called right adjoint to F.

4.3.2 Structural Characterizations

Instead of thinking of an adjunction as a single structure living in the 2-category


Cat, we can think of it as a correlation between families of structures living
in two particular categories. This is like the component-wise presentation of
a natural transformation. One such characterization of an adjunction is the
following:
Definition 4.3.2.1 (adjunction – natural bijection of hom sets charaterization)
Anti-parallel functors F ∶ ℂ ⟶ 𝔻 and G ∶ 𝔻 ⟶ ℂ form an adjunction F ⊣ G if
for any A ∶ ℂ and B ∶ 𝔻 there is a natural bijection of hom sets:

ℂ (A → G(B))
θ
𝔻 (F(A) → B)

This characterization is internal or structural because, unlike the zigzag char-


acterization, we look inside the categories ℂ and 𝔻. We will call the downward
direction of such a bijection “–♯ ” and the upward direction “–♭ ”, so:

–♯
𝑓 ∶ ℂ (A → G(B)) ⟼ 𝑓 ♯ ∶ 𝔻 (F(A) → B)
and
–♭
𝑔 ∶ 𝔻 (F(A) → B) ⟼ 𝑔♭ ∶ ℂ (A → G(B))
and
(𝑓 ♯ )♭ = 𝑓 and (𝑔♭ )♯ = 𝑔

We call the image of an arrow under this bijection its adjoint complement.
64 CHAPTER 4. TWO DIMENSIONAL STRUCTURE

A bijection of hom sets is natural if it extends along its boundary by the relevant
functors. In this case, that means that for any 𝑎 ∶ ℂ (A′ → A) and 𝑏 ∶ 𝔻 (B →
B′ ) we have,
𝑎 𝑓 = 𝑔♭ G(𝑏)
ℂ∶ A′ A G(B) G(B′ )

𝔻∶ F(A′ ) F(A) B B′
F(𝑎) 𝑔 = 𝑓♯ 𝑏

Technically, this is a natural isomorphism in the functor category (ℂ° × 𝔻) ⊃ Set


between ℂ (–1 → G(–))2 1
and 𝔻 (F(–) 2
→ –).
We won’t prove the equivalence of the various characterizations of adjunctions
in this course, but the fact that the zigzag characterization implies the natural
bijection of hom sets characterization is easy to see using string diagrams.
Given an arrow 𝑓 ∶ ℂ (A → G(B)), the obvious way to construct an arrow
𝑓 ♯ ∶ 𝔻 (F(A) → B) out of the parts at hand is by defining,
𝑓♯ ≔ F(𝑓) ⋅ ε(B)
A A
F
–♯ 𝑓
𝑓 ⟼ G
G
ε
B B

Likewise, given an arrow 𝑔 ∶ 𝔻 (F(A) → B), the obvious way to construct an


arrow 𝑔♭ ∶ ℂ (A → G(B)) is by defining,
𝑔♭ ≔ η(A) ⋅ G(𝑔)
A F A η
–♭
𝑔 ⟼ F
𝑔
G
B B

We can use the zigzag laws to show that –♯ and –♭ are inverse operations:
A η A A
𝑓
(𝑓 ♯ )♭ = 𝑓 F = η = 𝑓
G
G G F
B ε B ε G B G

A η A η F A F
F F G
♭ ♯ F
(𝑔 ) = 𝑔 G = ε = 𝑔
𝑔
B ε B
B
4.3. ADJUNCTIONS 65

The naturality of the bijection in the domain and codomain coordinates is also
obvious in the graphical language.
• For naturality in the codomain coordinate, given 𝑏 ∶ 𝔻 (B → B′ ) we have:

A A
F
𝑓 𝑓 F
G B
𝑓 ♯ ⋅𝑏 = B = G
= (𝑓⋅G(𝑏))♯
ε 𝑏
𝑏 ε
B′ B′

• For naturality in the domain coordinate, given 𝑎 ∶ ℂ (A′ → 𝑎) we have:

A′ A′
𝑎 η
η 𝑎
𝑎⋅𝑔♭ = A = F = (F(𝑎)⋅𝑔)♭
F A
𝑔 𝑔 G
G
B B

Exercise 4.3.2.2 With 𝑓, 𝑔, 𝑎 and 𝑏 as in the proof above, verify the following:
• (𝑔 ⋅ 𝑏)♭ = 𝑔♭ ⋅ G(𝑏)
• (𝑎 ⋅ 𝑓)♯ = F(𝑎) ⋅ 𝑓 ♯
We can work out that the adjoint complements of components of the unit and
counit of an adjunction are identities, which are easily seen in string diagrams:

G F
–♯
id(G(B)) = B G ⟼ B = ε(B)
ε

–♭ η
id(F(A)) = A F ⟼ A = η(A)
F G

Two more structural characterizations of an adjunction – which are dual to one


anther – are given by the universal properties of its unit and counit.
Definition 4.3.2.3 (adjunction – universal property of unit characterization)
Anti-parallel functors F ∶ ℂ ⟶ 𝔻 and G ∶ 𝔻 ⟶ ℂ form and adjunction
66 CHAPTER 4. TWO DIMENSIONAL STRUCTURE

F ⊣ G if there is a natural transformation η ∶ id(ℂ) ⟶ F ⋅ G such that for any


𝑓 ∶ ℂ (A → G(B)) there is a unique 𝑔 ∶ 𝔻 (F(A) → B) such that η(A) ⋅ G(𝑔) = 𝑓:

(G ∘ F)(A)
G(𝑔)
η(A)

ℂ∶ A G(B)
𝑓

𝔻∶ F(A) B
𝑔

Definition 4.3.2.4 (adjunction – universal property of counit characterization)


Anti-parallel functors F ∶ ℂ ⟶ 𝔻 and G ∶ 𝔻 ⟶ ℂ form and adjunction
F ⊣ G if there is a natural transformation ε ∶ G ⋅ F ⟶ id(𝔻) such that for any
𝑔 ∶ 𝔻 (F(A) → B) there is a unique 𝑓 ∶ ℂ (A → G(B)) such that F(𝑓) ⋅ ε(B) = 𝑔:
𝑓
ℂ∶ A G(B)

𝑔
𝔻∶ F(A) B

ε(B)
F(𝑓)
(F ∘ G)(B)

Of course, 𝑔 = 𝑓 ♯ and 𝑓 = 𝑔♭ . So the “internal picture” of an adjunction looks


like this:
(G ∘ F)(A)
G(𝑓 ♯ )
η(A)
⇓ β𝑙
ℂ∶ A G(B)
𝑓 = 𝑔♭

𝑔 = 𝑓♯
𝔻∶ F(A) B
β𝑟 ⇑
ε(B)
F(𝑔♭ )
(F ∘ G)(B)

The 2-cells labeled “β𝑙 ” and “β𝑟 ” are both equalities because ℂ and 𝔻 are just
ordinary (1-dimensional) categories so equality is the only possible kind of 2-
cell. But as we will see shortly, it is convenient to give them a suggestive name
and orientation.
4.3. ADJUNCTIONS 67

4.3.3 Harmony of the Propositional Connectives

The universal property of the counit should immediately remind you of the
definition of an exponential object. Indeed, for a fixed object A, we have endo-
functors
–×A ∶ ℂ⟶ℂ and A⊃– ∶ ℂ⟶ℂ
and an adjunction
–×A ⊣ A⊃–
The counit of this adjunction is the evaluation map and the unit is the pairing
map. The internal picture of this adjunction looks like this:

A ⊃ (X × A)
A⊃𝑓
η(X)

ℂ∶ X A⊃B
λ(𝑓)

𝑓
ℂ∶ X×A B
β𝑟 ⇑
ε(B)
λ(𝑓) × A
(A ⊃ B) × A

Recall our interpretations for the natural deduction introduction and elimination
rules for implication in terms of exponentials:

⟦⊃+⟧ = λ(–) and ⟦⊃−⟧ = ε(–)

The universal property of exponentials is just the universal property of the


counit of this adjunction. Its commuting triangle β𝑟 ,

λ(𝑓) × A ⋅ ε(B) = 𝑓

expresses the local reduction for implication:

Γ A
𝒟
Γ B Γ A
⊃+
A⊃B A 𝒟
⊃− ⊃>
B ⟼ B

Identity expansion for exponentials (lemma 3.4.1.2), which gives us the adjoint
complement of an identity morphism,

id(A ⊃ B) = λ(ε)
68 CHAPTER 4. TWO DIMENSIONAL STRUCTURE

expresses the local expansion of an identity derivation:

A⊃B A
⊃−
A⊃B B
⊃< ⊃+
A⊃B ⟼ A⊃B

Pre-composing with a curry (exercise 3.4.1.5), which expresses the naturality of


the hom set bijection in its domain coordinate,

𝑖 ⋅ λ𝑓 = λ(𝑖 × A ⋅ 𝑓)

allows us to move any derivation pre-composed with a ⊃+ rule into the hypo-
thetical subderivation. We can view this as a kind of permutation conversion:

Γ

Γ C A C A
ℰ 𝒟 𝒟
C B Γ B
⊃+ ⊃⇄ ⊃+
A⊃B ⟼ A⊃B

Combining this with the special case of local expansion of an identity derivation
yields the general case of local expansion for implication.
Remarkably, the same pattern obtains for the other negatively-presented propo-
sitional connectives (∧ and ⊤). There is an adjunction F ⊣ G such that:
• their introduction rule is interpreted by the adjoint complement operation,

⟦∗+⟧ ≔ –♭

• their elimination rule is interpreted by the component of the counit,

⟦∗−⟧ ≔ ε(–)

• their local reduction is interpreted by the commuting triangle in the uni-


versal property of the counit,

⟦∗ >⟧ ≔ β𝑟

• their identity local expansion is interpreted by the adjoint complement of


an identity morphism,

⟦∗ <⟧ ≔ id(G –) = (ε –)♭


4.3. ADJUNCTIONS 69

• their permutation conversion is interpreted by the naturality of the hom


set bijection in the domain coordinate,

⟦∗ ⇄⟧ ≔ 𝑖 ⋅ 𝑔♭ = (F(𝑖) ⋅ 𝑔)♭

And just as remarkably, modulo context distributivity, the dual pattern obtains
for the positively-presented propositional connectives (∨ and ⊥). There is an
adjunction such that:
• their introduction rule is interpreted by the component of the unit,

⟦∗+⟧ ≔ η(–)

• their elimination rule is interpreted by the adjoint complement operation,

⟦∗−⟧ ≔ –♯

• their local reduction is interpreted by the commuting triangle in the uni-


versal property of the unit,

⟦∗ >⟧ ≔ β𝑙

• their identity local expansion is interpreted by the adjoint complement of


an identity morphism,

⟦∗ <⟧ ≔ id(F –) = (η –)♯

• their permutation conversion is interpreted by the naturality of the hom


set bijection in the codomain coordinate,

⟦∗ ⇄⟧ ≔ 𝑓 ♯ ⋅ 𝑖 = (𝑓 ⋅ G(𝑖))♯

This provides the algebraic basis for connective harmony.

Adjoints to a Diagonal Functor

Recall that the category Cat has products via the product category construction,
and that in any category with products we can define diagonal maps. This
implies that for any category ℂ we have a diagonal functor,


ℂ ⟶ ℂ×ℂ
A ⟼ (A , A)
𝑓 ⟼ (𝑓 , 𝑓)
70 CHAPTER 4. TWO DIMENSIONAL STRUCTURE

When the category ℂ has products, the product functor, – × – ∶ ℂ × ℂ ⟶ ℂ, is


right adjoint to the diagonal functor:
∆ ⊣ –×–
The counit of this adjunction is the ordered pair of projections and the unit is
the diagonal map. The internal picture for this adjunction looks like this:

X×X
𝑓 ×𝑔
∆(X)

ℂ∶ X A×B
⟨𝑓 , 𝑔⟩

(𝑓 , 𝑔)
ℂ×ℂ∶ ∆(X) (A , B)
β𝑟 ⇑
(π0 , π1 )(A , B)
∆⟨𝑓 , 𝑔⟩
∆(A × B)

Recall our interpretations for the natural deduction introduction and elimination
rules for conjunction in terms of products:
⟦∧+⟧ = ⟨– , –⟩ and ⟦∧−⟧ = (π0 , π1 )
The universal property of products is just the universal property of the counit
of this adjunction. Its commuting triangle β𝑟 ,
∆⟨𝑓 , 𝑔⟩ ⋅ (π0 , π1 ) = (𝑓 , 𝑔)
expresses the local reduction for conjunction:

Γ Γ Γ Γ
𝒟0 𝒟1 𝒟0 𝒟1
Γ A B Γ A B Γ Γ
∧+ ∧+
A∧B A∧B 𝒟0 𝒟1
∧−0 ∧−1 ∧>
A B ⟼ A B

Identity expansion for products (lemma 3.2.1.2), which gives us the adjoint
complement of an identity morphism,
id(A × B) = ⟨π0 , π1 ⟩
expresses the local expansion of an identity derivation:

A∧B A∧B
∧−0 ∧−1
A∧B A B
∧< ∧+
A∧B ⟼ A∧B
4.3. ADJUNCTIONS 71

Pre-composing with a tuple (exercise 3.2.1.5), which expresses the naturality of


the hom set bijection in its domain coordinate,
𝑖 ⋅ ⟨𝑓 , 𝑔⟩ = ⟨𝑖 ⋅ 𝑓 , 𝑖 ⋅ 𝑔⟩
allows us to take any derivation pre-composed with a ∧+ rule, copy it and move
it into the hypothetical subderivations. We can view this as a permutation
conversion:

Γ Γ
ℰ ℰ
Γ C C C C
ℰ 𝒟1 𝒟2 𝒟1 𝒟2
C A B Γ A B
∧+ ∧⇄ ∧+
A∧B ⟼ A∧B
Combining this with the special case of local expansion of an identity derivation
yields the general case of local expansion for conjunction.

When the category ℂ has coproducts, the diagonal functor ∆ ∶ ℂ ⟶ ℂ × ℂ also


has a left adjoint, namely the coproduct functor – + – ∶ ℂ × ℂ ⟶ ℂ:
–+– ⊣ ∆
The unit of this adjunction is the ordered pair of insertions and the counit is
the codiagonal map. The internal picture for this adjunction looks like this:

∆(A + B)
∆[𝑓 , 𝑔]
(ι0 , ι1 )(A , B)
⇓ β𝑙
ℂ×ℂ∶ (A , B) ∆X
(𝑓 , 𝑔)

[𝑓 , 𝑔]
ℂ∶ A+B X

∇(X)
𝑓 ∨𝑔
X+X

Recall our interpretations (modulo the distributive law) for the natural deduc-
tion introduction and elimination rules for disjunction in terms of coproducts:
⟦∨+⟧ = (ι0 , ι1 ) and ⟦∨−† ⟧ = [– , –]
The universal property of coproducts is just the universal property of the unit
of this adjunction. Its commuting triangle β𝑙 ,
(ι0 , ι1 ) ⋅ ∆[𝑓 , 𝑔] = (𝑓 , 𝑔)
72 CHAPTER 4. TWO DIMENSIONAL STRUCTURE

expresses the local reduction for disjunction:

A B A B
A 𝒟0 𝒟1 B 𝒟0 𝒟1 A B
∨+0 ∨+1
A∨B C C A∨B C C 𝒟0 𝒟1
∨−† ∨−† ∨>
C C ⟼ C C

Identity expansion for coproducts (lemma 3.3.1.2), which gives us the adjoint
complement of an identity morphism,

id(A + B) = [ι0 , ι1 ]

expresses the local expansion of an identity derivation:

A B
∨+0 ∨+1
A∨B A∨B A∨B
∨< ∨−†
A∨B ⟼ A∨B

Post-composing with a cotuple (lemma 3.3.1.5), which expresses the naturality


of the hom set bijection in its codomain coordinate,

[𝑓 , 𝑔] ⋅ 𝑖 = [𝑓 ⋅ 𝑖 , 𝑔 ⋅ 𝑖]

allows us to take any derivation post-composed with a ∨− rule, copy it and move
it into the hypothetical subderivations. This is the permutation conversion for
disjunction:

A B A B
𝒟0 𝒟1 𝒟0 𝒟1
A∨B C C C C
∨−†
C ℰ ℰ
ℰ A∨B D D
∨⇄ ∨−†
D ⟼ D

Adjoints to a Bang Functor

Recall that the category Cat has terminal objects in the form of singleton cat-
egories, and that in any category with a terminal object we have bang maps.
This implies that for any category ℂ we have a bang functor,
!
ℂ ⟶ 𝟙
A ⟼ ⋆
𝑓 ⟼ id(⋆)
4.3. ADJUNCTIONS 73

When the category ℂ has terminal objects, the functor 1 ∶ 𝟙 ⟶ ℂ picking out
a terminal object is right adjoint to the bang functor:

! ⊣ 1

The counit of this adjunction is (trivially) the identity and the unit is the bang
map. The internal picture for this adjunction looks like this:

1
1(id(⋆))
!(X)

ℂ∶ X 1
!(X)

𝑓 = id(⋆)
𝟙∶ !(X) ⋆
β𝑟 ⇑
id
!(!(X))
!(1)

The triangle in 𝟙 is trivial because id(⋆) is the only arrow in the whole category.
Recall our interpretation for the natural deduction introduction rule for truth
in terms of terminal objects:

⟦⊤+⟧ = !(–)

This fits the pattern we have been describing if we rewrite it as:


𝒟
Γ ⋆
⊤+

But there is only one possible choice for ⟦𝒟⟧, namely, id(⋆).
The derived “elimination rule for truth” informs us of the existence of the mor-
phism id(⋆) in the category 𝟙, which is hardly earth-shattering news. Likewise,
the derived “local reduction for truth” tells us that id(⋆) ⋅ id(⋆) = id(⋆).
Identity expansion for terminal objects (lemma 3.1.1.2), which gives us the ad-
joint complement of an identity morphism,

id(1) = !(1)

expresses the local expansion of an identity derivation:

⊤ ⋆
⊤< ⊤+
⊤ ⟼ ⊤
74 CHAPTER 4. TWO DIMENSIONAL STRUCTURE

Pre-composing with a bang (exercise 3.1.1.4), which is naturality of the hom set
bijection in its domain coordinate,
𝑖⋅! = !
allows us to take any derivation pre-composed with a ⊤+ rule, and “throw it
away” by moving its !-image – i.e. id(⋆) – to the singleton category. We can
view this as a permutation conversion:
Γ

A ⋆ Γ ⋆
⊤+ ⊤⇄ ⊤+
⊤ ⟼ ⊤
Combining this with the special case of local expansion of an identity derivation
yields the general case of local expansion for truth.

When the category ℂ has initial objects, the functor 0 ∶ 𝟙 ⟶ ℂ picking out an
initial object is left adjoint to the bang functor:
0 ⊣ !
The unit of this adjunction is (trivially) the identity and the unit is the cobang
map. The internal picture for this adjunction looks like this:

!(0)
!(¡(X))
id
⇓ β𝑙
𝟙∶ ⋆ !(X)
𝑓 = id(⋆)

¡(X)
ℂ∶ 0 X

¡(X)
0(id(⋆))
0

Again, the triangle in the category 𝟙 is trivial.


Recall our interpretation (modulo the absorption law) for the natural deduction
elimination rule for falsehood in terms of initial objects:
⟦⊥−† ⟧ = ¡(–)
This fits the pattern we have been describing if we rewrite it as:


𝒟
⊥ ⋆
⊥−†
A
4.3. ADJUNCTIONS 75

where again, the only possibility for ⟦𝒟⟧ is id(⋆). The derived “introduction
rule” and “local reduction” for falsehood are as uninformative as the elimination
and local reduction for truth.
Identity expansion for initial objects (lemma 3.1.4.2), which gives us the adjoint
complement of an identity morphism,

id(0) = ¡(0)

expresses the local expansion of an identity derivation:

⊥ ⋆
⊥< ⊥−†
⊥ ⟼ ⊥

Post-composing with a cobang (lemma 3.1.4.4), which is naturality of the hom


set bijection in its codomain coordinate:

¡⋅𝑖 = ¡

allows us to take any derivation post-composed with a ⊥−† rule, and “throw it
away” by moving its !-image – i.e. id(⋆) – to the singleton category. This is the
permutation conversion for falsehood:

⊥ ⋆
⊥−†
A
ℰ ⊥ ⋆
⊥⇄ ⊥−†
B ⟼ B

4.3.4 Context Distributivity Revisited

The context distributivity laws for the positively-presented connectives, the dis-
tributive law and absorption law, are actually both instances of a more general
result about cartesian closed categories and adjoint functors called Frobenius
reciprocity.
Proposition 4.3.4.1 (Frobenius reciprocity) For anti-parallel functors F ∶ ℂ ⟶
𝔻 and G ∶ 𝔻 ⟶ ℂ between cartesian closed categories, if there is an adjunction
F ⊣ G and the right adjoint G preserves exponentials then for objects A ∶ ℂ and
X ∶ 𝔻,
X × F(A) ≅ F(G(X) × A)

The idea is that X is the interpretation of some ambient context and F is the
functor determining some positively-presented connective. Admittedly, the con-
dition that G preserves exponentials seems unmotivated, but when you try to
prove the result, you see that it is exactly what is needed to make it go through.
76 CHAPTER 4. TWO DIMENSIONAL STRUCTURE

Proof. By the Yoneda principle, for an arbitrary Z ∶ 𝔻,

𝔻 (X × F(A) → Z)
≅ [product symmetry]
𝔻 (F(A) × X → Z)
≅ [currying]
𝔻 (F(A) → X ⊃ Z)
≅ [adjoint complement –♭ ]
ℂ (A → G(X ⊃ Z))
≅ [assumption that G preserves exponentials]
ℂ (A → G(X) ⊃ G(Z))
≅ [uncurrying]
ℂ (A × G(X) → G(Z))
≅ [adjoint complement –♯ ]
𝔻 (F(A × G(X)) → Z)
≅ [product symmetry]
𝔻 (F(G(X) × A) → Z)

For example, in the case of the adjunction – + – ⊣ ∆, Frobenius reciprocity tells


us:
X × (+(A , B)) ≅ +(∆(X) × (A , B))
or, in other words:

X × (A + B) ≅ (X × A) + (X × B)

which is the distributive law!


What is really going on here is that there is a natural isomorphism in the functor
category (𝔻 × ℂ) ⊃ 𝔻,

–1 × F(–)
2
≅ 1
F(G(–) 2
× –)
Chapter 5

Dependency

5.1 Indexed Categories

5.1.1 Set Indexed Set Families

Dependency is a phenomenon that occurs throughout mathematics and com-


puter science. One example is full dependent type theory (about which you
are learning in a parallel course). But perhaps more familiar is the idea of an
indexed family of sets.
In our discussion of the axiom of choice we saw how an ordinary function (in
Set) can be used to create a set-indexed family of sets, or indexed set: if E and
B are sets then a function 𝑓 ∶ E ⟶ B gives rise to a function 𝑓 ∗ ∶ B ⟶ ℘(E),
which we can think of as 𝑓 ∗ ∶ B ⟶ Set by the inclusion ℘(E) ↪ Set.

5.1.2 Catgory Indexed Set Families

We can generalize this setup by using an arbitrary category ℂ rather than a


discrete one B to index a family of sets.
We can define a contravariant functor P ∶ ℂ° ⟶ Set. The contravariance is not
essential (after all, every category is the opposite of some other category) but, as
we’ll soon see, gives the right variance for our intended use of this construction.
Definition 5.1.2.1 (presheaf) A presheaf 1 is a contravariant functor from a
category to the category of sets:

P ∶ ℂ° ⟶ Set
1 The name “presheaf” belies the importance that such functors play in category theory,
which is a shame.

77
78 CHAPTER 5. DEPENDENCY

We can think of a presheaf as a family of sets indexed by a category. For each


object X ∶ ℂ we have the set P(X) and for each arrow 𝑓 ∶ ℂ (X → Y) we have a
function P(𝑓) ∶ P(Y) ⟶ P(X). When the presheaf P is known or irrelevant, it
is customary to write “𝑓 ∗ ” for P(𝑓).

P(Z) P(Y) P(X)


𝑔∗ 𝑓∗

Set ∶

ℂ∶ Z Y X
𝑔 𝑓

Perhaps the most important kind of presheaf is a representable presheaf , which,


recall, is the contravariant functor represented by an object of ℂ:

ℂ (– → Z) ∶ ℂ° ⟶ Set

In this case, the set corresponding to each object in ℂ is the set of ℂ-arrows
from that object to the representative object.

5.1.3 Catgory Indexed Category Families

We can generalize this setup even more: instead of a family of sets indexed by
a category, we can create a family of categories indexed by a category.
Definition 5.1.3.1 (indexed category) An indexed category is a contravariant
functor from a category to the 2-category of (small) categories:

P ∶ ℂ° ⟶ Cat

The category ℂ is called the base category of the indexed category P, for an
object X ∶ ℂ, the category P(X) is called the fiber of P over X, and for arrow
𝑓 ∶ ℂ (X → Y) the functor 𝑓 ∗ ∶ P(Y) ⟶ P(X) is called the reindexing functor
induced by 𝑓.

We can also do a version of this construction in which the codomain of the


functor P is an arbitrary 2-category of categories, not necessarily Cat. In par-
ticular, we will be interested in indexed bicartesian closed categories, which
are functors P ∶ ℂ° ⟶ BCC.
5.2. INTERPRETATION OF PREDICATE LOGIC 79

5.2 Interpretation of Predicate Logic

5.2.1 Interpretation of Terms

In order to move beyond propositional logic, we need to be able to interpret


predicates over a term language. Our term language will be typed, but because
our focus is the logic, we will not introduce any type formers. We explain the
interpretation of the term language only briefly, as it is not the focus of this
section.
We begin with an arbitrary collection of atomic types and interpret them as
objects of a cartesian category ℂ. For type X,

⟦X⟧ ∶ ℂ

A typing context Φ is a list of distinct typed variables:

Φ = 𝑥1 ∶ X 1 , ⋯ , 𝑥 𝑛 ∶ X 𝑛

We use the cartesian structure of ℂ to interpret typing contexts in the same way
we did for propositional contexts:

⟦∅⟧ ≔ 1
⟦Φ , 𝑥 ∶ X⟧ ≔ ⟦Φ⟧ × ⟦X⟧

The idea is that the names of the variables are immaterial, they merely act as
projections out of a product.
Weakening of typing contexts lets us forget about some of the variables in scope.
by the structural rule of context exchange, it suffices to consider just the case
of a single omission:
𝑥̂ ∶ Φ , 𝑥 ∶ X ⟼ Φ
Its interpretation is the same as that of propositional context weakening, namely
a projection, or up to isomorphism,

⟦𝑥⟧̂ ≔ id × ! ∶ ⟦Φ⟧ × ⟦X⟧ ⟶ ⟦Φ⟧

Next, we consider an arbitrary collection of typed function symbols, each of


the form,
𝑓 ∈ ℱ(Y1 , ⋯ , Y𝑛 ; X)
where X and each Y𝑖 is a type. The idea is that when the function symbol 𝑓
is applied to terms of types Y⃗ the result will be a term of type X. We follow
the usual convention that a constant symbol 𝑐 of type X is a nullary function
symbol,
𝑐 ∈ ℱ(∅ ; X)
80 CHAPTER 5. DEPENDENCY

We interpret function symbols as morphisms from the product of the interpre-


tations of their argument types to that of their result type:

⟦𝑓 ∈ ℱ(Y1 , ⋯ , Y𝑛 ; X)⟧ ∶ ⟦Y1 ⟧ × ⋯ × ⟦Y𝑛 ⟧ ⟶ ⟦X⟧

Open terms, or terms in context are built inductively from the function sym-
bols. We express that term 𝑡 has type X in typing context Φ as “Φ | 𝑡 ∶ X”.
In order for such a term in context to be valid, the context Φ must contain at
least the typed free variables that occur in 𝑡. However, the context Φ may also
contain additional dummy variables that do not occur free in 𝑡.
Our inductive interpretation of terms follows their inductive construction
from the function symbols:
lifted variable: for variable 𝑥𝑖 ∈ Φ,

π𝑖
⟦Φ | 𝑥𝑖 ∶ X𝑖 ⟧ ≔ ⟦Φ⟧ ⟦X⟧

applied function symbol: for function symbol 𝑓 ∈ ℱ(Y1 , ⋯ , Y𝑛 ; X) and


terms Φ | 𝑡1 ∶ Y1 , ⋯ , 𝑡𝑛 ∶ Y𝑛 ,

⟨⟦𝑡1 ⟧ , ⋯ , ⟦𝑡𝑛 ⟧⟩ ⟦𝑓⟧


⟦Φ | 𝑓(𝑡1 ,⋯,𝑡𝑛 ) ∶ X⟧ ≔ ⟦Φ⟧ ⟦Y1 ⟧ × ⋯ × ⟦Y𝑛 ⟧ ⟦X⟧

context extension: for term Φ | 𝑡 ∶ X and variable 𝑦 ∉ Φ,

⟦𝑦⟧̂ ⟦𝑡⟧
⟦Φ,𝑦 ∶ Y | 𝑡 ∶ X⟧ ≔ ⟦Φ⟧ × ⟦Y⟧ ⟦Φ⟧ ⟦X⟧

substitution: for terms Φ , 𝑦 ∶ Y | 𝑡 ∶ X and Φ | 𝑠 ∶ Y,

⟨⟦Φ⟧ , ⟦𝑠⟧⟩ ⟦𝑡⟧


⟦Φ | 𝑡[𝑦↦𝑠] ∶ X⟧ ≔ ⟦Φ⟧ ⟦Φ⟧ × ⟦Y⟧ ⟦X⟧

A substitution of just one term for a variable is a single substitution. We call


the precomposed arrow in the definition of a term under single substitution the
interpretation of the single substitution:

⟦ [𝑦↦𝑠] ⟧ ≔ ⟨id , ⟦𝑠⟧⟩

The reason that it tuples the interpretation of the substituting term with that
of its context is that in the language, applying such a substitution to a term
leaves undisturbed any other variables that may occur in the term.
5.2. INTERPRETATION OF PREDICATE LOGIC 81

5.2.2 Interpretation of Predicates

Interpreting Propositions

In order to define predicates we begin with a collection of typed relation sym-


bols, each of the form,
R ∈ ℛ(X1 , ⋯ , X𝑛 )
where each X𝑖 is a type. The idea is that when the relation symbol R is applied
to terms of types X⃗ the result is an atomic proposition, or predicate.
We will need to interpret not only closed predicates (those without free term
variables), but open ones as well. Thus predicates are dependent on their free
term variables. This suggests that we interpret predicates in an indexed category
over a base category interpreting their typing contexts and terms.
Given an interpretation of the term language in a cartesian category ℂ, we
interpret relation symbols in a ℂ-indexed bicartesian closed category P ∶ ℂ° ⟶
BCC as objects in the fibers over the product of the interpretations of their
argument types:
⟦R ∈ ℛ(X1 , ⋯ , X𝑛 )⟧ ∶ P(⟦X1 ⟧ × ⋯ × ⟦X𝑛 ⟧)

As in the case of terms, we need to keep track of the typing context in which a
predicate (and in general, a proposition, which may contain connectives) occurs.
Thus we speak of propositions in context and write “Φ | A prop” to indicate
that A is a proposition, all of whose free variables are contained in the typing
context Φ.
Our inductive interpretation of predicates follows their inductive construc-
tion from the relation symbols:
applied relation symbol: for relation symbol R ∈ ℛ(Y1 , ⋯ , Y𝑛 ) and terms
Φ | 𝑡𝑖 ∶ Y 𝑖 ,
⟦Φ | R(𝑡1 , ⋯ , 𝑡𝑛 ) prop⟧ ≔ ⟨⟦𝑡1 ⟧ , ⋯ , ⟦𝑡𝑛 ⟧⟩∗ (⟦R⟧) ∶ P(⟦Φ⟧)

context extension: for predicate Φ | A prop and variable 𝑦 ∉ Φ,

⟦Φ , 𝑦 ∶ Y | A prop⟧ ≔ ⟦𝑦⟧̂ ∗ (⟦A⟧) ∶ P(⟦Φ , 𝑦 ∶ Y⟧)

substitution: for predicate Φ , 𝑦 ∶ Y | A prop and term Φ | 𝑠 ∶ Y,

⟦Φ | A[𝑦↦𝑠] prop⟧ ≔ ⟦ [𝑦↦𝑠] ⟧∗ (⟦A⟧) ∶ P(⟦Φ⟧)

Note that in each case we simply reindex by the same morphism with which we
precomposed in the inductive interpretation of terms.
Finally, in order to interpret full predicate logic, we use the interpretations of
the connectives that we presented earlier.
82 CHAPTER 5. DEPENDENCY

Remark 5.2.2.1 (strictness) Because our interpretation is in an indexed bi-


cartesian closed category, we know that the reindexing functors will respect the
bicartesian closed structure of the fibers (e.g. send products to products) This
sounds nice and tidy, but there is a subtle issue having to do with strictness.

Consider a term Φ | 𝑡 ∶ X and proposition Φ , 𝑥 ∶ X | A ∧ B Prop. The object


⟦ [𝑥↦𝑡] ⟧∗ (⟦A ∧ B⟧) will indeed be a cartesian product of ⟦ [𝑥↦𝑡] ⟧∗ (⟦A⟧) and
⟦ [𝑥↦𝑡] ⟧∗ (⟦B⟧) in P(⟦Φ⟧), but there is no a priori reason to assume that it will
be the same cartesian product as ⟦A[𝑥↦𝑡] ∧ B[𝑥↦𝑡]⟧ even though (A ∧ B)[𝑥↦𝑡]
and A[𝑥↦𝑡] ∧ B[𝑥↦𝑡] are usually considered to be the same proposition in the
language.

This is an issue known as soundness for syntax, and there are established tech-
niques for dealing with it, but we will not have time to consider them in this
course.

5.3 Interpretation of Quantification

Bill Lawvere observed that generalized quantifiers could be interpreted as ad-


joints to reindexing functors, which led to his hyperdoctrine interpretation of
first-order logic. In the familiar case, where we quantify only over bound vari-
ables rather than more general bound terms, the interpretations of the quanti-
fiers ∀𝑥 and ∃𝑥 are respectively right and left adjoints to the reindexing functors
determined by the context weakening 𝑥:̂

P(⟦Φ⟧) ⟦∃𝑥⟧ P(⟦Φ , 𝑥 ∶ X⟧)


BCC ∶ ⟦𝑥⟧̂ ∗


P
⟦∀𝑥⟧

ℂ∶ ⟦Φ⟧ ⟦Φ , 𝑥 ∶ X⟧
⟦𝑥⟧̂
5.3. INTERPRETATION OF QUANTIFICATION 83

5.3.1 Universal Quantification

Suppressing the semantic brackets for readability, the internal picture of this
adjunction looks like this:

∀𝑥 ∶ X . 𝑥̂∗ Γ
∀𝑥 ∶ X . 𝒟
η(Γ)

P(Φ) ∶ Γ ∀𝑥 ∶ X . A
𝒟♭

𝒟
P(Φ , 𝑥 ∶ X) ∶ 𝑥̂∗ Γ A
β𝑟 ⇑
ε(A)
𝑥̂∗ (𝒟♭ )
𝑥̂∗ (∀𝑥 ∶ X . A)

In this adjunction, the adjoint complement operation –♭ takes a derivation from


assumptions in which a given variable does not occur free to a derivation of the
universal quantification over that variable of the goal:
–♭
𝒟 ∶ 𝑥∗̂ Γ ⟶ A ⟼ 𝒟♭ ∶ Γ ⟶ ∀𝑥 ∶ X . A

We can express this with the following inference rule of natural deduction:

𝑥̂∗ Γ

𝑥̂ Γ 𝒟
𝒟 Γ A
–♭ ∀+†
A ⟼ ∀𝑥 ∶ X . A

This is our derived introduction rule for universal quantification. It is equivalent


to the Gentzen rule with the context variable 𝑥 acting as the private variable of
the hypothetical subderivation. Observe that the side condition of the Gentzen
rule is automatically enforced because the rest of the derivation is in the category
P(Φ), where the variable 𝑥 is not in scope.
The counit of this adjunction when written as an inference rule becomes our
derived elimination rule:
𝑥∗̂ (∀𝑥 ∶ X . A)
ε ∀−†
A ⟼ A

The corresponding Gentzen rule allows us to conclude any instance of the for-
mula A in which a type-appropriate term 𝑡 is substituted for the variable 𝑥 and
any remaining free variables of A are left undisturbed. Categorically, this corre-
sponds to reindexing by the interpretation of the single substitution induced by
84 CHAPTER 5. DEPENDENCY

the term in context Φ | 𝑡 ∶ X. Thus, the Gentzen elimination rule corresponds


to (ε(A))[𝑥↦𝑡], as shown:

∀𝑥 ∶ X . A 𝑥̂∗ (∀𝑥 ∶ X . A) ∀𝑥 ∶ X . A

ε(A) (ε(A))[𝑥↦𝑡]

A A[𝑥↦𝑡]

𝑥̂ [𝑥↦𝑡]
Φ Φ,𝑥∶X Φ

id

The Gentzen rule gives us a stronger result by yielding a derivation in the orig-
inal typing context Φ. But it also makes a stronger demand by requiring us to
immediately choose a term of type X in that context to act as the represen-
tative of its type under consideration. The adjoint-theoretic rule takes a more
relaxed approach. It gives us the option, but not the obligation, of supplying a
representative term at some point in the future, while in the meantime choosing
the context variable 𝑥 to act as a generic representative.
To wit, the context variable 𝑥 is a term of type X, but in the extended context
Φ , 𝑥 ∶ X, and not in the original context Φ. At any point we may choose
a representative term Φ | 𝑡 ∶ X to use in place of this context variable by
performing the substitution [𝑥↦𝑡], but until we do so our derivation is valid only
in the extended context, a world in which a term of the specified type exists by
fiat, in the form of a context variable. The derived rule has the advantage that
we need not decide which term 𝑡 to substitute for 𝑥 in A at the time we apply
the rule. This has useful applications to the study of metavariables and proof
search.
The commuting triangle of the universal property of the counit,
β𝑟
𝑥∗̂ (𝒟♭ ) ⋅ ε(A) = 𝒟
expresses the local reduction for universal quantification in the category P(Φ,𝑥 ∶
X):
𝑥∗̂ Γ
𝒟
𝑥∗̂ Γ A 𝑥∗̂ Γ
𝑥∗̂ (∀+† )
𝑥∗̂ (∀𝑥 ∶ X . A) 𝒟
∀−† ∀>
A ⟼ A
We recover the Gentzen version by applying a single substitution for 𝑥 to both
sides.
5.3. INTERPRETATION OF QUANTIFICATION 85

The equation for the adjoint complement of a counit component,

id(∀𝑥 ∶ X . –) = (ε –)♭

expresses the local expansion of an identity derivation:

𝑥∗̂ (∀𝑥 ∶ X . A)
∀−†
∀𝑥 ∶ X . A A †
∀< ∀+
∀𝑥 ∶ X . A ⟼ ∀𝑥 ∶ X . A

We get the local expansion for an arbitrary derivation by precomposing it and


applying the permutation conversion, which is the naturality of the hom set
bijection of this adjunction in the domain coordinate,

ℰ ⋅ 𝒟♭ = (𝑥∗̂ ℰ ⋅ 𝒟)♭

or,
𝑥∗̂ Γ
𝑥∗̂ ℰ
Γ 𝑥∗̂ C 𝑥∗̂ C
ℰ 𝒟 𝒟
C A Γ A
∀+† ∀⇄ ∀+†
∀𝑥 ∶ X . A ⟼ ∀𝑥 ∶ X . A

5.3.2 Existential Quantification

Again suppressing the semantic brackets for readability, the internal picture of
this adjunction looks like this:

𝑥̂∗ (∃𝑥 ∶ X . A)
𝑥̂∗ (𝒟♯ )
η(A)
⇓ β𝑙
P(Φ , 𝑥 ∶ X) ∶ A 𝑥̂∗ B
𝒟

𝒟♯
P(Φ) ∶ ∃𝑥 ∶ X . A B

ε(B)
∃𝑥 ∶ X . 𝒟
∃𝑥 ∶ X . 𝑥̂∗ B

In this adjunction, the adjoint complement operation –♯ takes a derivation with


a goal in which a given variable does not occur free to a derivation from the
86 CHAPTER 5. DEPENDENCY

existential quantification over that variable of the assumption:

–♯
𝒟 ∶ A ⟶ 𝑥∗̂ B ⟼ 𝒟♯ ∶ ∃𝑥 ∶ X . A ⟶ B

We can express this with the following inference rule of natural deduction:

A
A 𝒟
𝒟 ∃𝑥 ∶ X . A 𝑥∗̂ B
–♯ ∃−†
𝑥∗̂ B ⟼ B

This is our derived elimination rule for existential quantification. As with the
derived rule for universal introduction, the context variable 𝑥 plays the role
of the private variable and Gentzen’s side condition is automatically enforced
because the rest of the derivation is in the category P(Φ), where 𝑥 is not in
scope.

As with the other positively presented connectives (falsehood and disjunction),


this rule does not directly encode compatibility with ambient propositional con-
texts. For that, we need the instance of Frobenius reciprocity,

𝑓𝑟𝑜𝑏 ∶ Γ × (∃𝑥 ∶ X . A) ≅ ∃𝑥 ∶ X . 𝑥∗̂ (Γ) × A

Indeed, this is the motivating case for that concept. Precomposing 𝑓𝑟𝑜𝑏 with
the derived rule yields Gentzen’s rule:

FIXME

Γ
ℰ 𝑥∗̂ Γ A
Γ ∃𝑥 ∶ X . A 𝒟
𝑓𝑟𝑜𝑏
∃𝑥 ∶ X . 𝑥∗̂ Γ ∧ A 𝑥∗̂ B
∃−†
B

The unit of this adjunction when written as an inference rule becomes our
derived introduction rule:

A
η
∗ ∃+†
A ⟼ 𝑥̂ (∃𝑥 ∶ X . A)

Dual to the case of ∀−† , we recover the Gentzen rule by reindexing along a
5.3. INTERPRETATION OF QUANTIFICATION 87

single substitution:

A A[𝑥↦𝑡]

η(A) (η(A))[𝑥↦𝑡]

∃𝑥 ∶ X . A 𝑥̂∗ (∃𝑥 ∶ X . A) ∃𝑥 ∶ X . A

𝑥̂ [𝑥↦𝑡]
Φ Φ,𝑥∶X Φ

id

Like ∀−† , this rule is more lenient than Gentzen’s because it does not require
us to immediately produce a witness at the time we apply the rule, but rather
allows us to temporarily use a context variable as a generic witness. This has
the effect of leaving 𝑥 as a free variable (i.e. metavariable or logic variable) to
be instantiated later, for example through unification. But it also means that
in order to obtain a derivation in the world in which we started, the typing
context Φ, we must eventually produce a witness term Φ | 𝑡 ∶ X to substitute
for the context variable 𝑥. Otherwise, we have a derivation that is valid only in
a world where such a term is assumed to exist.
The importance of knowing which fiber we are in is illustrated by the attempt
to prove the existence of a magical fairy from the well-known fact that all fairies
are magical:
Example 5.3.2.1 (magical fairies) If we allow F to represent the type of fairies
and M the predicate that 𝑥 is magical, then we may derive 𝑥 ∶ F | ∀𝑥 ∶ F . M ⊢
∃𝑥 ∶ F . M as shown.

∀𝑥 ∶ F . M 𝑥̂∗ (∀𝑥 ∶ F . M) ∀𝑥 ∶ F . M

ε∀𝑥 (M)

M (ε∀𝑥 (M) ⋅ η∃𝑥 (M))[𝑥↦?]

η∃𝑥 (M)

∃𝑥 ∶ F . M 𝑥̂∗ (∃𝑥 ∶ F . M) ∃𝑥 ∶ F . M

𝑥̂ [𝑥↦?]
∅ 𝑥∶F ∅

id
88 CHAPTER 5. DEPENDENCY

Then the fulfillment of childhood dreams awaits us in our own world – just as
soon as we are able to produce any fairy whatsoever.
The commuting triangle of the universal property of the unit,
β𝑙
η(A) ⋅ 𝑥∗̂ (𝒟♯ ) = 𝒟
expresses the local reduction for existential quantification in the category P(Φ ,
𝑥 ∶ X):
A
A 𝒟 A
∗ ∃+†
𝑥̂ (∃𝑥 ∶ X . A) 𝑥∗̂ B 𝒟
𝑥∗̂ (∃−† ) ∃>
𝑥∗̂ B ⟼ 𝑥∗̂ B
We recover the Gentzen version by precomposing 𝑓𝑟𝑜𝑏 and applying a single
substitution for 𝑥 to both sides.
The equation for the adjoint complement of a unit component,
id(∃𝑥 ∶ X . –) = (η –)♯
expresses the local expansion of an identity derivation:

A
∗ ∃+†
∃𝑥 ∶ X . A 𝑥̂ (∃𝑥 ∶ X . A)
∃< ∃−†
∃𝑥 ∶ X . A ⟼ ∃𝑥 ∶ X . A

The naturality of the hom set bijection of this adjunction in the codomain
coordinate,
𝒟♯ ⋅ ℰ = (𝒟 ⋅ 𝑥∗̂ ℰ)♯
or
[A] [A]
𝒟 𝒟
∃𝑥 ∶ X . A 𝑥∗̂ B 𝑥∗̂ B
∃−† 𝑥∗̂ ℰ
B
ℰ ∃𝑥 ∶ X . A 𝑥∗̂ C
∃⇄ ∃−†
C ⟼ C
is the permutation conversion for existential quantification.

5.3.3 Substitution Compatibility

In logic, the quantifiers–like the propositional connectives–are compatible with


(capture-avoiding) substitution:
(∀𝑥 ∶ X . A)[𝑦↦𝑡] = ∀𝑥 ∶ X . (A[𝑦↦𝑡])
(∃𝑥 ∶ X . A)[𝑦↦𝑡] = ∃𝑥 ∶ X . (A[𝑦↦𝑡])
5.3. INTERPRETATION OF QUANTIFICATION 89

We need to ensure that this property holds in our categorical semantics. Unlike
the case of context distributivity, there is nothing special about bicartesian
closed categories that guarantees this will be the case.
First, observe that the interpretation of a single substitution commutes with
that of a single omission:

⟦[𝑦↦𝑡]⟧
ℂ∶ ⟦Φ , 𝑥 ∶ X⟧ ⟦Φ , 𝑥 ∶ X , 𝑦 ∶ Y⟧

⟦𝑥⟧̂ ⟦𝑥⟧̂

⟦Φ⟧ ⟦Φ , 𝑦 ∶ Y⟧
⟦[𝑦↦𝑡]⟧

This is a consequence of the fact that the interpretation of a single substitution


in an extended context is the product of the single substitution and the context
extension:
⟦Φ , 𝑦 ∶ Y , 𝑥 ∶ X⟧

⟦[𝑦↦𝑡]⟧ × ⟦X⟧ ⟦Φ⟧ × σ

⟦Φ , 𝑥 ∶ X⟧ ⟦Φ , 𝑥 ∶ X , 𝑦 ∶ Y⟧
⟦[𝑦↦𝑡]⟧

together with the definition of a product of arrows.


This gives us a commuting square of the corresponding reindexing functors in
BCC:
⟦[𝑦↦𝑡]⟧∗
BCC ∶ P(⟦Φ , 𝑥 ∶ X⟧) P(⟦Φ , 𝑥 ∶ X , 𝑦 ∶ Y⟧)

⟦𝑥⟧̂ ∗ ⟦𝑥⟧̂ ∗ (5.1)

P(⟦Φ⟧) P(⟦Φ , 𝑦 ∶ Y⟧)


⟦[𝑦↦𝑡]⟧∗

Recall that ⟦∃𝑥⟧ and ⟦∀𝑥⟧ are adjoints to ⟦𝑥⟧̂ ∗ . So it would suffice if we had
a condition that guaranteed that whenever the square above commutes, for
∈ {∀ , ∃}, this one does as well:
Q

⟦[𝑦↦𝑡]⟧∗
BCC ∶ P(⟦Φ , 𝑥 ∶ X⟧) P(⟦Φ , 𝑥 ∶ X , 𝑦 ∶ Y⟧)

⟦ 𝑥⟧
Q
⟦ 𝑥⟧
Q (5.2)

P(⟦Φ⟧) P(⟦Φ , 𝑦 ∶ Y⟧)


⟦[𝑦↦𝑡]⟧∗
90 CHAPTER 5. DEPENDENCY

Here’s how we can arrange it.


Lemma 5.3.3.1 Given adjunctions F1 ⊣ G1 and F2 ⊣ G2 and functors A and
B as shown (without assuming that anything commutes):

A
𝔸1 𝔸2

G1 ⊢ F1 G2 ⊢ F2

𝔹1 𝔹2
B

there is a bijection between sets of natural transformations:

𝔸1 ⊃ 𝔹2 (A ⋅ F2 → F1 ⋅ B)
ζ
𝔹1 ⊃ 𝔸2 (G1 ⋅ A → B ⋅ G2 )

Proof. Such a bijection is given by pasting with the respective unit and counit
of the two adjunctions:

A A id
𝔸1 𝔸2 𝔸1 𝔸2 𝔸2
ζ
F2 G1 ⇓ η2
⇓ϕ ⟼ F1 ⇓ϕ F2
F1 ⇓ ε1 G2
𝔹1 𝔹2 𝔹1 𝔹1 𝔹2
B id B

and

A id A
𝔸1 𝔸2 𝔸1 𝔸1 𝔸2
ζ−1
G1 ⇓ η1 F2
⇓ψ ⟼ G1 ⇓ψ G2
G2 F1 ⇓ ε2
𝔹1 𝔹2 𝔹1 𝔹2 𝔹2
B B id

or equivalently, as string diagrams:

𝔸2 𝔸1 𝔸2
A F2 A η2
G1
ζ F2
𝔸1 ϕ 𝔹2 ⟼ ϕ
F1
ε1 G2
F1 B B
𝔹1 𝔹1 𝔹2
5.3. INTERPRETATION OF QUANTIFICATION 91

and

𝔸1 𝔸1 𝔸2
G1 A η1 A
F2
ζ−1 G1
𝔹1 ψ 𝔸2 ⟼ ψ
G2
F1 ε2
B G2 B
𝔹2 𝔹1 𝔹2

In this form, it’s easy to see how the zigzag laws ensure that going back and
forth in either order amounts to the identity.
Definition 5.3.3.2 (mate) Natural transformations related by the bijection ζ
are each called the other’s mate. If we need to be more specific, we call φ the
left mate of ψ and ψ the right mate of φ, after the adjoint functors involved.
Definition 5.3.3.3 (Beck-Chevalley condition) The Beck-Chevalley condi-
tion is the requirement that the mate of a natural isomorphism is itself a natural
isomorphism.
So in order to ensure that all squares of the form 5.2 commute (at least up
to isomorphism), it suffices to require that the Beck-Chevaley condition hold
in cases where one of the adjoint functors in each adjunction is the reindexing
functor determined by a projection. Then the natural isomorphism in square 5.2
will be the mate of the identity in square 5.1, and its component at a proposition
A will be the isomorphisms between ( 𝑥 ∶ X . A)[𝑦↦𝑡] and 𝑥 ∶ X . (A[𝑦↦𝑡]).
Q Q

You might also like