{- | The realization of `Δ/[1]` and edges of nerves.
- The realization of `Δ/[1]` is the walking arrow ({realization-slice}). It is generated by the zigzag {edgeZ}: from the vertex `0`
- to the terminal object of `Δ/[1]` ({edgeArr}), and back from the vertex `1`, along an arrow over the last vertex.
- * {edgeZ-hequiv}: {edgeZ} as a functor from {DI} is an equivalence onto the realization of `Δ/[1]`.
- * {nerve-edge-equiv}: the edges between two vertices of the simplicial nerve of {C} are the arrows of {C} between the corresponding
- objects ({snerve-ob}). An edge, a section over `Δ/[1]`, goes to the image of {edgeZ} under the corresponding functor
- out of the realization ({realize-map}).
-}
\import Category
\import Category.Simplex
\import Category.Slice
\import Arith.Fin.Order
\import Order.PartialOrder
\import Equiv
\import Equiv.Path
\import Equiv.Sigma
\import Function.Meta
\import InfCat.Basics
\import InfCat.Fibration.Categorical
\import InfCat.Fibration.Exponent.ExponentCocartesianCore
\import InfCat.Fibration.SimplexFib
\import InfCat.Functor.Equiv
\import InfCat.Functor.FullyFaithful
\import InfCat.Localization.CatWeakEq
\import InfCat.Localization.Concrete
\import InfCat.Nerve.Nerve
\import InfCat.Nerve.NerveHom
\import InfCat.Nerve.Simplicial.CospanIso
\import InfCat.Nerve.Simplicial.NerveSegal
\import InfCat.Nerve.Simplicial.Realization
\import InfCat.Nerve.Simplicial.SimplicialNerve
\import InfCat.Paths
\import InfCat.Rezk
\import InfCat.Simplicial.Segal
\import InfCat.Simplicial.SimplexSections
\import InfCat.Simplicial.SegalSquare
\import InfCat.Simplicial.SimplexOperators
\import Logic
\import Logic.Unique
\import Paths
\import Paths.Meta
\open SegalHelpers
\open NerveLow
\open RealizationHelpers (lastN, lastN-sec)
-- | The vertex {j} of `Δ/[1]` in the base change of the universal simplex, as a last vertex.
\func edgeOb (j : Fin 2) : BaseChange (sliceProj 1) (nerveMap simplexProj)
=> lastVertex (sliceProj 1) (edgeV j)
-- | The last vertex of the terminal object of `Δ/[1]`.
\func topOb : BaseChange (sliceProj 1) (nerveMap simplexProj)
=> lastVertex (sliceProj 1) (nerveOb {SliceS 1} (1, SimplexCat.id {1}))
-- | The arrow from the vertex {j} to the last vertex of the terminal object.
\func edgeArr (j : Fin 2) : edgeOb j ~> topOb
=> dpath \lam i => lastVertex (sliceProj 1) (sliceArr j i)
-- | The arrow from the vertex `1` lies over the last vertex.
\lemma edgeArr1-realWeakEq : isWeakEq {RealWeakEq (sliceProj 1)} (\lam i => edgeArr 1 i)
=> (lastWeakEq-char (vert 1)).2 idp
-- | The zigzag from the vertex `0` to the vertex `1` in the realization of `Δ/[1]`.
\func edgeZ : real (sliceProj 1) (edgeOb 0) ~> real (sliceProj 1) (edgeOb 1)
=> comp (dmap (real (sliceProj 1)) (edgeArr 0)) (=_~> (inv (IsIso_= ((localize-inverts {RealWeakEq (sliceProj 1)}).hfunc-we {\lam i => edgeArr 1 i} edgeArr1-realWeakEq)).1))
-- | The identification of the realization of `Δ/[1]` with `[1]`.
\func sliceR (y :⁺ Realization (sliceProj 1)) : Nerve (Simplex 1)
=> localize-lift (ellN-isLocalization (sliceProj 1) (slice-terminal 1) idp).1 y
-- | The vertex {j} of `Δ/[1]` is the vertex {j} of `[1]`.
\sfunc sliceR-vertex (j : Fin 2) : sliceR (real (sliceProj 1) (edgeOb j)) = nerveOb j
=> path (\lam k => (ellN-natural (sliceProj 1) (slice-terminal 1) idp (\lam (_ :⁺ Nerve (Simplex 0)) => edgeV j) (simplex-terminal 0) idp
(vert j) (sliceArr j) idp k) (pt0, (edgeOb j).2))
*> pmap (nerveMap (vert j)) (path \lam k => inv nerve0-contr k (ellN {Nerve (Simplex 0)} (\lam _ => nerveOb 0) (simplex-terminal 0) idp (pt0, (edgeOb j).2)))
-- | Functors out of {DI} into a category with propositional hom-types are determined by their endpoints.
\func thin-arrow-path {C : \Cat} (Ct : \Pi (a b : C) -> isProp (a ~> b)) {h h' : DI ->⁺ C}
(P0 : h dleft = h' dleft) (P1 : h dright = h' dright) : h = {DI ->⁺ C} h'
=> aux (dpath h) (dpath h') P0 P1
\where
\func aux {a b a' b' : C} (f : a ~> b) (f' : a' ~> b') (P0 : a = a') (P1 : b = b')
: (\lam i => f i) = {DI ->⁺ C} (\lam i => f' i) \elim P0, P1
| idp, idp => path \lam k => \lam i =>⁺ (Ct a b f f' k) i
-- | {edgeZ} is an equivalence from {DI} onto the realization of `Δ/[1]`.
\lemma edgeZ-hequiv : IsHEquiv (\lam (i :⁺ DI) => edgeZ i)
=> IsHEquiv.leftFactor (realization-slice 1) $
transport IsHEquiv (inv (thin-arrow-path nerve-preorder-prop {\lam i => sliceR (edgeZ i)} {n1arr} (sliceR-vertex 0) (sliceR-vertex 1))) n1arr-hequiv
-- | A section along {pi} evaluated at the last vertices of the objects of its base.
\func evLast.{u} {K D : \Cat u} (pi : K ->⁺ DeltaCat) (t : \Pi (k :⁺ K) -> SNerveFib D (pi k)) (k :⁺ K) : D
=> realize-map pi t (real pi (lastVertex pi k))
-- | {evLast} inverts {LastWeakEq}.
\lemma evLast-inverts.{u} {K D : \Cat u} (pi : K ->⁺ DeltaCat) (t : \Pi (k :⁺ K) -> SNerveFib D (pi k)) {a : DI ->⁺ K} (w : isWeakEq {LastWeakEq pi} a)
: IsIso (dmap (evLast pi t) (dpath a))
=> dmap_IsIso (realize-map pi t) ((localize-inverts {RealWeakEq pi}).hfunc-we {\lam i => lastVertex pi (a i)} w)
-- | {edgeZ} followed by the arrow from the vertex `1` is the arrow from the vertex `0`.
\sfunc edgeZ-eq : comp edgeZ (dmap (real (sliceProj 1)) (edgeArr 1)) = dmap (real (sliceProj 1)) (edgeArr 0)
=> \let P => IsIso_= ((localize-inverts {RealWeakEq (sliceProj 1)}).hfunc-we {\lam i => edgeArr 1 i} edgeArr1-realWeakEq)
\in pmap (comp edgeZ) (inv P.2) *> inv comp-assoc *> pmap (comp (dmap (real (sliceProj 1)) (edgeArr 0))) (=_~>_comp *> pmap+ =_~> inv_*>)
*> comp_idd-right
-- | The image of {edgeZ} under the functor of a section is the zigzag of its last vertices.
\sfunc edge-zigzag.{u} {C : \Cat u} (t : \Pi (s :⁺ Nerve (SliceS 1)) -> SNerveFib C (sliceProj 1 s))
: dmap (realize-map (sliceProj 1) t) edgeZ = comp_iso_dmap (evLast (sliceProj 1) t) (sliceArr 0) (sliceArr 1) (evLast-inverts (sliceProj 1) t edgeArr1-realWeakEq)
=> comp_iso_dmap-unique (evLast (sliceProj 1) t) (sliceArr 0) (sliceArr 1) (evLast-inverts (sliceProj 1) t edgeArr1-realWeakEq)
(inv (dmap_comp (realize-map (sliceProj 1) t)) *> pmap (dmap (realize-map (sliceProj 1) t)) edgeZ-eq)
-- | The realization of `Δ/[n]` has propositional hom-types, since it is `[n]`.
\lemma realization-slice-thin (n : Nat) (a b : Realization (sliceProj n)) : isProp (a ~> b)
=> isProp.equiv ((ff-surj-equiv.2 (realization-slice n)).1 a b) (nerve-preorder-prop _ _)
{- | For a section {t} of the nerve over `Δ/[1]`, the image of the arrow from the vertex `0` to the terminal object is an isomorphism
- if and only if the edge of the functor `[1] -> C` given by the top simplex is.
- In the realization of `Δ/[1]`, which is thin, that arrow is an arrow over the vertex `0` followed by the vertical arrow of the top simplex.
-}
\lemma evLast-edge-iso.{u} {C : \Cat u} (t : \Pi (s :⁺ Nerve (SliceS 1)) -> SNerveFib C (sliceProj 1 s))
: IsIso (dmap (evLast (sliceProj 1) t) (sliceArr 0)) <-> IsIso (n1edge (\lam s =>⁺ snerve-nu 1 (t (nerveOb (1, SimplexCat.id {1}))) s))
=> \let | top1 => nerveOb {SliceS 1} (1, SimplexCat.id {1})
| G => realize-map (sliceProj 1) t
| r (q :⁺ BaseChange (sliceProj 1) (nerveMap simplexProj)) => real (sliceProj 1) q
| al : ((edgeV 0, (nerveOb {SimplexTotal} (0, 0), idp)) : BaseChange (sliceProj 1) (nerveMap simplexProj))
~> ((top1, (nerveOb {SimplexTotal} (1, 0), idp)) : BaseChange (sliceProj 1) (nerveMap simplexProj))
=> dpath \lam i => (sliceArr 0 i, (nerveHom {SimplexTotal} {0, 0} {1, 0} (vert 0, <=-refl) i, idp))
| al-iso : IsIso (dmap r al) => (localize-inverts {RealWeakEq (sliceProj 1)}).hfunc-we {\lam i => al i}
(univSimplex-vertex-cocartesian {0} {1} {0} {0} (vert 0, <=-refl) idp)
| be : ((top1, univSimplexFib-incl 1 (nerveOb 0)) : BaseChange (sliceProj 1) (nerveMap simplexProj))
~> ((top1, univSimplexFib-incl 1 (nerveOb 1)) : BaseChange (sliceProj 1) (nerveMap simplexProj))
=> dpath \lam i => (top1, univSimplexFib-incl 1 (nerveHom {Simplex 1} {0} {1} h01 i))
| P1 : r (edgeOb 0) = r (edgeV 0, (nerveOb {SimplexTotal} (0, 0), idp)) => pmap (\lam w => r (edgeV 0, w)) (fibers-deltaCat-ext idp)
| P2 : r (top1, (nerveOb {SimplexTotal} (1, 0), idp)) = r (top1, univSimplexFib-incl 1 (nerveOb 0))
=> pmap (\lam w => r (top1, w)) (fibers-deltaCat-ext idp)
| Q : r (top1, univSimplexFib-incl 1 (nerveOb 1)) = r topOb => pmap (\lam w => r (top1, w)) (fibers-deltaCat-ext idp)
| A => comp (=_~> P1) (comp (dmap r al) (=_~> P2))
| A-iso : IsIso (dmap G A)
=> transportInv IsIso (dmap_comp G) $ comp-IsIso (transportInv IsIso (dmap_=_~> G) (=_~>-iso _)) $
transportInv IsIso (dmap_comp G) $ comp-IsIso (dmap_IsIso G al-iso) (transportInv IsIso (dmap_=_~> G) (=_~>-iso _))
| thin : dmap r (edgeArr 0) = comp (comp A (dmap r be)) (=_~> Q)
=> realization-slice-thin 1 _ _ _ _
| eq : dmap (evLast (sliceProj 1) t) (sliceArr 0) = comp (comp (dmap G A) (dmap G (dmap r be))) (=_~> (pmap+ G Q))
=> pmap (dmap G) thin *> dmap_comp G *> pmap (comp __ (dmap G (=_~> Q))) (dmap_comp G) *> pmap (comp _) (dmap_=_~> G)
\in (\lam i => (comp-IsIso-right A-iso).1 ((comp-IsIso-left (=_~>-iso _)).1 (transport IsIso eq i)),
\lam i => transportInv IsIso eq (comp-IsIso (comp-IsIso A-iso i) (=_~>-iso _)))
-- | The object of {C} given by a vertex of its nerve.
\func snerve-ob.{u} {C : \Cat u} (z : SNerveFib C (nerveOb 0)) : C
=> snerve-nu 0 z pt0
\lemma snerve-ob-equiv.{u} {C : \Cat u} : IsEquiv (snerve-ob {C})
=> IsEquiv.trans (snerve-nu-equiv 0) nerve0-ev-equiv
-- | The functor corresponding to a section over `Δ/[1]` at the vertex {j}.
\sfunc edge-vertex.{u} {C : \Cat u} (t : \Pi (s :⁺ Nerve (SliceS 1)) -> SNerveFib C (sliceProj 1 s)) (j : Fin 2)
: realize-map (sliceProj 1) t (real (sliceProj 1) (edgeOb j)) = snerve-ob (t (edgeV j))
=> pmap (ExpCocCore.fiber-eval univSimplex-cocartesianMap (t (edgeV j))) (fibers-deltaCat-ext idp *> inv (univSimplexFib-vertex 0 0))
-- | The arrow of {C} given by an edge of its nerve.
\func nerve-edge-map.{u} {C : \Cat u} (a b : SNerveFib C (nerveOb 0)) (w : EdgeSec (SNerve.proj C) a b) : snerve-ob a ~> snerve-ob b
=> transport2 (\lam c c' => c ~> c') (edge-vertex w.1 0 *> pmap snerve-ob w.2) (edge-vertex w.1 1 *> pmap snerve-ob w.3)
(dmap (realize-map (sliceProj 1) w.1) edgeZ)
-- | Edges between two vertices of the nerve of {C} are arrows between the corresponding objects of {C}.
\lemma nerve-edge-equiv.{u} {C : \Cat u} (a b : SNerveFib C (nerveOb 0)) : IsEquiv (nerve-edge-map a b)
=> \let | e1 : IsEquiv {EdgeSec (SNerve.proj C) a b}
{\Sigma (F : Realization.{u} (sliceProj 1) ->⁺ C) (F (real.{u} (sliceProj 1) (edgeOb 0)) = snerve-ob a) (F (real.{u} (sliceProj 1) (edgeOb 1)) = snerve-ob b)}
(\lam w => (realize-map.{u} (sliceProj 1) w.1, edge-vertex w.1 0 *> pmap snerve-ob w.2, edge-vertex w.1 1 *> pmap snerve-ob w.3))
=> sigma3-equiv (realization-adj.{u} (sliceProj 1))
{\lam t P0 => edge-vertex t 0 *> pmap snerve-ob P0}
(\lam t => inP (transQEquiv (IsEquiv.toQEquiv (pmapIsEquiv snerve-ob-equiv)) (pullback-equiv.concat-left (edge-vertex t 0))))
{\lam t P1 => edge-vertex t 1 *> pmap snerve-ob P1}
(\lam t => inP (transQEquiv (IsEquiv.toQEquiv (pmapIsEquiv snerve-ob-equiv)) (pullback-equiv.concat-left (edge-vertex t 1))))
| e2 : IsEquiv {\Sigma (F : Realization.{u} (sliceProj 1) ->⁺ C) (F (real.{u} (sliceProj 1) (edgeOb 0)) = snerve-ob a) (F (real.{u} (sliceProj 1) (edgeOb 1)) = snerve-ob b)}
{\Sigma (h : DI ->⁺ C) (h dleft = snerve-ob a) (h dright = snerve-ob b)}
(\lam s => (\lam i => s.1 (edgeZ i), s.2, s.3))
=> sigma3-equiv (IsHEquiv.toIsEquiv (IsHEquiv.precomp {_} {_} {C} edgeZ-hequiv)) {\lam F P => P} (\lam F => inP idEquiv) {\lam F P => P} (\lam F => inP idEquiv)
| res => IsEquiv.trans e1 (IsEquiv.trans e2 (arrow-ends-equiv (snerve-ob a) (snerve-ob b)))
\in res
-- | Functors from {DI} with given endpoints are arrows between them.
\lemma arrow-ends-equiv {C : \Cat} (c c' : C)
: IsEquiv {\Sigma (h : DI ->⁺ C) (h dleft = c) (h dright = c')} {c ~> c'} (\lam s => transport2 (\lam x y => x ~> y) s.2 s.3 (dpath s.1))
=> inP \new QEquiv {
| ret f => (\lam i => f i, idp, idp)
| ret_f s => aux s.2 s.3
| f_sec _ => idp
}
\where
\private \func aux {h : DI ->⁺ C} {c c' : C} (P : h dleft = c) (Q : h dright = c')
: ((\lam i => transport2 (\lam x y => x ~> y) P Q (dpath h) i, idp, idp) : \Sigma (h : DI ->⁺ C) (h dleft = c) (h dright = c')) = (h, P, Q) \elim P, Q
| idp, idp => idp
-- | A map of triples with independent second and third components is an equivalence if it is one componentwise.
\lemma sigma3-equiv {A A' : \Cat} {B C : A -> \Cat} {B' C' : A' -> \Cat} {f : A -> A'} (fe : IsEquiv f)
{g : \Pi (a : A) -> B a -> B' (f a)} (ge : \Pi (a : A) -> IsEquiv (g a))
{h : \Pi (a : A) -> C a -> C' (f a)} (he : \Pi (a : A) -> IsEquiv (h a))
: IsEquiv {\Sigma (a : A) (B a) (C a)} {\Sigma (a : A') (B' a) (C' a)} (\lam s => (f s.1, g s.1 s.2, h s.1 s.3))
=> \let | nested : IsEquiv {\Sigma (a : A) (\Sigma (B a) (C a))} {\Sigma (a : A') (\Sigma (B' a) (C' a))} (\lam s => (f s.1, (g s.1 s.2.1, h s.1 s.2.2)))
=> inP (sigma-equiv (IsEquiv.toQEquiv fe) \lam a => sigma-equiv (IsEquiv.toQEquiv (ge a)) \lam _ => IsEquiv.toQEquiv (he a))
| l : IsEquiv {\Sigma (a : A) (B a) (C a)} {\Sigma (a : A) (\Sigma (B a) (C a))} (\lam s => (s.1, (s.2, s.3)))
=> inP \new QEquiv { | ret t => (t.1, t.2.1, t.2.2) | ret_f _ => idp | f_sec _ => idp }
| r : IsEquiv {\Sigma (a : A') (\Sigma (B' a) (C' a))} {\Sigma (a : A') (B' a) (C' a)} (\lam s => (s.1, s.2.1, s.2.2))
=> inP \new QEquiv { | ret t => (t.1, (t.2, t.3)) | ret_f _ => idp | f_sec _ => idp }
| res => IsEquiv.trans l (IsEquiv.trans nested r)
\in res
-- | A section {t} of `Fibers p` over {pi} as a functor of base changes.
\func fibSec-map.{u} {K E : \Cat u} {pi : K ->⁺ DeltaCat} {p : E ->⁺ DeltaCat} (t : \Pi (k :⁺ K) -> Fibers p (pi k))
(q :⁺ BaseChange pi (nerveMap simplexProj)) : BaseChange p (nerveMap simplexProj)
=> ((t q.1).1, (q.2.1, q.2.2 *> inv (t q.1).2))
-- | {fibSec-map} preserves {RealWeakEq}.
\func fibSec-weakEq.{u} {K E : \Cat u} {pi : K ->⁺ DeltaCat} {p : E ->⁺ DeltaCat} (t : \Pi (k :⁺ K) -> Fibers p (pi k))
: FuncWeakEq (RealWeakEq pi) (RealWeakEq p) (fibSec-map t) \cowith
| hfunc-we w => w
-- | {fibSec-map} preserves last vertices.
\sfunc fibSec-lastVertex.{u} {K E : \Cat u} {pi : K ->⁺ DeltaCat} {p : E ->⁺ DeltaCat} (t : \Pi (k :⁺ K) -> Fibers p (pi k)) (k :⁺ K)
: fibSec-map t (lastVertex pi k) = lastVertex p (t k).1
=> path \lam i => ((t k).1, helper (t k).2 i)
\where
\protected \func helper {b b' :⁺ DeltaCat} (r :⁺ b' = b)
: (lastN b, path (\lam j => lastN-sec j b) *> inv r) = {UnivSimplexFib b'} (lastN b', path \lam j => lastN-sec j b') \elim r
| idp => idp
{- | {realize-map} is natural along sections: the functor corresponding to the restriction of {s} along a section {t}
- is the functor corresponding to {s} precomposed with the functor of realizations induced by {t}.
-}
\sfunc realize-map-fib.{u} {K E D : \Cat u} (pi : K ->⁺ DeltaCat) {p : E ->⁺ DeltaCat}
(t : \Pi (k :⁺ K) -> Fibers p (pi k)) (s : \Pi (e :⁺ E) -> SNerveFib D (p e))
: realize-map pi (\lam k => transport+ (SNerveFib D) (t k).2 (s (t k).1))
= {Realization pi ->⁺ D} (\lam y => realize-map p s (localize-map (fibSec-weakEq t) y))
=> IsEquiv.isInj (localize-ob-equiv {RealWeakEq pi} {D}) {realize-map pi (\lam k => transport+ (SNerveFib D) (t k).2 (s (t k).1))}
{\lam y => realize-map p s (localize-map (fibSec-weakEq t) y)} (ext (ext \lam q =>
eval-tr (t q.1).2 (s (t q.1).1) q.2
*> path (\lam m => ExpCocCore.fiber-eval univSimplex-cocartesianMap (s (t q.1).1) (tr-fib (inv (t q.1).2) q.2.1 q.2.2 m))))
\where {
\func eval-tr.{v} {C : \Cat v} {b b' :⁺ DeltaCat} (q :⁺ b = b') (z :⁺ SNerveFib C b) (x :⁺ UnivSimplexFib b')
: ExpCocCore.fiber-eval univSimplex-cocartesianMap (transport+ (SNerveFib C) q z) x
= ExpCocCore.fiber-eval univSimplex-cocartesianMap z (transport+ UnivSimplexFib (inv q) x) \elim q
| idp => idp
\func tr-fib {b b' :⁺ DeltaCat} (q :⁺ b = b') (w :⁺ Nerve SimplexTotal) (P :⁺ nerveMap simplexProj w = b)
: transport+ UnivSimplexFib q (w, P) = {UnivSimplexFib b'} (w, P *> q) \elim q
| idp => idp
}