]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/library/formal_topology/categories.ma
Preparing for 0.5.9 release.
[helm.git] / helm / software / matita / library / formal_topology / categories.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "formal_topology/cprop_connectives.ma".
16
17 notation "hvbox(a break = \sub \ID b)" non associative with precedence 45
18 for @{ 'eqID $a $b }.
19
20 notation > "hvbox(a break =_\ID b)" non associative with precedence 45
21 for @{ cic:/matita/logic/equality/eq.ind#xpointer(1/1) ? $a $b }.
22
23 interpretation "ID eq" 'eqID x y = (cic:/matita/logic/equality/eq.ind#xpointer(1/1) ? x y).
24
25 record equivalence_relation (A:Type0) : Type1 ≝
26  { eq_rel:2> A → A → CProp0;
27    refl: reflexive ? eq_rel;
28    sym: symmetric ? eq_rel;
29    trans: transitive ? eq_rel
30  }.
31
32 record setoid : Type1 ≝
33  { carr:> Type0;
34    eq: equivalence_relation carr
35  }.
36
37 record equivalence_relation1 (A:Type1) : Type2 ≝
38  { eq_rel1:2> A → A → CProp1;
39    refl1: reflexive1 ? eq_rel1;
40    sym1: symmetric1 ? eq_rel1;
41    trans1: transitive1 ? eq_rel1
42  }.
43
44 record setoid1: Type2 ≝
45  { carr1:> Type1;
46    eq1: equivalence_relation1 carr1
47  }.
48
49 definition setoid1_of_setoid: setoid → setoid1.
50  intro;
51  constructor 1;
52   [ apply (carr s)
53   | constructor 1;
54     [ apply (eq_rel s);
55       apply (eq s)
56     | apply (refl s)
57     | apply (sym s)
58     | apply (trans s)]]
59 qed.
60
61 coercion setoid1_of_setoid.
62 prefer coercion Type_OF_setoid.
63
64 record equivalence_relation2 (A:Type2) : Type3 ≝
65  { eq_rel2:2> A → A → CProp2;
66    refl2: reflexive2 ? eq_rel2;
67    sym2: symmetric2 ? eq_rel2;
68    trans2: transitive2 ? eq_rel2
69  }.
70
71 record setoid2: Type3 ≝
72  { carr2:> Type2;
73    eq2: equivalence_relation2 carr2
74  }.
75
76 definition setoid2_of_setoid1: setoid1 → setoid2.
77  intro;
78  constructor 1;
79   [ apply (carr1 s)
80   | constructor 1;
81     [ apply (eq_rel1 s);
82       apply (eq1 s)
83     | apply (refl1 s)
84     | apply (sym1 s)
85     | apply (trans1 s)]]
86 qed.
87
88 coercion setoid2_of_setoid1.
89 prefer coercion Type_OF_setoid2. 
90 prefer coercion Type_OF_setoid. 
91 prefer coercion Type_OF_setoid1.
92 (* we prefer 0 < 1 < 2 *)
93
94 record equivalence_relation3 (A:Type3) : Type4 ≝
95  { eq_rel3:2> A → A → CProp3;
96    refl3: reflexive3 ? eq_rel3;
97    sym3: symmetric3 ? eq_rel3;
98    trans3: transitive3 ? eq_rel3
99  }.
100
101 record setoid3: Type4 ≝
102  { carr3:> Type3;
103    eq3: equivalence_relation3 carr3
104  }.
105
106 interpretation "setoid3 eq" 'eq t x y = (eq_rel3 ? (eq3 t) x y).
107 interpretation "setoid2 eq" 'eq t x y = (eq_rel2 ? (eq2 t) x y).
108 interpretation "setoid1 eq" 'eq t x y = (eq_rel1 ? (eq1 t) x y).
109 interpretation "setoid eq" 'eq t x y = (eq_rel ? (eq t) x y).
110
111 notation > "hvbox(a break =_12 b)" non associative with precedence 45
112 for @{ eq_rel2 (carr2 (setoid2_of_setoid1 ?)) (eq2 (setoid2_of_setoid1 ?)) $a $b }.
113 notation > "hvbox(a break =_0 b)" non associative with precedence 45
114 for @{ eq_rel ? (eq ?) $a $b }.
115 notation > "hvbox(a break =_1 b)" non associative with precedence 45
116 for @{ eq_rel1 ? (eq1 ?) $a $b }.
117 notation > "hvbox(a break =_2 b)" non associative with precedence 45
118 for @{ eq_rel2 ? (eq2 ?) $a $b }.
119 notation > "hvbox(a break =_3 b)" non associative with precedence 45
120 for @{ eq_rel3 ? (eq3 ?) $a $b }.
121
122 interpretation "setoid3 symmetry" 'invert r = (sym3 ???? r).
123 interpretation "setoid2 symmetry" 'invert r = (sym2 ???? r).
124 interpretation "setoid1 symmetry" 'invert r = (sym1 ???? r).
125 interpretation "setoid symmetry" 'invert r = (sym ???? r).
126 notation ".= r" with precedence 50 for @{'trans $r}.
127 interpretation "trans3" 'trans r = (trans3 ????? r).
128 interpretation "trans2" 'trans r = (trans2 ????? r).
129 interpretation "trans1" 'trans r = (trans1 ????? r).
130 interpretation "trans" 'trans r = (trans ????? r).
131
132 record unary_morphism (A,B: setoid) : Type0 ≝
133  { fun1:1> A → B;
134    prop1: ∀a,a'. eq ? a a' → eq ? (fun1 a) (fun1 a')
135  }.
136
137 record unary_morphism1 (A,B: setoid1) : Type1 ≝
138  { fun11:1> A → B;
139    prop11: ∀a,a'. eq1 ? a a' → eq1 ? (fun11 a) (fun11 a')
140  }.
141
142 record unary_morphism2 (A,B: setoid2) : Type2 ≝
143  { fun12:1> A → B;
144    prop12: ∀a,a'. eq2 ? a a' → eq2 ? (fun12 a) (fun12 a')
145  }.
146
147 record unary_morphism3 (A,B: setoid3) : Type3 ≝
148  { fun13:1> A → B;
149    prop13: ∀a,a'. eq3 ? a a' → eq3 ? (fun13 a) (fun13 a')
150  }.
151
152 record binary_morphism (A,B,C:setoid) : Type0 ≝
153  { fun2:2> A → B → C;
154    prop2: ∀a,a',b,b'. eq ? a a' → eq ? b b' → eq ? (fun2 a b) (fun2 a' b')
155  }.
156
157 record binary_morphism1 (A,B,C:setoid1) : Type1 ≝
158  { fun21:2> A → B → C;
159    prop21: ∀a,a',b,b'. eq1 ? a a' → eq1 ? b b' → eq1 ? (fun21 a b) (fun21 a' b')
160  }.
161
162 record binary_morphism2 (A,B,C:setoid2) : Type2 ≝
163  { fun22:2> A → B → C;
164    prop22: ∀a,a',b,b'. eq2 ? a a' → eq2 ? b b' → eq2 ? (fun22 a b) (fun22 a' b')
165  }.
166
167 record binary_morphism3 (A,B,C:setoid3) : Type3 ≝
168  { fun23:2> A → B → C;
169    prop23: ∀a,a',b,b'. eq3 ? a a' → eq3 ? b b' → eq3 ? (fun23 a b) (fun23 a' b')
170  }.
171
172 notation "† c" with precedence 90 for @{'prop1 $c }.
173 notation "l ‡ r" with precedence 90 for @{'prop2 $l $r }.
174 notation "#" with precedence 90 for @{'refl}.
175 interpretation "prop1" 'prop1 c  = (prop1 ????? c).
176 interpretation "prop11" 'prop1 c = (prop11 ????? c).
177 interpretation "prop12" 'prop1 c = (prop12 ????? c).
178 interpretation "prop13" 'prop1 c = (prop13 ????? c).
179 interpretation "prop2" 'prop2 l r = (prop2 ???????? l r).
180 interpretation "prop21" 'prop2 l r = (prop21 ???????? l r).
181 interpretation "prop22" 'prop2 l r = (prop22 ???????? l r).
182 interpretation "prop23" 'prop2 l r = (prop23 ???????? l r).
183 interpretation "refl" 'refl = (refl ???).
184 interpretation "refl1" 'refl = (refl1 ???).
185 interpretation "refl2" 'refl = (refl2 ???).
186 interpretation "refl3" 'refl = (refl3 ???).
187
188 notation > "A × term 74 B ⇒ term 19 C" non associative with precedence 72 for @{'binary_morphism0 $A $B $C}.
189 notation > "A × term 74 B ⇒_1 term 19 C" non associative with precedence 72 for @{'binary_morphism1 $A $B $C}.
190 notation > "A × term 74 B ⇒_2 term 19 C" non associative with precedence 72 for @{'binary_morphism2 $A $B $C}.
191 notation > "A × term 74 B ⇒_3 term 19 C" non associative with precedence 72 for @{'binary_morphism3 $A $B $C}.
192 notation > "B ⇒_1 C" right associative with precedence 72 for @{'arrows1_SET $B $C}.
193 notation > "B ⇒_1. C" right associative with precedence 72 for @{'arrows1_SETlow $B $C}.
194 notation > "B ⇒_2 C" right associative with precedence 72 for @{'arrows2_SET1 $B $C}.
195 notation > "B ⇒_2. C" right associative with precedence 72 for @{'arrows2_SET1low $B $C}.
196
197 notation "A × term 74 B ⇒ term 19 C" non associative with precedence 72 for @{'binary_morphism0 $A $B $C}.
198 notation "A × term 74 B ⇒\sub 1 term 19 C" non associative with precedence 72 for @{'binary_morphism1 $A $B $C}.
199 notation "A × term 74 B ⇒\sub 2 term 19 C" non associative with precedence 72 for @{'binary_morphism2 $A $B $C}.
200 notation "A × term 74 B ⇒\sub 3 term 19 C" non associative with precedence 72 for @{'binary_morphism3 $A $B $C}.
201 notation "B ⇒\sub 1 C" right associative with precedence 72 for @{'arrows1_SET $B $C}.
202 notation "B ⇒\sub 2 C" right associative with precedence 72 for @{'arrows2_SET1 $B $C}.
203 notation "B ⇒\sub 1. C" right associative with precedence 72 for @{'arrows1_SETlow $B $C}.
204 notation "B ⇒\sub 2. C" right associative with precedence 72 for @{'arrows2_SET1low $B $C}.
205
206 interpretation "'binary_morphism0" 'binary_morphism0 A B C = (binary_morphism A B C).
207 interpretation "'arrows2_SET1 low" 'arrows2_SET1 A B = (unary_morphism2 A B).
208 interpretation "'arrows2_SET1low" 'arrows2_SET1low A B = (unary_morphism2 A B).
209 interpretation "'binary_morphism1" 'binary_morphism1 A B C = (binary_morphism1 A B C).
210 interpretation "'binary_morphism2" 'binary_morphism2 A B C = (binary_morphism2 A B C).
211 interpretation "'binary_morphism3" 'binary_morphism3 A B C = (binary_morphism3 A B C).
212 interpretation "'arrows1_SET low" 'arrows1_SET A B = (unary_morphism1 A B).
213 interpretation "'arrows1_SETlow" 'arrows1_SETlow A B = (unary_morphism1 A B).
214
215
216 definition unary_morphism2_of_unary_morphism1: 
217   ∀S,T:setoid1.unary_morphism1 S T → unary_morphism2 (setoid2_of_setoid1 S) T.
218  intros;
219  constructor 1;
220   [ apply (fun11 ?? u);
221   | apply (prop11 ?? u); ]
222 qed.
223
224 definition CPROP: setoid1.
225  constructor 1;
226   [ apply CProp0
227   | constructor 1;
228      [ apply Iff
229      | intros 1; split; intro; assumption
230      | intros 3; cases i; split; assumption
231      | intros 5; cases i; cases i1; split; intro;
232         [ apply (f2 (f x1)) | apply (f1 (f3 z1))]]]
233 qed.
234
235 definition CProp0_of_CPROP: carr1 CPROP → CProp0 ≝ λx.x.
236 coercion CProp0_of_CPROP.
237
238 alias symbol "eq" = "setoid1 eq".
239 definition fi': ∀A,B:CPROP. A = B → B → A.
240  intros; apply (fi ?? e); assumption.
241 qed.
242
243 notation ". r" with precedence 50 for @{'fi $r}.
244 interpretation "fi" 'fi r = (fi' ?? r).
245
246 definition and_morphism: binary_morphism1 CPROP CPROP CPROP.
247  constructor 1;
248   [ apply And
249   | intros; split; intro; cases a1; split;
250      [ apply (if ?? e a2)
251      | apply (if ?? e1 b1)
252      | apply (fi ?? e a2)
253      | apply (fi ?? e1 b1)]]
254 qed.
255
256 interpretation "and_morphism" 'and a b = (fun21 ??? and_morphism a b).
257
258 definition or_morphism: binary_morphism1 CPROP CPROP CPROP.
259  constructor 1;
260   [ apply Or
261   | intros; split; intro; cases o; [1,3:left |2,4: right]
262      [ apply (if ?? e a1)
263      | apply (fi ?? e a1)
264      | apply (if ?? e1 b1)
265      | apply (fi ?? e1 b1)]]
266 qed.
267
268 interpretation "or_morphism" 'or a b = (fun21 ??? or_morphism a b).
269
270 definition if_morphism: binary_morphism1 CPROP CPROP CPROP.
271  constructor 1;
272   [ apply (λA,B. A → B)
273   | intros; split; intros;
274      [ apply (if ?? e1); apply f; apply (fi ?? e); assumption
275      | apply (fi ?? e1); apply f; apply (if ?? e); assumption]]
276 qed.
277
278 notation > "hvbox(a break ∘ b)" left associative with precedence 55 for @{ comp ??? $a $b }.
279 record category : Type1 ≝ { 
280    objs:> Type0;
281    arrows: objs → objs → setoid;
282    id: ∀o:objs. arrows o o;
283    comp: ∀o1,o2,o3. (arrows o1 o2) × (arrows o2 o3) ⇒ (arrows o1 o3);
284    comp_assoc: ∀o1,o2,o3,o4.∀a12:arrows o1 ?.∀a23:arrows o2 ?.∀a34:arrows o3 o4.
285      (a12 ∘ a23) ∘ a34 =_0 a12 ∘ (a23 ∘ a34);
286    id_neutral_left : ∀o1,o2. ∀a: arrows o1 o2. (id o1) ∘ a =_0 a;
287    id_neutral_right: ∀o1,o2. ∀a: arrows o1 o2. a ∘ (id o2) =_0 a
288 }.
289 notation "hvbox(a break ∘ b)" left associative with precedence 55 for @{ 'compose $a $b }.
290
291 record category1 : Type2 ≝
292  { objs1:> Type1;
293    arrows1: objs1 → objs1 → setoid1;
294    id1: ∀o:objs1. arrows1 o o;
295    comp1: ∀o1,o2,o3. binary_morphism1 (arrows1 o1 o2) (arrows1 o2 o3) (arrows1 o1 o3);
296    comp_assoc1: ∀o1,o2,o3,o4. ∀a12,a23,a34.
297     comp1 o1 o3 o4 (comp1 o1 o2 o3 a12 a23) a34 =_1 comp1 o1 o2 o4 a12 (comp1 o2 o3 o4 a23 a34);
298    id_neutral_right1: ∀o1,o2. ∀a: arrows1 o1 o2. comp1 ??? (id1 o1) a =_1 a;
299    id_neutral_left1: ∀o1,o2. ∀a: arrows1 o1 o2. comp1 ??? a (id1 o2) =_1 a
300  }.
301
302 record category2 : Type3 ≝
303  { objs2:> Type2;
304    arrows2: objs2 → objs2 → setoid2;
305    id2: ∀o:objs2. arrows2 o o;
306    comp2: ∀o1,o2,o3. binary_morphism2 (arrows2 o1 o2) (arrows2 o2 o3) (arrows2 o1 o3);
307    comp_assoc2: ∀o1,o2,o3,o4. ∀a12,a23,a34.
308     comp2 o1 o3 o4 (comp2 o1 o2 o3 a12 a23) a34 =_2 comp2 o1 o2 o4 a12 (comp2 o2 o3 o4 a23 a34);
309    id_neutral_right2: ∀o1,o2. ∀a: arrows2 o1 o2. comp2 ??? (id2 o1) a =_2 a;
310    id_neutral_left2: ∀o1,o2. ∀a: arrows2 o1 o2. comp2 ??? a (id2 o2) =_2 a
311  }.
312
313 record category3 : Type4 ≝
314  { objs3:> Type3;
315    arrows3: objs3 → objs3 → setoid3;
316    id3: ∀o:objs3. arrows3 o o;
317    comp3: ∀o1,o2,o3. binary_morphism3 (arrows3 o1 o2) (arrows3 o2 o3) (arrows3 o1 o3);
318    comp_assoc3: ∀o1,o2,o3,o4. ∀a12,a23,a34.
319     comp3 o1 o3 o4 (comp3 o1 o2 o3 a12 a23) a34 =_3 comp3 o1 o2 o4 a12 (comp3 o2 o3 o4 a23 a34);
320    id_neutral_right3: ∀o1,o2. ∀a: arrows3 o1 o2. comp3 ??? (id3 o1) a =_3 a;
321    id_neutral_left3: ∀o1,o2. ∀a: arrows3 o1 o2. comp3 ??? a (id3 o2) =_3 a
322  }.
323
324 notation "'ASSOC'" with precedence 90 for @{'assoc}.
325
326 interpretation "category2 composition" 'compose x y = (fun22 ??? (comp2 ????) y x).
327 interpretation "category2 assoc" 'assoc = (comp_assoc2 ????????).
328 interpretation "category1 composition" 'compose x y = (fun21 ??? (comp1 ????) y x).
329 interpretation "category1 assoc" 'assoc = (comp_assoc1 ????????).
330 interpretation "category composition" 'compose x y = (fun2 ??? (comp ????) y x).
331 interpretation "category assoc" 'assoc = (comp_assoc ????????).
332
333 definition category2_of_category1: category1 → category2.
334  intro;
335  constructor 1;
336   [ apply (objs1 c);
337   | intros; apply (setoid2_of_setoid1 (arrows1 c o o1));
338   | apply (id1 c);
339   | intros;
340     constructor 1;
341      [ intros; apply (comp1 c o1 o2 o3 c1 c2);
342      | intros; unfold setoid2_of_setoid1 in e e1 a a' b b'; simplify in e e1 a a' b b'; 
343        change with ((b∘a) =_1 (b'∘a')); apply (e‡e1); ]
344   | intros; simplify; whd in a12 a23 a34; whd; apply rule (ASSOC);
345   | intros; simplify; whd in a; whd; apply id_neutral_right1;
346   | intros; simplify; whd in a; whd; apply id_neutral_left1; ]
347 qed.
348 (*coercion category2_of_category1.*)
349
350 record functor2 (C1: category2) (C2: category2) : Type3 ≝
351  { map_objs2:1> C1 → C2;
352    map_arrows2: ∀S,T. unary_morphism2 (arrows2 ? S T) (arrows2 ? (map_objs2 S) (map_objs2 T));
353    respects_id2: ∀o:C1. map_arrows2 ?? (id2 ? o) = id2 ? (map_objs2 o);
354    respects_comp2:
355      ∀o1,o2,o3.∀f1:arrows2 ? o1 o2.∀f2:arrows2 ? o2 o3.
356      map_arrows2 ?? (f2 ∘ f1) = map_arrows2 ?? f2 ∘ map_arrows2 ?? f1}.
357
358 notation > "F⎽⇒ x" left associative with precedence 60 for @{'map_arrows2 $F $x}.
359 notation "F\sub⇒ x" left associative with precedence 60 for @{'map_arrows2 $F $x}.
360 interpretation "map_arrows2" 'map_arrows2 F x = (fun12 ?? (map_arrows2 ?? F ??) x).
361
362 definition functor2_setoid: category2 → category2 → setoid3.
363  intros (C1 C2);
364  constructor 1;
365   [ apply (functor2 C1 C2);
366   | constructor 1;
367      [ intros (f g);
368        apply (∀c:C1. cic:/matita/logic/equality/eq.ind#xpointer(1/1) ? (f c) (g c));
369      | simplify; intros; apply cic:/matita/logic/equality/eq.ind#xpointer(1/1/1);
370      | simplify; intros; apply cic:/matita/logic/equality/sym_eq.con; apply H;
371      | simplify; intros; apply cic:/matita/logic/equality/trans_eq.con;
372         [2: apply H; | skip | apply H1;]]]
373 qed.
374
375 definition functor2_of_functor2_setoid: ∀S,T. functor2_setoid S T → functor2 S T ≝ λS,T,x.x.
376 coercion functor2_of_functor2_setoid.
377
378 definition CAT2: category3.
379  constructor 1;
380   [ apply category2;
381   | apply functor2_setoid;
382   | intros; constructor 1;
383      [ apply (λx.x);
384      | intros; constructor 1;
385         [ apply (λx.x);
386         | intros; assumption;]
387      | intros; apply rule #;
388      | intros; apply rule #; ]
389   | intros; constructor 1;
390      [ intros; constructor 1;
391         [ intros; apply (c1 (c o));
392         | intros; constructor 1;
393            [ intro; apply (map_arrows2 ?? c1 ?? (map_arrows2 ?? c ?? c2));
394            | intros; apply (††e); ]
395         | intros; simplify;
396           apply (.= †(respects_id2 : ?));
397           apply (respects_id2 : ?);
398         | intros; simplify;
399           apply (.= †(respects_comp2 : ?));
400           apply (respects_comp2 : ?); ]
401         | intros; intro; simplify;
402           apply (cic:/matita/logic/equality/eq_ind.con ????? (e ?));
403           apply (cic:/matita/logic/equality/eq_ind.con ????? (e1 ?));
404           constructor 1; ]
405         | intros; intro; simplify; constructor 1;
406         | intros; intro; simplify; constructor 1;
407         | intros; intro; simplify; constructor 1; ]
408 qed.
409
410 definition category2_of_objs3_CAT2: objs3 CAT2 → category2 ≝ λx.x.
411 coercion category2_of_objs3_CAT2.
412
413 definition functor2_setoid_of_arrows3_CAT2: ∀S,T. arrows3 CAT2 S T → functor2_setoid S T ≝ λS,T,x.x.
414 coercion functor2_setoid_of_arrows3_CAT2.
415
416 notation > "B ⇒_\c3 C" right associative with precedence 72 for @{'arrows3_CAT $B $C}.
417 notation "B ⇒\sub (\c 3) C" right associative with precedence 72 for @{'arrows3_CAT $B $C}.
418 interpretation "'arrows3_CAT" 'arrows3_CAT A B = (arrows3 CAT2 A B).
419
420 definition unary_morphism_setoid: setoid → setoid → setoid.
421  intros;
422  constructor 1;
423   [ apply (unary_morphism s s1);
424   | constructor 1;
425      [ intros (f g); apply (∀a:s. eq ? (f a) (g a));
426      | intros 1; simplify; intros; apply refl;
427      | simplify; intros; apply sym; apply f;
428      | simplify; intros; apply trans; [2: apply f; | skip | apply f1]]]
429 qed.
430
431 definition SET: category1.
432  constructor 1;
433   [ apply setoid;
434   | apply rule (λS,T:setoid.setoid1_of_setoid (unary_morphism_setoid S T));
435   | intros; constructor 1; [ apply (λx:carr o.x); | intros; assumption ]
436   | intros; constructor 1; [ intros; constructor 1; [ apply (λx. c1 (c x)); | intros;
437      apply († (†e));]
438   | intros; whd; intros; simplify; whd in H1; whd in H;
439     apply trans; [ apply (b (a' a1)); | lapply (prop1 ?? b (a a1) (a' a1));
440      [ apply Hletin | apply (e a1); ]  | apply e1; ]]
441   | intros; whd; intros; simplify; apply refl;
442   | intros; simplify; whd; intros; simplify; apply refl;
443   | intros; simplify; whd; intros; simplify; apply refl;
444   ]
445 qed.
446
447 definition setoid_of_SET: objs1 SET → setoid ≝ λx.x.
448 coercion setoid_of_SET.
449
450 definition unary_morphism_setoid_of_arrows1_SET: 
451   ∀P,Q.arrows1 SET P Q → unary_morphism_setoid P Q  ≝ λP,Q,x.x.
452 coercion unary_morphism_setoid_of_arrows1_SET.
453
454 interpretation "'arrows1_SET" 'arrows1_SET A B = (arrows1 SET A B).
455
456 definition unary_morphism1_setoid1: setoid1 → setoid1 → setoid1.
457  intros;
458  constructor 1;
459   [ apply (unary_morphism1 s s1);
460   | constructor 1;
461      [ intros (f g);
462        alias symbol "eq" = "setoid1 eq".
463        apply (∀a: carr1 s. f a = g a);
464      | intros 1; simplify; intros; apply refl1;
465      | simplify; intros; apply sym1; apply f;
466      | simplify; intros; apply trans1; [2: apply f; | skip | apply f1]]]
467 qed.
468
469 definition unary_morphism1_of_unary_morphism1_setoid1 : 
470   ∀S,T. unary_morphism1_setoid1 S T → unary_morphism1 S T ≝ λP,Q,x.x.
471 coercion unary_morphism1_of_unary_morphism1_setoid1.
472
473 definition SET1: objs3 CAT2.
474  constructor 1;
475   [ apply setoid1;
476   | apply rule (λS,T.setoid2_of_setoid1 (unary_morphism1_setoid1 S T));
477   | intros; constructor 1; [ apply (λx.x); | intros; assumption ]
478   | intros; constructor 1; [ intros; constructor 1; [ apply (λx. c1 (c x)); | intros;
479      apply († (†e));]
480   | intros; whd; intros; simplify; whd in H1; whd in H;
481     apply trans1; [ apply (b (a' a1)); | lapply (prop11 ?? b (a a1) (a' a1));
482      [ apply Hletin | apply (e a1); ]  | apply e1; ]]
483   | intros; whd; intros; simplify; apply refl1;
484   | intros; simplify; whd; intros; simplify; apply refl1;
485   | intros; simplify; whd; intros; simplify; apply refl1;
486   ]
487 qed.
488
489 interpretation "'arrows2_SET1" 'arrows2_SET1 A B = (arrows2 SET1 A B).
490
491 definition setoid1_of_SET1: objs2 SET1 → setoid1 ≝ λx.x.
492 coercion setoid1_of_SET1.
493
494 definition unary_morphism1_setoid1_of_arrows2_SET1: 
495   ∀P,Q.arrows2 SET1 P Q → unary_morphism1_setoid1 P Q ≝ λP,Q,x.x.
496 coercion unary_morphism1_setoid1_of_arrows2_SET1.
497  
498 variant objs2_of_category1: objs1 SET → objs2 SET1 ≝ setoid1_of_setoid.
499 coercion objs2_of_category1.
500
501 prefer coercion Type_OF_setoid. (* we prefer the lower carrier projection *)
502 prefer coercion Type_OF_objs1.
503
504 alias symbol "exists" (instance 1) = "CProp2 exists".
505 definition full2 ≝  
506   λA,B:CAT2.λF:carr3 (arrows3 CAT2 A B).
507     ∀o1,o2:A.∀f.∃g:arrows2 A o1 o2.F⎽⇒ g =_2 f.
508 alias symbol "exists" (instance 1) = "CProp exists".
509     
510 definition faithful2 ≝  
511   λA,B:CAT2.λF:carr3 (arrows3 CAT2 A B).
512     ∀o1,o2:A.∀f,g:arrows2 A o1 o2.F⎽⇒ f =_2 F⎽⇒ g → f =_2 g.
513     
514
515 notation "r \sup *" non associative with precedence 90 for @{'OR_f_star $r}.
516 notation > "r *" non associative with precedence 90 for @{'OR_f_star $r}.
517
518 notation "r \sup (⎻* )" non associative with precedence 90 for @{'OR_f_minus_star $r}.
519 notation > "r⎻*" non associative with precedence 90 for @{'OR_f_minus_star $r}.
520
521 notation "r \sup ⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
522 notation > "r⎻" non associative with precedence 90 for @{'OR_f_minus $r}.