elements of category theory
play

Elements of Category Theory Robin Cockett Department of Computer - PowerPoint PPT Presentation

Elements of Category Theory Robin Cockett Department of Computer Science University of Calgary Alberta, Canada robin@cpsc.ucalgary.ca Estonia, Feb. 2010 Functors and natural transformations Adjoints and Monads Limits and colimits Pullbacks


  1. Elements of Category Theory Robin Cockett Department of Computer Science University of Calgary Alberta, Canada robin@cpsc.ucalgary.ca Estonia, Feb. 2010

  2. Functors and natural transformations Adjoints and Monads Limits and colimits Pullbacks

  3. FUNCTORS A functor is a map of categories F : X − → Y which consists of a map F 0 of the objects and a map F 1 of the maps (we shall drop these subscripts) such that ◮ ∂ 0 ( F ( f )) = F ( ∂ 0 ( f )) and ∂ 1 ( F ( f )) = F ( ∂ 1 ( f )): f X − − → Y F ( X ) − − − − → F ( Y ) F ( f ) ◮ F (1 A ) = 1 F ( A ) , identity maps are preserved. ◮ F ( fg ) = F ( f ) F ( g ), composition is preserved. Every category has an identity functor. Composition of functors is associative. Thus: Lemma Categories and functors form a category Cat .

  4. � � � � � � EXAMPLES OF Set FUNCTORS ◮ The product (with A ) functor ( x , a ) X × A X � × A : Set − → Set; �→ f f × 1 Y ( f ( x ) , a ) Y × A ◮ The exponential functor: X A ⇒ X h � A ⇒ : Set − → Set; �→ f A ⇒ f Y A ⇒ Y hf

  5. � � � � � � EXAMPLES OF Set FUNCTORS ◮ List on A ( data L(A) = Nil | Cons A L(A) ) L( X ) [ x 1 , x 2 , ... ] X � L : Set − → Set; �→ L( f ) f Y L( Y ) [ f ( x 1 ) , f ( x 2 ) , ... ] ◮ Trees on A ( data T(A) = Lf A | Node T(A) T(A) ): T( X ) Node ( Lf x 1 )( Lf x 2 ) X � T : Set − → Set; �→ T( f ) f Y T( Y ) Node ( Lf f ( x 1 ))( Lf f ( x 2 ))

  6. � � � � � � EXAMPLES OF Set FUNCTORS ◮ The covariant powerset functor: X ′ ⊆ X P ( X ) X � P : Set − → Set; �→ P ( f ) f f ( X ′ ) ⊆ Y Y P ( Y ) ◮ The contravariant powerset functor: X ′ ⊆ X P ( X ) X � P : Set op − → Set; �→ P ( f ) f Y f − 1 ( X ′ ) ⊆ Y P ( Y ) Note: covariant functors are functors, contravariant functors are functors BUT starting at the dual category.

  7. � � NATURAL TRANSFORMATIONS Given two functors F , G : X − → Y a (natural) transformation α : F ⇒ G is a family of maps in Y α X : F ( X ) − → G ( X ), indexed → X ′ in X by the objects X ∈ X such that for every map f : X − the following diagram commutes: F ( f ) � F ( X ′ ) F ( X ) α X α X ′ � G ( X ′ ) G ( X ) G ( f ) This means that Cat( X , Y ) can be given the structure of a category. In fact, Cat is a Cat-enriched category (a.k.a. a 2-category ). Lemma Cat( X , Y ) is a category with objects functors and maps natural transformations.

  8. � NATURAL TRANSFORMATION EXAMPLE I Consider the category: ∂ 0 TWO = E � N ∂ 0 A functor G : TWO − → Set is precisely a directed graph!! A natural transformation between two functors: α : G 1 − → G 2 : TWO − → Set is precisely a morphism of the directed graphs. α N G 1 ( ∂ i )( f ) = G 2 ( ∂ i )( α E ( f )) .

  9. � � � NATURAL TRANSFORMATION EXAMPLE II Consider the category N op : .... 0 1 2 ∂ ∂ ∂ A functor F : N op − → Set is a forest. The children of a node x ∈ F ( n ) in the forest is given by { x ′ ∈ F ( n + 1) | ∂ ( x ′ ) = x } . A natural transformation between two functors → F 2 : N op − γ : F 1 − → Set is precisely a morphism of forests: γ n ( F 1 ( ∂ )( x )) = F 2 ( ∂ )( γ n +1 ( x )) .

  10. NATURAL TRANSFORMATION ... If functors define structure ... Then natural transformation define the (natural) homomorphisms of that structure ...

  11. � � UNIVERSAL PROPERTY Let G : Y − → X be a functor and X ∈ X , then an object U ∈ Y together with a map η : X − → G ( U ) is a universal pair for the functor G (at the object X ) if for any f : X − → G ( Y ) there is a unique f ♯ : U − → Y such that η X � G ( U ) X � � � � � � G ( f ♯ ) � � f � G ( Y ) commutes.

  12. UNIVERSAL PROPERTY – EXAMPLE I let Graph be the category of directed graphs and Cat the category of categories, let the functor U : Cat − → Graph be the “underlying functor” which forgets the composition structure of a category. The map which takes a directed graph and embeds it into the graph underlying the path category as the singleton paths (paths of length one) a η : G − → U (Path( G )); [ n 1 − − → n 2 ] �→ ( n 1 , [ a ] , n 2 ) has the universal property for this “underlying” functor U .

  13. UNIVERSAL PROPERTY – EXAMPLE cont. Consider a map of directed graphs into the graph underlying a category, h : G − → U ( C ), we can extend it uniquely to a functor from the path category to the category by defining h ♯ : Path( G ) − → C ; ( A , [ a 1 , .., a n ] , B ) �→ h ( a 1 ) .. h ( a n ) : h ( A ) − → h ( B ) This is uniquely determined by h as where the “generating” arrows go determines where the composite arrows go.

  14. � � UNIVERSAL PROPERTY – EXAMPLE ... For those more mathematically inclined: Consider the category of Group then there is an obvious underlying functor U : Group − → Set. The pair ( F ( X ) , η ) where η : X − → U ( F ( X )) is a universal pair for this underlying functor η X � U ( F ( X )) X � � � � � � U ( f ♯ ) � � � f � U ( Y ) The diagram expresses the property of being a “free” group (or more generally “free” algebra).

  15. � � ADJOINT Suppose G : Y − → X has for each X ∈ X a universal pair ( F ( X ) , η X ) so that η X � G ( F ( X )) X � � � � � � G ( f ♯ ) � � � f � G ( Y ) then G is said to be a right adjoint . → X ′ ∈ X then define F ( h ) := ( h η X ′ ) ♯ If h : X − then F is a functor ... F is left adjoint to G . η : 1 X − → FG is a natural transformation ...

  16. � � ADJOINT Furthermore, ǫ Y := (1 G ( Y ) ) ♯ : GF − → 1 Y is a natural transformation η G ( Y ) G ( Y ) G ( F ( G ( X ))) � � � � � � � � � � � U ((1 G ( Y ) ) ♯ ) � � � � � � � � � G ( Y )

  17. � � � ADJOINT This gives the following data (and adjunction ): ( η, ǫ ) : F ⊣ G : X − → Y ◮ F : X − → Y and G : Y − → X functors ◮ η : 1 X − → FG and ǫ : GF − → 1 Y natural transformations ◮ Triangle equalities: η G ( Y ) F ( η X ) � G ( F ( G ( Y ))) G ( Y ) F ( X ) F ( G ( F ( X ))) � � � � � � � � � � � � � � � � � � � � � � ǫ F ( X ) ǫ Y � � � � � � � � � � � � � � � � � � G ( Y ) F ( X ) This data is purely algebraic and is precisely to ask F be left adjoint to G !

  18. ADJOINT Another important characterization: f = g ♭ X − − − − − → G ( Y ) F ( X ) − − − − − → Y g = f ♯ And another important example: cartesian closed categories: f A × X − − → Y X − − − − − − → A ⇒ Y curry( f ) Semantics of the typed λ -calculus.

  19. � � ADJOINT Here is the couniversal property for A ⇒ B : A × Y � � � � � f � � 1 × curry( f ) � � � � � � � � � B A × A ⇒ B eval curry( f ) = y �→ λ a . f ( a , x )

  20. � � � � MONADS (briefly) Given an adjunction ( η, ǫ ) : F ⊣ G : X − → Y consider T := FG we have two transformations: η X : X − → T ( X ) = G ( F ( X )) G ( ǫ F ( X ) ) µ X : T ( T ( X )) − → T ( X ) = G ( F ( G ( F ( X )))) − − − − − − → G ( F ( X )) and one can check these satisfy: η T ( X ) T ( η X ) µ � T ( T ( X )) � T ( T ( X )) T ( X ) T ( X ) T ( T ( T ( X ))) � � � ��������� � ��������� � � � � � � � µ µ T ( µ ) � � � � � � � � T ( X ) T ( X ) T ( T ( X )) µ Such a ( T , η, µ ) is called a monad .

  21. � � � ADJUNCTIONS AND MONADS Any adjunction ( η, ǫ ) : F ⊣ G : X − → Y generates an monad on X and a comonad on Y . Furthermore, every monad arises through an adjunction ... Given a monad T = ( T , η, µ ) on a category X we may construct two categories with underlying right adjoints to X which generate T : the Kleisli category X T and the Eilenberg-Moore category X T so that any U : Y − → X a right adjoint which also generates T sits canonically between these categories: � X T X T Y � � � � � � � � � U � � � � U U � � � � X

  22. MONADS AND EFFECTS Computational effects (exceptions, state, continuations, non-determinism ...) can be generated by using the composition of Kleisli categories. Here is the definition of X T (e.g. think list monad): Objects: X ∈ X Maps: f X − − → T ( Y ) ∈ X f X − − → Y ∈ X T Identities: η X X − − → T ( X ) ∈ X 1 X X − − → X ∈ X T Composition: T ( f ) µ f → T 2 ( Z ) X − − → T ( Y ) − − − − − − → T ( Z ) ∈ X g f X − − → Y − − → Z ∈ X T

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend