]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/formal_topology/overlap/o-algebra.ma
Using the new category SET.
[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   let f ≝ λm.match m with [ true ⇒ a | false ⇒ b ] in f x = f y.
37 intros; cases x in H; cases y; simplify; intros; try apply refl; whd in H; cases H;
38 qed. 
39
40 lemma if_then_else : ∀T:SET. ∀a,b:T. arrows1 SET BOOL T.
41 intros; constructor 1; intros; 
42 [ apply (match c with [ true ⇒ t | false ⇒ t1 ]);
43 | apply (IF_THEN_ELSE_p T t t1 a a' H);]
44 qed.
45
46 interpretation "mk " 'comprehension T P = 
47   (mk_unary_morphism T _ P _).
48
49 notation > "hvbox({ ident i ∈ s | term 19 p | by })" with precedence 90
50 for @{ 'comprehension_by $s (\lambda ${ident i}. $p) $by}.
51
52 interpretation "unary morphism comprehension with proof" 'comprehension_by s f p = 
53   (mk_unary_morphism s _ f p).
54
55 definition A : ∀S:SET.∀a,b:S.arrows1 SET BOOL S.
56 apply (λS,a,b.{ x ∈ BOOL | match x with [ true ⇒ a | false ⇒ b] | IF_THEN_ELSE_p S a b}).
57 qed.
58
59 record OAlgebra : Type := {
60   oa_P :> SET;
61   oa_leq : binary_morphism1 oa_P oa_P CPROP; (* CPROP is setoid1 *)
62   oa_overlap: binary_morphism1 oa_P oa_P CPROP;
63   oa_meet: ∀I:SET.unary_morphism (arrows1 SET I oa_P) oa_P;
64   oa_join: ∀I:SET.unary_morphism (arrows1 SET I oa_P) oa_P;
65   oa_one: oa_P;
66   oa_zero: oa_P;
67   oa_leq_refl: ∀a:oa_P. oa_leq a a; 
68   oa_leq_antisym: ∀a,b:oa_P.oa_leq a b → oa_leq b a → a = b;
69   oa_leq_trans: ∀a,b,c:oa_P.oa_leq a b → oa_leq b c → oa_leq a c;
70   oa_overlap_sym: ∀a,b:oa_P.oa_overlap a b → oa_overlap b a;
71   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);
72   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;
73   oa_zero_bot: ∀p:oa_P.oa_leq oa_zero p;
74   oa_one_top: ∀p:oa_P.oa_leq p oa_one;
75   oa_overlap_preservers_meet: 
76       ∀p,q.oa_overlap p q → oa_overlap p 
77        (oa_meet ? { x ∈ BOOL | match x with [ true ⇒ p | false ⇒ q ] | IF_THEN_ELSE_p oa_P p q });
78      (*(oa_meet BOOL (if_then_else oa_P p q));*)
79   oa_join_split: (* ha I → oa_P da castare a funX (ums A oa_P) *)
80       ∀I:SET.∀p.∀q:arrows1 SET I oa_P.oa_overlap p (oa_join I q) ⇔ ∃i:I.oa_overlap p (q i);
81   (*oa_base : setoid;
82   oa_enum : ums oa_base oa_P;
83   oa_density: ∀p,q.(∀i.oa_overlap p (oa_enum i) → oa_overlap q (oa_enum i)) → oa_leq p q*)
84   oa_density: 
85       ∀p,q.(∀r.oa_overlap p r → oa_overlap q r) → oa_leq p q
86 }.
87
88 interpretation "o-algebra leq" 'leq a b = (fun1 ___ (oa_leq _) a b).
89
90 notation "hovbox(a mpadded width -150% (>)< b)" non associative with precedence 45
91 for @{ 'overlap $a $b}.
92 interpretation "o-algebra overlap" 'overlap a b = (fun1 ___ (oa_overlap _) a b).
93
94 notation > "hovbox(∧ f)" non associative with precedence 60
95 for @{ 'oa_meet $f }.
96 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (ident i ∈  I) break term 90 p)" non associative with precedence 50
97 for @{ 'oa_meet (λ${ident i}:$I.$p) }.
98 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (\emsp) \nbsp term 90 p)" non associative with precedence 50
99 for @{ 'oa_meet (λ${ident i}.($p $_)) }.
100 notation < "hovbox(a ∧ b)" left associative with precedence 50
101 for @{ 'oa_meet
102   ($foo $bar $baz 
103     (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) 
104     $res) }.
105
106 interpretation "o-algebra meet" 'oa_meet f = (fun_1 __ (oa_meet __) f).
107 (*interpretation "o-algebra binary meet" 'and x y = (fun_1 __ (oa_meet _ BOOL) (if_then_else _ x y)).*)
108
109 (*
110 notation > "hovbox(a ∨ b)" left associative with precedence 49
111 for @{ 'oa_join (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) }.
112 notation > "hovbox(∨ f)" non associative with precedence 59
113 for @{ 'oa_join $f }.
114 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈  I) break term 90 p)" non associative with precedence 49
115 for @{ 'oa_join (λ${ident i}:$I.$p) }.
116 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)" non associative with precedence 49
117 for @{ 'oa_join (λ${ident i}.($p $_)) }.
118 notation < "hovbox(a ∨ b)" left associative with precedence 49
119 for @{ 'oa_join (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
120
121 interpretation "o-algebra join" 'oa_join \eta.f = (oa_join _ _ f).
122 *)
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 axiom DAEMON: False.
147
148 definition ORelation_setoid : OAlgebra → OAlgebra → setoid1.
149 intros (P Q);
150 constructor 1;
151 [ apply (ORelation P Q);
152 | constructor 1;
153    [ apply (λp,q. eq1 ? p⎻* q⎻* ∧ eq1 ? p⎻ q⎻ ∧ eq1 ? p q ∧ eq1 ? p* q* ); 
154    | whd; simplify; intros; repeat split; intros; apply refl1;
155    | whd; simplify; intros; cases H; cases H1; cases H3; clear H H3 H1;
156      repeat split; intros; apply sym1; assumption;
157    | whd; simplify; intros; cases H; cases H1; cases H2; cases H4; cases H6; cases H8;
158      repeat split; intros; clear H H1 H2 H4 H6 H8; apply trans1;
159       [2: apply H10;
160       |5: apply H11;
161       |8: apply H7;
162       |11: apply H3;
163       |1,4,7,10: skip
164       |*: assumption
165       ]]]
166 qed.
167
168 lemma hint1 : ∀P,Q. ORelation_setoid P Q → arrows1 SET P Q. intros; apply (or_f ?? c);qed.
169 coercion hint1.
170
171 lemma hint3 : ∀P,Q. arrows1 SET P Q → P ⇒ Q. intros; apply c;qed.
172 coercion hint3.
173
174 lemma hint2: OAlgebra → setoid. intros; apply (oa_P o). qed.
175 coercion hint2.
176
177 definition composition : ∀P,Q,R. 
178   binary_morphism1 (ORelation_setoid P Q) (ORelation_setoid Q R) (ORelation_setoid P R).
179 intros;
180 constructor 1;
181 [ intros (F G);
182   constructor 1;
183   [ apply (G ∘ F);
184   | apply (G⎻* ∘ F⎻* );
185   | apply (F* ∘ G* );
186   | apply (F⎻ ∘ G⎻);
187   | intros; change with ((G (F p) ≤ q) = (p ≤ (F* (G* q))));
188     apply (.= or_prop1 ??? (F p) ?);
189     apply (.= or_prop1 ??? p ?);
190     apply refl1
191   | intros; change with ((F⎻ (G⎻ p) ≤ q) = (p ≤ (G⎻* (F⎻* q))));
192     apply (.= or_prop2 ??? (G⎻ p) ?);
193     apply (.= or_prop2 ??? p ?);
194     apply refl1;
195   | intros; change with ((G (F (p)) >< q) = (p >< (F⎻ (G⎻ q))));
196     apply (.= or_prop3 ??? (F p) ?);
197     apply (.= or_prop3 ??? p ?);
198     apply refl1
199   ]
200 | intros; repeat split; simplify; cases DAEMON (*
201    [ apply trans1; [2: apply prop1; [3: apply rule #; | skip | 4:
202      apply rule (†?);
203    
204      lapply (.= ((†H1)‡#)); [8: apply Hletin;
205    [ apply trans1; [2: lapply (prop1); [apply Hletin;
206 *)]
207 qed.
208
209 definition OA : category1.
210 split;
211 [ apply (OAlgebra);
212 | intros; apply (ORelation_setoid o o1);
213 | intro O; split;
214   [1,2,3,4: apply id1;
215   |5,6,7:intros; apply refl1;] 
216 | apply composition;
217 | intros; repeat split; unfold composition; simplify;
218   [1,3: apply (comp_assoc1); | 2,4: apply ((comp_assoc1 ????????) \sup -1);]
219 | intros; repeat split; unfold composition; simplify; apply id_neutral_left1;
220 | intros; repeat split; unfold composition; simplify; apply id_neutral_right1;]
221 qed.