-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDiscreteCategoryFunctors.v
219 lines (189 loc) · 6.6 KB
/
DiscreteCategoryFunctors.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
Require Import FunctionalExtensionality.
Require Export DiscreteCategory Functor SetCategory ComputableCategory SmallCat NaturalTransformation.
Require Import Common Adjoint.
Set Implicit Arguments.
Generalizable All Variables.
Set Asymmetric Patterns.
Set Universe Polymorphism.
Section FunctorFromDiscrete.
Variable O : Type.
Context `(D : @SpecializedCategory objD).
Variable objOf : O -> objD.
Let FunctorFromDiscrete_MorphismOf s d (m : Morphism (DiscreteCategory O) s d) : Morphism D (objOf s) (objOf d)
:= match m with
| eq_refl => Identity _
end.
Definition FunctorFromDiscrete : SpecializedFunctor (DiscreteCategory O) D.
Proof.
refine {| ObjectOf := objOf; MorphismOf := FunctorFromDiscrete_MorphismOf |};
abstract (
intros; hnf in *; subst; simpl;
auto with category
).
Defined.
End FunctorFromDiscrete.
Section Obj.
Local Ltac build_ob_functor Index2Object :=
match goal with
| [ |- SpecializedFunctor ?C ?D ] =>
refine (Build_SpecializedFunctor C D
(fun C' => Index2Object C')
(fun _ _ F => ObjectOf F)
_
_
)
end;
intros; simpl in *; reflexivity.
Section type.
Variable I : Type.
Variable Index2Object : I -> Type.
Context `(Index2Cat : forall i : I, @SpecializedCategory (@Index2Object i)).
Definition ObjectFunctor : SpecializedFunctor (@ComputableCategory _ _ Index2Cat) TypeCat.
build_ob_functor Index2Object.
Defined.
End type.
Section set.
Variable I : Type.
Variable Index2Object : I -> Set.
Context `(Index2Cat : forall i : I, @SpecializedCategory (@Index2Object i)).
Definition ObjectFunctorToSet : SpecializedFunctor (@ComputableCategory _ _ Index2Cat) SetCat.
build_ob_functor Index2Object.
Defined.
End set.
Section prop.
Variable I : Type.
Variable Index2Object : I -> Prop.
Context `(Index2Cat : forall i : I, @SpecializedCategory (@Index2Object i)).
Definition ObjectFunctorToProp : SpecializedFunctor (@ComputableCategory _ _ Index2Cat) PropCat.
build_ob_functor Index2Object.
Defined.
End prop.
End Obj.
Arguments ObjectFunctor {I Index2Object Index2Cat}.
Arguments ObjectFunctorToSet {I Index2Object Index2Cat}.
Arguments ObjectFunctorToProp {I Index2Object Index2Cat}.
Section Mor.
Local Ltac build_mor_functor Index2Object Index2Cat :=
match goal with
| [ |- SpecializedFunctor ?C ?D ] =>
refine (Build_SpecializedFunctor C D
(fun C' => { sd : Index2Object C' * Index2Object C' & (Index2Cat C').(Morphism) (fst sd) (snd sd) } )
(fun _ _ F => (fun sdm =>
existT (fun sd => Morphism _ (fst sd) (snd sd))
(F (fst (projT1 sdm)), F (snd (projT1 sdm)))
(MorphismOf F (s := fst (projT1 sdm)) (d := snd (projT1 sdm)) (projT2 sdm))
))
_
_
)
end;
intros; simpl in *; try reflexivity;
repeat (apply functional_extensionality_dep; intro);
simpl_eq;
reflexivity.
Section type.
Variable I : Type.
Variable Index2Object : I -> Type.
Context `(Index2Cat : forall i : I, @SpecializedCategory (@Index2Object i)).
Definition MorphismFunctor : SpecializedFunctor (@ComputableCategory _ _ Index2Cat) TypeCat.
build_mor_functor Index2Object Index2Cat.
Defined.
End type.
End Mor.
Arguments MorphismFunctor {I Index2Object Index2Cat}.
Section dom_cod.
Local Ltac build_dom_cod fst_snd :=
match goal with
| [ |- SpecializedNaturalTransformation ?F ?G ] =>
refine (Build_SpecializedNaturalTransformation F G
(fun _ => (fun sdf => fst_snd _ _ (projT1 sdf)))
_
)
end;
reflexivity.
Section type.
Variable I : Type.
Variable Index2Object : I -> Type.
Context `(Index2Cat : forall i : I, @SpecializedCategory (@Index2Object i)).
Definition DomainNaturalTransformation : SpecializedNaturalTransformation (@MorphismFunctor _ _ Index2Cat) ObjectFunctor.
build_dom_cod @fst.
Defined.
Definition CodomainNaturalTransformation : SpecializedNaturalTransformation (@MorphismFunctor _ _ Index2Cat) ObjectFunctor.
build_dom_cod @snd.
Defined.
End type.
End dom_cod.
Section InducedFunctor.
Variable O : Type.
Context `(O' : @SpecializedCategory obj).
Variable f : O -> O'.
Definition InducedDiscreteFunctor : SpecializedFunctor (DiscreteCategory O) O'.
match goal with
| [ |- SpecializedFunctor ?C ?D ] =>
refine (Build_SpecializedFunctor C D
f
(fun s d_ m => match m return _ with eq_refl => Identity (f s) end)
_
_
)
end;
abstract (
intros; simpl in *; repeat subst; trivial;
repeat rewrite RightIdentity; repeat rewrite LeftIdentity;
repeat rewrite Associativity;
reflexivity
).
Defined.
End InducedFunctor.
Section disc.
Local Ltac t := simpl; intros; functor_eq;
repeat (apply functional_extensionality_dep; intro);
hnf in *; subst;
auto.
Definition DiscreteFunctor : SpecializedFunctor TypeCat LocallySmallCat.
refine (Build_SpecializedFunctor TypeCat LocallySmallCat
(fun O => DiscreteCategory O : LocallySmallSpecializedCategory _)
(fun s d f => InducedDiscreteFunctor _ f)
_
_
);
abstract t.
Defined.
Definition DiscreteSetFunctor : SpecializedFunctor SetCat SmallCat.
refine (Build_SpecializedFunctor SetCat SmallCat
(fun O => DiscreteCategory O : SmallSpecializedCategory _)
(fun s d f => InducedDiscreteFunctor _ f)
_
_
);
abstract t.
Defined.
End disc.
Section Adjoints.
Lemma DiscreteObjectIdentity : ComposeFunctors ObjectFunctor DiscreteFunctor = IdentityFunctor _.
functor_eq.
Qed.
Definition DiscreteObjectAdjunction : HomAdjunction DiscreteFunctor ObjectFunctor.
match goal with
| [ |- HomAdjunction ?F ?G ] =>
refine (Build_HomAdjunction F G
(fun _ _ F => (fun x => F x))
_
_
)
end;
try abstract trivial;
simpl; intros.
exists (fun f => (InducedDiscreteFunctor _ f));
abstract (repeat match goal with
| _ => progress trivial
| _ => progress repeat (apply functional_extensionality_dep; intro)
| _ => hnf in *;
match goal with
| [ H : _ = _ |- _ ] => destruct H; simpl in *
end
| _ => rewrite FIdentityOf
| _ => progress functor_eq
end).
Defined.
End Adjoints.