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