Debian Codegraph @

test-suite/bugs/bug_4116.v

raw
1 (* File reduced by coq-bug-finder from original input, then from 13191 lines to 1315 lines, then from 1601 lines to 595 lines, then from 585 lines to 379 lines *)
2 (* coqc version 8.5beta1 (March 2015) compiled on Mar 3 2015 3:50:31 with OCaml 4.01.0
3 coqtop version cagnode15:/afs/csail.mit.edu/u/j/jgross/coq-8.5,v8.5 (ac62cda8a4f488b94033b108c37556877232137a) *)
4
5 Axiom admit : False.
6 Ltac admit := exfalso; exact admit.
7
8 Global Set Primitive Projections.
9
10 Notation projT1 := proj1_sig (only parsing).
11 Notation projT2 := proj2_sig (only parsing).
12
13 Definition relation (A : Type) := A -> A -> Type.
14
15 Class Reflexive {A} (R : relation A) :=
16 reflexivity : forall x : A, R x x.
17
18 Class Symmetric {A} (R : relation A) :=
19 symmetry : forall x y, R x y -> R y x.
20
21 Notation idmap := (fun x => x).
22 Delimit Scope function_scope with function.
23 Delimit Scope path_scope with path.
24 Delimit Scope fibration_scope with fibration.
25 Open Scope path_scope.
26 Open Scope fibration_scope.
27 Open Scope function_scope.
28
29 Notation pr1 := projT1.
30 Notation pr2 := projT2.
31
32 Notation "x .1" := (pr1 x) : fibration_scope.
33 Notation "x .2" := (pr2 x) : fibration_scope.
34
35 Notation compose := (fun g f x => g (f x)).
36
37 Notation "g 'o' f" := (compose g%function f%function) (at level 40, left associativity) : function_scope.
38
39 Inductive paths {A : Type} (a : A) : A -> Prop :=
40 idpath : paths a a.
41
42 Arguments idpath {A a} , [A] a.
43
44 Notation "x = y :> A" := (@paths A x y) : type_scope.
45 Notation "x = y" := (x = y :>_) : type_scope.
46
47 Scheme Rewriting for paths.
48
49 Definition inverse {A : Type} {x y : A} (p : x = y) : y = x
50 := match p with idpath => idpath end.
51
52 Global Instance symmetric_paths {A} : Symmetric (@paths A) | 0 := @inverse A.
53
54 Definition concat {A : Type} {x y z : A} (p : x = y) (q : y = z) : x = z :=
55 match p, q with idpath, idpath => idpath end.
56
57 Notation "1" := idpath : path_scope.
58
59 Notation "p @ q" := (concat p%path q%path) (at level 20, left associativity) : path_scope.
60
61 Notation "p ^" := (inverse p%path) (at level 3, format "p '^'") : path_scope.
62
63 Definition transport {A : Type} (P : A -> Type) {x y : A} (p : x = y) (u : P x) : P y :=
64 match p with idpath => u end.
65
66 Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
67 := match p with idpath => idpath end.
68
69 Definition pointwise_paths {A} {P:A->Type} (f g:forall x:A, P x)
70 := forall x:A, f x = g x.
71
72 Notation "f == g" := (pointwise_paths f g) (at level 70, no associativity) : type_scope.
73
74 Definition apD10 {A} {B:A->Type} {f g : forall x, B x} (h:f=g)
75 : f == g
76 := fun x => match h with idpath => 1 end.
77
78 Definition Sect {A B : Type} (s : A -> B) (r : B -> A) :=
79 forall x : A, r (s x) = x.
80
81 Class IsEquiv {A B : Type} (f : A -> B) := BuildIsEquiv {
82 equiv_inv : B -> A ;
83 eisretr : Sect equiv_inv f;
84 eissect : Sect f equiv_inv;
85 eisadj : forall x : A, eisretr (f x) = ap f (eissect x)
86 }.
87
88 Notation "f ^-1" := (@equiv_inv _ _ f _) (at level 3, format "f '^-1'") : function_scope.
89
90 Class Contr_internal (A : Type) := BuildContr {
91 center : A ;
92 contr : (forall y : A, center = y)
93 }.
94
95 Inductive trunc_index : Type :=
96 | minus_two : trunc_index
97 | trunc_S : trunc_index -> trunc_index.
98
99 Notation "n .+1" := (trunc_S n) (at level 2, left associativity, format "n .+1") : trunc_scope.
100 Local Open Scope trunc_scope.
101 Notation "-2" := minus_two (at level 0) : trunc_scope.
102 Notation "-1" := (-2.+1) (at level 0) : trunc_scope.
103 Notation "0" := (-1.+1) : trunc_scope.
104
105 Fixpoint IsTrunc_internal (n : trunc_index) (A : Type) : Type :=
106 match n with
107 | -2 => Contr_internal A
108 | n'.+1 => forall (x y : A), IsTrunc_internal n' (x = y)
109 end.
110
111 Class IsTrunc (n : trunc_index) (A : Type) : Type :=
112 Trunc_is_trunc : IsTrunc_internal n A.
113
114 Tactic Notation "transparent" "assert" "(" ident(name) ":" constr(type) ")" :=
115 unshelve refine (let __transparent_assert_hypothesis := (_ : type) in _);
116 [
117 | (
118 let H := match goal with H := _ |- _ => constr:(H) end in
119 rename H into name) ].
120
121 Definition transport_idmap_ap A (P : A -> Type) x y (p : x = y) (u : P x)
122 : transport P p u = transport idmap (ap P p) u
123 := match p with idpath => idpath end.
124
125 Section Adjointify.
126
127 Context {A B : Type} (f : A -> B) (g : B -> A).
128 Context (isretr : Sect g f) (issect : Sect f g).
129
130 Let issect' := fun x =>
131 ap g (ap f (issect x)^) @ ap g (isretr (f x)) @ issect x.
132
133 Let is_adjoint' (a : A) : isretr (f a) = ap f (issect' a).
134 admit.
135 Defined.
136
137 Definition isequiv_adjointify : IsEquiv f
138 := BuildIsEquiv A B f g isretr issect' is_adjoint'.
139
140 End Adjointify.
141
142 Record TruncType (n : trunc_index) := BuildTruncType {
143 trunctype_type : Type ;
144 istrunc_trunctype_type : IsTrunc n trunctype_type
145 }.
146 Arguments trunctype_type {_} _.
147
148 Coercion trunctype_type : TruncType >-> Sortclass.
149
150 Notation "n -Type" := (TruncType n) (at level 1) : type_scope.
151 Notation hSet := 0-Type.
152
153 Module Export Category.
154 Module Export Core.
155 Set Implicit Arguments.
156
157 Delimit Scope morphism_scope with morphism.
158 Delimit Scope category_scope with category.
159 Delimit Scope object_scope with object.
160
161 Record PreCategory :=
162 Build_PreCategory' {
163 object :> Type;
164 morphism : object -> object -> Type;
165
166 identity : forall x, morphism x x;
167 compose : forall s d d',
168 morphism d d'
169 -> morphism s d
170 -> morphism s d'
171 where "f 'o' g" := (compose f g);
172
173 associativity : forall x1 x2 x3 x4
174 (m1 : morphism x1 x2)
175 (m2 : morphism x2 x3)
176 (m3 : morphism x3 x4),
177 (m3 o m2) o m1 = m3 o (m2 o m1);
178
179 associativity_sym : forall x1 x2 x3 x4
180 (m1 : morphism x1 x2)
181 (m2 : morphism x2 x3)
182 (m3 : morphism x3 x4),
183 m3 o (m2 o m1) = (m3 o m2) o m1;
184
185 left_identity : forall a b (f : morphism a b), identity b o f = f;
186 right_identity : forall a b (f : morphism a b), f o identity a = f;
187
188 identity_identity : forall x, identity x o identity x = identity x
189 }.
190 Arguments identity {!C%_category} / x%_object : rename.
191 Arguments compose {!C%_category} / {s d d'}%_object (m1 m2)%_morphism : rename.
192
193 Definition Build_PreCategory
194 object morphism compose identity
195 associativity left_identity right_identity
196 := @Build_PreCategory'
197 object
198 morphism
199 compose
200 identity
201 associativity
202 (fun _ _ _ _ _ _ _ => symmetry _ _ (associativity _ _ _ _ _ _ _))
203 left_identity
204 right_identity
205 (fun _ => left_identity _ _ _).
206
207 Module Export CategoryCoreNotations.
208 Infix "o" := compose : morphism_scope.
209 Notation "1" := (identity _) : morphism_scope.
210 End CategoryCoreNotations.
211
212 End Core.
213
214 End Category.
215 Module Export Core.
216 Set Implicit Arguments.
217
218 Delimit Scope functor_scope with functor.
219
220 Local Open Scope morphism_scope.
221
222 Section Functor.
223 Variables C D : PreCategory.
224
225 Record Functor :=
226 {
227 object_of :> C -> D;
228 morphism_of : forall s d, morphism C s d
229 -> morphism D (object_of s) (object_of d);
230 composition_of : forall s d d'
231 (m1 : morphism C s d) (m2: morphism C d d'),
232 morphism_of _ _ (m2 o m1)
233 = (morphism_of _ _ m2) o (morphism_of _ _ m1);
234 identity_of : forall x, morphism_of _ _ (identity x)
235 = identity (object_of x)
236 }.
237 End Functor.
238 Arguments morphism_of [C%_category] [D%_category] F%_functor [s%_object d%_object] m%_morphism : rename, simpl nomatch.
239
240 End Core.
241 Module Export Morphisms.
242 Set Implicit Arguments.
243
244 Local Open Scope category_scope.
245 Local Open Scope morphism_scope.
246
247 Class IsIsomorphism {C : PreCategory} {s d} (m : morphism C s d) :=
248 {
249 morphism_inverse : morphism C d s;
250 left_inverse : morphism_inverse o m = identity _;
251 right_inverse : m o morphism_inverse = identity _
252 }.
253
254 Class Isomorphic {C : PreCategory} s d :=
255 {
256 morphism_isomorphic :: morphism C s d;
257 isisomorphism_isomorphic :: IsIsomorphism morphism_isomorphic
258 }.
259
260 Coercion morphism_isomorphic : Isomorphic >-> morphism.
261
262 Local Infix "<~=~>" := Isomorphic (at level 70, no associativity) : category_scope.
263
264 Section iso_equiv_relation.
265 Variable C : PreCategory.
266
267 Global Instance isisomorphism_identity (x : C) : IsIsomorphism (identity x)
268 := {| morphism_inverse := identity x;
269 left_inverse := left_identity C x x (identity x);
270 right_inverse := right_identity C x x (identity x) |}.
271
272 Global Instance isomorphic_refl : Reflexive (@Isomorphic C)
273 := fun x : C => {| morphism_isomorphic := identity x |}.
274
275 Definition idtoiso (x y : C) (H : x = y) : Isomorphic x y
276 := match H in (_ = y0) return (x <~=~> y0) with
277 | 1%path => reflexivity x
278 end.
279 End iso_equiv_relation.
280
281 End Morphisms.
282
283 Notation IsCategory C := (forall s d : object C, IsEquiv (@idtoiso C s d)).
284
285 Notation isotoid C s d := (@equiv_inv _ _ (@idtoiso C s d) _).
286
287 Notation cat_of obj :=
288 (@Build_PreCategory obj
289 (fun x y => x -> y)
290 (fun _ x => x)
291 (fun _ _ _ f g => f o g)%core
292 (fun _ _ _ _ _ _ _ => idpath)
293 (fun _ _ _ => idpath)
294 (fun _ _ _ => idpath)
295 ).
296 Definition set_cat : PreCategory := cat_of hSet.
297 Set Implicit Arguments.
298
299 Local Open Scope morphism_scope.
300
301 Section Grothendieck.
302 Variable C : PreCategory.
303 Variable F : Functor C set_cat.
304
305 Record Pair :=
306 {
307 c : C;
308 x : F c
309 }.
310
311 Local Notation Gmorphism s d :=
312 { f : morphism C s.(c) d.(c)
313 | morphism_of F f s.(x) = d.(x) }.
314
315 Definition identity_H s
316 := apD10 (identity_of F s.(c)) s.(x).
317
318 Definition Gidentity s : Gmorphism s s.
319 Proof.
320 exists 1.
321 apply identity_H.
322 Defined.
323
324 Definition Gcategory : PreCategory.
325 Proof.
326 unshelve refine (@Build_PreCategory
327 Pair
328 (fun s d => Gmorphism s d)
329 Gidentity
330 _
331 _
332 _
333 _); admit.
334 Defined.
335 End Grothendieck.
336
337 Lemma isotoid_1 {C} `{IsCategory C} {x : C} {H : IsIsomorphism (identity x)}
338 : isotoid C x x {| morphism_isomorphic := (identity x) ; isisomorphism_isomorphic := H |}
339 = idpath.
340 admit.
341 Defined.
342 Generalizable All Variables.
343
344 Section Grothendieck2.
345 Context `{IsCategory C}.
346 Variable F : Functor C set_cat.
347
348 Instance iscategory_grothendieck_toset : IsCategory (Gcategory F).
349 Proof.
350 intros s d.
351 unshelve refine (isequiv_adjointify _ _ _ _).
352 {
353 intro m.
354 transparent assert (H' : (s.(c) = d.(c))).
355 {
356 apply ((idtoiso C (x := s.(c)) (y := d.(c)))^-1)%function.
357 exists (m : morphism _ _ _).1.
358 admit.
359
360 }
361 {
362 transitivity {| x := transport (fun x => F x) H' s.(x) |}.
363 admit.
364
365 {
366 change d with {| c := d.(c) ; x := d.(x) |}; simpl.
367 apply ap.
368 subst H'.
369 simpl.
370 refine (transport_idmap_ap _ (fun x => F x : Type) _ _ _ _ @ _ @ (m : morphism _ _ _).2).
371 change (fun x => F x : Type) with (trunctype_type o object_of F)%function.
372 admit.
373 }
374 }
375 }
376 {
377 admit.
378 }
379
380 {
381 intro x.
382 hnf in s, d.
383 destruct x.
384 simpl.
385 erewrite @isotoid_1.
386 Abort.
387 End Grothendieck2.