{- | Initial functors.
-
- A functor is initial if it is a left map ({CatFactor.Family.IsLeft}) of the factorization system generated by
- `dleft : 1 ->⁺ DI` ({InfCat.Fibration.FreeLeft}), that is, if the right factor {freeLeftProj} of its factorization
- is an equivalence. Initial functors are exactly the maps left orthogonal to left fibrations
- ({initialFunctor-orthogonal}, {orthogonal-IsLeft}).
- Restriction of sections of left fibrations along initial functors is an equivalence ({initialFunctor-sections}),
- and conversely it suffices to check this for the free left fibration ({sections-IsLeft}).
- Initial functors are closed under composition ({initialFunctor-comp}) and contain the equivalences ({hequiv-initialFunctor}).
- Left adjoints are initial ({ladj-initialFunctor}), and so are localizations ({localization-initialFunctor}),
- since they are left orthogonal to conservative functors ({localization-orthogonal}).
- Initial functors induce equivalences of geometric realizations ({initialFunctor-realization}).
-}
\import Equiv
\import InfCat.Basics
\import InfCat.Fibration.Covariant.FreeLeft
\import InfCat.Fibration.Covariant.LeftFib
\import InfCat.Functor.Adjunction
\import InfCat.Functor.Equiv
\import InfCat.Groupoid
\import InfCat.Limit.Initial
\import InfCat.Localization.CatWeakEq
\import InfCat.Localization.Concrete
\import InfCat.Localization.Realization
\import InfCat.OFS.CatAccessibleOFS
\import InfCat.OFS.CatOFS
\import InfCat.Paths
\import Logic
\import Paths
-- | {f} is initial if it is a left map of the factorization system generated by {leftFam}.
\type IsInitialFunctor {C D : \Cat} (f : C ->⁺ D) : \Prop
=> leftFam.IsLeft f
-- | Initial functors are left orthogonal to left fibrations.
\lemma initialFunctor-orthogonal {C D E B : \Cat} {f : C ->⁺ D} (fi : IsInitialFunctor f) {h : E ->⁺ B} (hr : leftFam.IsRight h)
: IsOrthogonal f h
=> IsLeft-orthogonal {leftFam} fi hr
-- | Initial functors are closed under composition.
\lemma initialFunctor-comp {A B C : \Cat} {f : A ->⁺ B} {g : B ->⁺ C} (fi : IsInitialFunctor f) (gi : IsInitialFunctor g)
: IsInitialFunctor (\lam x => g (f x))
=> \let r => catFactorRight.isRight {leftFam} {A} {C} {\lam x => g (f x)}
\in orthogonal-IsLeft {leftFam} (IsOrthogonal_o-left (initialFunctor-orthogonal fi r) (initialFunctor-orthogonal gi r))
-- | Equivalences are initial.
\lemma hequiv-initialFunctor {C D : \Cat} {f : C ->⁺ D} (fe : IsHEquiv f) : IsInitialFunctor f
=> orthogonal-IsLeft {leftFam} (IsOrthogonal_IsHEquiv-left fe)
-- | Localizations are initial.
\lemma localization-initialFunctor {C : CatWeakEq} {L : \Cat} {l : C ->⁺ L} (Lz : IsLocalization l)
: IsInitialFunctor l
=> orthogonal-IsLeft {leftFam} (localization-orthogonal Lz (leftFib-conservative (leftFam-right-char.1 (catFactorRight.isRight {leftFam} {C} {L} {l}))))
-- | Restriction of sections of a left fibration along an initial functor is an equivalence.
\lemma initialFunctor-sections {C D : \Cat} {f : C ->⁺ D} (fi : IsInitialFunctor f) {Q : D ->⁺ \Cat} (Ql : IsLeftFib Q)
: IsEquiv {\Pi (y :⁺ D) -> Q y} {\Pi (x :⁺ C) -> Q (f x)} (\lam s x => s (f x))
=> IsOrthogonal-family-sections (initialFunctor-orthogonal fi (leftFam-right-char.2 (leftFib-total Ql))) id+
{- | Initial functors induce equivalences of geometric realizations.
- For a groupoid `G`, functors out of the realizations are functors into `G` ({realization-univ}), that is,
- sections of the constant left fibration at `G`, so restriction along `realization-map f` is an equivalence ({precomp-equiv}).
- The claim follows by the Yoneda argument, since realizations are groupoids.
-}
\lemma initialFunctor-realization {C D : \Cat} {f : C ->⁺ D} (fi : IsInitialFunctor f) : IsHEquiv (realization-map f)
=> \let | eC => precomp-equiv fi {Realization C} realization-groupoid
| h => IsEquiv.ret eC (\lam x => x)
| hg : (\lam (x :⁺ Realization C) => h (realization-map f x)) = (\lam (x :⁺ Realization C) => x) => IsEquiv.f_ret eC {\lam x => x}
| gh : (\lam (y :⁺ Realization D) => realization-map f (h y)) = (\lam (y :⁺ Realization D) => y)
=> IsEquiv.isInj (precomp-equiv fi {Realization D} realization-groupoid) (path \lam i x => realization-map f (hg i x))
\in inP \new HQEquiv {
| finv => h
| finv_f x => path \lam i => hg i x
| f_finv y => path \lam i => gh i y
}
\where
-- | Restriction along `realization-map f` of functors into a groupoid is an equivalence.
\lemma precomp-equiv {C D : \Cat} {f : C ->⁺ D} (fi : IsInitialFunctor f) {G : \Cat} (Gg : IsGroupoid G)
: IsEquiv {Realization D ->⁺ G} {Realization C ->⁺ G} (\lam H x => H (realization-map f x))
=> IsEquiv.leftFactor (IsHEquiv.toIsEquiv (realization-univ {C} Gg))
(IsEquiv.trans (IsHEquiv.toIsEquiv (realization-univ {D} Gg)) (initialFunctor-sections fi (const-leftFib Gg)))
-- | Restriction of sections of a left fibration along a left adjoint is an equivalence.
\lemma ladj-sections {C D : \Cat} (Ad : QAdjunction C D) {Q : D ->⁺ \Cat} (Ql : IsLeftFib Q)
: IsEquiv {\Pi (y :⁺ D) -> Q y} {\Pi (x :⁺ C) -> Q (Ad.ladj x)} (\lam s d => s (Ad.ladj d))
=> inP \new QEquiv {
| ret t c => leftFib-tr Ql (Ad.heps c) (t (Ad.radj c))
| ret_f s => funExt+ \lam c => leftFib-tr-dpath Ql (dpath \lam i => s (Ad.heps c i))
| f_sec t => funExt+ \lam d =>
path (\lam i => leftFib-tr Ql (Ad.heps (Ad.ladj d)) (inv (leftFib-tr-dpath Ql (dpath \lam j => t (Ad.heta d j))) i))
*> inv (leftFib-tr_comp Ql _ _)
*> path (\lam i => leftFib-tr Ql (Ad.heta_heps-right i) (t d))
*> leftFib-tr_idd Ql
}
-- | Left adjoints are initial.
\lemma ladj-initialFunctor {C D : \Cat} (Ad : QAdjunction C D) : IsInitialFunctor Ad.ladj
=> sections-IsLeft {leftFam} (ladj-sections Ad (freeLeft-leftFib Ad.ladj))
-- | Restriction of sections of a family of types along a left adjoint is an equivalence.
\lemma ladj-sections-type.{u} {C D : \Cat} (Ad : QAdjunction C D) (G : D ->⁺ \Type u)
: IsEquiv {\Pi (y :⁺ D) -> G y} {\Pi (x :⁺ C) -> G (Ad.ladj x)} (\lam s d => s (Ad.ladj d))
=> ladj-sections Ad (leftFib-pullback G universe-leftFib)
-- | Sections of a family of types over a category with an initial object are determined by their value there.
\lemma initial-sections.{u} {C : \Cat} (c0 : C) (init : IsInitial c0) (G : C ->⁺ \Type u)
: IsEquiv {\Pi (c :⁺ C) -> G c} {G c0} (\lam s => s c0)
=> IsEquiv.trans (ladj-sections-type (IsInitial.adjunction init) G) (inP \new QEquiv {
| f t => t ()
| ret a _ => a
| ret_f t => idp
| f_sec a => idp
})