Category Theory | a silly walk - CiteSeerX

0 downloads 0 Views 279KB Size Report
Jun 12, 1993 - Mort;u. 2. 8s; t; u2Obj: 8f 2Mors;t: 8g 2Mort;u: (f g) 2Mors;u. 3. 8s2Obj: 8t2Obj: 8f ..... rt(;;nil) := rt(emptylist emptylist;+) := emptylist; rt(emptylist ...
Category Theory | a silly walk Claus-Peter Wirth Informatik 5, Universitat Dortmund, D{44221, Germany [email protected]

June 12, 1993 Revised Rosenmontag, 1999 Revised 11.11 h, Nov. 11, 1999 Preliminary version

Abstract: Being a syntax-oriented formalist I always had problems with the usual informal and graphical presentation of categories. This is my trial to overcome these problems. This script was supported by my friend N. Bourbaki.

Contents 1 Basic Notions and Notations

1

2 Categories and Functors

2

3 Duality

7

4 On the Inside of Categories

8

5 Algebras

14

6 Co-Algebras

17

7 Di-Algebras

20

References

23

1

1 Basic Notions and Notations `IN' denotes the set of and `' the ordering on natural numbers. We de ne IN+ := f n 2 IN j 0 6= n g: We use `]' for the union of disjoint classes, `id' for the identity function, and `V ' for the class of all sets. For a class R we de ne domain , range , and restriction to and image and reverse-image of a class A by dom(R) := f a j 9b: (a; b) 2 R g ; ran(R) := f b j 9a: (a; b) 2 R g ; := f (a; b) 2 R j a 2 A g ; A jR hAiR := f b j 9a 2 A: (a; b) 2 R g ; RhB i := f a j 9b 2 B : (a; b) 2 R g : For a class A we de ne its power class and the class of its non-empty nite subsets by P(A) := f B j B  A g ; PIN+(A) := f B j B  A ^ jB j 2 IN+ g : For a (possibly) partial function B : V ; P(V ) and class1 A with A  dom(B ) we de ne their product and co-product (or free sum ) by Y Ba := f f : A ! V j 8a 2 A: f (a) 2 Ba g ; a2A

a

a2A

Ba := f (a; b) 2 AV j b 2 Ba g

:

1 Note that the product is meaningless unless A is a set: If A is a proper class, then any function f with dom(f ) = A is a proper class, so that the product will be the empty set.

2

2 Categories and Functors The notion of an (abstract) category can reasonably be de ned in several di erent ways. The following two are particularly useful. As prerequisites, de ne the morphism , domain , and codomain functions mor; Dom; Cod: VVV ! V by ((h; s; t) 2 VVV ) mor(h; s; t) := h; Dom(h; s; t) := s; and Cod(h; s; t) := t:

De nition 2.1 (Category)

A category C consists of (left indices deliberately omitted):  a class CObj of objects ,  a class CArr of arrows with CArr  VCObjCObj;  for each s 2 Obj an identity CIds with (Ids; s; s) 2 CArr;  a binary partial composition function C : (CArrCArr) ; CArr with in x notation. Now the following must hold: 1. dom(  ) = f (a; b) 2 ArrArr j Cod(a) = Dom(b) g 11 0 0 (a  b) 2 Arr 2. 8a; b 2 Arr: B @ Cod(a)= Dom(b) ) B@ ^ Dom(a  b) = Dom(a) CA CA ^ Cod(a  b) = Cod(b) 0  1 Dom( a ) = s ) (Id ; s; s )  a = a s A 3. 8s 2 Obj: 8a 2 Arr: @  ^ Cod(a) = s ) a  (Ids ; s; s) = a ! ! Cod( a ) = Dom( b ) 4. 8a; b; c 2 Arr: ^ Cod(b) = Dom(c) ) (a  b)  c = a  (b  c)

De nition 2.2 (Category alternate )

A category C consists of (left indices deliberately omitted):  a class CObj of objects ,  for each (s; t) 2 ObjObj a class CMors;t of morphisms ,  for each s 2 Obj an identity CIds with CIds 2 CMors;s;  a binary partial composition function C : (VV ) ; V with in x notation. Now the following must hold: 1. dom() = Ss;t;u2Obj Mors;t  Mort;u 2. 8s; t; u 2 Obj: 8f 2 Mors;t: 8g 2 Mort;u: (f  g) 2 Mors;u ! 8 t 2 Obj: 8 f 2 Mor : Id  f = f s;t s 3. 8s 2 Obj: ^ 8r 2 Obj: 8g 2 Mor : g  Id = g r;s s 4. 8s; t; u; v 2 Obj: 8f 2 Mors;t: 8g 2 Mort;u: 8h 2 Moru;v : (f  g)  h = f  (g  h)

3 First consider C to be given according to Def. 2.1: We can de ne for s; t 2 Obj: Mors;t := f f j (f; s; t) 2 CArr g: Now assume2 that the composition function depends only on the rst component of the arrows but not on their domain and !1 0 codomain, formally: (f; s; t); (f; s0; t0); (g; t; u); (g; t0; u0) 2 Arr C 8s; t; u; s0; t0; u0 2 Obj: 8f; g; h: B@ ^ (f; s; t)  (g; t; u) = (h; s; u) A: 0 0 0 0 0 0 ) (f; s ; t )  (g; t ; u ) = (h; s ; u ) Note that this is always the case if ! Mor \ Mor = ; s;t u;v 8s; t; u; v 2 Obj: _ (s; t) = (u; v) : (:x) Under this assumption, the composition function on morphisms f; g can be de ned just by adding any appropriate s; t; u such that (f; s; t); (g; t; u) 2 Arr and taking the rst component of the triple resulting from their composition. Now the enumerated items of Def. 2.2 follow from the respective items of Def. 2.1. Now, however, consider C to be given according to Def. 2.2: Then we can de ne Arr := f (f; s; t) j f 2 Mors;t ^ s; t 2 Obj g: Again, the enumerated items of Def. 2.1 follow from the respective items of Def. 2.2. Moreover, if (x) holds, we can treat Dom and Cod as if they were directly de ned on Mor := Ss;t2Obj Mors;t via3 \ \ t: s; and Cod(f ) := Dom(f ) := 9s: f 2Mor

9t: f 2Mor

s;t

s;t

All in all, if we have to de ne some concrete category, we can always choose the more convenient way and check the category property without translation. Moreover, by use of the translation given above, we can always use `Mors;t', `Arr', and `Mor', no matter which way the category has been de ned. In case of (x), we can even always use Dom and Cod and write the composition function on morphisms instead of arrows. We will abbreviate \f  g" by \fg" and \f (gh)" (or \(fg)h") by \fgh". Moreover, when \fg" appears in any atomic formula A, this formula is to be replaced with the formula (A ^ B ), where B is a formula saying that the composition is de ned, i.e. B is either Cod(f ) = Dom(g) or 9s; t; u 2 Obj: (f 2 Mors;t ^ g 2 Mort;u): Finally we write

f ::s!t

and intend it to mean any of either f 2 Mors;t or (f; s; t) 2 Arr: 2 Even

if this is not the case we could get a category in the sense of Def. 2.2 by setting Mor

s;t

:=

f (f; s; t) j (f; s; t) 2 CArr g; thereby (together with the transformation in the other direction) establishing

the equivalence of Def.2.1 and Def.2.2. We use the less general transformation because it is more useful in practice. 3 Note that in a set theory with ur-elements, we need Hilbert's "-operator to de ne Dom(f ) := "s: 9t: f 2 Mor etc.. Anyway, the simple meaning of this is: \Let Dom(f ) be such that f 2 MorDom( ) ." s;t

f ;t

4

Corollary 2.3

Let C be a category. Now Ids is unique in Mors;s satisfying item (3) in Def. 2.1 or Def. 2.2. More precisely: For s 2 Obj and i 2 Mors;s with 8f 2 Mors;s : (i; s; s)(f; s; s) = (f; s; s) or 8g 2 Mors;s : (g; s; s)(i; s; s)= (g; s; s) we have i = Ids:

De nition 2.4 (Functor) Let C, D be categories.

A (co-variant ) functor F from C to D (written \F: C  D") is a triple F = ((FObj; FArr); C; D) or else F = ((FObj; FMor); C; D) with:  An object function FObj: CObj ! DObj. We abbreviate \FObj(s)" by \sF".  An arrow function FArr: CArr ! DMor or else a morphism function FMor: We abbreviate \FArr(a)" by \a F" and \FMor(f )" by \f F". Note CMor ! DMor. that any morphism function FMor de nes the corresponding arrow function FArr via FArr(f; s; t) := FMor(f ); but the converse de nition is not always possible. Now for the array function (morphism function analogously) the following must hold: 1. 8s; t 2 CObj: 8f 2 CMors;t: ((f;s;t)F; sF; tF) 2 DArr. 2. 8s 2 CObj: (CId ;s;s)F = DIdsF. 3. 8s; t; u 2 CObj: 8f 2 CMors;t: 8g 2 CMort;u: (((f;s;t) C (g;t;u))F; sF; uF) = ((f;s;t)F; sF; tF) D ((g;t;u)F; tF; uF) s

.

When C and D are given according to Def. 2.2 this reads: 1. 8s; t 2 CObj: 8f 2 CMors;t: f F 2 DMorsF;tF. 2. 8s 2 CObj: CId F = DIdsF . 3. 8s; t; u 2 CObj: 8f 2 CMors;t: 8g 2 CMort;u: (f C g)F = f F D g F. s

F is full if 8s; t 2 CObj: 8f 0 2 DMorsF;tF: 9f 2 CMors;t: (f;s;t)F = f 0:  F is faithful if 8s; t 2 CObj: 8f; g 2 CMors;t: (f;s;t)F = (g;s;t)F ) f = g : The identity functor IC for C is the functor

IC

:= ((CObjjid; CMorjid); C; C) .

If ((CObjjid; CMorjid); C; D) is a functor, then it is called the inclusion functor from C to D and C is called a sub-category of D. If this functor is full, C is a full sub-category of D. A contra-variant functor (or contra-functor ) F from C to D (written \F: C D") di ers from a co-variant functor only in the following (for FArr analogously): 1. 8s; t 2 CObj: 8f 2 CMors;t: f F 2 DMortF;sF. 3. 8s; t; u 2 CObj: 8f 2 CMors;t: 8g 2 CMort;u: (f C g)F = g F D f F

5 Note that, due to our special notation for the application of FArr and FMor, we can get the references to C and D, resp., from the level and thus may omit them. E.g., we will write \Id F = IdsF" for \CId F = DIdsF" as well as \(f  g)F = f F  g F" (or even \fg F = f Fg F") for \(f C g)F = f F D g F". Furthermore, note that 8s; t 2 CObj: 8f 0 2 DMorsF;tF: 9a 2 CArr: aF = f 0 does in general not imply that F is full, and that a faithful F does not have to satisfy 8a; b 2 CArr: (aF = b F ) a = b): This is one of the unusual cases in category theory where the domain and codomain information becomes crucial. s

s

De nition 2.5 (Small, Large, and Superlarge)

A category C is small if CArr is a set.4 It is large if it is not small. A superlarge category C is like a category, but where CObj and CArr are collections of classes.

Corollary 2.6

Let C and D be categories. If C and D are a small, then CObj, (CIds )s2CObj , C , (CMors;t )(s;t)2CObjCObj , CArr, C, and all functors F: C  D are sets. If C is large, then C , CArr, C, and all functors F: C  D are proper classes.

Example 2.7 (Categories of Sets)

The relation category of sets is the large category REL given as follows: := V RELMorA;B := f R j R  AB g for A; B 2 V . R REL S := RS for R; S 2 RELMor. RELIdA := A jid for A 2 V . RELObj

The partial function category of sets is the large sub-category FUN of the category REL given by FUNObj := V and for A; B 2 V : FUNMorA;B

:= A ; B := f f j f : A ; B g

The (total function ) category of sets is the large sub-category SET of the category FUN given by SETObj := V and for A; B 2 V : SETMorA;B

4 This

:= A ! B := f f j f : A ! B g

is, of course, equivalent to CObj and CMor being sets, for any s; t 2 Obj. s;t

6

Example 2.8 (Categories of Classes)

The relation category of classes is the superlarge category RELCLASS given as follows: RELCLASSObj is the collection of all classes A  V . RELCLASSMorA;B is the collection all all classes R  AB for A; B  V . R RELCLASS S := RS for R; S in RELCLASSMor. RELCLASSIdA := A jid for A  V . The (total function ) category of classes is the superlarge sub-category CLASS of the superlarge category RELCLASS given by CLASSObj := RELCLASSObj and for A; B in RELCLASSObj: CLASSMorA;B is the collection of all f : A ! B .

Example 2.9 (Category of S-Sorted Sets)

Let Sbe some set of sorts . The function category of S-sorted sets is the category SORT(S) given as follows: SORT( )Obj := S! P(V ) is the class of all S-sorted families of sets. SORT( )MorA;B := f f : S! (V ; V ) j 8s 2 S: fs : As ! Bs g is the set of S-sorted functions from A to B for A; B 2 SORT( )Obj. f SORT( ) g := (fs gs)s2S for f; g 2 SORT( )Mor. SORT( )IdA := (A jid)s2S for A 2 SORT( )Obj. S

S

S

S

S

S

S

s

Note that SORT(S) is large i S6= ;: Even in this case | although SORT( )Obj and SORT( )Arr are proper classes | SORT( )MorA;B is always a set because it is contained in the set P(S A  S B ): S

S

S

s2S s

s2S s

Example 2.10 (Functor Categories of Categories)

The functor category of of small categories is the large category SMALL given as follows: SMALLObj := f C j C is a category g is the proper class of all small categories. SMALLMorC;D := f F j F: C  D g is the set of all functors from the small category C to the small category D. (FObj; FArr) SMALL (GObj; GArr) := (FObj  GObj; HArr) where HArr is given by (f;s;t)H := (( ) F;sF;tF) G for F: B  C and F: C  D. SMALLIdC := IC: f;s;t

The functor category of of all categories is the superlarge category ALL given as follows: ALLObj is the collection of all categories | excluding the superlarge categories. ALLMorC;D is the collection of all functors F: C  D from the category C to the category D. The rest is analogous to SMALL.

7

3 Duality The duality principle is a very important tool for doing universal category theory because it halves the proof work. The principle is based on the cognition that things do not change when all arrows and their composition are reversed.

De nition 3.1 (Dual Category and Functor)

Let C be a category. The dual 5 category of C is the category Dual(C) given by Dual(C)Obj := CObj; Dual(C)Arr := f (f; t; s) j (f; s; t) 2 CArr g; Dual(C)Ids := CIds ; Dual(C)Mors;t := CMort;s ; (g; u; t) Dual(C) (f; t; s) := (f; s; t) C (g; t; u): Let F: C  D. The dual functor of F Dual(F): Dual(C)  Dual(D) is given by Dual(F)Obj := FObj and (f;t;s)Dual(F) := (f;s;t)F: The dual contra-functor of F: C  D is F: C Dual(D): Of special interest is IC: C Dual(C), which in general is no co-variant functor because item (1) of Def. 2.4 is satis ed i jCObjj  1: The dual expression of some expression  is obtained by replacing each occurrence of a category or functor symbol X by Dual(X ), reversing the arguments of all concatenations, replacing CMors;t with CMort;s, Dom with Cod, and Cod with Dom. Simply speaking of the dual we mean what is obtained by substituting everything by its dual. Note that the dual expression has the same truth value in the dual as the original expression in the original. Since Dual(Dual(C)) = C and Dual(Dual(F)) = F for F: C  D, the dual of the dual is the original. Moreover, the dual of all categories and functors are all categories and functors: Indeed, the dual of the expression \C is a category" is logically equivalent to the expression \C is a category" itself. The same holds for the expression \F is a functor". Since the dual of a logic inference is a logic inference, if a set of axioms A has a consequence , then the dual of  is a consequence of the dual of A. Thus, the universal theory of categories and functors does not di er from its dual. Stated di erently: If a general theorem about categories and functors is valid, then the dual theorem is valid, too. This \duality principle " is a very important tool for doing universal category theory because it halves the proof work.

5 called opposite

by some authors

8

4 On the Inside of Categories In the whole section we assume C to be some category and omit the left indices to C.

De nition 4.1 t 2 Obj is called . . .

. . . initial if 8u 2 Obj: jMort;uj = 1. . . . nal (or terminal ) if 8s 2 Obj: jMors;tj = 1. Thus, \ nal" is the dual of \initial". . . . a zero object if t is initial and nal. Thus, \being a zero object" is the dual of itself.

E.g. in SET, ; is the only initial object, the terminal objects are exactly the sets with a single element, and zero objects do not exist.

De nition 4.2 a 2 Arr is called . . .   . . . monic if 8b; c 2 Arr: ba = ca ) b = c .   . . . epi if 8b; c 2 Arr: ab = ac ) b = c . ... ...

... ... ... ... ... ...

Thus, \epi" is the dual of \monic". split-monic if 9r 2 Arr: ar = (IdDom(a); Dom(a); Dom(a)): Such an r is called a retraction of a. split-epi if 9l 2 Arr: la =(IdCod(a); Cod(a); Cod(a)): Such an l is called a section of a. Thus, \split-epi" and \section" are the dual of \split-monic" and \retraction". 0 = (IdDom(a); Dom(a); Dom(a)) ! aa 0 : iso if 9a 2 Arr: ^ a0a = (Id Cod(a); Cod(a); Cod(a)) Such an a0 is called the inversion of a. endo if Dom(a)= Cod(a): auto if a is iso and endo. idempotent if aa = a: Thus, \iso", \endo", \auto", and \idempotent" are the duals of themselves.   an equalizer for p; q if ap = aq and 8a0 2 Arr: a0p = a0q ) 9!c 2 Arr: a0 = ca :   a co-equalizer for p; q if pa = qa and 8a0 2 Arr: pa0 = qa0 ) 9!c 2 Arr: a0 = ac : Thus, \co-equalizer" is the dual of \equalizer".

9

De nition 4.3 s; t 2 Obj are called . . .

. . . isomorphic if 9f 2 Mors;t: ( (f; s; t) is iso ). . . . uniquely isomorphic if 9!f 2 Mors;t: ( (f; s; t) is iso ).

Corollary 4.4 \isomorphic" and \uniquely isomorphic" are the duals of themselves. Corollary 4.5 Let a 2 Arr. a is iso i a is split-monic and split-epi. Lemma 4.6 (1) Two initial objects are uniquely isomorphic. (2) An object isomorphic to an initial object is initial. Dual(1) Two nal objects are uniquely isomorphic. Dual(2) An object isomorphic to an nal object is nal.

Proof of Lemma4.6

(1): Suppose that s; t are both initial. De ne ff g := Mors;t and fgg := Mort;s. Now mor((f; s; t)(g; t; s)) 2 Mors;s = fIdsg and mor((g; t; s)(f; s; t)) 2 Mort;t = fIdtg:

Lemma 4.7 (1) If a is split-monic, then a is monic. (2) If a is an equalizer for p; q, then a is monic. Dual(1) If a is split-epi, then a is epi. Dual(2) If a is a co-equalizer for p; q, then a is epi.

Proof of Lemma4.7

(1): For ba = ca we get b = b (IdDom(a); Dom(a); Dom(a)) = bar = car = c (IdDom(a); Dom(a); Dom(a)) = c: (2): By the rst property of an equalizer we get (ba)p = (ba)q for each b 2 Arr with Cod(b) = Dom(a): Thus, (by the uniqueness part of the second property of an equalizer) ba = ca implies b = c:

10

Lemma 4.8

In the relation category 6 REL of sets the following items are logically equivalent for R::A!B and C := f y j jRhfygij = 1 g : 1. R::A!B is split-monic. 2. R::A!B is monic. 3. 8X; Y  A: ( hX iR = hY iR ) X =Y ). 4. 8x 2 A: hAiR 6= hAnfxgiR. 5. dom(R  C jid) = A. 6. R  C jid  R?1 = A jid.

Proof of Lemma 4.8 (1) ) (2): By Lemma 4.7. (2) ) (3): Suppose hX iR = hY iR: De ne S := f;gX and T := f;gY: Then S R = f;ghX iR = f;ghY iR = T R: Since R::A!B is monic, we get S = T; i.e. X = Y: (3) ) (4): If (4) were not true, (3) would imply A = Anfxg . (4) ) (5): \" is trivial. For showing \" assume x 2 A but y 62 C for all y with (x; y) 2 R . Then we get hAiR = hAnfxgiR; which contradicts (4). (5) ) (6): \" is true by de nition of C . \" follows from (5). (6) ) (1): We get C jid  R?1 ::B !A and R  C jid  R?1 = Ajid = RELIdA. Lemma 4.9 In the relation category 6 REL of sets the following items are logically equivalent for R::A!B and C := f y j jhfygiRj = 1 g : 1. R::A!B is split-epi. 2. R::A!B is epi.   3. 8X; Y  B : RhX i = RhY i ) X = Y . 4. 8x 2 B : RhB i 6= RhB nfxgi. 5. ran(C jid  R) = B . 6. R?1  C jid  R = B jid. Since Dual(REL) is isomorphic to REL via F: Dual(REL)  REL given by AF := A and R F := R?1 and since Lemma 4.9 is the F-isomorphic of the dual of Lemma 4.8, we do not give a proof of Lemma 4.9 | even if the duality principle7 is actually only sucient to infer the logical equivalence of (1) and (2). 6 Cf. Ex.2.7. 7 Cf. section 3.

11

Lemma 4.10

In the (total function) category 8 SET of sets the following items are logically equivalent for f ::A!B : (1) f ::A!B is an equalizer [for each p; q::B !C with 8b 2 B : ( p(b) = q(b) , b 2 ran(f ) )]. (2) f ::A!B is monic. (3) f : A ! B is injective. Furthermore, (1) - (3) are implied by (4) f ::A!B is split-monic. In general, however, (4) is not implied by (1) - (3), but it is equivalent to (5) f : A ! B is injective and ( A = ; ) B = ; ) .

Proof of Lemma 4.10 (1) ) (2): By Lemma 4.7. (2) ) (3): If f were not injective, there would be a; b 2 dom(f ) with a 6= b and f (a) = f (b): De ne g; h::f;g!A by g(;) := a and h(;) := b: Thus, g  f = h  f and g 6= h; which contradicts (2). (3) ) (1): For p, q as indicated, we get f  p = f  q: Furthermore, for f 0::D!B with f 0  p = f 0  q we get ran(f 0)  ran(f ): Thus, since f is injective, we then can de ne h::D!A by h := f 0f ?1; and get f 0 = f 0  ran(f )jid = f 0  f ?1  f = h  f: Finally, for any other h0::D!A with f 0 = h0  f we get h0 = h0  A jid = h0  f  f ?1 = f 0  f ?1 = h: (4) ) (2): By Lemma 4.7. (4) ) (5): If f has a retraction r::B !;, we must have B = ;: (5) ) (4): If A = ; = B; f has the retraction ;::;!;. If there is some a 2 A, f has the retraction r::B !A given by r(x) := f ?1 (x) for x 2 ran(f ) and r(x) := a for x 2 B nran(f ). In general not \(3) ) (4)": Take f := A := ; and B := f;g . Now f is injective but cannot have a retraction since SETMorB;; = ; .

8 Cf. Ex. 2.7.

12

Lemma 4.11

In the (total function) category 8 SET of sets the following items are logically equivalent for f ::A!B : (1) f ::A!B is a co-equalizer [for p; q::C !A; C := ker(f ) := f  f ?1 ; and p; q given by ( (x; y) 2 C ) p(x; y) := x and q(x; y) := y ]. (2) f ::A!B is epi. (3) f : A ! B is surjective (i.e. ran(f ) = B ). Furthermore, (1) - (3) are implied by (4) f ::A!B is split-epi. \(3) ) (4)", however, is equivalent to the set-version of (the function choice function version of) the Axiom of Choice.

Proof of Lemma4.11

(1) ) (2): By Lemma 4.7. (2) ) (3): If ran(f ) 6= B; there would be some b 2 B nran(f ). De ne g; h::B !f0; 1g by g(b) := 1; g(x) := 0 for x 2 B nfbg, and h(x) := 0 for x 2 B . Thus, fg = fh and g 6= h; which contradicts the assumption that f ::A!B is epi. (3) ) (1): For p, q as indicated, we get p  f = q  f: Furthermore, for f 0::A!D with p  f 0 = q  f 0 we get ker(f )  ker(f 0) because f 0 is total on A. Thus, since f : A ! B is surjective, we then can de ne h::B !D by h := f ?1  f 0 and get f 0 = f  f ?1  f 0 because of A jid  f  f ?1  ker(f 0 ): Thus f 0 = f  h: Finally, for any other h0 ::B !D with f 0 = f  h0 ; since f is surjective we get h0 = B jid  h0 = ran(f )jid  h0 = f ?1  f  h0 = f ?1  f 0 = h: (4) ) (2): By Lemma 4.7. Axiom of Choice, (3) ) (4): Since ran(f ) = B; let f 00: B ! A be a function choice function of f 0: B ! P(A) given by (x 2 B ) f 0 (x) := f hfxgi: Since f is a function and then by ran(f ) = B we get f 00  f = ran(f )jid = B jid: Thus f 00::B !A is a section of f ::A!B . ((3) )S (4)) ) Axiom of Choice: Assume g: B ! P(V ) with 8x 2 B : g(x) 6= ;: De ne A := x2B (fxgg(x)) and the surjective f : A ! B by f (x; y) := x . If this is supposed to imply that f ::A!B is split-epi, then there must be a section f 0::B !A of f ::A!B . De ne h: A ! V by h(x; y) := y . Now f 0  h is a function choice function of g. Indeed, for x 2 B we get f (f 0(x)) = x; f 0(x) 2 fxg g(x); and h(f 0(x)) 2 g(x):

13

Lemma 4.12

In the partial function category 9 FUN of sets the following items are logically equivalent for f ::A!B : (1) f ::A!B is split-monic. (2) f ::A!B is monic. (3) f : A ; B is injective and dom(f ) = A .

Proof of Lemma 4.12 (1) ) (2): By Lemma 4.7. (2) ) (3): If f were not total on A, there would be an a 2 Andom(f ). Thus, fagjidf = ;f and fagjid = 6 ;; which contradicts (2) due to fagjid::A!A and ;::A!A. Thus, f ::A!B is also in SET. Since SET is a sub-category of FUN and f ::A!B is monic in FUN, f ::A!B is also monic in SET. By Lemma 4.10, we conclude that f is injective. (3) ) (1): For injective f : A ; B we get f ?1 ::B !A and f  f ?1 = FUNIdA .

dom(f )jid

= Ajid =

Lemma 4.13 In the partial function category 9 FUN of sets the following items are logically equivalent for f ::A!B : (1) f ::A!B is epi. (2) f : A ; B is surjective (i.e. ran(f ) = B ).

Furthermore, (1) and (2) are implied by (3) f ::A!B is split-epi. \ (1) ) (3)", however, is equivalent to the set-version of (the function choice function version of) the Axiom of Choice.

Proof of Lemma 4.13 (1) ) (2): If ran(f ) 6= B; there would be some b 2 B nran(f ). De ne g; h::B !f0; 1g by g(b) := 1; g(x) := 0 for x 2 B nfbg, and h(x) := 0 for x 2 B . Thus, f  g = f  h and g= 6 h; which contradicts the assumption that f ::A!B is epi. (2) ) (1): Assume g; h::B !C with f  g = f  h: Since f is a function and then by (2) we get f ?1  f = ran(f )jid = B jid: Thus g = B jid  g = f ?1  f  g = f ?1  f  h = B jid  h = h: (3) ) (1): By Lemma 4.7.

Logical equivalence with the Axiom of Choice: The proof for this does not di er from the respective part of the proof of Lemma 4.11. 9 Cf. Ex. 2.7.

14

5 Algebras De nition 5.1 (Signature)

A signature (S; F ; rt) consists of  a set of sorts S and  an S-sorted family F = (F s)s2S of sets F s of function symbols with argument sort s, and a  a result-type function rt: F s ! S: s2S

Example 5.2 (Signature) Set S := f1, zero, posnat, emptylist, nonemptylist, zero+posnat, zero+posnat+1, emptylist+nonemptylistg.

Note that 1 is included in S in order to model the range of \unde ned" function applications. Set F ; := f0; nilg; F zero := fsg; F posnat := fs; pg; F emptylist := flengthg; F nonemptylist := flength; car; cdrg; F zero zero := F zero posnat := F posnat posnat := f+; {g; F posnat zero := F emptylist emptylist := F emptylist nonemptylist := F nonemptylist emptylist := F nonemptylist nonemptylist := f+g; F zero emptylist := F zero nonemptylist := F posnat emptylist := F posnat nonemptylist := fconsg; and F s := ; for any other s 2 S. Set rt(;; 0) := rt(emptylist; length) := rt(zero zero; +) := rt(zero zero; {) := zero; rt(zero; s) := rt(posnat; s) := rt(nonemptylist; length) := rt(zero posnat; +) := rt(posnat zero; +) := rt(posnat posnat; +) := rt(posnat zero; {) := posnat; rt(posnat; p) := rt(nonemptylist; car) := zero+posnat; rt(posnat posnat; {) := zero+posnat+1; rt(;; nil) := rt(emptylist emptylist; +) := emptylist; rt(emptylist nonemptylist; +) := rt(nonemptylist emptylist; +) := rt(nonemptylist nonemptylist; +) := rt(zero emptylist; cons) := rt(zero nonemptylist; cons) := rt(posnat emptylist; cons) := rt(posnat nonemptylist; cons) := nonemptylist; and rt(nonemptylist; cdr) := emptylist+nonemptylist:

15 The following de nition is classical.

De nition 5.3 ((S; F ; rt)-Algebra)

Let (S; F ; rt) be a signature. A (total) (S; F ; rt)-algebra consists of  a family A = (As )s 2S of non-empty sets (\universes") and,  for each (s; f ) 2 `s2S F s, a function Y (s; f )A : As ! Art(s;f ): 0

0

i jsj

i

Example 5.4

Let (S; F ; rt) be the signature of Ex. 5.2. Set A1 := f!g; Azero := f0g; Aposnat := IN+; Aemptylist := f;g; Anonemptylist := IN+ ; and Azero+posnat := Azero ] Aposnat; Azero+posnat+1 := Azero+posnat ] A1; Aemptylist+nonemptylist :=

Aemptylist ] Anonemptylist: For x; y 2 IN and k; l 2 IN de ne: (;; 0)A(;) := 0; (;; nil)A(;) := ;; A A (zero; s) (x) := (posnat; s) (x) := x+1; (emptylist; length)A (l) := (nonemptylist; length)A(l) := jlj ; (zero zero; +)A(x; y) := (zero posnat; +)A(x; y) := (posnat zero; +)A(x; y) := (posnat posnat; +)A (x; y) := x+y; (posnat; p)A(x+1) := (posnat zero; {)A(x; 0) := (nonemptylist; car)A(xl) := x; (posnat posnat; {)A(x; y) := x?y for x  y; (posnat posnat; {)A(x; y) := ! for x  y; (emptylist emptylist; +)A(k; l) := (emptylist nonemptylist; +)A(k; l) := (nonemptylist emptylist; +)A (k; l) := (nonemptylist nonemptylist; +)A (k; l) := kl; (zero emptylist; cons)A(x; l) := (zero nonemptylist; cons)A(x; l) := (posnat emptylist; cons)A(x; l) := (posnat nonemptylist; cons)A(x; l) := xl; and (nonemptylist; cdr)A(xl) := l . Note that the signature of Ex. 5.2 is rather dull because s(p(s(s(0)))) is not a term although we can evaluate it: p(s(s(0))) has the sort zero+posnat and we have F zero+posnat = ;: Note that a signature cannot properly model functions with di erent range sorts for a single argument sort. This will be di erent with co-signatures in the next section.

16 While the notion of an algebra given in Def. 5.3 is nice, it is not very well suited for category theory. The rst step for coming to the categorical de nition of an algebra is to encode (S; F ; rt) into the following functor ((Obj; Mor); SORT(S); SORT(S)) from the category SORT(S) of S-sorted sets10 into itself: a Y (A)s := As 0

(s;f )2rthfs gi

i

i jsj

0

for A 2 SORT( )Obj and s0 2 S, and     (s; f ); (hs (ai))i jsj (h )s (s; f ); (ai)i jsj := for h::A!B in SORT(S); s0 2 S; (s; f ) 2 rthfs0gi; 8i  jsj : ai 2 As : Now we can categorically represent the above algebra over (F ; S; rt) as the arrow ( ; A; A) 2 SORT( )Arr given by s ((s; f ); a) := (s; f )A(a) for ((s; f ); a) 2 (A)s : S

0

i

i

S

0

0

De nition 5.5 (-Algebras and -Homomorphisms)

Let : SORT(S)  SORT(S). A -algebra is an arrow ( ; A; A) 2 SORT( )Arr with 8s 2 S: As 6= ;: Let ( ; A; A) and ( ; B ; B ) be -algebras. A -homomorphism from ( ; A; A) to ( ; B ; B ) is a morphism h::A!B in SORT(S) such that h is compatible with  in the sense that SORT( ) h = h SORT( ) : A  > B  = S

S

S

h

_

A

h

_

>B

Note that for  de ned from (S; F ; rt) as above, the latter condition means that for s0 2 S; (s; f ) 2 rthfs0gi; 8i  jsj : ai 2 As :      hs s (s; f ); (ai)i jsj = s (s; f ); (hs (ai))i jsj ; i.e.      = (s; f )B (hs (ai))i jsj : hs (s; f )A (ai)i jsj i

0

0

0

0

i

i

De nition 5.6 (ALG)

The -homomorphism category ALG of -algebras is given as follows: ALGObj is the class of all -algebras. ALGMor( ;A;A);( ;B ;B ) is the class of all -homomorphisms h::A!B . h ALG k := h SORT( ) k for h 2 ALGMor( ;A;A);( ;B;B) and h 2 ALGMor( ;B;B);( ;C;C). ALGId( ;A;A) := SORT( )IdA . S

S

Note that, while the morphisms of ALG are also morphisms of SORT(S) and their composition is the same, ALG is no sub-category of SORT(S) because the objects of ALG are no objects of SORT(S). 10Cf. Ex.2.9.

17

6 Co-Algebras De nition 6.1 (Co-Signature)

A co-signature (S; F ; rt) consists of  a set of sorts S and  an S-sorted family F = (F s )s2S of sets F s of function symbols with argument sort s, and a  a result-type function rt: F s ! PIN+(S): s2S

Example 6.2 (Co-Signature) Set S := f1, zero, posnat, emptylist, nonemptylistg [Pnat [ Plist [ Q; Pnat := fzerozero, zeroposnat, posnatzero, posnatposnatg; Plist := femptylistemptylist, emptylistnonemptylist, nonemptylistemptylist, nonemptylistnonemptylistg; and Q := fzeroemptylist, zerononemptylist, posnatemptylist, posnatnonemptylistg.

Note that 1 is included in Sin order to model the domain of nullary functions and the range of \unde ned" function applications. Set F 1 := f0; nilg; F zero := fsg; F posnat := fs; pg; F emptylist := flengthg; F nonemptylist := flength; car; cdrg; F zerozero := F posnatzero := F posnatposnat := f+; {g; F zeroposnat := F s := f+g for s 2 Plist ; and F s := fconsg for s 2 Q. Set rt(1; 0) := rt(emptylist; length) := rt(zerozero; +) := rt(zerozero; {) := fzerog; rt(zero; s) := rt(posnat; s) := rt(nonemptylist; length) := rt(zeroposnat; +) := rt(posnatzero; +) := rt(posnatposnat; +) := rt(posnatzero; {) := fposnatg; rt(posnat; p) := rt(nonemptylist; car) := fzero; posnatg; rt(posnatposnat; {) := f1; zero; posnatg; rt(1; nil) := rt(emptylistemptylist; +) := femptylistg; rt(emptylistnonemptylist; +) := rt(nonemptylistemptylist; +) := rt(nonemptylistnonemptylist; +) := rt(s; cons) := fnonemptylistg for s 2 Q; and rt(nonemptylist; cdr) := femptylist; nonemptylistg:

18

De nition 6.3 ((S; F ; rt)-Co-Algebra)

Let (S; F ; rt) be a co-signature. A (S; F ; rt)-co-algebra consists of  a family A = (As)s2S of non-empty sets (\universes") and,  for each (s; f ) 2 `s2SF s , a function a (s; f )A: As ! As : s 2rt(s;f )

0

0

Example 6.4

Let (S; F ; rt) be the co-signature of Ex. 6.2. Set A1 := f!g; Azero := f0g; Aposnat := IN+; Aemptylist := f;g; Anonemptylist := IN+ ; and Ast := As  At for st 2 Pnat [ Plist [ Q. For x; y 2 IN and k; l 2 IN de ne: (1; 0)A(!) := (posnat; p)A(1) := (emptylist; length)A(;) := (zerozero; +)A (0; 0) := (zerozero; {)A(0; 0) := (posnatposnat; {)A(x; x) := (nonemptylist; car)A (0l) := (zero; 0); (1; nil)A(!) := (emptylistemptylist; +)A(;; ;) := (nonemptylist; cdr)A(x) := (emptylist; ;); (zero; s)A (x) := (posnat; s)A (x) := (posnat; x+1); (nonemptylist; length)A (l) := (posnat; jlj ); (zeroposnat; +)A(x; y) := (posnatzero; +)A(x; y) := (posnatposnat; +)A(x; y) := (posnat; x+y); (posnat; p)A (x+1) := (posnatzero; {)A(x; 0) := (nonemptylist; car)A (xl) := (posnat; x) for x 2 IN+ ; (posnatposnat; {)A(x; y) := (posnat; x?y) for x  y; (posnatposnat; {)A(x; y) := (1; !) for x  y; (emptylistnonemptylist; +)A (k; l) := (nonemptylistemptylist; +)A(k; l) := (nonemptylistnonemptylist; +)A(k; l) := (nonemptylist; kl); A (s; cons) (x; l) := (nonemptylist; xl); and (nonemptylist; cdr)A (xl) := (nonemptylist; l) for l 2 IN+ . Note that the co-signature of Ex. 6.2 is rather dull because we cannot add three natural numbers: The co-signature does not know that the result of the rst addition can be paired with a natural number in order to add it. Actually, we cannot even add two natural numbers, but the sorts in Pnat have hidden this. Note that a co-signature cannot contain pairing functions because they always need more than one argument.

19 While the notion of a co-algebra given in Def. 6.3 is nice, it is not very well suited for category theory. The rst step for coming to the categorical de nition of a co-algebra is to encode (S; F ; rt) into the following functor ((Obj; Mor); SORT(S); SORT(S)) from the category SORT(S) of S-sorted sets11 into itself: Y a (A)s := As f 2F s 2rt(s;f ) for A 2 SORT( )Obj and s 2 S, and   := (s0f ; hs (a0f ))f 2F (h )s (s0f ; a0f )f 2F for h::A!B in SORT(S); s 2 S; 8f 2 F s : (s0f 2 rt(s; f ) ^ a0f 2 As ): Now we can categorically represent the above co-algebra over (F ; S; rt) as the arrow ( ; A; A) 2 SORT( )Arr given by s(a)f := (s; f )A(a) for a 2 As and f 2 F s. 0

s

0

S

0 f

s

s

0 f

S

De nition 6.5 (-Co-Algebras and -Co-Homomorphisms) Let : SORT(S)  SORT(S). A -co-algebra is an arrow ( ; A; A) 2 SORT( )Arr with 8s 2 S: As 6= ;: Let ( ; A; A) and ( ; B; B ) be -co-algebras. A -co-homomorphism from ( ; A; A) to ( ; B; B ) is a morphism h::A!B in SORT(S) such that h is compatible with  in the sense that SORT( ) h  = h SORT( ) : S

S

A



_

A

h

= h



S

>B



_

> B

Note that for  de ned from (S; F ; rt) as above, the latter condition means that for s 2 S; f 2 F s; a 2 As; and    0  for (s0; a0) := s(a)f : s ; hs (a0) = s hs(a) f , i.e.    0  for (s0; a0) := (s; f )A(a): s ; hs (a0) = (s; f )B hs(a) . 0

0

De nition 6.6 (COALG)

The -co-homomorphism category COALG of -co-algebras is given as follows: COALGObj is the class of all -co-algebras. COALGMor( ;A;A);( ;B;B ) is the class of all -co-homomorphisms h::A!B . h COALG k := h SORT( ) k for h 2 COALGMor( ;A;A);( ;B;B) and h 2 COALGMor( ;B;B);( ;C;C). COALGId( ;A;A) := SORT( )IdA . S

S

Note that, while the morphisms of COALG are also morphisms of SORT(S) and their composition is the same, COALG is no sub-category of SORT(S) because the objects of COALG are no objects of SORT(S). 11Cf. Ex. 2.9.

20

7 Di-Algebras De nition 7.1 (Di-Signature)

A di-signature (S; F ; rt) consists of  a set of sorts S and  an S-sorted family F = (F s)s2S of sets F s of function symbols with argument sort s, and a  a result-type function rt: F s ! PIN+(S): s2S

Example 7.2 (Di-Signature) Set S := f1, zero, posnat, emptylist, nonemptylistg.

Note that 1 is included in S in order to model the range of \unde ned" function applications. Set F ; := f0; nilg; F zero := fsg; F posnat := fs; pg; F emptylist := flengthg; F nonemptylist := flength; car; cdrg; F zero zero := F zero posnat := F posnat posnat := f+; {g; F posnat zero := F emptylist emptylist := F emptylist nonemptylist := F nonemptylist emptylist := F nonemptylist nonemptylist := f+g; F zero emptylist := F zero nonemptylist := F posnat emptylist := F posnat nonemptylist := fconsg; and F s := ; for any other s 2 S. Set rt(;; 0) := rt(emptylist; length) := rt(zero zero; +) := rt(zero zero; {) := fzerog; rt(zero; s) := rt(posnat; s) := rt(nonemptylist; length) := rt(zero posnat; +) := rt(posnat zero; +) := rt(posnat posnat; +) := rt(posnat zero; {) := fposnatg; rt(posnat; p) := rt(nonemptylist; car) := fzero; posnatg; rt(posnat posnat; {) := fzero; posnat; 1g; rt(;; nil) := rt(emptylist emptylist; +) := femptylistg; rt(emptylist nonemptylist; +) := rt(nonemptylist emptylist; +) := rt(nonemptylist nonemptylist; +) := rt(zero emptylist; cons) := rt(zero nonemptylist; cons) := rt(posnat emptylist; cons) := rt(posnat nonemptylist; cons) := fnonemptylistg; and rt(nonemptylist; cdr) := femptylist; nonemptylistg:

21

De nition 7.3 ((S; F ; rt)-Di-Algebra)

Let (S; F ; rt) be a di-signature. A (S; F ; rt)-di-algebra consists of  a family A = (As)s2S of non-empty sets (\universes") and,  for each (s; f ) 2 `s2SF s, a functionY a (s; f )A: As ! As : i jsj

i

s 2rt(s;f )

0

0

Example 7.4

Let (S; F ; rt) be the di-signature of Ex. 7.2. Set A1 := f!g; Azero := f0g; Aposnat := IN+; Aemptylist := f;g; Anonemptylist := IN+: For x; y 2 IN and k; l 2 IN de ne: (;; 0)A (!) := (posnat; p)A(1) := (emptylist; length)A(;) := (zero zero; +)A (0; 0) := (zero zero; {)A(0; 0) := (posnat posnat; {)A(x; x) := (nonemptylist; car)A(0l) := (zero; 0); (;; nil)A(!) := (emptylist emptylist; +)A(;; ;) := (nonemptylist; cdr)A(x) := (emptylist; ;); (zero; s)A(x) := (posnat; s)A(x) := (posnat; x+1); (nonemptylist; length)A(l) := (posnat; jlj ); (zero posnat; +)A(x; y) := (posnat zero; +)A (x; y) := (posnat posnat; +)A(x; y) := (posnat; x+y); (posnat; p)A(x+1) := (posnat zero; {)A(x; 0) := (nonemptylist; car)A(xl) := (posnat; x) for x 2 IN+; A (posnat posnat; {) (x; y) := (posnat; x?y) for x  y; (posnat posnat; {)A(x; y) := (1; !) for x  y; (emptylist nonemptylist; +)A(k; l) := (nonemptylist emptylist; +)A (k; l) := (nonemptylist nonemptylist; +)A (k; l) := (nonemptylist; kl); (s; cons)A(x; l) := (nonemptylist; xl); and (nonemptylist; cdr)A(xl) := (nonemptylist; l) for l 2 IN+. Note that the di-signature of Ex. 7.2 is rather ne because the problems with the cosignature of Ex. 6.2 and the problems with the signature of Ex. 5.2 are both overcome. On the one hand, we can now add three natural numbers: The di-signature does know that the result of the rst addition can be paired with a natural number in order to add it. On the other hand, s(p(s(s(0)))) is a term w.r.t. the di-algebra of Ex. 7.4 because p(s(s(0))) has the sort posnat. Note, however, that in order to tell whether s(p(s(s(0)))) really denotes something we have to know to which speci c di-algebra the question refers. The di-signature must accept s(p(s(s(0)))) as a term without knowing whether it denotes something. This problem of di-signatures already exists for co-signatures. While the notion of a di-algebra given in Def. 7.3 is nice, it is not very well suited for category theory. The rst step for coming to the categorical de nition of a di-algebra is to encode (S; F ; rt) into the following two functors ((?Obj ; ?Mor); SORT(S); SORT(S)) and ((Obj; Mor); SORT(S); SORT(S)) from the category SORT(S) of S-sorted sets into the category SORT(S) of S-sorted sets:

22

Y (A?)s := As Y i jsj a (A)s := As f 2 F s 2 rt( s;f )   (h?)s (ai)i jsj  := (hs (ai))i jsj := (s0f ; hs (a0f ))f 2F (h)s (s0f ; a0f )f 2F for A 2 SORT( )Obj; h::A!B in SORT(S); s 2 S; 8i  jsj : ai 2 As ; and 8f 2 F s : (s0f 2 rt(s; f ) ^ a0f 2 As ): Now we can categorically represent the above di-algebra over (F ; S; rt) using the morphism ::A?!A in SORT(S) given by s(a)f := (s; f )A(a) for a 2 As and f 2 F s. While the de nition of a -algebra is standard and the de nition of a ?-co-algebra is its dual, the de nition of a (?; )-di-algebra below is our invention. i

0

0

s

i

0 f

s

s

S

i

0 f

De nition 7.5 ((?; )-Di-Algebras and (?; )-Di-Homomorphisms) (Cf. Fokkinga (1996).) Let ?; : SORT(S)  SORT(S). A (?; )-di-algebra is a pair (A; ) with A 2 SORT( )Obj; 8s 2 S: As = 6 ;; and ::A?!A  in SORT(S ). S

Let (A; ) and (B; ) be (?; )-di-algebras. A (?; )-di-homomorphism from (A; ) to (B; ) is a morphism h::A!B in SORT(S) such that h is compatible with (?; ) in the sense that SORT( ) h = h? SORT( ) : A? ? > B ? = _ _ A  > B  S

S

h

h

Note that for (?; ) de ned from (S; F ; rt) as above, the latter condition means that for s 2 S; f 2 F s ; 8i  jsj : ai 2 As ; and  0      s ; hs (a0) = s (hs (a)i )i jsj f , for (s0; a0) := s (ai)i jsj f : i.e.       0 s ; hs (a0) = (s; f )B (hs (ai))i jsj . for (s0; a0) := (s; f )A (ai)i jsj : i

0

0

i

i

De nition 7.6 (SUALG)

The (?; )-di-homomorphism category SUALG of (?; )-di-algebras is given as follows: SUALGObj is the class of all (?; )-di-algebras. SUALGMor(A; );(B; ) is the class of all (?; )-di-homomorphisms h::A!B . h SUALG k := h SORT( ) k for h 2 SUALGMor(A; );(B; ) and h 2 SUALGMor(B; );(C; ). SUALGId(A; ) := SORT( )IdA . S

S

Note that, while the morphisms of SUALG are also morphisms of SORT(S) and their composition is the same, SUALG is no sub-category of SORT(S) because the objects of SUALG are no objects of SORT(S).

23

References Maarten M. Fokkinga (1996). Datatype Lawes without Signatures. Math. Struct. in Comp. Sci. 6, pp. 1-32, Cambridge Univ. Press.