]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/overlap/o-algebra.ma
Simplified.
[helm.git] / helm / software / matita / nlibrary / 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 "sets/categories2.ma".
16
17 (*
18 interpretation "unary morphism comprehension with no proof" 'comprehension T P = 
19   (mk_unary_morphism T ? P ?).
20 interpretation "unary morphism1 comprehension with no proof" 'comprehension T P = 
21   (mk_unary_morphism1 T ? P ?).
22
23 notation > "hvbox({ ident i ∈ s | term 19 p | by })" with precedence 90
24 for @{ 'comprehension_by $s (λ${ident i}. $p) $by}.
25 notation < "hvbox({ ident i ∈ s | term 19 p })" with precedence 90
26 for @{ 'comprehension_by $s (λ${ident i}:$_. $p) $by}.
27
28 interpretation "unary morphism comprehension with proof" 'comprehension_by s \eta.f p = 
29   (mk_unary_morphism s ? f p).
30 interpretation "unary morphism1 comprehension with proof" 'comprehension_by s \eta.f p = 
31   (mk_unary_morphism1 s ? f p).
32 *)
33
34 (* per il set-indexing vedere capitolo BPTools (foundational tools), Sect. 0.3.4 complete
35    lattices, Definizione 0.9 *)
36 (* USARE L'ESISTENZIALE DEBOLE *)
37 nrecord OAlgebra : Type[2] := {
38   oa_P :> setoid1;
39   oa_leq : binary_morphism1 oa_P oa_P CPROP; (*CSC: dovrebbe essere CProp bug refiner*)
40   oa_overlap: binary_morphism1 oa_P oa_P CPROP;
41   binary_meet: binary_morphism1 oa_P oa_P oa_P;
42 (*CSC:  oa_join: ∀I:setoid.unary_morphism1 (setoid1_of_setoid … I ⇒ oa_P) oa_P;*)
43   oa_one: oa_P;
44   oa_zero: oa_P;
45   oa_leq_refl: ∀a:oa_P. oa_leq a a; 
46   oa_leq_antisym: ∀a,b:oa_P.oa_leq a b → oa_leq b a → a = b;
47   oa_leq_trans: ∀a,b,c:oa_P.oa_leq a b → oa_leq b c → oa_leq a c;
48   oa_overlap_sym: ∀a,b:oa_P.oa_overlap a b → oa_overlap b a;
49 (*CSC:  oa_join_sup: ∀I:setoid.∀p_i:I ⇒ oa_P.∀p:oa_P.oa_leq (oa_join I p_i) p = (∀i:I.oa_leq (p_i i) p);*)
50   oa_zero_bot: ∀p:oa_P.oa_leq oa_zero p;
51   oa_one_top: ∀p:oa_P.oa_leq p oa_one;
52   oa_overlap_preservers_meet: ∀p,q:oa_P.oa_overlap p q → oa_overlap p (binary_meet p q);
53 (*CSC:  oa_join_split:
54       ∀I:SET.∀p.∀q:I ⇒ oa_P.
55        oa_overlap p (oa_join I q) = (∃i:I.oa_overlap p (q i));*)
56   (*oa_base : setoid;
57   1) enum non e' il nome giusto perche' non e' suriettiva
58   2) manca (vedere altro capitolo) la "suriettivita'" come immagine di insiemi di oa_base
59   oa_enum : ums oa_base oa_P;
60   oa_density: ∀p,q.(∀i.oa_overlap p (oa_enum i) → oa_overlap q (oa_enum i)) → oa_leq p q
61   *)
62   oa_density: 
63       ∀p,q.(∀r.oa_overlap p r → oa_overlap q r) → oa_leq p q
64 }.
65
66 interpretation "o-algebra leq" 'leq a b = (fun21 ??? (oa_leq ?) a b).
67
68 notation "hovbox(a mpadded width -150% (>)< b)" non associative with precedence 45
69 for @{ 'overlap $a $b}.
70 interpretation "o-algebra overlap" 'overlap a b = (fun21 ??? (oa_overlap ?) a b).
71
72 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (\emsp) \nbsp term 90 p)" 
73 non associative with precedence 50 for @{ 'oa_meet $p }.
74 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∧) \below (ident i ∈  I) break term 90 p)" 
75 non associative with precedence 50 for @{ 'oa_meet_mk (λ${ident i}:$I.$p) }.
76
77 (*notation > "hovbox(∧ f)" non associative with precedence 60
78 for @{ 'oa_meet $f }.
79 interpretation "o-algebra meet" 'oa_meet f = 
80   (fun12 ?? (oa_meet ??) f).
81 interpretation "o-algebra meet with explicit function" 'oa_meet_mk f = 
82   (fun12 ?? (oa_meet ??) (mk_unary_morphism ?? f ?)).
83 *)
84 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)" 
85 non associative with precedence 50 for @{ 'oa_join $p }.
86 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈  I) break term 90 p)" 
87 non associative with precedence 50 for @{ 'oa_join_mk (λ${ident i}:$I.$p) }.
88
89 (*CSC
90 notation > "hovbox(∨ f)" non associative with precedence 60
91 for @{ 'oa_join $f }.
92 interpretation "o-algebra join" 'oa_join f = 
93   (fun12 ?? (oa_join ??) f).
94 interpretation "o-algebra join with explicit function" 'oa_join_mk f = 
95   (fun12 ?? (oa_join ??) (mk_unary_morphism ?? f ?)).
96 *)
97 (*definition binary_meet : ∀O:OAlgebra. binary_morphism1 O O O.
98 intros; split;
99 [ intros (p q); 
100   apply (∧ { x ∈ BOOL | match x with [ true ⇒ p | false ⇒ q ] | IF_THEN_ELSE_p ? p q });
101 | intros; lapply (prop12 ? O (oa_meet O BOOL));
102    [2: apply ({ x ∈ BOOL | match x with [ true ⇒ a | false ⇒ b ] | IF_THEN_ELSE_p ? a b });
103    |3: apply ({ x ∈ BOOL | match x with [ true ⇒ a' | false ⇒ b' ] | IF_THEN_ELSE_p ? a' b' });
104    | apply Hletin;]
105   intro x; simplify; cases x; simplify; assumption;]
106 qed.*)
107
108 interpretation "o-algebra binary meet" 'and a b = 
109   (fun21 ??? (binary_meet ?) a b).
110
111 (*
112 prefer coercion Type1_OF_OAlgebra.
113
114 definition binary_join : ∀O:OAlgebra. binary_morphism1 O O O.
115 intros; split;
116 [ intros (p q); 
117   apply (∨ { x ∈ BOOL | match x with [ true ⇒ p | false ⇒ q ] | IF_THEN_ELSE_p ? p q });
118 | intros; lapply (prop12 ? O (oa_join O BOOL));
119    [2: apply ({ x ∈ BOOL | match x with [ true ⇒ a | false ⇒ b ] | IF_THEN_ELSE_p ? a b });
120    |3: apply ({ x ∈ BOOL | match x with [ true ⇒ a' | false ⇒ b' ] | IF_THEN_ELSE_p ? a' b' });
121    | apply Hletin;]
122   intro x; simplify; cases x; simplify; assumption;]
123 qed.
124
125 interpretation "o-algebra binary join" 'or a b = 
126   (fun21 ??? (binary_join ?) a b).
127 *)
128 (*
129 lemma oa_overlap_preservers_meet: ∀O:OAlgebra.∀p,q:O.p >< q → p >< (p ∧ q).
130 (* next change to avoid universe inconsistency *)
131 change in ⊢ (?→%→%→?) with (Type1_OF_OAlgebra O);
132 intros;  lapply (oa_overlap_preserves_meet_ O p q f);
133 lapply (prop21 O O CPROP (oa_overlap O) p p ? (p ∧ q) # ?);
134 [3: apply (if ?? (Hletin1)); apply Hletin;|skip] apply refl1;
135 qed.
136 *)
137 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (\emsp) \nbsp term 90 p)" 
138 non associative with precedence 49 for @{ 'oa_join $p }.
139 notation < "hovbox(mstyle scriptlevel 1 scriptsizemultiplier 1.7 (∨) \below (ident i ∈  I) break term 90 p)" 
140 non associative with precedence 49 for @{ 'oa_join_mk (λ${ident i}:$I.$p) }.
141 notation < "hovbox(a ∨ b)" left associative with precedence 49
142 for @{ 'oa_join_mk (λ${ident i}:$_.match $i with [ true ⇒ $a | false ⇒ $b ]) }.
143
144 notation > "hovbox(∨ f)" non associative with precedence 59
145 for @{ 'oa_join $f }.
146 notation > "hovbox(a ∨ b)" left associative with precedence 49
147 for @{ 'oa_join (mk_unary_morphism BOOL ? (λx__:bool.match x__ with [ true ⇒ $a | false ⇒ $b ]) (IF_THEN_ELSE_p ? $a $b)) }.
148
149 (*interpretation "o-algebra join" 'oa_join f = 
150   (fun12 ?? (oa_join ??) f).
151 interpretation "o-algebra join with explicit function" 'oa_join_mk f = 
152   (fun12 ?? (oa_join ??) (mk_unary_morphism ?? f ?)).
153 *)
154 nrecord ORelation (P,Q : OAlgebra) : Type[1] ≝ {
155   or_f :> P ⇒ Q;
156   or_f_minus_star : P ⇒ Q;
157   or_f_star : Q ⇒ P;
158   or_f_minus : Q ⇒ P;
159   or_prop1 : ∀p,q. (or_f p ≤ q) = (p ≤ or_f_star q);
160   or_prop2 : ∀p,q. (or_f_minus p ≤ q) = (p ≤ or_f_minus_star q);
161   or_prop3 : ∀p,q. (or_f p >< q) = (p >< or_f_minus q)
162 }.
163  
164 notation "r \sup *" non associative with precedence 90 for @{'OR_f_star $r}.
165 notation > "r *" non associative with precedence 90 for @{'OR_f_star $r}.
166
167 notation "r \sup (⎻* )" non associative with precedence 90 for @{'OR_f_minus_star $r}.
168 notation > "r⎻*" non associative with precedence 90 for @{'OR_f_minus_star $r}.
169
170 notation "r \sup ⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
171 notation > "r⎻" non associative with precedence 90 for @{'OR_f_minus $r}.
172
173 interpretation "o-relation f⎻*" 'OR_f_minus_star r = (or_f_minus_star ? ? r).
174 interpretation "o-relation f⎻" 'OR_f_minus r = (or_f_minus ? ? r).
175 interpretation "o-relation f*" 'OR_f_star r = (or_f_star ? ? r).
176
177
178 ndefinition ORelation_setoid : OAlgebra → OAlgebra → setoid1.
179 #P; #Q; @ (ORelation P Q); @
180  [ napply (λp,q.p = q)
181  | #x; napply refl1
182  | #x; #y; napply sym1
183  | #x; #y; #z; napply trans1 ]
184 nqed.
185
186 unification hint 0 ≔ P, Q ;
187   R ≟ (ORelation_setoid P Q)
188 (* -------------------------- *) ⊢
189     carr1 R ≡ ORelation P Q.
190
191 ndefinition or_f_morphism1: ∀P,Q:OAlgebra.unary_morphism1 (ORelation_setoid P Q)
192  (unary_morphism1_setoid1 P Q).
193  #P; #Q; @
194   [ napply or_f
195   | #a; #a'; #e; nassumption]
196 nqed.
197
198 unification hint 0 ≔ P, Q, r;
199  R ≟ (mk_unary_morphism1 … (or_f …) (prop11 … (or_f_morphism1 …)))
200 (* ------------------------ *) ⊢
201   fun11 … R r ≡ or_f P Q r.
202
203 nlemma ORelation_eq_respects_leq_or_f_minus_:
204  ∀P,Q:OAlgebra.∀r,r':ORelation P Q.
205   r=r' → ∀x. r⎻ x ≤ r'⎻ x.
206  #P; #Q; #a; #a'; #e; #x;
207  napply oa_density; #r; #H;
208  napply oa_overlap_sym;
209  napply (. (or_prop3 … a' …)^-1); (*CSC: why a'? *)
210  napply (. ?‡#)
211   [##2: napply (a r)
212   | ngeneralize in match r in ⊢ %;
213     nchange with (or_f … a' = or_f … a);
214     napply (.= †e^-1);
215     napply #]
216  napply (. (or_prop3 …));
217  napply oa_overlap_sym;
218  nassumption.
219 nqed.
220
221 nlemma ORelation_eq2:
222  ∀P,Q:OAlgebra.∀r,r':ORelation P Q.
223   r=r' → r⎻ = r'⎻.
224  #P; #Q; #a; #a'; #e; #x;
225  napply oa_leq_antisym; napply ORelation_eq_respects_leq_or_f_minus_
226   [ napply e | napply e^-1]
227 nqed.
228
229 ndefinition or_f_minus_morphism1: ∀P,Q:OAlgebra.unary_morphism1 (ORelation_setoid P Q)
230  (unary_morphism1_setoid1 Q P).
231  #P; #Q; @
232   [ napply or_f_minus
233   | napply ORelation_eq2]
234 nqed.
235
236 unification hint 0 ≔ P, Q, r;
237  R ≟ (mk_unary_morphism1 … (or_f_minus …) (prop11 … (or_f_minus_morphism1 …)))
238 (* ------------------------ *) ⊢
239   fun11 … R r ≡ or_f_minus P Q r.
240   
241 naxiom daemon : False.
242
243 nlemma ORelation_eq_respects_leq_or_f_star_:
244  ∀P,Q:OAlgebra.∀r,r':ORelation P Q.
245   r=r' → ∀x. r* x ≤ r'* x.
246  #P; #Q; #a; #a'; #e; #x; (*CSC: una schifezza *)
247  ncases daemon.
248  (*
249  ngeneralize in match (. (or_prop1 P Q a' (a* x) x)^-1) in ⊢ %; #H; napply H;
250  nchange with (or_f P Q a' (a* x) ≤ x);
251  napply (. ?‡#)
252   [##2: napply (a (a* x))
253   | ngeneralize in match (a* x);
254     nchange with (or_f P Q a' = or_f P Q a);
255     napply (.= †e^-1); napply #]
256  napply (. (or_prop1 …));
257  napply oa_leq_refl.*)
258 nqed.
259
260 nlemma ORelation_eq3:
261  ∀P,Q:OAlgebra.∀r,r':ORelation P Q.
262   r=r' → r* = r'*.
263  #P; #Q; #a; #a'; #e; #x;
264  napply oa_leq_antisym; napply ORelation_eq_respects_leq_or_f_star_
265   [ napply e | napply e^-1]
266 nqed.
267
268 ndefinition or_f_star_morphism1: ∀P,Q:OAlgebra.unary_morphism1 (ORelation_setoid P Q)
269  (unary_morphism1_setoid1 Q P).
270  #P; #Q; @
271   [ napply or_f_star
272   | napply ORelation_eq3] 
273 nqed.
274
275 unification hint 0 ≔ P, Q, r;
276  R ≟ (mk_unary_morphism1 … (or_f_star …) (prop11 … (or_f_star_morphism1 …)))
277 (* ------------------------ *) ⊢
278   fun11 … R r ≡ or_f_star P Q r.
279
280 nlemma ORelation_eq_respects_leq_or_f_minus_star_:
281  ∀P,Q:OAlgebra.∀r,r':ORelation P Q.
282   r=r' → ∀x. r⎻* x ≤ r'⎻* x.
283  #P; #Q; #a; #a'; #e; #x; (*CSC: una schifezza *)
284  ncases daemon. (*
285  ngeneralize in match (. (or_prop2 P Q a' (a⎻* x) x)^-1) in ⊢ %; #H; napply H;
286  nchange with (or_f_minus P Q a' (a⎻* x) ≤ x);
287  napply (. ?‡#)
288   [##2: napply (a⎻ (a⎻* x))
289   | ngeneralize in match (a⎻* x);
290     nchange with (a'⎻ = a⎻);
291     napply (.= †e^-1); napply #]
292  napply (. (or_prop2 …));
293  napply oa_leq_refl.*)
294 nqed.
295
296 nlemma ORelation_eq4:
297  ∀P,Q:OAlgebra.∀r,r':ORelation P Q.
298   r=r' → r⎻* = r'⎻*.
299  #P; #Q; #a; #a'; #e; #x;
300  napply oa_leq_antisym; napply ORelation_eq_respects_leq_or_f_minus_star_
301   [ napply e | napply e^-1]
302 nqed.
303
304 ndefinition or_f_minus_star_morphism1:
305  ∀P,Q:OAlgebra.unary_morphism1 (ORelation_setoid P Q) (unary_morphism1_setoid1 P Q).
306  #P; #Q; @
307   [ napply or_f_minus_star
308   | napply ORelation_eq4]
309 nqed.
310
311
312 unification hint 0 ≔ P, Q, r;
313  R ≟ (mk_unary_morphism1 … (or_f_minus_star …) (prop11 … (or_f_minus_star_morphism1 …)))
314 (* ------------------------ *) ⊢
315   fun11 … R r ≡ or_f_minus_star P Q r.
316   
317 ninductive one : Type[0] ≝ unit : one.
318
319 ndefinition force : ∀S:Type[2]. S → ∀T:Type[2]. T → one → Type[2] ≝   
320  λS,s,T,t,lock. match lock with [ unit => S ].
321
322 ndefinition enrich_as : 
323  ∀S:Type[2].∀s:S.∀T:Type[2].∀t:T.∀lock:one.force S s T t lock ≝ 
324  λS,s,T,t,lock. match lock return λlock.match lock with [ unit ⇒ S ] 
325                     with [ unit ⇒ s ].
326
327 ncoercion enrich_as : ∀S:Type[2].∀s:S.∀T:Type[2].∀t:T.∀lock:one. force S s T t lock
328  ≝ enrich_as on t: ? to force ? ? ? ? ?.
329
330 (* does not work here 
331 nlemma foo : ∀A,B,C:setoid1.∀f:B ⇒ C.∀g:A ⇒ B. unary_morphism1 A C.
332 #A; #B; #C; #f; #g; napply(f \circ g).
333 nqed.*)
334
335 (* This precise hint does not leave spurious metavariables *)
336 unification hint 0 ≔ A,B,C : setoid1, f:B ⇒ C, g: A ⇒ B;
337    lock ≟ unit
338 (* --------------------------------------------------------------- *) ⊢
339   (unary_morphism1 A C)
340  ≡
341   (force (unary_morphism1 A C) (comp1_unary_morphisms A B C f g)
342    (carr1 A → carr1 C) (composition1 A B C f g)  lock)
343   .
344
345 (* This uniform hint opens spurious metavariables
346 unification hint 0 ≔ A,B,C : setoid1, f:B ⇒ C, g: A ⇒ B, X;
347    lock ≟ unit
348 (* --------------------------------------------------------------- *) ⊢
349   (unary_morphism1 A C)
350  ≡
351   (force (unary_morphism1 A C) X (carr1 A → carr1 C) (fun11 … X)  lock)
352   .
353 *)
354
355 nlemma foo : ∀A,B,C:setoid1.∀f:B ⇒ C.∀g:A ⇒ B. unary_morphism1 A C.
356 #A; #B; #C; #f; #g; napply(f ∘ g).
357 nqed.
358
359 (*
360
361 ndefinition uffa: ∀A,B. ∀U: unary_morphism1 A B. (A → B) → CProp[0].
362  #A;#B;#_;#_; napply True.
363 nqed.
364 ndefinition mk_uffa: ∀A,B.∀U: unary_morphism1 A B. ∀f: (A → B). uffa A B U f.
365  #A; #B; #U; #f; napply I.
366 nqed.
367
368 ndefinition coerc_to_unary_morphism1:
369  ∀A,B. ∀U: unary_morphism1 A B. uffa A B U (fun11 … U) → unary_morphism1 A B.
370  #A; #B; #U; #_; nassumption.
371 nqed.
372
373 ncheck (λA,B,C,f,g.coerc_to_unary_morphism1 ??? (mk_uffa ??? (composition1 A B C f g))). 
374 *)
375 ndefinition ORelation_composition : ∀P,Q,R. 
376   binary_morphism1 (ORelation_setoid P Q) (ORelation_setoid Q R) (ORelation_setoid P R).
377 #P; #Q; #R; @
378 [ #F; #G; @
379   [ napply (G ∘ F) (* napply (comp1_unary_morphisms … G F) (*CSC: was (G ∘ F);*) *)
380   | napply (G⎻* ∘ F⎻* ) (* napply (comp1_unary_morphisms … G⎻* F⎻* ) (*CSC: was (G⎻* ∘ F⎻* );*)*)
381   | napply (comp1_unary_morphisms … F* G* ) (*CSC: was (F* ∘ G* );*)
382   | napply (comp1_unary_morphisms … F⎻ G⎻) (*CSC: was (F⎻ ∘ G⎻);*)
383   | #p; #q; nnormalize;
384     napply (.= (or_prop1 … G …)); (*CSC: it used to understand without G *)
385     napply (or_prop1 …)
386   | #p; #q; nnormalize;
387     napply (.= (or_prop2 … F …));
388     napply or_prop2
389   | #p; #q; nnormalize;
390     napply (.= (or_prop3 … G …));
391     napply or_prop3
392   ]
393 ##| #a;#a';#b;#b';#e;#e1;#x;nnormalize;napply (.= †(e x));napply e1]
394 nqed.
395
396 (*
397 ndefinition OA : category2.
398 split;
399 [ apply (OAlgebra);
400 | intros; apply (ORelation_setoid o o1);
401 | intro O; split;
402   [1,2,3,4: apply id2;
403   |5,6,7:intros; apply refl1;] 
404 | apply ORelation_composition;
405 | intros (P Q R S F G H); split;
406    [ change with (H⎻* ∘ G⎻* ∘ F⎻* = H⎻* ∘ (G⎻* ∘ F⎻* ));
407      apply (comp_assoc2 ????? (F⎻* ) (G⎻* ) (H⎻* ));
408    | apply ((comp_assoc2 ????? (H⎻) (G⎻) (F⎻))^-1);
409    | apply ((comp_assoc2 ????? F G H)^-1);
410    | apply ((comp_assoc2 ????? H* G* F* ));]
411 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_left2;
412 | intros; split; unfold ORelation_composition; simplify; apply id_neutral_right2;]
413 qed.
414
415 definition OAlgebra_of_objs2_OA: objs2 OA → OAlgebra ≝ λx.x.
416 coercion OAlgebra_of_objs2_OA.
417
418 definition ORelation_setoid_of_arrows2_OA: 
419   ∀P,Q. arrows2 OA P Q → ORelation_setoid P Q ≝ λP,Q,c.c.
420 coercion ORelation_setoid_of_arrows2_OA.
421
422 prefer coercion Type_OF_objs2.
423 *)
424 (* alias symbol "eq" = "setoid1 eq". *)
425
426 (* qui la notazione non va *)
427 (*CSC
428 nlemma leq_to_eq_join: ∀S:OAlgebra.∀p,q:S. p ≤ q → q = (binary_join ? p q).
429  intros;
430  apply oa_leq_antisym;
431   [ apply oa_density; intros;
432     apply oa_overlap_sym;
433     unfold binary_join; simplify;
434     apply (. (oa_join_split : ?));
435     exists; [ apply false ]
436     apply oa_overlap_sym;
437     assumption
438   | unfold binary_join; simplify;
439     apply (. (oa_join_sup : ?)); intro;
440     cases i; whd in ⊢ (? ? ? ? ? % ?);
441      [ assumption | apply oa_leq_refl ]]
442 qed.
443
444 nlemma overlap_monotone_left: ∀S:OAlgebra.∀p,q,r:S. p ≤ q → p >< r → q >< r.
445  #S; #p; #q; #r; #H1; #H2;
446  apply (. (leq_to_eq_join : ?)‡#);
447   [ apply f;
448   | skip
449   | apply oa_overlap_sym;
450     unfold binary_join; simplify;
451     apply (. (oa_join_split : ?));
452     exists [ apply true ]
453     apply oa_overlap_sym;
454     assumption; ]
455 qed.*)
456
457 (* Part of proposition 9.9 *)
458 nlemma f_minus_image_monotone: ∀S,T.∀R:ORelation S T.∀p,q. p ≤ q → R⎻ p ≤ R⎻ q.
459  #S; #T; #R; #p; #q; #H;
460  napply (. (or_prop2 …));
461  napply oa_leq_trans; ##[##2: napply H; ##| ##skip |
462   napply (. (or_prop2 … q …)^ -1);(*CSC: why q?*) napply oa_leq_refl]
463 nqed.
464  
465 (* Part of proposition 9.9 *)
466 nlemma f_minus_star_image_monotone: ∀S,T.∀R:ORelation S T.∀p,q. p ≤ q → R⎻* p ≤ R⎻* q.
467  #S; #T; #R; #p; #q; #H;
468  napply (. (or_prop2 … (R⎻* p) q)^ -1); (*CSC: why ?*)
469  napply oa_leq_trans; ##[##3: napply H; ##| ##skip | napply (. (or_prop2 …)); napply oa_leq_refl]
470 nqed.
471
472 (* Part of proposition 9.9 *)
473 nlemma f_image_monotone: ∀S,T.∀R:ORelation S T.∀p,q. p ≤ q → R p ≤ R q.
474  #S; #T; #R; #p; #q; #H;
475  napply (. (or_prop1 …));
476  napply oa_leq_trans; ##[##2: napply H; ##| ##skip | napply (. (or_prop1 … q …)^ -1); napply oa_leq_refl]
477 nqed.
478
479 (* Part of proposition 9.9 *)
480 nlemma f_star_image_monotone: ∀S,T.∀R:ORelation S T.∀p,q. p ≤ q → R* p ≤ R* q.
481  #S; #T; #R; #p; #q; #H;
482  napply (. (or_prop1 … (R* p) q)^ -1);
483  napply oa_leq_trans; ##[##3: napply H; ##| ##skip | napply (. (or_prop1 …)); napply oa_leq_refl]
484 nqed.
485
486 nlemma lemma_10_2_a: ∀S,T.∀R:ORelation S T.∀p. p ≤ R⎻* (R⎻ p).
487  #S; #T; #R; #p;
488  napply (. (or_prop2 … p …)^-1);
489  napply oa_leq_refl.
490 nqed.
491
492 nlemma lemma_10_2_b: ∀S,T.∀R:ORelation S T.∀p. R⎻ (R⎻* p) ≤ p.
493  #S; #T; #R; #p;
494  napply (. (or_prop2 …));
495  napply oa_leq_refl.
496 nqed.
497
498 nlemma lemma_10_2_c: ∀S,T.∀R:ORelation S T.∀p. p ≤ R* (R p).
499  #S; #T; #R; #p;
500  napply (. (or_prop1 … p …)^-1);
501  napply oa_leq_refl.
502 nqed.
503
504 nlemma lemma_10_2_d: ∀S,T.∀R:ORelation S T.∀p. R (R* p) ≤ p.
505  #S; #T; #R; #p;
506  napply (. (or_prop1 …));
507  napply oa_leq_refl.
508 nqed.
509
510 nlemma lemma_10_3_a: ∀S,T.∀R:ORelation S T.∀p. R⎻ (R⎻* (R⎻ p)) = R⎻ p.
511  #S; #T; #R; #p; napply oa_leq_antisym
512   [ napply lemma_10_2_b
513   | napply f_minus_image_monotone;
514     napply lemma_10_2_a ]
515 nqed.
516
517 nlemma lemma_10_3_b: ∀S,T.∀R:ORelation S T.∀p. R* (R (R* p)) = R* p.
518  #S; #T; #R; #p; napply oa_leq_antisym
519   [ napply f_star_image_monotone;
520     napply (lemma_10_2_d ?? R p)
521   | napply lemma_10_2_c ]
522 nqed.
523
524 nlemma lemma_10_3_c: ∀S,T.∀R:ORelation S T.∀p. R (R* (R p)) = R p.
525  #S; #T; #R; #p; napply oa_leq_antisym
526   [ napply lemma_10_2_d
527   | napply f_image_monotone;
528     napply (lemma_10_2_c ?? R p) ]
529 nqed.
530
531 nlemma lemma_10_3_d: ∀S,T.∀R:ORelation S T.∀p. R⎻* (R⎻ (R⎻* p)) = R⎻* p.
532  #S; #T; #R; #p; napply oa_leq_antisym
533   [ napply f_minus_star_image_monotone;
534     napply (lemma_10_2_b ?? R p)
535   | napply lemma_10_2_a ]
536 nqed.
537
538 nlemma lemma_10_4_a: ∀S,T.∀R:ORelation S T.∀p. R⎻* (R⎻ (R⎻* (R⎻ p))) = R⎻* (R⎻ p).
539  #S; #T; #R; #p; napply (†(lemma_10_3_a …)).
540 nqed.
541
542 nlemma lemma_10_4_b: ∀S,T.∀R:ORelation S T.∀p. R (R* (R (R* p))) = R (R* p).
543  #S; #T; #R; #p; napply (†(lemma_10_3_b …));
544 nqed.
545
546 nlemma oa_overlap_sym': ∀o:OAlgebra.∀U,V:o. (U >< V) = (V >< U).
547  #o; #U; #V; @; #H; napply oa_overlap_sym; nassumption.
548 nqed.