Library HoTT.Colimits.SpanPushout

Pushouts of "dependent spans".


Section SpanPushout.
  Context {X Y : Type} (Q : X Y Type).

  Definition SPushout := @Pushout@{up _ _ up} (sig@{up _} (fun (xy : X × Y) ⇒ Q (fst xy) (snd xy))) X Y
                                  (fst o pr1) (snd o pr1).
  Definition spushl : X SPushout := pushl.
  Definition spushr : Y SPushout := pushr.
  Definition spglue {x:X} {y:Y} : Q x y spushl x = spushr y
    := fun qpglue ((x,y) ; q).

  Definition spushout_rec (R : Type)
             (spushl' : X R) (spushr' : Y R)
             (spglue' : x y (q : Q x y), spushl' x = spushr' y)
    : SPushout R.
  Proof.
    srapply (@Pushout_rec {xy:X × Y & Q (fst xy) (snd xy)} X Y
                          (fst o pr1) (snd o pr1) R spushl' spushr').
    intros [[x y] q]; cbn in ×.
    apply spglue'; assumption.
  Defined.

  Definition spushout_rec_beta_spglue (R : Type)
             (spushl' : X R) (spushr' : Y R)
             (spglue' : x y (q : Q x y), spushl' x = spushr' y)
             (x:X) (y:Y) (q:Q x y)
    : ap (spushout_rec R spushl' spushr' spglue') (spglue q) = spglue' x y q
    := Pushout_rec_beta_pglue _ _ _ _ ((x, y); q).

  Definition spushout_ind (R : SPushout Type)
             (spushl' : x, R (spushl x))
             (spushr' : y, R (spushr y))
             (spglue' : x y (q : Q x y),
                 transport R (spglue q) (spushl' x) = (spushr' y))
    : p, R p.
  Proof.
    srapply (@Pushout_ind {xy:X × Y & Q (fst xy) (snd xy)} X Y
                          (fst o pr1) (snd o pr1) R spushl' spushr').
    intros [[x y] q]; cbn in ×.
    apply spglue'; assumption.
  Defined.

  Definition spushout_ind_beta_spglue (R : SPushout Type)
             (spushl' : x, R (spushl x))
             (spushr' : y, R (spushr y))
             (spglue' : x y (q : Q x y),
                 transport R (spglue q) (spushl' x) = (spushr' y))
             (x:X) (y:Y) (q:Q x y)
    : apD (spushout_ind R spushl' spushr' spglue') (spglue q) = spglue' x y q
    := Pushout_ind_beta_pglue _ _ _ _ ((x,y);q).

End SpanPushout.

Definition functor_spushout {X Y Z W : Type}
  {Q : X Y Type} {Q' : Z W Type}
  (f : X Z) (g : Y W) (h : x y, Q x y Q' (f x) (g y))
  : SPushout Q SPushout Q'.
Proof.
  snrapply spushout_rec.
  - exact (fun xspushl Q' (f x)).
  - exact (fun yspushr Q' (g y)).
  - intros x y q. apply spglue. exact (h x y q).
Defined.

Definition functor_spushout_compose {X Y X' Y' X'' Y'' : Type}
  {Q : X Y Type} {Q' : X' Y' Type} {Q'' : X'' Y'' Type}
  (f : X X') (g : Y Y') (f' : X' X'') (g' : Y' Y'')
  (h : x y, Q x y Q' (f x) (g y))
  (h' : x y, Q' x y Q'' (f' x) (g' y))
  : functor_spushout f' g' h' o functor_spushout f g h
    == functor_spushout (f' o f) (g' o g) (fun x yh' _ _ o h x y).
Proof.
  snrapply spushout_ind.
  1,2: reflexivity.
  intros x y q; cbn beta.
  snrapply transport_paths_FFlFr'.
  apply equiv_p1_1q.
  lhs nrapply ap.
  1: nrapply spushout_rec_beta_spglue.
  lhs nrapply spushout_rec_beta_spglue.
  symmetry.
  nrapply (spushout_rec_beta_spglue Q).
Defined.

Definition functor_spushout_idmap {X Y : Type} {Q : X Y Type}
  : functor_spushout idmap idmap (fun x y (q : Q x y) ⇒ q) == idmap.
Proof.
  snrapply spushout_ind.
  1,2: reflexivity.
  intros x y q; cbn.
  snrapply transport_paths_Flr'.
  apply equiv_p1_1q.
  nrapply spushout_rec_beta_spglue.
Defined.

Definition functor_spushout_homotopic {X Y Z W : Type}
  {Q : X Y Type} {Q' : Z W Type}
  {f g : X Z} (h : f == g)
  {i j : Y W} (k : i == j)
  (l : x y, Q x y Q' (f x) (i y))
  (m : x y, Q x y Q' (g x) (j y))
  (H : x y q,
    spglue Q' (l x y q) @ ap (spushr Q') (k y)
      = ap (spushl Q') (h x) @ spglue Q' (m x y q))
  : functor_spushout f i l == functor_spushout g j m.
Proof.
  snrapply spushout_ind.
  - intros x; cbn.
    exact (ap (spushl Q') (h x)).
  - intros y; cbn.
    exact (ap (spushr Q') (k y)).
  - intros x y q.
    snrapply transport_paths_FlFr'.
    lhs nrapply whiskerR.
    1: apply spushout_rec_beta_spglue.
    rhs nrapply whiskerL.
    2: apply spushout_rec_beta_spglue.
    apply H.
Defined.

Any pushout is equivalent to a span pushout.
Definition equiv_pushout_spushout {X Y Z : Type} (f : X Y) (g : X Z)
  : Pushout f g
    <~> SPushout (fun (y : Y) (z : Z) ⇒ {x : X & f x = y g x = z}).
Proof.
  snrapply equiv_pushout.
  { nrefine (equiv_sigma_prod _ oE _).
    apply equiv_double_fibration_replacement. }
  1-4: reflexivity.
Defined.

There is a natural map from the total space of Q to the pushout product of Q.
Definition spushout_sjoin_map {X Y : Type} (Q : X Y Type)
  : {x : X & {y : Y & Q x y}} Pullback (spushl Q) (spushr Q)
  := functor_sigma idmap (fun _functor_sigma idmap (fun _spglue Q)).