Skip to content

Commit 6c68ac5

Browse files
committed
Defined equalizers and coequalizers of semigroups and pullbacks of sets.
1 parent 1168bb4 commit 6c68ac5

File tree

5 files changed

+267
-9
lines changed

5 files changed

+267
-9
lines changed

Category/Monoidal.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Set Implicit Arguments.
66

77
Class Monoidal : Type :=
88
{
9-
cat : Cat;
9+
cat :> Cat;
1010
tensor : Bifunctor cat cat cat;
1111
tensor_unit : Ob cat;
1212
associator : forall X Y Z : Ob cat, Hom (biob (biob X Y) Z) (biob X (biob Y Z));

Instances/Setoid/Sgr.v

+172
Original file line numberDiff line numberDiff line change
@@ -512,4 +512,176 @@ Proof.
512512
+ now apply HB.
513513
+ change {| hd := h; tl := Some t; |} with (@op (Sgr_coproduct A B) (Cons h None) t).
514514
now rewrite (@pres_op _ _ h1), (@pres_op _ _ h2), IHt; destruct h; rewrite ?HA, ?HB.
515+
Defined.
516+
517+
#[refine]
518+
#[export]
519+
Instance Sgr_equalizer {A B : Sgr} (f g : SgrHom A B) : Sgr :=
520+
{
521+
setoid := CoqSetoid_equalizer f g;
522+
}.
523+
Proof.
524+
- cbn; intros [x Hx] [y Hy].
525+
exists (op x y).
526+
now rewrite !pres_op, Hx, Hy.
527+
- intros [a1 H1] [a2 H2] Heq1 [a3 H3] [a4 H4] Heq2; cbn in *.
528+
now rewrite Heq1, Heq2.
529+
- intros [x Hx] [y Hy] [z Hz]; cbn in *.
530+
now rewrite assoc.
531+
Defined.
532+
533+
#[refine]
534+
#[export]
535+
Instance Sgr_equalize {A B : Sgr} (f g : SgrHom A B) : SgrHom (Sgr_equalizer f g) A :=
536+
{
537+
setoidHom := CoqSetoid_equalize f g;
538+
}.
539+
Proof.
540+
now intros [x Hx] [y Hy]; cbn.
541+
Defined.
542+
543+
#[export]
544+
#[refine]
545+
Instance Sgr_factorize
546+
{A B : Sgr} {f g : SgrHom A B}
547+
{E' : Sgr} (e' : Hom E' A) (Heq : (e' .> f) == (e' .> g))
548+
: SgrHom E' (Sgr_equalizer f g) :=
549+
{
550+
setoidHom := CoqSetoid_factorize e' Heq;
551+
}.
552+
Proof.
553+
now cbn; intros; rewrite pres_op.
554+
Defined.
555+
556+
#[refine]
557+
#[export]
558+
Instance HasEqualizers_Sgr : HasEqualizers SgrCat :=
559+
{
560+
equalizer := @Sgr_equalizer;
561+
equalize := @Sgr_equalize;
562+
factorize := @Sgr_factorize;
563+
}.
564+
Proof.
565+
split; cbn.
566+
- now intros [x H]; cbn.
567+
- easy.
568+
- easy.
569+
Defined.
570+
571+
Inductive Sgr_coeq_equiv {A B : Sgr} (f g : SgrHom A B) : B -> B -> Prop :=
572+
| SgrCE_quot : forall a : A, Sgr_coeq_equiv f g (f a) (g a)
573+
| SgrCE_op :
574+
forall {l1 r1 l2 r2 : B},
575+
Sgr_coeq_equiv f g l1 l2 ->
576+
Sgr_coeq_equiv f g r1 r2 ->
577+
Sgr_coeq_equiv f g (op l1 r1) (op l2 r2)
578+
| SgrCE_refl : forall {b1 b2 : B}, b1 == b2 -> Sgr_coeq_equiv f g b1 b2
579+
| SgrCE_sym :
580+
forall {b1 b2 : B}, Sgr_coeq_equiv f g b1 b2 -> Sgr_coeq_equiv f g b2 b1
581+
| SgrCE_trans :
582+
forall {b1 b2 b3 : B},
583+
Sgr_coeq_equiv f g b1 b2 ->
584+
Sgr_coeq_equiv f g b2 b3 ->
585+
Sgr_coeq_equiv f g b1 b3.
586+
587+
#[export] Hint Constructors Sgr_coeq_equiv : core.
588+
589+
#[refine]
590+
#[export]
591+
Instance Sgr_coequalizer_Setoid {A B : Sgr} (f g : SgrHom A B) : Setoid' :=
592+
{
593+
carrier := B;
594+
Setoids.setoid :=
595+
{|
596+
equiv := Sgr_coeq_equiv f g;
597+
|};
598+
}.
599+
Proof.
600+
split; red.
601+
- now constructor.
602+
- now apply SgrCE_sym.
603+
- now intros; apply SgrCE_trans with y.
604+
Defined.
605+
606+
#[refine]
607+
#[export]
608+
Instance Sgr_coequalizer {A B : Sgr} (f g : SgrHom A B) : Sgr :=
609+
{
610+
setoid := Sgr_coequalizer_Setoid f g;
611+
op := op;
612+
}.
613+
Proof.
614+
- intros x1 x2 H12 x3 x4 H34; cbn in *.
615+
now constructor.
616+
- cbn; intros.
617+
apply SgrCE_refl.
618+
now rewrite assoc.
619+
Defined.
620+
621+
#[refine]
622+
#[export]
623+
Instance Sgr_coequalize' {A B : Sgr} (f g : SgrHom A B) : SetoidHom B (Sgr_coequalizer f g) :=
624+
{
625+
func := fun b => b;
626+
}.
627+
Proof.
628+
intros b1 b2 Heq; cbn.
629+
now constructor.
630+
Defined.
631+
632+
#[refine]
633+
#[export]
634+
Instance Sgr_coequalize {A B : Sgr} (f g : SgrHom A B) : SgrHom B (Sgr_coequalizer f g) :=
635+
{
636+
setoidHom := Sgr_coequalize' f g;
637+
}.
638+
Proof.
639+
now constructor; cbn.
640+
Defined.
641+
642+
#[export]
643+
#[refine]
644+
Instance Sgr_cofactorize'
645+
{A B : Sgr} {f g : Hom A B}
646+
{Q : Sgr} (q : Hom B Q) (Heq : f .> q == g .> q)
647+
: SetoidHom (Sgr_coequalizer f g) Q :=
648+
{
649+
func := q;
650+
}.
651+
Proof.
652+
intros x y H. cbn in *.
653+
induction H.
654+
- easy.
655+
- now rewrite !pres_op, IHSgr_coeq_equiv1, IHSgr_coeq_equiv2.
656+
- now rewrite H.
657+
- now symmetry.
658+
- now transitivity (q b2).
659+
Defined.
660+
661+
#[export]
662+
#[refine]
663+
Instance Sgr_cofactorize
664+
{A B : Sgr} {f g : Hom A B}
665+
{Q : Sgr} (q : Hom B Q) (Heq : f .> q == g .> q)
666+
: SgrHom (Sgr_coequalizer f g) Q :=
667+
{
668+
setoidHom := Sgr_cofactorize' Heq;
669+
}.
670+
Proof.
671+
now cbn; intros; rewrite pres_op.
672+
Defined.
673+
674+
#[refine]
675+
#[export]
676+
Instance HasCoequalizers_Sgr : HasCoequalizers SgrCat :=
677+
{
678+
coequalizer := @Sgr_coequalizer;
679+
coequalize := @Sgr_coequalize;
680+
cofactorize := @Sgr_cofactorize;
681+
}.
682+
Proof.
683+
split; cbn.
684+
- now constructor.
685+
- easy.
686+
- easy.
515687
Defined.

Instances/Setoids.v

+88-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From Cat Require Export Cat.
22
From Cat Require Import Category.CartesianClosed.
33
From Cat.Universal Require Export
4-
Initial Terminal Product Coproduct Equalizer Coequalizer Exponential
4+
Initial Terminal Product Coproduct Equalizer Coequalizer Pullback Pushout Exponential
55
IndexedProduct IndexedCoproduct.
66

77
Set Implicit Arguments.
@@ -288,8 +288,8 @@ Proof. now setoid. Defined.
288288

289289
#[export]
290290
Program Instance CoqSetoid_factorize
291-
{X Y : Setoid'} (f g : SetoidHom X Y)
292-
(E' : Setoid') (e' : SetoidHom E' X) (H : forall x : E', f (e' x) == g (e' x))
291+
{X Y : Setoid'} {f g : SetoidHom X Y}
292+
{E' : Setoid'} (e' : SetoidHom E' X) (Heq : forall x : E', f (e' x) == g (e' x))
293293
: SetoidHom E' (CoqSetoid_equalizer f g) :=
294294
{
295295
func := fun x => e' x
@@ -517,4 +517,88 @@ Instance CoqSetoid_CartesianClosed : CartesianClosed CoqSetoid :=
517517
HasTerm_CartesianClosed := HasTerm_CoqSetoid;
518518
HasProducts_CartesianClosed := HasProducts_CoqSetoid;
519519
HasExponentials_CartesianClosed := HasExponentials_CoqSetoid;
520-
}.
520+
}.
521+
522+
Record CoqSetoid_pullback'
523+
{A B X : Setoid'} (f : SetoidHom A X) (g : SetoidHom B X) : Type := triple
524+
{
525+
pullL : A;
526+
pullR : B;
527+
ok : f pullL == g pullR;
528+
}.
529+
530+
Arguments triple {A B X f g} _ _ _.
531+
Arguments pullL {A B X f g} _.
532+
Arguments pullR {A B X f g} _.
533+
Arguments ok {A B X f g} _.
534+
535+
#[refine]
536+
#[export]
537+
Instance CoqSetoid_pullback
538+
{A B X : Setoid'} (f : SetoidHom A X) (g : SetoidHom B X) : Setoid' :=
539+
{
540+
carrier := CoqSetoid_pullback' f g;
541+
}.
542+
Proof.
543+
unshelve esplit.
544+
- refine (fun x y => pullL x == pullL y /\ pullR x == pullR y).
545+
- split; red.
546+
+ easy.
547+
+ easy.
548+
+ now intros x y z [-> ->] [-> ->].
549+
Defined.
550+
551+
#[refine]
552+
#[export]
553+
Instance CoqSetoid_pullL
554+
{A B X : Setoid'} (f : SetoidHom A X) (g : SetoidHom B X)
555+
: SetoidHom (CoqSetoid_pullback f g) A :=
556+
{
557+
func := pullL
558+
}.
559+
Proof.
560+
now intros x y [H _]; cbn.
561+
Defined.
562+
563+
#[refine]
564+
#[export]
565+
Instance CoqSetoid_pullR
566+
{A B X : Setoid'} (f : SetoidHom A X) (g : SetoidHom B X)
567+
: SetoidHom (CoqSetoid_pullback f g) B :=
568+
{
569+
func := pullR;
570+
}.
571+
Proof.
572+
now intros x y [_ H]; cbn.
573+
Defined.
574+
575+
#[refine]
576+
#[export]
577+
Instance CoqSetoid_triple
578+
{A B X : Setoid'} (f : SetoidHom A X) (g : SetoidHom B X)
579+
{Γ : Setoid'} (a : SetoidHom Γ A) (b : SetoidHom Γ B) (Heq : forall x : Γ, f (a x) == g (b x))
580+
: SetoidHom Γ (CoqSetoid_pullback f g) :=
581+
{
582+
func := fun x => triple (a x) (b x) (Heq x);
583+
}.
584+
Proof.
585+
intros x y H; cbn.
586+
now rewrite H.
587+
Defined.
588+
589+
#[refine]
590+
#[export]
591+
Instance HasPullbacks_CoqSetoid : HasPullbacks CoqSetoid :=
592+
{
593+
pullback := @CoqSetoid_pullback;
594+
pullL := @CoqSetoid_pullL;
595+
pullR := @CoqSetoid_pullR;
596+
triple := @CoqSetoid_triple;
597+
}.
598+
Proof.
599+
split; cbn.
600+
- now apply ok.
601+
- easy.
602+
- easy.
603+
- easy.
604+
Defined.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- equalizers and coequalizers
2020
- pullbacks and pushouts
2121
- exponentials
22+
2223
The definitions are quite far from what you can find in a typical textbook a- they are equational and stated in a way that strongly resembles the rules of type theory (formation, introduction, elimination, computation and uniqueness), but with the uniqueness rules being "symmetric".
2324

2425
This is one of my greatest accomplishments — after changing, improving and correcting the definitions a gazillion times I'm starting to be pretty sure that they are correct and convenient. However, they're not perfect yet: there are issues with coherence conditions.

Universal/Equalizer.v

+5-4
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Proof.
118118
exists (factorize2 E1 equalize1 ok).
119119
repeat split.
120120
- exists (factorize1 E2 equalize2 ok).
121-
now rewrite equiv_equalizer', equiv_equalizer', !comp_assoc, !factorize_equalize, !comp_id_l.
121+
now rewrite !equiv_equalizer', !comp_assoc, !factorize_equalize, !comp_id_l.
122122
- now rewrite factorize_equalize.
123123
- now intros y [_ ?]; rewrite equiv_equalizer', factorize_equalize.
124124
Qed.
@@ -150,7 +150,8 @@ Qed.
150150
Lemma isEqualizer_equiv_factorize :
151151
forall
152152
(E : Ob C) (equalize : Hom E X)
153-
(factorize1 factorize2 : forall (E' : Ob C) (e' : Hom E' X), e' .> f == e' .> g -> Hom E' E),
153+
(factorize1 factorize2 :
154+
forall (E' : Ob C) (e' : Hom E' X), e' .> f == e' .> g -> Hom E' E),
154155
isEqualizer C f g E equalize factorize1 ->
155156
isEqualizer C f g E equalize factorize2 ->
156157
forall (E' : Ob C) (e' : Hom E' X) (H : e' .> f == e' .> g),
@@ -187,6 +188,6 @@ Class HasEqualizers (C : Cat) : Type :=
187188
isEqualizer C f g (equalizer f g) (equalize f g) (@factorize _ _ f g)
188189
}.
189190

190-
Arguments equalizer [C _ X Y] _ _.
191-
Arguments equalize [C _ X Y] _ _.
191+
Arguments equalizer [C _ X Y] _ _.
192+
Arguments equalize [C _ X Y] _ _.
192193
Arguments factorize [C _ X Y f g E'] _ _.

0 commit comments

Comments
 (0)