{- | The slice category of A ->⁺ \Type u over F is equivalent to
- the category of functors \Sigma⁺ (x : X) (F x) ->⁺ \Type u ({sumSlice-equiv}).
- The inverse is {sliceFiber}, which is natural in F.
-
- Pullbacks of slices of `X ->⁺ \Type u` are computed by precomposing with `totalMap` ({pullbackSlice-isProduct}).
-}
\import Equiv
\import Equiv.Fiber
\import Equiv.Sigma
\import Function.Meta
\import InfCat.Basics
\import InfCat.Fibration.Univalence.DirectedUnivalence
\import InfCat.Fibration.Covariant.LeftFib
\import InfCat.Fibration.Univalence.Straightening
\import InfCat.Functor.Conservative
\import InfCat.Functor.Equiv
\import InfCat.Functor.FullyFaithful
\import InfCat.Limit.Product
\import InfCat.Slice
\import InfCat.Square
\import InfCat.Paths
\import InfCat.Yoneda.CovariantYoneda
\import Logic
\import Logic.Unique
\import Meta
\import Paths
\import Paths.Meta
\open FunctorCartesian
\open sumSlice
\open sumSlice-equiv
-- | The slice category over {F}.
\func Slice.{u} {X : \Cat u} (F :⁺ X ->⁺ \Type u) : \Cat
=> SliceCat {X ->⁺ \Type u} F
-- | Functors on the total category of {F} as objects over {F}.
\func sumSlice.{u} {X : \Cat u} (F :⁺ X ->⁺ \Type u) (G' :⁺ \Sigma⁺ (x : X) (F x) ->⁺ \Type u) : Slice F
=> (sumFam F G', sumProj F G')
\where {
-- | The sum of a functor on the total category of {F} over the fibers of {F}.
\func sumFam.{u} {X : \Cat u} (F :⁺ X ->⁺ \Type u) (G' :⁺ \Sigma⁺ (x : X) (F x) ->⁺ \Type u) (x :⁺ X) : \Type u
=> \Sigma⁺ (t : F x) (G' (x,t))
-- | The projection of {sumFam} to {F}.
\func sumProj.{u} {X : \Cat u} (F :⁺ X ->⁺ \Type u) (G' :⁺ \Sigma⁺ (x : X) (F x) ->⁺ \Type u) : sumFam F G' ~> F
=> dpath \lam i x => dpath (iso+ {sumFam F G' x} {F x} \lam s => s.1) i
-- | The action of {sumFam} on an arrow {h} fixes the first component and acts by {h} on the second one.
\sfunc sumFam-dmap.{u} {X : \Cat u} (F : X ->⁺ \Type u) {P P' : \Sigma⁺ (x : X) (F x) ->⁺ \Type u} (h : P ~> P')
{x :⁺ X} {t :⁺ F x} {p :⁺ P (x,t)}
: ~>_-> (dpath \lam i => sumFam F (h i) x) (t, p) = (t, ~>_-> (dpath \lam i => h i (x,t)) p)
=> aux (~>_= (dpath \lam i => coe+ (sumProj F (h i) __ x) (coe+ (\lam i => sumFam F (h i) x) (t, p) i) dright))
(pmap+ (\lam k => k ((x,t),p)) (sumSlice-equiv.value-yoneda F P h))
\where
\private \func aux {A :⁺ \Type} {B :⁺ A ->⁺ \Type} {a a' :⁺ A} {b :⁺ B a} {b' :⁺ B a'} (e :⁺ a = a') (v :⁺ b = transport+ B (inv e) b')
: (a', b') = {\Sigma⁺ (x : A) (B x)} (a, b) \elim e
| idp => path \lam i => (a, inv v i)
}
-- | The fiber of {s} over {y}; it is covariant in {F}, {s} and {y}, and it is the inverse of {sumSlice} ({sumSlice-equiv.totalFun-slice}).
\func sliceFiber.{u} {X : \Cat u} (F :⁺ X ->⁺ \Type u) (s :⁺ Slice F) (y :⁺ \Sigma⁺ (x : X) (F x)) : \Type u
=> Straight leftFib small (F, (s, y))
\where {
-- | The action of an arrow of functors to types on the total category.
\func covMap.{v} {X : \Cat v} {G F :⁺ X ->⁺ \Type v} (a :⁺ G ~> F) (s :⁺ \Sigma⁺ (x : X) (G x)) : F s.1
=> ~>_-> (dpath \lam i => a i s.1) s.2
-- | Functors to types with an object over them and a point of the total category.
\func Base.{v} {X : \Cat v} : \Cat
=> \Sigma⁺ (F : X ->⁺ \Type v) (\Sigma⁺ (s : Slice F) (\Sigma⁺ (x : X) (F x)))
-- | The fibers of objects of slices, as a family of categories.
\func FibCat.{v} {X : \Cat v} (w :⁺ Base {X}) : \Cat
=> \Sigma⁺ (g : w.2.1.1 w.2.2.1) (covMap w.2.1.2 (w.2.2.1, g) = w.2.2.2)
\lemma leftFib.{v} {X : \Cat v} : IsLeftFib (FibCat {X})
=> leftFib-sigma {Base {X}} {\lam w => w.2.1.1 w.2.2.1} (leftFib-pullback (\lam (w : Base {X}) => w.2.1.1 w.2.2.1) universe-leftFib)
{\lam z => covMap z.1.2.1.2 (z.1.2.2.1, z.2) = z.1.2.2.2}
(leftFib-path (leftFib-pullback (\lam (z : \Sigma⁺ (w : Base {X}) (w.2.1.1 w.2.2.1)) => z.1.1 z.1.2.2.1) universe-leftFib)
(\lam z => covMap z.1.2.1.2 (z.1.2.2.1, z.2)) (\lam z => z.1.2.2.2))
\lemma small.{v} {X : \Cat v} (w : Base {X}) : IsSmall.{v} (FibCat w)
=> IsSmall.fromGroupoid (leftFib-grpd leftFib w) {\Sigma (g : w.2.1.1 w.2.2.1) (covMap w.2.1.2 (w.2.2.1, g) = w.2.2.2)}
\new QEquiv {\Sigma (g : w.2.1.1 w.2.2.1) (covMap w.2.1.2 (w.2.2.1, g) = w.2.2.2)} {FibCat w} {
| f u => (u.1, u.2)
| ret u => (u.1, u.2)
| ret_f u => idp
| f_sec u => idp
}
}
-- | The categories of functors on the total category of {F} and functors over {F} are equivalent.
\lemma sumSlice-equiv.{u} {X : \Cat u} (F : X ->⁺ \Type u) : IsHEquiv (sumSlice F)
=> ff-surj-equiv.1 (sumSlice-ff F, \lam s => inP (fibFam s.2, (totalFun-slice F).f_sec s))
\where {
\open sumSlice
-- | The fibers of a functor {G} over {F}.
\func fibFam.{u} {X : \Cat u} {F G : X ->⁺ \Type u} (a : G ~> F) (s :⁺ \Sigma⁺ (x : X) (F x)) : \Type u
=> sliceFiber F (G, a) s
-- | The equivalence on the level of objects.
\sfunc totalFun-slice.{u} {X : \Cat u} (F : X ->⁺ \Type u) : QEquiv (sumSlice F) (\lam s => fibFam s.2) \cowith
| ret_f G' => (fun-path {_} {fibFam (sumProj F G')} {G'}
(\lam s => transport+ (\lam t => G' (s.1.1, t)) (Straight.fromStraight s.2).2 (Straight.fromStraight s.2).1.2)
(sum-fib-equiv G')).1
| f_sec s => \let | h (u :⁺ \Sigma⁺ (x : X) (sumFam F (fibFam s.2) x)) : s.1 u.1 => (Straight.fromStraight u.2.2).1
| r => fun-path {_} {sumFam F (fibFam s.2)} {s.1} h (\lam x => fib-sum-equiv s.2 x)
| Q => depUnivalence {X} {sumFam F (fibFam s.2)} {F}
| Q' => depUnivalence {X} {sumFam F (fibFam s.2)} {s.1}
\in sigma-ext r.1 $ transport+-slice r.1 $ later $
pmap {\Pi (u :⁺ \Sigma⁺ (x : X) (sumFam F (fibFam s.2) x)) -> F u.1} Q.ret
(ext \lam u => inv (Straight.fromStraight u.2.2).2 *> inv (~>_->_comp-fam (Q'.ret h) s.2 u.1 u.2))
*> Q.ret_f _ *> pmap (comp __ s.2) (inv r.2)
\where {
-- | The fibers of the sum of {G'} are the values of {G'}.
\lemma sum-fib-equiv.{v} {X : \Cat v} {F : X ->⁺ \Type v} (G' : \Sigma⁺ (x : X) (F x) ->⁺ \Type v) (x : \Sigma⁺ (x : X) (F x))
: IsEquiv {fibFam (sumProj F G') x} {G' x}
(\lam r => transport+ (\lam t => G' (x.1, t)) (Straight.fromStraight r).2 (Straight.fromStraight r).1.2)
=> IsEquiv.trans (inP Straight.equiv) $ inP \new QEquiv {
| ret g => ((x.2, g), idp)
| ret_f u => aux u.2
| f_sec g => idp
}
\where
\private \func aux.{w} {X : \Cat w} {F : X ->⁺ \Type w} {G' : \Sigma⁺ (x : X) (F x) ->⁺ \Type w} {x : X} {t : F x} {u : sumFam F G' x} (e : u.1 = t)
: ((t, transport+ (\lam t' => G' (x, t')) e u.2), idp) = {sliceFiber.FibCat (F, ((sumFam F G', sumProj F G'), (x,t)))} (u, e) \elim e
| idp => idp
\private \lemma fib-sum-equiv.{v} {X : \Cat v} {F G : X ->⁺ \Type v} (a : G ~> F) (x : X)
: IsEquiv {sumFam F (fibFam a) x} {G x} (\lam u => (Straight.fromStraight u.2).1)
=> inP \new QEquiv {
| ret g => (sliceFiber.covMap a (x, g), Straight.toStraight (g, idp))
| ret_f u => aux *> path \lam i => (u.1, Straight.toStraight_fromStraight u.2 i)
| f_sec g => idp
}
\where
\func aux.{w} {X : \Cat w} {F G : X ->⁺ \Type w} {a : G ~> F} {x : X} {t : F x} {g : G x} {e : sliceFiber.covMap a (x, g) = t}
: (sliceFiber.covMap a (x, g), Straight.toStraight (g, idp)) = {sumFam F (fibFam a) x} (t, Straight.toStraight (g, e)) \elim e
| idp => idp
}
\func value.{v} {X : \Cat v} (F : X ->⁺ \Type v) (P : \Sigma⁺ (x : X) (F x) ->⁺ \Type v)
(k :⁺ \Sigma⁺ (P' : \Sigma⁺ (x : X) (F x) ->⁺ \Type v) (P ~> P')) (s :⁺ \Sigma⁺ (z : \Sigma⁺ (x : X) (F x)) (P z)) : k.1 s.1
=> transport+ (\lam t => k.1 (s.1.1, t))
(inv (~>_= (dpath \lam i => coe+ (\lam j => sumProj F (k.2 i) j s.1.1) (coe+ (\lam i => sumFam F (k.2 i) s.1.1) (s.1.2, s.2) i) dright)))
(~>_-> (dpath \lam i => sumFam F (k.2 i) s.1.1) (s.1.2, s.2)).2
-- | {value} is {depUnivalence}.
\func value-yoneda.{v} {X : \Cat v} (F : X ->⁺ \Type v) (P : \Sigma⁺ (x : X) (F x) ->⁺ \Type v) {P' : \Sigma⁺ (x : X) (F x) ->⁺ \Type v} (h : P ~> P')
: depUnivalence h = value F P (P', h)
=> inv $ pmap (\lam M => M (P', h)) $ QEquiv.isInj
{coslice-yoneda P (\lam k => \Pi (s :⁺ \Sigma⁺ (z : \Sigma⁺ (x : X) (F x)) (P z)) -> k.1 s.1)}
{value F P} {\lam k s => ~>_-> (dpath \lam i => k.2 i s.1) s.2}
(ext \lam s => value-idd (\lam t => P (s.1.1, t)) s.1.2 s.2)
-- | {value} at the identity: transport along the identity in a sum of types.
\sfunc value-idd.{v} {A :⁺ \Type v} (B :⁺ A ->⁺ \Type v) (a :⁺ A) (b :⁺ B a)
: transport+ B (inv (~>_= (dpath \lam i => (coe+ (\lam _ => \Sigma⁺ (a' : A) (B a')) (a, b) i).1))) (coe+ (\lam _ => \Sigma⁺ (a' : A) (B a')) (a, b) dright).2
= coe+ (\lam _ => B a) b dright
=> pmap+ (\lam l => transport+ B (inv (~>_= (dpath \lam i => (l.2 i).1))) l.1.2) $
leftFib-lift-unique universe-leftFib
{\Sigma⁺ (a' : A) (B a'), \Sigma⁺ (a' : A) (B a'), idd, later (a, b)}
{coe+ (\lam _ => \Sigma⁺ (a' : A) (B a')) (a, b) dright, dpath \lam i => coe+ (\lam _ => \Sigma⁺ (a' : A) (B a')) (a, b) i}
{later (a, coe+ (\lam _ => B a) b dright), dpath \lam i => ((a, coe+ (\lam _ => B a) b i) : \Sigma⁺ (a' : A) (B a'))}
-- | {sumSlice} is fully faithful.
\lemma sumSlice-ff.{u} {X : \Cat u} (F : X ->⁺ \Type u) : IsFFMap (sumSlice F)
=> \lam P P' => IsEquiv.leftFactor SliceCat.hom-equiv $
transport IsEquiv (ext \lam h =>
\have q => (\peval ~>-natural (sumProj F) {P} {P'} {h}) *> inv (\peval ~>-natural (\lam s => s.2) {sumSlice F P} {sumSlice F P'} {dmap (sumSlice F) h})
\in path (\lam i => (dmap (sumFam F) h, q i)))
(sumSlice-hom-equiv F P P')
\where \private {
{- | Triangles in the category of functors to types are pointwise paths.
- A 2-cell `t` with sides {k}, {b} and {a} gives, for every point `s` of {G}, a path from the transport of `s` along {a}
- to its transport along {k} followed by {b}; it is obtained by transporting `s` along {k} and then along `t`.
-}
\lemma triangle-pointwise-equiv.{u} {X : \Cat u} {G G' F : X ->⁺ \Type u} (k : G ~> G') (b : G' ~> F) (a : G ~> F)
: IsEquiv {DPath (\lam i => k i ~> F) a b}
{\Pi (s :⁺ \Sigma⁺ (x : X) (G x)) -> ~>_-> (dpath \lam j => a j s.1) s.2 = ~>_-> (dpath \lam j => b j s.1) (~>_-> (dpath \lam i => k i s.1) s.2)}
(\lam t s => ~>_= (dpath \lam i => coe+ (\lam j => t i j s.1) (coe+ (\lam i => k i s.1) s.2 i) dright))
=> \let | f (a' : G ~> F) (t : DPath (\lam i => k i ~> F) a' b) (s :⁺ \Sigma⁺ (x : X) (G x))
=> ~>_= (dpath \lam i => coe+ (\lam j => t i j s.1) (coe+ (\lam i => k i s.1) s.2 i) dright)
| cZ' : Contr (\Sigma (a' : G ~> F) (\Pi (s :⁺ \Sigma⁺ (x : X) (G x)) ->
~>_-> (dpath \lam j => a' j s.1) s.2 = ~>_-> (dpath \lam j => b j s.1) (~>_-> (dpath \lam i => k i s.1) s.2)))
=> Contr.Contr_QEquiv (symQEquiv (sigma-right \lam (a' : G ~> F) => later funExt+-equiv)) $
IsEquiv=>contrFibers (inP depUnivalence) \lam s => ~>_-> (dpath \lam j => b j s.1) (~>_-> (dpath \lam i => k i s.1) s.2)
\in (totalEquiv f).2 (contr-equiv (SliceCat.triangle-contr k b) cZ') a
-- | Triangles over {F} between the sums of {P} and {P'} are sections of {P'} over the total category of {P}.
\func section-equiv.{v} {X : \Cat v} (F : X ->⁺ \Type v) (P P' : \Sigma⁺ (x : X) (F x) ->⁺ \Type v)
: QEquiv {\Sigma (k : sumFam F P ~> sumFam F P') (DPath (\lam i => k i ~> F) (sumProj F P) (sumProj F P'))}
{\Pi (s :⁺ \Sigma⁺ (z : \Sigma⁺ (x : X) (F x)) (P z)) -> P' s.1}
=> sigma-right (\lam k => IsEquiv.toQEquiv (triangle-pointwise-equiv k (sumProj F P') (sumProj F P)))
`transQEquiv` qsigma-left (depUnivalence {X} {sumFam F P} {sumFam F P'})
`transQEquiv` later \new QEquiv {\Sigma (c : \Pi (u :⁺ \Sigma⁺ (x : X) (sumFam F P x)) -> sumFam F P' u.1)
(\Pi (u :⁺ \Sigma⁺ (x : X) (sumFam F P x)) -> u.2.1 = (c u).1)} {
| f p s => transport+ (\lam t => P' (s.1.1, t)) (inv (p.2 (s.1.1, (s.1.2, s.2)))) (p.1 (s.1.1, (s.1.2, s.2))).2
| ret q => (\lam u => (u.2.1, q ((u.1, u.2.1), u.2.2)), \lam u => idp)
| ret_f p => path \lam i => (\lam u => (aux F (p.2 u) i).1, \lam u => (aux F {P'} (p.2 u) i).2)
| f_sec q => idp
}
\where
-- | The round trip of the last step of {section-equiv}.
\private \func aux.{v} {X : \Cat v} (F : X ->⁺ \Type v) {P' : \Sigma⁺ (x : X) (F x) ->⁺ \Type v}
{x :⁺ X} {c :⁺ \Sigma⁺ (t' : F x) (P' (x, t'))} {t :⁺ F x} (e :⁺ t = c.1)
: ((t, transport+ (\lam t' => P' (x, t')) (inv e) c.2), idp) = {\Sigma⁺ (c' : \Sigma⁺ (t' : F x) (P' (x, t'))) (t = c'.1)} (c, e) \elim e
| idp => idp
{- | Transformations of functors on the total category of {F} are transformations of their sums over {F}
- together with the naturality square of {sumProj}.
-
- This is the hom-level part of {totalFun-slice}; it is {sumSlice-triangle-equiv} with triangles read off as in {~>-natural}.
-}
\lemma sumSlice-hom-equiv.{u} {X : \Cat u} (F : X ->⁺ \Type u) (P P' : \Sigma⁺ (x : X) (F x) ->⁺ \Type u)
: IsEquiv {P ~> P'} {\Sigma (k : sumFam F P ~> sumFam F P') (comp k (sumProj F P') = comp (sumProj F P) idd)}
(\lam h => (dmap (sumFam F) h, ~>-natural (sumProj F)))
=> transport IsEquiv (ext \lam h =>
\have q => (\peval ~>-natural (\lam s => s.2) {sumSlice F P} {sumSlice F P'} {dpath \lam i => (sumFam F (h i), sumProj F (h i))})
*> inv (\peval ~>-natural (sumProj F) {P} {P'} {h})
\in path (\lam i => (dmap (sumFam F) h, q i)))
(IsEquiv.trans (sumSlice-triangle-equiv F P P')
(inP $ sigma-right \lam k => IsEquiv.toQEquiv $ SliceCat.triangle-equiv (sumProj F P) (sumProj F P') k))
{- | Transformations of functors on the total category of {F} are transformations of their sums over {F}
- together with the triangle of {sumProj}; this is the action of {sumSlice} on arrows, up to {dpath-sigma-equiv}.
-
- The triangles are sections of `P'` over the total category of `P` ({section-equiv}, via {triangle-pointwise-equiv}).
- The composite of the action on arrows with this equivalence is {depUnivalence}: both are natural in the arrow,
- so by the Yoneda lemma {coslice-yoneda} it is enough to compare them at the identity ({value-idd}).
-}
\lemma sumSlice-triangle-equiv.{u} {X : \Cat u} (F : X ->⁺ \Type u) (P P' : \Sigma⁺ (x : X) (F x) ->⁺ \Type u)
: IsEquiv {P ~> P'} {\Sigma (k : sumFam F P ~> sumFam F P') (DPath (\lam i => k i ~> F) (sumProj F P) (sumProj F P'))}
(\lam h => (dmap (sumFam F) h, dpath \lam i => sumProj F (h i)))
=> IsEquiv.leftFactor (inP (section-equiv F P P')) $ transport IsEquiv (path \lam j h => value-yoneda F P h j) (inP depUnivalence)
}
}
-- | {sliceFiber} is an equivalence: it is a functorial inverse of {sumSlice}, since the unit {sliceFiber-equiv.unit} is a natural isomorphism.
\lemma sliceFiber-equiv.{u} {X : \Cat u} (F : X ->⁺ \Type u) : IsHEquiv (sliceFiber F)
=> IsHEquiv.rightFactor (sumSlice-equiv F) $ transport IsHEquiv
(natIso-path (unit F) \lam G' => objectwise-iso \lam z => ~>_->-equiv-iso (unit-equiv G' z)) idHEquiv
\where \private {
-- | The inclusion of a functor on the total category of {F} into the fibers of its sum.
\func unit.{v} {X : \Cat v} (F : X ->⁺ \Type v) (G' :⁺ \Sigma⁺ (x : X) (F x) ->⁺ \Type v) : G' ~> sliceFiber F (sumSlice F G')
=> dpath \lam i y => dpath (iso+ {G' y} {sliceFiber F (sumSlice F G') y} \lam g => Straight.toStraight ((y.2, g), idp)) i
-- | {unit} is a pointwise equivalence, being a section of {totalFun-slice.sum-fib-equiv}.
\lemma unit-equiv.{v} {X : \Cat v} {F : X ->⁺ \Type v} (G' : \Sigma⁺ (x : X) (F x) ->⁺ \Type v) (z : \Sigma⁺ (x : X) (F x))
: IsEquiv {G' z} {sliceFiber F (sumSlice F G') z} (\lam g => Straight.toStraight ((z.2, g), idp))
=> IsEquiv.leftFactor (totalFun-slice.sum-fib-equiv G' z) (inP idEquiv)
}
-- | Postcomposition with {a} maps the fiber of {s} over {y} to the fiber of `s ; a` over the image of {y}.
\func sliceFiber-postcomp.{u} {X : \Cat u} {F G : X ->⁺ \Type u} (a : F ~> G) {s :⁺ Slice F} (y :⁺ \Sigma⁺ (x : X) (F x)) (e :⁺ sliceFiber F s y)
: sliceFiber G (s.1, comp s.2 a) (pullbackSlice-isProduct.totalMap a y)
=> Straight.toStraight ((Straight.fromStraight e).1,
~>_->_comp-fam s.2 a y.1 (Straight.fromStraight e).1 *> pmap+ (\lam z => sliceFiber.covMap a (y.1, z)) (Straight.fromStraight e).2)
{- | If {g0} is a universal element of `s.1 ∘ phi`, then {sliceFiber} of {s} along {phi} has a universal element over the image of {g0}.
- Summed over the second coordinate, arrows out of the base point are arrows of {Y} and elements of {sliceFiber} are elements of `s.1`;
- under these identifications, transport of the base point is transport of {g0}.
-}
\lemma sliceFiber-univElem.{u} {Y X : \Cat u} (phi : Y ->⁺ X) (F : X ->⁺ \Type u) (s : Slice F) {y0 : Y} {g0 : s.1 (phi y0)}
(U : IsUnivElem (\lam y => s.1 (phi y)) y0 g0)
: IsUnivElem {\Sigma⁺ (y : Y) (F (phi y))} (\lam w => sliceFiber F s (phi w.1, w.2)) (y0, sliceFiber.covMap s.2 (phi y0, g0)) (Straight.toStraight (g0, idp))
=> equiv-univElem \lam w => (totalEquiv \lam f (k : (y0, sliceFiber.covMap s.2 (phi y0, g0)) ~> {\Sigma⁺ (y : Y) (F (phi y))} (w.1, f)) =>
~>_-> (dpath \lam i => sliceFiber F s (phi (k i).1, (k i).2)) (Straight.toStraight (g0, idp))).2
((IsEquiv.parallelEquiv {_} {_} {_} {_}
{totalEquiv.total \lam f (k : (y0, sliceFiber.covMap s.2 (phi y0, g0)) ~> {\Sigma⁺ (y : Y) (F (phi y))} (w.1, f)) =>
~>_-> (dpath \lam i => sliceFiber F s (phi (k i).1, (k i).2)) (Straight.toStraight (g0, idp))}
(arrows-equiv phi F s w.1) (elems-equiv phi F s w.1)
(\lam t => inv (~>_->-natural {_} {\lam w => sliceFiber F s (phi w.1, w.2)} (\lam w a => (Straight.fromStraight a).1) t.2))).2
(univElem-equiv U w.1)) w.2
\where {
\lemma arrows-equiv.{v} {Y X : \Cat v} (phi : Y ->⁺ X) (F : X ->⁺ \Type v) (s : Slice F) {y0 : Y} {f0 : F (phi y0)} (y : Y)
: IsEquiv {\Sigma (f : F (phi y)) ((y0, f0) ~> {\Sigma⁺ (y : Y) (F (phi y))} (y, f))} {y0 ~> y} (\lam t => dpath \lam i => (t.2 i).1)
=> inP (sigma-right (\lam f => dpath-sigma-equiv (\lam _ y' => F (phi y')) {y0, f0} {y, f})
`transQEquiv` later \new QEquiv {
| f t => (t.2.1, (t.1, t.2.2))
| ret t => (t.2.1, (t.1, t.2.2))
| ret_f t => idp
| f_sec t => idp
} `transQEquiv` contr-right (\lam k => universe-leftFib (F (phi y0), F (phi y), dmap (\lam y' => F (phi y')) k, f0)))
\lemma elems-equiv.{v} {Y X : \Cat v} (phi : Y ->⁺ X) (F : X ->⁺ \Type v) (s : Slice F) (y : Y)
: IsEquiv {\Sigma (f : F (phi y)) (sliceFiber F s (phi y, f))} {s.1 (phi y)} (\lam t => (Straight.fromStraight t.2).1)
=> inP (sigma-right {_} {\lam f => sliceFiber F s (phi y, f)} (\lam f => Straight.equiv)
`transQEquiv` later \new QEquiv {
| f t => (t.2.1, (t.1, t.2.2))
| ret t => (t.2.1, (t.1, t.2.2))
| ret_f t => idp
| f_sec t => idp
} `transQEquiv` contr-right \lam g => lsigma (sliceFiber.covMap s.2 (phi y, g)))
}
-- | {sliceFiber} of a family of slices over {Y} is {sliceFiber} of the uncurried slice over `Y × X`.
\sfunc sliceFiber-curry.{u} {Y X : \Cat u} {K : Y ->⁺ X ->⁺ \Type u} (S : \Pi (y :⁺ Y) -> Slice (K y))
{z :⁺ \Sigma⁺ (w : \Sigma⁺ Y X) (K w.1 w.2)}
: sliceFiber (\lam (w : \Sigma⁺ Y X) => K w.1 w.2) (uncurrySlice S) z = sliceFiber (K z.1.1) (S z.1.1) (z.1.2, z.2)
=> path \lam i => (fun-path {_} {sliceFiber (\lam (w : \Sigma⁺ Y X) => K w.1 w.2) (uncurrySlice S)}
{\lam (z : \Sigma⁺ (w : \Sigma⁺ Y X) (K w.1 w.2)) => sliceFiber (K z.1.1) (S z.1.1) (z.1.2, z.2)}
(\lam s => Straight.toStraight (Straight.fromStraight s.2))
(\lam z => IsEquiv.trans (inP Straight.equiv)
(inP (symQEquiv (Straight.equiv {_} {sliceFiber.FibCat} {_} {_} {K z.1.1, (S z.1.1, (z.1.2, z.2))}))))).1 i z
\where
-- | The slice over `Y × X` of a family of slices over `Y`.
\func uncurrySlice.{v} {Y X : \Cat v} {K : Y ->⁺ X ->⁺ \Type v} (S : \Pi (y :⁺ Y) -> Slice (K y))
: Slice (\lam (w : \Sigma⁺ Y X) => K w.1 w.2)
=> (\lam w => (S w.1).1 w.2, dpath \lam i w => (S w.1).2 i w.2)
-- | {sliceFiber} of {sumSlice} is the original functor, covariantly in a parameter `z`.
\sfunc sliceFiber-sumSlice.{u} {Z X : \Cat u} {F : Z ->⁺ X ->⁺ \Type u} (G' : \Pi (z :⁺ Z) -> \Sigma⁺ (x : X) (F z x) ->⁺ \Type u)
{w :⁺ \Sigma⁺ (z : Z) (\Sigma⁺ (x : X) (F z x))}
: sliceFiber (F w.1) (sumSlice (F w.1) (G' w.1)) w.2 = G' w.1 w.2
=> path \lam i => (fun-path {\Sigma⁺ (z : Z) (\Sigma⁺ (x : X) (F z x))} {\lam w => sliceFiber (F w.1) (sumSlice (F w.1) (G' w.1)) w.2} {\lam w => G' w.1 w.2}
(\lam s => transport+ (\lam t => G' s.1.1 (s.1.2.1, t)) (Straight.fromStraight s.2).2 (Straight.fromStraight s.2).1.2)
(\lam w => sumSlice-equiv.totalFun-slice.sum-fib-equiv (G' w.1) w.2)).1 i w
{- | The pullback of {sig} along {alpha} is the sum of the functor of {sig} precomposed with {totalMap} {alpha}:
- {pullbackSlice} underlies a product of `(F', alpha)` and {sig} in the slice over `F`.
-
- We may assume that `(F', alpha)` and {sig} are sums of functors `Phi` and `H` on the total category of `F` ({reduce}).
- The pullback is then the sum of the product of `Phi` and `H`,
- and it is the sum of `H ∘ totalMap alpha` over `F'` ({prod-path}).
-}
\sfunc pullbackSlice-isProduct.{u} {X : \Cat u} {F' F : X ->⁺ \Type u} (alpha : F' ~> F) (sig : Slice F)
: \Sigma (c : SliceCat {Slice F} (F', alpha)) (q : c.1 ~> sig) (IsProduct c.2 q) (SliceCat.over-forget c = pullbackSlice alpha sig)
=> reduce (fibFam alpha) (fibFam sig.2) ((totalFun-slice F).f_sec (F',alpha)) ((totalFun-slice F).f_sec sig)
\where {
-- | The functor between total categories induced by an arrow {a}.
\func totalMap.{u} {X : \Cat u} {F' F : X ->⁺ \Type u} (a : F' ~> F) (s :⁺ \Sigma⁺ (x : X) (F' x)) : \Sigma⁺ (x : X) (F x)
=> (s.1, sliceFiber.covMap a s)
-- | The pullback of {sig} along {alpha}: the sum of the functor of {sig} precomposed with `totalMap alpha`.
\func pullbackSlice.{u} {X : \Cat u} {F' F : X ->⁺ \Type u} (alpha : F' ~> F) (sig : Slice F) : Slice F'
=> sumSlice F' (\lam z =>⁺ fibFam sig.2 (totalMap alpha z))
-- | It is enough to construct the product for sums.
\sfunc reduce.{u} {X : \Cat u} {F : X ->⁺ \Type u} (Phi H : \Sigma⁺ (x : X) (F x) ->⁺ \Type u) {s' sig : Slice F}
(p : sumSlice F Phi = s') (q : sumSlice F H = sig)
: \Sigma (c : SliceCat {Slice F} s') (r : c.1 ~> sig) (IsProduct c.2 r) (SliceCat.over-forget c = pullbackSlice s'.2 sig) \elim p, q
| idp, idp => ((sumSlice F (FunProd Phi H), dmap (sumSlice F) (FunProd-proj1 Phi H)), dmap (sumSlice F) (FunProd-proj2 Phi H),
IsProduct.equiv-preserve (sumSlice-equiv F) (CartesianHCat.Prod-isProduct {FunctorCartesian} {Phi} {H}), prod-path Phi H)
-- | The sum of the product of {Phi} and {H} as an object of the slice over `sumFam F Phi`.
\func sumSlice-pb.{u} {X : \Cat u} {F : X ->⁺ \Type u} (Phi H : \Sigma⁺ (x : X) (F x) ->⁺ \Type u) : Slice (sumFam F Phi)
=> (sumFam F (FunProd Phi H), dmap (sumFam F) (FunProd-proj1 Phi H))
-- | The functor on the total category of `sumFam F Phi` whose sum is the pullback.
\func fibFamTotal.{u} {X : \Cat u} {F : X ->⁺ \Type u} (Phi H : \Sigma⁺ (x : X) (F x) ->⁺ \Type u) (z :⁺ \Sigma⁺ (x : X) (sumFam F Phi x)) : \Type u
=> fibFam (sumProj F H) (totalMap (sumProj F Phi) z)
-- | The sum of the product of {Phi} and {H} over `sumFam F Phi` is the sum of {fibFamTotal}.
\sfunc prod-path.{u} {X : \Cat u} {F : X ->⁺ \Type u} (Phi H : \Sigma⁺ (x : X) (F x) ->⁺ \Type u)
: sumSlice-pb Phi H = {Slice (sumFam F Phi)} sumSlice (sumFam F Phi) (fibFamTotal Phi H)
=> \let q => fun-path {X} {sumFam F (FunProd Phi H)} {sumFam (sumFam F Phi) (fibFamTotal Phi H)} (prod-map Phi H) (prod-map-equiv Phi H)
\in sigma-ext q.1 $ transport+-slice q.1 $ prod-arrow Phi H *> pmap (comp __ (sumProj (sumFam F Phi) (fibFamTotal Phi H))) (inv q.2)
-- | The projection of the pullback to `sumFam F Phi` factors through {prod-map}.
\sfunc prod-arrow.{u} {X : \Cat u} {F : X ->⁺ \Type u} (Phi H : \Sigma⁺ (x : X) (F x) ->⁺ \Type u)
: dmap (sumFam F) (FunProd-proj1 Phi H) = comp (depUnivalence.ret (prod-map Phi H)) (sumProj (sumFam F Phi) (fibFamTotal Phi H))
=> QEquiv.isInj {depUnivalence} $ ext \lam s =>
sumFam-dmap F (FunProd-proj1 Phi H) {s.1} {s.2.1} {s.2.2} *> inv (~>_->_comp-fam (depUnivalence.ret (prod-map Phi H)) (sumProj (sumFam F Phi) (fibFamTotal Phi H)) s.1 s.2)
-- | The comparison map from the sum of the product of {Phi} and {H} to the sum of {fibFamTotal}.
\func prod-map.{u} {X : \Cat u} {F : X ->⁺ \Type u} (Phi H : \Sigma⁺ (x : X) (F x) ->⁺ \Type u)
(s :⁺ \Sigma⁺ (x : X) (sumFam F (FunProd Phi H) x)) : sumFam (sumFam F Phi) (fibFamTotal Phi H) s.1
=> ((s.2.1, s.2.2.1), Straight.toStraight ((s.2.1, s.2.2.2), idp))
\lemma prod-map-equiv.{u} {X : \Cat u} {F : X ->⁺ \Type u} (Phi H : \Sigma⁺ (x : X) (F x) ->⁺ \Type u) (x : X)
: IsEquiv {sumFam F (FunProd Phi H) x} {sumFam (sumFam F Phi) (fibFamTotal Phi H) x} (\lam a => prod-map Phi H (x,a))
=> inP \new QEquiv {
| ret r => (r.1.1, (r.1.2, transport (\lam t => H (x,t)) (Straight.fromStraight r.2).2 (Straight.fromStraight r.2).1.2))
| ret_f a => idp
| f_sec r => path (\lam i => (r.1, (aux (Straight.fromStraight r.2).2 *> Straight.toStraight_fromStraight r.2) i))
}
\where
\private \func aux {t t' : F x} {h : H (x,t)} (e : t = t')
: Straight.toStraight {_} {sliceFiber.FibCat} {sliceFiber.leftFib} {sliceFiber.small} {F, ((sumFam F H, sumProj F H), (x,t'))} ((t', transport (\lam t => H (x,t)) e h), idp)
= Straight.toStraight ((t, h), e) \elim e
| idp => idp
}