categories and computer science

Post on 04-Jan-2016

23 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Categories and Computer Science. http://cis.k.hosei.ac.jp/~yukita/. What is category theory?. Algebra of functions Composition is the principal operation on functions Abstract structure Collection of objects Collection of arrows between them - PowerPoint PPT Presentation

TRANSCRIPT

Categories and Computer Science

http://cis.k.hosei.ac.jp/~yukita/

2

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

3

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

4

Topics we choose

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

5

CategoriesThe Algebra of Functions

slide)next the to(continues (4)

.:1 morphismidentity designated a is there,Given (3)

.: morphism composite

designated a is there,: and :Given (2)

. objin are and where,:

. and designated a has morphismEach (1)

:Further

. ,,,,,,,

)arr (called or ofset a and

,,,,,,,

) obj (called ofset a of consists category A

AAA

CAfg

CBgBAf

BABAf

codomaindomain

hgf

arrowsmorphisms

YXCBA

objects

A

A

A

AADef.

6

fghfgh

BAfffff AB

)()( law. eAssociativ

.:for 1 and 1 laws.Identity

:following thesatisfies above data The (4)

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.

7

A Bf

1A 1B

8

Ex 1. Sets: The category of sets

,: functions all arecategory thisof morphisms The

,,, sets all arecategory thisof objects The

BAf

CBA

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?

9

Small examples

AA

A

A

AA

A

A

A

α

α

AAAAA

AAA

11

1

1

11

1

(ii) Case (i) Case

.: ,:1 arrows two;object One

arrows. no objects; No

.:1 arrow one and object One

Ex.4.

Ex.3.

Ex.2.

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

10

Ex.5. Two objects and three arrows

defined.partially isn compositio The required. is 11

11

11

.: and identities are Arrows . and are Objects

BB

AA

BA

BABA

11

Ex. 6 One object with four arrows

2121212121

2122122

2121111

2121

2121

22

212

11221

2121

11

1

.,,with

,,,1 :Arrows , :Object

eeeeeeeeee

eeeeeee

eeeeeee

eeee

eeee

eeeeeeee

eeeeA

AA

A

A

12

Is Ex.6 really a category?

ity.associativ verify toneed no is theremodel, theis thisIf

)},0(),(),0,(),(,{

tion.implementaan is following thecheck that usLet

arrows. by thegiven theof

an is model ticalset theore hesay that tmay We

category. a constitute arrows that thededuceeasily can then we

n table,compositio for the ticalset theore a is thereIf

212 yyxexyxeA

ionspecificat

tionimplementa

tionrepresenta

R

13

Ex. 7 The category of power set 2X

• The subsets of X = {0,1,2} is the set of objects.

• The arrows are inclusions.

• In the figure, identities are omitted.

{0,1,2}

{0,1} {1,2}{0,2}

{0} {1} {2}

14

Ex. 8 Identities are only arrows.

A

1A

B

1B

C

1C

E

1E

D

1D

15

.1

such that : arrowan is there,: arroweach to

thatis monoids, among groups, of feature special The

. a called isobject oneith category wA

groups. of axioms by the eassociativ iswhich

group, in the elements ofproduct theisn Compositio .object one of

category aget get we we,},,,1{ groupany Given

morphisms eassociativh object wit oneExactly

11

1

A

AAAA

monoid

A

gfG

Remark

Def.

10. Ex.

9. Ex.

Monoids and Groups

16

Examples of monoids

.by given isn Compositio

,,,,,1,,, arrows ;object One

additionunder Integers

.by given isn Compositio

,,,,,1 arrows ;object One

additionunder numbers Natural

43212

432

nmnm

A

nmnm

A

eee

eeeeeeA

eee

eeeeA

12. Ex.

11. Ex.

17

Order

set. preordered

a is of subsets all of 2category theset aGiven

. a called is , to from arrow onemost at is there

thenobjects are and ifhat property t ith thecategory wA

condition.given the

by equal arecodomain anddomain same with thearrows two

since satisfiedlly automatica are laws eassociativ theand lawsidentity The

. implies and that requiresn compositio of existence The

. allfor requires identities of existence The

.by it denote to from arrowan is thereIf

object.other any object to oneany from arrow onemost At

XX

setpreorderedBA

BA

CACBBA

AAA

BABA

X14. Ex.

Def.

Notation.

13. Ex.

18

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

19

Ex. 15. Modulo 4 addition

233

322

32

32

32

4

1

1

1

11

1

category a ofon presentati relation with :arrow One

:object One

eeee

eeee

eeee

eee

eee

ee

A

A

A

A

AA

A

20

Ex. 16. A category of words

relations. no with },,,,,,,,{ arrows ofset The

* :object One

ZCBAzcba

sMathematic* *

**

* *

**

・・・・

s M

ci t

a

21

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.

22

Ex. 17.

fgffgfg

ggg

fgff

fgf

g

fggf

gf

ABgBAf

BA

A

BB

AA

BA

A

1

11

11

11

1relation one Take

.: and : arrows two(2)

and , , objects two(1)

generators as Take

.

23

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.

24

Def. The free category on a graph G

paths.empty theare identities The

paths. ofion concatenat isn Compositio

.

i.e. up, maching codomains and domains with to

from arrows of paths are object toobject from Arrows

. of thoseas same thearecategory free theof objects The

.on thecalled by generated

category a formcan werelations,given no and ,graph aGiven

121111 BAAABA

BA

BA

G

Gcategory freeG

G

nnnn fn

ffffff

25

Ex. 18. A Regular Language

A CBE

_

0

1

9

・・

0

1

9

・・

exponent. negative-non a with numbers Signed

274102102274 CBBBBAAAA

EE

26

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

.8)4( meaning

,

following; thehave We

.,

relations with :,:,:

arrows and and objects graph withA

f

ssssssssossssssssfossssssfsossssfssossfsssofsssso

ssffsofo

NNfNNsNIo

NI

27

The dual of a category

CBACBA

gffg

ff

AA

A

gfgf

and

other.each todual are categories twofollowing The

. have We

.in arrowan toscorrespond that of arrow theby denote We

.in object an toscorrespond that ofobject theby denote We

reversed. being arrows theallwith

and as objects same ith thecategory w a is category. a be Let

op

op

op

20. .Ex

AA

AA

AA

28

Ex. 23. Setsfinite and BoolAlgfinite

Highly advanced topic

29

Isomorphic categories

. writeWe

.)identities preserves ( 1)1(

A thenin identity an is 1 if (iii)

ns.)compositio preserves ( )()()(

A thenin : and : if (ii)

)codomains. and domains preserves (

.in )()(:)(

then in : if (i)

such that ly,respective , of arrows and objects the to of arrows

and objects thefrom bijection a is to from misomorphisAn

)(

3221

21

21

BA

B

A

BA

BA

AA

A

fggf

AAgAAf

AAf

AAf

30

.2 toisomorphic is )2( 27. Ex. op XX

{0,1,2}

{0,1} {1,2}{0,2}

{0} {1} {2}

{0,1,2}

{0,1}{1,2} {0,2}

{0}{1}{2}

31

Def. Product of categories

component.by component performed isn Compositio

.: and :

arrows of ),( pairs are ),( to),( from arrows The

. ofobject an

is and ofobject is where),( pairs are of objects The

following. by the defined

is , and of the, then categories are , If

211211

112211

BBgAAf

gfBABA

BABA

product

B

ABA

BABABA

32

arrows. nine and objectsfour has Then

.: and ,1,1 arrows threeand , objects twohas

.: and ,1,1 arrows threeand , objects twohas

figure.) in the omitted are s(Identitie

2121

2121

21

21

BA

B

A

28. Ex.

BBgBB

AAfAA

BB

AA

),( 12 BA ),( 22 BA

),( 11 BA ),( 21 BA

)1,(2B

f

),1(2

gA

),1(1

gA

),( gf)1,(

1Bf

33

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.

top related