Debian Codegraph @

test-suite/bugs/bug_4544.v

raw
1 (* -*- mode: coq; coq-prog-args: ("-nois" "-indices-matter") -*- *)
2 (* File reduced by coq-bug-finder from original input, then from 2553 lines to 1932 lines, then from 1946 lines to 1932 lines, then from 2467 lines to 1002 lines, then from 1016 lines to 1002 lines *)
3 (* coqc version 8.5 (January 2016) compiled on Jan 23 2016 16:15:22 with OCaml 4.01.0
4 coqtop version 8.5 (January 2016) *)
5 Require Import Corelib.Init.Ltac.
6 Inductive False := .
7 Axiom proof_admitted : False.
8 Tactic Notation "admit" := case proof_admitted.
9 Require Corelib.Init.Datatypes.
10
11 Import Corelib.Init.Notations.
12
13 Global Set Universe Polymorphism.
14
15 Notation "A -> B" := (forall (_ : A), B) : type_scope.
16 Global Set Primitive Projections.
17
18 Inductive sum (A B : Type) : Type :=
19 | inl : A -> sum A B
20 | inr : B -> sum A B.
21 Notation nat := Corelib.Init.Datatypes.nat.
22 Notation O := Corelib.Init.Datatypes.O.
23 Notation S := Corelib.Init.Datatypes.S.
24 Notation "x + y" := (sum x y) : type_scope.
25
26 Record prod (A B : Type) := pair { fst : A ; snd : B }.
27
28 Notation "x * y" := (prod x y) : type_scope.
29 Module Export Specif.
30
31 Set Implicit Arguments.
32
33 Record sig {A} (P : A -> Type) := exist { proj1_sig : A ; proj2_sig : P proj1_sig }.
34 Arguments proj1_sig {A P} _ / .
35
36 Notation sigT := sig (only parsing).
37 Notation existT := exist (only parsing).
38
39 Notation "{ x : A & P }" := (sigT (fun x:A => P)) : type_scope.
40
41 Notation projT1 := proj1_sig (only parsing).
42 Notation projT2 := proj2_sig (only parsing).
43
44 End Specif.
45 Module Export HoTT_DOT_Basics_DOT_Overture.
46 Module Export HoTT.
47 Module Export Basics.
48 Module Export Overture.
49
50 Global Set Keyed Unification.
51
52 Global Unset Strict Universe Declaration.
53
54 Notation Type0 := Set.
55
56 Definition Type1@{i} := Eval hnf in let gt := (Set : Type@{i}) in Type@{i}.
57
58 Definition Type2@{i j} := Eval hnf in let gt := (Type1@{j} : Type@{i}) in Type@{i}.
59
60 Definition Type2le@{i j} := Eval hnf in let gt := (Set : Type@{i}) in
61 let ge := ((fun x => x) : Type1@{j} -> Type@{i}) in Type@{i}.
62
63 Notation idmap := (fun x => x).
64 Delimit Scope function_scope with function.
65 Delimit Scope path_scope with path.
66 Delimit Scope fibration_scope with fibration.
67 Delimit Scope trunc_scope with trunc.
68
69 Open Scope trunc_scope.
70 Open Scope path_scope.
71 Open Scope fibration_scope.
72 Open Scope nat_scope.
73 Open Scope function_scope.
74
75 Notation "( x ; y )" := (existT _ x y) : fibration_scope.
76
77 Notation pr1 := projT1.
78 Notation pr2 := projT2.
79
80 Notation "x .1" := (pr1 x) : fibration_scope.
81 Notation "x .2" := (pr2 x) : fibration_scope.
82
83 Notation compose := (fun g f x => g (f x)).
84
85 Notation "g 'o' f" := (compose g%function f%function) (at level 40, left associativity) : function_scope.
86
87 Inductive paths {A : Type} (a : A) : A -> Type :=
88 idpath : paths a a.
89
90 Arguments idpath {A a} , [A] a.
91
92 Notation "x = y :> A" := (@paths A x y) : type_scope.
93 Notation "x = y" := (x = y :>_) : type_scope.
94
95 Scheme Rewriting for paths.
96
97 Definition inverse {A : Type} {x y : A} (p : x = y) : y = x
98 := match p with idpath => idpath end.
99
100 Definition concat {A : Type} {x y z : A} (p : x = y) (q : y = z) : x = z :=
101 match p, q with idpath, idpath => idpath end.
102
103 Notation "1" := idpath : path_scope.
104
105 Notation "p @ q" := (concat p%path q%path) (at level 20, left associativity) : path_scope.
106
107 Notation "p ^" := (inverse p%path) (at level 3, format "p '^'") : path_scope.
108
109 Definition transport {A : Type} (P : A -> Type) {x y : A} (p : x = y) (u : P x) : P y :=
110 match p with idpath => u end.
111
112 Notation "p # x" := (transport _ p x) (right associativity, at level 65, only parsing) : path_scope.
113
114 Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
115 := match p with idpath => idpath end.
116
117 Definition pointwise_paths {A} {P:A->Type} (f g:forall x:A, P x)
118 := forall x:A, f x = g x.
119
120 Notation "f == g" := (pointwise_paths f g) (at level 70, no associativity) : type_scope.
121
122 Definition Sect {A B : Type} (s : A -> B) (r : B -> A) :=
123 forall x : A, r (s x) = x.
124
125 Class IsEquiv {A B : Type} (f : A -> B) := BuildIsEquiv {
126 equiv_inv : B -> A ;
127 eisretr : Sect equiv_inv f;
128 eissect : Sect f equiv_inv;
129 eisadj : forall x : A, eisretr (f x) = ap f (eissect x)
130 }.
131
132 Arguments eisretr {A B}%_type_scope f%_function_scope {_} _.
133
134 Record Equiv A B := BuildEquiv {
135 equiv_fun : A -> B ;
136 equiv_isequiv : IsEquiv equiv_fun
137 }.
138
139 Coercion equiv_fun : Equiv >-> Funclass.
140
141 Create HintDb typeclass_instances discriminated.
142
143 Global Existing Instance equiv_isequiv.
144
145 Notation "A <~> B" := (Equiv A B) (at level 85) : type_scope.
146
147 Notation "f ^-1" := (@equiv_inv _ _ f _) (at level 3, format "f '^-1'") : function_scope.
148
149 Class Contr_internal (A : Type) := BuildContr {
150 center : A ;
151 contr : (forall y : A, center = y)
152 }.
153
154 Arguments center A {_}.
155
156 Inductive trunc_index : Type :=
157 | minus_two : trunc_index
158 | trunc_S : trunc_index -> trunc_index.
159
160 Notation "n .+1" := (trunc_S n) (at level 2, left associativity, format "n .+1") : trunc_scope.
161 Notation "-2" := minus_two (at level 0) : trunc_scope.
162 Notation "-1" := (-2.+1) (at level 0) : trunc_scope.
163 Notation "0" := (-1.+1) : trunc_scope.
164
165 Fixpoint IsTrunc_internal (n : trunc_index) (A : Type) : Type :=
166 match n with
167 | -2 => Contr_internal A
168 | n'.+1 => forall (x y : A), IsTrunc_internal n' (x = y)
169 end.
170
171 Class IsTrunc (n : trunc_index) (A : Type) : Type :=
172 Trunc_is_trunc : IsTrunc_internal n A.
173
174 Global Instance istrunc_paths (A : Type) n `{H : IsTrunc n.+1 A} (x y : A)
175 : IsTrunc n (x = y)
176 := H x y.
177
178 Notation Contr := (IsTrunc -2).
179 Notation IsHProp := (IsTrunc -1).
180
181 #[global] Hint Extern 0 => progress change Contr_internal with Contr in * : typeclass_instances.
182
183 Monomorphic Axiom dummy_funext_type : Type0.
184 Monomorphic Class Funext := { dummy_funext_value : dummy_funext_type }.
185
186 Inductive Unit : Type1 :=
187 tt : Unit.
188
189 Class IsPointed (A : Type) := point : A.
190
191 Arguments point A {_}.
192
193 Record pType :=
194 { pointed_type : Type ;
195 ispointed_type : IsPointed pointed_type }.
196
197 Coercion pointed_type : pType >-> Sortclass.
198
199 Global Existing Instance ispointed_type.
200
201 Definition hfiber {A B : Type} (f : A -> B) (y : B) := { x : A & f x = y }.
202
203 Ltac revert_opaque x :=
204 revert x;
205 match goal with
206 | [ |- forall _, _ ] => idtac
207 | _ => fail 1 "Reverted constant is not an opaque variable"
208 end.
209
210 End Overture.
211
212 End Basics.
213
214 End HoTT.
215
216 End HoTT_DOT_Basics_DOT_Overture.
217 Module Export HoTT_DOT_Basics_DOT_PathGroupoids.
218 Module Export HoTT.
219 Module Export Basics.
220 Module Export PathGroupoids.
221
222 Local Open Scope path_scope.
223
224 Definition concat_p1 {A : Type} {x y : A} (p : x = y) :
225 p @ 1 = p
226 :=
227 match p with idpath => 1 end.
228
229 Definition concat_1p {A : Type} {x y : A} (p : x = y) :
230 1 @ p = p
231 :=
232 match p with idpath => 1 end.
233
234 Definition concat_p_pp {A : Type} {x y z t : A} (p : x = y) (q : y = z) (r : z = t) :
235 p @ (q @ r) = (p @ q) @ r :=
236 match r with idpath =>
237 match q with idpath =>
238 match p with idpath => 1
239 end end end.
240
241 Definition concat_pp_p {A : Type} {x y z t : A} (p : x = y) (q : y = z) (r : z = t) :
242 (p @ q) @ r = p @ (q @ r) :=
243 match r with idpath =>
244 match q with idpath =>
245 match p with idpath => 1
246 end end end.
247
248 Definition concat_pV {A : Type} {x y : A} (p : x = y) :
249 p @ p^ = 1
250 :=
251 match p with idpath => 1 end.
252
253 Definition moveR_Vp {A : Type} {x y z : A} (p : x = z) (q : y = z) (r : x = y) :
254 p = r @ q -> r^ @ p = q.
255 admit.
256 Defined.
257
258 Definition moveL_Vp {A : Type} {x y z : A} (p : x = z) (q : y = z) (r : x = y) :
259 r @ q = p -> q = r^ @ p.
260 admit.
261 Defined.
262
263 Definition moveR_M1 {A : Type} {x y : A} (p q : x = y) :
264 1 = p^ @ q -> p = q.
265 admit.
266 Defined.
267
268 Definition ap_pp {A B : Type} (f : A -> B) {x y z : A} (p : x = y) (q : y = z) :
269 ap f (p @ q) = (ap f p) @ (ap f q)
270 :=
271 match q with
272 idpath =>
273 match p with idpath => 1 end
274 end.
275
276 Definition ap_V {A B : Type} (f : A -> B) {x y : A} (p : x = y) :
277 ap f (p^) = (ap f p)^
278 :=
279 match p with idpath => 1 end.
280
281 Definition ap_compose {A B C : Type} (f : A -> B) (g : B -> C) {x y : A} (p : x = y) :
282 ap (g o f) p = ap g (ap f p)
283 :=
284 match p with idpath => 1 end.
285
286 Definition concat_pA1 {A : Type} {f : A -> A} (p : forall x, x = f x) {x y : A} (q : x = y) :
287 (p x) @ (ap f q) = q @ (p y)
288 :=
289 match q as i in (_ = y) return (p x @ ap f i = i @ p y) with
290 | idpath => concat_p1 _ @ (concat_1p _)^
291 end.
292
293 End PathGroupoids.
294
295 End Basics.
296
297 End HoTT.
298
299 End HoTT_DOT_Basics_DOT_PathGroupoids.
300 Module Export HoTT_DOT_Basics_DOT_Equivalences.
301 Module Export HoTT.
302 Module Export Basics.
303 Module Export Equivalences.
304
305 Definition isequiv_commsq {A B C D}
306 (f : A -> B) (g : C -> D) (h : A -> C) (k : B -> D)
307 (p : k o f == g o h)
308 `{IsEquiv _ _ f} `{IsEquiv _ _ h} `{IsEquiv _ _ k}
309 : IsEquiv g.
310 admit.
311 Defined.
312
313 Section Adjointify.
314
315 Context {A B : Type} (f : A -> B) (g : B -> A).
316 Context (isretr : Sect g f) (issect : Sect f g).
317
318 Let issect' := fun x =>
319 ap g (ap f (issect x)^) @ ap g (isretr (f x)) @ issect x.
320
321 Let is_adjoint' (a : A) : isretr (f a) = ap f (issect' a).
322 Proof.
323 unfold issect'.
324 apply moveR_M1.
325 repeat rewrite ap_pp, concat_p_pp; rewrite <- ap_compose.
326 rewrite (concat_pA1 (fun b => (isretr b)^) (ap f (issect a)^)).
327 repeat rewrite concat_pp_p; rewrite ap_V; apply moveL_Vp; rewrite concat_p1.
328 rewrite concat_p_pp, <- ap_compose.
329 rewrite (concat_pA1 (fun b => (isretr b)^) (isretr (f a))).
330 rewrite concat_pV, concat_1p; reflexivity.
331 Qed.
332
333 Definition isequiv_adjointify : IsEquiv f
334 := BuildIsEquiv A B f g isretr issect' is_adjoint'.
335
336 End Adjointify.
337
338 End Equivalences.
339
340 End Basics.
341
342 End HoTT.
343
344 End HoTT_DOT_Basics_DOT_Equivalences.
345 Module Export HoTT_DOT_Basics_DOT_Trunc.
346 Module Export HoTT.
347 Module Export Basics.
348 Module Export Trunc.
349 Generalizable Variables A B m n f.
350
351 Definition trunc_equiv A {B} (f : A -> B)
352 `{IsTrunc n A} `{IsEquiv A B f}
353 : IsTrunc n B.
354 admit.
355 Defined.
356
357 Record TruncType (n : trunc_index) := BuildTruncType {
358 trunctype_type : Type ;
359 istrunc_trunctype_type : IsTrunc n trunctype_type
360 }.
361
362 Arguments BuildTruncType _ _ {_}.
363
364 Coercion trunctype_type : TruncType >-> Sortclass.
365
366 Notation "n -Type" := (TruncType n) (at level 1) : type_scope.
367 Notation hProp := (-1)-Type.
368
369 Notation BuildhProp := (BuildTruncType -1).
370
371 End Trunc.
372
373 End Basics.
374
375 End HoTT.
376
377 End HoTT_DOT_Basics_DOT_Trunc.
378 Module Export HoTT_DOT_Types_DOT_Unit.
379 Module Export HoTT.
380 Module Export Types.
381 Module Export Unit.
382
383 Notation unit_name x := (fun (_ : Unit) => x).
384
385 End Unit.
386
387 End Types.
388
389 End HoTT.
390
391 End HoTT_DOT_Types_DOT_Unit.
392 Module Export HoTT_DOT_Types_DOT_Sigma.
393 Module Export HoTT.
394 Module Export Types.
395 Module Export Sigma.
396 Local Open Scope path_scope.
397
398 Definition path_sigma_uncurried {A : Type} (P : A -> Type) (u v : sigT P)
399 (pq : {p : u.1 = v.1 & p # u.2 = v.2})
400 : u = v
401 := match pq.2 in (_ = v2) return u = (v.1; v2) with
402 | 1 => match pq.1 as p in (_ = v1) return u = (v1; p # u.2) with
403 | 1 => 1
404 end
405 end.
406
407 Definition path_sigma {A : Type} (P : A -> Type) (u v : sigT P)
408 (p : u.1 = v.1) (q : p # u.2 = v.2)
409 : u = v
410 := path_sigma_uncurried P u v (p;q).
411
412 Definition path_sigma' {A : Type} (P : A -> Type) {x x' : A} {y : P x} {y' : P x'}
413 (p : x = x') (q : p # y = y')
414 : (x;y) = (x';y')
415 := path_sigma P (x;y) (x';y') p q.
416
417 Global Instance isequiv_pr1_contr {A} {P : A -> Type}
418 `{forall a, Contr (P a)}
419 : IsEquiv (@pr1 A P) | 100.
420 Proof.
421 refine (isequiv_adjointify (@pr1 A P)
422 (fun a => (a ; center (P a))) _ _).
423 -
424 intros a; reflexivity.
425 -
426 intros [a p].
427 refine (path_sigma' P 1 (contr _)).
428 Defined.
429
430 Definition path_sigma_hprop {A : Type} {P : A -> Type}
431 `{forall x, IsHProp (P x)}
432 (u v : sigT P)
433 : u.1 = v.1 -> u = v
434 := path_sigma_uncurried P u v o pr1^-1.
435
436 End Sigma.
437
438 End Types.
439
440 End HoTT.
441
442 End HoTT_DOT_Types_DOT_Sigma.
443 Module Export HoTT_DOT_Extensions.
444 Module Export HoTT.
445 Module Export Extensions.
446
447 Section Extensions.
448
449 Definition ExtensionAlong {A B : Type} (f : A -> B)
450 (P : B -> Type) (d : forall x:A, P (f x))
451 := { s : forall y:B, P y & forall x:A, s (f x) = d x }.
452
453 Fixpoint ExtendableAlong@{i j k l}
454 (n : nat) {A : Type@{i}} {B : Type@{j}}
455 (f : A -> B) (C : B -> Type@{k}) : Type@{l}
456 := match n with
457 | O => Unit@{l}
458 | S n => (forall (g : forall a, C (f a)),
459 ExtensionAlong@{i j k l l} f C g) *
460 forall (h k : forall b, C b),
461 ExtendableAlong n f (fun b => h b = k b)
462 end.
463
464 Definition ooExtendableAlong@{i j k l}
465 {A : Type@{i}} {B : Type@{j}}
466 (f : A -> B) (C : B -> Type@{k}) : Type@{l}
467 := forall n, ExtendableAlong@{i j k l} n f C.
468
469 End Extensions.
470
471 End Extensions.
472
473 End HoTT.
474
475 End HoTT_DOT_Extensions.
476 Module Export HoTT.
477 Module Export Modalities.
478 Module Export ReflectiveSubuniverse.
479
480 Module Type ReflectiveSubuniverses.
481
482 Parameter ReflectiveSubuniverse@{u a} : Type2@{u a}.
483
484 Parameter O_reflector@{u a i} : forall (O : ReflectiveSubuniverse@{u a}),
485 Type2le@{i a} -> Type2le@{i a}.
486
487 Parameter In@{u a i} : forall (O : ReflectiveSubuniverse@{u a}),
488 Type2le@{i a} -> Type2le@{i a}.
489
490 Parameter O_inO@{u a i} : forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}),
491 In@{u a i} O (O_reflector@{u a i} O T).
492
493 Parameter to@{u a i} : forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}),
494 T -> O_reflector@{u a i} O T.
495
496 Parameter inO_equiv_inO@{u a i j k} :
497 forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}) (U : Type@{j})
498 (T_inO : In@{u a i} O T) (f : T -> U) (feq : IsEquiv f),
499
500 let gei := ((fun x => x) : Type@{i} -> Type@{k}) in
501 let gej := ((fun x => x) : Type@{j} -> Type@{k}) in
502 In@{u a j} O U.
503
504 Parameter hprop_inO@{u a i}
505 : Funext -> forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}),
506 IsHProp (In@{u a i} O T).
507
508 Parameter extendable_to_O@{u a i j k}
509 : forall (O : ReflectiveSubuniverse@{u a}) {P : Type2le@{i a}} {Q : Type2le@{j a}} {Q_inO : In@{u a j} O Q},
510 ooExtendableAlong@{i i j k} (to O P) (fun _ => Q).
511
512 End ReflectiveSubuniverses.
513
514 Module ReflectiveSubuniverses_Theory (Os : ReflectiveSubuniverses).
515 Export Os.
516
517 Module Export Coercions.
518
519 Coercion O_reflector : ReflectiveSubuniverse >-> Funclass.
520
521 End Coercions.
522
523 End ReflectiveSubuniverses_Theory.
524
525 Module Type ReflectiveSubuniverses_Restriction_Data (Os : ReflectiveSubuniverses).
526
527 Parameter New_ReflectiveSubuniverse@{u a} : Type2@{u a}.
528
529 Parameter ReflectiveSubuniverses_restriction@{u a}
530 : New_ReflectiveSubuniverse@{u a} -> Os.ReflectiveSubuniverse@{u a}.
531
532 End ReflectiveSubuniverses_Restriction_Data.
533
534 Module ReflectiveSubuniverses_Restriction
535 (Os : ReflectiveSubuniverses)
536 (Res : ReflectiveSubuniverses_Restriction_Data Os)
537 <: ReflectiveSubuniverses.
538
539 Definition ReflectiveSubuniverse := Res.New_ReflectiveSubuniverse.
540
541 Definition O_reflector@{u a i} (O : ReflectiveSubuniverse@{u a})
542 := Os.O_reflector@{u a i} (Res.ReflectiveSubuniverses_restriction O).
543 Definition In@{u a i} (O : ReflectiveSubuniverse@{u a})
544 := Os.In@{u a i} (Res.ReflectiveSubuniverses_restriction O).
545 Definition O_inO@{u a i} (O : ReflectiveSubuniverse@{u a})
546 := Os.O_inO@{u a i} (Res.ReflectiveSubuniverses_restriction O).
547 Definition to@{u a i} (O : ReflectiveSubuniverse@{u a})
548 := Os.to@{u a i} (Res.ReflectiveSubuniverses_restriction O).
549 Definition inO_equiv_inO@{u a i j k} (O : ReflectiveSubuniverse@{u a})
550 := Os.inO_equiv_inO@{u a i j k} (Res.ReflectiveSubuniverses_restriction O).
551 Definition hprop_inO@{u a i} (H : Funext) (O : ReflectiveSubuniverse@{u a})
552 := Os.hprop_inO@{u a i} H (Res.ReflectiveSubuniverses_restriction O).
553 Definition extendable_to_O@{u a i j k} (O : ReflectiveSubuniverse@{u a})
554 := @Os.extendable_to_O@{u a i j k} (Res.ReflectiveSubuniverses_restriction@{u a} O).
555
556 End ReflectiveSubuniverses_Restriction.
557
558 Module ReflectiveSubuniverses_FamUnion
559 (Os1 Os2 : ReflectiveSubuniverses)
560 <: ReflectiveSubuniverses.
561
562 Definition ReflectiveSubuniverse@{u a} : Type2@{u a}
563 := Os1.ReflectiveSubuniverse@{u a} + Os2.ReflectiveSubuniverse@{u a}.
564
565 Definition O_reflector@{u a i} : forall (O : ReflectiveSubuniverse@{u a}),
566 Type2le@{i a} -> Type2le@{i a}.
567 admit.
568 Defined.
569
570 Definition In@{u a i} : forall (O : ReflectiveSubuniverse@{u a}),
571 Type2le@{i a} -> Type2le@{i a}.
572 Proof.
573 intros [O|O]; [ exact (Os1.In@{u a i} O)
574 | exact (Os2.In@{u a i} O) ].
575 Defined.
576
577 Definition O_inO@{u a i}
578 : forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}),
579 In@{u a i} O (O_reflector@{u a i} O T).
580 admit.
581 Defined.
582
583 Definition to@{u a i} : forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}),
584 T -> O_reflector@{u a i} O T.
585 admit.
586 Defined.
587
588 Definition inO_equiv_inO@{u a i j k} :
589 forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}) (U : Type@{j})
590 (T_inO : In@{u a i} O T) (f : T -> U) (feq : IsEquiv f),
591 In@{u a j} O U.
592 Proof.
593 intros [O|O]; [ exact (Os1.inO_equiv_inO@{u a i j k} O)
594 | exact (Os2.inO_equiv_inO@{u a i j k} O) ].
595 Defined.
596
597 Definition hprop_inO@{u a i}
598 : Funext -> forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}),
599 IsHProp (In@{u a i} O T).
600 admit.
601 Defined.
602
603 Definition extendable_to_O@{u a i j k}
604 : forall (O : ReflectiveSubuniverse@{u a}) {P : Type2le@{i a}} {Q : Type2le@{j a}} {Q_inO : In@{u a j} O Q},
605 ooExtendableAlong@{i i j k} (to O P) (fun _ => Q).
606 admit.
607 Defined.
608
609 End ReflectiveSubuniverses_FamUnion.
610
611 End ReflectiveSubuniverse.
612
613 End Modalities.
614
615 End HoTT.
616
617 Module Type Modalities.
618
619 Parameter Modality@{u a} : Type2@{u a}.
620
621 Parameter O_reflector@{u a i} : forall (O : Modality@{u a}),
622 Type2le@{i a} -> Type2le@{i a}.
623
624 Parameter In@{u a i} : forall (O : Modality@{u a}),
625 Type2le@{i a} -> Type2le@{i a}.
626
627 Parameter O_inO@{u a i} : forall (O : Modality@{u a}) (T : Type@{i}),
628 In@{u a i} O (O_reflector@{u a i} O T).
629
630 Parameter to@{u a i} : forall (O : Modality@{u a}) (T : Type@{i}),
631 T -> O_reflector@{u a i} O T.
632
633 Parameter inO_equiv_inO@{u a i j k} :
634 forall (O : Modality@{u a}) (T : Type@{i}) (U : Type@{j})
635 (T_inO : In@{u a i} O T) (f : T -> U) (feq : IsEquiv f),
636
637 let gei := ((fun x => x) : Type@{i} -> Type@{k}) in
638 let gej := ((fun x => x) : Type@{j} -> Type@{k}) in
639 In@{u a j} O U.
640
641 Parameter hprop_inO@{u a i}
642 : Funext -> forall (O : Modality@{u a}) (T : Type@{i}),
643 IsHProp (In@{u a i} O T).
644
645 End Modalities.
646
647 Module Modalities_to_ReflectiveSubuniverses
648 (Os : Modalities) <: ReflectiveSubuniverses.
649
650 Import Os.
651
652 Fixpoint O_extendable@{u a i j k} (O : Modality@{u a})
653 (A : Type@{i}) (B : O_reflector O A -> Type@{j})
654 (B_inO : forall a, In@{u a j} O (B a)) (n : nat)
655 : ExtendableAlong@{i i j k} n (to O A) B.
656 admit.
657 Defined.
658
659 Definition ReflectiveSubuniverse := Modality.
660
661 Definition O_reflector@{u a i} := O_reflector@{u a i}.
662
663 Definition In@{u a i} : forall (O : ReflectiveSubuniverse@{u a}),
664 Type2le@{i a} -> Type2le@{i a}
665 := In@{u a i}.
666 Definition O_inO@{u a i} : forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}),
667 In@{u a i} O (O_reflector@{u a i} O T)
668 := O_inO@{u a i}.
669 Definition to@{u a i} := to@{u a i}.
670 Definition inO_equiv_inO@{u a i j k} :
671 forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}) (U : Type@{j})
672 (T_inO : In@{u a i} O T) (f : T -> U) (feq : IsEquiv f),
673 In@{u a j} O U
674 := inO_equiv_inO@{u a i j k}.
675 Definition hprop_inO@{u a i}
676 : Funext -> forall (O : ReflectiveSubuniverse@{u a}) (T : Type@{i}),
677 IsHProp (In@{u a i} O T)
678 := hprop_inO@{u a i}.
679
680 Definition extendable_to_O@{u a i j k} (O : ReflectiveSubuniverse@{u a})
681 {P : Type2le@{i a}} {Q : Type2le@{j a}} {Q_inO : In@{u a j} O Q}
682 : ooExtendableAlong@{i i j k} (to O P) (fun _ => Q)
683 := fun n => O_extendable O P (fun _ => Q) (fun _ => Q_inO) n.
684
685 End Modalities_to_ReflectiveSubuniverses.
686
687 Module Type EasyModalities.
688
689 Parameter Modality@{u a} : Type2@{u a}.
690
691 Parameter O_reflector@{u a i} : forall (O : Modality@{u a}),
692 Type2le@{i a} -> Type2le@{i a}.
693
694 Parameter to@{u a i} : forall (O : Modality@{u a}) (T : Type@{i}),
695 T -> O_reflector@{u a i} O T.
696
697 Parameter minO_pathsO@{u a i}
698 : forall (O : Modality@{u a}) (A : Type@{i})
699 (z z' : O_reflector@{u a i} O A),
700 IsEquiv (to@{u a i} O (z = z')).
701
702 End EasyModalities.
703
704 Module EasyModalities_to_Modalities (Os : EasyModalities)
705 <: Modalities.
706
707 Import Os.
708
709 Definition Modality := Modality.
710
711 Definition O_reflector@{u a i} := O_reflector@{u a i}.
712 Definition to@{u a i} := to@{u a i}.
713
714 Definition In@{u a i}
715 : forall (O : Modality@{u a}), Type@{i} -> Type@{i}
716 := fun O A => IsEquiv@{i i} (to O A).
717
718 Definition hprop_inO@{u a i} `{Funext} (O : Modality@{u a})
719 (T : Type@{i})
720 : IsHProp (In@{u a i} O T).
721 admit.
722 Defined.
723
724 Definition O_ind_internal@{u a i j k} (O : Modality@{u a})
725 (A : Type@{i}) (B : O_reflector@{u a i} O A -> Type@{j})
726 (B_inO : forall oa, In@{u a j} O (B oa))
727 : let gei := ((fun x => x) : Type@{i} -> Type@{k}) in
728 let gej := ((fun x => x) : Type@{j} -> Type@{k}) in
729 (forall a, B (to O A a)) -> forall oa, B oa.
730 admit.
731 Defined.
732
733 Definition O_ind_beta_internal@{u a i j k} (O : Modality@{u a})
734 (A : Type@{i}) (B : O_reflector@{u a i} O A -> Type@{j})
735 (B_inO : forall oa, In@{u a j} O (B oa))
736 (f : forall a : A, B (to O A a)) (a:A)
737 : O_ind_internal@{u a i j k} O A B B_inO f (to O A a) = f a.
738 admit.
739 Defined.
740
741 Definition O_inO@{u a i} (O : Modality@{u a}) (A : Type@{i})
742 : In@{u a i} O (O_reflector@{u a i} O A).
743 admit.
744 Defined.
745
746 Definition inO_equiv_inO@{u a i j k} (O : Modality@{u a}) (A : Type@{i}) (B : Type@{j})
747 (A_inO : In@{u a i} O A) (f : A -> B) (feq : IsEquiv f)
748 : In@{u a j} O B.
749 Proof.
750 simple refine (isequiv_commsq (to O A) (to O B) f
751 (O_ind_internal O A (fun _ => O_reflector O B) _ (fun a => to O B (f a))) _).
752 -
753 intros; apply O_inO.
754 -
755 intros a; refine (O_ind_beta_internal@{u a i j k} O A (fun _ => O_reflector O B) _ _ a).
756 -
757 apply A_inO.
758 -
759 simple refine (isequiv_adjointify _
760 (O_ind_internal O B (fun _ => O_reflector O A) _ (fun b => to O A (f^-1 b))) _ _);
761 intros x.
762 +
763 apply O_inO.
764 +
765 pattern x; refine (O_ind_internal O B _ _ _ x); intros.
766 *
767 apply minO_pathsO.
768 *
769 simpl; admit.
770 +
771 pattern x; refine (O_ind_internal O A _ _ _ x); intros.
772 *
773 apply minO_pathsO.
774 *
775 simpl; admit.
776 Defined.
777
778 End EasyModalities_to_Modalities.
779
780 Module Modalities_Theory (Os : Modalities).
781
782 Export Os.
783 Module Export Os_ReflectiveSubuniverses
784 := Modalities_to_ReflectiveSubuniverses Os.
785 Module Export RSU
786 := ReflectiveSubuniverses_Theory Os_ReflectiveSubuniverses.
787
788 Module Export Coercions.
789 Coercion modality_to_reflective_subuniverse
790 := idmap : Modality -> ReflectiveSubuniverse.
791 End Coercions.
792
793 Class IsConnected (O : Modality@{u a}) (A : Type@{i})
794
795 := isconnected_contr_O : IsTrunc@{i} -2 (O A).
796
797 Class IsConnMap (O : Modality@{u a})
798 {A : Type@{i}} {B : Type@{j}} (f : A -> B)
799 := isconnected_hfiber_conn_map
800
801 : forall b:B, IsConnected@{u a k} O (hfiber@{i j} f b).
802
803 End Modalities_Theory.
804
805 Private Inductive Trunc (n : trunc_index) (A :Type) : Type :=
806 tr : A -> Trunc n A.
807 Arguments tr {n A} a.
808
809 Global Instance istrunc_truncation (n : trunc_index) (A : Type@{i})
810 : IsTrunc@{j} n (Trunc@{i} n A).
811 Admitted.
812
813 Definition Trunc_ind {n A}
814 (P : Trunc n A -> Type) {Pt : forall aa, IsTrunc n (P aa)}
815 : (forall a, P (tr a)) -> (forall aa, P aa)
816 := (fun f aa => match aa with tr a => fun _ => f a end Pt).
817
818 Definition Truncation_Modality := trunc_index.
819
820 Module Truncation_Modalities <: Modalities.
821
822 Definition Modality : Type2@{u a} := Truncation_Modality.
823
824 Definition O_reflector (n : Modality@{u u'}) A := Trunc n A.
825
826 Definition In (n : Modality@{u u'}) A := IsTrunc n A.
827
828 Definition O_inO (n : Modality@{u u'}) A : In n (O_reflector n A).
829 admit.
830 Defined.
831
832 Definition to (n : Modality@{u u'}) A := @tr n A.
833
834 Definition inO_equiv_inO (n : Modality@{u u'})
835 (A : Type@{i}) (B : Type@{j}) Atr f feq
836 : let gei := ((fun x => x) : Type@{i} -> Type@{k}) in
837 let gej := ((fun x => x) : Type@{j} -> Type@{k}) in
838 In n B
839 := @trunc_equiv A B f n Atr feq.
840
841 Definition hprop_inO `{Funext} (n : Modality@{u u'}) A
842 : IsHProp (In n A).
843 admit.
844 Defined.
845
846 End Truncation_Modalities.
847
848 Module Import TrM := Modalities_Theory Truncation_Modalities.
849
850 Definition merely (A : Type@{i}) : hProp := BuildhProp (Trunc -1 A).
851
852 Notation IsSurjection := (IsConnMap -1).
853
854 Definition BuildIsSurjection {A B} (f : A -> B) :
855 (forall b, merely (hfiber f b)) -> IsSurjection f.
856 admit.
857 Defined.
858
859 Ltac strip_truncations :=
860
861 progress repeat match goal with
862 | [ T : _ |- _ ]
863 => revert_opaque T;
864 refine (@Trunc_ind _ _ _ _ _);
865
866 [];
867 intro T
868 end.
869 Local Open Scope trunc_scope.
870
871 Global Instance conn_pointed_type {n : trunc_index} {A : Type} (a0:A)
872 `{IsConnMap n _ _ (unit_name a0)} : IsConnected n.+1 A | 1000.
873 admit.
874 Defined.
875
876 Definition loops (A : pType) : pType :=
877 Build_pType (point A = point A) idpath.
878
879 Record pMap (A B : pType) :=
880 { pointed_fun : A -> B ;
881 point_eq : pointed_fun (point A) = point B }.
882
883 Arguments point_eq {A B} f : rename.
884 Coercion pointed_fun : pMap >-> Funclass.
885
886 Infix "->*" := pMap (at level 99) : pointed_scope.
887 Local Open Scope pointed_scope.
888
889 Definition pmap_compose {A B C : pType}
890 (g : B ->* C) (f : A ->* B)
891 : A ->* C
892 := Build_pMap A C (g o f)
893 (ap g (point_eq f) @ point_eq g).
894
895 Record pHomotopy {A B : pType} (f g : pMap A B) :=
896 { pointed_htpy : f == g ;
897 point_htpy : pointed_htpy (point A) @ point_eq g = point_eq f }.
898 Arguments pointed_htpy {A B f g} p x.
899
900 Infix "==*" := pHomotopy (at level 70, no associativity) : pointed_scope.
901
902 Definition loops_functor {A B : pType} (f : A ->* B)
903 : (loops A) ->* (loops B).
904 Proof.
905 refine (Build_pMap (loops A) (loops B)
906 (fun p => (point_eq f)^ @ (ap f p @ point_eq f)) _).
907 apply moveR_Vp; simpl.
908 refine (concat_1p _ @ (concat_p1 _)^).
909 Defined.
910
911 Definition loops_functor_compose {A B C : pType}
912 (g : B ->* C) (f : A ->* B)
913 : (loops_functor (pmap_compose g f))
914 ==* (pmap_compose (loops_functor g) (loops_functor f)).
915 admit.
916 Defined.
917
918 Local Open Scope path_scope.
919
920 Record ooGroup :=
921 { classifying_space : pType@{i} ;
922 isconn_classifying_space : IsConnected@{u a i} 0 classifying_space
923 }.
924
925 Local Notation B := classifying_space.
926
927 Definition group_type (G : ooGroup) : Type
928 := point (B G) = point (B G).
929
930 Coercion group_type : ooGroup >-> Sortclass.
931
932 Definition group_loops (X : pType)
933 : ooGroup.
934 Proof.
935
936 pose (x0 := point X);
937 pose (BG := (Build_pType
938 { x:X & merely (x = point X) }
939 (existT (fun x:X => merely (x = point X)) x0 (tr 1)))).
940
941 cut (IsConnected 0 BG).
942 {
943 exact (Build_ooGroup BG).
944 }
945 cut (IsSurjection (unit_name (point BG))).
946 {
947 intros; refine (conn_pointed_type (point _)).
948 }
949 apply BuildIsSurjection; simpl; intros [x p].
950 strip_truncations; apply tr; exists tt.
951 apply path_sigma_hprop; simpl.
952 exact (p^).
953 Defined.
954
955 Definition loops_group (X : pType)
956 : loops X <~> group_loops X.
957 admit.
958 Defined.
959
960 Definition ooGroupHom (G H : ooGroup)
961 := pMap (B G) (B H).
962
963 Definition grouphom_fun {G H} (phi : ooGroupHom G H) : G -> H
964 := loops_functor phi.
965
966 Coercion grouphom_fun : ooGroupHom >-> Funclass.
967
968 Definition group_loops_functor
969 {X Y : pType} (f : pMap X Y)
970 : ooGroupHom (group_loops X) (group_loops Y).
971 Proof.
972 simple refine (Build_pMap _ _ _ _); simpl.
973 -
974 intros [x p].
975 exists (f x).
976 strip_truncations; apply tr.
977 exact (ap f p @ point_eq f).
978 -
979 apply path_sigma_hprop; simpl.
980 apply point_eq.
981 Defined.
982
983 Definition loops_functor_group
984 {X Y : pType} (f : pMap X Y)
985 : loops_functor (group_loops_functor f) o loops_group X
986 == loops_group Y o loops_functor f.
987 admit.
988 Defined.
989
990 Definition grouphom_compose {G H K : ooGroup}
991 (psi : ooGroupHom H K) (phi : ooGroupHom G H)
992 : ooGroupHom G K
993 := pmap_compose psi phi.
994
995 Definition group_loops_functor_compose
996 {X Y Z : pType}
997 (psi : pMap Y Z) (phi : pMap X Y)
998 : grouphom_compose (group_loops_functor psi) (group_loops_functor phi)
999 == group_loops_functor (pmap_compose psi phi).
1000 Proof.
1001 intros g.
1002 unfold grouphom_fun, grouphom_compose.
1003 refine (pointed_htpy (loops_functor_compose _ _) g @ _).
1004 pose (p := eisretr (loops_group X) g).
1005 change (loops_functor (group_loops_functor psi)
1006 (loops_functor (group_loops_functor phi) g)
1007 = loops_functor (group_loops_functor
1008 (pmap_compose psi phi)) g).
1009 rewrite <- p.
1010 Timeout 1 Time rewrite !loops_functor_group.
1011 Undo.
1012 (* 0.004 s in 8.5rc1, 8.677 s in 8.5 *)
1013 Timeout 1 do 3 rewrite loops_functor_group.
1014 Abort.