-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCoendFunctor.v
149 lines (121 loc) · 4.87 KB
/
CoendFunctor.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
Require Import ProofIrrelevance.
Require Export Coend LimitFunctors LimitFunctors FunctorCategory ProductInducedFunctors FunctorialComposition.
Require Import Common Notations.
Set Implicit Arguments.
Generalizable All Variables.
Set Asymmetric Patterns.
Set Universe Polymorphism.
Local Open Scope type_scope.
Section Coend.
Context `(C : @SpecializedCategory objC).
Let COp := OppositeCategory C.
Definition CoendFunctor_Index_Object := { ds : objC * objC & Morphism C (snd ds) (fst ds) } + objC.
Global Arguments CoendFunctor_Index_Object /.
Definition CoendFunctor_Index_Morphism (s d : CoendFunctor_Index_Object) : Set :=
match (s, d) with
| (inl sdm, inr c) => (fst (projT1 sdm) = c) + (snd (projT1 sdm) = c)
| _ => (s = d)
end.
Global Arguments CoendFunctor_Index_Morphism s d /.
Definition CoendFunctor_Index_Identity x : CoendFunctor_Index_Morphism x x :=
match x as s return (CoendFunctor_Index_Morphism s s) with
| inl s => eq_refl
| inr s => eq_refl
end.
Global Arguments CoendFunctor_Index_Identity x /.
Ltac inj H := injection H; clear H; intros; subst.
Definition CoendFunctor_Index_Compose s d d' :
CoendFunctor_Index_Morphism d d'
-> CoendFunctor_Index_Morphism s d
-> CoendFunctor_Index_Morphism s d'.
Proof.
destruct s, d, d'; simpl; intros;
match goal with
| [ H : _ + _ |- _ ] => destruct H; [ left | right ];
abstract congruence
| _ => abstract congruence
end.
Defined.
Definition CoendFunctor_Index : SpecializedCategory CoendFunctor_Index_Object.
Proof.
refine (@Build_SpecializedCategory _
CoendFunctor_Index_Morphism
CoendFunctor_Index_Identity
CoendFunctor_Index_Compose
_
_
_);
abstract (
simpl; intros;
repeat (match goal with
| [ x : _ + _ |- _ ] => destruct x; simpl in *
| _ => apply proof_irrelevance
| _ => congruence
| _ => f_equal
end)
).
Defined.
Definition CoendFunctor_Diagram_ObjectOf_pre : CoendFunctor_Index -> (COp * C) :=
fun x => match x with
| inl c0c1 => (projT1 c0c1)
| inr c => (c, c)
end.
Global Arguments CoendFunctor_Diagram_ObjectOf_pre _ /.
Hint Extern 1 (Morphism _ ?X ?X) => apply Identity : morphism.
(* Hint Extern 1 (Morphism _ _ _) => hnf. *)
Definition CoendFunctor_Diagram_MorphismOf_pre s d :
CoendFunctor_Index_Morphism s d
-> Morphism (COp * C) (CoendFunctor_Diagram_ObjectOf_pre s) (CoendFunctor_Diagram_ObjectOf_pre d).
Proof.
destruct s, d; simpl in *; intros; split;
repeat match goal with
| _ => discriminate
| _ => assumption
| [ H : inl _ = inl _ |- _ ] => inj H
| [ H : inr _ = inr _ |- _ ] => inj H
| [ H : sigT _ |- _ ] => destruct H; simpl in *
| [ H : _ + _ |- _ ] => destruct H; subst
end;
apply Identity.
Defined.
Ltac inj' H :=
match type of H with
| ?X = ?X => fail 1
| _ => injection H; intros; subst
end.
Definition CoendFunctor_Diagram_pre : SpecializedFunctor CoendFunctor_Index (COp * C).
Proof.
refine (Build_SpecializedFunctor
CoendFunctor_Index (COp * C)
CoendFunctor_Diagram_ObjectOf_pre
CoendFunctor_Diagram_MorphismOf_pre
_
_);
abstract (
repeat match goal with
| [ |- forall x : CoendFunctor_Index_Object, _ ] =>
destruct x
end; simpl; intros;
repeat match goal with
| _ => discriminate
| _ => progress (subst; unfold eq_rect_r)
| [ H : inl _ = inl _ |- _ ] => inj' H
| [ H : inr _ = inr _ |- _ ] => inj' H
| [ x : sigT _ |- _ ] => destruct x; simpl in *
| [ H : _ + _ |- _ ] => destruct H
| _ => rewrite <- eq_rect_eq
| _ => apply injective_projections; simpl
end; auto with category
).
Defined.
End Coend.
Section CoendFunctor.
Context `(C : @SpecializedCategory objC).
Context `(D : @SpecializedCategory objD).
Let COp := OppositeCategory C.
Hypothesis HasColimits : forall F : SpecializedFunctor (CoendFunctor_Index C) D, Colimit F.
Let CoendFunctor_post := ColimitFunctor HasColimits.
Let o := (FunctorialComposition (CoendFunctor_Index C) (COp * C) D).
Let CoendFunctor_pre := (o ⟨ - , (CoendFunctor_Diagram_pre C) ⟩)%functor.
Definition CoendFunctor := ComposeFunctors CoendFunctor_post CoendFunctor_pre.
End CoendFunctor.