Вы находитесь на странице: 1из 48

# An Introduction to

Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
An Introduction to Category Theory
and Categorical Logic
Wolfgang Jeltsch
TT

U K uberneetika Instituut
Teooriaseminar
April 19 and 26, 2012
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Category theory basics
Products, coproducts, and exponentials
Categorical logic
Functors and natural transformations
Monoidal categories and monoidal functors
References
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Category theory basics
Products, coproducts, and exponentials
Categorical logic
Functors and natural transformations
Monoidal categories and monoidal functors
References
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
From set theory to universal algebra

sets

vector spaces

## homomorphisms from such algebras

to other such algebras

## identity functions are homomorphisms

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Beyond universal algebra

## topological space is a set X and a closure operator

cl : T(X) T(X)
that fullls certain axioms

## continuous function from (X, cl) to (X

, cl

)
is a function f : X X

with
f (cl(A)) cl

(f (A))

## will t into the categorical framework

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
No elements anymore

## revision control system darcs:

repository states

## more about a categorical approach to darcs in [Swierstra]

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Categories

components of a category:

a class of objects

## class of morphisms, each having a unique domain

and a unique codomain, which are objects

composition of morphisms:
f : A B g : B C
gf : A C

identity morphisms:
id
A
: A A

## axioms that have to hold:

composition is associative

## classes of objects and morphism are not necessarily sets:

allows categories of sets, vector spaces, etc.

composition is partial:
codomain and domain must match

## above constructions lead to categories Set, Vec, etc.

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Duality

## changing the argument order of composition

opposite category (
op
for every category (:

objects of (
op
are the ones of (

morphisms f : A B of (
op
are the morphism
f : B A of (

compositions gf in (
op
are the compositions fg in (

identities in (
op
are the same as in (

consequences:

## for every categorical notion N, there is a dual notion N

op
such that something is an N
op
in ( if it is an N in (
op

## for every theorem, there is a dual theorem that refers

to the dual notions
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Products of categories

## product category ( T for any two categories ( and T:

objects
(A, B)
where A is an object of (, and B is an object of T

morphisms
(f , g) : (A, B) (A

, B

)
where f : A A

and g : B B

(f

, g

)(f , g) = (f

f , g

g)
id
(A,B)
= (id
A
, id
B
)

## exactly one morphism (the identity of that object)

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Categories and elements

of categories

## furthermore, some concepts that seem to require

the notion of element actually do not
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Injectivity
Denition (Injectivity)
A function f : A B is injective if and only if
x
1
, x
2
A . f (x
1
) = f (x
2
) x
1
= x
2
.
Theorem
A function f : A B is injective if and only if
C . g
1
, g
2
: C A . fg
1
= fg
2
g
1
= g
2
.

## does not mention elements, but only sets and functions

(point-free style)

## leads to the notion of monomorphism

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Surjectivity
Denition (Surjectivity)
A function f : A B is surjective if and only if
y B . x A . f (x) = y .
Theorem
A function f : A B is surjective if and only if
C . g
1
, g
2
: B C . g
1
f = g
2
f g
1
= g
2
.

of epimorphism

## point-free style makes it clear that monomorphism

and epimorphism (injectivity and surjectivity) are duals
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Isomorphisms

generalization of bijections

morphism f : A B is an isomorphism
if there is an f
1
: B A such that
f
1
f = id
A

1
= id
B

## objects A and B are isomorphic (A

= B)
if there exists an isomorphism f : A B
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Category theory basics
Products, coproducts, and exponentials
Categorical logic
Functors and natural transformations
Monoidal categories and monoidal functors
References
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Cartesian products

pair construction:
x A y B
(x, y) A B

pair destruction:

1
: A B A
2
: A B B

## construction can be made point-free:

f : C A g : C B
f , g : C A B
where
z C . f , g(z) = (f (z), g(z))
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Products

## a product of A and B is an object A B together

with morphisms

1
: A B A
2
: A B B
(called projections) for which the following holds:

f : C A g : C B
f , g : C A B

1
f , g = f
2
f , g = g

## products of two specic objects are unique

up to isomorphism
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Coproducts

duals of products

## a coproduct of A and B is an object A + B together

with morphisms

1
: A A + B
2
: B A + B
(called injections) for which the following holds:

## for every object C, we have

f : A C g : B C
[f , g] : A + B C

[f , g]
1
= f [f , g]
2
= g

## coproducts of two specic objects are unique

up to isomorphism
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Terminal and initial objects

## 1 is a terminal object if there is a unique morphism

! : C 1
for every object C

## 0 is an initial object if there is a unique morphism

? : 0 C
for every object C

## if terminal object exists, A 1 and 1 A exist

for every object A, and we have
A 1

= A

= 1 A

## analogously for initial object

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Function spaces

## for sets A and B, we have

B
A
= f [ f : A B

Currying:
f : C A B

f
: C B
A

function application:
: B
A
A B
where
(f , x) = f (x)
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Exponentials

## an exponential of A and B is an object B

A
together
with a morphism
: B
A
A B
for which the following holds:

f : C A B

f
: C B
A

f

1
,
2
= f

the morphism
f
is unique

## exponentials of two specic objects are unique

up to isomorphism
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Cartesian closed categories and beyond
Denition (Cartesian closed category)
A category is a cartesian closed category (CCC) if it has
all (binary) products, a terminal object, and all exponentials.
Denition (Bicartesian closed category)
A category is a bicartesian closed category (BCCC),
sometimes called cocartesian closed category (CCCC),
if it is a CCC and has all (binary) coproducts
and an initial object.
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Category theory basics
Products, coproducts, and exponentials
Categorical logic
Functors and natural transformations
Monoidal categories and monoidal functors
References
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Categorical logic basics

general idea:

## if objects A and B model propositions and ,

morphisms f : A B model proofs of

## even linear logic can be modeled by extended BCCCs

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Products and conjunctions

models :

## projections prove conjunction elimination:

1 models :

! proves truth:

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Coproducts and disjunctions

+ models :

0 models :

## ? proves ex falso quodlibet:

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Exponentials and implications

exponentiation models :

## proves implication elimination:

( )
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Category theory basics
Products, coproducts, and exponentials
Categorical logic
Functors and natural transformations
Monoidal categories and monoidal functors
References
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Functors

## structure-preserving maps between categories

(category homomorphisms)

## notation for application of these maps

uses juxtaposition of functor and argument:

axioms:

f : A B
Ff : FA FB

## compatibility with composition:

F(gf ) = (Fg)(Ff )

## compatibility with identities:

Fid
A
= id
FA
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Functor examples

TA = M [ M A

## morphism map turns functions into elementwise

applications of them:
(Tf )(M) = f (x) [ x M

## morphism map turns functions into elementwise

applications of them

1
(A, B) = A
2
(A, B) = B

## morphism maps turn pairs of morphisms into morphisms:

1
(f , g) = f
2
(f , g) = g
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Functor intuitions

container intuition:

of containers

## morphism map turns functions into elementwise

applications of them

eect intuition:

## object map turns types/sets of results into types/sets

of eectful computations

## morphism map turns functions into functions

that append the former functions to eectful
computations

## sets denote nondeterministic computations

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Category of small categories

composition GF : ( c of functors F : ( T
and G : T c:

## morphism map is composition of morphism maps

of F and G

identity functor Id : ( (:

## set theory in use might not allow for the class

of all categories

## morhpism classes are sets

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Natural transformations

## natural transformation from functor F to functor G

is an indexed family of morphisms

A
: FA GA ,
one for each object A

## compatibility with morphism maps:

B
(Ff ) = (Gf )
A
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Functor categories

## pointwise identities are natural transformations

functor category:

## objects are all functors from a certain source

to a certain target category

from F to G

## compositions and identities constructed pointwise

natural isomorphisms:

## are exactly those natural transformations

that consist only of isomorphisms
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Revisiting products and coproducts

products:

## is a functor from ( ( to ( with

f g = f
1
, g
2

1
and
2
are natural transformations:

1
:
1

2
:
2

coproducts:

## + is a functor from ( ( to ( with

f + g = [
1
f ,
2
g]

1
and
2
are natural transformations:

1
:
1
+
2
:
2
+
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Revisiting exponentials

exponentiation is a functor E : (
op
( ( with
g
f
=
g(id
B
A
f )

is a natural transformation
: E
1

2
,
where E
1
is the functor with
(E
1
)A = EA
1
A
and
(E
1
)f = Ef
1
f
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Category theory basics
Products, coproducts, and exponentials
Categorical logic
Functors and natural transformations
Monoidal categories and monoidal functors
References
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Monoidal categories

## categories ( that have the following additional structure:

a functor
: ( ( ( ,
called the tensor product

## a natural isomorphism establishing associativity of :

A,B,C
: (A B) C A (B C)

## two natural isomorphisms and establishing the fact

that I is a left and right unit of :

A
: I A A
A
: A I A

axiom:
For any objects A and B, all morphisms from A to B
that are built solely from , , , and are equal.

## three dedicated equalities actually enough, since the rest

follows from Mac Lanes coherence theorem
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Monoidal functors

## monoidal functor F from monoidal category ((, , I )

to monoidal category ((

, I

## ) consists of the following:

a functor from ( to (

(also named F)

coherence maps:
m
A,B
: FA

FB F(A B)
n : I

FI

with , , and

## comonoidal functor is dual of monoidal functor

(coherence maps go into opposite direction)
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Monoidal category and functor examples

category

category

## if ( is a category with all nite products and F : ( (,

then F is a comonoidal functor from ((, , 1) to itself:
m = F
1
, F
2
n = !
F1

## innite list functor is a strong monoidal functor

from ((, , 1) to itself:

## inverses of coherence maps are the coherence maps

of the abovementioned comonoidal functor
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Category theory basics
Products, coproducts, and exponentials
Categorical logic
Functors and natural transformations
Monoidal categories and monoidal functors
References
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References

## monad on a category ( consists of the following:

a functor T : ( (

: Id T : TT T

axioms:

A
(T
A
) =
A

TA
: TTTA TA
1
TA
=
A
(T
A
) =
A

TA
: TA TA

consequences:

## For every n, there are natural transformations

from T
n
to T that are built solely from T, , and .

## For every n, all such transformations are equal.

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References

is general union

: T(TA) TA

is singleton construction
: A TA

## corresponds to x [x] in Haskell

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References

containers:

## turns a single value (zero-level nested container)

into a singleton container

of computations:

computation

## turns a result value into a computation without eect

that just returns this value
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References

## comonad on a category ( consists of the following:

a functor U : ( (

: U Id : U UU

axioms:
(U
A
)
A
=
UA

A
: UA UUUA
1
UA
= (U
A
)
A
=
UA

A
: UA UA

consequences:

## For every n, there are natural transformations

from U to U
n
that are built solely from U, , and .

## For every n, all such transformations are equal.

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References

## intuition is that of containers that can be turned

into arbitrarily nested containers:

## turns a at container into a single value,

which is taken from a special position inside the container
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Kleisli and Co-Kleisli categories

## morphisms f : A B of the Kleisli category

are the morphisms f : A TB of (

## compositions gf in the Kleisli category correspond

to morphisms (Tg)f in (

## Kleisli category intuition:

morphisms are eectful computations
that also have an input

## Co-Kleisli categories are the duals of Kleisli categories

An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
Category theory basics
Products, coproducts, and exponentials
Categorical logic
Functors and natural transformations
Monoidal categories and monoidal functors
References
An Introduction to
Category Theory
and Categorical
Logic
Wolfgang Jeltsch
Category theory
basics
Products,
coproducts, and
exponentials
Categorical logic
Functors and
natural
transformations
Monoidal
categories and
monoidal functors
References
References
Andrea Asperti and Giuseppe Longo
Categories, Types, and Structures
http://www.cs.unibo.it/
~
asperti/PAPERS/book.pdf
Steve Awodey
Category Theory
http://www.andrew.cmu.edu/course/80-413-713/
notes/cats.pdf
Samson Abramsky and Nikos Tzevelekos
Introduction to Categories and Categorical Logic
http://arxiv.org/pdf/1102.1313v1
Wouter Swierstra
Theory of patches
http://sneezy.cs.nott.ac.uk/fplunch/weblog/?p=4