Functors and Natural Transformations

Functors and Natural Transformations

Functors and natural transformations functors ; category morphisms natural transformations ; functor morphisms Andrzej Tarlecki: Category Theory, 2018 - 90 - Functors A functor F: K ! K0 from a category K to a category K0 consists of: • a function F: jKj ! jK0j, and • for all A; B 2 jKj, a function F: K(A; B) ! K0(F(A); F(B)) such that: Make explicit categories in which we work at various places here • F preserves identities, i.e., F(idA) = idF(A) for all A 2 jKj, and • F preserves composition, i.e., F(f;g) = F(f);F(g) for all f : A ! B and g : B ! C in K. We really should differentiate between various components of F Andrzej Tarlecki: Category Theory, 2018 - 91 - Examples • identity functors: IdK : K ! K, for any category K 0 0 • inclusions: IK,!K0 : K ! K , for any subcategory K of K 0 0 0 • constant functors: CA : K ! K , for any categories K; K and A 2 jK j, with CA(f) = idA for all morphisms f in K • powerset functor: P: Set ! Set given by − P(X) = fY j Y ⊆ Xg, for all X 2 jSetj − P(f): P(X) ! P(X0) for all f : X ! X0 in Set, P(f)(Y ) = ff(y) j y 2 Y g for all Y ⊆ X op • contravariant powerset functor: P−1 : Set ! Set given by − P−1(X) = fY j Y ⊆ Xg, for all X 2 jSetj 0 0 − P−1(f): P(X ) ! P(X) for all f : X ! X in Set, 0 0 0 0 P−1(f)(Y ) = fx 2 X j f(x) 2 Y g for all Y ⊆ X Andrzej Tarlecki: Category Theory, 2018 - 92 - Examples, cont'd. 0 0 0 • projection functors: π1 : K × K ! K, π2 : K × K ! K • list functor: List: Set ! Monoid, where Monoid is the category of monoids (as objects) with monoid homomorphisms as morphisms: ∗ ∗ − List(X) = hX ; b; i, for all X 2 jSetj, where X is the set of all finite lists of elements from X, b is the list concatenation, and is the empty list. − List(f): List(X) ! List(X0) for f : X ! X0 in Set, List(f)(hx1; : : : ; xni) = hf(x1); : : : ; f(xn)i for all x1; : : : ; xn 2 X • totalisation functor: Tot: Pfn ! Set∗, where Set∗ is the subcategory of Set of sets with a distinguished element ∗ and ∗-preserving functions − Tot(X) = X ] f∗g Define Set∗ as the category of algebras 8 < f(x) if it is defined − Tot(f)(x) = : ∗ otherwise Andrzej Tarlecki: Category Theory, 2018 - 93 - Examples, cont'd. • carrier set functors: j j: Alg(Σ) ! SetS, for any algebraic signature Σ = hS; Ωi, yielding the algebra carriers and homomorphisms as functions between them 0 • reduct functors: σ : Alg(Σ ) ! Alg(Σ), for any signature morphism σ :Σ ! Σ0, as defined earlier • term algebra functors: TΣ : Set ! Alg(Σ) for all (single-sorted) algebraic signatures Σ 2 jAlgSigj Generalise to many-sorted signatures − TΣ(X) = TΣ(X) for all X 2 jSetj # 0 0 − TΣ(f) = f : TΣ(X) ! TΣ(X ) for all functions f : X ! X G G • diagonal functors: ∆K : K ! DiagK for any graph G with nodes N = jGjnodes and edges E = jGjedges , and category K G A A A − ∆K(A) = D , where D is the \constant" diagram, with Dn = A for all A n 2 N and De = idA for all e 2 E G f A B f − ∆K(f) = µ : D ! D , for all f : A ! B, where µn = f for all n 2 N Andrzej Tarlecki: Category Theory, 2018 - 94 - Hom-functors Given a locally small category K, define op HomK : K × K ! Set a binary hom-functor, contravariant on the first argument and covariant on the second argument, as follows: op • HomK(hA; Bi) = K(A; B), for all hA; Bi 2 jK × Kj, i.e., A; B 2 jKj 0 0 0 0 • HomK(hf; gi): K(A; B) ! K(A ;B ), for hf; gi: hA; Bi ! hA ;B i in Kop × K, i.e., f : A0 ! A and g : B ! B0 in K, as a function given by Hom (hf; gi)(h) = f;h;g. f K A 0 A K(A; B) h K(A0;B0) ? g ? B -B0 Also: HomK(A; ): K ! Set op HomK(f; g) 6 HomK( ;B): K ! Set Andrzej Tarlecki: Category Theory, 2018 - 95 - Functors preserve. • Check whether functors preserve: − monomorphisms − epimorphisms − (co)retractions − isomorphisms − (co)cones − (co)limits − ... • A functor is (finitely) continuous if it preserves all existing (finite) limits. Which of the above functors are (finitely) continuous? Dualise! Andrzej Tarlecki: Category Theory, 2018 - 96 - Functors compose. Given two functors F: K ! K0 and G: K0 ! K00, their composition F;G: K ! K00 is defined as expected: • (F;G)(A) = G(F(A)) for all A 2 jKj • (F;G)(f) = G(F(f)) for all f : A ! B in K Cat, the category of (sm)all categories − objects: (sm)all categories − morphisms: functors between them − composition: as above Characterise isomorphisms in Cat Define products, terminal objects, equalisers and pullback in Cat Try to define their duals Andrzej Tarlecki: Category Theory, 2018 - 97 - Comma categories Given two functors with a common target, F: K1 ! K and G: K2 ! K, define their comma category (F; G) − objects: triples hA1; f : F(A1) ! G(A2);A2i, where A1 2 jK1j, A2 2 jK2j, and f : F(A1) ! G(A2) in K − morphisms: a morphism in (F; G) is any pair hh1; h2i: hA1; f : F(A1) ! G(A2);A2i ! hB1; g : F(B1) ! G(B2);B2i, where h1 : A1 ! B1 in K1, h2 : A2 ! B2 in K2, and F(h1);g = f;G(h2) in K. K1: K: K2: f - − composition: component-wise A1 F(A1) G(A2) A2 h1 F(h1) G(h2) h2 ? ? g ? ? B1 F(B1) - G(B2) B2 Andrzej Tarlecki: Category Theory, 2018 - 98 - Examples • The category of graphs as a comma category: Graph = (IdSet; CP) where CP: Set ! Set is the (Cartesian) product functor (CP(X) = X × X and CP(f)(hx; x0i) = hf(x); f(x0)i). Hint: write objects of this category as hE; hsource; targeti: E ! N × N;Ni • The category of algebraic signatures as a comma category: + AlgSig = (IdSet; ( ) ) where ( )+ : Set ! Set is the non-empty list functor ((X)+ is the set of all + non-empty lists of elements from X, (f) (hx1; : : : ; xni) = hf(x1); : : : ; f(xn)i). Hint: write objects of this category as hΩ; harity; sorti:Ω ! S+;Si Define K!, K#A as comma categories. The same for Alg(Σ). Andrzej Tarlecki: Category Theory, 2018 - 99 - Cocompleteness of comma categories Fact: If K1 and K2 are (finitely) cocomplete categories, F: K1 ! K is a (finitely) cocontinuous functor, and G: K2 ! K is a functor then the comma category (F; G) is (finitely) cocomplete. Proof (idea): Construct coproducts and coequalisers in (F; G), using the corresponding constructions in K1 and K2, and cocontinuity of F. State and prove the dual fact, concerning completeness of comma categories Andrzej Tarlecki: Category Theory, 2018 - 100 - Coproducts: f A1 F(A1) - G(A2) A2 ιA1 ¡ A ¡ A ιA2 F(ιA1 ) G(ιA2 ) ¡ ¡ AAU ¡ ¡ AAU A1 + B1 F(A1 + B1) - G(A2 + B2) A2 + B2 AK ¡ AK ¡ A F(ιB )¡ AG(ιB ) ¡ ιB1 1 2 ιB2 A ¡ g A ¡ B1 F(B1) - G(B2) B2 Coequalisers: f A1 F(A1) - G(A2) A2 0 0 0 0 h1 h1 F(h1) F(h1) G(h2) G(h2) h2 h2 ?? ?? g ?? ?? B1 F(B1) - G(B2) B2 c1 F(c1) G(c2) c2 ? ? ? ? C1 F(C1) - G(C2) C2 Andrzej Tarlecki: Category Theory, 2018 - 101 - Indexed categories An indexed category is a functor C : Indop ! Cat . Standard example: Alg: AlgSigop ! Cat The Grothendieck construction: Given C : Indop ! Cat, define a category Flat(C): − objects: hi; Ai for all i 2 jIndj, A 2 jC(i)j − morphisms: a morphism from hi; Ai to hj; Bi, hσ; fi: hi; Ai ! hj; Bi, consists of a morphism σ : i ! j in Ind and a morphism f : A !C(σ)(B) in C(i) − composition: given hσ; fi: hi; Ai ! hi0;A0i and hσ0; f 0i: hi0;A0i ! hi00;A00i, their composition in Flat(C), hσ; fi;hσ0; f 0i: hi; Ai ! hi00;A00i, is given by hσ; fi;hσ0; f 0i = hσ;σ0; f;C(σ)(f 0)i Fact: If Ind is complete, C(i) are complete for all i 2 jIndj, and C(σ) are continuous for all σ : i ! j in Ind, then Flat(C) is complete. Try to formulate and prove a theorem concerning cocompleteness of Flat(C) Andrzej Tarlecki: Category Theory, 2018 - 102 - Natural transformations Given two parallel functors F; G: K ! K0, a natural transformation from F to G τ : F ! G 0 is a family τ = hτA : F(A) ! G(A)iA2jKj of K -morphisms such that for all f : A ! B in K (with A; B 2 jKj), τA;G(f) = F(f);τB K: K0: τ A F(A) A - G(A) f F(f) G(f) Then, τ is a natural isomorphism if for ? ? ? τB all A 2 jKj, τA is an isomorphism. B F(B) - G(B) Andrzej Tarlecki: Category Theory, 2018 - 103 - Examples 0 • identity transformations: idF : F ! F, where F: K ! K , for all objects A 2 jKj, (idF)A = idA : F(A) ! F(A) • singleton functions: sing : IdSet ! P (: Set ! Set), where for all X 2 jSetj, singX : X ! P(X) is a function defined by singX (x) = fxg for x 2 X List • singleton-list functions: sing : IdSet ! jListj (: Set ! Set), where jListj = List;j j: Set(! Monoid) ! Set, and for all X 2 jSetj, List ∗ List singX : X ! X is a function defined by singX (x) = hxi for x 2 X • append functions: append : jListj;CP ! jListj (: Set ! Set), where for all ∗ ∗ ∗ X 2 jSetj, append X :(X × X ) ! X is the usual append function (list concatenation) polymorphic functions between algebraic types Andrzej Tarlecki: Category Theory, 2018 - 104 - Polymorphic functions Work out the following generalisation of the last two examples: − for each algebraic type scheme 8α1 : : : αn · T , built in Standard ML using at least products and algebraic data types (no function types though), define the corresponding functor [[T ]]: Setn ! Set − argue that in a representative subset of Standard ML, for each polymorphic 0 expression E : 8α1 : : : αn · T ! T its semantics is a natural transformation [[E]]: [[T ]] ! [[T 0]] Theorems for free! (see Wadler 89) Andrzej Tarlecki: Category Theory, 2018 - 105 - Yoneda lemma Given a locally small category K, functor F: K ! Set and object A 2 jKj: ∼ Nat(HomK(A; ); F) = F(A) natural transformations from HomK(A; ) to F, between functors from K to Set, are given exactly by the elements of the set F(A) EXERCISES: • Dualise: for G: Kop ! Set, ∼ Nat(HomK( ;A); G) = G(A) .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    26 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us