Timings for Colimit_Sigma.v
Require Import Diagrams.Diagram.
Require Import Diagrams.Graph.
Require Import Diagrams.Cocone.
Require Import Colimits.Colimit.
(** * Colimit of the dependent sum of a family of diagrams *)
(** Given a family of diagrams [D y], and a colimit [Q y] of each diagram, one can consider the diagram of the sigmas of the types of the [D y]s. Then, a colimit of such a diagram is the sigma of the [Q y]s. *)
Context `{Funext} {G : Graph} {Y : Type} (D : Y -> Diagram G).
(** The diagram of the sigmas. *)
Definition sigma_diagram : Diagram G.
exact (fun i => {y: Y & D y i}).
exact (x.1; D x.1 _f g x.2).
(** The embedding, for a particular [y], of [D(y)] in the sigma diagram. *)
Definition sigma_diagram_map (y: Y) : DiagramMap (D y) sigma_diagram.
srapply Build_DiagramMap.
1: exact (fun i x => (y; x)).
(** The sigma of a family of cocones. *)
Definition sigma_cocone (C : forall y, Cocone (D y) (Q y))
: Cocone sigma_diagram (sig Q).
srapply Build_Cocone; simpl; intros i x.
1: exact (x.1; legs (C x.1) i x.2).
(** The main result: [sig Q] is a colimit of the diagram of sigma types. *)
Lemma iscolimit_sigma (HQ : forall y, IsColimit (D y) (Q y))
: IsColimit sigma_diagram (sig Q).
pose (SigmaC := sigma_cocone (fun y => HQ y)).
srapply (Build_IsColimit SigmaC).
srapply Build_UniversalCocone.
intros X; srapply isequiv_adjointify.
srapply (cocone_postcompose_inv (HQ x.1) _ x.2).
srapply (cocone_precompose _ CX).
pose (CXy := fun y => cocone_precompose (sigma_diagram_map y) CX).
change (cocone_postcompose SigmaC
(fun x => cocone_postcompose_inv (HQ x.1) (CXy x.1) x.2) = CX).
srapply path_cocone; simpl.
change (legs (cocone_postcompose (HQ x.1)
(cocone_postcompose_inv (HQ x.1) (CXy x.1))) i x.2 = CX i x).
exact (ap10 (apD10 (ap legs (eisretr
(cocone_postcompose (HQ x.1)) (CXy _))) i) x.2).
intros i j g [y x]; simpl.
set (py := (eisretr (cocone_postcompose (HQ y)) (CXy y))).
specialize (apD legs_comm py); intro py2.
rewrite (path_forall _ _(transport_forall_constant _ _)) in py2.
apply apD10 in py2; specialize (py2 i); simpl in py2.
rewrite (path_forall _ _(transport_forall_constant _ _)) in py2.
apply apD10 in py2; specialize (py2 j); simpl in py2.
rewrite (path_forall _ _(transport_forall_constant _ _)) in py2.
apply apD10 in py2; specialize (py2 g); simpl in py2.
rewrite (path_forall _ _(transport_forall_constant _ _)) in py2.
apply apD10 in py2; specialize (py2 x); simpl in py2.
rewrite transport_paths_FlFr in py2.
rewrite concat_1p, concat_pp_p in py2.
rewrite (ap_path_sigma_1p
(fun x01 x02 => cocone_postcompose_inv (HQ x01) (CXy x01) x02)).
(* Set Printing Coercions. (* to understand what happens *) *)
rewrite (ap_compose legs (fun x0 => x0 i x)).
rewrite (ap_apply_lD2 _ i x).
rewrite (ap_compose legs (fun x0 => x0 j _)).
rewrite (ap_apply_lD2 _ j _).
apply path_forall; intros [y x]; simpl.
rewrite <- cocone_precompose_postcompose.
srapply (apD10 (g := fun x => f (y; x)) _ x).
snapply equiv_moveR_equiv_V.
exact (ap_compose _ _ _)^.
(** ** Sigma diagrams and diagram maps / equivalences *)
Context {G : Graph} {Y : Type} (D1 D2 : Y -> Diagram G).
Definition sigma_diagram_functor (m : forall y, DiagramMap (D1 y) (D2 y))
: DiagramMap (sigma_diagram D1) (sigma_diagram D2).
srapply Build_DiagramMap.
srapply (functor_sigma idmap _).
intros i j g x; simpl in *.
apply (DiagramMap_comm (m x.1)).
Definition sigma_diag_functor_equiv (m : forall y, (D1 y) ~d~ (D2 y))
: (sigma_diagram D1) ~d~ (sigma_diagram D2).
srapply (Build_diagram_equiv (sigma_diagram_functor m)).
srapply isequiv_functor_sigma.