Yoneda lemma and string diagrams 
Ray D. Sameshima 
2014/09/06  
2014/09/20
Contents 
-1 Preface 3 
-1.1 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 
-1.2 Notations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 
0 De
nitions 5 
0.0 The size problem . . . . . . . . . . . . . . . . . . . . . . . . . 5 
0.0.1 Naive de
nition of a category . . . . . . . . . . . . . . 5 
0.0.2 De
nition of a universe . . . . . . . . . . . . . . . . . 7 
0.0.3 Axiom (universe) . . . . . . . . . . . . . . . . . . . . . 9 
0.0.4 Axiom (class) . . . . . . . . . . . . . . . . . . . . . . . 10 
0.1 Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 
0.1.1 De
nition of categories . . . . . . . . . . . . . . . . . . 10 
0.1.2 Examples of category . . . . . . . . . . . . . . . . . . 12 
0.1.3 Some arrows . . . . . . . . . . . . . . . . . . . . . . . 12 
0.2 Functors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 
0.2.1 De
nition of functors (covariant functors) . . . . . . . 13 
0.3 Natural transformations . . . . . . . . . . . . . . . . . . . . . 15 
0.3.1 De
nition of natural transformations . . . . . . . . . . 15 
0.3.2 De
nition of functor categories . . . . . . . . . . . . . 16 
1 Yoneda lemma 18 
1.1 Representable functors . . . . . . . . . . . . . . . . . . . . . . 18 
1.1.1 De
nition of representable functors . . . . . . . . . . . 18 
1.1.2 The Yoneda lemma . . . . . . . . . . . . . . . . . . . . 19 
2 Godement products of natural transformations 24 
2.1 De
nition of Godement products . . . . . . . . . . . . . . . . 24 
2.1.1 Check . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 
2.2 Proposition (The interchanging law) . . . . . . . . . . . . . . 26 
1
2.2.1 Proof . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 
3 String diagrams 28 
3.1 A class change method . . . . . . . . . . . . . . . . . . . . . . 28 
3.2 String diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . 29 
3.3 The Godement product . . . . . . . . . . . . . . . . . . . . . 31 
3.3.1 The interchanging law . . . . . . . . . . . . . . . . . . 33 
3.3.2 Functors . . . . . . . . . . . . . . . . . . . . . . . . . . 33 
3.3.3 Natural transformations . . . . . . . . . . . . . . . . . 34 
3.4 The Yoneda lemma . . . . . . . . . . . . . . . . . . . . . . . . 35 
2
Chapter -1 
Preface 
This is a rough note from my under progress work entitled Cat. I wish to 
express my gratitude to Professor Azita Mayeli and Arthur Parzygnat for 
their advises. 
-1.1 References 
Handbook of Categorical Algebra 1 Basic Category Theory (Francis Borceux) 
Category Theory (Steve Awodey) 
An Introduction to Category Theory (Harold Simmons) 
nLab (http://ncatlab.org) 
http://d.hatena.ne.jp/m-hiyama/20130621/1371785971 
http://hal.archives-ouvertes.fr/docs/00/69/71/15/PDF/csl-2008.pdf 
http://www.pps.univ-paris-diderot.fr/~curien/categories-pl.ps 
http://www.ma.kagu.tus.ac.jp/~abe/index.html 
(underconstruction) Cat (Ray D. Sameshima) 
-1.2 Notations 
8 : (for) all 
9 : exists 
3
9! : uniquely exists 
S ) T : If S, then T . 
S , T : S iff (if and only if) T . 
lhs := rhs or lhs :, rhs : (unknown) lhs is de
ned by (known) rhs. 
4
Chapter 0 
De
nitions 
0.0 The size problem 
We have to pay some attentions on the sizes, but let us start with some 
intuitive de
nitions. 
0.0.1 Naive de
nition of a category 
A category C consists of the following date: 
1. Objects: A;B;C;    2 Obj. 
2. Arrows: 
f! 
; 
g! 
; 
h! 
;    2 Arr: 
3. 8f 2 Arr; 9dom(f); cod(f) 2 Obj. 
The notation 
f : A ! B (1) 
means that A = dom(f);B = cod(f). 
4. (composition law) 8f : A ! B and g : B ! C with 
cod(f) = B = dom(g) (2) 
then 9 an arrow 
g ◦ f : A ! C: (3) 
5
5. (9identity arrow as a unit) 8A 2 Obj; 9 an arrow 
1A : A ! A (4) 
s.t. if we compose it with 8 arrow from left and right, we get the same 
arrow, 8f : A ! B, 
f ◦ 1A = f = 1B ◦ f: (5) 
Then the identity arrow is unique: 
′ 
A = 1A ◦ 1 
1 
′ 
A = 1A: (6) 
6. (associativity) 8f : A ! B; g : B ! C; h : C ! D, 
h ◦ (g ◦ f) = (h ◦ g) ◦ f: (7) 
We depict these in the following diagram: 
1A f 
A 
/ 
@@ @@ @@ @ 
g◦f  @ 
1B
B 
@ 
@@ g 
@@ @@  
C 
h◦g 
  @ 
h 
/D 
(8) 
Now we can de
ne a category of sets and mappings. It is easy to check 
the above conditions, for example 
1A : A ! A; a7! 1A(a) := a (9) 
and 8a 2 A, 
h ◦ (g ◦ f)(a) = h (g (f(a))) = (h ◦ g) ◦ f(a): (10) 
We denote this category as 
Set (11) 
We, however, face a problem: objects of Set runs through something which 
is not a set! This fact is a consequence of the following well-known paradox: 
Russell's paradox 
There exists no set S s.t., 
x 2 S , x is a set. (12) 
6
Proof We use a contradiction argument. Let say there exists such S, 
de
ne 
R := fx 2 Sjx̸2 xg: (13) 
R is well-de
ned and is a subset of S. By the law of excluded middle, either 
R 2 R or R̸2 R, but from the de
nition of R itself, 
R 2 R ) R̸2 R (14) 
R̸2 R ) R 2 R: (15) 
This leads us to a contradiction in each case. 
Or, we can prove it directly, let x be a set, 
x 2 R , x̸2 x (16) 
From the axiom of extensionality, i.e., if every element of M is also an 
element of N, and vice versa, then M = N, we get 
R̸= x (17) 
that is, R is not a set. 
■ 
Taking, intuitively, a set of sets, it is not a set, something bigger than 
a set. In category theory, it is useful to pay some attention to the size. 
In order to handle this size problem, there is a way to assume the axiom of 
universes: 
0.0.2 De
nition of a universe 
A universe is a set U with the following properties: 
x 2 y; y 2 U ) x 2 U (18) 
I 2 U; 8i 2 I; xi 2 U ) 
∪ 
i2I 
xi 2 U (19) 
x 2 U ) P(x) 2 U (20) 
x 2 U; f : x ! y is surjective ) y 2 U (21) 
N 2 U (22) 
where N denotes the set of
nite ordinals and P(x) denotes the set of all 
subsets of x (the power set of x). 
7
Corollary 
The following results are immediate consequence of the de
nition of a uni- 
verse U. 
x 2 U; y  x ) y 2 U (23) 
x; y 2 U ) fx; yg 2 U (24) 
x; y 2 U ) x  y 2 U (25) 
x; y 2 U ) yx 2 U (26) 
Proof Since 
∅ 2 N ) ∅ 2 U: (27) 
Assume that x 2 U; y  x with y̸= ∅. Pick z 2 y and de
ne f : x ! y to 
be 
f(t) := 
{ 
t t 2 y 
z t̸2 y 
(28) 
then f is surjective and therefore y 2 U. 
Then let us de
ne 
I := f1; 2g 2 N; x1 = x; x2 = y (29) 
then 
fx; yg = 
∪ 
i2I 
xi (30) 
and we get fx; yg 2 U. 
Since we can use x  y as its index, we have 
x  y = 
∪ 
x02x 
x0  y = 
∪ 
y02y 
∪ 
x02x 
x0  y0 (31) 
and hence x  y 2 U. 
Finally, 
yx = 
∪ 
x02x 
yx0 = 
∪ 
y02y 
∪ 
x02x 
yx0 
o (32) 
and we get yx 2 U. 
■ 
8
Axiom of choice 
For any set X of nonempty sets, there exists a choice function f de
ned on 
X: 
8X; ∅̸2 X ) 9f : X ! 
∪ 
X;A7! f(A) 2 A; (33) 
eq.(21) should have been replaced precisely by eq.(23): (x 2 U; y  x ) y 2 
U). 
By the above, the existence of a universe axiom can be translated as 
below: 
0.0.3 Axiom (universe) 
Every set belongs to some universe. 
Because of the property in eq.(23), it sounds reasonable to think of the 
elements of a universe as being sufficiently small sets. If we choose to use 
the theory of universes as a foundation for category theory, the following 
convention has to remain valid: 
Convention 
We
x a universe U and call small sets the elements of U. 
Obviously we now have the following proposition: 
Proposition 
There exists a set S with the property 
x 2 S , x is a small set. (34) 
Proof For the proof, it is sufficient to choose S = U. 
■ 
An alternative way to handle these size problem is to use the Godel- 
Bernays theory of sets and classes. In the Zermelo-Frankle theory, the prim- 
itive notions are set and membership relation. In the Godel-Bernays 
theory, there is one more primitive notion called class (think of it as a 
big set); that primitive notion is related to the other two by the property 
that every set is a class and, more precisely: 
9
0.0.4 Axiom (class) 
A class is a set iff it belongs to some (other) class. 
The axioms concerning classes imply in particular the following com- 
prehension scheme for constructing classes: 
Comprehension scheme 
If 
φ(x1;    ; xn) (35) 
is a formula where quanti
cation just occurs on set variables, then there is 
a class A s.t. 
(x1;    ; xn) 2 A , φ(x1;    ; xn) (36) 
Thus the class of all sets is well de
ned: 
the class of all sets := jSetj: (37) 
When the axiom of universes is assumed and a universe U is
xed, one 
gets a model of the Godel-Bernays theory by choosing as sets the elements 
of U and as classes the subsets of U; 
sets 2 classes  a
xed universe U: (38) 
It makes no relevant difference whether we base category theory on the 
axiom of universes or on the Godel-Bernays theory of classes. We shall use 
the terminology of the latter, thus using the words set and class. 
0.1 Categories 
0.1.1 De
nition of categories 
A category C consists of the following date: 
1. (Objects) A class jCj, whose elements is called objects of C: 
A;B;C;D;    2 jCj: (39) 
10
2. (Arrows) 8 pair of objects A;B, a set C(A;B), whose elements is called 
arrows from A to B: 
f 2 C(A;B): (40) 
We write 
f : A ! B or A 
f! 
B (41) 
to indicate that A = dom(f);B = cod(f). We sometimes call such a 
category locally small whose arrows consist of a set. We may use 
dom(f) = s(f) = source of f; (42) 
cod(f) = t(f) = target of f: (43) 
3. Let us abuse the notation; C also means all the arrows of category C. 
Then 8f 2 C, 
9dom(f); cod(f) 2 jCj: (44) 
4. (composition law) 8f 2 C(A;B) and g 2 C(B;C) with 
cod(f) = B = dom(g) (45) 
then 9 an arrow 
g ◦ f 2 C(A;C): (46) 
5. (9identity arrow as a unit) 8A 2 jCj; 9 an arrow 
1A 2 C(A;A); (47) 
s.t. 
f ◦ 1A = f = 1B ◦ f: (48) 
Then the identity arrow is unique, since 
′ 
A = 1A ◦ 1 
1 
′ 
A = 1A: (49) 
6. (associativity) 8f 2 C(A;B); g 2 C(B;C); h 2 C(C;D), 
h ◦ (g ◦ f) = (h ◦ g) ◦ f: (50) 
11

Yoneda lemma and string diagrams

  • 1.
    Yoneda lemma andstring diagrams Ray D. Sameshima 2014/09/06 2014/09/20
  • 2.
    Contents -1 Preface3 -1.1 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 -1.2 Notations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 0 De
  • 3.
    nitions 5 0.0The size problem . . . . . . . . . . . . . . . . . . . . . . . . . 5 0.0.1 Naive de
  • 4.
    nition of acategory . . . . . . . . . . . . . . 5 0.0.2 De
  • 5.
    nition of auniverse . . . . . . . . . . . . . . . . . 7 0.0.3 Axiom (universe) . . . . . . . . . . . . . . . . . . . . . 9 0.0.4 Axiom (class) . . . . . . . . . . . . . . . . . . . . . . . 10 0.1 Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 0.1.1 De
  • 6.
    nition of categories. . . . . . . . . . . . . . . . . . 10 0.1.2 Examples of category . . . . . . . . . . . . . . . . . . 12 0.1.3 Some arrows . . . . . . . . . . . . . . . . . . . . . . . 12 0.2 Functors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 0.2.1 De
  • 7.
    nition of functors(covariant functors) . . . . . . . 13 0.3 Natural transformations . . . . . . . . . . . . . . . . . . . . . 15 0.3.1 De
  • 8.
    nition of naturaltransformations . . . . . . . . . . 15 0.3.2 De
  • 9.
    nition of functorcategories . . . . . . . . . . . . . 16 1 Yoneda lemma 18 1.1 Representable functors . . . . . . . . . . . . . . . . . . . . . . 18 1.1.1 De
  • 10.
    nition of representablefunctors . . . . . . . . . . . 18 1.1.2 The Yoneda lemma . . . . . . . . . . . . . . . . . . . . 19 2 Godement products of natural transformations 24 2.1 De
  • 11.
    nition of Godementproducts . . . . . . . . . . . . . . . . 24 2.1.1 Check . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.2 Proposition (The interchanging law) . . . . . . . . . . . . . . 26 1
  • 12.
    2.2.1 Proof .. . . . . . . . . . . . . . . . . . . . . . . . . . 26 3 String diagrams 28 3.1 A class change method . . . . . . . . . . . . . . . . . . . . . . 28 3.2 String diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.3 The Godement product . . . . . . . . . . . . . . . . . . . . . 31 3.3.1 The interchanging law . . . . . . . . . . . . . . . . . . 33 3.3.2 Functors . . . . . . . . . . . . . . . . . . . . . . . . . . 33 3.3.3 Natural transformations . . . . . . . . . . . . . . . . . 34 3.4 The Yoneda lemma . . . . . . . . . . . . . . . . . . . . . . . . 35 2
  • 13.
    Chapter -1 Preface This is a rough note from my under progress work entitled Cat. I wish to express my gratitude to Professor Azita Mayeli and Arthur Parzygnat for their advises. -1.1 References Handbook of Categorical Algebra 1 Basic Category Theory (Francis Borceux) Category Theory (Steve Awodey) An Introduction to Category Theory (Harold Simmons) nLab (http://ncatlab.org) http://d.hatena.ne.jp/m-hiyama/20130621/1371785971 http://hal.archives-ouvertes.fr/docs/00/69/71/15/PDF/csl-2008.pdf http://www.pps.univ-paris-diderot.fr/~curien/categories-pl.ps http://www.ma.kagu.tus.ac.jp/~abe/index.html (underconstruction) Cat (Ray D. Sameshima) -1.2 Notations 8 : (for) all 9 : exists 3
  • 14.
    9! : uniquelyexists S ) T : If S, then T . S , T : S iff (if and only if) T . lhs := rhs or lhs :, rhs : (unknown) lhs is de
  • 15.
  • 16.
  • 17.
    nitions 0.0 Thesize problem We have to pay some attentions on the sizes, but let us start with some intuitive de
  • 18.
  • 19.
    nition of acategory A category C consists of the following date: 1. Objects: A;B;C; 2 Obj. 2. Arrows: f! ; g! ; h! ; 2 Arr: 3. 8f 2 Arr; 9dom(f); cod(f) 2 Obj. The notation f : A ! B (1) means that A = dom(f);B = cod(f). 4. (composition law) 8f : A ! B and g : B ! C with cod(f) = B = dom(g) (2) then 9 an arrow g ◦ f : A ! C: (3) 5
  • 20.
    5. (9identity arrowas a unit) 8A 2 Obj; 9 an arrow 1A : A ! A (4) s.t. if we compose it with 8 arrow from left and right, we get the same arrow, 8f : A ! B, f ◦ 1A = f = 1B ◦ f: (5) Then the identity arrow is unique: ′ A = 1A ◦ 1 1 ′ A = 1A: (6) 6. (associativity) 8f : A ! B; g : B ! C; h : C ! D, h ◦ (g ◦ f) = (h ◦ g) ◦ f: (7) We depict these in the following diagram: 1A f A / @@ @@ @@ @ g◦f @ 1B
  • 21.
    B @ @@g @@ @@ C h◦g @ h /D (8) Now we can de
  • 22.
    ne a categoryof sets and mappings. It is easy to check the above conditions, for example 1A : A ! A; a7! 1A(a) := a (9) and 8a 2 A, h ◦ (g ◦ f)(a) = h (g (f(a))) = (h ◦ g) ◦ f(a): (10) We denote this category as Set (11) We, however, face a problem: objects of Set runs through something which is not a set! This fact is a consequence of the following well-known paradox: Russell's paradox There exists no set S s.t., x 2 S , x is a set. (12) 6
  • 23.
    Proof We usea contradiction argument. Let say there exists such S, de
  • 24.
    ne R :=fx 2 Sjx̸2 xg: (13) R is well-de
  • 25.
    ned and isa subset of S. By the law of excluded middle, either R 2 R or R̸2 R, but from the de
  • 26.
    nition of Ritself, R 2 R ) R̸2 R (14) R̸2 R ) R 2 R: (15) This leads us to a contradiction in each case. Or, we can prove it directly, let x be a set, x 2 R , x̸2 x (16) From the axiom of extensionality, i.e., if every element of M is also an element of N, and vice versa, then M = N, we get R̸= x (17) that is, R is not a set. ■ Taking, intuitively, a set of sets, it is not a set, something bigger than a set. In category theory, it is useful to pay some attention to the size. In order to handle this size problem, there is a way to assume the axiom of universes: 0.0.2 De
  • 27.
    nition of auniverse A universe is a set U with the following properties: x 2 y; y 2 U ) x 2 U (18) I 2 U; 8i 2 I; xi 2 U ) ∪ i2I xi 2 U (19) x 2 U ) P(x) 2 U (20) x 2 U; f : x ! y is surjective ) y 2 U (21) N 2 U (22) where N denotes the set of
  • 28.
    nite ordinals andP(x) denotes the set of all subsets of x (the power set of x). 7
  • 29.
    Corollary The followingresults are immediate consequence of the de
  • 30.
    nition of auni- verse U. x 2 U; y x ) y 2 U (23) x; y 2 U ) fx; yg 2 U (24) x; y 2 U ) x y 2 U (25) x; y 2 U ) yx 2 U (26) Proof Since ∅ 2 N ) ∅ 2 U: (27) Assume that x 2 U; y x with y̸= ∅. Pick z 2 y and de
  • 31.
    ne f :x ! y to be f(t) := { t t 2 y z t̸2 y (28) then f is surjective and therefore y 2 U. Then let us de
  • 32.
    ne I :=f1; 2g 2 N; x1 = x; x2 = y (29) then fx; yg = ∪ i2I xi (30) and we get fx; yg 2 U. Since we can use x y as its index, we have x y = ∪ x02x x0 y = ∪ y02y ∪ x02x x0 y0 (31) and hence x y 2 U. Finally, yx = ∪ x02x yx0 = ∪ y02y ∪ x02x yx0 o (32) and we get yx 2 U. ■ 8
  • 33.
    Axiom of choice For any set X of nonempty sets, there exists a choice function f de
  • 34.
    ned on X: 8X; ∅̸2 X ) 9f : X ! ∪ X;A7! f(A) 2 A; (33) eq.(21) should have been replaced precisely by eq.(23): (x 2 U; y x ) y 2 U). By the above, the existence of a universe axiom can be translated as below: 0.0.3 Axiom (universe) Every set belongs to some universe. Because of the property in eq.(23), it sounds reasonable to think of the elements of a universe as being sufficiently small sets. If we choose to use the theory of universes as a foundation for category theory, the following convention has to remain valid: Convention We
  • 35.
    x a universeU and call small sets the elements of U. Obviously we now have the following proposition: Proposition There exists a set S with the property x 2 S , x is a small set. (34) Proof For the proof, it is sufficient to choose S = U. ■ An alternative way to handle these size problem is to use the Godel- Bernays theory of sets and classes. In the Zermelo-Frankle theory, the prim- itive notions are set and membership relation. In the Godel-Bernays theory, there is one more primitive notion called class (think of it as a big set); that primitive notion is related to the other two by the property that every set is a class and, more precisely: 9
  • 36.
    0.0.4 Axiom (class) A class is a set iff it belongs to some (other) class. The axioms concerning classes imply in particular the following com- prehension scheme for constructing classes: Comprehension scheme If φ(x1; ; xn) (35) is a formula where quanti
  • 37.
    cation just occurson set variables, then there is a class A s.t. (x1; ; xn) 2 A , φ(x1; ; xn) (36) Thus the class of all sets is well de
  • 38.
    ned: the classof all sets := jSetj: (37) When the axiom of universes is assumed and a universe U is
  • 39.
    xed, one getsa model of the Godel-Bernays theory by choosing as sets the elements of U and as classes the subsets of U; sets 2 classes a
  • 40.
    xed universe U:(38) It makes no relevant difference whether we base category theory on the axiom of universes or on the Godel-Bernays theory of classes. We shall use the terminology of the latter, thus using the words set and class. 0.1 Categories 0.1.1 De
  • 41.
    nition of categories A category C consists of the following date: 1. (Objects) A class jCj, whose elements is called objects of C: A;B;C;D; 2 jCj: (39) 10
  • 42.
    2. (Arrows) 8pair of objects A;B, a set C(A;B), whose elements is called arrows from A to B: f 2 C(A;B): (40) We write f : A ! B or A f! B (41) to indicate that A = dom(f);B = cod(f). We sometimes call such a category locally small whose arrows consist of a set. We may use dom(f) = s(f) = source of f; (42) cod(f) = t(f) = target of f: (43) 3. Let us abuse the notation; C also means all the arrows of category C. Then 8f 2 C, 9dom(f); cod(f) 2 jCj: (44) 4. (composition law) 8f 2 C(A;B) and g 2 C(B;C) with cod(f) = B = dom(g) (45) then 9 an arrow g ◦ f 2 C(A;C): (46) 5. (9identity arrow as a unit) 8A 2 jCj; 9 an arrow 1A 2 C(A;A); (47) s.t. f ◦ 1A = f = 1B ◦ f: (48) Then the identity arrow is unique, since ′ A = 1A ◦ 1 1 ′ A = 1A: (49) 6. (associativity) 8f 2 C(A;B); g 2 C(B;C); h 2 C(C;D), h ◦ (g ◦ f) = (h ◦ g) ◦ f: (50) 11