Debian Codegraph @

test-suite/bugs/bug_3485.v

raw
1 Set Universe Polymorphism.
2 Set Primitive Projections.
3 Reserved Infix "o" (at level 40, left associativity).
4 Definition relation (A : Type) := A -> A -> Type.
5 Class Transitive {A} (R : relation A) := transitivity : forall x y z, R x y -> R y z -> R x z.
6 Tactic Notation "etransitivity" open_constr(y) :=
7 let R := match goal with |- ?R ?x ?z => constr:(R) end in
8 let x := match goal with |- ?R ?x ?z => constr:(x) end in
9 let z := match goal with |- ?R ?x ?z => constr:(z) end in
10 refine (@transitivity _ R _ x y z _ _).
11 Tactic Notation "etransitivity" := etransitivity _.
12 Notation "( x ; y )" := (existT _ x y) : fibration_scope.
13 Open Scope fibration_scope.
14 Notation "x .1" := (projT1 x) : fibration_scope.
15 Notation "x .2" := (projT2 x) : fibration_scope.
16 Inductive paths {A : Type} (a : A) : A -> Type := idpath : paths a a where "x = y" := (@paths _ x y) : type_scope.
17 Arguments idpath {A a} , [A] a.
18 Scheme Rewriting for paths.
19 Definition concat {A : Type} {x y z : A} (p : x = y) (q : y = z) : x = z := match p, q with idpath, idpath => idpath end.
20 #[export] Instance transitive_paths {A} : Transitive (@paths A) | 0 := @concat A.
21 Definition transport {A : Type} (P : A -> Type) {x y : A} (p : x = y) (u : P x) : P y := match p with idpath => u end.
22 Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
23 := match p with idpath => idpath end.
24 Class Contr_internal (A : Type) := { center : A ; contr : (forall y : A, center = y) }.
25 Generalizable Variables X A B C f g n.
26 Definition projT1_path `{P : A -> Type} {u v : sigT P} (p : u = v) : u.1 = v.1 := ap (@projT1 _ _) p.
27 Notation "p ..1" := (projT1_path p) (at level 3) : fibration_scope.
28 Ltac simpl_do_clear tac term :=
29 let H := fresh in
30 assert (H := term);
31 simpl in H |- *;
32 tac H;
33 clear H.
34 Set Implicit Arguments.
35 Delimit Scope morphism_scope with morphism.
36 Delimit Scope category_scope with category.
37 Delimit Scope object_scope with object.
38 Record PreCategory :=
39 { object :> Type;
40 morphism : object -> object -> Type;
41
42 identity : forall x, morphism x x;
43 compose : forall s d d',
44 morphism d d'
45 -> morphism s d
46 -> morphism s d'
47 where "f 'o' g" := (compose f g);
48
49 left_identity : forall a b (f : morphism a b), identity b o f = f;
50 right_identity : forall a b (f : morphism a b), f o identity a = f }.
51 Arguments identity {C%_category} / x%_object : rename.
52 Arguments compose {C%_category} / {s d d'}%_object (m1 m2)%_morphism : rename.
53 Infix "o" := compose : morphism_scope.
54 Notation "1" := (identity _) : morphism_scope.
55 Delimit Scope functor_scope with functor.
56 Local Open Scope morphism_scope.
57 Record Functor (C D : PreCategory) :=
58 { object_of :> C -> D;
59 morphism_of : forall s d, morphism C s d
60 -> morphism D (object_of s) (object_of d);
61 identity_of : forall x, morphism_of _ _ (identity x)
62 = identity (object_of x) }.
63 Bind Scope functor_scope with Functor.
64 Arguments morphism_of [C%_category] [D%_category] F%_functor / [s%_object d%_object] m%_morphism : rename.
65 Notation "F '_1' m" := (morphism_of F m) (at level 10, no associativity) : morphism_scope.
66 Section composition.
67 Variable C : PreCategory.
68 Variable D : PreCategory.
69 Variable E : PreCategory.
70 Variable G : Functor D E.
71 Variable F : Functor C D.
72
73 Local Notation c_object_of c := (G (F c)) (only parsing).
74 Local Notation c_morphism_of m := (morphism_of G (morphism_of F m)) (only parsing).
75
76 Definition compose_identity_of x
77 : c_morphism_of (identity x) = identity (c_object_of x)
78 := transport (@paths _ _)
79 (identity_of G _)
80 (ap (@morphism_of _ _ G _ _) (identity_of F x)).
81
82 Definition composeF : Functor C E
83 := Build_Functor
84 C E
85 (fun c => G (F c))
86 (fun _ _ m => morphism_of G (morphism_of F m))
87 compose_identity_of.
88 End composition.
89 Infix "o" := composeF : functor_scope.
90
91 Definition identityF C : Functor C C
92 := Build_Functor C C
93 (fun x => x)
94 (fun _ _ x => x)
95 (fun _ => idpath).
96 Notation "1" := (identityF _) : functor_scope.
97
98 Record NaturalTransformation C D (F G : Functor C D) := { components_of :> forall c, morphism D (F c) (G c) }.
99
100 Section unit.
101 Variable C : PreCategory.
102 Variable D : PreCategory.
103 Variable F : Functor C D.
104 Variable G : Functor D C.
105
106 Definition AdjunctionUnit :=
107 { T : NaturalTransformation 1 (G o F)
108 & forall (c : C) (d : D) (f : morphism C c (G d)),
109 Contr_internal { g : morphism D (F c) d & G _1 g o T c = f }
110 }.
111 End unit.
112 Parameter C : PreCategory.
113 Parameter D : PreCategory.
114 Parameter F : Functor C D.
115 Parameter G : Functor D C.
116
117 Definition zig__of__adjunction_unit
118 (A : AdjunctionUnit F G)
119 (Y : C)
120 (eta := A.1)
121 (eps := fun X => (@center _ (A.2 (G X) X 1)).1)
122 : G _1 (eps (F Y) o F _1 (eta Y)) o eta Y = eta Y
123 -> eps (F Y) o F _1 (eta Y) = 1.
124 Proof.
125 intros.
126 etransitivity; [ symmetry | ];
127 simpl_do_clear
128 ltac:(fun H => apply H)
129 (fun y H => (@contr _ (A.2 _ _ (A.1 Y)) (y; H))..1);
130 try assumption.
131 simpl.
132 rewrite ?@identity_of, ?@left_identity, ?@right_identity;
133 reflexivity.
134 Qed.