]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/formal_topology/overlap/o-algebra.ma
bleah
[helm.git] / helm / software / matita / contribs / formal_topology / overlap / o-algebra.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 "datatypes/categories.ma".
16 include "logic/cprop_connectives.ma". 
17
18 inductive bool : Type := true : bool | false : bool.
19
20 <<<<<<< .mine
21 lemma BOOL : setoid.
22 =======
23 lemma BOOL : objs1 SET.
24 >>>>>>> .r9407
25 constructor 1; [apply bool] constructor 1;
26 [ intros (x y); apply (match x with [ true ⇒ match y with [ true ⇒ True | _ ⇒ False] | false ⇒ match y with [ true ⇒ False | false ⇒ True ]]);
27 | whd; simplify; intros; cases x; apply I;
28 | whd; simplify; intros 2; cases x; cases y; simplify; intros; assumption;
29 | whd; simplify; intros 3; cases x; cases y; cases z; simplify; intros; try assumption; apply I]
30 qed.
31
32 definition hint: objs1 SET → setoid.
33  intros; apply o;
34 qed.
35
36 coercion hint.
37
38 lemma IF_THEN_ELSE_p :
39   ∀S:setoid.∀a,b:S.∀x,y:BOOL.x = y → 
40     (λm.match m with [ true ⇒ a | false ⇒ b ]) x =
41     (λm.match m with [ true ⇒ a | false ⇒ b ]) y.
42 intros; cases x in H; cases y; simplify; intros; try apply refl; whd in H; cases H;
43 qed. 
44
45 <<<<<<< .mine
46 interpretation "unary morphism comprehension with no proof" 'comprehension T P = 
47 =======
48 lemma if_then_else : ∀T:SET. ∀a,b:T. arrows1 SET BOOL T.
49 intros; constructor 1; intros; 
50 [ apply (match c with [ true ⇒ t | false ⇒ t1 ]);
51 | apply (IF_THEN_ELSE_p T t t1 a a' H);]
52 qed.
53
54 interpretation "mk " 'comprehension T P = 
55 >>>>>>> .r9407
56   (mk_unary_morphism T _ P _).
57
58 notation > "hvbox({ ident i ∈ s | term 19 p | by })" with precedence 90
59 for @{ 'comprehension_by $s (λ${ident i}. $p) $by}.
60 notation < "hvbox({ ident i ∈ s | term 19 p })" with precedence 90
61 for @{ 'comprehension_by $s (λ${ident i}:$_. $p) $by}.
62
63 interpretation "unary morphism comprehension with proof" 'comprehension_by s \eta.f p = 
64   (mk_unary_morphism s _ f p).
65
66 <<<<<<< .mine
67 =======
68 definition A : ∀S:SET.∀a,b:S.arrows1 SET BOOL S.
69 apply (λS,a,b.{ x ∈ BOOL | match x with [ true ⇒ a | false ⇒ b] | IF_THEN_ELSE_p S a b}).
70 qed.
71
72 >>>>>>> .r9407
73 record OAlgebra : Type := {
74   oa_P :> SET;
75   oa_leq : binary_morphism1 oa_P oa_P CPROP; (* CPROP is setoid1 *)
76   oa_overlap: binary_morphism1 oa_P oa_P CPROP;
77 <<<<<<< .mine
78   oa_meet: ∀I:setoid.unary_morphism (unary_morphism_setoid I oa_P) oa_P;
79   oa_join: ∀I:setoid.unary_morphism (unary_morphism_setoid I oa_P) oa_P;
80 =======
81   oa_meet: ∀I:SET.unary_morphism (arrows1 SET I oa_P) oa_P;
82   oa_join: ∀I:SET.unary_morphism (arrows1 SET I oa_P) oa_P;
83 >>>>>>> .r9407
84   oa_one: oa_P;
85   oa_zero: oa_P;
86   oa_leq_refl: ∀a:oa_P. oa_leq a a; 
87   oa_leq_antisym: ∀a,b:oa_P.oa_leq a b → oa_leq b a → a = b;
88   oa_leq_trans: ∀a,b,c:oa_P.oa_leq a b → oa_leq b c → oa_leq a c;
89   oa_overlap_sym: ∀a,b:oa_P.oa_overlap a b → oa_overlap b a;
90   oa_meet_inf: ∀I.∀p_i.∀p:oa_P.oa_leq p (oa_meet I p_i) → ∀i:I.oa_leq p (p_i i);
91   oa_join_sup: ∀I.∀p_i.∀p:oa_P.oa_leq (oa_join I p_i) p → ∀i:I.oa_leq (p_i i) p;
92   oa_zero_bot: ∀p:oa_P.oa_leq oa_zero p;
93   oa_one_top: ∀p:oa_P.oa_leq p oa_one;
94   oa_overlap_preservers_meet: 
95       ∀p,q.oa_overlap p q → oa_overlap p 
96        (oa_meet ? { x ∈ BOOL | match x with [ true ⇒ p | false ⇒ q ] | IF_THEN_ELSE_p oa_P p q });
97 <<<<<<< .mine
98   oa_join_split:
99       ∀I:setoid.∀p.∀q:I ⇒  oa_P.oa_overlap p (oa_join I q) ⇔ ∃i:I.oa_overlap p (q i);
100   (*
101   oa_base : setoid;
102 =======
103      (*(oa_meet BOOL (if_then_else oa_P p q));*)
104   oa_join_split: (* ha I → oa_P da castare a funX (ums A oa_P) *)
105       ∀I:SET.∀p.∀q:arrows1 SET I oa_P.oa_overlap p (oa_join I q) ⇔ ∃i:I.oa_overlap p (q i);
106   (*oa_base : setoid;
107 >>>>>>> .r9407
108   oa_enum : ums oa_base oa_P;
109   oa_density: ∀p,q.(∀i.oa_overlap p (oa_enum i) → oa_overlap q (oa_enum i)) → oa_leq p q
110   *)
111   oa_density: 
112       ∀p,q.(∀r.oa_overlap p r → oa_overlap q r) → oa_leq p q
113 }.
114
115 interpretation "o-algebra leq" 'leq a b = (fun1 ___ (oa_leq _) a b).
116
117 notation "hovbox(a mpadded width -150% (>)< b)" non associative with precedence 45
118 for @{ 'overlap $a $b}.
119 interpretation "o-algebra overlap" 'overlap a b = (fun1 ___ (oa_overlap _) a b).
120
121 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (\emsp) \nbsp term 90 p)" 
122 non associative with precedence 50 for @{ 'oa_meet $p }.
123 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (ident i ∈  I) break term 90 p)" 
124 non associative with precedence 50 for @{ 'oa_meet_mk (λ${ident i}:$I.$p) }.
125 notation < "hovbox(a ∧ b)" left associative with precedence 35
126 for @{ 'oa_meet_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
127
128 notation > "hovbox(∧ f)" non associative with precedence 60
129 for @{ 'oa_meet $f }.
130 notation > "hovbox(a ∧ b)" left associative with precedence 50
131 for @{ 'oa_meet (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
132
133 interpretation "o-algebra meet" 'oa_meet f = 
134   (fun_1 __ (oa_meet __) f).
135 interpretation "o-algebra meet with explicit function" 'oa_meet_mk f = 
136   (fun_1 __ (oa_meet __) (mk_unary_morphism _ _ f _)).
137
138 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)" 
139 non associative with precedence 49 for @{ 'oa_join $p }.
140 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈  I) break term 90 p)" 
141 non associative with precedence 49 for @{ 'oa_join_mk (λ${ident i}:$I.$p) }.
142 notation < "hovbox(a ∨ b)" left associative with precedence 49
143 for @{ 'oa_join_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
144
145 notation > "hovbox(∨ f)" non associative with precedence 59
146 for @{ 'oa_join $f }.
147 notation > "hovbox(a ∨ b)" left associative with precedence 49
148 for @{ 'oa_join (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
149
150 interpretation "o-algebra join" 'oa_join f = 
151   (fun_1 __ (oa_join __) f).
152 interpretation "o-algebra join with explicit function" 'oa_join_mk f = 
153   (fun_1 __ (oa_join __) (mk_unary_morphism _ _ f _)).
154
155 record ORelation (P,Q : OAlgebra) : Type ≝ {
156   or_f :> arrows1 SET P Q;
157   or_f_minus_star : arrows1 SET P Q;
158   or_f_star : arrows1 SET Q P;
159   or_f_minus : arrows1 SET Q P;
160   or_prop1 : ∀p,q. (or_f p ≤ q) = (p ≤ or_f_star q);
161   or_prop2 : ∀p,q. (or_f_minus p ≤ q) = (p ≤ or_f_minus_star q);
162   or_prop3 : ∀p,q. (or_f p >< q) = (p >< or_f_minus q)
163 }.
164
165 notation "r \sup *" non associative with precedence 90 for @{'OR_f_star $r}.
166 notation > "r *" non associative with precedence 90 for @{'OR_f_star $r}.
167 interpretation "o-relation f*" 'OR_f_star r = (or_f_star _ _ r).
168
169 notation "r \sup (⎻* )" non associative with precedence 90 for @{'OR_f_minus_star $r}.
170 notation > "r⎻*" non associative with precedence 90 for @{'OR_f_minus_star $r}.
171 interpretation "o-relation f⎻*" 'OR_f_minus_star r = (or_f_minus_star _ _ r).
172
173 notation "r \sup ⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
174 notation > "r⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
175 interpretation "o-relation f⎻" 'OR_f_minus r = (or_f_minus _ _ r).
176
177 axiom DAEMON: False.
178
179 definition ORelation_setoid : OAlgebra → OAlgebra → setoid1.
180 intros (P Q);
181 constructor 1;
182 [ apply (ORelation P Q);
183 | constructor 1;
184 <<<<<<< .mine
185    [ alias symbol "and" = "constructive and".
186      apply (λp,q. And4 (∀a.p⎻* a = q⎻* a) (∀a.p⎻ a  = q⎻ a)
187                        (∀a.p a   = q a)   (∀a.p* a  = q* a)); 
188    | whd; simplify; intros; repeat split; intros; apply refl;
189 =======
190    [ apply (λp,q. eq1 ? p⎻* q⎻* ∧ eq1 ? p⎻ q⎻ ∧ eq1 ? p q ∧ eq1 ? p* q* ); 
191    | whd; simplify; intros; repeat split; intros; apply refl1;
192 >>>>>>> .r9407
193 <<<<<<< .mine
194    | whd; simplify; intros; cases H; clear H; split; 
195      intro a; apply sym; generalize in match a;assumption;
196    | whd; simplify; intros; cases H; cases H1; clear H H1; split; intro a;
197      [ apply (.= (H2 a)); apply H6;
198      | apply (.= (H3 a)); apply H7;
199      | apply (.= (H4 a)); apply H8;
200      | apply (.= (H5 a)); apply H9;]]]
201 qed.  
202 =======
203    | whd; simplify; intros; cases H; cases H1; cases H3; clear H H3 H1;
204      repeat split; intros; apply sym1; assumption;
205    | whd; simplify; intros; cases H; cases H1; cases H2; cases H4; cases H6; cases H8;
206      repeat split; intros; clear H H1 H2 H4 H6 H8; apply trans1;
207       [2: apply H10;
208       |5: apply H11;
209       |8: apply H7;
210       |11: apply H3;
211       |1,4,7,10: skip
212       |*: assumption
213       ]]]
214 qed.
215 >>>>>>> .r9407
216
217 <<<<<<< .mine
218 definition ORelation_composition : ∀P,Q,R. 
219 =======
220 lemma hint1 : ∀P,Q. ORelation_setoid P Q → arrows1 SET P Q. intros; apply (or_f ?? c);qed.
221 coercion hint1.
222
223 lemma hint3 : ∀P,Q. arrows1 SET P Q → P ⇒ Q. intros; apply c;qed.
224 coercion hint3.
225
226 lemma hint2: OAlgebra → setoid. intros; apply (oa_P o). qed.
227 coercion hint2.
228
229 definition composition : ∀P,Q,R. 
230 >>>>>>> .r9407
231   binary_morphism1 (ORelation_setoid P Q) (ORelation_setoid Q R) (ORelation_setoid P R).
232 intros;
233 constructor 1;
234 [ intros (F G);
235   constructor 1;
236 <<<<<<< .mine
237     [ apply {x ∈ P | G (F x)}; intros; simplify; apply (†(†H));
238     | apply {x ∈ P | G⎻* (F⎻* x)}; intros; simplify; apply (†(†H));
239     | apply {x ∈ R | F* (G* x)}; intros; simplify; apply (†(†H));
240     | apply {x ∈ R | F⎻ (G⎻ x)}; intros; simplify; apply (†(†H));
241     | intros; simplify; 
242       lapply (or_prop1 ?? G (F p) q) as H1; lapply (or_prop1 ?? F p (G* q)) as H2;
243       split; intro H; 
244         [ apply (if1 ?? H2); apply (if1 ?? H1); apply H;
245         | apply (fi1 ?? H1); apply (fi1 ?? H2); apply H;] 
246     | intros; simplify;
247       lapply (or_prop2 ?? G p (F⎻* q)) as H1; lapply (or_prop2 ?? F (G⎻ p) q) as H2;
248       split; intro H;
249         [ apply (if1 ?? H1); apply (if1 ?? H2); apply H;   
250         | apply (fi1 ?? H2); apply (fi1 ?? H1); apply H;]
251     | intros; simplify;
252       lapply (or_prop3 ?? F p (G⎻ q)) as H1; lapply (or_prop3 ?? G (F p) q) as H2;
253       split; intro H;
254         [ apply (if1 ?? H1); apply (if1 ?? H2); apply H;   
255         | apply (fi1 ?? H2); apply (fi1 ?? H1); apply H;]]
256 | intros; simplify; split; simplify; intros; elim DAEMON;]
257 =======
258   [ apply (G ∘ F);
259   | apply (G⎻* ∘ F⎻* );
260   | apply (F* ∘ G* );
261   | apply (F⎻ ∘ G⎻);
262   | intros; change with ((G (F p) ≤ q) = (p ≤ (F* (G* q))));
263     apply (.= or_prop1 ??? (F p) ?);
264     apply (.= or_prop1 ??? p ?);
265     apply refl1
266   | intros; change with ((F⎻ (G⎻ p) ≤ q) = (p ≤ (G⎻* (F⎻* q))));
267     apply (.= or_prop2 ??? (G⎻ p) ?);
268     apply (.= or_prop2 ??? p ?);
269     apply refl1;
270   | intros; change with ((G (F (p)) >< q) = (p >< (F⎻ (G⎻ q))));
271     apply (.= or_prop3 ??? (F p) ?);
272     apply (.= or_prop3 ??? p ?);
273     apply refl1
274   ]
275 | intros; repeat split; simplify; cases DAEMON (*
276    [ apply trans1; [2: apply prop1; [3: apply rule #; | skip | 4:
277      apply rule (†?);
278    
279      lapply (.= ((†H1)‡#)); [8: apply Hletin;
280    [ apply trans1; [2: lapply (prop1); [apply Hletin;
281 *)]
282 >>>>>>> .r9407
283 qed.
284
285 definition OA : category1.
286 split;
287 [ apply (OAlgebra);
288 | intros; apply (ORelation_setoid o o1);
289 | intro O; split;
290 <<<<<<< .mine
291   [1,2,3,4: constructor 1; [1,3,5,7:apply (λx.x);|*:intros;assumption]
292   |5,6,7:intros;split;intros; assumption;] 
293 |4: apply ORelation_composition;
294 |*: elim DAEMON;]
295 qed. 
296
297
298
299 =======
300   [1,2,3,4: apply id1;
301   |5,6,7:intros; apply refl1;] 
302 | apply composition;
303 | intros; repeat split; unfold composition; simplify;
304   [1,3: apply (comp_assoc1); | 2,4: apply ((comp_assoc1 ????????) \sup -1);]
305 | intros; repeat split; unfold composition; simplify; apply id_neutral_left1;
306 | intros; repeat split; unfold composition; simplify; apply id_neutral_right1;]
307 qed.>>>>>>> .r9407