{-# OPTIONS --lossy-unification #-}
open import Cat.Prelude

import Cat.Functor.Reasoning
import Cat.Reasoning

module Cat.Functor.Adjoint.Compose


Suppose we have four functors and such that they βfit togetherβ, i.e.Β the composites and both exist. What can we say about their composites? The hope is that they would again be adjoints, and this is indeed the case.

We prove this here by explicitly exhibiting the adjunction natural transformations and the triangle identities, which is definitely suboptimal for readability, but is the most efficient choice in terms of the resulting Agda program.

    {o β oβ ββ oβ ββ}
{A : Precategory o β} {B : Precategory oβ ββ}
{C : Precategory oβ ββ}
{F : Functor A B} {G : Functor B A}
{L : Functor B C} {R : Functor C B}
(Fβ£G : F β£ G)
(Lβ£R : L β£ R)
where

private
module fg = _β£_ Fβ£G
module lr = _β£_ Lβ£R
module A = Cat.Reasoning A
module B = Cat.Reasoning B
module C = Cat.Reasoning C
module F = Cat.Functor.Reasoning F
module G = Cat.Functor.Reasoning G
module L = Cat.Functor.Reasoning L
module R = Cat.Functor.Reasoning R
open _β£_
open _=>_
module LF = Functor (L Fβ F)
module GR = Functor (G Fβ R)

LFβ£GR : (L Fβ F) β£ (G Fβ R)
LFβ£GR .unit .Ξ· x          = G.β (lr.Ξ· _) A.β fg.Ξ· _
LFβ£GR .counit .Ξ· x        = lr.Ξ΅ _ C.β L.β (fg.Ξ΅ _)

LFβ£GR .unit .is-natural x y f =
(G.β (lr.Ξ· _) A.β fg.Ξ· _) A.β f                β‘β¨ A.pullr (fg.unit.is-natural _ _ _) β©β‘
G.β (lr.Ξ· _) A.β G.β (F.β f) A.β fg.Ξ· _        β‘β¨ A.pulll (sym (G.F-β _ _)) β©β‘
G.β β lr.Ξ· _ B.β F.β f β A.β fg.Ξ· _            β‘β¨ apβ A._β_ (ap G.β (lr.unit.is-natural _ _ _)) refl β©β‘
G.β (R.β (L.β (F.β f)) B.β lr.Ξ· _) A.β fg.Ξ· _  β‘β¨ A.pushl (G.F-β _ _) β©β‘
GR.β (LF.β f) A.β G.β (lr.Ξ· _) A.β (fg.Ξ· _)    β

LFβ£GR .counit .is-natural x y f =
(lr.Ξ΅ _ C.β L.β (fg.Ξ΅ _)) C.β LF.β (GR.β f) β‘β¨ C.pullr (sym (L.F-β _ _)) β©β‘
lr.Ξ΅ _ C.β L.β β fg.Ξ΅ _ B.β F.β (GR.β f) β  β‘β¨ apβ C._β_ refl (ap L.β (fg.counit.is-natural _ _ _)) β©β‘
lr.Ξ΅ _ C.β β L.β (R.Fβ f B.β fg.Ξ΅ _) β      β‘β¨ apβ C._β_ refl (L.F-β _ _) β©β‘
lr.Ξ΅ _ C.β L.β (R.Fβ f) C.β L.β (fg.Ξ΅ _)    β‘β¨ C.extendl (lr.counit.is-natural _ _ _) β©β‘
f C.β lr.Ξ΅ _ C.β L.β (fg.Ξ΅ _)               β

LFβ£GR .zig =
(lr.Ξ΅ _ C.β L.β (fg.Ξ΅ _)) C.β β LF.β (G.β (lr.Ξ· _) A.β fg.Ξ· _) β β‘β¨ C.extendr (apβ C._β_ refl (LF.F-β _ _) β L.extendl (fg.counit.is-natural _ _ _)) β©β‘
(lr.Ξ΅ _ C.β L.β (lr.Ξ· _)) C.β (L.β (fg.Ξ΅ _) C.β LF.β (fg.Ξ· _))   β‘β¨ C.elimr (L.annihilate fg.zig) β©β‘
lr.Ξ΅ _ C.β L.β (lr.Ξ· _)                                          β‘β¨ lr.zig β©β‘
C.id                                                             β

LFβ£GR .zag =
GR.β (lr.Ξ΅ _ C.β L.β (fg.Ξ΅ _)) A.β G.β (lr.Ξ· _) A.β fg.Ξ· _ β‘β¨ A.pulll (G.collapse (B.pushl (R.F-β _ _) β apβ B._β_ refl (sym (lr.unit.is-natural _ _ _)))) β©β‘
G.β (β R.β (lr.Ξ΅ _) B.β lr.Ξ· _ B.β fg.Ξ΅ _ β) A.β fg.Ξ· _    β‘β¨ apβ A._β_ (ap G.β (B.cancell lr.zag)) refl β©β‘
G.β (fg.Ξ΅ _) A.β fg.Ξ· _                                    β‘β¨ fg.zag β©β‘
A.id                                                       β