หากผมยังไม่สามารถโน้มน้าวให้คุณเชื่อว่า category theory นั้นเกี่ยวกับมอร์ฟิซึมส์ทั้งหมด แสดงว่าผมไม่ได้ทำงานตามควรจะเป็น เนื่องจากหัวข้อถัดไปคือ adjunctions ซึ่งถูกกำหนดในแง่ของ isomorphisms ของ hom-sets จึงสมเหตุสมผลที่จะทบทวนสัญชาติญาณของเราเกี่ยวกับส่วนประกอบพื้นฐานของ hom-sets นอกจากนี้ คุณจะเห็นว่า adjunctions ให้ภาษาทั่วไปมากขึ้นเพื่ออธิบายโครงสร้างจำนวนมากที่เราศึกษามาก่อน ดังนั้นการทบทวนจึงอาจเป็นประโยชน์เช่นกัน
Functors (ฟังก์เตอร์)
ก่อนอื่น ควรคิดว่า functors เป็นการแมปมอร์ฟิซึมส์ — มุมมองที่เน้นในคำจำกัดความของ Functor typeclass ใน Haskell ซึ่งหมุนรอบ fmap แน่นอนว่า functors ยังแมป objects — จุดปลายของมอร์ฟิซึมส์ — มิฉะนั้นเราจะไม่สามารถพูดเกี่ยวกับการ preserve composition ได้ Objects บอกเราว่า pairs ของมอร์ฟิซึมส์ใดที่สามารถ compose ได้ เป้าหมายของมอร์ฟิซึมส์หนึ่งต้องเท่ากับแหล่งที่มาของอีกมอร์ฟิซึมส์หนึ่ง — หากพวกเขาต้องการ compose ดังนั้น หากเราต้องการให้การ compose ของมอร์ฟิซึมส์ถูกแมปไปยังการ compose ของ lifted มอร์ฟิซึมส์ การแมป endpoints ของพวกเขาก็มีการกำหนดไว้ค่อนข้างมาก
Commuting Diagrams (ไดอะแกรมที่สลับสับเปลี่ยนได้)
สมบัติจำนวนมากของมอร์ฟิซึมส์ถูกแสดงออกมาในแง่ของ commuting diagrams หากมอร์ฟิซึมส์เฉพาะอาจถูกอธิบายว่าเป็นการ compose มอร์ฟิซึมส์อื่นๆ ได้มากกว่าหนึ่งวิธี แล้วเรามี commuting diagram
โดยเฉพาะอย่างยิ่ง commuting diagrams สร้างพื้นฐานของเกือบทั้งหมด universal constructions (พร้อมข้อยกเว้นที่เด่นชัดของ initial และ terminal objects) เราได้เห็นสิ่งนี้ในคำจำกัดความของ products, coproducts, various other (co-)limits, exponential objects, free monoids เป็นต้น
Product คือตัวอย่างง่ายๆ ของ universal construction เราเลือก objects สองตัวคือ a และ b และเห็นว่ามี object c พร้อมกับ pairs ของมอร์ฟิซึมส์ p และ q ที่มี universal property ของการเป็น product ของพวกเขาหรือไม่
Product คือกรณีพิเศษของ limit Limit ถูกกำหนดในแง่ของ cones General cone ถูกสร้างจาก commuting diagrams Commutativity ของ diagrams เหล่านั้นอาจถูกแทนที่ด้วย naturality condition ที่เหมาะสมสำหรับการแมป functors ด้วยวิธีนี้ commutativity จะลดลงเหลือบทบาทของ assembly language สำหรับภาษาระดับสูงของ natural transformations
Natural Transformations (การแปลงทางธรรมชาติ)
โดยทั่วไป natural transformations นั้นสะดวกมากเมื่อใดก็ตามที่เราต้องการแมปจาก morphisms ไปยัง commuting squares ด้านตรงข้ามของ naturality square คือการแมป morphism f บางตัวภายใต้ functors F และ G สองตัว ด้านอื่นๆ คือ components ของ natural transformation (ซึ่งเป็น morphisms ด้วย)
Naturality หมายความว่าเมื่อคุณย้ายไป "neighboring" component (โดย neighboring ผมหมายถึง connected by a morphism) คุณจะไม่ไปต่างประเทศกับโครงสร้างของ category หรือ functors ไม่สำคัญว่าคุณจะใช้ component ของ natural transformation เพื่อเติมช่องว่างระหว่าง objects ก่อน จากนั้นกระโดดไปที่ neighbor ด้วย functor หรือในทางกลับกัน ทั้งสองทิศทางเป็น orthogonal A natural transformation ย้ายคุณไปทางซ้ายและขวา และ functors ย้ายคุณขึ้นลงหรือไปกลับมา — พูดง่ายๆ คุณสามารถเห็นภาพ image ของ functor เป็น sheet ใน target category A natural transformation แมป sheet หนึ่ง corresponding to F ไปยังอีกอัน corresponding to G
เราได้เห็น examples ของ orthogonality นี้ใน Haskell ที่นี่ functor action ปรับเปลี่ยนเนื้อหาของ container โดยไม่เปลี่ยนรูปร่าง ในขณะที่ natural transformation สัสวัส repackages เนื้อหาที่ไม่ได้สัมผัสลงใน container ที่แตกต่างกัน ลำดับของการทำงาน นี้ไม่สำคัญ
เราได้เห็น cones ในคำจำกัดความของ limit ถูกแทนที่ด้วย natural transformations Naturality ทำให้ด้านทั้งหมดของทุก cone commute อย่างไรก็ตาม limit ยังคงถูกกำหนดในแง่ของ mappings between cones Mappings เหล่านี้ต้องตอบสนอง commutativity conditions ด้วย (ตัวอย่างเช่น triangles ในคำจำกัดความของ product ต้องทำการเดินทาง)
Conditions เหล่านี้ด้วย อาจถูกแทนที่ด้วย naturality คุณอาจจำได้ว่า universal cone หรือ limit ถูกกำหนดเป็น natural transformation ระหว่าง (contravariant) hom-functor:
F :: c -> C(c, Lim D)
และ (contravariant ด้วย) functor ที่แมป objects ใน C ไปยัง cones ซึ่งตัวมันเองคือ natural transformations:
G :: c -> Nat(Δc, D)
ที่นี่ Δc คือ constant functor และ D คือ functor ที่กำหนด diagram ใน C Functors F และ G ทั้งคู่มี well defined actions บน morphisms ใน C เกิดขึ้นว่า natural transformation เฉพาะ นี้ ระหว่าง F และ G คือ isomorphism
Natural Isomorphisms (ไอโซมอร์ฟิซึมธรรมชาติ)
Natural isomorphism — ซึ่งเป็น natural transformation ที่ทุก component สามารถ reverse ได้ — คือวิธีของ category theory ที่บอกว่า "สองสิ่ง นั้นเหมือนกัน" Component ของการแปลง ดังกล่าว จะต้องเป็น isomorphism ระหว่าง objects — morphism ที่มี inverse หากคุณเห็นภาพ functor images เป็น sheets natural isomorphism คือการแมป one-to-one invertible ระหว่าง sheets เหล่านั้น
Hom-Sets (เซตมอร์ฟิซึมส์)
แต่มอร์ฟิซึมส์คืออะไร? พวกเขามีโครงสร้างมากกว่า objects: ต่างจาก objects มอร์ฟิซึมส์มีปลายสองด้าน แต่หากคุณกำหนด source และ target objects มอร์ฟิซึมส์ระหว่าง ทั้งสองสร้างเป็นเซตที่น่าบ่นน่าร้อง (อย่างน้อยสำหรับ locally small categories) เราสามารถให้ elements ของเซตนี้มีชื่อเช่น f หรือ g เพื่อแยกความแตกต่างหนึ่งจากอีกอัน — แต่จริง ๆ แล้วมันคืออะไร ที่ทำให้พวกเขาแตกต่างกัน?
ความแตกต่างที่ยิ่งใหญ่ระหว่างมอร์ฟิซึมส์ใน hom-set ที่ให้มา อยู่ในวิธีที่พวกเขา compose กับมอร์ฟิซึมส์อื่นๆ (จาก abutting hom-sets) หากมี morphism h ที่มี composition (pre- หรือ post-) กับ f แตกต่างจากสิ่งที่มี g เช่น:
h ∘ f ≠ h ∘ g
แล้วเราสามารถโดยตรง "observe" ความแตกต่างระหว่าง f และ g ได้ แต่แม้ว่าความแตกต่างจะไม่สามารถ observe ได้โดยตรง เราอาจใช้ functors เพื่อ zoom in บน hom-set Functor F อาจแมป morphisms สองตัวไปยัง distinct morphisms:
F f ≠ F g
ในรูปแบบที่ phức tạp ขึ้นที่มี abutting hom-sets ให้ resolution มากขึ้น เช่น
h' ∘ F f ≠ h' ∘ F g
โดยที่ h' ไม่อยู่ใน image ของ F
Hom-Set Isomorphisms (ไอโซมอร์ฟิซึมของเซตมอร์ฟิซึมส์)
Constructions ทางหมวดหมู่จำนวนมากพึ่งพา isomorphisms ระหว่าง hom-sets แต่เนื่องจาก hom-sets เป็นเพียงแค่เซต plain isomorphism ระหว่างพวกเขาจึงไม่ได้บอกคุณอะไรมากนัก สำหรับเซตจำกัด isomorphism บอกว่าพวกเขามี elements จำนวนเดียวกัน หากเซตไม่มีขีดจำกัด cardinality ของพวกเขาจะต้องเหมือนกัน แต่ isomorphism ที่มีความหมายใดๆ ของ hom-sets จะต้องคำนึงถึง composition และ composition เกี่ยวข้องมากกว่าหนึ่ง hom-set เราต้องกำหนด isomorphisms ที่ครอบคลุม whole collections ของ hom-sets และเราต้องกำหนด compatibility conditions ที่ interoperate กับ composition และ natural isomorphism นั้น fit the bill exactly
แต่ natural isomorphism ของ hom-sets คืออะไร? Naturality เป็น property ของ mappings ระหว่าง functors ไม่ใช่เซต ดังนั้นเราจึงพูดถึง natural isomorphism ระหว่าง hom-set-valued functors functors เหล่านี้มากกว่า just set-valued functors action ของพวกเขาบน morphisms ถูก induced โดย appropriate hom-functors morphisms ถูก canonically map โดย hom-functors โดยใช้ either pre- หรือ post-composition (depending on the covariance ของ functor)
Yoneda embedding เป็นตัวอย่างหนึ่งของ isomorphism ดังกล่าว มันแมป hom-sets ใน C ไปยัง hom-sets ใน functor category และมันเป็น natural One functor ใน Yoneda embedding คือ hom-functor ใน C และอีกตัวแมป objects ไปยัง sets ของ natural transformations ระหว่าง hom-sets
ความหมาย ของ limit ก็เป็น natural isomorphism ระหว่าง hom-sets (ตัวที่สอง อีกครั้ง ใน functor category) ด้วย:
C(c, Lim D) ≃ Nat(Δc, D)
เกิดขึ้นว่า construction ของเรา ของ exponential object หรือ construction ของ free monoid สามารถเขียนใหม่เป็น natural isomorphism ระหว่าง hom-sets ได้
นี่ไม่ใช่เรื่องบังเอิญ — เราจะเห็นถัดไปว่า adjunctions ซึ่งถูกกำหนดเป็น natural isomorphisms ของ hom-sets
Asymmetry of Hom-Sets (ความไม่สมมาตรของเซตมอร์ฟิซึมส์)
มี observation เพิ่มเติมหนึ่งอย่างที่จะช่วยให้เราเข้าใจ adjunctions Hom-sets ไม่ symmetric โดยทั่วไป Hom-set C(a, b) มักจะแตกต่างมากจาก hom-set C(b, a) การสาธิตขั้นสุดท้ายของ asymmetry นี้คือ partial order ที่ดู เป็น category ใน partial order morphism จาก a ไปยัง b มีอยู่ก็ต่อเมื่อ a เล็กกว่าหรือเท่ากับ b หาก a และ b แตกต่างกัน จะไม่มี morphism ที่ไปทางอื่น จาก b ไปยัง a ได้ ดังนั้น หากเซต C(a, b) ไม่ว่าง ซึ่งในกรณีนี้หมายความว่าเป็น singleton set แล้ว C(b, a) ต้องว่าง เว้นแต่ a = b Arrows ใน category นี้มี definite flow ในทิศทางเดียว
Preorder ซึ่ง based on relation ที่ไม่จำเป็นต้อง antisymmetric นั้น "mostly" directional นอกเหนือจากบางครั้ง cycles มันสะดวก ที่จะคิดว่า arbitrary category เป็น generalization ของ preorder
Preorder เป็น thin category — all hom-sets เป็น either singletons หรือ empty เราสามารถ visualize general category เป็น "thick" preorder
Challenges (ความท้าทาย)
-
พิจารณา degenerate cases บางอย่าง ของ naturality condition และวาด diagrams ที่เหมาะสม ตัวอย่างเช่น จะเกิดอะไรหากอย่างใดอย่างหนึ่ง functor
FหรือGแมป objects ทั้งสองอันaและb(ends ของf :: a -> b) ไปยัง object เดียวกัน เช่นF a = F bหรือG a = G b? (สังเกตว่าคุณได้ cone หรือ co-cone ด้วยวิธีนี้) จากนั้นพิจารณา cases ที่F a = G aหรือF b = G bสุดท้าย จะเกิดอะไรขึ้นหากคุณเริ่มต้นด้วย morphism ที่ loop on itself —f :: a -> a?
Acknowledgments (ขอบคุณ)
ผมอยากขอบคุณ Gershom Bazerman สำหรับการตรวจสอบคณิตศาสตร์และตรรกะของผม และ André van Meulebrouck ที่อาสาช่วยเหลือการแก้ไขตลอดซีรี่ส์โพสต์นี้
ในคณิตศาสตร์เรามี various ways ของการพูดว่า one thing เหมือน another ความเข้มงวดที่สุดคือ equality ข้อความสองข้อเท่าเทียมกันหากไม่มีวิธีที่จะแยกความแตกต่างหนึ่ง จากอีกตัว อันหนึ่งสามารถแทนที่สืบต่อในบริบทที่คิดได้ทั้งหมด ตัวอย่างเช่น สังเกตหรือไม่ว่าเราใช้ equality ของ morphisms ทุกครั้งที่เราพูดถึง commuting diagrams? นั่นเป็นเพราะ morphisms form a set (hom-set) และ elements ของเซต สามารถเปรียบเทียบได้ความเท่าเทียม
แต่ equality มักจะเข้มงวดเกินไป มี examples จำนวนมากของสิ่ง การเป็นสิ่งเดียวกันสำหรับวัตถุประสงค์ทั้งหมด โดยไม่เท่าเทียมจริง ตัวอย่างเช่น pair type (Bool, Char) ไม่เท่าเทียมอย่างเคร่งครัดกับ (Char, Bool) แต่เราเข้าใจว่า พวกเขามี information เดียวกัน concept นี้ถูก capture ดีที่สุด โดย isomorphism ระหว่าง two types — morphism ที่ invertible เนื่องจากเป็น morphism มันจึง preserve โครงสร้าง และการเป็น "iso" หมายความว่ามันเป็นส่วนหนึ่งของ round trip ที่ landed คุณในจุดเดียวกัน ไม่ว่าคุณจะ start จากด้านใด ในกรณี pairs isomorphism นี้ เรียก swap:
swap :: (a,b) -> (b,a)
swap (a,b) = (b,a)
swap เกิดขึ้นที่จะเป็น inverse ของมันเอง
Adjunction and Unit/Counit Pair (การผนวก และคู่ Unit/Counit)
เมื่อเราพูดถึง categories ที่ isomorphic เราแสดงสิ่งนี้ในแง่ของ mappings ระหว่าง categories คือ functors เราต้องการที่จะสามารถพูดว่า categories สองตัว C และ D isomorphic หากมี functor R ("right") จาก C ไปยัง D ซึ่ง invertible กล่าวอีกนัยหนึ่ง มี functor อีกตัวหนึ่ง L ("left") จาก D กลับมา C ซึ่งเมื่อ composed กับ R เท่ากับ identity functor I มี possible compositions สองแบบ R ∘ L และ L ∘ R และ possible identity functors สองอัน: หนึ่งใน C และอีกอัน ใน D
แต่ที่นี่คือ tricky part: What does it mean สำหรับ two functors ที่เป็น equal? เราหมายถึงอะไร โดยความเท่าเทียมนี้:
R ∘ L = ID
หรือตัวนี้:
L ∘ R = IC
มันจะสมเหตุสมผลที่จะกำหนด functor equality ในแง่ของ equality ของ objects functor สองตัว เมื่อทำการกับ equal objects ควร produce equal objects แต่เราไม่ได้มี โดยทั่วไป notion ของ object equality ใน arbitrary category มันไม่เป็นส่วนหนึ่งของ definition (Going deeper ลงใน rabbit hole นี้ ของ "what equality really is" เราจะจบลงใน Homotopy Type Theory)
คุณอาจแย้งว่า functors are morphisms ใน category ของ categories ดังนั้นพวกเขาควรจะ equality-comparable และจริง ๆ แล้ว ตราบใดที่เรากำลังพูดถึง small categories ที่ objects form a set เราสามารถใช้ equality ของ elements ของ set เพื่อ equality-compare objects ได้
แต่จำไว้ว่า Cat จริง ๆ แล้วเป็น 2-category Hom-sets ใน 2-category มี additional structure — มี 2-morphisms ทำหน้าที่ระหว่าง 1-morphisms ใน Cat 1-morphisms คือ functors และ 2-morphisms คือ natural transformations ดังนั้นจึงเป็นธรรมชาติมากขึ้น (ไม่สามารถหลีกเลี่ยง pun นี้!) ที่จะพิจารณา natural isomorphisms เป็นตัวแทนสำหรับ equality เมื่อพูดถึง functors
ดังนั้น แทนที่จะเป็น isomorphism ของ categories มันสมเหตุสมผลที่จะพิจารณา more general notion ของ equivalence categories สองตัว C และ D equivalent หากเราสามารถ find two functors ไปกลับมาระหว่างพวกเขา ซึ่ง composition (either way) เป็น naturally isomorphic ไปยัง identity functor กล่าวอีกนัยหนึ่ง มี two-way natural transformation ระหว่าง composition R ∘ L และ identity functor ID และอีกอันระหว่าง L ∘ R และ identity functor IC
Adjunction เป็น even weaker กว่า equivalence เพราะมันไม่ต้องการให้ composition ของ two functors เป็น isomorphic ไปยัง identity functor แทนที่ว่า มันระบุการมีอยู่ของ one way natural transformation จาก ID ไปยัง R∘L และอีกอันจาก L∘R ไปยัง
IC
. ที่นี่คือ signatures ของ two natural transformations นี้:
η :: ID -> R ∘ L
ε :: L ∘ R -> IC
η เรียก unit และ ε counit ของ adjunction
สังเกตเห็น asymmetry ระหว่าง definitions สองอัน นี้ โดยทั่วไป เราไม่มี two remaining mappings:
R ∘ L -> ID -- not necessarily
IC -> L ∘ R -- not necessarily
เนื่องจาก asymmetry นี้ functor L เรียกว่า left adjoint ไปยัง functor R ในขณะที่ functor R คือ right adjoint ไปยัง L (แน่นอนว่า left และ right ทำให้ sense เฉพาะหากคุณวาด diagrams ของคุณแบบหนึ่ง)
Compact notation สำหรับ adjunction คือ:
L ⊣ R
เพื่อให้เข้าใจ adjunction ได้ดีขึ้น เรามาวิเคราะห์ unit และ counit อย่างรายละเอียดกว่า
เรามาเริ่มต้นด้วย unit ซึ่งเป็น natural transformation ดังนั้น มันเป็น family ของ morphisms ให้ object d ใน D component ของ η เป็น morphism ระหว่าง I d ซึ่งเท่ากับ d และ (R ∘ L) d ซึ่งในรูป เรียก d':
ηd :: d -> (R ∘ L) d
สังเกตว่า composition R∘L คือ endofunctor ใน D
equation นี้บอกเราว่าเราสามารถ pick any object d ใน D เป็น starting point ของเรา และใช้ round trip functor R ∘ L เพื่อ pick target object d' ของเรา จากนั้น shoot an arrow — morphism
ηd
— ไปยัง target ของเรา
ด้วยเหตุผลเดียวกัน component ของ counit ε สามารถ described เป็น:
εc' :: (L ∘ R) c -> c
ที่ c' คือ (L ∘ R) c มันบอกเราว่าเราสามารถ pick any object c ใน C เป็น target ของเรา และใช้ round trip functor L ∘ R เพื่อ pick source c' จากนั้น shoot the arrow — morphism
εc'
— จาก source ไปยัง target
Another way ของการดู unit และ counit คือ unit let เราไป introduce composition R ∘ L ได้ทุกที่ที่เราสามารถ insert identity functor บน D และ counit let เราไป eliminate composition L ∘ R แทนที่ด้วย identity บน C ที่ lead ไปยัง consistency conditions บาง "obvious" ซึ่งให้ certainty ว่า introduction ตามด้วย elimination ไม่เปลี่ยน anything:
L = L ∘ ID -> L ∘ R ∘ L -> IC ∘ L = L
R = ID ∘ R -> R ∘ L ∘ R -> R ∘ IC = R
เรียกว่า triangular identities เพราะว่า พวกเขา make following diagrams commute:
diagrams เหล่านี้อยู่ใน functor category: arrows เป็น natural transformations และ composition ของพวกเขาคือ horizontal composition ของ natural transformations ใน components identities เหล่านี้เกิดขึ้น:
ε L d ∘ L η d = id L d
R ε c ∘ η R c = id R c
เรามักจะเห็น unit และ counit ใน Haskell ภายใต้ different names Unit เป็น return (หรือ pure ใน definition ของ Applicative):
return :: d -> m d
และ counint เป็น extract:
extract :: w c -> c
ที่นี่ m คือ (endo-) functor corresponding ไปยัง R∘L และ w คือ (endo-) functor corresponding ไปยัง L∘R ตามที่เราจะเห็นต่อมา พวกเขาเป็นส่วนหนึ่งของ definition ของ monad และ comonad ตามลำดับ
หากคุณคิดว่า endofunctor เป็น container unit (หรือ return) เป็น polymorphic function ที่สร้าง default box รอบ value ของ type arbitrary the counit (หรือ extract) ทำ reverse: มันดึงหรือ produce value เดี่ยวจาก container
เราจะเห็นต่อมาว่า every pair ของ adjoint functors กำหนด monad และ comonad ตรงกันข้าม every monad หรือ comonad อาจ factorized ลงใน pair ของ adjoint functors — factorization นี้ไม่ unique แม้ว่า
ใน Haskell เรา use monads many แต่ only rarely factorize พวกเขาลงใน pairs ของ adjoint functors โดยหลัก เนื่องจาก functors เหล่านั้นมักจะใช้ us ออก Hask นอกเหนือจากนี้
เราสามารถ define adjunctions ของ endofunctors ใน Haskell ที่นี่คือ part ของ definition taken จาก Data.Functor.Adjunction:
class (Functor f, Representable u) =>
Adjunction f u | f -> u, u -> f where
unit :: a -> u (f a)
counit :: f (u a) -> a
definition นี้ต้องการ some explanation ประการแรก มันอธิบาย multi-parameter type class — two parameters เป็น f และ u มันสร้าง relation เรียก Adjunction ระหว่าง two type constructors นี้
Additional conditions หลัง vertical bar ระบุ functional dependencies ตัวอย่างเช่น f -> u หมายความว่า u ถูก determined โดย f (relation ระหว่าง f และ u เป็น function ที่นี่ บน type constructors) ตรงกันข้าม u -> f หมายความว่า หากเรารู้ u แล้ว f ถูก uniquely determined
ผมจะอธิบายในช่วงเวลาหนึ่ง ว่าทำไม ใน Haskell เราสามารถ impose condition ว่า right adjoint u be representable functor
Adjunctions and Hom-Sets (การผนวก และเซตมอร์ฟิซึมส์)
มี equivalent definition ของ adjunction ในแง่ของ natural isomorphisms ของ hom-sets definition นี้ tie nicely กับ universal constructions ที่เราศึกษา ทุกครั้งที่คุณได้ยินคำสัญญาว่ามี some unique morphism ซึ่ง factorizes some construction คุณควรคิดถึงมันเป็น mapping ของ some set ไปยัง hom-set นั่นคือ meaning ของ "picking a unique morphism"
นอกจากนี้ factorization สามารถ often described ในแง่ของ natural transformations factorization เกี่ยวข้อง commuting diagrams — some morphism เป็น equal ถึง composition ของ two morphisms (factors) A natural transformation maps morphisms ไปยัง commuting diagrams ดังนั้น ใน universal construction เราไป from a morphism ไปยัง commuting diagram และจากนั้นไปยัง unique morphism เราจบลงด้วย mapping จาก morphism ไปยัง morphism หรือจาก one hom-set ไปยัง another (usually ใน different categories) หากการแมป นี้ invertible และหากมันสามารถ naturally extended ข้าม all hom-sets เรามี adjunction
ความแตกต่างหลัก ระหว่าง universal constructions และ adjunctions คือ latter ถูก defined globally — สำหรับ all hom-sets ตัวอย่างเช่น ใช้ universal construction คุณสามารถกำหนด product ของ two select objects แม้ว่า มันไม่มีอยู่สำหรับ any other pair ของ objects ใน category นั้น ตามที่เราจะเห็นเร็ว ๆ นี้ หาก product ของ any pair ของ objects มีอยู่ใน category มันสามารถ also defined ผ่าน adjunction ได้
ที่นี่คือ alternative definition ของ adjunction ใช้ hom-sets ตามก่อน เรามี two functors L :: D->C และ R :: C->D เราเลือก two arbitrary objects: source object d ใน D และ target object c ใน C เราสามารถแมป source object d ไป C ใช้ L ตอนนี้เรามี two objects ใน C L d และ c พวกเขากำหนด hom-set:
C(L d, c)
ในทำนองเดียวกัน เราสามารถแมป target object c ใช้ R ตอนนี้เรามี two objects ใน D d และ R c พวกเขา เกิน มาก define hom set:
D(d, R c)
เราพูดว่า L คือ left adjoint ของ R iff มี isomorphism ของ hom sets:
C(L d, c) ≅ D(d, R c)
ซึ่งเป็น natural ทั้ง ใน d และ c
Naturality หมายความว่า source d สามารถ varied smoothly ข้าม D และ target c ข้าม C อย่างแม่นยำมากขึ้น เรามี natural transformation φ ระหว่าง following two (covariant) functors จาก C ไปยัง Set ที่นี่คือ action ของ functors เหล่านี้ บน objects:
c -> C(L d, c)
c -> D(d, R c)
ที่ other natural transformation ψ acts ระหว่าง following (contravariant) functors:
d -> C(L d, c)
d -> D(d, R c)
ทั้ง natural transformations ต้อง invertible
ง่ายต่อการแสดงว่า definitions สอง ของ adjunction เป็น equivalent ตัวอย่างเช่น เรามากระบาย unit transformation starting จาก isomorphism ของ hom-sets:
C(L d, c) ≅ D(d, R c)
เนื่องจากมี isomorphism นี้ works สำหรับ any object c มันต้อง also work สำหรับ c = L d:
C(L d, L d) ≅ D(d, (R ∘ L) d)
เรารู้ว่า left hand side ต้อง contain ที่เล็กน้อยหนึ่ง morphism identity natural transformation จะแมป morphism นี้ไปยัง element ของ D(d, (R ∘ L) d) หรือ inserting identity functor I morphism ใน:
D(I d, (R ∘ L) d)
เราได้ family ของ morphisms parameterized โดย d พวกเขา form natural transformation ระหว่าง functor I และ functor R ∘ L (naturality condition นั้น ง่าย ต่อการยืนยัน) นี่คือ exactly our unit η
ตรงกันข้าม starting จาก existence ของ unit และ co-unit เราสามารถกำหนด transformations ระหว่าง hom-sets ตัวอย่างเช่น เรามาเลือก arbitrary morphism f ใน hom-set C(L d, c) เราต้องการกำหนด φ ซึ่ง acting บน f produces morphism ใน D(d, R c)
ไม่มี really much choice มีสิ่ง one thing เราสามารถลอง คือ lift f ใช้ R ซึ่งจะ produce morphism R f จาก R (L d) ไปยัง R c — morphism ซึ่งเป็น element ของ D((R ∘ L) d, R c)
สิ่ง that we need สำหรับ component ของ φ คือ morphism จาก d ไปยัง R c นี่ไม่ใช่ปัญหา เนื่องจาก เราสามารถใช้ component ของ
ηd
เพื่อ get จาก d ไปยัง (R ∘ L) d เราได้:
φf = R f ∘ ηd
ทาง other คล้ายคลึงกัน และเป็นเช่นเดียวกับ derivation ของ ψ
Going back ไปยัง Haskell definition ของ Adjunction natural transformations φ และ ψ ถูก replaced โดย polymorphic (ใน a และ b) functions leftAdjunct และ rightAdjunct ตามลำดับ functors L และ R เรียก f และ u:
class (Functor f, Representable u) =>
Adjunction f u | f -> u, u -> f where
leftAdjunct :: (f a -> b) -> (a -> u b)
rightAdjunct :: (a -> u b) -> (f a -> b)
equivalence ระหว่าง unit/counit formulation และ leftAdjunct/rightAdjunct formulation เป็น witnessed โดย these mappings:
unit = leftAdjunct id
counit = rightAdjunct id
leftAdjunct f = fmap f . unit
rightAdjunct f = counit . fmap f
มันเป็นอย่างมากให้สอน เพื่อ follow translation จาก categorical description ของ adjunction ไปยัง Haskell code ผมปลอบโยน เรื่อง นี้เป็น exercise
เรา ready ตอนนี้ เพื่ออธิบายทำไม ใน Haskell right adjoint คือ automatically representable functor เหตุผล สำหรับสิ่ง นี้คือ เพื่อ first approximation เราสามารถบำรุง category ของ Haskell types เช่น category ของ sets
เมื่อ right category D คือ Set right adjoint R คือ functor จาก C ไปยัง Set functor ดังกล่าว คือ representable หากเราสามารถ find object rep ใน C ดังกล่าว ว่า hom-functor C(rep, _) คือ naturally isomorphic ไปยัง R เกิดขึ้นว่า หาก R คือ right adjoint ของ some functor L จาก Set ไปยัง C ดังกล่าว object always exists — มันคือ image ของ singleton set () ภายใต้ L:
rep = L ()
จริง ๆ adjunction บอกเราว่า following two hom-sets เป็น naturally isomorphic:
C(L (), c) ≅ Set((), R c)
สำหรับ given c right hand side คือ set ของ functions จาก singleton set () ไปยัง R c เรามาเห็นแล้ว ต้นน้ำ ว่า each such function picks one element จาก set R c set ของ such functions คือ isomorphic ไปยัง set R c ดังนั้น เรามี:
C(L (), -) ≅ R
ซึ่งแสดง ว่า R คือ จริง ๆ representable
Product from Adjunction (สินค้าจากผนวก)
เรามากำหนด several concepts ก่อนหน้านี้ใช้ universal constructions หลาย ๆ ของ those concepts เมื่อ defined globally เป็นง่าย ต่อ express ใช้ adjunctions ที่ simplest non-trivial example คือ ของ product gist ของ universal construction ของ product คือ ability เพื่อ factorize any product-like candidate ผ่าน universal product
อย่างแม่นยำมากขึ้น product ของ two objects a และ b คือ object (a × b) (หรือ (a, b) ใน Haskell notation) equipped กับ two morphisms fst และ snd ดังกล่าว ว่า สำหรับ any other candidate c equipped กับ two morphisms p::c->a และ q::c->b มี unique morphism m::c->(a, b) ที่ factorizes p และ q ผ่าน fst และ snd
ตามที่เรามา ก่อนหน้า ใน Haskell เราสามารถใช้ factorizer ซึ่ง generates morphism นี้จาก two projections:
factorizer :: (c -> a) -> (c -> b) -> (c -> (a, b))
factorizer p q = \x -> (p x, q x)
มันง่าย ต่อการยืนยัน ว่า factorization conditions hold:
fst . factorizer p q = p
snd . factorizer p q = q
เรามี mapping ที่ takes pair ของ morphisms p และ q และ produces another morphism m = factorizer p q
วิธี เราสามารถแปล นี้เป็น mapping ระหว่าง two hom-sets ที่ เราต้องการ เพื่อ define adjunction? trick คือ go outside ของ Hask และ treat pair ของ morphisms เป็น single morphism ใน product category
let me remind you สิ่งที่ product category คือ take two arbitrary categories C และ D objects ใน product category C×D เป็น pairs ของ objects หนึ่ง จาก C และ one จาก D morphisms เป็น pairs ของ morphisms one จาก C และ one จาก D
เพื่อ define product ใน some category C เราควรเริ่มต้นด้วย product category C×C pairs ของ morphism จาก C เป็น single morphisms ใน product category C×C
มันอาจเป็น little confusing ที่ first ว่า เรากำลัง using product category เพื่อ define product ดังกล่าว เหล่านี้ แต่ very different products เราไม่ต้องการ universal construction เพื่อ define product category ทั้งหมด we need คือ notion ของ pair ของ objects และ pair ของ morphisms
แต่ pair ของ objects จาก C เป็น not object ใน C มันเป็น object ใน different category C×C เราสามารถ write pair formally เป็น <a, b> ที่ a และ b เป็น objects ของ C universal construction บนอื่น ๆ hand คือ necessary เพื่อ define object a×b (หรือ (a, b) ใน Haskell) ซึ่งเป็น object ใน the same category C object นี้เป็น supposed เพื่อ represent pair <a, b> ในทำนองที่ specified โดย universal construction มันไม่ always exist และ even หากมันอยู่สำหรับ some อย่างไรก็ตาม might ไม่ exist สำหรับ other pairs ของ objects ใน C
เรามาดู factorizer เป็น mapping ของ hom-sets ตอนแรก hom-set อยู่ใน product category C×C และ second อยู่ใน C general morphism ใน C×C would เป็น pair ของ morphisms <f, g>:
f :: c' -> a
g :: c'' -> b
กับ c'' potentially different จาก c' แต่ เพื่อ define product เราสนใจ special morphism ใน C×C pair p และ q ที่ share same source object c ดังนั้น fine: ใน definition ของ adjuncion source ของ left hom-set ไม่ arbitrary object — มันเป็น result ของ left functor L acting บน some object จาก right category functor ที่ fits bill คือ easy เพื่อ guess — มันเป็น diagonal functor จาก C ไปยัง C×C ซึ่ง action บน objects คือ:
Δ c = <c, c>
left-hand side hom-set ใน adjunction ของเรา ควร เป็น:
(C×C)(Δ c, <a, b>)
มันเป็น hom-set ใน product category elements ของมันเป็น pairs ของ morphisms ที่ เราจำได้ เป็น arguments ไปยัง factorizer ของเรา:
(c -> a) -> (c -> b) ...
right-hand side hom-set lives ใน C และ มันไป ระหว่าง source object c และ result ของ some functor R acting บน target object ใน C×C ซึ่งเป็น functor ที่ maps pair <a, b> ไปยัง product object ของเรา a×b เราจำได้ element นี้ของ hom-set เป็น result ของ factorizer ของเรา:
... -> (c -> (a, b))
เรายังไม่มี full adjunction สำหรับ that we first need factorizer ของเรา เพื่อ be invertible — เรากำลังสร้าง isomorphism ระหว่าง hom-sets inverse ของ factorizer ควรเริ่มต้นจาก morphism m — morphism จาก some object c ไปยัง product object a×b ในอื่น ๆ words m ควร be element ของ:
C(c, a×b)
inverse factorizer ควรแมป m ไปยัง morphism <p, q> ใน C×C ที่ไปจาก <c, c> ไปยัง <a, b> ในอื่น ๆ words morphism ซึ่งเป็น element ของ:
(C×C)(Δ c, <a, b>)
หาก ว่า mapping exists เราสรุป ว่า exists right adjoint ไปยัง diagonal functor นั่น functor defines product
ใน Haskell เราสามารถ always construct inverse ของ factorizer โดย composing m กับ respectively fst และ snd
p = fst ∘ m
q = snd ∘ m
เพื่อ complete proof ของ equivalence ของ two ways ของ defining product เรา also ต้อง show ว่า mapping ระหว่าง hom-sets คือ natural ใน a b และ c ผมจะ leave นี้เป็น exercise สำหรับ dedicated reader
เพื่อสรุป สิ่งที่ เราได้ทำ: categorical product อาจ defined globally เป็น right adjoint ของ diagonal functor:
(C × C)(Δ c, <a, b>) ≅ C(c, a×b)
ที่นี่ a×b คือ result ของ action ของ right adjoint functor ของเรา Product บน pair <a, b> สังเกต ว่า any functor จาก C×C คือ bifunctor ดังนั้น Product คือ bifunctor ใน Haskell Product bifunctor เขียนเพียง เช่น (,) คุณสามารถ apply มันไปยัง two types และ get their product type ตัวอย่างเช่น:
(,) Int Bool ~ (Int, Bool)
Exponential from Adjunction (เลขชี้กำลังจากผนวก)
exponential
ba
หรือ function object a⇒b สามารถ defined ใช้ universal construction construction นี้ หากมันอยู่สำหรับ all pairs ของ objects สามารถ seen เป็น adjunction again trick คือ concentrate บน statement:
สำหรับ any other object
zกับ morphismg :: z × a -> bมี unique morphism
h :: z -> (a⇒b)
statement นี้ establishes mapping ระหว่าง hom-sets
ในกรณีนี้ เราจัดการกับ objects ใน same category ดังนั้น two adjoint functors คือ endofunctors left (endo-)functor L เมื่อ acting บน object z produces z × a มันเป็น functor ที่ corresponds ไปยัง taking product กับ some fixed a
right (endo-)functor R เมื่อ acting บน b produces function object a⇒b (หรือ
ba
) อีกครั้ง a fixed adjunction ระหว่าง two functors นี้ บ่อยครั้ง written เป็น:
- × a ⊣ (-)a
mapping ของ hom-sets ที่ underlies adjunction นี้ best seen โดย redrawing diagram ที่ เราใช้ ใน universal construction
สังเกต ว่า eval morphism เป็น nothing else แต่ counit ของ adjunction นี้:
(a⇒b) × a -> b
ที่:
(a⇒b) × a = (L ∘ R) b
ผมได้ previously mentioned ว่า universal construction defines unique object up ไปยัง isomorphism นั่นคือ ทำไม เรามี "the" product และ "the" exponential property นี้ translates ไปยัง adjunctions ด้วย: หาก functor มี adjoint นี้ adjoint คือ unique up ไปยัง isomorphism
Challenges (ความท้าทาย)
-
อนุมาน naturality square สำหรับ
ψtransformation ระหว่าง two (contravariant) functors:a -> C(L a, b) a -> D(a, R b) -
อนุมาน counit
εstarting จาก hom-sets isomorphism ใน second definition ของ adjunction -
complete proof ของ equivalence ของ two definitions ของ adjunction
-
show ว่า coproduct สามารถ defined โดย adjunction start กับ definition ของ factorizer สำหรับ coproduct
-
show ว่า coproduct คือ left adjoint ของ diagonal functor
-
define adjunction ระหว่าง product และ function object ใน Haskell