module Cat.Functor.Morphism
  {o β„“ o' β„“'}
  {π’ž : Precategory o β„“} {π’Ÿ : Precategory o' β„“'}
  (F : Functor π’ž π’Ÿ)
  where

Actions of functors on morphismsπŸ”—

This module describes how various classes of functors act on designated collections of morphisms.

First, some general definitions. Let be a collection of morphisms in A functor preserves if implies that

preserves-monos : Type _
preserves-monos =
  βˆ€ {a b : π’ž.Ob} {f : π’ž.Hom a b} β†’ π’ž.is-monic f β†’ π’Ÿ.is-monic (F₁ f)

preserves-epis : Type _
preserves-epis =
  βˆ€ {a b : π’ž.Ob} {f : π’ž.Hom a b} β†’ π’ž.is-epic f β†’ π’Ÿ.is-epic (F₁ f)

Likewise, a functor reflects if implies that

reflects-monos : Type _
reflects-monos =
  βˆ€ {a b : π’ž.Ob} {f : π’ž.Hom a b} β†’ π’Ÿ.is-monic (F₁ f) β†’ π’ž.is-monic f

reflects-epis : Type _
reflects-epis =
  βˆ€ {a b : π’ž.Ob} {f : π’ž.Hom a b} β†’ π’Ÿ.is-epic (F₁ f) β†’ π’ž.is-epic f

Faithful functorsπŸ”—

Faithful functors reflect monomorphisms and epimorphisms. We will only comment on the proof regarding monomorphisms, since the argument for epimorphisms is formally dual. Let be monic in and let be a pair of morphisms in such that Because preserves all commutative diagrams, is monic, so Finally, is faithful, so we can deduce

module _ (faithful : is-faithful F) where
  faithfulβ†’reflects-mono : π’Ÿ.is-monic (F₁ a) β†’ π’ž.is-monic a
  faithful→reflects-mono {a = a} F[a]-monic b c p =
    faithful (F[a]-monic (F₁ b) (F₁ c) (weave p))

  faithfulβ†’reflects-epi : π’Ÿ.is-epic (F₁ a) β†’ π’ž.is-epic a
  faithful→reflects-epi {a = a} F[a]-epic b c p =
    faithful (F[a]-epic (F₁ b) (F₁ c) (weave p))

Likewise, faithful functors reflect all diagrams: this means that if and either form a section/retraction pair or an isomorphism, then it must have been the case that and already did.

  faithfulβ†’reflects-section-of : (F₁ a) π’Ÿ.section-of (F₁ b) β†’ a π’ž.section-of b
  faithfulβ†’reflects-section-of p = faithful (F-∘ _ _ βˆ™ p βˆ™ sym F-id)

  faithfulβ†’reflects-retract-of : (F₁ a) π’Ÿ.retract-of (F₁ b) β†’ a π’ž.retract-of b
  faithful→reflects-retract-of p = faithful→reflects-section-of p

  faithfulβ†’reflects-inverses : π’Ÿ.Inverses (F₁ a) (F₁ b) β†’ π’ž.Inverses a b
  faithfulβ†’reflects-inverses ab-inv .π’ž.Inverses.invl =
    faithfulβ†’reflects-section-of (π’Ÿ.Inverses.invl ab-inv)
  faithfulβ†’reflects-inverses ab-inv .π’ž.Inverses.invr =
    faithfulβ†’reflects-section-of (π’Ÿ.Inverses.invr ab-inv)

Fully faithful, essentially surjective functorsπŸ”—

If a functor is fully faithful and essentially surjective, then it preserves all mono- and epimorphisms. Keep in mind that, since we have not assumed that the categories involved are univalent, this condition is slightly weaker than being an equivalence of categories.

Let be a mono, and let be a pair of morphisms in satisfying that Since is eso, there merely exists a with Because is also full, there must merely exist a pair of morphisms satisfying and

module _ (ff : is-fully-faithful F) (eso : is-eso F) where
  ff+esoβ†’preserves-mono : π’ž.is-monic a β†’ π’Ÿ.is-monic (F₁ a)
  ff+esoβ†’preserves-mono {a = a} a-monic {x} f g p = βˆ₯-βˆ₯-out! do
    (x* , i) ← eso x
    (f* , q) ← ffβ†’full {F = F} ff (f π’Ÿ.∘ π’Ÿ.to i)
    (g* , r) ← ffβ†’full {F = F} ff (g π’Ÿ.∘ π’Ÿ.to i)

Next, note that this follows from faithfulness of and our hypothesis that

    let
      s =
        ff→faithful {F = F} ff $
        F₁ (a π’ž.∘ f*)           β‰‘βŸ¨ F-∘ _ _ βˆ™ π’Ÿ.pushr q βŸ©β‰‘
        (F₁ a π’Ÿ.∘ f) π’Ÿ.∘ π’Ÿ.to i β‰‘βŸ¨ apβ‚‚ π’Ÿ._∘_ p refl βŸ©β‰‘
        (F₁ a π’Ÿ.∘ g) π’Ÿ.∘ π’Ÿ.to i β‰‘βŸ¨ π’Ÿ.pullr (sym r) βˆ™ sym (F-∘ _ _) βŸ©β‰‘
        F₁ (a π’ž.∘ g*)           ∎

To wrap things up, recall that is monic, so and However, and by definition, so we can deduce that Finally, isomorphisms are epic, so we can cancel on the left, concluding that

    pure $ π’Ÿ.isoβ†’epic i f g $
      f π’Ÿ.∘ π’Ÿ.to i β‰‘Λ˜βŸ¨ q βŸ©β‰‘Λ˜
      F₁ f*        β‰‘βŸ¨ ap F₁ (a-monic f* g* s) βŸ©β‰‘
      F₁ g*        β‰‘βŸ¨ r βŸ©β‰‘
      g π’Ÿ.∘ π’Ÿ.to i ∎
As mentioned above, the same holds for epimorphisms. Since the proof is formally dual to the case above, we will not dwell on it.
  ff+esoβ†’preserves-epi : π’ž.is-epic a β†’ π’Ÿ.is-epic (F₁ a)
  ff+esoβ†’preserves-epi {a = a} a-epic {x} f g p = βˆ₯-βˆ₯-out! do
    (x* , i) ← eso x
    (f* , q) ← ffβ†’full {F = F} ff (π’Ÿ.from i π’Ÿ.∘ f)
    (g* , r) ← ffβ†’full {F = F} ff (π’Ÿ.from i π’Ÿ.∘ g)
    let s = F-∘ _ _ βˆ™ π’Ÿ.pushl q βˆ™ apβ‚‚ π’Ÿ._∘_ refl p βˆ™ π’Ÿ.pulll (sym r) βˆ™ sym (F-∘ _ _)
    pure $ π’Ÿ.isoβ†’monic (i π’Ÿ.Iso⁻¹) f g $
      sym q
      Β·Β· ap F₁ (a-epic f* g* (ffβ†’faithful {F = F} ff s))
      Β·Β· r

Left and right adjointsπŸ”—

If we are given an adjunction then the right adjoint preserves monomorphisms. Fix a mono and let satisfy We want to show and, by the adjunction, it will suffice to show that Since is a monomorphism, we can again reduce this to showing

which follows by a quick calculation.

  right-adjointβ†’preserves-monos : π’ž.is-monic a β†’ π’Ÿ.is-monic (F₁ a)
  right-adjoint→preserves-monos {a = a} a-monic f g p =
    Equiv.injective (_ , R-adjunct-is-equiv L⊣F) $
    a-monic _ _ $
    a π’ž.∘ Ξ΅ _ π’ž.∘ L.₁ f            β‰‘βŸ¨ π’ž.pulll (sym (counit.is-natural _ _ _)) βŸ©β‰‘
    (Ξ΅ _ π’ž.∘ L.₁ (F₁ a)) π’ž.∘ L.₁ f β‰‘βŸ¨ L.extendr p βŸ©β‰‘
    (Ξ΅ _ π’ž.∘ L.₁ (F₁ a)) π’ž.∘ L.₁ g β‰‘βŸ¨ π’ž.pushl (counit.is-natural _ _ _) βŸ©β‰‘
    a π’ž.∘ Ξ΅ _ π’ž.∘ L.₁ g            ∎
Dualizing this argument, we can show that left adjoints preserve epimorphisms.
module _ {R : Functor π’Ÿ π’ž} (F⊣R : F ⊣ R) where
  private
    module R = Cat.Functor.Reasoning R
  open _⊣_ F⊣R

  left-adjointβ†’preserves-epis : π’ž.is-epic a β†’ π’Ÿ.is-epic (F₁ a)
  left-adjoint→preserves-epis {a = a} a-epic f g p =
    Equiv.injective (_ , L-adjunct-is-equiv F⊣R) $
    a-epic _ _ $
    π’ž.pullr (unit.is-natural _ _ _)
    βˆ™ R.extendl p
    βˆ™ π’ž.pushr (sym (unit.is-natural _ _ _))