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 definition hint: Type_OF_category2 SET1 → setoid2.
53 intro; apply (setoid2_of_setoid1 t); qed.
56 definition hint2: Type_OF_category1 SET → objs2 SET1.
57 intro; apply (setoid1_of_setoid t); qed.
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 := {
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;
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 *)
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);
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
95 ∀p,q.(∀r.oa_overlap p r → oa_overlap q r) → oa_leq p q
98 interpretation "o-algebra leq" 'leq a b = (fun21 ___ (oa_leq _) a b).
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).
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) }.
110 notation < "hovbox(a ∧ b)" left associative with precedence 35
111 for @{ 'oa_meet_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
113 notation > "hovbox(∧ f)" non associative with precedence 60
114 for @{ 'oa_meet $f }.
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)) }.
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 _)).
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; apply (prop_1 ?? (oa_meet O BOOL)); intro x; simplify;
131 cases x; simplify; assumption;]
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).
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;
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 ]) }.
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)) }.
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 _)).
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)
173 definition ORelation_setoid : OAlgebra → OAlgebra → setoid1.
176 [ apply (ORelation P Q);
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;]]]
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]
200 definition or_f: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET P Q.
201 intros; constructor 1;
203 | intros; cases H; assumption]
208 definition or_f_minus: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET Q P.
209 intros; constructor 1;
211 | intros; cases H; assumption]
214 definition or_f_star: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET Q P.
215 intros; constructor 1;
217 | intros; cases H; assumption]
220 lemma arrows1_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → arrows1 SET P Q.
221 intros; apply (or_f ?? c);
224 coercion arrows1_OF_ORelation_setoid nocomposites.
226 lemma umorphism_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → P ⇒ Q.
227 intros; apply (or_f ?? c);
230 coercion umorphism_OF_ORelation_setoid.
233 lemma uncurry_arrows : ∀B,C. arrows1 SET B C → B → C.
234 intros; apply ((fun_1 ?? c) t);
237 coercion uncurry_arrows 1.
239 lemma hint3 : ∀P,Q. arrows1 SET P Q → P ⇒ Q. intros; apply c;qed.
240 coercion hint3 nocomposites.
243 lemma hint2: OAlgebra → setoid. intros; apply (oa_P o). qed.
244 coercion hint2 nocomposites.
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}.
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}.
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}.
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).
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);
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);
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);
276 definition ORelation_composition : ∀P,Q,R.
277 binary_morphism1 (ORelation_setoid P Q) (ORelation_setoid Q R) (ORelation_setoid P R).
283 | apply (G⎻* ∘ F⎻* );
287 change with ((G (F p) ≤ q) = (p ≤ (F* (G* q))));
288 apply (.= (or_prop1 :?));
291 change with ((F⎻ (G⎻ p) ≤ q) = (p ≤ (G⎻* (F⎻* q))));
292 apply (.= (or_prop2 :?));
294 | intros; change with ((G (F (p)) >< q) = (p >< (F⎻ (G⎻ q))));
295 apply (.= (or_prop3 :?));
298 | intros; split; simplify;
299 [1,3: unfold arrows1_OF_ORelation_setoid; apply ((†H)‡(†H1));
300 |2,4: apply ((†H1)‡(†H));]]
303 definition OA : category1.
306 | intros; apply (ORelation_setoid o o1);
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;]