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 "categories.ma".
16 include "logic/cprop_connectives.ma".
18 inductive bool : Type0 := true : bool | false : bool.
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]
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.
34 intros; cases x in e; cases y; simplify; intros; try apply refl1; whd in e; cases e;
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 _).
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}.
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).
52 (* per il set-indexing vedere capitolo BPTools (foundational tools), Sect. 0.3.4 complete
53 lattices, Definizione 0.9 *)
54 (* USARE L'ESISTENZIALE DEBOLE *)
55 (*alias symbol "comprehension_by" = "unary morphism comprehension with proof".*)
56 record OAlgebra : Type2 := {
58 oa_leq : binary_morphism1 oa_P oa_P CPROP; (* CPROP is setoid1, CPROP importante che sia small *)
59 oa_overlap: binary_morphism1 oa_P oa_P CPROP;
60 oa_meet: ∀I:SET.unary_morphism2 (arrows2 SET1 I oa_P) oa_P;
61 oa_join: ∀I:SET.unary_morphism2 (arrows2 SET1 I oa_P) oa_P;
64 oa_leq_refl: ∀a:oa_P. oa_leq a a;
65 oa_leq_antisym: ∀a,b:oa_P.oa_leq a b → oa_leq b a → a = b;
66 oa_leq_trans: ∀a,b,c:oa_P.oa_leq a b → oa_leq b c → oa_leq a c;
67 oa_overlap_sym: ∀a,b:oa_P.oa_overlap a b → oa_overlap b a;
68 (* Errore: = in oa_meet_inf e oa_join_sup *)
69 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);
70 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;
71 oa_zero_bot: ∀p:oa_P.oa_leq oa_zero p;
72 oa_one_top: ∀p:oa_P.oa_leq p oa_one;
73 oa_overlap_preserves_meet_:
74 ∀p,q:oa_P.oa_overlap p q → oa_overlap p
75 (oa_meet ? { x ∈ BOOL | match x with [ true ⇒ p | false ⇒ q ] | IF_THEN_ELSE_p oa_P p q });
76 (* ⇔ deve essere =, l'esiste debole *)
78 ∀I:SET.∀p.∀q:arrows2 SET1 I oa_P.
79 oa_overlap p (oa_join I q) ⇔ ∃i:I.oa_overlap p (q i);
81 1) enum non e' il nome giusto perche' non e' suriettiva
82 2) manca (vedere altro capitolo) la "suriettivita'" come immagine di insiemi di oa_base
83 oa_enum : ums oa_base oa_P;
84 oa_density: ∀p,q.(∀i.oa_overlap p (oa_enum i) → oa_overlap q (oa_enum i)) → oa_leq p q
87 ∀p,q.(∀r.oa_overlap p r → oa_overlap q r) → oa_leq p q
90 interpretation "o-algebra leq" 'leq a b = (fun21 ___ (oa_leq _) a b).
92 notation "hovbox(a mpadded width -150% (>)< b)" non associative with precedence 45
93 for @{ 'overlap $a $b}.
94 interpretation "o-algebra overlap" 'overlap a b = (fun21 ___ (oa_overlap _) a b).
96 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (\emsp) \nbsp term 90 p)"
97 non associative with precedence 50 for @{ 'oa_meet $p }.
98 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (ident i ∈ I) break term 90 p)"
99 non associative with precedence 50 for @{ 'oa_meet_mk (λ${ident i}:$I.$p) }.
102 notation < "hovbox(a ∧ b)" left associative with precedence 35
103 for @{ 'oa_meet_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
105 notation > "hovbox(∧ f)" non associative with precedence 60
106 for @{ 'oa_meet $f }.
108 notation > "hovbox(a ∧ b)" left associative with precedence 50
109 for @{ 'oa_meet (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
111 interpretation "o-algebra meet" 'oa_meet f =
112 (fun12 __ (oa_meet __) f).
113 interpretation "o-algebra meet with explicit function" 'oa_meet_mk f =
114 (fun12 __ (oa_meet __) (mk_unary_morphism _ _ f _)).
116 definition hint3: OAlgebra → setoid1.
117 intro; apply (oa_P o);
121 definition hint4: ∀A. setoid2_OF_OAlgebra A → hint3 A.
126 definition binary_meet : ∀O:OAlgebra. binary_morphism1 O O 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 notation "hovbox(a ∧ b)" left associative with precedence 35
138 for @{ 'oa_meet_bin $a $b }.
139 interpretation "o-algebra binary meet" 'oa_meet_bin a b =
140 (fun21 ___ (binary_meet _) a b).
142 coercion Type1_OF_OAlgebra nocomposites.
144 lemma oa_overlap_preservers_meet: ∀O:OAlgebra.∀p,q:O.p >< q → p >< (p ∧ q).
145 (* next change to avoid universe inconsistency *)
146 change in ⊢ (?→%→%→?) with (Type1_OF_OAlgebra O);
147 intros; lapply (oa_overlap_preserves_meet_ O p q f);
148 lapply (prop21 O O CPROP (oa_overlap O) p p ? (p ∧ q) # ?);
149 [3: apply (if ?? (Hletin1)); apply Hletin;|skip] apply refl1;
152 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)"
153 non associative with precedence 49 for @{ 'oa_join $p }.
154 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈ I) break term 90 p)"
155 non associative with precedence 49 for @{ 'oa_join_mk (λ${ident i}:$I.$p) }.
156 notation < "hovbox(a ∨ b)" left associative with precedence 49
157 for @{ 'oa_join_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
159 notation > "hovbox(∨ f)" non associative with precedence 59
160 for @{ 'oa_join $f }.
161 notation > "hovbox(a ∨ b)" left associative with precedence 49
162 for @{ 'oa_join (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
164 interpretation "o-algebra join" 'oa_join f =
165 (fun12 __ (oa_join __) f).
166 interpretation "o-algebra join with explicit function" 'oa_join_mk f =
167 (fun12 __ (oa_join __) (mk_unary_morphism _ _ f _)).
169 definition hint5: OAlgebra → objs2 SET1.
170 intro; apply (oa_P o);
174 record ORelation (P,Q : OAlgebra) : Type ≝ {
176 or_f_minus_star_ : P ⇒ Q;
179 or_prop1_ : ∀p,q. (or_f_ p ≤ q) = (p ≤ or_f_star_ q);
180 or_prop2_ : ∀p,q. (or_f_minus_ p ≤ q) = (p ≤ or_f_minus_star_ q);
181 or_prop3_ : ∀p,q. (or_f_ p >< q) = (p >< or_f_minus_ q)
184 definition ORelation_setoid : OAlgebra → OAlgebra → setoid2.
187 [ apply (ORelation P Q);
189 (* tenere solo una uguaglianza e usare la proposizione 9.9 per
190 le altre (unicita' degli aggiunti e del simmetrico) *)
191 [ apply (λp,q. And4 (eq2 ? (or_f_minus_star_ ?? p) (or_f_minus_star_ ?? q))
192 (eq2 ? (or_f_minus_ ?? p) (or_f_minus_ ?? q))
193 (eq2 ? (or_f_ ?? p) (or_f_ ?? q))
194 (eq2 ? (or_f_star_ ?? p) (or_f_star_ ?? q)));
195 | whd; simplify; intros; repeat split; intros; apply refl2;
196 | whd; simplify; intros; cases H; clear H; split;
197 intro a; apply sym1; generalize in match a;assumption;
198 | whd; simplify; intros; cases H; cases H1; clear H H1; split; intro a;
199 [ apply (.= (e a)); apply e4;
200 | apply (.= (e1 a)); apply e5;
201 | apply (.= (e2 a)); apply e6;
202 | apply (.= (e3 a)); apply e7;]]]
205 definition or_f_minus_star:
206 ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (P ⇒ Q).
207 intros; constructor 1;
208 [ apply or_f_minus_star_;
209 | intros; cases e; assumption]
212 definition or_f: ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (P ⇒ Q).
213 intros; constructor 1;
215 | intros; cases e; assumption]
220 definition or_f_minus: ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (Q ⇒ P).
221 intros; constructor 1;
223 | intros; cases e; assumption]
226 definition or_f_star: ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (Q ⇒ P).
227 intros; constructor 1;
229 | intros; cases e; assumption]
232 lemma arrows1_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → (P ⇒ Q).
233 intros; apply (or_f ?? t);
236 coercion arrows1_OF_ORelation_setoid.
238 lemma umorphism_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → unary_morphism1 P Q.
239 intros; apply (or_f ?? t);
242 coercion umorphism_OF_ORelation_setoid.
244 lemma umorphism_setoid_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → unary_morphism1_setoid1 P Q.
245 intros; apply (or_f ?? t);
248 coercion umorphism_setoid_OF_ORelation_setoid.
250 lemma uncurry_arrows : ∀B,C. ORelation_setoid B C → B → C.
251 intros; apply ((fun11 ?? t) t1);
254 coercion uncurry_arrows 1.
256 lemma hint6: ∀P,Q. Type_OF_setoid2 (hint5 P ⇒ hint5 Q) → unary_morphism1 P Q.
261 notation "r \sup *" non associative with precedence 90 for @{'OR_f_star $r}.
262 notation > "r *" non associative with precedence 90 for @{'OR_f_star $r}.
264 notation "r \sup (⎻* )" non associative with precedence 90 for @{'OR_f_minus_star $r}.
265 notation > "r⎻*" non associative with precedence 90 for @{'OR_f_minus_star $r}.
267 notation "r \sup ⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
268 notation > "r⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
270 interpretation "o-relation f⎻*" 'OR_f_minus_star r = (fun12 __ (or_f_minus_star _ _) r).
271 interpretation "o-relation f⎻" 'OR_f_minus r = (fun12 __ (or_f_minus _ _) r).
272 interpretation "o-relation f*" 'OR_f_star r = (fun12 __ (or_f_star _ _) r).
274 definition or_prop1 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
275 (F p ≤ q) = (p ≤ F* q).
276 intros; apply (or_prop1_ ?? F p q);
279 definition or_prop2 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
280 (F⎻ p ≤ q) = (p ≤ F⎻* q).
281 intros; apply (or_prop2_ ?? F p q);
284 definition or_prop3 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
285 (F p >< q) = (p >< F⎻ q).
286 intros; apply (or_prop3_ ?? F p q);
289 definition ORelation_composition : ∀P,Q,R.
290 binary_morphism2 (ORelation_setoid P Q) (ORelation_setoid Q R) (ORelation_setoid P R).
296 | apply rule (G⎻* ∘ F⎻* );
300 change with ((G (F p) ≤ q) = (p ≤ (F* (G* q))));
301 apply (.= (or_prop1 :?));
304 change with ((F⎻ (G⎻ p) ≤ q) = (p ≤ (G⎻* (F⎻* q))));
305 apply (.= (or_prop2 :?));
307 | intros; change with ((G (F (p)) >< q) = (p >< (F⎻ (G⎻ q))));
308 apply (.= (or_prop3 :?));
311 | intros; split; simplify;
312 [1,3: unfold umorphism_setoid_OF_ORelation_setoid; unfold arrows1_OF_ORelation_setoid; apply ((†e)‡(†e1));
313 |2,4: apply ((†e1)‡(†e));]]
316 definition OA : category2.
319 | intros; apply (ORelation_setoid o o1);
322 |5,6,7:intros; apply refl1;]
323 | apply ORelation_composition;
324 | intros (P Q R S F G H); split;
325 [ change with (H⎻* ∘ G⎻* ∘ F⎻* = H⎻* ∘ (G⎻* ∘ F⎻* ));
326 apply (comp_assoc2 ????? (F⎻* ) (G⎻* ) (H⎻* ));
327 | apply ((comp_assoc2 ????? (H⎻) (G⎻) (F⎻))^-1);
328 | apply ((comp_assoc2 ????? F G H)^-1);
329 | apply ((comp_assoc2 ????? H* G* F* ));]
330 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_left2;
331 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_right2;]
334 lemma setoid1_of_OA: OA → setoid1.
335 intro; apply (oa_P t);
337 coercion setoid1_of_OA.
339 lemma SET1_of_OA: OA → SET1.
340 intro; whd; apply (setoid1_of_OA t);
344 lemma objs2_SET1_OF_OA: OA → objs2 SET1.
345 intro; whd; apply (setoid1_of_OA t);
347 coercion objs2_SET1_OF_OA.
349 lemma Type_OF_category2_OF_SET1_OF_OA: OA → Type_OF_category2 SET1.
350 intro; apply (oa_P t);
352 coercion Type_OF_category2_OF_SET1_OF_OA.