Categories and Computer Science http cis k hosei

  • Slides: 33
Download presentation
Categories and Computer Science http: //cis. k. hosei. ac. jp/~yukita/

Categories and Computer Science http: //cis. k. hosei. ac. jp/~yukita/

What is category theory? • Algebra of functions – Composition is the principal operation

What is category theory? • Algebra of functions – Composition is the principal operation on functions • Abstract structure – Collection of objects – Collection of arrows between them • Invented by S. Eilenberg and S. Mac Lane in 1945 – originated from algebraic topology – influence on • Algebraic geometry A. Grothendieck • Logic F. W. Lawvere • Computer science 2

How does category theory appear in Computer Science? • Construction of functions out of

How does category theory appear in Computer Science? • Construction of functions out of a given set of simple functions – using various operations on functions such as: • composition and repeated composition – An important aspect of CS • Dynamical systems – having states which vary over time – Computing is concerned with machines • An algebra of functions which really does not consist of functions – Programs and languages are formal things that specify actual functions – Syntactical side of CS 3

Topics we choose • • Grammars and Languages Data types Boolean algebra Circuit theory

Topics we choose • • Grammars and Languages Data types Boolean algebra Circuit theory Flow charts Imperative programming Specification Lambda calculus 4

Categories The Algebra of Functions 5

Categories The Algebra of Functions 5

Note. The notion of category is axiomatically defined and formal. The objects of a

Note. The notion of category is axiomatically defined and formal. The objects of a category need not be actual sets and the arrows need not be actual functions. As is usual with axiomatic definitions this allows great flexibility. CS note. An object of a category does not necessarily have methods such as union, intersection, Cartesian producs, etc. 6

1 A A f B 1 B 7

1 A A f B 1 B 7

Ex 1. Sets: The category of sets Note. If you are unfamiliar with the

Ex 1. Sets: The category of sets Note. If you are unfamiliar with the notions of sets and functions, you should consult with some elementary textbooks on set theory. Can you clearly tell the differences between surjection, injection, and bijection? 8

Small examples We should check if all the axioms are satisfied in these examples.

Small examples We should check if all the axioms are satisfied in these examples. 9

Ex. 5. Two objects and three arrows 10

Ex. 5. Two objects and three arrows 10

Ex. 6 One object with four arrows 11

Ex. 6 One object with four arrows 11

Is Ex. 6 really a category? 12

Is Ex. 6 really a category? 12

Ex. 7 The category of power set 2 X {0, 1, 2} {0, 1}

Ex. 7 The category of power set 2 X {0, 1, 2} {0, 1} {0, 2} {1, 2} {0} {1} {2} • The subsets of X = {0, 1, 2} is the set of objects. • The arrows are inclusions. • In the figure, identities are omitted. 13

Ex. 8 Identities are only arrows. 14

Ex. 8 Identities are only arrows. 14

Monoids and Groups 15

Monoids and Groups 15

Examples of monoids 16

Examples of monoids 16

Order 17

Order 17

Presenting a category by its generators and relations • Generators – All of the

Presenting a category by its generators and relations • Generators – All of the objects – Some of the arrows • Relations – Some equations between composites of given arrows 18

Ex. 15. Modulo 4 addition 19

Ex. 15. Modulo 4 addition 19

Ex. 16. A category of words * * * * ・・・・ * a 20

Ex. 16. A category of words * * * * ・・・・ * a 20

Def. Free monoid • A category with one object and several arrows with no

Def. Free monoid • A category with one object and several arrows with no relations is called a monoid. • The set of arrows is call the alphabet of the monoid. • Languages are subsets of a free monoid. • We usually think of a language as a set of well-formed sentences with respect to some grammar. 21

Ex. 17. 22

Ex. 17. 22

Def. Directed graphs • A (directed) graph is a set of objects and a

Def. Directed graphs • A (directed) graph is a set of objects and a set of arrows, each with a prescribed domain object and codomain object. • There’s no composition. This is the difference between graphs and categories. 23

Def. The free category on a graph G 24

Def. The free category on a graph G 24

Ex. 18. A Regular Language ・・ 9 1 1 0 0 + _ 25

Ex. 18. A Regular Language ・・ 9 1 1 0 0 + _ 25

Ex. 19. Function f(n)=2 n 26

Ex. 19. Function f(n)=2 n 26

The dual of a category 27

The dual of a category 27

Ex. 23. Setsfinite and Bool. Algfinite Highly advanced topic 28

Ex. 23. Setsfinite and Bool. Algfinite Highly advanced topic 28

Isomorphic categories 29

Isomorphic categories 29

Def. Product of categories 31

Def. Product of categories 31

32

32

Remark • In any category, • given any two objects in the diagram, say

Remark • In any category, • given any two objects in the diagram, say P and Q, any composite of arrows from P to Q yields the same result. • We then say that the diagram commutes. 33