-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDecidableDiscreteCategoryFunctors.v
276 lines (248 loc) · 9.12 KB
/
DecidableDiscreteCategoryFunctors.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
Require Import FunctionalExtensionality Eqdep_dec ProofIrrelevance JMeq.
Require Export DiscreteCategoryFunctors DecidableDiscreteCategory DecidableSetCategory DecidableComputableCategory DecidableSmallCat.
Require Import Common Adjoint.
Set Implicit Arguments.
Generalizable All Variables.
Set Asymmetric Patterns.
Set Universe Polymorphism.
Section eq_dec_prop.
Lemma eq_dec_prop T (eq_dec : forall x y : T, {x = y} + {x <> y}) : forall x y : T, x = y \/ x <> y.
intros x y; case (eq_dec x y); intuition.
Qed.
End eq_dec_prop.
Section Obj.
Local Ltac build_ob_functor Index2Object :=
match goal with
| [ |- SpecializedFunctor ?C ?D ] =>
refine (Build_SpecializedFunctor C D
(fun C' => existT _ (Index2Object (projT1 C')) (projT2 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 ObjectFunctorDec : SpecializedFunctor (@ComputableCategoryDec _ _ Index2Cat) TypeCatDec.
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 ObjectFunctorToSetDec : SpecializedFunctor (@ComputableCategoryDec _ _ Index2Cat) SetCatDec.
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 ObjectFunctorToPropDec : SpecializedFunctor (@ComputableCategoryDec _ _ Index2Cat) PropCatDec.
build_ob_functor Index2Object.
Defined.
End prop.
End Obj.
Arguments ObjectFunctorDec {I Index2Object Index2Cat}.
Arguments ObjectFunctorToSetDec {I Index2Object Index2Cat}.
Arguments ObjectFunctorToPropDec {I Index2Object Index2Cat}.
Section InducedFunctor.
Variable O : Type.
Context `(O' : @SpecializedCategory obj).
Variable f : O -> O'.
Variable eq_dec : forall x y : O, {x = y} + {x <> y}.
Hint Unfold Object.
Local Ltac t' := intros; simpl in *; autounfold with core in *; repeat subst; trivial.
Local Ltac t := t';
repeat match goal with
| _ => reflexivity
| _ => apply Identity; assumption
| [ H : appcontext[eq_dec ?a ?b] |- _ ] => destruct (eq_dec a b); t'
| [ |- appcontext[eq_dec ?a ?b] ] => destruct (eq_dec a b); t'
| [ H : _ |- _ ] => specialize (H (eq_refl _)); t'
| [ H : False |- _ ] => destruct H
| [ H : Empty_set |- _ ] => destruct H
| [ H : unit |- _ ] => destruct H
| [ |- _ = _ ] => progress (repeat rewrite RightIdentity; repeat rewrite LeftIdentity; repeat rewrite Associativity)
| [ H : ?a = ?a |- _ ] => pose proof (UIP_refl _ _ H); subst H
| [ H : _ |- _ ] => unique_pose (H eq_refl)
| [ H : Morphism _ _ _ |- _ ] => hnf in H
| [ H : _ = _ |- _ ] => case H; try clear H
end.
Definition InducedDiscreteFunctorDec_MorphismOf s d (m : Morphism (DiscreteCategoryDec eq_dec) s d) :
Morphism O' (f s) (f d).
t.
Defined.
Hint Unfold InducedDiscreteFunctorDec_MorphismOf.
Hint Unfold DiscreteCategoryDec_Compose.
Hint Unfold eq_rect_r eq_rect eq_sym.
Local Arguments Compose {obj} [C s d d'] / _ _ : rename, simpl nomatch.
Definition InducedDiscreteFunctorDec : SpecializedFunctor (DiscreteCategoryDec eq_dec) O'.
match goal with
| [ |- SpecializedFunctor ?C ?D ] =>
refine (Build_SpecializedFunctor C D
f
InducedDiscreteFunctorDec_MorphismOf
_
_
)
end;
t.
Defined.
End InducedFunctor.
Local Ltac destruct_eq_dec eq_dec a b :=
match type of eq_dec with
| forall x y : _, {x = y} + {x <> y} => destruct (eq_dec a b)
| forall x y : _, {x = y} + {x = y -> False} => destruct (eq_dec a b)
end;
repeat subst; trivial; intros.
Local Ltac t_dec := repeat (intros; simpl in *; autounfold with core in *; simpl in *; trivial;
match goal with
| [ |- _ = _ ] => apply functional_extensionality_dep; intro
| _ => progress functor_eq
| [ H0 : appcontext[?H ?a ?b] |- _ ] => revert H0; destruct_eq_dec H a b
| [ |- appcontext[?H ?a ?b] ] => destruct_eq_dec H a b
| _ => progress (unfold Morphism, Object, InducedDiscreteFunctorDec_MorphismOf in *)
| _ => progress destruct_sig
| [ H : unit |- _ ] => destruct H
| [ H : ?a = ?a, eq_dec : _ |- _ ] => pose proof (eq_proofs_unicity (eq_dec_prop eq_dec) H eq_refl); subst H
| [ H : _ |- _ ] => unique_pose (H eq_refl)
| _ => progress destruct_to_empty_set
| [ H0 : appcontext[?H ?a ?b] |- appcontext[?H ?a ?b] ] => revert H0; destruct_eq_dec H a b
| [ H : ?a = ?b |- _ ] => pose proof H; first [ subst a | subst b ]
end
).
Section disc.
Hint Unfold DiscreteCategoryDec_Identity.
Hint Unfold eq_rect_r eq_rect eq_sym.
Definition DiscreteFunctorDec : SpecializedFunctor TypeCatDec LocallySmallCatDec.
refine (Build_SpecializedFunctor TypeCatDec LocallySmallCatDec
(fun O => existT
(fun C : LocallySmallCategory => forall x y : C, {x = y} + {x <> y})
(DiscreteCategoryDec (projT2 O) : LocallySmallSpecializedCategory _)
(fun x y => projT2 O x y))
(fun s d f => InducedDiscreteFunctorDec _ f (projT2 s))
_
_
);
t_dec.
match goal with
| [ H : if ?eq_dec ?a ?b then unit else Empty_set |- _ ] => cut (JMeq H tt); [ intro | destruct_eq_dec eq_dec a b ]
end.
apply JMeq_eq.
symmetry.
(*
Require Import Setoid.
etransitivity; [ apply H | clear H ].
compute.
assert (JMeq match
s x0 x0 as s0 return (if s0 then unit else Empty_set)
with
| left _ => tt
| right n => match n eq_refl return Empty_set with
end
end tt).
destruct (s x0 x0); trivial.
change ((match
s x x0 as s0
return
((if s0 then unit else Empty_set) ->
if s x x0 then unit else Empty_set)
with
| left e =>
fun _ : unit =>
match
match e in (_ = y) return (y = x) with
| eq_refl => eq_refl
end in (_ = y) return (if s y x0 then unit else Empty_set)
with
| eq_refl =>
match
s x0 x0 as s0 return (if s0 then unit else Empty_set)
with
| left _ => tt
| right n => match n eq_refl return Empty_set with
end
end
end
| right _ =>
fun m : Empty_set =>
match m return (if s x x0 then unit else Empty_set) with
end
end x1)) with ((match
s x x0 as s0
return
((if s0 then unit else Empty_set) ->
if s x x0 then unit else Empty_set)
with
| left e =>
fun _ : unit =>
match
match e in (_ = y) return (y = x) with
| eq_refl => eq_refl
end in (_ = y) return (if s y x0 then unit else Empty_set)
with
| eq_refl =>
match
s x0 x0 as s0 return (if s0 then unit else Empty_set)
with
| left _ => tt
| right n => match n eq_refl return Empty_set with
end
end
end
| right _ =>
fun m : Empty_set =>
match m return (if s x x0 then unit else Empty_set) with
end
end x1)). *)
admit.
Defined.
Definition DiscreteSetFunctorDec : SpecializedFunctor SetCatDec SmallCatDec.
refine (Build_SpecializedFunctor SetCatDec SmallCatDec
(fun O => existT
(fun C : SmallCategory => forall x y : C, {x = y} + {x <> y})
(DiscreteCategoryDec (projT2 O) : SmallSpecializedCategory _)
(fun x y => projT2 O x y))
(fun s d f => InducedDiscreteFunctorDec _ f (projT2 s))
_
_
);
admit.
Defined.
End disc.
Section Adjoints.
Local Ltac t :=
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.
Lemma DiscreteObjectIdentityDec : ComposeFunctors ObjectFunctorDec DiscreteFunctorDec = IdentityFunctor _.
functor_eq; simpl_eq; reflexivity.
Qed.
Definition DiscreteObjectAdjunction : HomAdjunction DiscreteFunctorDec ObjectFunctorDec.
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 => (InducedDiscreteFunctorDec _ f (projT2 A)));
t.
admit.
Defined.
End Adjoints.