Skip to content

Commit

Permalink
Base change, sliced adjoints (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinjangrzybowski authored Sep 10, 2024
1 parent 760a894 commit fce3814
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 43 deletions.
24 changes: 19 additions & 5 deletions Cubical/Categories/Adjoint.agda
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ equivalence.

private
variable
ℓC ℓC' ℓD ℓD' : Level
ℓC ℓC' ℓD ℓD' ℓE ℓE' : Level

{-
==============================================
Expand Down Expand Up @@ -69,7 +69,7 @@ private
variable
C : Category ℓC ℓC'
D : Category ℓC ℓC'

E : Category ℓE ℓE'

module _ {F : Functor C D} {G : Functor D C} where
open UnitCounit
Expand Down Expand Up @@ -125,8 +125,8 @@ module AdjointUniqeUpToNatIso where
open _⊣_ H⊣G using (η ; Δ₂)
open _⊣_ H'⊣G using (ε ; Δ₁)
by-N-homs =
AssocCong₂⋆R {C = D} _
(AssocCong₂⋆L {C = D} (sym (N-hom ε _)) _)
AssocCong₂⋆R D
(AssocCong₂⋆L D (sym (N-hom ε _)))
∙ cong₂ _D⋆_
(sym (F-seq H' _ _)
∙∙ cong (H' ⟪_⟫) ((sym (N-hom η _)))
Expand Down Expand Up @@ -155,7 +155,7 @@ module AdjointUniqeUpToNatIso where
(sym (F-seq F _ _)
∙∙ cong (F ⟪_⟫) (N-hom (F'⊣G .η) _)
∙∙ (F-seq F _ _))
∙∙ AssocCong₂⋆R {C = D} _ (N-hom (F⊣G .ε) _)
∙∙ AssocCong₂⋆R D (N-hom (F⊣G .ε) _)
where open _⊣_
inv (nIso F≅ᶜF' _) = _
sec (nIso F≅ᶜF' _) = s F⊣G F'⊣G
Expand Down Expand Up @@ -232,6 +232,20 @@ module NaturalBijection where
isRightAdjoint : {C : Category ℓC ℓC'} {D : Category ℓD ℓD'} (G : Functor D C) Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD'))
isRightAdjoint {C = C}{D} G = Σ[ F ∈ Functor C D ] F ⊣ G

module Compose {F : Functor C D} {G : Functor D C}
{L : Functor D E} {R : Functor E D}
where
open NaturalBijection
module _ (F⊣G : F ⊣ G) (L⊣R : L ⊣ R) where
open _⊣_

LF⊣GR : (L ∘F F) ⊣ (G ∘F R)
adjIso LF⊣GR = compIso (adjIso L⊣R) (adjIso F⊣G)
adjNatInD LF⊣GR f k =
cong (adjIso F⊣G .fun) (adjNatInD L⊣R _ _) ∙ adjNatInD F⊣G _ _
adjNatInC LF⊣GR f k =
cong (adjIso L⊣R .inv) (adjNatInC F⊣G _ _) ∙ adjNatInC L⊣R _ _

{-
==============================================
Proofs of equivalence
Expand Down
11 changes: 6 additions & 5 deletions Cubical/Categories/Category/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,27 @@ module _ {C : Category ℓ ℓ'} where
f ⋆⟨ C ⟩ g ≡ seqP' {p = p} f' g
rCatWhiskerP f' f g r = cong (λ v v ⋆⟨ C ⟩ g) (sym (fromPathP r))

module _ (C : Category ℓ ℓ') where

AssocCong₂⋆L : {x y' y z w : C .ob}
{f' : C [ x , y' ]} {f : C [ x , y ]}
{g' : C [ y' , z ]} {g : C [ y , z ]}
f ⋆⟨ C ⟩ g ≡ f' ⋆⟨ C ⟩ g' (h : C [ z , w ])
f ⋆⟨ C ⟩ g ≡ f' ⋆⟨ C ⟩ g' {h : C [ z , w ]}
f ⋆⟨ C ⟩ (g ⋆⟨ C ⟩ h) ≡
f' ⋆⟨ C ⟩ (g' ⋆⟨ C ⟩ h)
AssocCong₂⋆L p h =
sym (⋆Assoc C _ _ h)
AssocCong₂⋆L p {h} =
sym (⋆Assoc C _ _ _)
∙∙ (λ i p i ⋆⟨ C ⟩ h) ∙∙
⋆Assoc C _ _ h

AssocCong₂⋆R : {x y z z' w : C .ob}
(f : C [ x , y ])
{f : C [ x , y ]}
{g' : C [ y , z' ]} {g : C [ y , z ]}
{h' : C [ z' , w ]} {h : C [ z , w ]}
g ⋆⟨ C ⟩ h ≡ g' ⋆⟨ C ⟩ h'
(f ⋆⟨ C ⟩ g) ⋆⟨ C ⟩ h ≡
(f ⋆⟨ C ⟩ g') ⋆⟨ C ⟩ h'
AssocCong₂⋆R f p =
AssocCong₂⋆R {f = f} p =
⋆Assoc C f _ _
∙∙ (λ i f ⋆⟨ C ⟩ p i) ∙∙
sym (⋆Assoc C _ _ _)
193 changes: 193 additions & 0 deletions Cubical/Categories/Constructions/Slice/Functor.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{-# OPTIONS --safe #-}

module Cubical.Categories.Constructions.Slice.Functor where

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism

open import Cubical.Categories.Category
open import Cubical.Categories.Category.Properties

open import Cubical.Categories.Constructions.Slice.Base

open import Cubical.Categories.Limits.Pullback
open import Cubical.Categories.Functor
open import Cubical.Categories.NaturalTransformation
open import Cubical.Categories.Adjoint

open import Cubical.Tactics.FunctorSolver.Reflection


open Category hiding (_∘_)
open Functor
open NatTrans

private
variable
ℓ ℓ' : Level
C D : Category ℓ ℓ'
c d : C .ob

infix 39 _F/_
infix 40 ∑_

_F/_ : (F : Functor C D) c Functor (SliceCat C c) (SliceCat D (F ⟅ c ⟆))
F-ob (F F/ c) = sliceob ∘ F ⟪_⟫ ∘ S-arr
F-hom (F F/ c) h = slicehom _
$ sym ( F-seq F _ _) ∙ cong (F ⟪_⟫) (S-comm h)
F-id (F F/ c) = SliceHom-≡-intro' _ _ $ F-id F
F-seq (F F/ c) _ _ = SliceHom-≡-intro' _ _ $ F-seq F _ _


∑_ : {c d} f Functor (SliceCat C c) (SliceCat C d)
F-ob (∑_ {C = C} f) (sliceob x) = sliceob (x ⋆⟨ C ⟩ f)
F-hom (∑_ {C = C} f) (slicehom h p) = slicehom _ $
sym (C .⋆Assoc _ _ _) ∙ cong (comp' C f) p
F-id (∑ f) = SliceHom-≡-intro' _ _ refl
F-seq (∑ f) _ _ = SliceHom-≡-intro' _ _ refl

module _ (Pbs : Pullbacks C) where

open Category C using () renaming (_⋆_ to _⋆ᶜ_)

module BaseChange {c d} (𝑓 : C [ c , d ]) where
infix 40 _*

module _ {x@(sliceob arr) : SliceOb C d} where
open Pullback (Pbs (cospan _ _ _ 𝑓 arr)) public

module _ {x} {y} ((slicehom h h-comm) : SliceCat C d [ y , x ]) where

pbU = univProp (pbPr₁ {x = y}) (pbPr₂ ⋆ᶜ h)
(pbCommutes {x = y} ∙∙ cong (pbPr₂ ⋆ᶜ_) (sym (h-comm)) ∙∙ sym (C .⋆Assoc _ _ _))
.fst .snd

_* : Functor (SliceCat C d) (SliceCat C c)
F-ob _* x = sliceob (pbPr₁ {x = x})
F-hom _* f = slicehom _ (sym (fst (pbU f)))
F-id _* = SliceHom-≡-intro' _ _ $ pullbackArrowUnique (sym (C .⋆IdL _)) (C .⋆IdR _ ∙ sym (C .⋆IdL _))

F-seq _* _ _ =
let (u₁ , v₁) = pbU _ ; (u₂ , v₂) = pbU _
in SliceHom-≡-intro' _ _ $ pullbackArrowUnique
(u₂ ∙∙ cong (C ⋆ _) u₁ ∙∙ sym (C .⋆Assoc _ _ _))
(sym (C .⋆Assoc _ _ _) ∙∙ cong (comp' C _) v₂ ∙∙ AssocCong₂⋆R C v₁)

open BaseChange using (_*)
open NaturalBijection renaming (_⊣_ to _⊣₂_)
open Iso
open _⊣₂_


module _ (𝑓 : C [ c , d ]) where

open BaseChange 𝑓 hiding (_*)

∑𝑓⊣𝑓* : ∑ 𝑓 ⊣₂ 𝑓 *
fun (adjIso ∑𝑓⊣𝑓*) (slicehom h o) =
let ((_ , (p , _)) , _) = univProp _ _ (sym o)
in slicehom _ (sym p)
inv (adjIso ∑𝑓⊣𝑓*) (slicehom h o) = slicehom _ $
AssocCong₂⋆R C (sym (pbCommutes)) ∙ cong (_⋆ᶜ 𝑓) o
rightInv (adjIso ∑𝑓⊣𝑓*) (slicehom h o) =
SliceHom-≡-intro' _ _ (pullbackArrowUnique (sym o) refl)
leftInv (adjIso ∑𝑓⊣𝑓*) (slicehom h o) =
let ((_ , (_ , q)) , _) = univProp _ _ _
in SliceHom-≡-intro' _ _ (sym q)
adjNatInD ∑𝑓⊣𝑓* f k = SliceHom-≡-intro' _ _ $
let ((h' , (v' , u')) , _) = univProp _ _ _
((_ , (v'' , u'')) , _) = univProp _ _ _
in pullbackArrowUnique (v' ∙∙ cong (h' ⋆ᶜ_) v'' ∙∙ sym (C .⋆Assoc _ _ _))
(cong (_⋆ᶜ _) u' ∙ AssocCong₂⋆R C u'')

adjNatInC ∑𝑓⊣𝑓* g h = SliceHom-≡-intro' _ _ $ C .⋆Assoc _ _ _


open UnitCounit

module SlicedAdjoint {L : Functor C D} {R} (L⊣R : L ⊣ R) where

open Category D using () renaming (_⋆_ to _⋆ᵈ_)

open _⊣_ L⊣R

module _ {c} {d} where
module aI = Iso (adjIso (adj→adj' _ _ L⊣R) {c} {d})

module Left (b : D .ob) where

⊣F/ : Functor (SliceCat C (R ⟅ b ⟆)) (SliceCat D b)
⊣F/ = ∑ (ε ⟦ b ⟧) ∘F L F/ (R ⟅ b ⟆)

L/b⊣R/b : ⊣F/ ⊣₂ (R F/ b)
fun (adjIso L/b⊣R/b) (slicehom _ p) = slicehom _ $
C .⋆Assoc _ _ _
∙∙ cong (_ ⋆ᶜ_) (sym (F-seq R _ _) ∙∙ cong (R ⟪_⟫) p ∙∙ F-seq R _ _)
∙∙ AssocCong₂⋆L C (sym (N-hom η _))
∙∙ cong (_ ⋆ᶜ_) (Δ₂ _)
∙∙ C .⋆IdR _

inv (adjIso L/b⊣R/b) (slicehom _ p) =
slicehom _ $ AssocCong₂⋆R D (sym (N-hom ε _))
∙ cong (_⋆ᵈ _) (sym (F-seq L _ _) ∙ cong (L ⟪_⟫) p)
rightInv (adjIso L/b⊣R/b) _ = SliceHom-≡-intro' _ _ $ aI.rightInv _
leftInv (adjIso L/b⊣R/b) _ = SliceHom-≡-intro' _ _ $ aI.leftInv _
adjNatInD L/b⊣R/b _ _ = SliceHom-≡-intro' _ _ $
cong (_ ⋆ᶜ_) (F-seq R _ _) ∙ sym (C .⋆Assoc _ _ _)
adjNatInC L/b⊣R/b _ _ = SliceHom-≡-intro' _ _ $
cong (_⋆ᵈ _) (F-seq L _ _) ∙ (D .⋆Assoc _ _ _)


module Right (b : C .ob) where

F/⊣ : Functor (SliceCat D (L ⟅ b ⟆)) (SliceCat C b)
F/⊣ = (η ⟦ b ⟧) * ∘F R F/ (L ⟅ b ⟆)

open BaseChange (η ⟦ b ⟧) hiding (_*)

L/b⊣R/b : L F/ b ⊣₂ F/⊣
fun (adjIso L/b⊣R/b) (slicehom f s) = slicehom _ $
sym $ univProp _ _ (N-hom η _ ∙∙
cong (_ ⋆ᶜ_) (cong (R ⟪_⟫) (sym s) ∙ F-seq R _ _)
∙∙ sym (C .⋆Assoc _ _ _)) .fst .snd .fst
inv (adjIso L/b⊣R/b) (slicehom f s) = slicehom _
(D .⋆Assoc _ _ _
∙∙ congS (_⋆ᵈ (ε ⟦ _ ⟧ ⋆⟨ D ⟩ _)) (F-seq L _ _)
∙∙ D .⋆Assoc _ _ _ ∙ cong (L ⟪ f ⟫ ⋆ᵈ_)
(cong (L ⟪ pbPr₂ ⟫ ⋆ᵈ_) (sym (N-hom ε _))
∙∙ sym (D .⋆Assoc _ _ _)
∙∙ cong (_⋆ᵈ ε ⟦ F-ob L b ⟧)
(preserveCommF L $ sym pbCommutes)
∙∙ D .⋆Assoc _ _ _
∙∙ cong (L ⟪ pbPr₁ ⟫ ⋆ᵈ_) (Δ₁ b)
∙ D .⋆IdR _)
∙∙ sym (F-seq L _ _)
∙∙ cong (L ⟪_⟫) s)

rightInv (adjIso L/b⊣R/b) h = SliceHom-≡-intro' _ _ $
let p₂ : {x} η ⟦ _ ⟧ ⋆ᶜ R ⟪ L ⟪ x ⟫ ⋆⟨ D ⟩ ε ⟦ _ ⟧ ⟫ ≡ x
p₂ = cong (_ ⋆ᶜ_) (F-seq R _ _) ∙
AssocCong₂⋆L C (sym (N-hom η _))
∙∙ cong (_ ⋆ᶜ_) (Δ₂ _) ∙∙ C .⋆IdR _


in pullbackArrowUnique (sym (S-comm h)) p₂

leftInv (adjIso L/b⊣R/b) _ = SliceHom-≡-intro' _ _ $
cong ((_⋆ᵈ _) ∘ L ⟪_⟫) (sym (snd (snd (fst (univProp _ _ _)))))
∙ aI.leftInv _
adjNatInD L/b⊣R/b _ _ = SliceHom-≡-intro' _ _ $
let (h , (u , v)) = univProp _ _ _ .fst
(u' , v') = pbU _

in pullbackArrowUnique
(u ∙∙ cong (h ⋆ᶜ_) u' ∙∙ sym (C .⋆Assoc h _ _))
(cong (_ ⋆ᶜ_) (F-seq R _ _)
∙∙ sym (C .⋆Assoc _ _ _) ∙∙
(cong (_⋆ᶜ _) v ∙ AssocCong₂⋆R C v'))

adjNatInC L/b⊣R/b g h = let w = _ in SliceHom-≡-intro' _ _ $
cong (_⋆ᵈ _) (cong (L ⟪_⟫) (C .⋆Assoc _ _ w) ∙ F-seq L _ (_ ⋆ᶜ w))
∙ D .⋆Assoc _ _ _

31 changes: 17 additions & 14 deletions Cubical/Categories/Functor/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,6 @@ module _ {F : Functor C D} where
F-rUnit i .F-id {x} = rUnit (F .F-id) (~ i)
F-rUnit i .F-seq f g = rUnit (F .F-seq f g) (~ i)

-- functors preserve commutative diagrams (specificallysqures here)
preserveCommF : {x y z w} {f : C [ x , y ]} {g : C [ y , w ]} {h : C [ x , z ]} {k : C [ z , w ]}
f ⋆⟨ C ⟩ g ≡ h ⋆⟨ C ⟩ k
(F ⟪ f ⟫) ⋆⟨ D ⟩ (F ⟪ g ⟫) ≡ (F ⟪ h ⟫) ⋆⟨ D ⟩ (F ⟪ k ⟫)
preserveCommF {f = f} {g = g} {h = h} {k = k} eq
= (F ⟪ f ⟫) ⋆⟨ D ⟩ (F ⟪ g ⟫)
≡⟨ sym (F .F-seq _ _) ⟩
F ⟪ f ⋆⟨ C ⟩ g ⟫
≡⟨ cong (F ⟪_⟫) eq ⟩
F ⟪ h ⋆⟨ C ⟩ k ⟫
≡⟨ F .F-seq _ _ ⟩
(F ⟪ h ⟫) ⋆⟨ D ⟩ (F ⟪ k ⟫)

-- functors preserve isomorphisms
preserveIsosF : {x y} CatIso C x y CatIso D (F ⟅ x ⟆) (F ⟅ y ⟆)
preserveIsosF {x} {y} (f , isiso f⁻¹ sec' ret') =
Expand Down Expand Up @@ -131,9 +117,26 @@ isOfHLevelFunctor {D = D} {C = C} hLevel x _ _ =
λ _ isOfHLevelPlus' 1 (isPropImplicitΠ2
λ _ _ isPropΠ λ _ isOfHLevelPathP' 1 (λ _ _ D .isSetHom _ _) _ _ ))


isSetFunctor : isSet (D .ob) isSet (Functor C D)
isSetFunctor = isOfHLevelFunctor 0

module _ (F : Functor C D) where

-- functors preserve commutative diagrams (specifically squres here)
preserveCommF : {x y z w} {f : C [ x , y ]} {g : C [ y , w ]} {h : C [ x , z ]} {k : C [ z , w ]}
f ⋆⟨ C ⟩ g ≡ h ⋆⟨ C ⟩ k
(F ⟪ f ⟫) ⋆⟨ D ⟩ (F ⟪ g ⟫) ≡ (F ⟪ h ⟫) ⋆⟨ D ⟩ (F ⟪ k ⟫)
preserveCommF {f = f} {g = g} {h = h} {k = k} eq
= (F ⟪ f ⟫) ⋆⟨ D ⟩ (F ⟪ g ⟫)
≡⟨ sym (F .F-seq _ _) ⟩
F ⟪ f ⋆⟨ C ⟩ g ⟫
≡⟨ cong (F ⟪_⟫) eq ⟩
F ⟪ h ⋆⟨ C ⟩ k ⟫
≡⟨ F .F-seq _ _ ⟩
(F ⟪ h ⟫) ⋆⟨ D ⟩ (F ⟪ k ⟫)

-- Conservative Functor,
-- namely if a morphism f is mapped to an isomorphism,
-- the morphism f is itself isomorphism.
Expand Down
4 changes: 2 additions & 2 deletions Cubical/Categories/Instances/Functors/Currying.agda
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module _ (C : Category ℓC ℓC') (D : Category ℓD ℓD') where
F-seq (λF⁻ a) _ (eG , cG) =
cong₂ (seq' D) (F-seq (F-ob a _) _ _) (cong (flip N-ob _)
(F-seq a _ _))
∙ AssocCong₂⋆R {C = D} _
∙ AssocCong₂⋆R D
(N-hom ((F-hom a _) ●ᵛ (F-hom a _)) _ ∙
(⋆Assoc D _ _ _) ∙
cong (seq' D _) (sym (N-hom (F-hom a eG) cG)))
Expand All @@ -85,7 +85,7 @@ module _ (C : Category ℓC ℓC') (D : Category ℓD ℓD') where
N-ob (F-hom λF⁻Functor x) = uncurry (N-ob ∘→ N-ob x)
N-hom ((F-hom λF⁻Functor) {F} {F'} x) {xx} {yy} =
uncurry λ hh gg
AssocCong₂⋆R {C = D} _ (cong N-ob (N-hom x hh) ≡$ _)
AssocCong₂⋆R D (cong N-ob (N-hom x hh) ≡$ _)
∙∙ cong (comp' D _) ((N-ob x (fst xx) .N-hom) gg)
∙∙ D .⋆Assoc _ _ _

Expand Down
Loading

0 comments on commit fce3814

Please sign in to comment.