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 "datatypes/categories.ma".
16 include "logic/cprop_connectives.ma".
18 inductive bool : Type := 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 definition setoid_OF_SET: objs1 SET → setoid.
32 coercion setoid_OF_SET.
34 lemma IF_THEN_ELSE_p :
35 ∀S:setoid.∀a,b:S.∀x,y:BOOL.x = y →
36 (λm.match m with [ true ⇒ a | false ⇒ b ]) x =
37 (λm.match m with [ true ⇒ a | false ⇒ b ]) y.
39 intros; cases x in H; cases y; simplify; intros; try apply refl; whd in H; cases H;
42 interpretation "unary morphism comprehension with no proof" 'comprehension T P =
43 (mk_unary_morphism T _ P _).
45 notation > "hvbox({ ident i ∈ s | term 19 p | by })" with precedence 90
46 for @{ 'comprehension_by $s (λ${ident i}. $p) $by}.
47 notation < "hvbox({ ident i ∈ s | term 19 p })" with precedence 90
48 for @{ 'comprehension_by $s (λ${ident i}:$_. $p) $by}.
50 interpretation "unary morphism comprehension with proof" 'comprehension_by s \eta.f p =
51 (mk_unary_morphism s _ f p).
53 record OAlgebra : Type := {
55 oa_leq : binary_morphism1 oa_P oa_P CPROP; (* CPROP is setoid1 *)
56 oa_overlap: binary_morphism1 oa_P oa_P CPROP;
57 oa_meet: ∀I:SET.unary_morphism (arrows1 SET I oa_P) oa_P;
58 oa_join: ∀I:SET.unary_morphism (arrows1 SET I oa_P) oa_P;
61 oa_leq_refl: ∀a:oa_P. oa_leq a a;
62 oa_leq_antisym: ∀a,b:oa_P.oa_leq a b → oa_leq b a → a = b;
63 oa_leq_trans: ∀a,b,c:oa_P.oa_leq a b → oa_leq b c → oa_leq a c;
64 oa_overlap_sym: ∀a,b:oa_P.oa_overlap a b → oa_overlap b a;
65 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);
66 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;
67 oa_zero_bot: ∀p:oa_P.oa_leq oa_zero p;
68 oa_one_top: ∀p:oa_P.oa_leq p oa_one;
69 oa_overlap_preservers_meet:
70 ∀p,q.oa_overlap p q → oa_overlap p
71 (oa_meet ? { x ∈ BOOL | match x with [ true ⇒ p | false ⇒ q ] | IF_THEN_ELSE_p oa_P p q });
73 ∀I:SET.∀p.∀q:arrows1 SET I oa_P.oa_overlap p (oa_join I q) ⇔ ∃i:I.oa_overlap p (q i);
75 oa_enum : ums oa_base oa_P;
76 oa_density: ∀p,q.(∀i.oa_overlap p (oa_enum i) → oa_overlap q (oa_enum i)) → oa_leq p q
79 ∀p,q.(∀r.oa_overlap p r → oa_overlap q r) → oa_leq p q
82 interpretation "o-algebra leq" 'leq a b = (fun1 ___ (oa_leq _) a b).
84 notation "hovbox(a mpadded width -150% (>)< b)" non associative with precedence 45
85 for @{ 'overlap $a $b}.
86 interpretation "o-algebra overlap" 'overlap a b = (fun1 ___ (oa_overlap _) a b).
88 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (\emsp) \nbsp term 90 p)"
89 non associative with precedence 50 for @{ 'oa_meet $p }.
90 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (ident i ∈ I) break term 90 p)"
91 non associative with precedence 50 for @{ 'oa_meet_mk (λ${ident i}:$I.$p) }.
92 notation < "hovbox(a ∧ b)" left associative with precedence 35
93 for @{ 'oa_meet_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
95 notation > "hovbox(∧ f)" non associative with precedence 60
97 notation > "hovbox(a ∧ b)" left associative with precedence 50
98 for @{ 'oa_meet (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
100 interpretation "o-algebra meet" 'oa_meet f =
101 (fun_1 __ (oa_meet __) f).
102 interpretation "o-algebra meet with explicit function" 'oa_meet_mk f =
103 (fun_1 __ (oa_meet __) (mk_unary_morphism _ _ f _)).
105 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)"
106 non associative with precedence 49 for @{ 'oa_join $p }.
107 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈ I) break term 90 p)"
108 non associative with precedence 49 for @{ 'oa_join_mk (λ${ident i}:$I.$p) }.
109 notation < "hovbox(a ∨ b)" left associative with precedence 49
110 for @{ 'oa_join_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
112 notation > "hovbox(∨ f)" non associative with precedence 59
113 for @{ 'oa_join $f }.
114 notation > "hovbox(a ∨ b)" left associative with precedence 49
115 for @{ 'oa_join (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
117 interpretation "o-algebra join" 'oa_join f =
118 (fun_1 __ (oa_join __) f).
119 interpretation "o-algebra join with explicit function" 'oa_join_mk f =
120 (fun_1 __ (oa_join __) (mk_unary_morphism _ _ f _)).
122 record ORelation (P,Q : OAlgebra) : Type ≝ {
123 or_f_ : arrows1 SET P Q;
124 or_f_minus_star_ : arrows1 SET P Q;
125 or_f_star_ : arrows1 SET Q P;
126 or_f_minus_ : arrows1 SET Q P;
127 or_prop1_ : ∀p,q. (or_f_ p ≤ q) = (p ≤ or_f_star_ q);
128 or_prop2_ : ∀p,q. (or_f_minus_ p ≤ q) = (p ≤ or_f_minus_star_ q);
129 or_prop3_ : ∀p,q. (or_f_ p >< q) = (p >< or_f_minus_ q)
133 definition ORelation_setoid : OAlgebra → OAlgebra → setoid1.
136 [ apply (ORelation P Q);
138 [ apply (λp,q. And4 (eq1 ? (or_f_minus_star_ ?? p) (or_f_minus_star_ ?? q))
139 (eq1 ? (or_f_minus_ ?? p) (or_f_minus_ ?? q))
140 (eq1 ? (or_f_ ?? p) (or_f_ ?? q))
141 (eq1 ? (or_f_star_ ?? p) (or_f_star_ ?? q)));
142 | whd; simplify; intros; repeat split; intros; apply refl1;
143 | whd; simplify; intros; cases H; clear H; split;
144 intro a; apply sym; generalize in match a;assumption;
145 | whd; simplify; intros; cases H; cases H1; clear H H1; split; intro a;
146 [ apply (.= (H2 a)); apply H6;
147 | apply (.= (H3 a)); apply H7;
148 | apply (.= (H4 a)); apply H8;
149 | apply (.= (H5 a)); apply H9;]]]
152 definition or_f_minus_star: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET P Q.
153 intros; constructor 1;
154 [ apply or_f_minus_star_;
155 | intros; cases H; assumption]
158 definition or_f: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET P Q.
159 intros; constructor 1;
161 | intros; cases H; assumption]
166 definition or_f_minus: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET Q P.
167 intros; constructor 1;
169 | intros; cases H; assumption]
172 definition or_f_star: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET Q P.
173 intros; constructor 1;
175 | intros; cases H; assumption]
178 lemma arrows1_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → arrows1 SET P Q.
179 intros; apply (or_f ?? c);
182 coercion arrows1_OF_ORelation_setoid nocomposites.
184 lemma umorphism_OF_ORelation_setoid : ∀P,Q. ORelation_setoid P Q → P ⇒ Q.
185 intros; apply (or_f ?? c);
188 coercion umorphism_OF_ORelation_setoid.
191 lemma uncurry_arrows : ∀B,C. arrows1 SET B C → B → C.
192 intros; apply ((fun_1 ?? c) t);
195 coercion uncurry_arrows 1.
197 lemma hint3 : ∀P,Q. arrows1 SET P Q → P ⇒ Q. intros; apply c;qed.
198 coercion hint3 nocomposites.
201 lemma hint2: OAlgebra → setoid. intros; apply (oa_P o). qed.
202 coercion hint2 nocomposites.
206 notation "r \sup *" non associative with precedence 90 for @{'OR_f_star $r}.
207 notation > "r *" non associative with precedence 90 for @{'OR_f_star $r}.
209 notation "r \sup (⎻* )" non associative with precedence 90 for @{'OR_f_minus_star $r}.
210 notation > "r⎻*" non associative with precedence 90 for @{'OR_f_minus_star $r}.
212 notation "r \sup ⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
213 notation > "r⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
215 interpretation "o-relation f⎻*" 'OR_f_minus_star r = (fun_1 __ (or_f_minus_star _ _) r).
216 interpretation "o-relation f⎻" 'OR_f_minus r = (fun_1 __ (or_f_minus _ _) r).
217 interpretation "o-relation f*" 'OR_f_star r = (fun_1 __ (or_f_star _ _) r).
219 definition or_prop1 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
220 (F p ≤ q) = (p ≤ F* q).
221 intros; apply (or_prop1_ ?? F p q);
224 definition or_prop2 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
225 (F⎻ p ≤ q) = (p ≤ F⎻* q).
226 intros; apply (or_prop2_ ?? F p q);
229 definition or_prop3 : ∀P,Q:OAlgebra.∀F:ORelation_setoid P Q.∀p,q.
230 (F p >< q) = (p >< F⎻ q).
231 intros; apply (or_prop3_ ?? F p q);
234 definition ORelation_composition : ∀P,Q,R.
235 binary_morphism1 (ORelation_setoid P Q) (ORelation_setoid Q R) (ORelation_setoid P R).
242 | apply (G⎻* ∘ F⎻* );
246 change with ((G (F p) ≤ q) = (p ≤ (F* (G* q))));
247 apply (.= (or_prop1 :?));
250 change with ((F⎻ (G⎻ p) ≤ q) = (p ≤ (G⎻* (F⎻* q))));
251 apply (.= (or_prop2 :?));
253 | intros; change with ((G (F (p)) >< q) = (p >< (F⎻ (G⎻ q))));
254 apply (.= (or_prop3 :?));
257 | intros; split; simplify;
258 [1,3: unfold arrows1_OF_ORelation_setoid; apply ((†H)‡(†H1));
259 |2,4: apply ((†H1)‡(†H));]]
262 definition OA : category1.
265 | intros; apply (ORelation_setoid o o1);
268 |5,6,7:intros; apply refl1;]
269 | apply ORelation_composition;
270 | intros (P Q R S F G H); split;
271 [ change with (H⎻* ∘ G⎻* ∘ F⎻* = H⎻* ∘ (G⎻* ∘ F⎻* ));
272 apply (comp_assoc1 ????? (F⎻* ) (G⎻* ) (H⎻* ));
273 | apply ((comp_assoc1 ????? (H⎻) (G⎻) (F⎻))^-1);
274 | apply ((comp_assoc1 ????? F G H)^-1);
275 | apply ((comp_assoc1 ????? H* G* F* ));]
276 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_left1;
277 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_right1;]