module Cat.Instances.Functor.Duality where

Duality of functor categoriesπŸ”—

The duality involution on categories extends to a β€œduality involution” on functors. However, since this changes the type of the functor β€” the dual of is β€” it does not represent an involution on functor categories; Rather, it is an equivalence

op-functor→ : Functor (Cat[ C , D ] ^op) Cat[ C ^op , D ^op ]
op-functor→ .F₀ = Functor.op
op-functorβ†’ .F₁ nt .Ξ· = nt .Ξ·
op-functorβ†’ .F₁ nt .is-natural x y f = sym (nt .is-natural y x f)
op-functor→ .F-id = trivial!
op-functorβ†’ .F-∘ f g = trivial!

op-functor-is-iso : is-precat-iso (op-functor→ {C = C} {D = D})
op-functor-is-iso = isom where
  open is-precat-iso
  open is-iso

  isom : is-precat-iso _
  isom .has-is-ff = is-iso→is-equiv ff where
    ff : is-iso (F₁ op-functorβ†’)
    ff .inv nt .Ξ· = nt .Ξ·
    ff .inv nt .is-natural x y f = sym (nt .is-natural y x f)
    ff .rinv x = trivial!
    ff .linv x = trivial!
  isom .has-is-iso = is-iso→is-equiv (iso Functor.op
    (Ξ» x β†’ Functor-path (Ξ» x β†’ refl) (Ξ» x β†’ refl)) (Ξ» x β†’ F^op^op≑F))

This means, in particular, that it is an adjoint equivalence:

op-functor-is-equiv : is-equivalence (op-functor→ {C = C} {D = D})
op-functor-is-equiv = is-precat-iso→is-equivalence op-functor-is-iso

op-functor← : Functor Cat[ C ^op , D ^op ] (Cat[ C , D ] ^op)
op-functor← = is-equivalence.F⁻¹ op-functor-is-equiv

op-functor←→ : op-functor← {C = C} {D = D} F∘ op-functorβ†’ ≑ Id
op-functor←→ {C = C} {D = D} = Functor-path (Ξ» _ β†’ refl) Ξ» f β†’ ext Ξ» x β†’
  Regularity.precise! (( D.∘ f .Ξ· x) D.∘ β‰‘βŸ¨ cat! D βŸ©β‰‘ f .Ξ· x ∎)
    module D = Cat.Reasoning D