![Page 1: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/1.jpg)
Lecture 2: Introduction to Category Theory
Nick Rossiter, Computing Science, Newcastle University, England
[email protected]://www.cs.ncl.ac.uk/people/b.n.rossiter/
![Page 2: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/2.jpg)
Features of Interoperability
• Complex mappings from user views to way data is held
• Need to handle data, metadata and metameta data
• Need to make semantic transformations
![Page 3: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/3.jpg)
Category Theory?
• Need relations to represent mappings between levels
• Multi-level construction (higher-order)
• Category theory seems appropriate:- categories for basic structures
- functors relate categories
- natural transformations relate functors
![Page 4: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/4.jpg)
Origins of Category Theory
1940s Sammy Eilenberg
1960s Fred Lawvere
1970s Saunders Mac Lane
1990s Mike Barr & Charles Wells
Peter Freyd
Various views: “Multi level Graph Theory”
“Multi level Functional Programming”
“Multi level Type Theory”
![Page 5: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/5.jpg)
Basic Constructions
• The Category:
• Collection of arrows which may be named:
(name:) source target
e.g. a b
1a: a a (identity arrow named 1a)
f: b c (arrow named f)
![Page 6: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/6.jpg)
Categorial Axioms 1
• The identity arrow 1a identifies an object a
• Arrows are composable if the source of one forms the target of the other:
a b, b c has composite a c
• Composition is associative:
f: a b, g: b c, h: c d
f o (g o (h)) equiv ((f) o g) o h
![Page 7: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/7.jpg)
Categorial Axioms 2
• Identity arrows may be used for the operation of composition:
e.g. f: a b, g: b c f
a b
f 1b g
b c
g
• Equations: 1b o f = f and g o 1b = g
![Page 8: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/8.jpg)
Types of Category
• Categories are named in bold font.
• A number of universal basic types have been developed for:
Sets
Ordered constructions on sets
Products
Relationships
(and many others)
![Page 9: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/9.jpg)
Discrete Categories
• Every arrow is an identity arrow
e.g. aa, b b, c c
• Discrete categories are sets (without functions)
![Page 10: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/10.jpg)
Simple Categories 0,1
• 0
empty category -- no objects, no arrows
• 1
(discrete) category with one object and one identity arrow e.g.
a 1a: a a
![Page 11: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/11.jpg)
Simple Categories 2
• 2
Category with two objects and one arrow which is not an identity e.g.
a, b a b
![Page 12: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/12.jpg)
Category Set
• Set
The objects are sets
The arrows are total functions between the sets
e.g. Sets X, Y, Z
Total functions a:X Y, b:Y Z
![Page 13: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/13.jpg)
Category Set (commuting diagram)
• Represented as category XYZ in the universal category of Set
X
a c
Y Z
b
• Diagram is said to commute if c = b o a
• Equational logic to accompany diagrams
![Page 14: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/14.jpg)
Category Preorder
• A set of objects p,q,r,…
• A collection of arrows such that:
each arrow represents an ordering
• There is no more than one arrow between any two objects
• p q is the ordered pair <p,q> for which p <= q
![Page 15: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/15.jpg)
Preorder construction
• Satisfies categorical axioms:
identity p p (for each object)
composition p <= q <= r implies p <= r through transitivity
• Example of preorder: (may be symmetric)
b
d c e
a
![Page 16: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/16.jpg)
Preorder Applications
• May be cyclic
• Occur naturally as rich data structures in information systems e.g. object-oriented
• In some approaches e.g. relational, preorders are converted to an equivalent collection of partial orders
• Normalization techniques
![Page 17: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/17.jpg)
Partial Orders - Category Pos
• Collection of partial-order objects with order-preserving arrows between them
• As preorder but with asymmetric axiom:
if p<=q and q<=p then p=q is implied Objects b
Pos1 d c e
a
Pos2 a d
Order-preserving arrows: Pos2Pos1; Pos1 Pos2
![Page 18: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/18.jpg)
Pos Applications
• Derived from Preorder by Functor (see later) to convert symmetric structures to asymmetric ones
• Basis of logic
• Ordering by projection, inclusion
• Inheritance and aggregation paths• Basic data structuring with constraints (keys)
• Relationship representation
![Page 19: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/19.jpg)
Types of Arrow - Monic
• Monic:
m
a b
f g
d
• If m o f = m o g implies f=g, then m is monic. Left-cancellable.
• One path. Injective in sets. 1:1 relationship.
![Page 20: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/20.jpg)
Types of Arrow - Epic
• Epic
h d
a b c
e
• If d o h = e o h implies d=e then h is epic.
Right-cancellable.• Onto. Surjective in sets. Mandatory relation.
![Page 21: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/21.jpg)
Isomorphisms
• A mapping that is both monic and epic in the category Set is isomorphic.
• In other types of categories, this cannot always be assumed to hold.
![Page 22: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/22.jpg)
Collections of Arrows - Hom Sets
• Sometimes useful to think of the collection of arrows between two objects
• Termed a hom set
• Written homC(a,b)
to represent all arrows between objects a and b in the category C.
• Emerge as results of queries on information systems
![Page 23: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/23.jpg)
Types of Object - Initial
• An initial object in a category has precisely one arrow from it to every other object.
b
a c
d
• a is initial object in this category
• Bottom in partial orders; identifiers or keys in databases;
![Page 24: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/24.jpg)
Types of Object - Terminal
• A terminal object in category has precisely one arrow onto it from every other object
a
b emptyset
c
• emptyset is terminal object
• top in partial orders; base supertype in inheritance partial orders
![Page 25: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/25.jpg)
Category with Products
• A category has finite products if in addition to objects, say, a,b,c, it has:
• a product object a x b x c • projections:
pi1: a x b x c a
pi2: a x b x c b
pi3: a x b x c c
![Page 26: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/26.jpg)
Product - Universal Mapping
• Binary product example (U universal object)
A x B
pi1 d pi2
A U B
f g
Equations: f o pi1 = d = g o pi2
![Page 27: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/27.jpg)
Relationships -- Pullbacks
• Notion of subproduct
• Relation of two objects in context of a third
• Restriction of universal product
• Pullback of one arrow over another
![Page 28: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/28.jpg)
Pullback Diagram for f over g - Basic Arrows
A
pil f
A XC B C
pir g
B• A, B are objects in relationship• C includes coproduct A+B, product AXB, link objects.
• A XC B is product A X B in context C
• Equational logic: f o pil = g o pir
![Page 29: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/29.jpg)
Pullbacks - More Arrows 1
A
pil pi*l f
Delta
A XC B C
pi*r
pir g
B
![Page 30: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/30.jpg)
Pullback - More Arrows 2
A
pil pi*l f
Coprod
A XC B Delta C
pi*r Prod
pir g
B
![Page 31: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/31.jpg)
Interpretation of Objects, Arrows
• A XC B relation A to B over C
• Delta: C A XC B
Mapping from link object to relation
• Coprod: A XC B C (exists)
Mapping from relation to coproduct in C
• Prod: A XC B C (for all)
Mapping from relation to product in C
![Page 32: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/32.jpg)
Interpretation of Projection Arrows
• pil: A XC B A
left projection
monic -- each A participates once in relation
epic -- each A must participate in relation
• pir: A XC B B
right projection
monic -- each B participates once in relation
epic -- each B must participate in relation
![Page 33: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/33.jpg)
Coproducts (Sums)
A+B
il d ir
A U B
f g
Equations il o f = d = ir o g
U is universal object
![Page 34: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/34.jpg)
Restricted Coproduct
• Pushout
A
f il
C A +C B
g ir
B
Restriction over object C
![Page 35: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/35.jpg)
Limits
• Both Pullbacks and Pushouts are examples of Limits.
• They are restricted products/coproducts
• A +C B is colimit
• A XC B is limit
![Page 36: Lecture 2: Introduction to Category Theory Nick Rossiter, Computing Science, Newcastle University, England B.N.Rossiter@newcastle.ac.uk](https://reader035.vdocument.in/reader035/viewer/2022062517/56649f2f5503460f94c49b34/html5/thumbnails/36.jpg)
Further Reading
• Categories for the Working Mathematician
Mac Lane, Saunders
2nd edition
Springer-Verlag 1998.
• Category Theory for Computing Science Barr, Michael & Wells, Charles
1st edition (later editions are available)
Prentice-Hall 1990.