Timings for GrpPullback.v
Require Import Basics Types Limits.Pullback Cubical.PathSquare.
Require Import Algebra.Groups.Group.
Require Import WildCat.Core.
(** Pullbacks of groups are formalized by equipping the set-pullback with the desired group structure. The universal property in the category of groups is proved by saying that the corecursion principle [grp_pullback_corec] is an equivalence. *)
Local Open Scope mc_scope.
Local Open Scope mc_mult_scope.
(* Variables are named to correspond with Limits.Pullback. *)
Context {A B C : Group} (f : B $-> A) (g : C $-> A).
Local Instance grp_pullback_sgop : SgOp (Pullback f g).
intros [b [c p]] [d [e q]].
refine (b * d; c * e; _).
exact (grp_homo_op_agree _ _ p q).
Local Instance grp_pullback_sgop_associative
: Associative grp_pullback_sgop.
intros [x1 [x2 p]] [y1 [y2 q]] [z1 [z2 u]].
apply equiv_path_pullback; simpl.
refine (associativity _ _ _; associativity _ _ _; _).
Local Instance grp_pullback_issemigroup : IsSemiGroup (Pullback f g) := {}.
Local Instance grp_pullback_mon_unit : MonUnit (Pullback f g)
:= (1; 1; grp_homo_unit f @ (grp_homo_unit g)^).
Local Instance grp_pullback_leftidentity
: LeftIdentity grp_pullback_sgop grp_pullback_mon_unit.
apply equiv_path_pullback; simpl.
refine (left_identity _; left_identity _; _).
Local Instance grp_pullback_rightidentity
: RightIdentity grp_pullback_sgop grp_pullback_mon_unit.
apply equiv_path_pullback; simpl.
refine (right_identity _; right_identity _; _).
Local Instance ismonoid_grp_pullback : IsMonoid (Pullback f g) := {}.
Local Instance grp_pullback_inverse : Inverse (Pullback f g).
refine (b^; c^; grp_homo_inv f b @ _ @ (grp_homo_inv g c)^).
Local Instance grp_pullback_leftinverse : LeftInverse (.*.) (^) mon_unit.
unfold grp_pullback_sgop; simpl.
apply equiv_path_pullback; simpl.
refine (left_inverse _; left_inverse _; _).
Local Instance grp_pullback_rightinverse : RightInverse (.*.) (^) mon_unit.
unfold grp_pullback_sgop; simpl.
apply equiv_path_pullback; simpl.
refine (right_inverse _; right_inverse _; _).
#[export] Instance isgroup_grp_pullback : IsGroup (Pullback f g) := {}.
Definition grp_pullback : Group
:= Build_Group (Pullback f g) _ _ _ _.
Definition grp_pullback_pr1 : grp_pullback $-> B.
snapply Build_GroupHomomorphism.
Definition grp_pullback_pr2 : grp_pullback $-> C.
snapply Build_GroupHomomorphism.
Proposition grp_pullback_corec {X : Group}
(b : X $-> B) (c : X $-> C)
(p : f o b == g o c)
: X $-> grp_pullback.
snapply Build_GroupHomomorphism.
exact (fun x => (b x; c x; p x)).
refine (transport_sigma' _ _ @ _).
Corollary grp_pullback_corec' (X : Group)
: {b : X $-> B & { c : X $-> C & f o b == g o c}}
-> (X $-> grp_pullback).
intros [b [c p]]; exact (grp_pullback_corec b c p).
Definition functor_grp_pullback {A A' B B' C C' : Group}
(f : B $-> A) (f' : B' $-> A')
(g : C $-> A) (g' : C' $-> A')
(alpha : A $-> A') (beta : B $-> B') (gamma : C $-> C')
(h : f' o beta == alpha o f)
(k : alpha o g == g' o gamma)
: grp_pullback f g $-> grp_pullback f' g'.
srapply grp_pullback_corec.
exact (beta $o grp_pullback_pr1 f g).
exact (gamma $o grp_pullback_pr2 f g).
refine (h _ @ ap alpha _ @ k _).
Definition equiv_functor_grp_pullback {A A' B B' C C' : Group}
(f : B $-> A) (f' : B' $-> A')
(g : C $-> A) (g' : C' $-> A')
(alpha : GroupIsomorphism A A')
(beta : GroupIsomorphism B B')
(gamma : GroupIsomorphism C C')
(h : f' o beta == alpha o f)
(k : alpha o g == g' o gamma)
: GroupIsomorphism (grp_pullback f g) (grp_pullback f' g').
srapply Build_GroupIsomorphism.
1: exact (functor_grp_pullback f f' g g' _ _ _ h k).
srapply isequiv_adjointify.
srapply (functor_grp_pullback f' f g' g).
1-3: rapply grp_iso_inverse; assumption.
rapply (equiv_ind beta); intro b.
refine (ap f (eissect _ _) @ _).
apply (equiv_ap' alpha _ _)^-1.
exact ((h b)^ @ (eisretr _ _)^).
rapply (equiv_ind gamma); intro c.
refine (_ @ ap g (eissect _ _)^).
apply (equiv_ap' alpha _ _)^-1.
exact (eisretr _ _ @ (k c)^).
all: intro x;
apply equiv_path_pullback_hset; split; cbn.
(** Pulling back along some [g : Y $-> Z] and then [g' : Y' $-> Y] is the same as pulling back along [g $o g']. *)
Definition equiv_grp_pullback_compose_r {X Z Y Y' : Group} (f : X $-> Z) (g' : Y' $-> Y) (g : Y $-> Z)
: GroupIsomorphism (grp_pullback (grp_pullback_pr2 f g) g') (grp_pullback f (g $o g')).
srapply Build_GroupIsomorphism.
srapply grp_pullback_corec.
exact (grp_pullback_pr1 _ _ $o grp_pullback_pr1 _ _).
exact (pullback_commsq _ _ _ @ ap g (pullback_commsq _ _ _)).
srapply isequiv_adjointify.
srapply grp_pullback_corec.
srapply functor_grp_pullback.
by srapply equiv_path_pullback_hset.
intros [[x [y z0]] [y' z1]]; srapply equiv_path_pullback_hset; split; cbn.
srapply equiv_path_pullback_hset; split; cbn.
Section IsEquivGrpPullbackCorec.
(* New section with Funext at the start of the Context. *)
Context `{Funext} {A B C : Group} (f : B $-> A) (g : C $-> A).
Lemma grp_pullback_corec_pr1 {X : Group}
(b : X $-> B) (c : X $-> C)
(p : f o b == g o c)
: grp_pullback_pr1 f g $o grp_pullback_corec f g b c p = b.
apply equiv_path_grouphomomorphism; reflexivity.
Lemma grp_pullback_corec_pr2 {X : Group}
(b : X $-> B) (c : X $-> C)
(p : f o b == g o c)
: grp_pullback_pr2 f g $o grp_pullback_corec f g b c p = c.
apply equiv_path_grouphomomorphism; reflexivity.
Theorem isequiv_grp_pullback_corec (X : Group)
: IsEquiv (grp_pullback_corec' f g X).
snapply isequiv_adjointify.
refine (grp_pullback_pr1 f g $o phi; grp_pullback_pr2 f g $o phi; _).
intro x; exact (pullback_commsq f g (phi x)).
apply equiv_path_grouphomomorphism; reflexivity.
apply grp_pullback_corec_pr1.
refine (transport_sigma' _ _ @ _).
apply path_sigma_hprop; simpl pr1.
apply grp_pullback_corec_pr2.
End IsEquivGrpPullbackCorec.