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 interpretation "o-algebra binary meet" 'and a b =
138 (fun21 ___ (binary_meet _) a b).
140 coercion Type1_OF_OAlgebra nocomposites.
142 lemma oa_overlap_preservers_meet: ∀O:OAlgebra.∀p,q:O.p >< q → p >< (p ∧ q).
143 (* next change to avoid universe inconsistency *)
144 change in ⊢ (?→%→%→?) with (Type1_OF_OAlgebra O);
145 intros; lapply (oa_overlap_preserves_meet_ O p q f);
146 lapply (prop21 O O CPROP (oa_overlap O) p p ? (p ∧ q) # ?);
147 [3: apply (if ?? (Hletin1)); apply Hletin;|skip] apply refl1;
150 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)"
151 non associative with precedence 49 for @{ 'oa_join $p }.
152 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈ I) break term 90 p)"
153 non associative with precedence 49 for @{ 'oa_join_mk (λ${ident i}:$I.$p) }.
154 notation < "hovbox(a ∨ b)" left associative with precedence 49
155 for @{ 'oa_join_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
157 notation > "hovbox(∨ f)" non associative with precedence 59
158 for @{ 'oa_join $f }.
159 notation > "hovbox(a ∨ b)" left associative with precedence 49
160 for @{ 'oa_join (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
162 interpretation "o-algebra join" 'oa_join f =
163 (fun12 __ (oa_join __) f).
164 interpretation "o-algebra join with explicit function" 'oa_join_mk f =
165 (fun12 __ (oa_join __) (mk_unary_morphism _ _ f _)).
167 definition hint5: OAlgebra → objs2 SET1.
168 intro; apply (oa_P o);
172 record ORelation (P,Q : OAlgebra) : Type ≝ {
174 or_f_minus_star_ : P ⇒ Q;
177 or_prop1_ : ∀p,q. (or_f_ p ≤ q) = (p ≤ or_f_star_ q);
178 or_prop2_ : ∀p,q. (or_f_minus_ p ≤ q) = (p ≤ or_f_minus_star_ q);
179 or_prop3_ : ∀p,q. (or_f_ p >< q) = (p >< or_f_minus_ q)
182 definition ORelation_setoid : OAlgebra → OAlgebra → setoid2.
185 [ apply (ORelation P Q);
187 (* tenere solo una uguaglianza e usare la proposizione 9.9 per
188 le altre (unicita' degli aggiunti e del simmetrico) *)
189 [ apply (λp,q. And4 (eq2 ? (or_f_minus_star_ ?? p) (or_f_minus_star_ ?? q))
190 (eq2 ? (or_f_minus_ ?? p) (or_f_minus_ ?? q))
191 (eq2 ? (or_f_ ?? p) (or_f_ ?? q))
192 (eq2 ? (or_f_star_ ?? p) (or_f_star_ ?? q)));
193 | whd; simplify; intros; repeat split; intros; apply refl2;
194 | whd; simplify; intros; cases H; clear H; split;
195 intro a; apply sym1; generalize in match a;assumption;
196 | whd; simplify; intros; cases H; cases H1; clear H H1; split; intro a;
197 [ apply (.= (e a)); apply e4;
198 | apply (.= (e1 a)); apply e5;
199 | apply (.= (e2 a)); apply e6;
200 | apply (.= (e3 a)); apply e7;]]]
203 definition or_f_minus_star:
204 ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (P ⇒ Q).
205 intros; constructor 1;
206 [ apply or_f_minus_star_;
207 | intros; cases e; assumption]
210 definition or_f: ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (P ⇒ Q).
211 intros; constructor 1;
213 | intros; cases e; assumption]
218 definition or_f_minus: ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (Q ⇒ P).
219 intros; constructor 1;
221 | intros; cases e; assumption]
224 definition or_f_star: ∀P,Q:OAlgebra.unary_morphism2 (ORelation_setoid P Q) (Q ⇒ P).
225 intros; constructor 1;
227 | intros; cases e; assumption]
230 lemma arrows1_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → (P ⇒ Q).
231 intros; apply (or_f ?? t);
234 coercion arrows1_OF_ORelation_setoid.
236 lemma umorphism_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → unary_morphism1 P Q.
237 intros; apply (or_f ?? t);
240 coercion umorphism_OF_ORelation_setoid.
242 lemma umorphism_setoid_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → unary_morphism1_setoid1 P Q.
243 intros; apply (or_f ?? t);
246 coercion umorphism_setoid_OF_ORelation_setoid.
248 lemma uncurry_arrows : ∀B,C. ORelation_setoid B C → B → C.
249 intros; apply ((fun11 ?? t) t1);
252 coercion uncurry_arrows 1.
254 lemma hint6: ∀P,Q. Type_OF_setoid2 (hint5 P ⇒ hint5 Q) → unary_morphism1 P Q.
259 notation "r \sup *" non associative with precedence 90 for @{'OR_f_star $r}.
260 notation > "r *" non associative with precedence 90 for @{'OR_f_star $r}.
262 notation "r \sup (⎻* )" non associative with precedence 90 for @{'OR_f_minus_star $r}.
263 notation > "r⎻*" non associative with precedence 90 for @{'OR_f_minus_star $r}.
265 notation "r \sup ⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
266 notation > "r⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
268 interpretation "o-relation f⎻*" 'OR_f_minus_star r = (fun12 __ (or_f_minus_star _ _) r).
269 interpretation "o-relation f⎻" 'OR_f_minus r = (fun12 __ (or_f_minus _ _) r).
270 interpretation "o-relation f*" 'OR_f_star r = (fun12 __ (or_f_star _ _) r).
272 definition or_prop1 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
273 (F p ≤ q) = (p ≤ F* q).
274 intros; apply (or_prop1_ ?? F p q);
277 definition or_prop2 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
278 (F⎻ p ≤ q) = (p ≤ F⎻* q).
279 intros; apply (or_prop2_ ?? F p q);
282 definition or_prop3 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
283 (F p >< q) = (p >< F⎻ q).
284 intros; apply (or_prop3_ ?? F p q);
287 definition ORelation_composition : ∀P,Q,R.
288 binary_morphism2 (ORelation_setoid P Q) (ORelation_setoid Q R) (ORelation_setoid P R).
294 | apply rule (G⎻* ∘ F⎻* );
298 change with ((G (F p) ≤ q) = (p ≤ (F* (G* q))));
299 apply (.= (or_prop1 :?));
302 change with ((F⎻ (G⎻ p) ≤ q) = (p ≤ (G⎻* (F⎻* q))));
303 apply (.= (or_prop2 :?));
305 | intros; change with ((G (F (p)) >< q) = (p >< (F⎻ (G⎻ q))));
306 apply (.= (or_prop3 :?));
309 | intros; split; simplify;
310 [1,3: unfold umorphism_setoid_OF_ORelation_setoid; unfold arrows1_OF_ORelation_setoid; apply ((†e)‡(†e1));
311 |2,4: apply ((†e1)‡(†e));]]
314 definition OA : category2.
317 | intros; apply (ORelation_setoid o o1);
320 |5,6,7:intros; apply refl1;]
321 | apply ORelation_composition;
322 | intros (P Q R S F G H); split;
323 [ change with (H⎻* ∘ G⎻* ∘ F⎻* = H⎻* ∘ (G⎻* ∘ F⎻* ));
324 apply (comp_assoc2 ????? (F⎻* ) (G⎻* ) (H⎻* ));
325 | apply ((comp_assoc2 ????? (H⎻) (G⎻) (F⎻))^-1);
326 | apply ((comp_assoc2 ????? F G H)^-1);
327 | apply ((comp_assoc2 ????? H* G* F* ));]
328 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_left2;
329 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_right2;]
332 lemma setoid1_of_OA: OA → setoid1.
333 intro; apply (oa_P t);
335 coercion setoid1_of_OA.
337 lemma SET1_of_OA: OA → SET1.
338 intro; whd; apply (setoid1_of_OA t);
342 lemma objs2_SET1_OF_OA: OA → objs2 SET1.
343 intro; whd; apply (setoid1_of_OA t);
345 coercion objs2_SET1_OF_OA.
347 lemma Type_OF_category2_OF_SET1_OF_OA: OA → Type_OF_category2 SET1.
348 intro; apply (oa_P t);
350 coercion Type_OF_category2_OF_SET1_OF_OA.