]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/formal_topology/overlap/o-algebra.ma
Proof that \Omega \sup A is an overlap algebra, up to universe inconsistency :-(
[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 "categories.ma".
16 include "logic/cprop_connectives.ma". 
17
18 inductive bool : Type0 := true : bool | false : bool.
19
20 lemma BOOL : objs1 SET.
21 constructor 1; [apply bool] constructor 1;
22 [ intros (x y); apply (match x with [ true ⇒ match y with [ true ⇒ True | _ ⇒ False] | false ⇒ match y with [ true ⇒ False | false ⇒ True ]]);
23 | whd; simplify; intros; cases x; apply I;
24 | whd; simplify; intros 2; cases x; cases y; simplify; intros; assumption;
25 | whd; simplify; intros 3; cases x; cases y; cases z; simplify; intros; 
26   try assumption; apply I]
27 qed.
28
29 lemma IF_THEN_ELSE_p :
30   ∀S:setoid1.∀a,b:S.∀x,y:BOOL.x = y → 
31     (λm.match m with [ true ⇒ a | false ⇒ b ]) x =
32     (λm.match m with [ true ⇒ a | false ⇒ b ]) y.
33 whd in ⊢ (?→?→?→%→?);
34 intros; cases x in e; cases y; simplify; intros; try apply refl1; whd in e; cases e;
35 qed.
36
37 interpretation "unary morphism comprehension with no proof" 'comprehension T P = 
38   (mk_unary_morphism T _ P _).
39 interpretation "unary morphism1 comprehension with no proof" 'comprehension T P = 
40   (mk_unary_morphism1 T _ P _).
41
42 notation > "hvbox({ ident i ∈ s | term 19 p | by })" with precedence 90
43 for @{ 'comprehension_by $s (λ${ident i}. $p) $by}.
44 notation < "hvbox({ ident i ∈ s | term 19 p })" with precedence 90
45 for @{ 'comprehension_by $s (λ${ident i}:$_. $p) $by}.
46
47 interpretation "unary morphism comprehension with proof" 'comprehension_by s \eta.f p = 
48   (mk_unary_morphism s _ f p).
49 interpretation "unary morphism1 comprehension with proof" 'comprehension_by s \eta.f p = 
50   (mk_unary_morphism1 s _ f p).
51
52 definition hint: Type_OF_category2 SET1 → setoid2.
53  intro; apply (setoid2_of_setoid1 t); qed.
54 coercion hint.
55
56 definition hint2: Type_OF_category1 SET → objs2 SET1.
57  intro; apply (setoid1_of_setoid t); qed.
58 coercion hint2.
59
60 (* per il set-indexing vedere capitolo BPTools (foundational tools), Sect. 0.3.4 complete
61    lattices, Definizione 0.9 *)
62 (* USARE L'ESISTENZIALE DEBOLE *)
63 (*alias symbol "comprehension_by" = "unary morphism comprehension with proof".*)
64 record OAlgebra : Type2 := {
65   oa_P :> SET1;
66   oa_leq : binary_morphism1 oa_P oa_P CPROP; (* CPROP is setoid1, CPROP importante che sia small *)
67   oa_overlap: binary_morphism1 oa_P oa_P CPROP;
68   oa_meet: ∀I:SET.unary_morphism2 (arrows2 SET1 I oa_P) oa_P;
69   oa_join: ∀I:SET.unary_morphism2 (arrows2 SET1 I oa_P) oa_P;
70   oa_one: oa_P;
71   oa_zero: oa_P;
72   oa_leq_refl: ∀a:oa_P. oa_leq a a; 
73   oa_leq_antisym: ∀a,b:oa_P.oa_leq a b → oa_leq b a → a = b;
74   oa_leq_trans: ∀a,b,c:oa_P.oa_leq a b → oa_leq b c → oa_leq a c;
75   oa_overlap_sym: ∀a,b:oa_P.oa_overlap a b → oa_overlap b a;
76   (* Errore: = in oa_meet_inf e oa_join_sup *)
77   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);
78   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;
79   oa_zero_bot: ∀p:oa_P.oa_leq oa_zero p;
80   oa_one_top: ∀p:oa_P.oa_leq p oa_one;
81   oa_overlap_preserves_meet_: 
82       ∀p,q:oa_P.oa_overlap p q → oa_overlap p 
83        (oa_meet ? { x ∈ BOOL | match x with [ true ⇒ p | false ⇒ q ] | IF_THEN_ELSE_p oa_P p q });
84   (* ⇔ deve essere =, l'esiste debole *)
85   oa_join_split:
86       ∀I:SET.∀p.∀q:arrows2 SET1 I oa_P.
87        oa_overlap p (oa_join I q) ⇔ ∃i:I.oa_overlap p (q i);
88   (*oa_base : setoid;
89   1) enum non e' il nome giusto perche' non e' suriettiva
90   2) manca (vedere altro capitolo) la "suriettivita'" come immagine di insiemi di oa_base
91   oa_enum : ums oa_base oa_P;
92   oa_density: ∀p,q.(∀i.oa_overlap p (oa_enum i) → oa_overlap q (oa_enum i)) → oa_leq p q
93   *)
94   oa_density: 
95       ∀p,q.(∀r.oa_overlap p r → oa_overlap q r) → oa_leq p q
96 }.
97
98 interpretation "o-algebra leq" 'leq a b = (fun21 ___ (oa_leq _) a b).
99
100 notation "hovbox(a mpadded width -150% (>)< b)" non associative with precedence 45
101 for @{ 'overlap $a $b}.
102 interpretation "o-algebra overlap" 'overlap a b = (fun22 ___ (oa_overlap _) a b).
103
104 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (\emsp) \nbsp term 90 p)" 
105 non associative with precedence 50 for @{ 'oa_meet $p }.
106 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (ident i ∈  I) break term 90 p)" 
107 non associative with precedence 50 for @{ 'oa_meet_mk (λ${ident i}:$I.$p) }.
108
109 (*
110 notation < "hovbox(a ∧ b)" left associative with precedence 35
111 for @{ 'oa_meet_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
112 *)
113 notation > "hovbox(∧ f)" non associative with precedence 60
114 for @{ 'oa_meet $f }.
115 (*
116 notation > "hovbox(a ∧ b)" left associative with precedence 50
117 for @{ 'oa_meet (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
118 *)
119 interpretation "o-algebra meet" 'oa_meet f = 
120   (fun11 __ (oa_meet __) f).
121 interpretation "o-algebra meet with explicit function" 'oa_meet_mk f = 
122   (fun11 __ (oa_meet __) (mk_unary_morphism _ _ f _)).
123
124 (*
125
126 definition binary_meet : ∀O:OAlgebra. binary_morphism1 O O O.
127 intros; split;
128 [ intros (p q); 
129   apply (∧ { x ∈ BOOL | match x with [ true ⇒ p | false ⇒ q ] | IF_THEN_ELSE_p ? p q });
130 | intros; apply (prop_1 ?? (oa_meet O BOOL)); intro x; simplify;
131   cases x; simplify; assumption;]
132 qed.
133
134 notation "hovbox(a ∧ b)" left associative with precedence 35
135 for @{ 'oa_meet_bin $a $b }.
136 interpretation "o-algebra binary meet" 'oa_meet_bin a b = 
137   (fun1 ___ (binary_meet _) a b).
138
139 lemma oa_overlap_preservers_meet: ∀O:OAlgebra.∀p,q:O.p >< q → p >< (p ∧ q).
140 intros;  lapply (oa_overlap_preservers_meet_ O p q f);
141 lapply (prop1 O O CPROP (oa_overlap O) p p ? (p ∧ q) # ?);
142 [3: apply (if ?? (Hletin1)); apply Hletin;|skip] apply refl1;
143 qed.
144
145 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)" 
146 non associative with precedence 49 for @{ 'oa_join $p }.
147 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈  I) break term 90 p)" 
148 non associative with precedence 49 for @{ 'oa_join_mk (λ${ident i}:$I.$p) }.
149 notation < "hovbox(a ∨ b)" left associative with precedence 49
150 for @{ 'oa_join_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
151
152 notation > "hovbox(∨ f)" non associative with precedence 59
153 for @{ 'oa_join $f }.
154 notation > "hovbox(a ∨ b)" left associative with precedence 49
155 for @{ 'oa_join (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
156
157 interpretation "o-algebra join" 'oa_join f = 
158   (fun_1 __ (oa_join __) f).
159 interpretation "o-algebra join with explicit function" 'oa_join_mk f = 
160   (fun_1 __ (oa_join __) (mk_unary_morphism _ _ f _)).
161
162 record ORelation (P,Q : OAlgebra) : Type ≝ {
163   or_f_ : arrows1 SET P Q;
164   or_f_minus_star_ : arrows1 SET P Q;
165   or_f_star_ : arrows1 SET Q P;
166   or_f_minus_ : arrows1 SET Q P;
167   or_prop1_ : ∀p,q. (or_f_ p ≤ q) = (p ≤ or_f_star_ q);
168   or_prop2_ : ∀p,q. (or_f_minus_ p ≤ q) = (p ≤ or_f_minus_star_ q);
169   or_prop3_ : ∀p,q. (or_f_ p >< q) = (p >< or_f_minus_ q)
170 }.
171
172
173 definition ORelation_setoid : OAlgebra → OAlgebra → setoid1.
174 intros (P Q);
175 constructor 1;
176 [ apply (ORelation P Q);
177 | constructor 1;
178    (* tenere solo una uguaglianza e usare la proposizione 9.9 per
179       le altre (unicita' degli aggiunti e del simmetrico) *)
180    [ apply (λp,q. And4 (eq1 ? (or_f_minus_star_ ?? p) (or_f_minus_star_ ?? q)) 
181              (eq1 ? (or_f_minus_ ?? p) (or_f_minus_ ?? q)) 
182              (eq1 ? (or_f_ ?? p) (or_f_ ?? q)) 
183              (eq1 ? (or_f_star_ ?? p) (or_f_star_ ?? q))); 
184    | whd; simplify; intros; repeat split; intros; apply refl1;
185    | whd; simplify; intros; cases H; clear H; split; 
186      intro a; apply sym; generalize in match a;assumption;
187    | whd; simplify; intros; cases H; cases H1; clear H H1; split; intro a;
188      [ apply (.= (H2 a)); apply H6;
189      | apply (.= (H3 a)); apply H7;
190      | apply (.= (H4 a)); apply H8;
191      | apply (.= (H5 a)); apply H9;]]]
192 qed.  
193
194 definition or_f_minus_star: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET P Q.
195  intros; constructor 1;
196   [ apply or_f_minus_star_;
197   | intros; cases H; assumption]
198 qed.
199
200 definition or_f: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET P Q.
201  intros; constructor 1;
202   [ apply or_f_;
203   | intros; cases H; assumption]
204 qed.
205
206 coercion or_f.
207
208 definition or_f_minus: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET Q P.
209  intros; constructor 1;
210   [ apply or_f_minus_;
211   | intros; cases H; assumption]
212 qed.
213
214 definition or_f_star: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET Q P.
215  intros; constructor 1;
216   [ apply or_f_star_;
217   | intros; cases H; assumption]
218 qed.
219
220 lemma arrows1_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → arrows1 SET P Q.
221 intros; apply (or_f ?? c);
222 qed.
223
224 coercion arrows1_OF_ORelation_setoid nocomposites.
225
226 lemma umorphism_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → P ⇒ Q.
227 intros; apply (or_f ?? c);
228 qed.
229
230 coercion umorphism_OF_ORelation_setoid.
231
232
233 lemma uncurry_arrows : ∀B,C. arrows1 SET B C → B → C. 
234 intros; apply ((fun_1 ?? c) t);
235 qed.
236
237 coercion uncurry_arrows 1.
238
239 lemma hint3 : ∀P,Q. arrows1 SET P Q → P ⇒ Q. intros; apply c;qed.
240 coercion hint3 nocomposites.
241
242 (*
243 lemma hint2: OAlgebra → setoid. intros; apply (oa_P o). qed.
244 coercion hint2 nocomposites.
245 *)
246
247
248 notation "r \sup *" non associative with precedence 90 for @{'OR_f_star $r}.
249 notation > "r *" non associative with precedence 90 for @{'OR_f_star $r}.
250
251 notation "r \sup (⎻* )" non associative with precedence 90 for @{'OR_f_minus_star $r}.
252 notation > "r⎻*" non associative with precedence 90 for @{'OR_f_minus_star $r}.
253
254 notation "r \sup ⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
255 notation > "r⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
256
257 interpretation "o-relation f⎻*" 'OR_f_minus_star r = (fun_1 __ (or_f_minus_star _ _) r).
258 interpretation "o-relation f⎻" 'OR_f_minus r = (fun_1 __ (or_f_minus _ _) r).
259 interpretation "o-relation f*" 'OR_f_star r = (fun_1 __ (or_f_star _ _) r).
260
261 definition or_prop1 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
262    (F p ≤ q) = (p ≤ F* q).
263 intros; apply (or_prop1_ ?? F p q);
264 qed.
265
266 definition or_prop2 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
267    (F⎻ p ≤ q) = (p ≤ F⎻* q).
268 intros; apply (or_prop2_ ?? F p q);
269 qed.
270
271 definition or_prop3 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
272    (F p >< q) = (p >< F⎻ q).
273 intros; apply (or_prop3_ ?? F p q);
274 qed.
275
276 definition ORelation_composition : ∀P,Q,R. 
277   binary_morphism1 (ORelation_setoid P Q) (ORelation_setoid Q R) (ORelation_setoid P R).
278 intros;
279 constructor 1;
280 [ intros (F G);
281   constructor 1;
282   [ apply (G ∘ F);
283   | apply (G⎻* ∘ F⎻* );
284   | apply (F* ∘ G* );
285   | apply (F⎻ ∘ G⎻);
286   | intros; 
287     change with ((G (F p) ≤ q) = (p ≤ (F* (G* q))));
288     apply (.= (or_prop1 :?));
289     apply (or_prop1 :?);
290   | intros;
291     change with ((F⎻ (G⎻ p) ≤ q) = (p ≤ (G⎻* (F⎻* q))));
292     apply (.= (or_prop2 :?));
293     apply or_prop2 ; 
294   | intros; change with ((G (F (p)) >< q) = (p >< (F⎻ (G⎻ q))));
295     apply (.= (or_prop3 :?));
296     apply or_prop3;
297   ]
298 | intros; split; simplify; 
299    [1,3: unfold arrows1_OF_ORelation_setoid; apply ((†H)‡(†H1));
300    |2,4: apply ((†H1)‡(†H));]]
301 qed.
302
303 definition OA : category1.
304 split;
305 [ apply (OAlgebra);
306 | intros; apply (ORelation_setoid o o1);
307 | intro O; split;
308   [1,2,3,4: apply id1;
309   |5,6,7:intros; apply refl1;] 
310 | apply ORelation_composition;
311 | intros (P Q R S F G H); split;
312    [ change with (H⎻* ∘ G⎻* ∘ F⎻* = H⎻* ∘ (G⎻* ∘ F⎻* ));
313      apply (comp_assoc1 ????? (F⎻* ) (G⎻* ) (H⎻* ));
314    | apply ((comp_assoc1 ????? (H⎻) (G⎻) (F⎻))^-1);
315    | apply ((comp_assoc1 ????? F G H)^-1);
316    | apply ((comp_assoc1 ????? H* G* F* ));]
317 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_left1;
318 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_right1;]
319 qed.
320 *)