]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/dama/lattice.ma
Improved approximations for A and prim.
[helm.git] / helm / software / matita / dama / lattice.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 "excess.ma".
16
17 record semi_lattice_base : Type ≝ {
18   sl_carr:> apartness;
19   sl_op: sl_carr → sl_carr → sl_carr;
20   sl_op_refl: ∀x.sl_op x x ≈ x;  
21   sl_op_comm: ∀x,y:sl_carr. sl_op x y ≈ sl_op y x;
22   sl_op_assoc: ∀x,y,z:sl_carr. sl_op x (sl_op y z) ≈ sl_op (sl_op x y) z;
23   sl_strong_extop: ∀x.strong_ext ? (sl_op x)  
24 }.
25
26 notation "a \cross b" left associative with precedence 50 for @{ 'op $a $b }.
27 interpretation "semi lattice base operation" 'op a b = (cic:/matita/lattice/sl_op.con _ a b).
28
29 lemma excess_of_semi_lattice_base: semi_lattice_base → excess.
30 intro l;
31 apply mk_excess;
32 [1: apply mk_excess_;
33     [1: apply mk_excess_dual_smart;
34          
35   apply (mk_excess_base (sl_carr l));
36     [1: apply (λa,b:sl_carr l.a # (a ✗ b));
37     |2: unfold; intros 2 (x H); simplify in H;
38         lapply (Ap≪ ? (sl_op_refl ??) H) as H1; clear H;
39         apply (ap_coreflexive ?? H1);
40     |3: unfold; simplify; intros (x y z H1);
41         cases (ap_cotransitive ??? ((x ✗ z) ✗ y) H1) (H2 H2);[2:
42           lapply (Ap≪ ? (sl_op_comm ???) H2) as H21;
43           lapply (Ap≫ ? (sl_op_comm ???) H21) as H22; clear H21 H2;
44           lapply (sl_strong_extop ???? H22); clear H22; 
45           left; apply ap_symmetric; assumption;]
46         cases (ap_cotransitive ??? (x ✗ z) H2) (H3 H3);[left;assumption]
47         right; lapply (Ap≫ ? (sl_op_assoc ????) H3) as H31;
48         apply (sl_strong_extop ???? H31);]
49
50     |2:
51     apply apartness_of_excess_base; 
52     
53   apply (mk_excess_base (sl_carr l));
54     [1: apply (λa,b:sl_carr l.a # (a ✗ b));
55     |2: unfold; intros 2 (x H); simplify in H;
56         lapply (Ap≪ ? (sl_op_refl ??) H) as H1; clear H;
57         apply (ap_coreflexive ?? H1);
58     |3: unfold; simplify; intros (x y z H1);
59         cases (ap_cotransitive ??? ((x ✗ z) ✗ y) H1) (H2 H2);[2:
60           lapply (Ap≪ ? (sl_op_comm ???) H2) as H21;
61           lapply (Ap≫ ? (sl_op_comm ???) H21) as H22; clear H21 H2;
62           lapply (sl_strong_extop ???? H22); clear H22; 
63           left; apply ap_symmetric; assumption;]
64         cases (ap_cotransitive ??? (x ✗ z) H2) (H3 H3);[left;assumption]
65         right; lapply (Ap≫ ? (sl_op_assoc ????) H3) as H31;
66         apply (sl_strong_extop ???? H31);]
67     
68     |3: apply refl_eq;]
69 |2,3: intros (x y H); assumption;]         
70 qed.    
71
72 record semi_lattice : Type ≝ {
73   sl_exc:> excess;
74   sl_meet: sl_exc → sl_exc → sl_exc;
75   sl_meet_refl: ∀x.sl_meet x x ≈ x;  
76   sl_meet_comm: ∀x,y. sl_meet x y ≈ sl_meet y x;
77   sl_meet_assoc: ∀x,y,z. sl_meet x (sl_meet y z) ≈ sl_meet (sl_meet x y) z;
78   sl_strong_extm: ∀x.strong_ext ? (sl_meet x);
79   sl_le_to_eqm: ∀x,y.x ≤ y → x ≈ sl_meet x y;
80   sl_lem: ∀x,y.(sl_meet x y) ≤ y 
81 }.
82  
83 interpretation "semi lattice meet" 'and a b = (cic:/matita/lattice/sl_meet.con _ a b).
84
85 lemma sl_feq_ml: ∀ml:semi_lattice.∀a,b,c:ml. a ≈ b → (c ∧ a) ≈ (c ∧ b).
86 intros (l a b c H); unfold eq in H ⊢ %; unfold Not in H ⊢ %;
87 intro H1; apply H; clear H; apply (sl_strong_extm ???? H1);
88 qed.
89
90 lemma sl_feq_mr: ∀ml:semi_lattice.∀a,b,c:ml. a ≈ b → (a ∧ c) ≈ (b ∧ c).
91 intros (l a b c H); 
92 apply (Eq≈ ? (sl_meet_comm ???)); apply (Eq≈ ?? (sl_meet_comm ???));
93 apply sl_feq_ml; assumption;
94 qed.
95  
96  
97 (*
98 lemma semi_lattice_of_semi_lattice_base: semi_lattice_base → semi_lattice.
99 intro slb; apply (mk_semi_lattice (excess_of_semi_lattice_base slb));
100 [1: apply (sl_op slb);
101 |2: intro x; apply (eq_trans (excess_of_semi_lattice_base slb)); [2: 
102       apply (sl_op_refl slb);|1:skip] (sl_op slb x x)); ? (sl_op_refl slb x));
103
104  unfold excess_of_semi_lattice_base; simplify;
105     intro H; elim H;
106     [ 
107     
108     
109     lapply (ap_rewl (excess_of_semi_lattice_base slb) x ? (sl_op slb x x) 
110       (eq_sym (excess_of_semi_lattice_base slb) ?? (sl_op_refl slb x)) t);
111     change in x with (sl_carr slb);
112     apply (Ap≪ (x ✗ x)); (sl_op_refl slb x)); 
113
114 whd in H; elim H; clear H;
115     [ apply (ap_coreflexive (excess_of_semi_lattice_base slb) (x ✗ x) t);
116
117 prelattice (excess_of_directed l_)); [apply (sl_op l_);]
118 unfold excess_of_directed; try unfold apart_of_excess; simplify;
119 unfold excl; simplify;
120 [intro x; intro H; elim H; clear H; 
121  [apply (sl_op_refl l_ x); 
122   lapply (Ap≫ ? (sl_op_comm ???) t) as H; clear t; 
123   lapply (sl_strong_extop l_ ??? H); apply ap_symmetric; assumption
124  | lapply (Ap≪ ? (sl_op_refl ?x) t) as H; clear t;
125    lapply (sl_strong_extop l_ ??? H); apply (sl_op_refl l_ x);
126    apply ap_symmetric; assumption]
127 |intros 3 (x y H); cases H (H1 H2); clear H;
128  [lapply (Ap≪ ? (sl_op_refl ? (sl_op l_ x y)) H1) as H; clear H1;
129   lapply (sl_strong_extop l_ ??? H) as H1; clear H;
130   lapply (Ap≪ ? (sl_op_comm ???) H1); apply (ap_coreflexive ?? Hletin);
131  |lapply (Ap≪ ? (sl_op_refl ? (sl_op l_ y x)) H2) as H; clear H2;
132   lapply (sl_strong_extop l_ ??? H) as H1; clear H;
133   lapply (Ap≪ ? (sl_op_comm ???) H1);apply (ap_coreflexive ?? Hletin);]
134 |intros 4 (x y z H); cases H (H1 H2); clear H;
135  [lapply (Ap≪ ? (sl_op_refl ? (sl_op l_ x (sl_op l_ y z))) H1) as H; clear H1;
136   lapply (sl_strong_extop l_ ??? H) as H1; clear H;
137   lapply (Ap≪ ? (eq_sym ??? (sl_op_assoc ?x y z)) H1) as H; clear H1;
138   apply (ap_coreflexive ?? H);
139  |lapply (Ap≪ ? (sl_op_refl ? (sl_op l_ (sl_op l_ x y) z)) H2) as H; clear H2;
140   lapply (sl_strong_extop l_ ??? H) as H1; clear H;
141   lapply (Ap≪ ? (sl_op_assoc ?x y z) H1) as H; clear H1;
142   apply (ap_coreflexive ?? H);]
143 |intros (x y z H); elim H (H1 H1); clear H;
144  lapply (Ap≪ ? (sl_op_refl ??) H1) as H; clear H1;
145  lapply (sl_strong_extop l_ ??? H) as H1; clear H;
146  lapply (sl_strong_extop l_ ??? H1) as H; clear H1;
147  cases (ap_cotransitive ??? (sl_op l_ y z) H);[left|right|right|left] try assumption;
148  [apply ap_symmetric;apply (Ap≪ ? (sl_op_comm ???));
149  |apply (Ap≫ ? (sl_op_comm ???));
150  |apply ap_symmetric;] assumption;
151 |intros 4 (x y H H1); apply H; clear H; elim H1 (H H);
152  lapply (Ap≪ ? (sl_op_refl ??) H) as H1; clear H;
153  lapply (sl_strong_extop l_ ??? H1) as H; clear H1;[2: apply ap_symmetric]
154  assumption
155 |intros 3 (x y H); 
156  cut (sl_op l_ x y ≈ sl_op l_ x (sl_op l_ y y)) as H1;[2:
157    intro; lapply (sl_strong_extop ???? a); apply (sl_op_refl l_ y);
158    apply ap_symmetric; assumption;]
159  lapply (Ap≪ ? (eq_sym ??? H1) H); apply (sl_op_assoc l_ x y y);
160  assumption; ]
161 qed.
162 *)
163
164 (* ED(≰,≱) → EB(≰') → ED(≰',≱') *)
165 lemma subst_excess_base: excess_dual → excess_base → excess_dual.
166 intros; apply (mk_excess_dual_smart e1);
167 qed.
168
169 (* E_(ED(≰,≱),AP(#),c ED = c AP) → ED' → c DE' = c E_ → E_(ED',#,p) *)
170 lemma subst_dual_excess: ∀e:excess_.∀e1:excess_dual.exc_carr e = exc_carr e1 → excess_.
171 intros (e e1 p); apply (mk_excess_ e1 e); cases p; reflexivity;
172 qed. 
173
174 (* E(E_,H1,H2) → E_' → H1' → H2' → E(E_',H1',H2') *)
175 alias symbol "nleq" = "Excess excess_".
176 lemma subst_excess_: ∀e:excess. ∀e1:excess_. 
177   (∀y,x:e1. y # x → y ≰ x ∨ x ≰ y) →
178   (∀y,x:e1.y ≰ x ∨ x ≰ y →  y # x) →
179   excess.
180 intros (e e1 H1 H2); apply (mk_excess e1 H1 H2); 
181 qed. 
182
183 (* SL(E,M,H2-5(#),H67(≰)) → E' → c E = c E' → H67'(≰') → SL(E,M,p2-5,H67') *)
184 lemma subst_excess: 
185   ∀l:semi_lattice.
186   ∀e:excess. 
187   ∀p:exc_ap l = exc_ap e.
188   (∀x,y:e.(le (exc_dual_base e)) x y → x ≈ (?(sl_meet l)) x y) →
189   (∀x,y:e.(le (exc_dual_base e)) ((?(sl_meet l)) x y) y) → 
190   semi_lattice.
191 [1,2:intro M;
192  change with ((λx.ap_carr x) e -> (λx.ap_carr x) e -> (λx.ap_carr x) e);
193  cases p; apply M;
194 |intros (l e p H1 H2);
195  apply (mk_semi_lattice e);
196    [ change with ((λx.ap_carr x) e -> (λx.ap_carr x) e -> (λx.ap_carr x) e);
197      cases p; simplify; apply (sl_meet l);
198    |2: change in ⊢ (% → ?) with ((λx.ap_carr x) e); cases p; simplify; apply sl_meet_refl;
199    |3: change in ⊢ (% → % → ?) with ((λx.ap_carr x) e); cases p; simplify; apply sl_meet_comm;
200    |4: change in ⊢ (% → % → % → ?) with ((λx.ap_carr x) e); cases p; simplify; apply sl_meet_assoc;  
201    |5: change in ⊢ (% → ?) with ((λx.ap_carr x) e); cases p; simplify; apply sl_strong_extm;
202    |6: clear H2; apply H1;
203    |7: clear H1; apply H2;]]
204 qed.
205
206 lemma excess_of_excess_base: excess_base → excess.
207 intro eb;
208 apply mk_excess;
209   [apply (mk_excess_ (mk_excess_dual_smart eb));
210     [apply (apartness_of_excess_base eb);
211     |reflexivity]
212   |2,3: intros; assumption]
213 qed. 
214
215 lemma subst_excess_base_in_semi_lattice: 
216   ∀sl:semi_lattice.
217   ∀eb:excess_base.
218   ∀p:exc_carr sl = exc_carr eb.
219   (∀y1,x1:eb. (?(ap_apart sl)) y1  x1 → y1 ≰ x1 ∨ x1 ≰ y1) →
220   (∀y2,x2:eb.y2 ≰ x2 ∨ x2 ≰ y2 →  (?(ap_apart sl)) y2 x2) →
221   (∀x3,y3:eb.(le eb) x3 y3 → (?(ap_apart sl)) x3 ((?(sl_meet sl)) x3 y3)) →
222   (∀x4,y4:eb.(le eb) ((?(sl_meet sl)) x4 y4) y4) → 
223   semi_lattice.
224 [2,3,7,9,10: apply Type|4:apply (exc_carr eb);
225 |1,5,6,8,11: intro f; cases p; apply f;]
226 intros (sl eb H H1 H2 H3 H4); apply (subst_excess sl);
227   [apply (subst_excess_ sl);
228     [apply (subst_dual_excess sl);
229       [apply (subst_excess_base sl eb);
230       |apply H;]
231     | (*clear H2 H3 H4;*) 
232       change in ⊢ (% -> % -> ?) with (exc_carr eb);
233       unfold subst_excess_base; unfold mk_excess_dual_smart;
234       unfold subst_dual_excess; simplify in ⊢ (?→?→?→%);
235       (unfold exc_ap; simplify in ⊢ (?→?→? % ? ?→?));
236       simplify; intros (x y H2); apply H1;
237       generalize in match H2;
238       generalize in match x as x;
239       generalize in match y as y; (*clear H1 H2 x y;*)
240       change in ⊢ (?→?→match ? return λ_:?.(λ_:? ? % ?.?) with [_⇒?] ? ?→?)
241       with (Type_OF_semi_lattice sl); 
242       change in ⊢ (?→?→match match ? return λ_:?.(λ_:? ? % ?.? ? % ?) with [_⇒? ? %] return ? with [_⇒?] ??→?) with (Type_OF_semi_lattice sl);
243       cases H; intros; assumption; (* se faccio le clear... BuM! *)
244     | clear H1 H3 H4;
245     
246     ]
247
248 record lattice_ : Type ≝ {
249   latt_mcarr:> semi_lattice;
250   latt_jcarr_: semi_lattice;
251   (*latt_with1: latt_jcarr_ = subst latt_jcarr (exc_dual_dual latt_mcarr)*) 
252 (*  latt_with1:   (subst_excess_
253                   (subst_dual_excess
254                     (subst_excess_base 
255                       (excess_dual_OF_excess (sl_exc latt_jcarr_))
256                       (excess_base_OF_excess (sl_exc latt_mcarr))))) =
257                 sl_exc latt_jcarr_;   
258   
259 *)  
260   latt_with1: excess_base_OF_excess1 (sl_exc latt_jcarr_) =  excess_base_OF_excess (sl_exc latt_mcarr);
261   latt_with2: excess_base_OF_excess (sl_exc latt_jcarr_) =  excess_base_OF_excess1 (sl_exc latt_mcarr);
262   latt_with3: apartness_OF_excess (sl_exc latt_jcarr_) = apartness_OF_excess (sl_exc latt_mcarr)
263 }.
264
265 axiom FALSE: False.
266
267 lemma latt_jcarr : lattice_ → semi_lattice.
268 intro l;
269 apply mk_semi_lattice;
270   [apply mk_excess;
271     [apply mk_excess_;
272       [apply (mk_excess_dual_smart l);
273       |apply (exc_ap l);
274       |reflexivity]
275     |unfold mk_excess_dual_smart; simplify;
276      intros (x y H); cases (ap2exc ??? H); [right|left]  assumption;
277     |unfold mk_excess_dual_smart; simplify;
278      intros (x y H);cases H; apply exc2ap;[right|left] assumption;]] 
279 unfold mk_excess_dual_smart; simplify;
280 [1: change with ((λx.ap_carr x) l → (λx.ap_carr x) l → (λx.ap_carr x) l);
281     simplify; unfold apartness_OF_lattice_; 
282     cases (latt_with3 l); apply (sl_meet (latt_jcarr_ l)); 
283 |2: change in ⊢ (%→?) with ((λx.ap_carr x) l); simplify;
284     unfold apartness_OF_lattice_;
285     cases (latt_with3 l); apply (sl_meet_refl (latt_jcarr_ l));
286 |3: change in ⊢ (%→%→?) with ((λx.ap_carr x) l); simplify; unfold apartness_OF_lattice_;
287     cases (latt_with3 l); apply (sl_meet_comm (latt_jcarr_ l));
288 |4: change in ⊢ (%→%→%→?) with ((λx.ap_carr x) l); simplify; unfold apartness_OF_lattice_;
289     cases (latt_with3 l); apply (sl_meet_assoc (latt_jcarr_ l));
290 |5: change in ⊢ (%→%→%→?) with ((λx.ap_carr x) l); simplify; unfold apartness_OF_lattice_;
291     cases (latt_with3 l); apply (sl_strong_extm (latt_jcarr_ l));
292 |7: 
293 (*
294 unfold excess_base_OF_lattice_; 
295     change in ⊢ (?→?→? ? (% ? ?) ?)
296     with (match latt_with3 l
297  in eq
298  return 
299 λright_1:apartness
300 .(λmatched:eq apartness (apartness_OF_semi_lattice (latt_jcarr_ l)) right_1
301   .ap_carr right_1→ap_carr right_1→ap_carr right_1)
302  with 
303 [refl_eq⇒sl_meet (latt_jcarr_ l)]
304  : ?
305 );
306   change in ⊢ (?→?→? ? ((?:%->%->%) ? ?) ?)
307   with ((λx.exc_carr x) (excess_base_OF_semi_lattice (latt_mcarr l)));
308   unfold excess_base_OF_lattice_ in ⊢ (?→?→? ? ((?:%->%->%) ? ?) ?);
309   simplify in ⊢ (?→?→? ? ((?:%->%->%) ? ?) ?);
310 change in ⊢ (?→?→? ? (% ? ?) ?) with
311   (match refl_eq ? (excess__OF_semi_lattice (latt_mcarr l)) in eq
312    return (λR.λE:eq ? (excess_base_OF_semi_lattice (latt_mcarr l)) R.R → R → R)
313    with [refl_eq⇒ 
314      (match latt_with3 l in eq
315      return 
316        (λright:apartness
317         .(λmatched:eq apartness (apartness_OF_semi_lattice (latt_jcarr_ l)) right
318           .ap_carr right→ap_carr right→ap_carr right))
319      with [refl_eq⇒ sl_meet (latt_jcarr_ l)]
320      :
321      exc_carr (excess_base_OF_semi_lattice (latt_mcarr l))
322       →exc_carr (excess_base_OF_semi_lattice (latt_mcarr l))
323        →exc_carr (excess_base_OF_semi_lattice (latt_mcarr l))
324      )
325    ]);
326    generalize in ⊢ (?→?→? ? (match % return ? with [_⇒?] ? ?) ?);
327    unfold excess_base_OF_lattice_ in ⊢ (? ? ? %→?);
328    cases (latt_with1 l);
329   change in ⊢ (?→?→?→? ? (match ? return ? with [_⇒(?:%→%->%)] ? ?) ?)
330   with ((λx.ap_carr x) (latt_mcarr l));
331   simplify in ⊢ (?→?→?→? ? (match ? return ? with [_⇒(?:%→%->%)] ? ?) ?);
332   cases (latt_with3 l);
333    
334    change in ⊢ (? ? % ?→?) with ((λx.ap_carr x) l);
335    simplify in ⊢ (% → ?);
336    change in ⊢ (?→?→?→? ? (match ? return λ_:?.(λ_:? ? % ?.?) with [_⇒?] ? ?) ?)
337      with ((λx.ap_carr x) (apartness_OF_lattice_ l));
338    unfold apartness_OF_lattice_;  
339    cases (latt_with3 l); simplify;
340    change in ⊢ (? ? ? %→%→%→?) with ((λx.exc_carr x) l);
341    unfold excess_base_OF_lattice_;
342    cases (latt_with1 l); simplify;
343    change in \vdash (? -> % -> % -> ?) with (exc_carr (excess_base_OF_semi_lattice (latt_jcarr_ l)));
344    change in ⊢ ((? ? % ?)→%→%→? ? (match ? return λ_:?.(λ_:? ? % ?.?) with [_⇒?] ? ?) ?)
345      with ((λx.exc_carr x) (excess_base_OF_semi_lattice1 (latt_jcarr_ l)));
346    simplify;
347    intro H;
348    unfold excess_base_OF_semi_lattice1;
349    unfold excess_base_OF_excess1;
350    unfold excess_base_OF_excess_1;
351    change 
352 *)
353
354 change in ⊢ (?→?→? ? (% ? ?) ?) with
355   (match refl_eq ? (Type_OF_lattice_ l) in eq
356    return (λR.λE:eq ? (Type_OF_lattice_ l) R.R → R → R)
357    with [refl_eq⇒ 
358      match latt_with3 l in eq
359      return 
360        (λright:apartness
361         .(λmatched:eq apartness (apartness_OF_semi_lattice (latt_jcarr_ l)) right
362           .ap_carr right→ap_carr right→ap_carr right))
363      with [refl_eq⇒ sl_meet (latt_jcarr_ l)]
364    ]);
365    generalize in ⊢ (?→?→? ? (match % return ? with [_⇒?] ? ?) ?);
366    change in ⊢ (? ? % ?→?) with ((λx.ap_carr x) l);
367    simplify in ⊢ (% → ?);
368    change in ⊢ (?→?→?→? ? (match ? return λ_:?.(λ_:? ? % ?.?) with [_⇒?] ? ?) ?)
369      with ((λx.ap_carr x) (apartness_OF_lattice_ l));
370    unfold apartness_OF_lattice_;  
371    cases (latt_with3 l); simplify;
372    change in ⊢ (? ? ? %→%→%→?) with ((λx.exc_carr x) l);
373    unfold excess_base_OF_lattice_;
374    cases (latt_with1 l); simplify;
375    change in \vdash (? -> % -> % -> ?) with (exc_carr (excess_base_OF_semi_lattice (latt_jcarr_ l)));
376    change in ⊢ ((? ? % ?)→%→%→? ? (match ? return λ_:?.(λ_:? ? % ?.?) with [_⇒?] ? ?) ?)
377      with ((λx.exc_carr x) (excess_base_OF_semi_lattice1 (latt_jcarr_ l)));
378    simplify;
379    intro H;
380    change in ⊢ (?→?→%) with (le (mk_excess_base 
381           ((λx.exc_carr x) (excess_base_OF_semi_lattice1 (latt_jcarr_ l)))
382           ((λx.exc_excess x) (excess_base_OF_semi_lattice1 (latt_jcarr_ l)))
383           ((λx.exc_coreflexive x) (excess_base_OF_semi_lattice1 (latt_jcarr_ l)))
384           ((λx.exc_cotransitive x) (excess_base_OF_semi_lattice1 (latt_jcarr_ l)))
385         ) (match H
386  in eq
387  return 
388 λR:Type
389 .(λE:eq Type (exc_carr (excess_base_OF_semi_lattice1 (latt_jcarr_ l))) R
390   .R→R→R)
391  with 
392 [refl_eq⇒sl_meet (latt_jcarr_ l)] x y) y); 
393  simplify in ⊢ (?→?→? (? % ???) ? ?); 
394  change in ⊢ (?→?→? ? (match ? return λ_:?.(λ_:? ? % ?.?) with [_⇒?] ? ?) ?)
395  with ((λx.exc_carr x) (excess_base_OF_semi_lattice1 (latt_jcarr_ l)));
396  simplify in  ⊢ (?→?→? ? (match ? return λ_:?.(λ_:? ? % ?.?) with [_⇒?] ? ?) ?);
397  lapply (match H in eq return 
398         λright.λe:eq ? (exc_carr (excess_base_OF_semi_lattice1 (latt_jcarr_ l))) right.
399        
400 ∀x:right
401 .∀y:right
402  .le
403   (mk_excess_base right ???)
404   (match e
405     in eq
406     return 
407    λR:Type.(λE:eq Type (exc_carr (excess_base_OF_semi_lattice1 (latt_jcarr_ l))) R.R→R→R)
408     with 
409    [refl_eq⇒sl_meet (latt_jcarr_ l)] x y) y
410         with [refl_eq ⇒ ?]) as XX;
411   [cases e; apply (exc_excess (latt_jcarr_ l)); 
412   |unfold;cases e;simplify;apply (exc_coreflexive (latt_jcarr_ l)); 
413   |unfold;cases e;simplify;apply (exc_cotransitive (latt_jcarr_ l)); 
414   ||apply XX|
415   |apply XX;
416         
417          simplify; apply (sl_lem);
418 |elim FALSE]
419 qed.
420
421    
422  
423     
424 coercion cic:/matita/lattice/latt_jcarr.con.
425
426 interpretation "Lattice meet" 'and a b =
427  (cic:/matita/lattice/sl_meet.con (cic:/matita/lattice/latt_mcarr.con _) a b).  
428
429 interpretation "Lattice join" 'or a b =
430  (cic:/matita/lattice/sl_meet.con (cic:/matita/lattice/latt_jcarr.con _) a b).  
431
432 record lattice : Type ≝ {
433   latt_carr:> lattice_;
434   absorbjm: ∀f,g:latt_carr. (f ∨ (f ∧ g)) ≈ f;
435   absorbmj: ∀f,g:latt_carr. (f ∧ (f ∨ g)) ≈ f
436 }.
437
438 notation "'meet'"        non associative with precedence 50 for @{'meet}.
439 notation "'meet_refl'"   non associative with precedence 50 for @{'meet_refl}.
440 notation "'meet_comm'"   non associative with precedence 50 for @{'meet_comm}.
441 notation "'meet_assoc'"  non associative with precedence 50 for @{'meet_assoc}.
442 notation "'strong_extm'" non associative with precedence 50 for @{'strong_extm}.
443 notation "'le_to_eqm'"   non associative with precedence 50 for @{'le_to_eqm}.
444 notation "'lem'"         non associative with precedence 50 for @{'lem}.
445 notation "'join'"        non associative with precedence 50 for @{'join}.
446 notation "'join_refl'"   non associative with precedence 50 for @{'join_refl}.
447 notation "'join_comm'"   non associative with precedence 50 for @{'join_comm}.
448 notation "'join_assoc'"  non associative with precedence 50 for @{'join_assoc}.
449 notation "'strong_extj'" non associative with precedence 50 for @{'strong_extj}.
450 notation "'le_to_eqj'"   non associative with precedence 50 for @{'le_to_eqj}.
451 notation "'lej'"         non associative with precedence 50 for @{'lej}.
452
453 interpretation "Lattice meet"        'meet        = (cic:/matita/lattice/sl_meet.con (cic:/matita/lattice/latt_mcarr.con _)).
454 interpretation "Lattice meet_refl"   'meet_refl   = (cic:/matita/lattice/sl_meet_refl.con (cic:/matita/lattice/latt_mcarr.con _)).
455 interpretation "Lattice meet_comm"   'meet_comm   = (cic:/matita/lattice/sl_meet_comm.con (cic:/matita/lattice/latt_mcarr.con _)).
456 interpretation "Lattice meet_assoc"  'meet_assoc  = (cic:/matita/lattice/sl_meet_assoc.con (cic:/matita/lattice/latt_mcarr.con _)).
457 interpretation "Lattice strong_extm" 'strong_extm = (cic:/matita/lattice/sl_strong_extm.con (cic:/matita/lattice/latt_mcarr.con _)).
458 interpretation "Lattice le_to_eqm"   'le_to_eqm   = (cic:/matita/lattice/sl_le_to_eqm.con (cic:/matita/lattice/latt_mcarr.con _)).
459 interpretation "Lattice lem"         'lem         = (cic:/matita/lattice/sl_lem.con (cic:/matita/lattice/latt_mcarr.con _)).
460 interpretation "Lattice join"        'join        = (cic:/matita/lattice/sl_meet.con (cic:/matita/lattice/latt_jcarr.con _)).
461 interpretation "Lattice join_refl"   'join_refl   = (cic:/matita/lattice/sl_meet_refl.con (cic:/matita/lattice/latt_jcarr.con _)).
462 interpretation "Lattice join_comm"   'join_comm   = (cic:/matita/lattice/sl_meet_comm.con (cic:/matita/lattice/latt_jcarr.con _)).
463 interpretation "Lattice join_assoc"  'join_assoc  = (cic:/matita/lattice/sl_meet_assoc.con (cic:/matita/lattice/latt_jcarr.con _)).
464 interpretation "Lattice strong_extm" 'strong_extj = (cic:/matita/lattice/sl_strong_extm.con (cic:/matita/lattice/latt_jcarr.con _)).
465 interpretation "Lattice le_to_eqj"   'le_to_eqj   = (cic:/matita/lattice/sl_le_to_eqm.con (cic:/matita/lattice/latt_jcarr.con _)).
466 interpretation "Lattice lej"         'lej         = (cic:/matita/lattice/sl_lem.con (cic:/matita/lattice/latt_jcarr.con _)).
467
468 notation "'feq_jl'" non associative with precedence 50 for @{'feq_jl}.
469 notation "'feq_jr'" non associative with precedence 50 for @{'feq_jr}.
470 notation "'feq_ml'" non associative with precedence 50 for @{'feq_ml}.
471 notation "'feq_mr'" non associative with precedence 50 for @{'feq_mr}.
472 interpretation "Lattice feq_jl" 'feq_jl = (cic:/matita/lattice/sl_feq_ml.con (cic:/matita/lattice/latt_jcarr.con _)).
473 interpretation "Lattice feq_jr" 'feq_jr = (cic:/matita/lattice/sl_feq_mr.con (cic:/matita/lattice/latt_jcarr.con _)).
474 interpretation "Lattice feq_ml" 'feq_ml = (cic:/matita/lattice/sl_feq_ml.con (cic:/matita/lattice/latt_mcarr.con _)).
475 interpretation "Lattice feq_mr" 'feq_mr = (cic:/matita/lattice/sl_feq_mr.con (cic:/matita/lattice/latt_mcarr.con _)).
476
477
478 interpretation "Lattive meet le" 'leq a b =
479  (cic:/matita/excess/le.con (cic:/matita/lattice/excess_OF_lattice1.con _) a b).
480
481 interpretation "Lattive join le (aka ge)" 'geq a b =
482  (cic:/matita/excess/le.con (cic:/matita/lattice/excess_OF_lattice.con _) a b).
483
484 (* these coercions help unification, handmaking a bit of conversion 
485    over an open term 
486 *)
487 lemma le_to_ge: ∀l:lattice.∀a,b:l.a ≤ b → b ≥ a.
488 intros(l a b H); apply H;
489 qed.
490
491 lemma ge_to_le: ∀l:lattice.∀a,b:l.b ≥ a → a ≤ b.
492 intros(l a b H); apply H;
493 qed.
494
495 coercion cic:/matita/lattice/le_to_ge.con nocomposites.
496 coercion cic:/matita/lattice/ge_to_le.con nocomposites.