You are on page 1of 77

math people math for non-math people

Intro to Category Theory


Chapter 1: Preliminaries (Part 1)
CHANNEL PHILOSOPHY
-don’t dwell too much on jargon and proofs, focus entirely
on simple layman terms to get the non-specialist just
enough knowledge to use specialist math in their fields

-one (1) hour videos which, while long, will essentially


each be a college class, and in the end can serve as a
crash course
SOURCES
Barr M, Wells C. Category theory for computing science.
Montréal: <> Publications CRM; 1999.
-pretty much all the words here are from that book, but I
drew quite a bit of graphs to illustrate the ideas better
as it’s quite spartan.
What the fuck is category theory?
-alternative to set theory (a category is a collection of
objects linked by arrows, contrasted to a set which is an
entity with elements that is distinct from but entirely
determined by them if there are elements)

-attempts to be axiomatic/ fundamental (reframes everything


in math in terms of itself and claims to be superior)

--this makes category theory useful in moving one type of


mathematical structure to another
Main topics for this chapter
-introduction to notation and terminology

-discussion of graphs/ a specific type of directed graph


(as basis for the definition of category and an essential
part of the definition of commutative diagrams and
sketches)

-defining homomorphisms
Sets
-again, an entity with elements that is distinct from but
entirely determined by them if there are elements

-can be defined explicitly or denoted by setbuilder notation {


x | P(x) } as collection of entities satisfying predicate

- x is a variable ranging over a specific type of data


- P(x) is a predicate about that kind of data
- { x | P(x) } set of all things with type x about which
P(x) is true, is the extension of predicate P
notation
We denote the set of natural numbers (nonnegative integers)
by N, the set of all integers by Z, the set of all rational
numbers by Q, and the set of all real numbers by R.
Russell’s paradox
-implicit error within setbuilder notation

- { S | S is a set and S ∉ S }

-avoiding this paradox involves restricting the type of


x to one that already forms a set

-proves by contradiction that there is no “set of all


sets”, since S ∈ S implies S ∉ S, but S ∉ S implies S ∈ S
Cartesian products
-If S and T are sets, S x T is the set of the combination
of every ordered pair (s,t) where s ∈ S and t ∈ T. Thus in
set builder notation, S x T = { (s,t) | s ∈ S and t ∈ T }

-Since these are ordered pairs, T x S = { (t,s) | s ∈ S


and t ∈ T } and so is not the same as S x T unless S=T.

-Ordered pairs are defined entirely by the fact that the


first coordinate is and and the second is t.
Tuples
-An ordered n-tuple is a sequence (a1,...,an) determined
uniquely by the fact that for i=1,...,n, the i th coordinate
of (a1,...,an) is ai. In this case, the Cartesian product
S1xS2x...xSn is the set of all n-tuples (a1,...,an) with ai ∈
Si for i = 1,...,n

-for example, (3,4,5) is a 3-tuple


Relations
-A relation α from a set S to a set T is a subset of S x T.
This makes sense- S x T is every possible interaction
between S and T, and the specific pattern of which pairs
from S x T is in the subset determines the nature of this
relation.

-the empty set counts as a relation from S to T.


continued
--the diagonal relation Δs from S to S for any set is ΔS = {(x,x)|x ∈ S}.
Usually we just denote Δ with ‘=’.

-order relations such as ‘<’ or ‘≤’ on R are examples of relations and can
be defined purely by which ordered pairs from S x T are in it. For
example, ‘<’ is the set { (r,s) | There is a positive number t such that
r+t=s }

-If α is a relation from S to T, then we write s α t to mean that


(s,t) ∈ α.

-Observe that if S≠T, then a relation from S to T is not the same


as from T to S (as that would mean S x T ≠ T x S)
Functions
-a function f is an entity with four properties:

- F-1 f has a domain and codomain, both of which are sets


- F-2 For every element x of domain f has a value at x,
which is an element and is defined f(x)
- F-3 The function completely determines the domain,
codomain, and the value f(x) for each x in the domain
- F-4 The domain, codomain, and value f(x) for each x in
the domain completely determine the function f
continued
-the domain and codomain are called the source and
target of f

-the notation for “the function f has domain of S and


codomain of T” is f: S=>T

-the barred arrow can be used as notation to show what


the function does instead of just the domain and codomain
(e.g x ↦ x2: R => R+) and is used for functions mainly
defined by their formula
continued
-the barred arrow notation serves the same purpose as the
logician’s lambda notation- the above function can be depicted
as λx.x2, though we do not use this except to discuss λ-
calculus in a later video.

- F-3 is one rule together with the domain and codomain.


This means that the same formula with different domain
and/ or codomain are different functions:
- x ↦ x2: R => R+ and x ↦ x2: R => R are
different
inclusion functions
-every set S has an identity function idS: S=>S for which
idS(x)=x (basically it spits out what you put in)

-if S is a subset of a set T, then there is an inclusion


function i:S=>T for which i(x)=x for all x ∈ S.
Graphs (and properties)
-the graph of a function f: S=>T is the set of ordered
pairs { (x,f(x)) | x ∈ S }. You can guess why it’s called
“graph”- get a cartesian plane, map out all of the ordered
pairs, and you have the function’s graph.

-the image or range of a function is it’s set of values


(which we defined earlier as the set of all f(x)).
Formally, we say the image of f: S=>T is { t ∈ T | Ǝs ∈ S
for which f(s)=t }, but ultimately it just means all the
f(x) values of a function.
Injective functions
-injective is another way of saying one-to-one. More
formally, A function f:S=>T is injective if whenever s≠s’
in S, then f(s)≠f(s’) in T.

-If there is an s and s’ which aren’t the same in S,


but there’s a f(s)=f(s’) in T, that’s basically saying that
there are at least two s values which lead to the same f(s)
value in a function. Graphed, it would mean you would not
see more than one instance of a specific f(s) value on a
horizontal line.
Surjective functions
-surjective is another way of saying onto. More formally, a
function f: S=>T is surjective if its image is T.

-This is basically saying that all of the f(s)


values together cover the whole codomain:
Bijective functions
A function is bijective if it is both injective and
surjective. Such a function is also called a one to one
correspondence.

-basically think of a function where f(x) spans the


whole codomain and doesn’t violate the vertical and
horizontal line rule
Projection functions
-If S and T are sets, S x T has two coordinate or
projection functions proj1:S x T=>S and proj2:S x T=>T. If S
and T are not empty, these functions are by definition
surjective (since Cartesian products are every possible
combination of every element of both sets, reducing to
either set would have all the elements of that set).

-Coordinate functions for products of more than two sets


are defined analogously (there would be a proj 3 S x T x U=>
U if there was a third set U).
-if X, S, and T are sets and f:X=>S and g:X=>T are
functions, then the function <f,g>:X=> S x T is defined by
<f,g>(x)=(f(x),g(x)) for all x ∈ X

-If X, Y, S, and T are sets and f:X=>S and g:Y=>T are


functions, then f x g: X x Y => S x T is the function
defined by (f x g)(x,y)=(f(x),g(y)). This is the cartesian
product of the functions f and g.
Composite function
-if g: S=>T and f: T=>U, then fºg: S=>U is defined to be
the unique function with domain S and codomain U for which
(fºg)(x)=f(g(x)) for all x ∈ S.
note:
category theory is based on composition as a fundamental
operation in the same way the classical set theory is based
on the ‘element of’ or membership relation.
Restriction
-If f:S=>T and A ⊆ S, the restriction of f to A is the
composite fºi, where i:A=>S is the inclusion function
(basically you’re restricting which of the elements of S
goes to T).

-Similarly, if T ⊆ B, f is called the corestriction of


the function jºf:S=>B to T, where j is the inclusion of T
in B (basically you’re choosing a selection of elements
moved from S to T).
Functions in theory...
The concept of function can be explicitly defined in terms
of its domain, codomain, and graph. A function f:S=>T could
be defined as an ordered triple (S,Γ,T) with the property
that Γ is a subset of S x T (meaning a relation) with the
functional property (Γ is the graph of f). Then for x ∈ S,
f(x) is the unique element y ∈ T for which (x,y) ∈ Γ.

A function is not actually an ordered triple, though.


Hom sets and functors
-Hom set Hom(S,T) is the set of all functions with domain S
and codomain T, which is to say, the set of morphisms
between objects.

-Hom function is more accurately a “functor”, since if


you feed it a set it gives you a set but if you give it a
morphism it gives you a morphism

-If f: T => V is a function, then Hom(S,f): Hom(S,T) =>


Hom(S,V) is defined by Hom(S,f)(g)=fºg
fuck does this mean?
f: T => V is a function that moves from domain T (which is
already the codomain of S) to codomain V (essentially
making V the co-codomain of S if that makes sense).

Now, here’s where the dualism comes in- since the second
variable in Hom(S,f) is a function, Hom(S,f) is no longer
defined as a set of functions but a function itself called
a Hom function.
continued
With defining it as Hom(S,f)(g)=fºg, we are defining the
previously undefined Hom(S,f)(g) with fºg, where if again
f: T=>V and g is whatever but presumably moves from
somewhere to T (like S=>T), then fºg: S=>V
continued
What Hom(S,f) does is move from domain of Hom(S,T)
[basically saying set of all functions with domain S and
codomain T] towards the codomain of Hom (S,V) [basically
saying set of all functions with domain S and codomain V].
Essentially, the purpose of this is to put a function into
a different framework, to move the function into another
codomain (like for example from positive to real,
essentially).
Graphs
-specifically, directed multigraphs with loops

-the way we define the graph is as a constituent of a


sketch, which will be discussed in a later video. It is
also a precursor to the concept of category: a category is
a graph in which paths can be composed.

-specifying a graph means specifying its nodes (or objects)


and arrows. Each arrow has a specific source or domain node
and a target or codomain node.
continued
-the notation we previously used for functions, f: a=>b, can also be used
to denote that f is an arrow, a is the source, and b is the target.

-there can be any amount of arrows, from one to two to none at all.

-an arrow with the same source and target node is called an endomorphism
of that node.

-We denote the collection of nodes of a graph G by G 0 and its collection of


arrows as G1. The nodes form the zero-dimensional part, and the arrows form
the one-dimensional part.
The graph of sets and functions
The graph of all sets and functions (which, unlike the set
of all sets, exists) has all possible sets as nodes and all
the functions between them as arrows. The source of a
function is its domain and the target is its codomain,
hence using the function notation for nodes and arrows.

-important to note: THE NODES FOR THIS SPECIFIC GRAPH DO


NOT FORM A SET UNLIKE THE OTHER EXAMPLES HERE.
Kinds of graphs
-A graph that has a set of nodes and arrows is a small graph. In
general we call stuff ‘small’ if the collection(s) it’s built on
form sets. If it doesn’t, we call them large.

-if G is a small graph, source: G1=>G0 and target: G1=>G0 are


functions.

-A graph without arrows is called discrete. The empty set, which


has no nodes, is discrete. A small discrete graph is essentially a
set, can define a set, and for most purposes are the same thing
(think about this).
continued
-A graph with a finite number of both nodes and arrows is
called finite.

-It’s possible to portray a relation (which was defined


previously as a subset of all possible ordered pair
combinations between two sets) as a graph:
continued
-Graphs that arise this way cannot have more than one arrow
with the same source and target. Such graphs are called
simple graphs.

-The graph of a function is a relation, and corresponds


to a graph like in the most recent example. The picture it
creates has an arrow from each element x of the domain to
f(x) and does not look like a graph used in calculus.
Graph representation of data structures
-a data structure can be represented by a graph. For example, the
set N of natural numbers can be represented in terms of zero and a
successor function (succ) that adds 1:

-Adding ‘1’ as a node is a conventional notation to require


that a node is a singleton set, or a set with exactly one element:
The graph of graphs
We have defined arrows and nodes as sets, and sources and targets
as functions (and therefore arrows). If we define arrows as a,
nodes as n, and source and target as s and t respectively, we can
define a small graph to be two sets and two functions with the set
of arrows as domain and the set of nodes as codomain. Formalized,
the functions are s,t:a=>n. Putting all of this together, we get a
graph. This is called the graph of graphs:
Homomorphisms
-a homomorphism (which is NOT a homeomorphism, the similarity of the
name is a pure unfortunate coincidence) of a graph is whatever the
fuck (yes, literally whatever the fuck) that preserves the graph’s
abstract shape.

-A homomorphism Φ from a graph G to a graph H, denoted Φ: G=>H, is


a pair of functions
Φ0: G0=>H0 and Φ1: G1=>H1

- with the property that if u:m=>n is an arrow of G (which is to


say, the function u is an element of G1), then Φ1(u): Φ0(m)=>Φ0(n) in
H:
another way to define homomorphisms
Using the graph of graphs, we can define source and target mappings.
An arrow or function is an element of either G1 or H1. If we want to
find the source of an arrow, which is a node, we have to define
sourceG: G1=>G0. Remember that in the graph of graphs, both source and
target are arrows moving from the arrows to nodes- as such the rest is
defined targetG: G1=>G0, sourceH: H1=>H0, and targetH: H1=>H0,
altogether:

sourceG: G1=>G0
targetG: G1=>G0
sourceH: H1=>H0
targetH: H1=>H0
continued
If we lay these out, we find
that the pair of mappings that
constitute homomorphism, Φ0:
G0=>H0 and Φ1: G1=>H1, are only
graph homomorphisms if
sourceHºΦ1=Φ0ºsourceG and
targetHºΦ1=Φ0ºtargetG.

Reminder of how composite


functions work:
continued
As such, those compositions (sourceHºΦ1=Φ0ºsourceG and
targetHºΦ1=Φ0ºtargetG) should look like this:
Here, the equality is clear- both compositions lead to the
same collection.
note:
to this point, we have been doing a bad practice, which is overloaded
notation. For example, with a:B=>C, we can denote a set-theoretic function, a
graph homomorphism, or an arrow in a graph.

-you could say that the first two are examples of the third: there is a
large graph whose nodes are sets and arrows are functions, and another large
graph whose nodes are small graphs and the arrows are graph homomorphisms.

-the prior “Φ: G=>H, is a pair of functions Φ 0: G0=>H0 and Φ1: G1=>H1” is
also overloaded notation- usually the subscripts for the thetas are omitted in
all three.

-in practice, you can usually use common sense to distinguish between them
(yes, really).
identity homomorphism
If G is any graph, the identity homomorphism idG:G=>G is
defined by (idG)0=idG0 and (idG)1=idG1. If you remember how
composition works, this is basically just G 0 and G1 pointing
at themselves.
example
If G is this graph:

and H is this graph:

then there is a homomorphism Φ: G=>H, for which Φ 0(1)=S (theta with zero
subscript meaning translating from node to node), Φ 0(2)=Φ0(3)=F, and
Φ (4)=Q:
continued
Φ1 takes the loop on 2 and the arrow from 2 to 3 both to
the upper loop of F. Since F has two loops, Φ1 can be 4
different combinations on the arrows (keeping Φ 0 fixed):
continued
If H is any graph with a node n and a loop u:n=>n, then
there is a homomorphism from any graph G to H that takes
every node of G to n and every arrow to u. This means there
are two more homomorphisms from G to H in the above example
aside from the four there:
model of a sketch
There is a homomorphism σ to this graph:

That takes the node called 1 to a one-element set {*} which takes the node
n to the set N of natural numbers. The homomorphism σ takes the arrow 1=>n
to the function *↦0 that picks out the natural number 0, and σ(successor)
is the function that adds 1. This is an example of a model of a sketch.

-one can let n go to the set of integers (mod k) for a fixed k and let
succ be the function that adds one (mod k) (it wraps around).

-you can get other homomorphisms by adjoining extra elements to


the set corresponding to n which are their own successors.
on the graph of graphs...
This graph:

can also be given semantics in the same way. If G is any small


graph, there is a graph homomorphism Φ from that diagram to the
graph of sets for which Φ0(n) is the set of nodes of G, Φ0(a) is
the set of arrows, and Φ1 takes the arrows labeled source and
target to the corresponding functions from the set of arrows of G
to the set of nodes of G:
[INSERT END CARD HERE]
still working on it lol

You might also like