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 "formal_topology/categories.ma".
17 inductive bool : Type0 := true : bool | false : bool.
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]
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.
33 intros; cases x in e; cases y; simplify; intros; try apply refl1; whd in e; cases e;
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 ?).
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}.
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).
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 *)
55 definition if_then_else ≝ λT:Type.λe,t,f.match e return λ_.T with [ true ⇒ t | false ⇒ f].
56 notation > "'If' term 19 e 'then' term 19 t 'else' term 90 f" non associative with precedence 19 for @{ 'if_then_else $e $t $f }.
57 notation < "'If' \nbsp term 19 e \nbsp 'then' \nbsp term 19 t \nbsp 'else' \nbsp term 90 f \nbsp" non associative with precedence 19 for @{ 'if_then_else $e $t $f }.
58 interpretation "Formula if_then_else" 'if_then_else e t f = (if_then_else ? e t f).
60 notation > "hvbox(a break ≤ b)" non associative with precedence 45 for @{oa_leq $a $b}.
61 notation > "a >< b" non associative with precedence 45 for @{oa_overlap $a $b}.
62 notation > "⋁ p" non associative with precedence 45 for @{oa_join ? $p}.
63 notation > "⋀ p" non associative with precedence 45 for @{oa_meet ? $p}.
64 notation > "𝟙" non associative with precedence 90 for @{oa_one}.
65 notation > "𝟘" non associative with precedence 90 for @{oa_zero}.
66 record OAlgebra : Type2 := {
68 oa_leq : oa_P × oa_P ⇒_1 CPROP;
69 oa_overlap: oa_P × oa_P ⇒_1 CPROP;
70 oa_meet: ∀I:SET.(I ⇒_2 oa_P) ⇒_2. oa_P;
71 oa_join: ∀I:SET.(I ⇒_2 oa_P) ⇒_2. oa_P;
74 oa_leq_refl: ∀a:oa_P. a ≤ a;
75 oa_leq_antisym: ∀a,b:oa_P.a ≤ b → b ≤ a → a = b;
76 oa_leq_trans: ∀a,b,c:oa_P.a ≤ b → b ≤ c → a ≤ c;
77 oa_overlap_sym: ∀a,b:oa_P.a >< b → b >< a;
78 oa_meet_inf: ∀I:SET.∀p_i:I ⇒_2 oa_P.∀p:oa_P.p ≤ (⋀ p_i) = (∀i:I.p ≤ (p_i i));
79 oa_join_sup: ∀I:SET.∀p_i:I ⇒_2 oa_P.∀p:oa_P.(⋁ p_i) ≤ p = (∀i:I.p_i i ≤ p);
80 oa_zero_bot: ∀p:oa_P.𝟘 ≤ p;
81 oa_one_top: ∀p:oa_P.p ≤ 𝟙;
82 oa_overlap_preserves_meet_: ∀p,q:oa_P.p >< q →
83 p >< (⋀ { x ∈ BOOL | If x then p else q | IF_THEN_ELSE_p oa_P p q });
84 oa_join_split: ∀I:SET.∀p.∀q:I ⇒_2 oa_P.p >< (⋁ q) = (∃i:I.p >< (q i));
86 1) enum non e' il nome giusto perche' non e' suriettiva
87 2) manca (vedere altro capitolo) la "suriettivita'" come immagine di insiemi di oa_base
88 oa_enum : ums oa_base oa_P;
89 oa_density: ∀p,q.(∀i.oa_overlap p (oa_enum i) → oa_overlap q (oa_enum i)) → oa_leq p q
91 oa_density: ∀p,q.(∀r.p >< r → q >< r) → p ≤ q
94 notation "hvbox(a break ≤ b)" non associative with precedence 45 for @{ 'leq $a $b }.
96 interpretation "o-algebra leq" 'leq a b = (fun21 ??? (oa_leq ?) a b).
98 notation "hovbox(a mpadded width -150% (>)< b)" non associative with precedence 45
99 for @{ 'overlap $a $b}.
100 interpretation "o-algebra overlap" 'overlap a b = (fun21 ??? (oa_overlap ?) a b).
102 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (\emsp) \nbsp term 90 p)"
103 non associative with precedence 50 for @{ 'oa_meet $p }.
104 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (ident i ∈ I) break term 90 p)"
105 non associative with precedence 50 for @{ 'oa_meet_mk (λ${ident i}:$I.$p) }.
107 notation > "hovbox(∧ f)" non associative with precedence 60
108 for @{ 'oa_meet $f }.
109 interpretation "o-algebra meet" 'oa_meet f =
110 (fun12 ?? (oa_meet ??) f).
111 interpretation "o-algebra meet with explicit function" 'oa_meet_mk f =
112 (fun12 ?? (oa_meet ??) (mk_unary_morphism1 ?? f ?)).
114 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)"
115 non associative with precedence 50 for @{ 'oa_join $p }.
116 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈ I) break term 90 p)"
117 non associative with precedence 50 for @{ 'oa_join_mk (λ${ident i}:$I.$p) }.
119 notation > "hovbox(∨ f)" non associative with precedence 60
120 for @{ 'oa_join $f }.
121 interpretation "o-algebra join" 'oa_join f =
122 (fun12 ?? (oa_join ??) f).
123 interpretation "o-algebra join with explicit function" 'oa_join_mk f =
124 (fun12 ?? (oa_join ??) (mk_unary_morphism ?? f ?)).
126 definition binary_meet : ∀O:OAlgebra. O × O ⇒_1 O.
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' });
134 intro x; simplify; cases x; simplify; assumption;]
137 interpretation "o-algebra binary meet" 'and a b =
138 (fun21 ??? (binary_meet ?) a b).
140 prefer coercion Type1_OF_OAlgebra.
142 definition binary_join : ∀O:OAlgebra. O × O ⇒_1 O.
145 apply (∨ { x ∈ BOOL | match x with [ true ⇒ p | false ⇒ q ] | IF_THEN_ELSE_p ? p q });
146 | intros; lapply (prop12 ? O (oa_join O BOOL));
147 [2: apply ({ x ∈ BOOL | match x with [ true ⇒ a | false ⇒ b ] | IF_THEN_ELSE_p ? a b });
148 |3: apply ({ x ∈ BOOL | match x with [ true ⇒ a' | false ⇒ b' ] | IF_THEN_ELSE_p ? a' b' });
150 intro x; simplify; cases x; simplify; assumption;]
153 interpretation "o-algebra binary join" 'or a b =
154 (fun21 ??? (binary_join ?) a b).
156 lemma oa_overlap_preservers_meet: ∀O:OAlgebra.∀p,q:O.p >< q → p >< (p ∧ q).
157 intros; lapply (oa_overlap_preserves_meet_ O p q f) as H; clear f;
158 (** screenshot "screenoa". *)
162 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)"
163 non associative with precedence 49 for @{ 'oa_join $p }.
164 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈ I) break term 90 p)"
165 non associative with precedence 49 for @{ 'oa_join_mk (λ${ident i}:$I.$p) }.
166 notation < "hovbox(a ∨ b)" left associative with precedence 49
167 for @{ 'oa_join_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
169 notation > "hovbox(∨ f)" non associative with precedence 59
170 for @{ 'oa_join $f }.
171 notation > "hovbox(a ∨ b)" left associative with precedence 49
172 for @{ 'oa_join (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
174 interpretation "o-algebra join" 'oa_join f =
175 (fun12 ?? (oa_join ??) f).
176 interpretation "o-algebra join with explicit function" 'oa_join_mk f =
177 (fun12 ?? (oa_join ??) (mk_unary_morphism ?? f ?)).
179 record ORelation (P,Q : OAlgebra) : Type2 ≝ {
181 or_f_minus_star_ : P ⇒_2 Q;
182 or_f_star_ : Q ⇒_2 P;
183 or_f_minus_ : Q ⇒_2 P;
184 or_prop1_ : ∀p,q. (or_f_ p ≤ q) = (p ≤ or_f_star_ q);
185 or_prop2_ : ∀p,q. (or_f_minus_ p ≤ q) = (p ≤ or_f_minus_star_ q);
186 or_prop3_ : ∀p,q. (or_f_ p >< q) = (p >< or_f_minus_ q)
189 definition ORelation_setoid : OAlgebra → OAlgebra → setoid2.
192 [ apply (ORelation P Q);
194 (* tenere solo una uguaglianza e usare la proposizione 9.9 per
195 le altre (unicita' degli aggiunti e del simmetrico) *)
197 (or_f_minus_star_ ?? p = or_f_minus_star_ ?? q)
198 (or_f_minus_ ?? p = or_f_minus_ ?? q)
199 (or_f_ ?? p = or_f_ ?? q)
200 (or_f_star_ ?? p = or_f_star_ ?? q));
201 | whd; simplify; intros; repeat split; intros; apply refl2;
202 | whd; simplify; intros; cases a; clear a; split;
203 intro a; apply sym1; generalize in match a;assumption;
204 | whd; simplify; intros; cases a; cases a1; clear a a1; split; intro a;
205 [ apply (.= (e a)); apply e4;
206 | apply (.= (e1 a)); apply e5;
207 | apply (.= (e2 a)); apply e6;
208 | apply (.= (e3 a)); apply e7;]]]
211 definition ORelation_of_ORelation_setoid :
212 ∀P,Q.ORelation_setoid P Q → ORelation P Q ≝ λP,Q,x.x.
213 coercion ORelation_of_ORelation_setoid.
215 definition or_f_minus_star: ∀P,Q:OAlgebra.(ORelation_setoid P Q) ⇒_2 (P ⇒_2 Q).
216 intros; constructor 1;
217 [ apply or_f_minus_star_;
218 | intros; cases e; assumption]
221 definition or_f: ∀P,Q:OAlgebra.(ORelation_setoid P Q) ⇒_2 (P ⇒_2 Q).
222 intros; constructor 1;
224 | intros; cases e; assumption]
227 definition or_f_minus: ∀P,Q:OAlgebra.(ORelation_setoid P Q) ⇒_2 (Q ⇒_2 P).
228 intros; constructor 1;
230 | intros; cases e; assumption]
233 definition or_f_star: ∀P,Q:OAlgebra.(ORelation_setoid P Q) ⇒_2 (Q ⇒_2 P).
234 intros; constructor 1;
236 | intros; cases e; assumption]
239 lemma arrows1_of_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → (P ⇒_2 Q).
240 intros; apply (or_f ?? c);
242 coercion arrows1_of_ORelation_setoid.
244 interpretation "o-relation f⎻*" 'OR_f_minus_star r = (fun12 ?? (or_f_minus_star ? ?) r).
245 interpretation "o-relation f⎻" 'OR_f_minus r = (fun12 ?? (or_f_minus ? ?) r).
246 interpretation "o-relation f*" 'OR_f_star r = (fun12 ?? (or_f_star ? ?) r).
248 definition or_prop1 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
249 (F p ≤ q) =_1 (p ≤ F* q).
250 intros; apply (or_prop1_ ?? F p q);
253 definition or_prop2 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
254 (F⎻ p ≤ q) = (p ≤ F⎻* q).
255 intros; apply (or_prop2_ ?? F p q);
258 definition or_prop3 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
259 (F p >< q) = (p >< F⎻ q).
260 intros; apply (or_prop3_ ?? F p q);
263 definition ORelation_composition : ∀P,Q,R.
264 (ORelation_setoid P Q) × (ORelation_setoid Q R) ⇒_2 (ORelation_setoid P R).
270 | apply rule (G⎻* ∘ F⎻* );
274 change with ((G (F p) ≤ q) = (p ≤ (F* (G* q))));
275 apply (.= (or_prop1 :?));
278 change with ((F⎻ (G⎻ p) ≤ q) = (p ≤ (G⎻* (F⎻* q))));
279 apply (.= (or_prop2 :?));
281 | intros; change with ((G (F (p)) >< q) = (p >< (F⎻ (G⎻ q))));
282 apply (.= (or_prop3 :?));
285 | intros; split; simplify;
286 [3: unfold arrows1_of_ORelation_setoid; apply ((†e)‡(†e1));
287 |1: apply ((†e)‡(†e1));
288 |2,4: apply ((†e1)‡(†e));]]
291 definition OA : category2.
294 | intros; apply (ORelation_setoid o o1);
297 |5,6,7:intros; apply refl1;]
298 | apply ORelation_composition;
299 | intros (P Q R S F G H); split;
300 [ change with (H⎻* ∘ G⎻* ∘ F⎻* = H⎻* ∘ (G⎻* ∘ F⎻* ));
301 apply (comp_assoc2 ????? (F⎻* ) (G⎻* ) (H⎻* ));
302 | apply ((comp_assoc2 ????? (H⎻) (G⎻) (F⎻))^-1);
303 | apply ((comp_assoc2 ????? F G H)^-1);
304 | apply ((comp_assoc2 ????? H* G* F* ));]
305 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_left2;
306 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_right2;]
309 definition OAlgebra_of_objs2_OA: objs2 OA → OAlgebra ≝ λx.x.
310 coercion OAlgebra_of_objs2_OA.
312 definition ORelation_setoid_of_arrows2_OA:
313 ∀P,Q. arrows2 OA P Q → ORelation_setoid P Q ≝ λP,Q,c.c.
314 coercion ORelation_setoid_of_arrows2_OA.
316 prefer coercion Type_OF_objs2.
318 notation > "B ⇒_\o2 C" right associative with precedence 72 for @{'arrows2_OA $B $C}.
319 notation "B ⇒\sub (\o 2) C" right associative with precedence 72 for @{'arrows2_OA $B $C}.
320 interpretation "'arrows2_OA" 'arrows2_OA A B = (arrows2 OA A B).
322 (* qui la notazione non va *)
323 lemma leq_to_eq_join: ∀S:OA.∀p,q:S. p ≤ q → q = (binary_join ? p q).
325 apply oa_leq_antisym;
326 [ apply oa_density; intros;
327 apply oa_overlap_sym;
328 unfold binary_join; simplify;
329 apply (. (oa_join_split : ?));
330 exists; [ apply false ]
331 apply oa_overlap_sym;
333 | unfold binary_join; simplify;
334 apply (. (oa_join_sup : ?)); intro;
335 cases i; whd in ⊢ (? ? ? ? ? % ?);
336 [ assumption | apply oa_leq_refl ]]
339 lemma overlap_monotone_left: ∀S:OA.∀p,q,r:S. p ≤ q → p >< r → q >< r.
341 apply (. (leq_to_eq_join : ?)‡#);
344 | apply oa_overlap_sym;
345 unfold binary_join; simplify;
346 apply (. (oa_join_split : ?));
347 exists [ apply true ]
348 apply oa_overlap_sym;
352 (* Part of proposition 9.9 *)
353 lemma f_minus_image_monotone: ∀S,T.∀R:arrows2 OA S T.∀p,q. p ≤ q → R⎻ p ≤ R⎻ q.
355 apply (. (or_prop2 : ?));
356 apply oa_leq_trans; [2: apply f; | skip | apply (. (or_prop2 : ?)^ -1); apply oa_leq_refl;]
359 (* Part of proposition 9.9 *)
360 lemma f_minus_star_image_monotone: ∀S,T.∀R:arrows2 OA S T.∀p,q. p ≤ q → R⎻* p ≤ R⎻* q.
362 apply (. (or_prop2 : ?)^ -1);
363 apply oa_leq_trans; [3: apply f; | skip | apply (. (or_prop2 : ?)); apply oa_leq_refl;]
366 (* Part of proposition 9.9 *)
367 lemma f_image_monotone: ∀S,T.∀R:arrows2 OA S T.∀p,q. p ≤ q → R p ≤ R q.
369 apply (. (or_prop1 : ?));
370 apply oa_leq_trans; [2: apply f; | skip | apply (. (or_prop1 : ?)^ -1); apply oa_leq_refl;]
373 (* Part of proposition 9.9 *)
374 lemma f_star_image_monotone: ∀S,T.∀R:arrows2 OA S T.∀p,q. p ≤ q → R* p ≤ R* q.
376 apply (. (or_prop1 : ?)^ -1);
377 apply oa_leq_trans; [3: apply f; | skip | apply (. (or_prop1 : ?)); apply oa_leq_refl;]
380 lemma lemma_10_2_a: ∀S,T.∀R:arrows2 OA S T.∀p. p ≤ R⎻* (R⎻ p).
382 apply (. (or_prop2 : ?)^-1);
386 lemma lemma_10_2_b: ∀S,T.∀R:arrows2 OA S T.∀p. R⎻ (R⎻* p) ≤ p.
388 apply (. (or_prop2 : ?));
392 lemma lemma_10_2_c: ∀S,T.∀R:arrows2 OA S T.∀p. p ≤ R* (R p).
394 apply (. (or_prop1 : ?)^-1);
398 lemma lemma_10_2_d: ∀S,T.∀R:arrows2 OA S T.∀p. R (R* p) ≤ p.
400 apply (. (or_prop1 : ?));
404 lemma lemma_10_3_a: ∀S,T.∀R:arrows2 OA S T.∀p. R⎻ (R⎻* (R⎻ p)) = R⎻ p.
405 intros; apply oa_leq_antisym;
406 [ apply lemma_10_2_b;
407 | apply f_minus_image_monotone;
408 apply lemma_10_2_a; ]
411 lemma lemma_10_3_b: ∀S,T.∀R:arrows2 OA S T.∀p. R* (R (R* p)) = R* p.
412 intros; apply oa_leq_antisym;
413 [ apply f_star_image_monotone;
414 apply (lemma_10_2_d ?? R p);
415 | apply lemma_10_2_c; ]
418 lemma lemma_10_3_c: ∀S,T.∀R:arrows2 OA S T.∀p. R (R* (R p)) = R p.
419 intros; apply oa_leq_antisym;
420 [ apply lemma_10_2_d;
421 | apply f_image_monotone;
422 apply (lemma_10_2_c ?? R p); ]
425 lemma lemma_10_3_d: ∀S,T.∀R:arrows2 OA S T.∀p. R⎻* (R⎻ (R⎻* p)) = R⎻* p.
426 intros; apply oa_leq_antisym;
427 [ apply f_minus_star_image_monotone;
428 apply (lemma_10_2_b ?? R p);
429 | apply lemma_10_2_a; ]
432 lemma lemma_10_4_a: ∀S,T.∀R:arrows2 OA S T.∀p. R⎻* (R⎻ (R⎻* (R⎻ p))) = R⎻* (R⎻ p).
433 intros; apply (†(lemma_10_3_a ?? R p));
436 lemma lemma_10_4_b: ∀S,T.∀R:arrows2 OA S T.∀p. R (R* (R (R* p))) = R (R* p).
437 intros; unfold in ⊢ (? ? ? % %); apply (†(lemma_10_3_b ?? R p));
440 lemma oa_overlap_sym': ∀o:OA.∀U,V:o. (U >< V) = (V >< U).
441 intros; split; intro; apply oa_overlap_sym; assumption.