1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "logic/cprop_connectives.ma".
17 record equivalence_relation (A:Type) : Type ≝
18 { eq_rel:2> A → A → CProp;
19 refl: reflexive ? eq_rel;
20 sym: symmetric ? eq_rel;
21 trans: transitive ? eq_rel
24 record setoid : Type ≝
26 eq: equivalence_relation carr
29 definition reflexive1 ≝ λA:Type.λR:A→A→CProp.∀x:A.R x x.
30 definition symmetric1 ≝ λC:Type.λlt:C→C→CProp. ∀x,y:C.lt x y → lt y x.
31 definition transitive1 ≝ λA:Type.λR:A→A→CProp.∀x,y,z:A.R x y → R y z → R x z.
33 record equivalence_relation1 (A:Type) : Type ≝
34 { eq_rel1:2> A → A → CProp;
35 refl1: reflexive1 ? eq_rel1;
36 sym1: symmetric1 ? eq_rel1;
37 trans1: transitive1 ? eq_rel1
40 record setoid1: Type ≝
42 eq1: equivalence_relation1 carr1
45 definition setoid1_of_setoid: setoid → setoid1.
57 coercion setoid1_of_setoid.
60 definition Leibniz: Type → setoid.
65 [ apply (λx,y:T.cic:/matita/logic/equality/eq.ind#xpointer(1/1) ? x y)
66 | alias id "refl_eq" = "cic:/matita/logic/equality/eq.ind#xpointer(1/1/1)".
68 | alias id "sym_eq" = "cic:/matita/logic/equality/sym_eq.con".
70 | alias id "trans_eq" = "cic:/matita/logic/equality/trans_eq.con".
77 interpretation "setoid1 eq" 'eq x y = (eq_rel1 _ (eq1 _) x y).
78 interpretation "setoid eq" 'eq x y = (eq_rel _ (eq _) x y).
79 interpretation "setoid1 symmetry" 'invert r = (sym1 ____ r).
80 interpretation "setoid symmetry" 'invert r = (sym ____ r).
81 notation ".= r" with precedence 50 for @{'trans $r}.
82 interpretation "trans1" 'trans r = (trans1 _____ r).
83 interpretation "trans" 'trans r = (trans _____ r).
85 record unary_morphism (A,B: setoid1) : Type ≝
87 prop_1: ∀a,a'. eq1 ? a a' → eq1 ? (fun_1 a) (fun_1 a')
90 record binary_morphism (A,B,C:setoid) : Type ≝
92 prop: ∀a,a',b,b'. eq ? a a' → eq ? b b' → eq ? (fun a b) (fun a' b')
95 record binary_morphism1 (A,B,C:setoid1) : Type ≝
97 prop1: ∀a,a',b,b'. eq1 ? a a' → eq1 ? b b' → eq1 ? (fun1 a b) (fun1 a' b')
100 notation "hbox(a break ⇒ b)" right associative with precedence 20 for @{ 'Imply $a $b }.
101 interpretation "unary morphism" 'Imply a b = (unary_morphism a b).
103 notation "† c" with precedence 90 for @{'prop1 $c }.
104 notation "l ‡ r" with precedence 90 for @{'prop $l $r }.
105 notation "#" with precedence 90 for @{'refl}.
106 interpretation "prop_1" 'prop1 c = (prop_1 _____ c).
107 interpretation "prop1" 'prop l r = (prop1 ________ l r).
108 interpretation "prop" 'prop l r = (prop ________ l r).
109 interpretation "refl1" 'refl = (refl1 ___).
110 interpretation "refl" 'refl = (refl ___).
112 definition CPROP: setoid1.
117 | intros 1; split; intro; assumption
118 | intros 3; cases H; split; assumption
119 | intros 5; cases H; cases H1; split; intro;
120 [ apply (H4 (H2 H6)) | apply (H3 (H5 H6))]]]
123 definition if': ∀A,B:CPROP. A = B → A → B.
124 intros; apply (if ?? H); assumption.
127 notation ". r" with precedence 50 for @{'if $r}.
128 interpretation "if" 'if r = (if' __ r).
130 definition and_morphism: binary_morphism1 CPROP CPROP CPROP.
133 | intros; split; intro; cases H2; split;
135 | apply (if ?? H1 b1)
137 | apply (fi ?? H1 b1)]]
140 interpretation "and_morphism" 'and a b = (fun1 ___ and_morphism a b).
142 definition or_morphism: binary_morphism1 CPROP CPROP CPROP.
145 | intros; split; intro; cases H2; [1,3:left |2,4: right]
148 | apply (if ?? H1 b1)
149 | apply (fi ?? H1 b1)]]
152 interpretation "or_morphism" 'or a b = (fun1 ___ or_morphism a b).
154 definition if_morphism: binary_morphism1 CPROP CPROP CPROP.
156 [ apply (λA,B. A → B)
157 | intros; split; intros;
158 [ apply (if ?? H1); apply H2; apply (fi ?? H); assumption
159 | apply (fi ?? H1); apply H2; apply (if ?? H); assumption]]
163 definition eq_morphism: ∀S:setoid. binary_morphism S S CPROP.
166 [ apply (eq_rel ? (eq S))
167 | intros; split; intro;
168 [ apply (.= H \sup -1);
177 record category : Type ≝
179 arrows: objs → objs → setoid;
180 id: ∀o:objs. arrows o o;
181 comp: ∀o1,o2,o3. binary_morphism (arrows o1 o2) (arrows o2 o3) (arrows o1 o3);
182 comp_assoc: ∀o1,o2,o3,o4. ∀a12,a23,a34.
183 comp o1 o3 o4 (comp o1 o2 o3 a12 a23) a34 = comp o1 o2 o4 a12 (comp o2 o3 o4 a23 a34);
184 id_neutral_left: ∀o1,o2. ∀a: arrows o1 o2. comp ??? (id o1) a = a;
185 id_neutral_right: ∀o1,o2. ∀a: arrows o1 o2. comp ??? a (id o2) = a
188 record category1 : Type ≝
190 arrows1: objs1 → objs1 → setoid1;
191 id1: ∀o:objs1. arrows1 o o;
192 comp1: ∀o1,o2,o3. binary_morphism1 (arrows1 o1 o2) (arrows1 o2 o3) (arrows1 o1 o3);
193 comp_assoc1: ∀o1,o2,o3,o4. ∀a12,a23,a34.
194 comp1 o1 o3 o4 (comp1 o1 o2 o3 a12 a23) a34 = comp1 o1 o2 o4 a12 (comp1 o2 o3 o4 a23 a34);
195 id_neutral_right1: ∀o1,o2. ∀a: arrows1 o1 o2. comp1 ??? (id1 o1) a = a;
196 id_neutral_left1: ∀o1,o2. ∀a: arrows1 o1 o2. comp1 ??? a (id1 o2) = a
199 notation "'ASSOC'" with precedence 90 for @{'assoc}.
200 notation "'ASSOC1'" with precedence 90 for @{'assoc1}.
202 interpretation "category1 composition" 'compose x y = (fun1 ___ (comp1 ____) y x).
203 interpretation "category1 assoc" 'assoc1 = (comp_assoc1 ________).
204 interpretation "category composition" 'compose x y = (fun ___ (comp ____) y x).
205 interpretation "category assoc" 'assoc = (comp_assoc ________).