Skip to content

Commit e67e486

Browse files
committed
Significant progress on biproducts.
1 parent 107d9eb commit e67e486

File tree

8 files changed

+132
-32
lines changed

8 files changed

+132
-32
lines changed

Cat.v

+11
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,17 @@ Definition isAut' {C : Cat} {A : Ob C} (f : Hom A A) : Type :=
303303

304304
#[global] Hint Unfold isEndo isMono isEpi isBi isSec isRet isIso isAut : core.
305305

306+
(** Constant, coconstant and zero morphisms *)
307+
308+
Definition isConstant {C : Cat} {A B : Ob C} (f : Hom A B) : Prop :=
309+
forall (X : Ob C) (h1 h2 : Hom X A), h1 .> f == h2 .> f.
310+
311+
Definition isCoconstant {C : Cat} {A B : Ob C} (f : Hom A B) : Prop :=
312+
forall (X : Ob C) (h1 h2 : Hom B X), f .> h1 == f .> h2.
313+
314+
Definition isZeroMor {C : Cat} {A B : Ob C} (f : Hom A B) : Prop :=
315+
isConstant f /\ isCoconstant f.
316+
306317
(** *** Duality and subsumption *)
307318

308319
Lemma isMono_Dual :

Instances/AbGrp.v

+2
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ Proof.
156156
- now apply HasProducts_AbGrp.
157157
- now apply HasCoproducts_AbGrp.
158158
- now cbn.
159+
- now cbn.
160+
- now cbn.
159161
Defined.
160162

161163
#[refine]

Instances/CMon.v

+2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ Proof.
203203
- now apply HasProducts_CMon.
204204
- now apply HasCoproducts_CMon.
205205
- now cbn.
206+
- now cbn.
207+
- now cbn.
206208
Defined.
207209

208210
#[refine]

Instances/FunCat.v

+23-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
From Cat Require Import Cat.
22
From Cat.Universal Require Import
3-
Initial Terminal Product Coproduct Biproduct Equalizer Coequalizer Pullback Pushout Exponential.
3+
Initial Terminal Product Coproduct Biproduct
4+
Equalizer Coequalizer Pullback Pushout Exponential.
45
From Cat.Universal Require Import Duality.
56

67
Set Implicit Arguments.
@@ -244,7 +245,8 @@ Defined.
244245

245246
#[refine]
246247
#[export]
247-
Instance FunCat_biproduct {C D : Cat} {hb : HasBiproducts' D} (F G : Functor C D) : Functor C D :=
248+
Instance FunCat_biproduct
249+
{C D : Cat} {hb : HasBiproducts' D} (F G : Functor C D) : Functor C D :=
248250
{
249251
fob := fun X : Ob C => biproduct (fob F X) (fob G X);
250252
fmap := fun (X Y : Ob C) (f : Hom X Y) => fmap F f ×+' fmap G f
@@ -258,7 +260,8 @@ Defined.
258260
#[refine]
259261
#[export]
260262
Instance FunCat_bioutl
261-
{C D : Cat} {hp : HasBiproducts' D} {F G : Functor C D} : NatTrans (FunCat_biproduct F G) F :=
263+
{C D : Cat} {hp : HasBiproducts' D} {F G : Functor C D}
264+
: NatTrans (FunCat_biproduct F G) F :=
262265
{
263266
component := fun _ : Ob C => bioutl
264267
}.
@@ -272,7 +275,8 @@ Defined.
272275
#[refine]
273276
#[export]
274277
Instance FunCat_bioutr
275-
{C D : Cat} {hp : HasBiproducts' D} {F G : Functor C D} : NatTrans (FunCat_biproduct F G) G :=
278+
{C D : Cat} {hp : HasBiproducts' D} {F G : Functor C D}
279+
: NatTrans (FunCat_biproduct F G) G :=
276280
{
277281
component := fun _ : Ob C => bioutr
278282
}.
@@ -292,19 +296,18 @@ Instance FunCat_bipair
292296
component := fun X : Ob C => bipair (component α X) (component β X)
293297
}.
294298
Proof.
295-
intros.
296-
rewrite fpair_comp, <- !natural.
297-
rewrite equiv_product', fpair_outl, fpair_outr.
298-
Search bipair fmap. cbn.
299-
(* rewrite equiv_product', !comp_assoc, fpair_outl, fpair_outr. cbn.
300-
rewrite !copair_comp, binr_bioutl', binl_bioutr'.
301-
rewrite !comp_assoc, binl_bioutl, binr_bioutr, !comp_id_r. *)
302-
Admitted.
299+
intros X Y f; cbn.
300+
rewrite equiv_product', !comp_assoc.
301+
rewrite bicopair_bioutl, bicopair_bioutr.
302+
rewrite fpair_outl, fpair_outr, <- !comp_assoc, fpair_outl, fpair_outr.
303+
now rewrite !natural.
304+
Defined.
303305

304306
#[refine]
305307
#[export]
306308
Instance FunCat_binl
307-
{C D : Cat} {hp : HasBiproducts' D} {F G : Functor C D} : NatTrans F (FunCat_biproduct F G) :=
309+
{C D : Cat} {hp : HasBiproducts' D} {F G : Functor C D}
310+
: NatTrans F (FunCat_biproduct F G) :=
308311
{
309312
component := fun _ : Ob C => binl
310313
}.
@@ -315,7 +318,8 @@ Defined.
315318
#[refine]
316319
#[export]
317320
Instance FunCat_binr
318-
{C D : Cat} {hp : HasBiproducts' D} {F G : Functor C D} : NatTrans G (FunCat_biproduct F G) :=
321+
{C D : Cat} {hp : HasBiproducts' D} {F G : Functor C D}
322+
: NatTrans G (FunCat_biproduct F G) :=
319323
{
320324
component := fun _ : Ob C => binr
321325
}.
@@ -352,14 +356,16 @@ Instance HasBiproducts_FunCat
352356
}.
353357
Proof.
354358
- split; cbn; intros.
355-
+ admit.
356-
+ admit.
359+
+ now rewrite fpair_outl.
360+
+ now rewrite fpair_outr.
357361
+ now rewrite equiv_product', H, H0.
358362
- split; cbn; intros.
359363
+ now rewrite finl_copair.
360364
+ now rewrite finr_copair.
361365
+ now rewrite equiv_coproduct', H, H0.
362-
- cbn; intros. apply HasBiproducts'_ok.
366+
- now cbn; intros F G X; apply binl_bioutl.
367+
- now cbn; intros F G X; apply binr_bioutr.
368+
- now cbn; intros; apply HasBiproducts'_ok.
363369
Defined.
364370

365371
#[refine]

Instances/Rel.v

+6
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ Instance HasBiproducts'_Rel : HasBiproducts' Rel :=
281281
Proof.
282282
- now apply HasProducts_Rel.
283283
- now apply HasCoproducts_Rel.
284+
- intros A B a1 a2; cbn; split.
285+
+ now intros [[a | b] [H1 H2]]; [rewrite H1, H2 |].
286+
+ now intros Heq; exists (inl a2).
287+
- intros A B b1 b2; cbn; split.
288+
+ now intros [[a | b] [H1 H2]]; [| rewrite H1, H2].
289+
+ now intros Heq; exists (inr b2).
284290
- intros A B [a1 | b1] [a2 | b2]; cbn.
285291
+ now firstorder.
286292
+ split; [| now firstorder].

Universal/Biproduct.v

+81-13
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Set Implicit Arguments.
1717
Class isBiproduct
1818
(C : Cat) {A B : Ob C}
1919
(P : Ob C) (outl : Hom P A) (outr : Hom P B) (finl : Hom A P) (finr : Hom B P)
20-
(fpair : forall {X : Ob C} (f : Hom X A) (g : Hom X B), Hom X P)
20+
(fpair : forall {X : Ob C} (f : Hom X A) (g : Hom X B), Hom X P)
2121
(copair : forall {X : Ob C} (f : Hom A X) (g : Hom B X), Hom P X)
2222
: Prop :=
2323
{
@@ -56,17 +56,36 @@ Class HasBiproducts' (C : Cat) : Type :=
5656
binl : forall {A B : Ob C}, Hom A (biproduct A B);
5757
binr : forall {A B : Ob C}, Hom B (biproduct A B);
5858
bicopair : forall {A B : Ob C} {P : Ob C} (f : Hom A P) (g : Hom B P), Hom (biproduct A B) P;
59-
6059
isCoproduct_HasBiproducts :>
6160
forall {A B : Ob C}, isCoproduct C (@biproduct A B) binl binr (@bicopair A B);
6261

62+
binl_bioutl :
63+
forall {A B : Ob C},
64+
@binl A B .> bioutl == id A;
65+
binr_bioutr :
66+
forall {A B : Ob C},
67+
@binr A B .> bioutr == id B;
68+
6369
HasBiproducts'_ok :
6470
forall {A B : Ob C},
6571
@bioutl A B .> @binl A B .> @bioutr A B .> @binr A B
6672
==
6773
bioutr .> binr .> bioutl .> binl;
6874
}.
69-
75+
76+
Definition zero {C : Cat} {hb : HasBiproducts' C} {A B : Ob C} : Hom A B :=
77+
@binl _ _ A B .> bioutr.
78+
79+
Definition bidiag {C : Cat} {hp : HasBiproducts' C} {A : Ob C} : Hom A (biproduct A A) :=
80+
bipair (id A) (id A).
81+
82+
Definition bicodiag {C : Cat} {hp : HasBiproducts' C} {A : Ob C} : Hom (biproduct A A) A :=
83+
bicopair (id A) (id A).
84+
85+
Definition biadd
86+
{C : Cat} {hb : HasBiproducts' C}
87+
{A B : Ob C} (f g : Hom A B) : Hom A B :=
88+
bipair f g .> bicodiag.
7089

7190
Section BiproductIdentities.
7291

@@ -75,20 +94,16 @@ Context
7594
(hb : HasBiproducts' C)
7695
(A B : Ob C).
7796

78-
Lemma binl_bioutl :
79-
@binl _ _ A B .> bioutl == id A.
80-
Proof.
81-
Admitted.
82-
83-
Lemma binr_bioutr :
84-
@binr _ _ A B .> bioutr == id B.
85-
Proof.
86-
Admitted.
87-
8897
Lemma binl_bioutr :
8998
forall {X : Ob C} (f : Hom B X),
9099
@binl _ _ A B .> bioutr .> f == @binl _ _ A X .> bioutr.
91100
Proof.
101+
intros.
102+
(* assert (
103+
bioutr .> binr .> bioutl .> @binl _ _ A B .> bioutr .> f
104+
==
105+
bioutr .> binr .> bioutl .> @binl _ _ A X .> bioutr).
106+
). *)
92107
Admitted.
93108

94109
Lemma binl_bioutr' :
@@ -107,10 +122,63 @@ Lemma binr_bioutl' :
107122
forall {X : Ob C} (f : Hom X B),
108123
f .> @binr _ _ A B .> bioutl == @binr _ _ A X .> bioutl.
109124
Proof.
125+
intros.
126+
assert (H1 : isConstant (@binr _ _ A B .> bioutl)) by admit.
127+
assert (H2 : isCoconstant (@binr _ _ A B .> bioutl)) by admit.
128+
unfold isConstant, isCoconstant in H1, H2.
110129
Admitted.
111130

112131
End BiproductIdentities.
113132

133+
Section MoreBiproductIdentities.
134+
135+
Context
136+
(C : Cat)
137+
(hb : HasBiproducts' C)
138+
(A B : Ob C).
139+
140+
Lemma binl_bipair :
141+
forall {A' B' : Ob C} (f : Hom A A') (g : Hom B B'),
142+
binl .> bipair (bioutl .> f) (bioutr .> g) == f .> binl.
143+
Proof.
144+
intros.
145+
rewrite equiv_product', !comp_assoc, fpair_outl, fpair_outr.
146+
rewrite binl_bioutl, <- !comp_assoc, binl_bioutl, comp_id_l, comp_id_r.
147+
now rewrite binl_bioutr, binl_bioutr'.
148+
Qed.
149+
150+
Lemma binr_bipair :
151+
forall {A' B' : Ob C} (f : Hom A A') (g : Hom B B'),
152+
binr .> bipair (bioutl .> f) (bioutr .> g) == g .> binr.
153+
Proof.
154+
intros.
155+
rewrite equiv_product', !comp_assoc, fpair_outl, fpair_outr.
156+
rewrite binr_bioutr, <- !comp_assoc, binr_bioutr, comp_id_l, comp_id_r.
157+
now rewrite binr_bioutl, binr_bioutl'.
158+
Qed.
159+
160+
Lemma bicopair_bioutl :
161+
forall {A' B' : Ob C} (f : Hom A A') (g : Hom B B'),
162+
bicopair (f .> binl) (g .> binr) .> bioutl == bioutl .> f.
163+
Proof.
164+
intros.
165+
rewrite equiv_coproduct', <- !comp_assoc, finl_copair, finr_copair.
166+
rewrite binr_bioutl, binr_bioutl'.
167+
now rewrite binl_bioutl, comp_assoc, binl_bioutl, comp_id_l, comp_id_r.
168+
Defined.
169+
170+
Lemma bicopair_bioutr :
171+
forall {A' B' : Ob C} (f : Hom A A') (g : Hom B B'),
172+
bicopair (f .> binl) (g .> binr) .> bioutr == bioutr .> g.
173+
Proof.
174+
intros.
175+
rewrite equiv_coproduct', <- !comp_assoc, finl_copair, finr_copair.
176+
rewrite binl_bioutr, binl_bioutr'.
177+
now rewrite binr_bioutr, comp_assoc, binr_bioutr, comp_id_l, comp_id_r.
178+
Defined.
179+
180+
End MoreBiproductIdentities.
181+
114182
#[refine]
115183
#[export]
116184
Instance BiproductBifunctor' {C : Cat} {hp : HasBiproducts' C} : Bifunctor C C C :=

Universal/Coproduct.v

+3
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ Proof.
353353
now apply isIso_associator.
354354
Defined.
355355

356+
Definition codiag {C : Cat} {hp : HasCoproducts C} {A : Ob C} : Hom (coproduct A A) A :=
357+
copair (id A) (id A).
358+
356359
#[refine]
357360
#[export]
358361
Instance CoproductBifunctor {C : Cat} {hp : HasCoproducts C} : Bifunctor C C C :=

Universal/Product.v

+4-2
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@ Lemma fpair_comp' :
249249
(A B Γ A' B' : Ob C) (a : Hom Γ A) (b : Hom Γ B) (h1 : Hom A A') (h2 : Hom B B'),
250250
fpair a b .> fpair (outl .> h1) (outr .> h2) == fpair (a .> h1) (b .> h2).
251251
Proof.
252-
intros; rewrite equiv_product'.
253-
now rewrite !comp_assoc, !fpair_outl, !fpair_outr, <- !comp_assoc, fpair_outl, fpair_outr.
252+
now intros; rewrite fpair_comp, <- !comp_assoc, fpair_outl, fpair_outr.
254253
Qed.
255254

256255
Lemma fpair_comp_id :
@@ -347,6 +346,9 @@ Proof.
347346
- now apply unassociator_associator.
348347
Defined.
349348

349+
Definition diag {C : Cat} {hp : HasProducts C} {A : Ob C} : Hom A (product A A) :=
350+
fpair (id A) (id A).
351+
350352
#[refine]
351353
#[export]
352354
Instance ProductBifunctor {C : Cat} {hp : HasProducts C} : Bifunctor C C C :=

0 commit comments

Comments
 (0)