]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/formal_topology/overlap/o-algebra.ma
1) no more DAEMONS
[helm.git] / helm / software / matita / contribs / formal_topology / overlap / o-algebra.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "datatypes/categories.ma".
16 include "logic/cprop_connectives.ma". 
17
18 inductive bool : Type := true : bool | false : bool.
19
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; try assumption; apply I]
26 qed.
27
28 definition hint: objs1 SET → setoid.
29  intros; apply o;
30 qed.
31
32 coercion hint.
33
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.
38 intros; cases x in H; cases y; simplify; intros; try apply refl; whd in H; cases H;
39 qed. 
40
41
42 interpretation "unary morphism comprehension with no proof" 'comprehension T P = 
43   (mk_unary_morphism T _ P _).
44
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}.
49
50 interpretation "unary morphism comprehension with proof" 'comprehension_by s \eta.f p = 
51   (mk_unary_morphism s _ f p).
52
53
54 record OAlgebra : Type := {
55   oa_P :> SET;
56   oa_leq : binary_morphism1 oa_P oa_P CPROP; (* CPROP is setoid1 *)
57   oa_overlap: binary_morphism1 oa_P oa_P CPROP;
58   oa_meet: ∀I:SET.unary_morphism (arrows1 SET I oa_P) oa_P;
59   oa_join: ∀I:SET.unary_morphism (arrows1 SET I oa_P) oa_P;
60   oa_one: oa_P;
61   oa_zero: oa_P;
62   oa_leq_refl: ∀a:oa_P. oa_leq a a; 
63   oa_leq_antisym: ∀a,b:oa_P.oa_leq a b → oa_leq b a → a = b;
64   oa_leq_trans: ∀a,b,c:oa_P.oa_leq a b → oa_leq b c → oa_leq a c;
65   oa_overlap_sym: ∀a,b:oa_P.oa_overlap a b → oa_overlap b a;
66   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);
67   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;
68   oa_zero_bot: ∀p:oa_P.oa_leq oa_zero p;
69   oa_one_top: ∀p:oa_P.oa_leq p oa_one;
70   oa_overlap_preservers_meet: 
71       ∀p,q.oa_overlap p q → oa_overlap p 
72        (oa_meet ? { x ∈ BOOL | match x with [ true ⇒ p | false ⇒ q ] | IF_THEN_ELSE_p oa_P p q });
73      (*(oa_meet BOOL (if_then_else oa_P p q));*)
74   oa_join_split: (* ha I → oa_P da castare a funX (ums A oa_P) *)
75       ∀I:SET.∀p.∀q:arrows1 SET I oa_P.oa_overlap p (oa_join I q) ⇔ ∃i:I.oa_overlap p (q i);
76   (*oa_base : setoid;
77   oa_enum : ums oa_base oa_P;
78   oa_density: ∀p,q.(∀i.oa_overlap p (oa_enum i) → oa_overlap q (oa_enum i)) → oa_leq p q
79   *)
80   oa_density: 
81       ∀p,q.(∀r.oa_overlap p r → oa_overlap q r) → oa_leq p q
82 }.
83
84 interpretation "o-algebra leq" 'leq a b = (fun1 ___ (oa_leq _) a b).
85
86 notation "hovbox(a mpadded width -150% (>)< b)" non associative with precedence 45
87 for @{ 'overlap $a $b}.
88 interpretation "o-algebra overlap" 'overlap a b = (fun1 ___ (oa_overlap _) a b).
89
90 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (\emsp) \nbsp term 90 p)" 
91 non associative with precedence 50 for @{ 'oa_meet $p }.
92 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (ident i ∈  I) break term 90 p)" 
93 non associative with precedence 50 for @{ 'oa_meet_mk (λ${ident i}:$I.$p) }.
94 notation < "hovbox(a ∧ b)" left associative with precedence 35
95 for @{ 'oa_meet_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
96
97 notation > "hovbox(∧ f)" non associative with precedence 60
98 for @{ 'oa_meet $f }.
99 notation > "hovbox(a ∧ b)" left associative with precedence 50
100 for @{ 'oa_meet (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
101
102 interpretation "o-algebra meet" 'oa_meet f = 
103   (fun_1 __ (oa_meet __) f).
104 interpretation "o-algebra meet with explicit function" 'oa_meet_mk f = 
105   (fun_1 __ (oa_meet __) (mk_unary_morphism _ _ f _)).
106
107 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)" 
108 non associative with precedence 49 for @{ 'oa_join $p }.
109 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈  I) break term 90 p)" 
110 non associative with precedence 49 for @{ 'oa_join_mk (λ${ident i}:$I.$p) }.
111 notation < "hovbox(a ∨ b)" left associative with precedence 49
112 for @{ 'oa_join_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
113
114 notation > "hovbox(∨ f)" non associative with precedence 59
115 for @{ 'oa_join $f }.
116 notation > "hovbox(a ∨ b)" left associative with precedence 49
117 for @{ 'oa_join (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
118
119 interpretation "o-algebra join" 'oa_join f = 
120   (fun_1 __ (oa_join __) f).
121 interpretation "o-algebra join with explicit function" 'oa_join_mk f = 
122   (fun_1 __ (oa_join __) (mk_unary_morphism _ _ f _)).
123
124 record ORelation (P,Q : OAlgebra) : Type ≝ {
125   or_f :> arrows1 SET P Q;
126   or_f_minus_star : arrows1 SET P Q;
127   or_f_star : arrows1 SET Q P;
128   or_f_minus : arrows1 SET Q P;
129   or_prop1 : ∀p,q. (or_f p ≤ q) = (p ≤ or_f_star q);
130   or_prop2 : ∀p,q. (or_f_minus p ≤ q) = (p ≤ or_f_minus_star q);
131   or_prop3 : ∀p,q. (or_f p >< q) = (p >< or_f_minus q)
132 }.
133
134 notation "r \sup *" non associative with precedence 90 for @{'OR_f_star $r}.
135 notation > "r *" non associative with precedence 90 for @{'OR_f_star $r}.
136 interpretation "o-relation f*" 'OR_f_star r = (or_f_star _ _ r).
137
138 notation "r \sup (⎻* )" non associative with precedence 90 for @{'OR_f_minus_star $r}.
139 notation > "r⎻*" non associative with precedence 90 for @{'OR_f_minus_star $r}.
140 interpretation "o-relation f⎻*" 'OR_f_minus_star r = (or_f_minus_star _ _ r).
141
142 notation "r \sup ⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
143 notation > "r⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
144 interpretation "o-relation f⎻" 'OR_f_minus r = (or_f_minus _ _ r).
145
146 definition ORelation_setoid : OAlgebra → OAlgebra → setoid1.
147 intros (P Q);
148 constructor 1;
149 [ apply (ORelation P Q);
150 | constructor 1;
151    [ apply (λp,q. And4 (eq1 ? p⎻* q⎻* ) (eq1 ? p⎻ q⎻) (eq1 ? p q) (eq1 ? p* q* )); 
152    | whd; simplify; intros; repeat split; intros; apply refl1;
153    | whd; simplify; intros; cases H; clear H; split; 
154      intro a; apply sym; generalize in match a;assumption;
155    | whd; simplify; intros; cases H; cases H1; clear H H1; split; intro a;
156      [ apply (.= (H2 a)); apply H6;
157      | apply (.= (H3 a)); apply H7;
158      | apply (.= (H4 a)); apply H8;
159      | apply (.= (H5 a)); apply H9;]]]
160 qed.  
161
162 lemma hint1 : ∀P,Q. ORelation_setoid P Q → arrows1 SET P Q. intros; apply (or_f ?? c);qed.
163 coercion hint1.
164
165 lemma hint3 : ∀P,Q. arrows1 SET P Q → P ⇒ Q. intros; apply c;qed.
166 coercion hint3.
167
168 lemma hint2: OAlgebra → setoid. intros; apply (oa_P o). qed.
169 coercion hint2.
170
171 definition or_f_minus_star2: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET P Q.
172  intros; constructor 1;
173   [ apply or_f_minus_star;
174   | intros; cases H; assumption]
175 qed.
176
177 definition or_f2: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET P Q.
178  intros; constructor 1;
179   [ apply or_f;
180   | intros; cases H; assumption]
181 qed.
182
183 definition or_f_minus2: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET Q P.
184  intros; constructor 1;
185   [ apply or_f_minus;
186   | intros; cases H; assumption]
187 qed.
188
189 definition or_f_star2: ∀P,Q:OAlgebra.ORelation_setoid P Q ⇒ arrows1 SET Q P.
190  intros; constructor 1;
191   [ apply or_f_star;
192   | intros; cases H; assumption]
193 qed.
194
195 interpretation "o-relation f⎻* 2" 'OR_f_minus_star r = (fun_1 __ (or_f_minus_star2 _ _) r).
196 interpretation "o-relation f⎻ 2" 'OR_f_minus r = (fun_1 __ (or_f_minus2 _ _) r).
197 interpretation "o-relation f* 2" 'OR_f_star r = (fun_1 __ (or_f_star2 _ _) r).
198 coercion or_f2.
199
200 definition ORelation_composition : ∀P,Q,R. 
201   binary_morphism1 (ORelation_setoid P Q) (ORelation_setoid Q R) (ORelation_setoid P R).
202 intros;
203 constructor 1;
204 [ intros (F G);
205   constructor 1;
206   [ apply (or_f2 ?? G ∘ or_f2 ?? F);
207   | alias symbol "compose" = "category1 composition".
208     apply (G⎻* ∘ F⎻* );
209   | apply (F* ∘ G* );
210   | apply (F⎻ ∘ G⎻);
211   | intros;
212     alias symbol "eq" = "setoid1 eq".
213     change with ((G (F p) ≤ q) = (p ≤ (F* (G* q))));
214     apply (.= or_prop1 ??? (F p) ?);
215     apply (.= or_prop1 ??? p ?);
216     apply refl1
217   | intros; alias symbol "eq" = "setoid1 eq".
218     change with ((F⎻ (G⎻ p) ≤ q) = (p ≤ (G⎻* (F⎻* q))));
219     alias symbol "trans" = "trans1".
220     apply (.= or_prop2 ?? F ??);
221     apply (.= or_prop2 ?? G ??);
222     apply refl1;
223   | intros; change with ((G (F (p)) >< q) = (p >< (F⎻ (G⎻ q))));
224     apply (.= or_prop3 ??? (F p) ?);
225     apply (.= or_prop3 ??? p ?);
226     apply refl1
227   ]
228 | intros; split; simplify; [1,3: apply ((†H)‡(†H1)); | 2,4: apply ((†H1)‡(†H));]]
229 qed.
230
231 definition OA : category1.
232 split;
233 [ apply (OAlgebra);
234 | intros; apply (ORelation_setoid o o1);
235 | intro O; split;
236   [1,2,3,4: apply id1;
237   |5,6,7:intros; apply refl1;] 
238 | apply ORelation_composition;
239 | intros; split;
240    [ apply (comp_assoc1 ????? (a12⎻* ) (a23⎻* ) (a34⎻* ));
241    | alias symbol "invert" = "setoid1 symmetry".
242      apply ((comp_assoc1 ????? (a34⎻) (a23⎻) (a12⎻)) \sup -1);
243    | apply (comp_assoc1 ????? a12 a23 a34);
244    | apply ((comp_assoc1 ????? (a34* ) (a23* ) (a12* )) \sup -1);]
245 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_left1;
246 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_right1;]
247 qed.