-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFunctorIsomorphisms.v
182 lines (148 loc) · 7.27 KB
/
FunctorIsomorphisms.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
Require Import Setoid.
Require Export Functor CategoryIsomorphisms.
Require Import Common.
Set Implicit Arguments.
Generalizable All Variables.
Set Asymmetric Patterns.
Set Universe Polymorphism.
Local Open Scope category_scope.
Section FunctorIsomorphism.
(* Copy definitions from CategoryIsomorphisms.v *)
Section FunctorIsInverseOf.
Context `{C : @SpecializedCategory objC}.
Context `{D : @SpecializedCategory objD}.
Definition FunctorIsInverseOf1 (F : SpecializedFunctor C D) (G : SpecializedFunctor D C) : Prop :=
ComposeFunctors G F = IdentityFunctor C.
Definition FunctorIsInverseOf2 (F : SpecializedFunctor C D) (G : SpecializedFunctor D C) : Prop :=
ComposeFunctors F G = IdentityFunctor D.
Global Arguments FunctorIsInverseOf1 / _ _.
Global Arguments FunctorIsInverseOf2 / _ _.
Definition FunctorIsInverseOf (F : SpecializedFunctor C D) (G : SpecializedFunctor D C) : Prop := Eval simpl in
FunctorIsInverseOf1 F G /\ FunctorIsInverseOf2 F G.
End FunctorIsInverseOf.
Lemma FunctorIsInverseOf_sym `{C : @SpecializedCategory objC} `{D : @SpecializedCategory objD}
(F : SpecializedFunctor C D) (G : SpecializedFunctor D C) :
FunctorIsInverseOf F G -> FunctorIsInverseOf G F.
intros; hnf in *; split_and; split; trivial.
Qed.
Section FunctorIsomorphismOf.
Record FunctorIsomorphismOf `{C : @SpecializedCategory objC} `{D : @SpecializedCategory objD} (F : SpecializedFunctor C D) := {
FunctorIsomorphismOf_Functor :> _ := F;
InverseFunctor : SpecializedFunctor D C;
LeftInverseFunctor : ComposeFunctors InverseFunctor F = IdentityFunctor C;
RightInverseFunctor : ComposeFunctors F InverseFunctor = IdentityFunctor D
}.
Hint Resolve RightInverseFunctor LeftInverseFunctor : category.
Hint Resolve RightInverseFunctor LeftInverseFunctor : functor.
Definition FunctorIsomorphismOf_Identity `(C : @SpecializedCategory objC) : FunctorIsomorphismOf (IdentityFunctor C).
exists (IdentityFunctor _); eauto with functor.
Defined.
Definition InverseOfFunctor `{C : @SpecializedCategory objC} `{D : @SpecializedCategory objD} (F : SpecializedFunctor C D)
(i : FunctorIsomorphismOf F) : FunctorIsomorphismOf (InverseFunctor i).
exists i; auto with functor.
Defined.
Definition ComposeFunctorIsmorphismOf `{C : @SpecializedCategory objC} `{D : @SpecializedCategory objD} `{E : @SpecializedCategory objE}
{F : SpecializedFunctor D E} {G : SpecializedFunctor C D} (i1 : FunctorIsomorphismOf F) (i2 : FunctorIsomorphismOf G) :
FunctorIsomorphismOf (ComposeFunctors F G).
exists (ComposeFunctors (InverseFunctor i2) (InverseFunctor i1));
abstract (
match goal with
| [ |- context[ComposeFunctors (ComposeFunctors ?F ?G) (ComposeFunctors ?H ?I)] ] =>
transitivity (ComposeFunctors (ComposeFunctors F (ComposeFunctors G H)) I);
try solve [ repeat rewrite ComposeFunctorsAssociativity; reflexivity ]; []
end;
destruct i1, i2; simpl;
repeat (rewrite_hyp; autorewrite with functor);
trivial
).
Defined.
End FunctorIsomorphismOf.
Section IsomorphismOfCategories.
Record IsomorphismOfCategories `(C : @SpecializedCategory objC) `(D : @SpecializedCategory objD) := {
IsomorphismOfCategories_Functor : SpecializedFunctor C D;
IsomorphismOfCategories_Of :> FunctorIsomorphismOf IsomorphismOfCategories_Functor
}.
Global Coercion Build_IsomorphismOfCategories : FunctorIsomorphismOf >-> IsomorphismOfCategories.
End IsomorphismOfCategories.
Section FunctorIsIsomorphism.
Definition FunctorIsIsomorphism `{C : @SpecializedCategory objC} `{D : @SpecializedCategory objD} (F : SpecializedFunctor C D) : Prop :=
exists G, FunctorIsInverseOf F G.
Lemma FunctorIsmorphismOf_FunctorIsIsomorphism `{C : @SpecializedCategory objC} `{D : @SpecializedCategory objD} (F : SpecializedFunctor C D) :
FunctorIsomorphismOf F -> FunctorIsIsomorphism F.
intro i; hnf.
exists (InverseFunctor i);
destruct i; simpl;
split;
assumption.
Qed.
Lemma FunctorIsIsomorphism_FunctorIsmorphismOf `{C : @SpecializedCategory objC} `{D : @SpecializedCategory objD} (F : SpecializedFunctor C D) :
FunctorIsIsomorphism F -> exists _ : FunctorIsomorphismOf F, True.
intro i; destruct_hypotheses.
destruct_exists; trivial.
eexists; eassumption.
Qed.
End FunctorIsIsomorphism.
Section CategoriesIsomorphic.
Definition CategoriesIsomorphic (C D : Category) : Prop :=
exists (F : SpecializedFunctor C D) (G : SpecializedFunctor D C), FunctorIsInverseOf F G.
Lemma IsmorphismOfCategories_CategoriesIsomorphic `(C : @SpecializedCategory objC) `(D : @SpecializedCategory objD) :
IsomorphismOfCategories C D -> CategoriesIsomorphic C D.
intro i; destruct i as [ m i ].
exists m.
apply FunctorIsmorphismOf_FunctorIsIsomorphism; assumption.
Qed.
Lemma CategoriesIsomorphic_IsomorphismOfCategories (C D : Category) :
CategoriesIsomorphic C D -> exists _ : IsomorphismOfCategories C D, True.
intro i; destruct_hypotheses.
destruct_exists; trivial.
repeat esplit; eassumption.
Qed.
Local Ltac t_iso' := intros;
repeat match goal with
| [ i : CategoriesIsomorphic _ _ |- _ ] => destruct (CategoriesIsomorphic_IsomorphismOfCategories i) as [ ? [] ] ; clear i
| [ |- CategoriesIsomorphic _ _ ] => apply IsmorphismOfCategories_CategoriesIsomorphic
end.
Local Ltac t_iso:= t_iso';
repeat match goal with
| [ i : IsomorphismOfCategories _ _ |- _ ] => unique_pose (IsomorphismOfCategories_Of i); try clear i
| [ |- IsomorphismOfCategories _ _ ] => eapply Build_IsomorphismOfCategories
end.
Lemma CategoriesIsomorphic_refl (C : Category) : CategoriesIsomorphic C C.
t_iso.
apply FunctorIsomorphismOf_Identity.
Qed.
Lemma CategoriesIsomorphic_sym (C D : Category) :
CategoriesIsomorphic C D -> CategoriesIsomorphic D C.
t_iso.
eapply InverseOfFunctor.
Grab Existential Variables.
eauto.
Qed.
Lemma CategoriesIsomorphic_trans (C D E : Category) :
CategoriesIsomorphic C D -> CategoriesIsomorphic D E -> CategoriesIsomorphic C E.
t_iso.
apply @ComposeFunctorIsmorphismOf;
eauto.
Qed.
Global Add Parametric Relation : _ @CategoriesIsomorphic
reflexivity proved by @CategoriesIsomorphic_refl
symmetry proved by @CategoriesIsomorphic_sym
transitivity proved by @CategoriesIsomorphic_trans
as CategoriesIsomorphic_rel.
End CategoriesIsomorphic.
End FunctorIsomorphism.
Section Functor_preserves_isomorphism.
Context `(C : SpecializedCategory objC).
Context `(D : SpecializedCategory objD).
Variable F : SpecializedFunctor C D.
Hint Rewrite <- FCompositionOf : functor.
Definition MorphismOf_IsomorphismOf s d (m : Morphism C s d) (i : IsomorphismOf m) : IsomorphismOf (F.(MorphismOf) m).
refine {| Inverse := (F.(MorphismOf) (Inverse i)) |};
abstract (
destruct i; simpl;
repeat (rewrite_hyp; autorewrite with functor);
reflexivity
).
Defined.
End Functor_preserves_isomorphism.
Hint Resolve @MorphismOf_IsomorphismOf : category functor.