Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

biproducts, additive and abelian categories #1929

Draft
wants to merge 40 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0c6a1a3
biproducts, semiadditive and additive categories
Alizter Apr 25, 2024
970f3c3
Endomorphism ring in an additive category
Alizter Apr 25, 2024
7188dce
reorganise additive categories
Alizter Apr 25, 2024
5e50233
shorten proof of swap and inl/inr
Alizter Apr 25, 2024
fb05a77
more comments + cleanup
Alizter Apr 25, 2024
b96d129
abelian categories
Alizter Apr 27, 2024
6228057
Abstract out some idioms for dealing with decidable types
jdchristensen Apr 27, 2024
528e832
rename cat_coprod_prod_incl -> cat_coprod_prod
Alizter Apr 28, 2024
265023f
remove funext from biproduct_op
Alizter Apr 28, 2024
b10c9e0
fix 8.18 issues
Alizter Apr 28, 2024
1ea6501
rename canonical abelian map
Alizter Apr 28, 2024
2b8177d
optimize Additive.v
Alizter Apr 29, 2024
7bdd036
optimize biproducts
Alizter Apr 29, 2024
442f50d
Merge branch 'master' into biproducts
Alizter Apr 29, 2024
ef2848a
simplify proof of opposite coproducts
Alizter Apr 29, 2024
dc29a67
AbGroup has biproducts
Alizter Apr 29, 2024
74c28c6
AbGroup is additive
Alizter Apr 29, 2024
74ea8ee
remove try and use goal selectors
Alizter Apr 29, 2024
d7a027b
Homological/Additive: fix a few typos
jdchristensen Apr 29, 2024
62c2290
review suggestions
Alizter Apr 29, 2024
365399b
spelling
Alizter Apr 29, 2024
bb6077b
inline definition
Alizter Apr 29, 2024
f37c55c
simplify left_identity in Additive.v
Alizter Apr 29, 2024
63c8cf7
update comment and order of arguments
Alizter Apr 29, 2024
ad2fcd5
Merge branch 'master' into biproducts
Alizter Apr 30, 2024
9dc9007
Merge branch 'master' into biproducts
Alizter Apr 30, 2024
acfe860
two proofs of pentagon and simplifications in biproducts
Alizter May 1, 2024
628ac55
short proof of hexagon
Alizter May 1, 2024
e1188e7
Merge remote-tracking branch 'origin/master' into biproducts
Alizter May 2, 2024
f6a4978
remove duplicated hexagon proof
Alizter May 2, 2024
3eb10fd
undo whitespace changes
Alizter May 2, 2024
b8f6663
Merge remote-tracking branch 'origin/master' into biproducts
Alizter May 4, 2024
edd3c8d
monoids and comonoids
Alizter May 6, 2024
04a1a3a
Merge branch 'monoids' into biproducts
Alizter May 8, 2024
74166bf
fixup
Alizter May 8, 2024
71a84d9
Merge remote-tracking branch 'origin/master' into biproducts
Alizter May 15, 2024
2682657
Merge remote-tracking branch 'origin/master' into biproducts
Alizter May 25, 2024
93182b2
wip cocommutative comonoid structure gives monoid structure
Alizter May 26, 2024
7068aa8
Merge remote-tracking branch 'origin/master' into biproducts
Alizter Jul 2, 2024
6fc082e
fix compilation issue in MonoidObject.v
Alizter Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions theories/Algebra/AbGroups/AbHom.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Require Import Basics Types.
Require Import WildCat HSet Truncations.Core Modalities.ReflectiveSubuniverse.
Require Import AbelianGroup Biproduct.
Require Import Algebra.Groups.Group.
Require Import Algebra.Homological.Additive.

(** * Homomorphisms from a group to an abelian group form an abelian group. *)

Expand Down Expand Up @@ -117,3 +119,27 @@ Proof.
rapply (conn_map_elim (Tr (-1)) f).
exact (equiv_path_grouphomomorphism^-1 p).
Defined.

(** ** Additivity of AbGroup *)

(** The group operation that is induced from the semiadditive structure agrees with the handcrafted operation on hom at the level of the underlying functions. *)
Definition ab_homo_add_is_semiadditive_add `{Funext}
{A B : AbGroup} (f g : A $-> B)
: ab_homo_add f g = sgop_hom A B f g :> (A -> B)
:= 1.

(** AbGroup is an additive category. *)
Global Instance additive_ab `{Funext} : IsAdditive AbGroup.
Proof.
snrapply Build_IsAdditive.
- exact _.
- exact _.
- intros A B f.
snrapply equiv_path_grouphomomorphism.
intros x.
exact (left_inverse (f x)).
- intros A B f.
snrapply equiv_path_grouphomomorphism.
intros x.
exact (right_inverse (f x)).
Defined.
2 changes: 1 addition & 1 deletion theories/Algebra/AbGroups/AbPushout.v
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Proof.
srapply path_sigma_hprop.
refine (grp_quotient_rec_beta _ Y _ _ @ _).
apply equiv_path_grouphomomorphism; intro bc.
exact (ab_biprod_rec_beta' (phi $o grp_quotient_map) bc).
exact (ab_biprod_rec_eta (phi $o grp_quotient_map) bc).
Defined.

(** Restricting [ab_pushout_rec] along [ab_pushout_inl] recovers the left inducing map. *)
Expand Down
77 changes: 54 additions & 23 deletions theories/Algebra/AbGroups/Biproduct.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Require Import WildCat.
Require Import HSet.
Require Import AbelianGroup.
Require Import Modalities.ReflectiveSubuniverse.
Require Import Algebra.Homological.Biproducts.
Require Import Algebra.Homological.Additive.

Local Open Scope mc_add_scope.

Expand Down Expand Up @@ -47,7 +49,7 @@ Proof.
intros [f g]. exact (ab_biprod_rec f g).
Defined.

Proposition ab_biprod_rec_beta' {A B Y : AbGroup}
Proposition ab_biprod_rec_eta {A B Y : AbGroup}
(u : ab_biprod A B $-> Y)
: ab_biprod_rec (u $o ab_biprod_inl) (u $o ab_biprod_inr) == u.
Proof.
Expand All @@ -58,29 +60,19 @@ Proof.
- exact (left_identity b).
Defined.

Proposition ab_biprod_rec_beta `{Funext} {A B Y : AbGroup}
(u : ab_biprod A B $-> Y)
: ab_biprod_rec (u $o ab_biprod_inl) (u $o ab_biprod_inr) = u.
Proof.
apply equiv_path_grouphomomorphism.
exact (ab_biprod_rec_beta' u).
Defined.

Proposition ab_biprod_rec_inl_beta `{Funext} {A B Y : AbGroup}
Proposition ab_biprod_rec_inl_beta {A B Y : AbGroup}
(a : A $-> Y) (b : B $-> Y)
: (ab_biprod_rec a b) $o ab_biprod_inl = a.
: (ab_biprod_rec a b) $o ab_biprod_inl == a.
Proof.
apply equiv_path_grouphomomorphism.
intro x; simpl.
rewrite (grp_homo_unit b).
exact (right_identity (a x)).
Defined.

Proposition ab_biprod_rec_inr_beta `{Funext} {A B Y : AbGroup}
Proposition ab_biprod_rec_inr_beta {A B Y : AbGroup}
(a : A $-> Y) (b : B $-> Y)
: (ab_biprod_rec a b) $o ab_biprod_inr = b.
: (ab_biprod_rec a b) $o ab_biprod_inr == b.
Proof.
apply equiv_path_grouphomomorphism.
intro y; simpl.
rewrite (grp_homo_unit a).
exact (left_identity (b y)).
Expand All @@ -93,19 +85,22 @@ Proof.
- intro phi.
exact (phi $o ab_biprod_inl, phi $o ab_biprod_inr).
- intro phi.
exact (ab_biprod_rec_beta phi).
apply equiv_path_grouphomomorphism.
exact (ab_biprod_rec_eta phi).
- intros [a b].
apply path_prod.
+ apply ab_biprod_rec_inl_beta.
+ apply ab_biprod_rec_inr_beta.
+ apply equiv_path_grouphomomorphism.
apply ab_biprod_rec_inl_beta.
+ apply equiv_path_grouphomomorphism.
apply ab_biprod_rec_inr_beta.
Defined.

(** Corecursion principle, inherited from Groups/Group.v. *)
Definition ab_biprod_corec {A B X : AbGroup} (f : X $-> A) (g : X $-> B)
: X $-> ab_biprod A B
:= grp_prod_corec f g.

Definition ab_corec_beta {X Y A B : AbGroup} (f : X $-> Y) (g0 : Y $-> A) (g1 : Y $-> B)
Definition ab_corec_eta {X Y A B : AbGroup} (f : X $-> Y) (g0 : Y $-> A) (g1 : Y $-> B)
: ab_biprod_corec g0 g1 $o f $== ab_biprod_corec (g0 $o f) (g1 $o f)
:= fun _ => idpath.

Expand Down Expand Up @@ -190,17 +185,26 @@ Proof.
- exact (left_identity _)^.
Defined.

Lemma ab_biprod_corec_eta' {A B X : AbGroup} (f g : ab_biprod A B $-> X)
: (f $o ab_biprod_inl $== g $o ab_biprod_inl)
-> (f $o ab_biprod_inr $== g $o ab_biprod_inr)
-> f $== g.
Proof.
intros h k.
intros [a b].
refine (ap f (ab_biprod_decompose _ _) @ _ @ ap g (ab_biprod_decompose _ _)^).
refine (grp_homo_op _ _ _ @ _ @ (grp_homo_op _ _ _)^).
exact (ap011 (+) (h a) (k b)).
Defined.

(* Maps out of biproducts are determined on the two inclusions. *)
Lemma equiv_path_biprod_corec `{Funext} {A B X : AbGroup} (phi psi : ab_biprod A B $-> X)
: ((phi $o ab_biprod_inl == psi $o ab_biprod_inl) * (phi $o ab_biprod_inr == psi $o ab_biprod_inr))
<~> phi == psi.
Proof.
apply equiv_iff_hprop.
- intros [h k].
intros [a b].
refine (ap phi (ab_biprod_decompose _ _) @ _ @ ap psi (ab_biprod_decompose _ _)^).
refine (grp_homo_op _ _ _ @ _ @ (grp_homo_op _ _ _)^).
exact (ap011 (+) (h a) (k b)).
apply ab_biprod_corec_eta'; assumption.
- intro h.
exact (fun a => h _, fun b => h _).
Defined.
Expand Down Expand Up @@ -311,3 +315,30 @@ Proof.
refine (abgroup_commutative _ _ _ @ _).
exact (ap (fun a => a + snd x) (abgroup_commutative _ _ _)).
Defined.

(** ** AbGroup has binary biproducts *)

Global Instance hasbinarybiproducts_ab : HasBinaryBiproducts AbGroup.
Proof.
intros A B.
snrapply Build_BinaryBiproduct.
- exact (ab_biprod A B).
- exact ab_biprod_pr1.
- exact ab_biprod_pr2.
- exact (fun _ => ab_biprod_corec).
- exact (fun _ f _ => Id f).
- exact (fun _ _ g => Id g).
- exact (fun _ _ _ p q a => path_prod' (p a) (q a)).
- exact ab_biprod_inl.
- exact ab_biprod_inr.
- exact (fun _ => ab_biprod_rec).
- exact (fun _ => ab_biprod_rec_inl_beta).
- exact (fun _ => ab_biprod_rec_inr_beta).
- exact (fun _ => ab_biprod_corec_eta').
- cbn; reflexivity.
- cbn; reflexivity.
- cbn; reflexivity.
- cbn; reflexivity.
Defined.

Global Instance issemiadditive_ab `{Funext} : IsSemiAdditive AbGroup := {}.
Alizter marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion theories/Algebra/AbSES/Core.v
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ Proposition projection_split_beta {B A : AbGroup} (E : AbSES B A)
: projection_split_iso E h o (inclusion _) == ab_biprod_inl.
Proof.
intro a.
refine (ap _ (ab_corec_beta _ _ _ _) @ _).
refine (ap _ (ab_corec_eta _ _ _ _) @ _).
refine (ab_biprod_functor_beta _ _ _ _ _ @ _).
nrapply path_prod'.
2: rapply cx_isexact.
Expand Down
143 changes: 143 additions & 0 deletions theories/Algebra/Homological/Abelian.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
Require Import Basics.Overture Basics.Tactics Basics.Equivalences.
Require Import WildCat.Core WildCat.Equiv WildCat.PointedCat WildCat.Opposite.
Require Import Algebra.AbGroups.AbelianGroup Algebra.Rings.Ring.
Require Import Algebra.Homological.Additive.
Require Import canonical_names.

(** * Abelian Categories *)

Local Open Scope mc_scope.
Local Open Scope mc_add_scope.

(** ** Kernels and cokernels *)

(** *** Kernels *)

Class Kernel {A : Type} `{IsPointedCat A} {a b : A} (f : a $-> b) := {
cat_ker_obj : A;
cat_ker : cat_ker_obj $-> a;

cat_ker_zero : f $o cat_ker $== zero_morphism;

cat_ker_corec {x} (g : x $-> a) : f $o g $== zero_morphism -> x $-> cat_ker_obj;

cat_ker_corec_beta {x} (g : x $-> a) (p : f $o g $== zero_morphism)
: cat_ker $o cat_ker_corec g p $== g;

monic_cat_ker : Monic cat_ker;
}.

Arguments cat_ker_obj {A _ _ _ _ _ a b} f {_}.
Arguments cat_ker_corec {A _ _ _ _ _ a b f _ x} g p.
Arguments cat_ker {A _ _ _ _ _ a b} f {_}.
Arguments cat_ker_zero {A _ _ _ _ _ a b} f {_}.
Arguments monic_cat_ker {A _ _ _ _ _ a b} f {_}.

(** Kernels of monomorphisms are zero. *)
Definition ker_zero_monic {A : Type} `{IsPointedCat A}
{a b : A} (f : a $-> b) `{!Kernel f}
: Monic f -> cat_ker f $== zero_morphism.
Proof.
intros monic.
nrapply monic.
refine (cat_ker_zero f $@ _^$).
apply cat_zero_r.
Defined.

(** Maps with zero kernel are monic. *)
Definition monic_ker_zero {A : Type} `{IsAdditive A}
{a b : A} (f : a $-> b) `{!Kernel f}
: cat_ker f $== zero_morphism -> Monic f.
Proof.
intros ker_zero c g h p.
nrapply GpdHom_path.
apply path_hom in p.
change (@paths (AbHom c a) g h).
change (@paths (AbHom c b) (f $o g) (f $o h)) in p.
apply grp_moveL_1M.
apply grp_moveL_1M in p.
apply GpdHom_path in p.
apply path_hom.
refine ((cat_ker_corec_beta (g + (-h)) _)^$ $@ (ker_zero $@R _) $@ cat_zero_l _).
refine (addcat_dist_l _ _ _ $@ _ $@ p).
apply GpdHom_path.
f_ap.
apply path_hom.
symmetry.
nrapply addcat_comp_negate_r.
Defined.

(** *** Cokernels *)

Class Cokernel {A : Type} `{IsPointedCat A} {a b : A} (f : a $-> b)
:= cokernel_kernel_op :: Kernel (A := A^op) (f : Hom (A:= A^op) b a).

Arguments Cokernel {A _ _ _ _ _ a b} f.

Definition cat_coker_obj {A : Type} `{IsPointedCat A} {a b : A} (f : a $-> b)
`{!Cokernel f} : A
:= cat_ker_obj (A:=A^op) (a:=b) f.

Definition cat_coker {A : Type} `{IsPointedCat A} {a b : A} (f : a $-> b)
`{!Cokernel f} : b $-> cat_coker_obj f
:= cat_ker (A:=A^op) (a:=b) (b:=a) f.

Definition cat_coker_zero {A : Type} `{IsPointedCat A} {a b : A} (f : a $-> b)
`{!Cokernel f} : cat_coker f $o f $== zero_morphism
:= cat_ker_zero (A:=A^op) (a:=b) f.

Definition cat_coker_rec {A : Type} `{IsPointedCat A} {a b : A} {f : a $-> b}
`{!Cokernel f} {x} (g : b $-> x)
: g $o f $== zero_morphism -> cat_coker_obj f $-> x
:= cat_ker_corec (A:=A^op) (a:=b) (b:=a) g.

Definition cat_coker_rec_beta {A : Type} `{IsPointedCat A} {a b : A} (f : a $-> b)
`{!Cokernel f} {x} (g : b $-> x) (p : g $o f $== zero_morphism)
: cat_coker_rec g p $o cat_coker f $== g
:= cat_ker_corec_beta (A:=A^op) (a:=b) (b:=a) g p.

Definition epic_cat_coker {A : Type} `{IsPointedCat A}
{a b : A} (f : a $-> b) `{!Cokernel f}
: Epic (cat_coker f)
:= monic_cat_ker (A:=A^op) (a:=b) (b:=a) f.

Definition coker_zero_epic {A : Type} `{IsPointedCat A}
{a b : A} (f : a $-> b) `{!Cokernel f}
: Epic f -> cat_coker f $== zero_morphism
:= ker_zero_monic (A:=A^op) (a:=b) f.

Definition epic_coker_zero {A : Type} `{IsAdditive A}
{a b : A} (f : a $-> b) {k : Cokernel f}
: cat_coker f $== zero_morphism -> Epic f
:= monic_ker_zero (A:=A^op) (a:=b) (b:=a) f.

(** ** Preabelian categories *)

Class IsPreAbelian {A : Type} `{IsAdditive A} := {
preabelian_has_kernels :: forall {a b : A} (f : a $-> b), Kernel f;
preabelian_has_cokernels :: forall {a b : A} (f : a $-> b), Cokernel f;
}.

Definition cat_coker_ker_ker_coker {A : Type} `{IsPreAbelian A}
{a b : A} (f : a $-> b)
: cat_coker_obj (cat_ker f) $-> cat_ker_obj (cat_coker f).
Proof.
snrapply cat_coker_rec.
- snrapply cat_ker_corec.
+ exact f.
+ nrapply cat_coker_zero.
- snrapply monic_cat_ker.
refine ((cat_assoc _ _ _)^$ $@ _).
refine ((_ $@R _) $@ _).
1: nrapply cat_ker_corec_beta.
refine (_ $@ (cat_zero_r _)^$).
nrapply cat_ker_zero.
Defined.

(** ** Abelian categories *)

Class IsAbelian {A : Type} `{IsPreAbelian A} := {
catie_preabelian_canonical_map : forall a b (f : a $-> b),
CatIsEquiv (cat_coker_ker_ker_coker f);
}.

Loading
Loading