]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/formal_topology/overlap/o-algebra.ma
Some work on o-algebras towards the proof that a and j are saturation/reduction
[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
17 inductive bool : Type0 := true : bool | false : bool.
18
19 lemma BOOL : objs1 SET.
20 constructor 1; [apply bool] constructor 1;
21 [ intros (x y); apply (match x with [ true ⇒ match y with [ true ⇒ True | _ ⇒ False] | false ⇒ match y with [ true ⇒ False | false ⇒ True ]]);
22 | whd; simplify; intros; cases x; apply I;
23 | whd; simplify; intros 2; cases x; cases y; simplify; intros; assumption;
24 | whd; simplify; intros 3; cases x; cases y; cases z; simplify; intros; 
25   try assumption; apply I]
26 qed.
27
28 lemma IF_THEN_ELSE_p :
29   ∀S:setoid1.∀a,b:S.∀x,y:BOOL.x = y → 
30     (λm.match m with [ true ⇒ a | false ⇒ b ]) x =
31     (λm.match m with [ true ⇒ a | false ⇒ b ]) y.
32 whd in ⊢ (?→?→?→%→?);
33 intros; cases x in e; cases y; simplify; intros; try apply refl1; whd in e; cases e;
34 qed.
35
36 interpretation "unary morphism comprehension with no proof" 'comprehension T P = 
37   (mk_unary_morphism T _ P _).
38 interpretation "unary morphism1 comprehension with no proof" 'comprehension T P = 
39   (mk_unary_morphism1 T _ P _).
40
41 notation > "hvbox({ ident i ∈ s | term 19 p | by })" with precedence 90
42 for @{ 'comprehension_by $s (λ${ident i}. $p) $by}.
43 notation < "hvbox({ ident i ∈ s | term 19 p })" with precedence 90
44 for @{ 'comprehension_by $s (λ${ident i}:$_. $p) $by}.
45
46 interpretation "unary morphism comprehension with proof" 'comprehension_by s \eta.f p = 
47   (mk_unary_morphism s _ f p).
48 interpretation "unary morphism1 comprehension with proof" 'comprehension_by s \eta.f p = 
49   (mk_unary_morphism1 s _ f p).
50
51 (* per il set-indexing vedere capitolo BPTools (foundational tools), Sect. 0.3.4 complete
52    lattices, Definizione 0.9 *)
53 (* USARE L'ESISTENZIALE DEBOLE *)
54 record OAlgebra : Type2 := {
55   oa_P :> SET1;
56   oa_leq : binary_morphism1 oa_P oa_P CPROP;
57   oa_overlap: binary_morphism1 oa_P oa_P CPROP;
58   oa_meet: ∀I:SET.unary_morphism2 (I ⇒ oa_P) oa_P;
59   oa_join: ∀I:SET.unary_morphism2 (I ⇒ oa_P) oa_P;
60   oa_one: oa_P;
61   oa_zero: oa_P;
62   oa_leq_refl: ∀a:oa_P. oa_leq a a; 
63   oa_leq_antisym: ∀a,b:oa_P.oa_leq a b → oa_leq b a → a = b;
64   oa_leq_trans: ∀a,b,c:oa_P.oa_leq a b → oa_leq b c → oa_leq a c;
65   oa_overlap_sym: ∀a,b:oa_P.oa_overlap a b → oa_overlap b a;
66   oa_meet_inf: ∀I:SET.∀p_i:I ⇒ oa_P.∀p:oa_P.oa_leq p (oa_meet I p_i) = ∀i:I.oa_leq p (p_i i);
67   oa_join_sup: ∀I:SET.∀p_i:I ⇒ oa_P.∀p:oa_P.oa_leq (oa_join I p_i) p = ∀i:I.oa_leq (p_i i) p;
68   oa_zero_bot: ∀p:oa_P.oa_leq oa_zero p;
69   oa_one_top: ∀p:oa_P.oa_leq p oa_one;
70   oa_overlap_preserves_meet_: 
71       ∀p,q:oa_P.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   oa_join_split:
74       ∀I:SET.∀p.∀q:I ⇒ oa_P.
75        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 = (fun21 ___ (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 = (fun21 ___ (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 notation > "hovbox(∧ f)" non associative with precedence 60
98 for @{ 'oa_meet $f }.
99 interpretation "o-algebra meet" 'oa_meet f = 
100   (fun12 __ (oa_meet __) f).
101 interpretation "o-algebra meet with explicit function" 'oa_meet_mk f = 
102   (fun12 __ (oa_meet __) (mk_unary_morphism _ _ f _)).
103
104 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)" 
105 non associative with precedence 50 for @{ 'oa_join $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_join_mk (λ${ident i}:$I.$p) }.
108
109 notation > "hovbox(∨ f)" non associative with precedence 60
110 for @{ 'oa_join $f }.
111 interpretation "o-algebra join" 'oa_join f = 
112   (fun12 __ (oa_join __) f).
113 interpretation "o-algebra join with explicit function" 'oa_join_mk f = 
114   (fun12 __ (oa_join __) (mk_unary_morphism _ _ f _)).
115
116 definition hint3: OAlgebra → setoid1.
117  intro; apply (oa_P o);
118 qed.
119 coercion hint3.
120
121 definition hint4: ∀A. setoid2_OF_OAlgebra A → hint3 A.
122  intros; apply t;
123 qed.
124 coercion hint4.
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; lapply (prop12 ? O (oa_meet O BOOL));
131    [2: apply ({ x ∈ BOOL | match x with [ true ⇒ a | false ⇒ b ] | IF_THEN_ELSE_p ? a b });
132    |3: apply ({ x ∈ BOOL | match x with [ true ⇒ a' | false ⇒ b' ] | IF_THEN_ELSE_p ? a' b' });
133    | apply Hletin;]
134   intro x; simplify; cases x; simplify; assumption;]
135 qed.
136
137 interpretation "o-algebra binary meet" 'and a b = 
138   (fun21 ___ (binary_meet _) a b).
139
140 definition binary_join : ∀O:OAlgebra. binary_morphism1 O O O.
141 intros; split;
142 [ intros (p q); 
143   apply (∨ { x ∈ BOOL | match x with [ true ⇒ p | false ⇒ q ] | IF_THEN_ELSE_p ? p q });
144 | intros; lapply (prop12 ? O (oa_join O BOOL));
145    [2: apply ({ x ∈ BOOL | match x with [ true ⇒ a | false ⇒ b ] | IF_THEN_ELSE_p ? a b });
146    |3: apply ({ x ∈ BOOL | match x with [ true ⇒ a' | false ⇒ b' ] | IF_THEN_ELSE_p ? a' b' });
147    | apply Hletin;]
148   intro x; simplify; cases x; simplify; assumption;]
149 qed.
150
151 interpretation "o-algebra binary join" 'or a b = 
152   (fun21 ___ (binary_join _) a b).
153
154 coercion Type1_OF_OAlgebra nocomposites.
155
156 lemma oa_overlap_preservers_meet: ∀O:OAlgebra.∀p,q:O.p >< q → p >< (p ∧ q).
157 (* next change to avoid universe inconsistency *)
158 change in ⊢ (?→%→%→?) with (Type1_OF_OAlgebra O);
159 intros;  lapply (oa_overlap_preserves_meet_ O p q f);
160 lapply (prop21 O O CPROP (oa_overlap O) p p ? (p ∧ q) # ?);
161 [3: apply (if ?? (Hletin1)); apply Hletin;|skip] apply refl1;
162 qed.
163
164 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)" 
165 non associative with precedence 49 for @{ 'oa_join $p }.
166 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈  I) break term 90 p)" 
167 non associative with precedence 49 for @{ 'oa_join_mk (λ${ident i}:$I.$p) }.
168 notation < "hovbox(a ∨ b)" left associative with precedence 49
169 for @{ 'oa_join_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
170
171 notation > "hovbox(∨ f)" non associative with precedence 59
172 for @{ 'oa_join $f }.
173 notation > "hovbox(a ∨ b)" left associative with precedence 49
174 for @{ 'oa_join (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
175
176 interpretation "o-algebra join" 'oa_join f = 
177   (fun12 __ (oa_join __) f).
178 interpretation "o-algebra join with explicit function" 'oa_join_mk f = 
179   (fun12 __ (oa_join __) (mk_unary_morphism _ _ f _)).
180
181 definition hint5: OAlgebra → objs2 SET1.
182  intro; apply (oa_P o);
183 qed.
184 coercion hint5.
185
186 record ORelation (P,Q : OAlgebra) : Type2 ≝ {
187   or_f_ : P ⇒ Q;
188   or_f_minus_star_ : P ⇒ Q;
189   or_f_star_ : Q ⇒ P;
190   or_f_minus_ : Q ⇒ P;
191   or_prop1_ : ∀p,q. (or_f_ p ≤ q) = (p ≤ or_f_star_ q);
192   or_prop2_ : ∀p,q. (or_f_minus_ p ≤ q) = (p ≤ or_f_minus_star_ q);
193   or_prop3_ : ∀p,q. (or_f_ p >< q) = (p >< or_f_minus_ q)
194 }.
195
196 definition ORelation_setoid : OAlgebra → OAlgebra → setoid2.
197 intros (P Q);
198 constructor 1;
199 [ apply (ORelation P Q);
200 | constructor 1;
201    (* tenere solo una uguaglianza e usare la proposizione 9.9 per
202       le altre (unicita' degli aggiunti e del simmetrico) *)
203    [ apply (λp,q. And42 (eq2 ? (or_f_minus_star_ ?? p) (or_f_minus_star_ ?? q)) 
204              (eq2 ? (or_f_minus_ ?? p) (or_f_minus_ ?? q)) 
205              (eq2 ? (or_f_ ?? p) (or_f_ ?? q)) 
206              (eq2 ? (or_f_star_ ?? p) (or_f_star_ ?? q))); 
207    | whd; simplify; intros; repeat split; intros; apply refl2;
208    | whd; simplify; intros; cases a; clear a; split; 
209      intro a; apply sym1; generalize in match a;assumption;
210    | whd; simplify; intros; cases a; cases a1; clear a a1; split; intro a;
211      [ apply (.= (e a)); apply e4;
212      | apply (.= (e1 a)); apply e5;
213      | apply (.= (e2 a)); apply e6;
214      | apply (.= (e3 a)); apply e7;]]]
215 qed.
216
217 definition or_f_minus_star:
218  ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (P ⇒ Q).
219  intros; constructor 1;
220   [ apply or_f_minus_star_;
221   | intros; cases e; assumption]
222 qed.
223
224 definition or_f: ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (P ⇒ Q).
225  intros; constructor 1;
226   [ apply or_f_;
227   | intros; cases e; assumption]
228 qed.
229
230 coercion or_f.
231
232 definition or_f_minus: ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (Q ⇒ P).
233  intros; constructor 1;
234   [ apply or_f_minus_;
235   | intros; cases e; assumption]
236 qed.
237
238 definition or_f_star: ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (Q ⇒ P).
239  intros; constructor 1;
240   [ apply or_f_star_;
241   | intros; cases e; assumption]
242 qed.
243
244 lemma arrows1_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → (P ⇒ Q).
245 intros; apply (or_f ?? t);
246 qed.
247
248 coercion arrows1_OF_ORelation_setoid.
249
250 lemma umorphism_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → unary_morphism1 P Q.
251 intros; apply (or_f ?? t);
252 qed.
253
254 coercion umorphism_OF_ORelation_setoid.
255
256 lemma umorphism_setoid_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → unary_morphism1_setoid1 P Q.
257 intros; apply (or_f ?? t);
258 qed.
259
260 coercion umorphism_setoid_OF_ORelation_setoid.
261
262 lemma uncurry_arrows : ∀B,C. ORelation_setoid B C → B → C. 
263 intros; apply ((fun11 ?? t) t1);
264 qed.
265
266 coercion uncurry_arrows 1.
267
268 lemma hint6: ∀P,Q. Type_OF_setoid2 (hint5 P ⇒ hint5 Q) → unary_morphism1 P Q.
269  intros; apply t;
270 qed.
271 coercion hint6.
272
273 notation "r \sup *" non associative with precedence 90 for @{'OR_f_star $r}.
274 notation > "r *" non associative with precedence 90 for @{'OR_f_star $r}.
275
276 notation "r \sup (⎻* )" non associative with precedence 90 for @{'OR_f_minus_star $r}.
277 notation > "r⎻*" non associative with precedence 90 for @{'OR_f_minus_star $r}.
278
279 notation "r \sup ⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
280 notation > "r⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
281
282 interpretation "o-relation f⎻*" 'OR_f_minus_star r = (fun12 __ (or_f_minus_star _ _) r).
283 interpretation "o-relation f⎻" 'OR_f_minus r = (fun12 __ (or_f_minus _ _) r).
284 interpretation "o-relation f*" 'OR_f_star r = (fun12 __ (or_f_star _ _) r).
285
286 definition or_prop1 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
287    (F p ≤ q) = (p ≤ F* q).
288 intros; apply (or_prop1_ ?? F p q);
289 qed.
290
291 definition or_prop2 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
292    (F⎻ p ≤ q) = (p ≤ F⎻* q).
293 intros; apply (or_prop2_ ?? F p q);
294 qed.
295
296 definition or_prop3 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
297    (F p >< q) = (p >< F⎻ q).
298 intros; apply (or_prop3_ ?? F p q);
299 qed.
300
301 definition ORelation_composition : ∀P,Q,R. 
302   binary_morphism2 (ORelation_setoid P Q) (ORelation_setoid Q R) (ORelation_setoid P R).
303 intros;
304 constructor 1;
305 [ intros (F G);
306   constructor 1;
307   [ apply (G ∘ F);
308   | apply rule (G⎻* ∘ F⎻* );
309   | apply (F* ∘ G* );
310   | apply (F⎻ ∘ G⎻);
311   | intros; 
312     change with ((G (F p) ≤ q) = (p ≤ (F* (G* q))));
313     apply (.= (or_prop1 :?));
314     apply (or_prop1 :?);
315   | intros;
316     change with ((F⎻ (G⎻ p) ≤ q) = (p ≤ (G⎻* (F⎻* q))));
317     apply (.= (or_prop2 :?));
318     apply or_prop2 ; 
319   | intros; change with ((G (F (p)) >< q) = (p >< (F⎻ (G⎻ q))));
320     apply (.= (or_prop3 :?));
321     apply or_prop3;
322   ]
323 | intros; split; simplify; 
324    [1,3: unfold umorphism_setoid_OF_ORelation_setoid; unfold arrows1_OF_ORelation_setoid; apply ((†e)‡(†e1));
325    |2,4: apply ((†e1)‡(†e));]]
326 qed.
327
328 definition OA : category2.
329 split;
330 [ apply (OAlgebra);
331 | intros; apply (ORelation_setoid o o1);
332 | intro O; split;
333   [1,2,3,4: apply id2;
334   |5,6,7:intros; apply refl1;] 
335 | apply ORelation_composition;
336 | intros (P Q R S F G H); split;
337    [ change with (H⎻* ∘ G⎻* ∘ F⎻* = H⎻* ∘ (G⎻* ∘ F⎻* ));
338      apply (comp_assoc2 ????? (F⎻* ) (G⎻* ) (H⎻* ));
339    | apply ((comp_assoc2 ????? (H⎻) (G⎻) (F⎻))^-1);
340    | apply ((comp_assoc2 ????? F G H)^-1);
341    | apply ((comp_assoc2 ????? H* G* F* ));]
342 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_left2;
343 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_right2;]
344 qed.
345
346 lemma setoid1_of_OA: OA → setoid1.
347  intro; apply (oa_P t);
348 qed.
349 coercion setoid1_of_OA.
350
351 lemma SET1_of_OA: OA → SET1.
352  intro; whd; apply (setoid1_of_OA t);
353 qed.
354 coercion SET1_of_OA.
355
356 lemma objs2_SET1_OF_OA: OA → objs2 SET1.
357  intro; whd; apply (setoid1_of_OA t);
358 qed.
359 coercion objs2_SET1_OF_OA.
360
361 lemma Type_OF_category2_OF_SET1_OF_OA: OA → Type_OF_category2 SET1.
362  intro; apply (oa_P t);
363 qed.
364 coercion Type_OF_category2_OF_SET1_OF_OA.