Debian Codegraph @

test-suite/bugs/bug_3330.v

raw
1 Unset Strict Universe Declaration.
2 Require Import TestSuite.admit.
3 (* File reduced by coq-bug-finder from original input, then from 12106 lines to 1070 lines *)
4 Set Universe Polymorphism.
5 Definition setleq (A : Type@{i}) (B : Type@{j}) := A : Type@{j}.
6
7 Inductive foo : Type@{l} := bar : foo .
8 Section MakeEq.
9 Variables (a : foo@{i}) (b : foo@{j}).
10
11 Let t := ltac:(let ty := type of b in exact ty).
12 Definition make_eq (x:=b) := a : t.
13 End MakeEq.
14
15 Definition same (x : foo@{i}) (y : foo@{i}) := x.
16
17 Section foo.
18
19 Variables x : foo@{i}.
20 Variables y : foo@{j}.
21
22 Let AleqB := let foo := make_eq x y in (Type * Type)%type.
23
24 Definition baz := same x y.
25 End foo.
26
27 Definition baz' := Eval unfold baz in baz@{i j k l}.
28
29 Module Export HoTT_DOT_Overture.
30 Module Export HoTT.
31 Module Export Overture.
32
33 Definition relation (A : Type) := A -> A -> Type.
34 Class Symmetric {A} (R : relation A) :=
35 symmetry : forall x y, R x y -> R y x.
36
37 Definition compose {A B C : Type} (g : B -> C) (f : A -> B) :=
38 fun x => g (f x).
39
40 Notation "g 'o' f" := (compose g f) (at level 40, left associativity) : function_scope.
41
42 Open Scope function_scope.
43
44 Set Printing Universes. Set Printing All.
45
46 Inductive paths {A : Type} (a : A) : A -> Type :=
47 idpath : paths a a.
48
49 Arguments idpath {A a} , [A] a.
50
51 Notation "x = y :> A" := (@paths A x y) : type_scope.
52
53 Notation "x = y" := (x = y :>_) : type_scope.
54
55 Delimit Scope path_scope with path.
56
57 Local Open Scope path_scope.
58
59 Definition concat {A : Type} {x y z : A} (p : x = y) (q : y = z) : x = z :=
60 match p, q with idpath, idpath => idpath end.
61
62 Definition inverse {A : Type} {x y : A} (p : x = y) : y = x
63 := match p with idpath => idpath end.
64
65 #[global] Instance symmetric_paths {A} : Symmetric (@paths A) | 0 := @inverse A.
66
67 Notation "1" := idpath : path_scope.
68
69 Notation "p @ q" := (concat p q) (at level 20, left associativity) : path_scope.
70
71 Notation "p ^" := (inverse p) (at level 3) : path_scope.
72
73 Definition transport {A : Type} (P : A -> Type) {x y : A} (p : x = y) (u : P x) : P y :=
74 match p with idpath => u end.
75
76 Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
77 := match p with idpath => idpath end.
78
79 Definition pointwise_paths {A} {P:A->Type} (f g:forall x:A, P x) : Type
80 := forall x:A, f x = g x.
81
82 #[global] Hint Unfold pointwise_paths : typeclass_instances.
83
84 Notation "f == g" := (pointwise_paths f g) (at level 70, no associativity) : type_scope.
85
86 Definition apD10 {A} {B:A->Type} {f g : forall x, B x} (h:f=g)
87 : f == g
88 := fun x => match h with idpath => 1 end.
89
90 Definition Sect {A B : Type} (s : A -> B) (r : B -> A) :=
91 forall x : A, r (s x) = x.
92
93 Class IsEquiv {A B : Type} (f : A -> B) := BuildIsEquiv {
94 equiv_inv : B -> A ;
95 eisretr : Sect equiv_inv f;
96 eissect : Sect f equiv_inv;
97 eisadj : forall x : A, eisretr (f x) = ap f (eissect x)
98 }.
99
100 Delimit Scope equiv_scope with equiv.
101
102 Local Open Scope equiv_scope.
103
104 Notation "f ^-1" := (@equiv_inv _ _ f _) (at level 3) : equiv_scope.
105
106 Class Contr_internal (A : Type) := BuildContr {
107 center : A ;
108 contr : (forall y : A, center = y)
109 }.
110
111 Inductive trunc_index : Type :=
112 | minus_two : trunc_index
113 | trunc_S : trunc_index -> trunc_index.
114
115 Fixpoint nat_to_trunc_index (n : nat) : trunc_index
116 := match n with
117 | 0 => trunc_S (trunc_S minus_two)
118 | S n' => trunc_S (nat_to_trunc_index n')
119 end.
120
121 Coercion nat_to_trunc_index : nat >-> trunc_index.
122
123 Fixpoint IsTrunc_internal (n : trunc_index) (A : Type) : Type :=
124 match n with
125 | minus_two => Contr_internal A
126 | trunc_S n' => forall (x y : A), IsTrunc_internal n' (x = y)
127 end.
128
129 Class IsTrunc (n : trunc_index) (A : Type) : Type :=
130 Trunc_is_trunc : IsTrunc_internal n A.
131
132 Notation IsHSet := (IsTrunc 0).
133
134 Class Funext :=
135 { isequiv_apD10 :: forall (A : Type) (P : A -> Type) f g, IsEquiv (@apD10 A P f g) }.
136
137 Definition path_forall `{Funext} {A : Type} {P : A -> Type} (f g : forall x : A, P x) :
138 f == g -> f = g
139 :=
140 (@apD10 A P f g)^-1.
141
142 End Overture.
143
144 End HoTT.
145
146 End HoTT_DOT_Overture.
147
148 Module Export HoTT_DOT_categories_DOT_Category_DOT_Core.
149
150 Module Export HoTT.
151 Module Export categories.
152 Module Export Category.
153 Module Export Core.
154 Set Universe Polymorphism.
155
156 Set Implicit Arguments.
157 Delimit Scope morphism_scope with morphism.
158
159 Delimit Scope category_scope with category.
160 Delimit Scope object_scope with object.
161 Set Printing Universes.
162 Set Printing All.
163 Record PreCategory :=
164 Build_PreCategory' {
165 object :> Type;
166 morphism : object -> object -> Type;
167
168 identity : forall x, morphism x x;
169 compose : forall s d d',
170 morphism d d'
171 -> morphism s d
172 -> morphism s d'
173 where "f 'o' g" := (compose f g);
174
175 associativity : forall x1 x2 x3 x4
176 (m1 : morphism x1 x2)
177 (m2 : morphism x2 x3)
178 (m3 : morphism x3 x4),
179 (m3 o m2) o m1 = m3 o (m2 o m1);
180
181 associativity_sym : forall x1 x2 x3 x4
182 (m1 : morphism x1 x2)
183 (m2 : morphism x2 x3)
184 (m3 : morphism x3 x4),
185 m3 o (m2 o m1) = (m3 o m2) o m1;
186
187 left_identity : forall a b (f : morphism a b), identity b o f = f;
188 right_identity : forall a b (f : morphism a b), f o identity a = f;
189
190 identity_identity : forall x, identity x o identity x = identity x;
191
192 trunc_morphism : forall s d, IsHSet (morphism s d)
193 }.
194
195 Bind Scope category_scope with PreCategory.
196
197 Arguments identity [!C%_category] x%_object : rename.
198 Arguments compose [!C%_category s%_object d%_object d'%_object] m1%_morphism m2%_morphism : rename.
199
200 Definition Build_PreCategory
201 object morphism compose identity
202 associativity left_identity right_identity
203 := @Build_PreCategory'
204 object
205 morphism
206 compose
207 identity
208 associativity
209 (fun _ _ _ _ _ _ _ => symmetry _ _ (associativity _ _ _ _ _ _ _))
210 left_identity
211 right_identity
212 (fun _ => left_identity _ _ _).
213
214 #[global] Existing Instance trunc_morphism.
215
216 #[global] Hint Resolve @left_identity @right_identity @associativity : category morphism.
217
218 Module Export CategoryCoreNotations.
219
220 Infix "o" := compose : morphism_scope.
221 End CategoryCoreNotations.
222 End Core.
223
224 End Category.
225
226 End categories.
227
228 End HoTT.
229
230 End HoTT_DOT_categories_DOT_Category_DOT_Core.
231
232 Module Export HoTT_DOT_types_DOT_Forall.
233
234 Module Export HoTT.
235 Module Export types.
236 Module Export Forall.
237 Generalizable Variables A B f g e n.
238
239 Section AssumeFunext.
240
241 Global Instance trunc_forall `{P : A -> Type} `{forall a, IsTrunc n (P a)}
242 : IsTrunc n (forall a, P a) | 100.
243
244 admit.
245 Defined.
246 End AssumeFunext.
247
248 End Forall.
249
250 End types.
251
252 End HoTT.
253
254 End HoTT_DOT_types_DOT_Forall.
255
256 Module Export HoTT_DOT_types_DOT_Prod.
257
258 Module Export HoTT.
259 Module Export types.
260 Module Export Prod.
261 Local Open Scope path_scope.
262
263 Definition path_prod_uncurried {A B : Type} (z z' : A * B)
264 (pq : (fst z = fst z') * (snd z = snd z'))
265 : (z = z')
266 := match pq with (p,q) =>
267 match z, z' return
268 (fst z = fst z') -> (snd z = snd z') -> (z = z') with
269 | (a,b), (a',b') => fun p q =>
270 match p, q with
271 idpath, idpath => 1
272 end
273 end p q
274 end.
275
276 Definition path_prod {A B : Type} (z z' : A * B) :
277 (fst z = fst z') -> (snd z = snd z') -> (z = z')
278 := fun p q => path_prod_uncurried z z' (p,q).
279
280 Definition path_prod' {A B : Type} {x x' : A} {y y' : B}
281 : (x = x') -> (y = y') -> ((x,y) = (x',y'))
282 := fun p q => path_prod (x,y) (x',y') p q.
283
284 End Prod.
285
286 End types.
287
288 End HoTT.
289
290 End HoTT_DOT_types_DOT_Prod.
291
292 Module Export HoTT_DOT_categories_DOT_Functor_DOT_Core.
293
294 Module Export HoTT.
295 Module Export categories.
296 Module Export Functor.
297 Module Export Core.
298 Set Universe Polymorphism.
299
300 Set Implicit Arguments.
301 Delimit Scope functor_scope with functor.
302
303 Local Open Scope morphism_scope.
304
305 Section Functor.
306
307 Variable C : PreCategory.
308 Variable D : PreCategory.
309
310 Record Functor :=
311 {
312 object_of :> C -> D;
313 morphism_of : forall s d, morphism C s d
314 -> morphism D (object_of s) (object_of d);
315 composition_of : forall s d d'
316 (m1 : morphism C s d) (m2: morphism C d d'),
317 morphism_of _ _ (m2 o m1)
318 = (morphism_of _ _ m2) o (morphism_of _ _ m1);
319 identity_of : forall x, morphism_of _ _ (identity x)
320 = identity (object_of x)
321 }.
322
323 End Functor.
324 Bind Scope functor_scope with Functor.
325
326 Arguments morphism_of [C%_category] [D%_category] F%_functor [s%_object d%_object] m%_morphism : rename, simpl nomatch.
327 Module Export FunctorCoreNotations.
328
329 Notation "F '_1' m" := (morphism_of F m) (at level 10, no associativity) : morphism_scope.
330 End FunctorCoreNotations.
331 End Core.
332
333 End Functor.
334
335 End categories.
336
337 End HoTT.
338
339 End HoTT_DOT_categories_DOT_Functor_DOT_Core.
340
341 Module Export HoTT_DOT_categories_DOT_Category_DOT_Morphisms.
342
343 Module Export HoTT.
344 Module Export categories.
345 Module Export Category.
346 Module Export Morphisms.
347 Set Universe Polymorphism.
348
349 Local Open Scope morphism_scope.
350
351 Class IsIsomorphism {C : PreCategory} {s d} (m : morphism C s d) :=
352 {
353 morphism_inverse : morphism C d s;
354 left_inverse : morphism_inverse o m = identity _;
355 right_inverse : m o morphism_inverse = identity _
356 }.
357
358 Class Isomorphic {C : PreCategory} s d :=
359 {
360 morphism_isomorphic :: morphism C s d;
361 isisomorphism_isomorphic :: IsIsomorphism morphism_isomorphic
362 }.
363
364 Module Export CategoryMorphismsNotations.
365
366 Infix "<~=~>" := Isomorphic (at level 70, no associativity) : category_scope.
367
368 End CategoryMorphismsNotations.
369 End Morphisms.
370
371 End Category.
372
373 End categories.
374
375 End HoTT.
376
377 End HoTT_DOT_categories_DOT_Category_DOT_Morphisms.
378
379 Module Export HoTT_DOT_categories_DOT_Category_DOT_Dual.
380
381 Module Export HoTT.
382 Module Export categories.
383 Module Export Category.
384 Module Export Dual.
385 Set Universe Polymorphism.
386
387 Local Open Scope morphism_scope.
388
389 Section opposite.
390
391 Definition opposite (C : PreCategory) : PreCategory
392 := @Build_PreCategory'
393 C
394 (fun s d => morphism C d s)
395 (identity (C := C))
396 (fun _ _ _ m1 m2 => m2 o m1)
397 (fun _ _ _ _ _ _ _ => @associativity_sym _ _ _ _ _ _ _ _)
398 (fun _ _ _ _ _ _ _ => @associativity _ _ _ _ _ _ _ _)
399 (fun _ _ => @right_identity _ _ _)
400 (fun _ _ => @left_identity _ _ _)
401 (@identity_identity C)
402 _.
403 End opposite.
404
405 Module Export CategoryDualNotations.
406
407 Notation "C ^op" := (opposite C) (at level 3) : category_scope.
408 End CategoryDualNotations.
409 End Dual.
410
411 End Category.
412
413 End categories.
414
415 End HoTT.
416
417 End HoTT_DOT_categories_DOT_Category_DOT_Dual.
418
419 Module Export HoTT_DOT_categories_DOT_Functor_DOT_Composition_DOT_Core.
420
421 Module Export HoTT.
422 Module Export categories.
423 Module Export Functor.
424 Module Export Composition.
425 Module Export Core.
426 Set Universe Polymorphism.
427
428 Set Implicit Arguments.
429 Local Open Scope morphism_scope.
430
431 Section composition.
432
433 Variable C : PreCategory.
434 Variable D : PreCategory.
435 Variable E : PreCategory.
436 Variable G : Functor D E.
437 Variable F : Functor C D.
438
439 Local Notation c_object_of c := (G (F c)) (only parsing).
440
441 Local Notation c_morphism_of m := (morphism_of G (morphism_of F m)) (only parsing).
442
443 Let compose_composition_of' s d d'
444 (m1 : morphism C s d) (m2 : morphism C d d')
445 : c_morphism_of (m2 o m1) = c_morphism_of m2 o c_morphism_of m1.
446 admit.
447 Defined.
448 Definition compose_composition_of s d d' m1 m2
449 := Eval cbv beta iota zeta delta
450 [compose_composition_of'] in
451 @compose_composition_of' s d d' m1 m2.
452 Let compose_identity_of' x
453 : c_morphism_of (identity x) = identity (c_object_of x).
454
455 admit.
456 Defined.
457 Definition compose_identity_of x
458 := Eval cbv beta iota zeta delta
459 [compose_identity_of'] in
460 @compose_identity_of' x.
461 Definition compose : Functor C E
462 := Build_Functor
463 C E
464 (fun c => G (F c))
465 (fun _ _ m => morphism_of G (morphism_of F m))
466 compose_composition_of
467 compose_identity_of.
468
469 End composition.
470 Module Export FunctorCompositionCoreNotations.
471
472 Infix "o" := compose : functor_scope.
473 End FunctorCompositionCoreNotations.
474 End Core.
475
476 End Composition.
477
478 End Functor.
479
480 End categories.
481
482 End HoTT.
483
484 End HoTT_DOT_categories_DOT_Functor_DOT_Composition_DOT_Core.
485
486 Module Export HoTT_DOT_categories_DOT_Functor_DOT_Dual.
487
488 Module Export HoTT.
489 Module Export categories.
490 Module Export Functor.
491 Module Export Dual.
492 Set Universe Polymorphism.
493
494 Set Implicit Arguments.
495
496 Section opposite.
497
498 Variable C : PreCategory.
499 Variable D : PreCategory.
500 Definition opposite (F : Functor C D) : Functor C^op D^op
501 := Build_Functor (C^op) (D^op)
502 (object_of F)
503 (fun s d => morphism_of F (s := d) (d := s))
504 (fun d' d s m1 m2 => composition_of F s d d' m2 m1)
505 (identity_of F).
506
507 End opposite.
508 Module Export FunctorDualNotations.
509
510 Notation "F ^op" := (opposite F) : functor_scope.
511 End FunctorDualNotations.
512 End Dual.
513
514 End Functor.
515
516 End categories.
517
518 End HoTT.
519
520 End HoTT_DOT_categories_DOT_Functor_DOT_Dual.
521
522 Module Export HoTT_DOT_categories_DOT_Functor_DOT_Identity.
523
524 Module Export HoTT.
525 Module Export categories.
526 Module Export Functor.
527 Module Export Identity.
528 Set Universe Polymorphism.
529
530 Section identity.
531
532 Definition identity C : Functor C C
533 := Build_Functor C C
534 (fun x => x)
535 (fun _ _ x => x)
536 (fun _ _ _ _ _ => idpath)
537 (fun _ => idpath).
538 End identity.
539 Module Export FunctorIdentityNotations.
540
541 Notation "1" := (identity _) : functor_scope.
542 End FunctorIdentityNotations.
543 End Identity.
544
545 End Functor.
546
547 End categories.
548
549 End HoTT.
550
551 End HoTT_DOT_categories_DOT_Functor_DOT_Identity.
552
553 Module Export HoTT_DOT_categories_DOT_NaturalTransformation_DOT_Core.
554
555 Module Export HoTT.
556 Module Export categories.
557 Module Export NaturalTransformation.
558 Module Export Core.
559 Set Universe Polymorphism.
560
561 Set Implicit Arguments.
562 Local Open Scope morphism_scope.
563
564 Section NaturalTransformation.
565
566 Variable C : PreCategory.
567 Variable D : PreCategory.
568 Variables F G : Functor C D.
569
570 Record NaturalTransformation :=
571 Build_NaturalTransformation' {
572 components_of :> forall c, morphism D (F c) (G c);
573 commutes : forall s d (m : morphism C s d),
574 components_of d o F _1 m = G _1 m o components_of s;
575
576 commutes_sym : forall s d (m : C.(morphism) s d),
577 G _1 m o components_of s = components_of d o F _1 m
578 }.
579
580 End NaturalTransformation.
581 End Core.
582
583 End NaturalTransformation.
584
585 End categories.
586
587 End HoTT.
588
589 End HoTT_DOT_categories_DOT_NaturalTransformation_DOT_Core.
590
591 Module Export HoTT_DOT_categories_DOT_NaturalTransformation_DOT_Dual.
592
593 Module Export HoTT.
594 Module Export categories.
595 Module Export NaturalTransformation.
596 Module Export Dual.
597 Set Universe Polymorphism.
598
599 Section opposite.
600
601 Variable C : PreCategory.
602 Variable D : PreCategory.
603
604 Definition opposite
605 (F G : Functor C D)
606 (T : NaturalTransformation F G)
607 : NaturalTransformation G^op F^op
608 := Build_NaturalTransformation' (G^op) (F^op)
609 (components_of T)
610 (fun s d => commutes_sym T d s)
611 (fun s d => commutes T d s).
612
613 End opposite.
614
615 End Dual.
616
617 End NaturalTransformation.
618
619 End categories.
620
621 End HoTT.
622
623 End HoTT_DOT_categories_DOT_NaturalTransformation_DOT_Dual.
624
625 Module Export HoTT_DOT_categories_DOT_Category_DOT_Strict.
626
627 Module Export HoTT.
628 Module Export categories.
629 Module Export Category.
630 Module Export Strict.
631
632 Export Category.Core.
633 Set Universe Polymorphism.
634
635 End Strict.
636
637 End Category.
638
639 End categories.
640
641 End HoTT.
642
643 End HoTT_DOT_categories_DOT_Category_DOT_Strict.
644
645 Module Export HoTT.
646 Module Export categories.
647 Module Export Category.
648 Module Export Prod.
649 Set Universe Polymorphism.
650
651 Local Open Scope morphism_scope.
652
653 Section prod.
654
655 Variable C : PreCategory.
656 Variable D : PreCategory.
657 Definition prod : PreCategory.
658
659 refine (@Build_PreCategory
660 (C * D)%type
661 (fun s d => (morphism C (fst s) (fst d)
662 * morphism D (snd s) (snd d))%type)
663 (fun x => (identity (fst x), identity (snd x)))
664 (fun s d d' m2 m1 => (fst m2 o fst m1, snd m2 o snd m1))
665 _
666 _
667 _
668 _); admit.
669 Defined.
670 End prod.
671 Module Export CategoryProdNotations.
672
673 Infix "*" := prod : category_scope.
674 End CategoryProdNotations.
675 End Prod.
676
677 End Category.
678
679 End categories.
680
681 End HoTT.
682
683 Module Functor.
684 Module Export Prod.
685 Set Universe Polymorphism.
686
687 Set Implicit Arguments.
688 Local Open Scope morphism_scope.
689
690 Section proj.
691
692 Context {C : PreCategory}.
693 Context {D : PreCategory}.
694 Definition fst : Functor (C * D) C
695 := Build_Functor (C * D) C
696 (@fst _ _)
697 (fun _ _ => @fst _ _)
698 (fun _ _ _ _ _ => idpath)
699 (fun _ => idpath).
700
701 Definition snd : Functor (C * D) D
702 := Build_Functor (C * D) D
703 (@snd _ _)
704 (fun _ _ => @snd _ _)
705 (fun _ _ _ _ _ => idpath)
706 (fun _ => idpath).
707
708 End proj.
709
710 Section prod.
711
712 Variable C : PreCategory.
713 Variable D : PreCategory.
714 Variable D' : PreCategory.
715 Definition prod (F : Functor C D) (F' : Functor C D')
716 : Functor C (D * D')
717 := Build_Functor
718 C (D * D')
719 (fun c => (F c, F' c))
720 (fun s d m => (F _1 m, F' _1 m))
721 (fun _ _ _ _ _ => path_prod' (composition_of F _ _ _ _ _)
722 (composition_of F' _ _ _ _ _))
723 (fun _ => path_prod' (identity_of F _) (identity_of F' _)).
724
725 End prod.
726 Local Infix "*" := prod : functor_scope.
727
728 Section pair.
729
730 Variable C : PreCategory.
731 Variable D : PreCategory.
732 Variable C' : PreCategory.
733 Variable D' : PreCategory.
734 Variable F : Functor C D.
735 Variable F' : Functor C' D'.
736 Definition pair : Functor (C * C') (D * D')
737 := (F o fst) * (F' o snd).
738
739 End pair.
740
741 Module Export FunctorProdNotations.
742
743 Notation "( x , y , .. , z )" := (pair .. (pair x y) .. z) : functor_scope.
744 End FunctorProdNotations.
745 End Prod.
746
747 End Functor.
748
749 Module Export HoTT_DOT_categories_DOT_NaturalTransformation_DOT_Composition_DOT_Core.
750
751 Module Export HoTT.
752 Module categories.
753 Module Export NaturalTransformation.
754 Module Export Composition.
755 Module Export Core.
756 Set Universe Polymorphism.
757
758 Set Implicit Arguments.
759 Local Open Scope path_scope.
760
761 Local Open Scope morphism_scope.
762
763 Section composition.
764
765 Section compose.
766 Variable C : PreCategory.
767 Variable D : PreCategory.
768 Variables F F' F'' : Functor C D.
769 Variable T' : NaturalTransformation F' F''.
770
771 Variable T : NaturalTransformation F F'.
772 Local Notation CO c := (T' c o T c).
773
774 Definition compose_commutes s d (m : morphism C s d)
775 : CO d o morphism_of F m = morphism_of F'' m o CO s
776 := (associativity _ _ _ _ _ _ _ _)
777 @ ap (fun x => _ o x) (commutes T _ _ m)
778 @ (associativity_sym _ _ _ _ _ _ _ _)
779 @ ap (fun x => x o _) (commutes T' _ _ m)
780 @ (associativity _ _ _ _ _ _ _ _).
781
782 Definition compose_commutes_sym s d (m : morphism C s d)
783 : morphism_of F'' m o CO s = CO d o morphism_of F m
784 := (associativity_sym _ _ _ _ _ _ _ _)
785 @ ap (fun x => x o _) (commutes_sym T' _ _ m)
786 @ (associativity _ _ _ _ _ _ _ _)
787 @ ap (fun x => _ o x) (commutes_sym T _ _ m)
788 @ (associativity_sym _ _ _ _ _ _ _ _).
789
790 Definition compose
791 : NaturalTransformation F F''
792 := Build_NaturalTransformation' F F''
793 (fun c => CO c)
794 compose_commutes
795 compose_commutes_sym.
796
797 End compose.
798 End composition.
799 Module Export NaturalTransformationCompositionCoreNotations.
800
801 Infix "o" := compose : natural_transformation_scope.
802 End NaturalTransformationCompositionCoreNotations.
803 End Core.
804
805 End Composition.
806
807 End NaturalTransformation.
808
809 End categories.
810
811 Set Universe Polymorphism.
812
813 Section path_natural_transformation.
814
815 Context `{Funext}.
816 Variable C : PreCategory.
817
818 Variable D : PreCategory.
819 Variables F G : Functor C D.
820
821 Global Instance trunc_natural_transformation
822 : IsHSet (NaturalTransformation F G).
823
824 admit.
825 Defined.
826 Section path.
827
828 Variables T U : NaturalTransformation F G.
829
830 Lemma path'_natural_transformation
831 : components_of T = components_of U
832 -> T = U.
833
834 admit.
835 Defined.
836 Lemma path_natural_transformation
837 : components_of T == components_of U
838 -> T = U.
839
840 Proof.
841 intros.
842 apply path'_natural_transformation.
843 apply path_forall; assumption.
844 Qed.
845 End path.
846 End path_natural_transformation.
847
848 Ltac path_natural_transformation :=
849 repeat match goal with
850 | _ => intro
851 | _ => apply path_natural_transformation; simpl
852 end.
853
854 Module Export Identity.
855 Set Universe Polymorphism.
856
857 Set Implicit Arguments.
858 Local Open Scope morphism_scope.
859
860 Local Open Scope path_scope.
861 Section identity.
862
863 Variable C : PreCategory.
864 Variable D : PreCategory.
865
866 Section generalized.
867
868 Variables F G : Functor C D.
869 Hypothesis HO : object_of F = object_of G.
870 Hypothesis HM : transport (fun GO => forall s d,
871 morphism C s d
872 -> morphism D (GO s) (GO d))
873 HO
874 (morphism_of F)
875 = morphism_of G.
876 Local Notation CO c := (transport (fun GO => morphism D (F c) (GO c))
877 HO
878 (identity (F c))).
879
880 Definition generalized_identity_commutes s d (m : morphism C s d)
881 : CO d o morphism_of F m = morphism_of G m o CO s.
882
883 Proof.
884 case HM.
885 case HO.
886 exact (left_identity _ _ _ _ @ (right_identity _ _ _ _)^).
887 Defined.
888 Definition generalized_identity_commutes_sym s d (m : morphism C s d)
889 : morphism_of G m o CO s = CO d o morphism_of F m.
890
891 admit.
892 Defined.
893 Definition generalized_identity
894 : NaturalTransformation F G
895 := Build_NaturalTransformation'
896 F G
897 (fun c => CO c)
898 generalized_identity_commutes
899 generalized_identity_commutes_sym.
900
901 End generalized.
902 Definition identity (F : Functor C D)
903 : NaturalTransformation F F
904 := Eval simpl in @generalized_identity F F 1 1.
905
906 End identity.
907 Module Export NaturalTransformationIdentityNotations.
908
909 Notation "1" := (identity _) : natural_transformation_scope.
910 End NaturalTransformationIdentityNotations.
911 End Identity.
912
913 Module Export Laws.
914 Import HoTT_DOT_categories_DOT_NaturalTransformation_DOT_Composition_DOT_Core.HoTT.categories.
915 Set Universe Polymorphism.
916
917 Local Open Scope natural_transformation_scope.
918 Section natural_transformation_identity.
919
920 Context `{fs : Funext}.
921 Variable C : PreCategory.
922
923 Variable D : PreCategory.
924
925 Lemma left_identity (F F' : Functor C D)
926 (T : NaturalTransformation F F')
927 : 1 o T = T.
928
929 Proof.
930 path_natural_transformation; auto with morphism.
931 Qed.
932
933 Lemma right_identity (F F' : Functor C D)
934 (T : NaturalTransformation F F')
935 : T o 1 = T.
936
937 Proof.
938 path_natural_transformation; auto with morphism.
939 Qed.
940 End natural_transformation_identity.
941 Section associativity.
942
943 Section nt.
944
945 Context `{fs : Funext}.
946 Definition associativity
947 C D F G H I
948 (V : @NaturalTransformation C D F G)
949 (U : @NaturalTransformation C D G H)
950 (T : @NaturalTransformation C D H I)
951 : (T o U) o V = T o (U o V).
952
953 Proof.
954 path_natural_transformation.
955 apply associativity.
956 Qed.
957 End nt.
958 End associativity.
959 End Laws.
960
961 Module Export FunctorCategory.
962 Module Export Core.
963 Import HoTT_DOT_categories_DOT_NaturalTransformation_DOT_Composition_DOT_Core.HoTT.categories.
964 Set Universe Polymorphism.
965
966 Section functor_category.
967
968 Context `{Funext}.
969 Variable C : PreCategory.
970
971 Variable D : PreCategory.
972
973 Definition functor_category : PreCategory
974 := @Build_PreCategory (Functor C D)
975 (@NaturalTransformation C D)
976 (@identity C D)
977 (@compose C D)
978 (@associativity _ C D)
979 (@left_identity _ C D)
980 (@right_identity _ C D)
981 _.
982
983 End functor_category.
984 Module Export FunctorCategoryCoreNotations.
985
986 Notation "C -> D" := (functor_category C D) : category_scope.
987 End FunctorCategoryCoreNotations.
988 End Core.
989
990 End FunctorCategory.
991
992 Module Export Morphisms.
993 Set Universe Polymorphism.
994
995 Set Implicit Arguments.
996
997 Definition NaturalIsomorphism `{Funext} (C D : PreCategory) F G :=
998 @Isomorphic (C -> D) F G.
999
1000 Module Export FunctorCategoryMorphismsNotations.
1001
1002 Infix "<~=~>" := NaturalIsomorphism : natural_transformation_scope.
1003 End FunctorCategoryMorphismsNotations.
1004 End Morphisms.
1005
1006 Module Export HSet.
1007 Record hSet := BuildhSet {setT:> Type; iss :> IsHSet setT}.
1008
1009 Global Existing Instance iss.
1010 End HSet.
1011
1012 Module Export Core.
1013 Set Universe Polymorphism.
1014
1015 Notation cat_of obj :=
1016 (@Build_PreCategory obj
1017 (fun x y => x -> y)
1018 (fun _ x => x)
1019 (fun _ _ _ f g => f o g)%core
1020 (fun _ _ _ _ _ _ _ => idpath)
1021 (fun _ _ _ => idpath)
1022 (fun _ _ _ => idpath)
1023 _).
1024
1025 Definition set_cat `{Funext} : PreCategory := cat_of hSet.
1026 Set Universe Polymorphism.
1027
1028 Local Open Scope morphism_scope.
1029
1030 Section hom_functor.
1031
1032 Context `{Funext}.
1033 Variable C : PreCategory.
1034 Local Notation obj_of c'c :=
1035 (BuildhSet
1036 (morphism
1037 C
1038 (fst (c'c : object (C^op * C)))
1039 (snd (c'c : object (C^op * C))))
1040 _).
1041
1042 Let hom_functor_morphism_of s's d'd (hf : morphism (C^op * C) s's d'd)
1043 : morphism set_cat (obj_of s's) (obj_of d'd)
1044 := fun g => snd hf o g o fst hf.
1045
1046 Definition hom_functor : Functor (C^op * C) set_cat.
1047
1048 refine (Build_Functor (C^op * C) set_cat
1049 (fun c'c => obj_of c'c)
1050 hom_functor_morphism_of
1051 _
1052 _);
1053 subst hom_functor_morphism_of;
1054 simpl; admit.
1055 Defined.
1056 End hom_functor.
1057 Set Universe Polymorphism.
1058
1059 Import Category.Dual Functor.Dual.
1060 Import Category.Prod Functor.Prod.
1061 Import Functor.Composition.Core.
1062 Import Functor.Identity.
1063 Set Universe Polymorphism.
1064
1065 Local Open Scope functor_scope.
1066 Local Open Scope natural_transformation_scope.
1067 Section Adjunction.
1068
1069 Context `{Funext}.
1070 Variable C : PreCategory.
1071 Variable D : PreCategory.
1072 Variable F : Functor C D.
1073 Variable G : Functor D C.
1074
1075 Let Adjunction_Type :=
1076 Eval simpl in (hom_functor D) o (F^op, 1) <~=~> (hom_functor C) o (1, G).
1077
1078 Record AdjunctionHom :=
1079 {
1080 mate_of :
1081 @NaturalIsomorphism H
1082 (Prod.prod (Category.Dual.opposite C) D)
1083 (@set_cat H)
1084 (@compose (Prod.prod (Category.Dual.opposite C) D)
1085 (Prod.prod (Category.Dual.opposite D) D)
1086 (@set_cat H) (@hom_functor H D)
1087 (@pair (Category.Dual.opposite C)
1088 (Category.Dual.opposite D) D D
1089 (@opposite C D F) (identity D)))
1090 (@compose (Prod.prod (Category.Dual.opposite C) D)
1091 (Prod.prod (Category.Dual.opposite C) C)
1092 (@set_cat H) (@hom_functor H C)
1093 (@pair (Category.Dual.opposite C)
1094 (Category.Dual.opposite C) D C
1095 (identity (Category.Dual.opposite C)) G))
1096 }.
1097 End Adjunction.
1098 (* Error: Illegal application:
1099 The term "NaturalIsomorphism" of type
1100 "forall (H : Funext) (C D : PreCategory),
1101 (C -> D)%category -> (C -> D)%category -> Type"
1102 cannot be applied to the terms
1103 "H" : "Funext"
1104 "(C ^op * D)%category" : "PreCategory"
1105 "set_cat" : "PreCategory"
1106 "hom_functor D o (F ^op, 1)" : "Functor (C ^op * D) set_cat"
1107 "hom_functor C o (1, G)" : "Functor (C ^op * D) set_cat"
1108 The 5th term has type "Functor (C ^op * D) set_cat"
1109 which should be coercible to "object (C ^op * D -> set_cat)".
1110 *)
1111 End Core.
1112
1113 End HoTT.
1114
1115 End HoTT_DOT_categories_DOT_NaturalTransformation_DOT_Composition_DOT_Core.