Debian Codegraph @

test-suite/bugs/bug_16995_2.v

raw
1 Require Export Corelib.Program.Basics.
2 Require Setoid.
3
4 Require Export Corelib.Classes.CMorphisms.
5
6 Declare Scope category_theory_scope.
7 Open Scope category_theory_scope.
8
9 Notation "∀ x .. y , P" := (forall x, .. (forall y, P) ..)
10 (at level 200, x binder, y binder, right associativity) :
11 category_theory_scope.
12
13 Notation "x → y" := (x -> y)
14 (at level 99, y at level 200, right associativity): category_theory_scope.
15 Notation "x ↔ y" := (iffT x y)
16 (at level 95, no associativity) : category_theory_scope.
17
18 Infix "∧" := prod (at level 80, right associativity) : category_theory_scope.
19
20 Notation "'λ' x .. y , t" := (fun x => .. (fun y => t) ..)
21 (at level 200, x binder, y binder, right associativity) :
22 category_theory_scope.
23 Set Universe Polymorphism.
24
25 Class Setoid A := {
26 equiv : crelation A;
27 setoid_equiv : Equivalence equiv
28 }.
29 #[export] Existing Instance setoid_equiv.
30
31 Notation "f ≈ g" := (equiv f g) (at level 79) : category_theory_scope.
32
33 Reserved Infix "~>" (at level 90, right associativity).
34
35 Class Category@{o h p | h <= p} : Type@{max(o+1,h+1,p+1)} := {
36 obj : Type@{o};
37
38 hom : obj → obj → Type@{h} where "a ~> b" := (hom a b);
39 homset : ∀ X Y, Setoid@{h p} (X ~> Y);
40
41 id {x} : x ~> x;
42 compose {x y z} (f: y ~> z) (g : x ~> y) : x ~> z
43 where "f ∘ g" := (compose f g);
44
45 compose_respects {x y z} :
46 Proper@{h p} (respectful@{h p h p h p} equiv
47 (respectful@{h p h p h p} equiv equiv))
48 (@compose x y z);
49
50 id_left {x y} (f : x ~> y) : id ∘ f ≈ f;
51 id_right {x y} (f : x ~> y) : f ∘ id ≈ f;
52
53 }.
54 #[export] Existing Instance homset.
55 #[export] Existing Instance compose_respects.
56
57 Delimit Scope category_scope with category.
58 Delimit Scope object_scope with object.
59 Delimit Scope morphism_scope with morphism.
60
61 Notation "x ~> y" := (@hom _%category x%object y%object)
62 (at level 90, right associativity) : homset_scope.
63
64 Notation "f ∘ g" :=
65 (@compose _%category _%object _%object _%object f%morphism g%morphism)
66 : morphism_scope.
67
68 Coercion obj : Category >-> Sortclass.
69
70 #[export] Hint Rewrite @id_left : categories.
71 #[export] Hint Rewrite @id_right : categories.
72 Open Scope homset_scope.
73 Open Scope morphism_scope.
74
75 Class Functor@{o1 h1 p1 o2 h2 p2}
76 {C : Category@{o1 h1 p1}} {D : Category@{o2 h2 p2}} := {
77 fobj : C → D;
78 fmap {x y : C} (f : x ~> y) : fobj x ~> fobj y;
79
80 fmap_id {x : C} : fmap (@id C x) ≈ id;
81 }.
82 Declare Scope functor_type_scope.
83 Delimit Scope functor_scope with functor.
84 Open Scope functor_type_scope.
85
86 Coercion fobj : Functor >-> Funclass.
87
88 Notation "C ⟶ D" := (@Functor C%category D%category)
89 (at level 90, right associativity) : functor_type_scope.
90 Notation "fmap[ F ]" := (@fmap _ _ F%functor _ _)
91 (at level 9, format "fmap[ F ]") : morphism_scope.
92
93 #[export] Hint Rewrite @fmap_id : categories.
94
95 Generalizable All Variables.
96
97 Section Transform.
98
99 Universes o1 h1 p1 o2 h2 p2.
100 Context {C : Category@{o1 h1 p2}}.
101 Context {D : Category@{o2 h2 p2}}.
102 Context {F : C ⟶ D}.
103 Context {G : C ⟶ D}.
104
105 Class Transform := {
106 transform {x} : F x ~> G x;
107
108 naturality {x y} (f : x ~> y) :
109 fmap[G] f ∘ transform ≈ transform ∘ fmap[F] f;
110
111 naturality_sym {x y} (f : x ~> y) :
112 transform ∘ fmap[F] f ≈ fmap[G] f ∘ transform
113 }.
114
115 End Transform.
116
117 #[export] Hint Extern 4 (equiv ?A ?A) => reflexivity : category_laws.
118
119 Ltac cat :=
120 autorewrite with categories;
121 auto with category_laws.
122
123 Ltac cat_simpl :=
124 intros;
125 simpl in *; cat.
126
127 #[global] Obligation Tactic := idtac.
128
129 Program Definition nat_id `{F : C ⟶ D} : @Transform _ _ F F :=
130 {| transform := λ X, fmap (@id C X) |}.
131
132 Solve Obligations with cat_simpl.