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