|
| 1 | +(** * Additive categories |
| 2 | +
|
| 3 | + Semi-additive categories in which morphism addition admits inverses, |
| 4 | + so that hom-sets are abelian groups and composition is bilinear. *) |
| 5 | + |
| 6 | +From HoTT Require Import Basics.Overture Basics.Tactics. |
| 7 | +From HoTT.Classes.interfaces Require Import canonical_names abstract_algebra. |
| 8 | +From HoTT.Categories Require Import Category.Core Functor.Core. |
| 9 | +From HoTT.Categories.Functor Require Import Identity Composition.Core. |
| 10 | +From HoTT.Categories.Additive Require Import ZeroObjects SemiAdditive. |
| 11 | +From HoTT.Algebra.AbGroups Require Import AbelianGroup. |
| 12 | + |
| 13 | +Local Open Scope morphism_scope. |
| 14 | + |
| 15 | +(** This lets us use "+", "-" and "0" notation for the commutative monoid |
| 16 | + structure on hom-sets defined in SemiAdditive.v. *) |
| 17 | +Local Open Scope mc_add_scope. |
| 18 | + |
| 19 | +(** ** Definition of additive category |
| 20 | +
|
| 21 | + The commutative monoid structure on hom-sets of a semi-additive category |
| 22 | + is canonical, so an additive category only needs to assume that each |
| 23 | + morphism has an additive inverse. *) |
| 24 | + |
| 25 | +Class AdditiveCategory := { |
| 26 | + additive_semiadditive :: SemiAdditiveCategory; |
| 27 | + |
| 28 | + additive_inverse :: forall (X Y : object additive_semiadditive), |
| 29 | + Inverse (morphism additive_semiadditive X Y); |
| 30 | + |
| 31 | + additive_inverse_l : forall {X Y : object additive_semiadditive} |
| 32 | + (f : morphism additive_semiadditive X Y), |
| 33 | + (- f) + f = 0; |
| 34 | +}. |
| 35 | + |
| 36 | +Coercion additive_semiadditive : AdditiveCategory >-> SemiAdditiveCategory. |
| 37 | + |
| 38 | +(** ** Hom-sets are abelian groups *) |
| 39 | + |
| 40 | +Section HomAbGroup. |
| 41 | + Context {A : AdditiveCategory} (X Y : object A). |
| 42 | + |
| 43 | + (** The bundled abelian group of morphisms from [X] to [Y]. *) |
| 44 | + Definition abgroup_hom : AbGroup |
| 45 | + := Build_AbGroup' (morphism A X Y) _ _ _ additive_inverse_l. |
| 46 | + |
| 47 | + #[export] Instance isabgroup_morphisms : IsAbGroup (morphism A X Y) |
| 48 | + := @isabgroup_abgroup abgroup_hom. |
| 49 | + |
| 50 | +End HomAbGroup. |
| 51 | + |
| 52 | +(** ** Negation and composition *) |
| 53 | + |
| 54 | +(** A left additive inverse equals the negation. *) |
| 55 | +Definition hom_moveL_1V {A : AdditiveCategory} {X Y : object A} |
| 56 | + {f g : morphism A X Y} (H : g + f = 0) |
| 57 | + : g = - f |
| 58 | + := grp_moveL_1V (G:=abgroup_hom X Y) H. |
| 59 | + |
| 60 | +(** Negation is compatible with precomposition. *) |
| 61 | +Definition inverse_precompose {A : AdditiveCategory} {X Y W : object A} |
| 62 | + (f : morphism A X Y) (a : morphism A W X) |
| 63 | + : (- f) o a = - (f o a). |
| 64 | +Proof. |
| 65 | + apply hom_moveL_1V. |
| 66 | + lhs_V napply addition_precompose. |
| 67 | + lhs napply (ap (fun g => g o a) (additive_inverse_l f)). |
| 68 | + napply zero_morphism_left. |
| 69 | +Qed. |
| 70 | + |
| 71 | +(** Negation is compatible with postcomposition. *) |
| 72 | +Definition inverse_postcompose {A : AdditiveCategory} {X Y W : object A} |
| 73 | + (a : morphism A Y W) (f : morphism A X Y) |
| 74 | + : a o (- f) = - (a o f). |
| 75 | +Proof. |
| 76 | + apply hom_moveL_1V. |
| 77 | + lhs_V napply addition_postcompose. |
| 78 | + lhs napply (ap (fun g => a o g) (additive_inverse_l f)). |
| 79 | + napply zero_morphism_right. |
| 80 | +Qed. |
| 81 | + |
| 82 | +(** ** Additive functors |
| 83 | +
|
| 84 | + A functor between additive categories is additive when its action on |
| 85 | + each hom-set is a monoid homomorphism for the canonical addition. |
| 86 | + Such functors automatically preserve zero morphisms and negation. *) |
| 87 | + |
| 88 | +Record AdditiveFunctor (A B : AdditiveCategory) := { |
| 89 | + addfunctor :> Functor A B; |
| 90 | + |
| 91 | + ismonoidpreserving_addfunctor :: forall (X Y : object A), |
| 92 | + IsMonoidPreserving (@morphism_of _ _ addfunctor X Y); |
| 93 | +}. |
| 94 | + |
| 95 | +Arguments addfunctor {A B} F : rename. |
| 96 | +Arguments ismonoidpreserving_addfunctor {A B} F X Y : rename. |
| 97 | + |
| 98 | +(** The identity functor is additive. *) |
| 99 | +Definition id_additive_functor (A : AdditiveCategory) |
| 100 | + : AdditiveFunctor A A. |
| 101 | +Proof. |
| 102 | + snapply Build_AdditiveFunctor. |
| 103 | + - exact 1%functor. |
| 104 | + - intros X Y. |
| 105 | + rapply id_monoid_morphism. |
| 106 | +Defined. |
| 107 | + |
| 108 | +(** Additive functors compose. *) |
| 109 | +Definition compose_additive_functors {A B C : AdditiveCategory} |
| 110 | + (G : AdditiveFunctor B C) (F : AdditiveFunctor A B) |
| 111 | + : AdditiveFunctor A C. |
| 112 | +Proof. |
| 113 | + snapply Build_AdditiveFunctor. |
| 114 | + - exact (G o F)%functor. |
| 115 | + - intros X Y. |
| 116 | + rapply compose_monoid_morphism. |
| 117 | +Defined. |
0 commit comments