Timings for Subobjects.v
- /home/gitlab-runner/builds/gGKko-aj/0/coq/coq/_bench/opam.OLD/ocaml-OLD/.opam-switch/build/coq-unimath.dev//./UniMath/CategoryTheory/Subobjects.v.timing
- /home/gitlab-runner/builds/gGKko-aj/0/coq/coq/_bench/opam.NEW/ocaml-NEW/.opam-switch/build/coq-unimath.dev//./UniMath/CategoryTheory/Subobjects.v.timing
(** *************************************************************************
Definition and theory about subobjects of an object c
Contents:
- Category of subobjects (monos) of c ([Subobjectscategory])
- Set of subobjects as equivalence classes of monos ([SubObj])
- Proof that the set of subobjects of an object is a poset ([SubObjPoset])
- The definition of the functor from C^op to hset_category
which maps c to the set of the subobject (module z_isomorphism) of c
and maps morphism "by pullback" ([SubObj_Functor])
Written by: Tomi Pannila and Anders Mörtberg, 2016-2017
*****************************************************************************)
Require Import UniMath.Foundations.PartD.
Require Import UniMath.Foundations.Propositions.
Require Import UniMath.Foundations.Sets.
Require Import UniMath.MoreFoundations.Tactics.
Require Import UniMath.CategoryTheory.Core.Categories.
Require Import UniMath.CategoryTheory.Core.Isos.
Require Import UniMath.CategoryTheory.Core.Functors.
Require Import UniMath.CategoryTheory.slicecat.
Require Import UniMath.CategoryTheory.Monics.
Require Import UniMath.CategoryTheory.Subcategory.Core.
Require Import UniMath.CategoryTheory.categories.HSET.Core.
Require Import UniMath.CategoryTheory.limits.pullbacks.
Require Import UniMath.CategoryTheory.opp_precat.
(** * Definition of the category of subobjects (monos) of c *)
Definition Subobjectscategory (c : C) : category :=
slice_cat (subcategory_of_monics C)
(subprecategory_of_monics_ob C c).
Lemma has_homsets_Subobjectscategory (c : C) :
has_homsets (Subobjectscategory c).
apply has_homsets_slice_precat.
(** Construction of a subobject from a monic *)
Definition Subobjectscategory_ob {c c' : C} (h : C⟦c', c⟧) (isM : isMonic h) :
Subobjectscategory c := (subprecategory_of_monics_ob C c',,(h,,isM)).
(** Accessor for an object of Subobjectscategory*)
Context {c:C} (S : Subobjectscategory c).
Definition Subobject_dom : C := pr1 (pr1 S).
Definition Subobject_Monic := pr2 S.
Definition Subobject_mor : C⟦ Subobject_dom , c ⟧ := pr1 (pr2 S).
Definition Subobject_isM : isMonic(Subobject_mor) := pr2 (pr2 S).
(** Accessor for a morphism of Subobjectscategory*)
Context {c:C} {S S' : Subobjectscategory c} (h : S --> S').
Definition Subobjectmor_Cmor : C⟦ Subobject_dom S, Subobject_dom S' ⟧ := pr1 (pr1 h).
Definition Subobjectmor_isM : isMonic(Subobjectmor_Cmor) := pr2 (pr1 h).
Definition Subobjectmor_tri := maponpaths (pr1) (pr2 h).
(** Given any subobject S of c and a morphism h : c' -> c, by taking then pullback of S by h we
obtain a subobject of c'. *)
Definition PullbackSubobject (PB : Pullbacks C) {c : C} (S : Subobjectscategory c) {c' : C} (h : C⟦c', c⟧) :
Subobjectscategory c'.
set (pb := PB _ _ _ h (Subobject_mor S)).
use Subobjectscategory_ob.
use MonicPullbackisMonic'.
(*a z_iso in Subobjectscategory can be obtained by
a z_iso on the underlying category C which makes the triangle commute*)
Definition make_z_iso_in_Subobjectscategory {c : C} {S S' : Subobjectscategory c}
(h : C ⟦Subobject_dom S ,Subobject_dom S'⟧)
(is_z_iso : is_z_isomorphism h)
(tri : Subobject_mor S = h · Subobject_mor S')
: z_iso S S'.
use precategory_morphisms_in_subcat.
use eq_in_sub_precategory.
use z_iso_to_slice_precat_z_iso.
use is_z_iso_in_subcategory_of_monics_weq.
(** a z_iso is Subobjectcategory gives, in particular, a z_iso of C between domains*)
Definition z_iso_from_z_iso_in_Subobjectcategory {c : C}
{S S' : Subobjectscategory c} (h : z_iso S S')
: (z_iso (Subobject_dom S) (Subobject_dom S')).
exact (Subobjectmor_Cmor h).
exact (Subobjectmor_Cmor (inv_from_z_iso h)).
induction h as (h, (g,(hg,gh))).
use make_is_inverse_in_precat.
exact (maponpaths Subobjectmor_Cmor hg).
exact (maponpaths Subobjectmor_Cmor gh).
(** * Definition of subobjects as equivalence classes of monos *)
(** Equivalence classes of subobjects defined by identifying monos into c
with isomorphic source *)
Definition SubObj (c : C) : hSet :=
make_hSet (setquot (z_iso_eqrel (C:=Subobjectscategory c))) (isasetsetquot _).
Definition SubObj_iseqc {c:C} (S : SubObj c) := pr2 S.
Definition PullbackSubObj (PB : Pullbacks C) {c : C} (S : SubObj c)
{c' : C} (h : C⟦c', c⟧)
: SubObj c'.
use (setquotfun (z_iso_eqrel (C:=Subobjectscategory c))).
use (PullbackSubobject PB s h).
use make_z_iso_in_Subobjectscategory.
use (iso_between_pullbacks
(PullbackSqrCommutes (PB _ _ _ h (Subobject_mor u)))
(PullbackSqrCommutes (PB _ _ _ h (Subobject_mor v)))
(isPullback_Pullback (PB _ _ _ h (Subobject_mor u)))
(isPullback_Pullback (PB _ _ _ h (Subobject_mor v)))
).
exact (identity_z_iso c').
use z_iso_from_z_iso_in_Subobjectcategory.
exact (identity_z_iso c).
rewrite id_left, id_right.
use z_iso_is_z_isomorphism.
rewrite <-(id_right (Subobject_mor _)).
use PullbackArrow_PullbackPr1.
(* For f and g monics into c: f <= g := ∃ h, f = h · g *)
Definition monorel (c : C) : hrel (Subobjectscategory c) :=
λ f g, ∃ h, pr1 (pr2 f) = h · pr1 (pr2 g).
Lemma isrefl_monorel (c : C) : isrefl (monorel c).
exists (pr1 (pr1 (identity x))).
Lemma istrans_monorel (c : C) : istrans (monorel c).
apply hinhuniv; intros h2; generalize h1; clear h1.
apply hinhuniv; intros h1; apply hinhpr.
exists (pr1 h1 · pr1 h2).
now rewrite <- assoc, <- (pr2 h2), <- (pr2 h1).
Lemma ispreorder_monorel c : ispreorder (monorel c).
exact (istrans_monorel c,,isrefl_monorel c).
Lemma are_z_isomorphic_monorel {c : C} {x1 y1 x2 y2 : Subobjectscategory c}
(h1 : are_z_isomorphic x1 y1) (h2 : are_z_isomorphic x2 y2) :
monorel c x1 x2 → monorel c y1 y2.
apply hinhuniv; intros f.
change (ishinh_UU (z_iso x1 y1)) in h1.
change (ishinh_UU (z_iso x2 y2)) in h2.
apply h1; clear h1; intro h1.
apply h2; clear h2; intro h2.
intros P H; apply H; clear P H.
set (h1_inv := inv_from_z_iso h1).
set (Hh1 := z_iso_after_z_iso_inv h1).
exists (pr1 (pr1 h1_inv) · pr1 f · pr1 (pr1 (pr1 h2))).
set (Htemp := maponpaths pr1 (pr2 (pr1 h2))).
apply pathsinv0; simpl in *.
rewrite <-!assoc, <- Htemp.
intermediate_path (pr1 (pr1 h1_inv) · pr1 (pr2 x1)).
apply maponpaths, pathsinv0, (pr2 f).
etrans; [ apply maponpaths, (maponpaths pr1 (pr2 (pr1 h1))) |]; simpl.
etrans; [ eapply cancel_postcomposition, (maponpaths pr1 (maponpaths pr1 Hh1)) |].
(** Construct a quotient relation on the Subobjects from the relation on monos *)
Definition SubObj_rel (c : C) : hrel (pr1 (SubObj c)).
intros x1 y1 x2 y2 h1 h2.
apply (are_z_isomorphic_monorel h1 h2).
apply (are_z_isomorphic_monorel (eqrelsymm (z_iso_eqrel) _ _ h1)
(eqrelsymm (z_iso_eqrel) _ _ h2)).
Lemma istrans_SubObj_rel (c : C) : istrans (SubObj_rel c).
apply istransquotrel, istrans_monorel.
Lemma isrefl_SubObj_rel (c : C) : isrefl (SubObj_rel c).
apply isreflquotrel, isrefl_monorel.
Lemma ispreorder_SubObj_rel (c : C) : ispreorder (SubObj_rel c).
exact (istrans_SubObj_rel c,,isrefl_SubObj_rel c).
Lemma isantisymm_SubObj_rel (c : C) : isantisymm (SubObj_rel c).
unfold isantisymm; simpl.
assert (int : ∏ x1 x2, isaprop (SubObj_rel c x1 x2 → SubObj_rel c x2 x1 -> x1 = x2)).
repeat (apply impred; intro).
apply (isasetsetquot _ x1 x2).
apply (setquotuniv2prop _ (λ x1 x2, make_hProp _ (int x1 x2))).
apply (iscompsetquotpr (z_iso_eqrel (C:=Subobjectscategory c))).
generalize h1; clear h1; apply hinhuniv; intros [h1 Hh1].
generalize h2; clear h2; apply hinhuniv; intros [h2 Hh2].
apply hinhpr, (invmap (weq_z_iso _ (subprecategory_of_monics_ob C c) _ _)).
induction x as [[x []] [fx Hfx]].
induction y as [[y []] [fy Hfy]].
assert (mon_h1 : isMonic h1).
apply (isMonic_postcomp _ h1 fy); rewrite <- Hh1; apply Hfx.
assert (mon_h2 : isMonic h2).
apply (isMonic_postcomp _ h2 fx); rewrite <- Hh2; apply Hfy.
split; apply subtypePath.
now rewrite <- assoc, <- Hh2, <- Hh1, id_left.
now rewrite <- assoc, <- Hh1, <- Hh2, id_left.
apply subtypePath; simpl; try apply Hh1.
now intros xx; apply isapropisMonic.
Definition SubObjPoset (c : C) : Poset :=
(SubObj c,,SubObj_rel c,,ispreorder_SubObj_rel c,,isantisymm_SubObj_rel c).
(*Definition of the functor C^op -> HSET which maps c on SubObj c and maps morphism "by pullback"*)
Context (C : category) (PB : Pullbacks C).
Definition SubObj_Functor_data : functor_data (op_cat C) hset_category.
Theorem SubObj_Functor_isfunctor : is_functor (SubObj_Functor_data).
change (pr1hSet (SubObj c)) in S.
use (squash_to_prop (X:=pr1setquot _ S)).
exact (eqax0 (SubObj_iseqc S)).
induction (setquotl0 _ S m).
use (weqpathsinsetquot (z_iso_eqrel (C:=Subobjectscategory c))).
use make_z_iso_in_Subobjectscategory.
exact (identity_is_z_iso c).
rewrite <- PullbackSqrCommutes, id_right.
cbn in c, c', c'', f, f'.
use (squash_to_prop (X:=pr1setquot _ S)).
exact (eqax0 (SubObj_iseqc S)).
induction (setquotl0 _ S m).
set (pb := (PB _ _ _ f ((Subobject_mor m)))).
set (pbpb := PB _ _ _ f' (PullbackPr1 pb)).
transparent assert (pb_glued : (Pullback (f'·f) (Subobject_mor m))).
exact (PullbackPr1 pbpb).
exact ((PullbackPr2 pbpb)·(PullbackPr2 pb)).
use (isPullbackGluedSquare
(isPullback_Pullback pb)
(isPullback_Pullback pbpb)).
use make_z_iso_in_Subobjectscategory.
assert (H : PullbackObject pb_glued = PullbackObject pbpb).
use z_iso_from_Pullback_to_Pullback.
use z_iso_is_z_isomorphism.
assert (H : PullbackPr1 pb_glued = PullbackPr1 pbpb).
use (PullbackArrow_PullbackPr1 pb_glued).
Definition SubObj_Functor : C^op ⟶ hset_category.
exact SubObj_Functor_data.
exact SubObj_Functor_isfunctor.