]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/contribs/dama/dama/supremum.ma
duality is a joke
[helm.git] / helm / software / matita / contribs / dama / dama / supremum.ma
index a4df778067905ea37101fd6cde92571158343462..7a52e5f064260f1a9f04463a4414e8b0c7b6962a 100644 (file)
 (*                                                                        *)
 (**************************************************************************)
 
+
+include "datatypes/constructors.ma".
+include "nat/plus.ma".
+include "nat_ordered_set.ma".
 include "sequence.ma".
-include "ordered_set.ma".
 
 (* Definition 2.4 *)
-definition upper_bound ≝ λO:ordered_set.λa:sequence O.λu:O.∀n:nat.a n ≤ u.
-definition lower_bound ≝ λO:ordered_set.λa:sequence O.λu:O.∀n:nat.u ≤ a n.
+definition upper_bound ≝ 
+  λO:half_ordered_set.λa:sequence O.λu:O.∀n:nat.a n ≤≤ u.
 
 definition supremum ≝
-  λO:ordered_set.λs:sequence O.λx.upper_bound ? s x ∧ (∀y:O.x ≰ y → ∃n.s n ≰ y).
-definition infimum ≝
-  λO:ordered_set.λs:sequence O.λx.lower_bound ? s x ∧ (∀y:O.y ≰ x → ∃n.y ≰ s n).
+  λO:half_ordered_set.λs:sequence O.λx.
+    upper_bound ? s x ∧ (∀y:O.x ≰≰ y → ∃n.s n ≰≰ y).
 
-definition increasing ≝ λO:ordered_set.λa:sequence O.∀n:nat.a n ≤ a (S n).
-definition decreasing ≝ λO:ordered_set.λa:sequence O.∀n:nat.a (S n) ≤ a n.
+definition increasing ≝ 
+  λO:half_ordered_set.λa:sequence O.∀n:nat.a n ≤≤ a (S n).
 
-notation < "x \nbsp 'is_upper_bound' \nbsp s" non associative with precedence 50 
+notation < "x \nbsp 'is_upper_bound' \nbsp s" non associative with precedence 45 
   for @{'upper_bound $s $x}.
-notation < "x \nbsp 'is_lower_bound' \nbsp s" non associative with precedence 50 
+notation < "x \nbsp 'is_lower_bound' \nbsp s" non associative with precedence 45 
   for @{'lower_bound $s $x}.
-notation < "s \nbsp 'is_increasing'" non associative with precedence 50 
+notation < "s \nbsp 'is_increasing'" non associative with precedence 45 
   for @{'increasing $s}.
-notation < "s \nbsp 'is_decreasing'" non associative with precedence 50 
+notation < "s \nbsp 'is_decreasing'" non associative with precedence 45 
   for @{'decreasing $s}.
-notation < "x \nbsp 'is_supremum' \nbsp s" non associative with precedence 50 
+notation < "x \nbsp 'is_supremum' \nbsp s" non associative with precedence 45 
   for @{'supremum $s $x}.
-notation < "x \nbsp 'is_infimum' \nbsp s" non associative with precedence 50 
+notation < "x \nbsp 'is_infimum' \nbsp s" non associative with precedence 45 
   for @{'infimum $s $x}.
-
-notation > "x 'is_upper_bound' s" non associative with precedence 50 
+notation > "x 'is_upper_bound' s" non associative with precedence 45 
   for @{'upper_bound $s $x}.
-notation > "x 'is_lower_bound' s" non associative with precedence 50 
+notation > "x 'is_lower_bound' s" non associative with precedence 45 
   for @{'lower_bound $s $x}.
-notation > "s 'is_increasing'"    non associative with precedence 50 
+notation > "s 'is_increasing'"    non associative with precedence 45 
   for @{'increasing $s}.
-notation > "s 'is_decreasing'"    non associative with precedence 50 
+notation > "s 'is_decreasing'"    non associative with precedence 45 
   for @{'decreasing $s}.
-notation > "x 'is_supremum' s"  non associative with precedence 50 
+notation > "x 'is_supremum' s"  non associative with precedence 45 
   for @{'supremum $s $x}.
-notation > "x 'is_infimum' s"  non associative with precedence 50 
+notation > "x 'is_infimum' s"  non associative with precedence 45 
   for @{'infimum $s $x}.
 
-interpretation "Ordered set upper bound" 'upper_bound s x = 
-  (cic:/matita/dama/supremum/upper_bound.con _ s x).
-interpretation "Ordered set lower bound" 'lower_bound s x = 
-  (cic:/matita/dama/supremum/lower_bound.con _ s x).
-interpretation "Ordered set increasing"  'increasing s    = 
-  (cic:/matita/dama/supremum/increasing.con _ s).
-interpretation "Ordered set decreasing"  'decreasing s    = 
-  (cic:/matita/dama/supremum/decreasing.con _ s).
-interpretation "Ordered set strong sup"  'supremum s x  = 
-  (cic:/matita/dama/supremum/supremum.con _ s x).
-interpretation "Ordered set strong inf"  'infimum s x  = 
-  (cic:/matita/dama/supremum/infimum.con _ s x).
-  
-include "bishop_set.ma".
-  
-lemma uniq_supremum: 
-  ∀O:ordered_set.∀s:sequence O.∀t1,t2:O.
-    t1 is_supremum s → t2 is_supremum s → t1 ≈ t2.
-intros (O s t1 t2 Ht1 Ht2); cases Ht1 (U1 H1); cases Ht2 (U2 H2); 
-apply le_le_eq; intro X;
-[1: cases (H1 ? X); apply (U2 w); assumption
-|2: cases (H2 ? X); apply (U1 w); assumption]
-qed.
+interpretation "Ordered set upper bound" 'upper_bound s x = (upper_bound (os_l _) s x).
+interpretation "Ordered set lower bound" 'lower_bound s x = (upper_bound (os_r _) s x).
 
+interpretation "Ordered set increasing"  'increasing s = (increasing (os_l _) s).
+interpretation "Ordered set decreasing"  'decreasing s = (increasing (os_r _) s).
+
+interpretation "Ordered set strong sup"  'supremum s x = (supremum (os_l _) s x).
+interpretation "Ordered set strong inf"  'infimum s x = (supremum (os_r _) s x).
+  
 (* Fact 2.5 *)
-lemma supremum_is_upper_bound: 
-  ∀C:ordered_set.∀a:sequence C.∀u:C.
-   u is_supremum a → ∀v.v is_upper_bound a → u ≤ v.
+lemma h_supremum_is_upper_bound: 
+  ∀C:half_ordered_set.∀a:sequence C.∀u:C.
+   supremum ? a u → ∀v.upper_bound ? a v → u ≤≤ v.
 intros 7 (C s u Hu v Hv H); cases Hu (_ H1); clear Hu;
-cases (H1 ? H) (w Hw); apply Hv; assumption;
+cases (H1 ? H) (w Hw); apply Hv; [apply w] assumption;
 qed.
 
+notation "'supremum_is_upper_bound'" non associative with precedence 90 for @{'supremum_is_upper_bound}.
+notation "'infimum_is_lower_bound'" non associative with precedence 90 for @{'infimum_is_lower_bound}.
+
+interpretation "supremum_is_upper_bound" 'supremum_is_upper_bound = (h_supremum_is_upper_bound (os_l _)).
+interpretation "infimum_is_lower_bound" 'infimum_is_lower_bound = (h_supremum_is_upper_bound (os_r _)).
+
 (* Lemma 2.6 *)
 definition strictly_increasing ≝ 
-  λC:ordered_set.λa:sequence C.∀n:nat.a (S n) ≰ a n.
-definition strictly_decreasing ≝ 
-  λC:ordered_set.λa:sequence C.∀n:nat.a n ≰ a (S n).
+  λC:half_ordered_set.λa:sequence C.∀n:nat.a (S n) ≰≰ a n.
 
-notation < "s \nbsp 'is_strictly_increasing'" non associative with precedence 50 
+notation < "s \nbsp 'is_strictly_increasing'" non associative with precedence 45 
   for @{'strictly_increasing $s}.
-notation > "s 'is_strictly_increasing'" non associative with precedence 50 
+notation > "s 'is_strictly_increasing'" non associative with precedence 45 
   for @{'strictly_increasing $s}.
 interpretation "Ordered set strict increasing"  'strictly_increasing s    = 
-  (cic:/matita/dama/supremum/strictly_increasing.con _ s).
-notation < "s \nbsp 'is_strictly_decreasing'" non associative with precedence 50 
+  (strictly_increasing (os_l _) s).
+  
+notation < "s \nbsp 'is_strictly_decreasing'" non associative with precedence 45 
   for @{'strictly_decreasing $s}.
-notation > "s 'is_strictly_decreasing'" non associative with precedence 50 
+notation > "s 'is_strictly_decreasing'" non associative with precedence 45 
   for @{'strictly_decreasing $s}.
 interpretation "Ordered set strict decreasing"  'strictly_decreasing s    = 
-  (cic:/matita/dama/supremum/strictly_decreasing.con _ s).
-  
-notation "a \uparrow u" non associative with precedence 50 for @{'sup_inc $a $u}.
-interpretation "Ordered set supremum of increasing" 'sup_inc s u =
- (cic:/matita/dama/cprop_connectives/And.ind#xpointer(1/1) 
-  (cic:/matita/dama/supremum/increasing.con _ s)
-  (cic:/matita/dama/supremum/supremum.con _ s u)).
-notation "a \downarrow u" non associative with precedence 50 for @{'inf_dec $a $u}.
-interpretation "Ordered set supremum of increasing" 'inf_dec s u =
- (cic:/matita/dama/cprop_connectives/And.ind#xpointer(1/1) 
-  (cic:/matita/dama/supremum/decreasing.con _ s)
-  (cic:/matita/dama/supremum/infimum.con _ s u)).
+  (strictly_increasing (os_r _) s).
 
-include "nat/plus.ma".
-include "nat_ordered_set.ma".
-  
-alias symbol "nleq" = "Ordered set excess".
-alias symbol "leq" = "Ordered set less or equal than".
-lemma trans_increasing: 
-  ∀C:ordered_set.∀a:sequence C.a is_increasing → ∀n,m:nat_ordered_set. n ≤ m → a n ≤ a m.
+definition uparrow ≝
+  λC:half_ordered_set.λs:sequence C.λu:C.
+   increasing ? s ∧ supremum ? s u.
+
+interpretation "Ordered set uparrow" 'funion s u = (uparrow (os_l _) s u).
+interpretation "Ordered set downarrow" 'fintersects s u = (uparrow (os_r _) s u).
+
+lemma h_trans_increasing: 
+  ∀C:half_ordered_set.∀a:sequence C.increasing ? a → 
+   ∀n,m:nat_ordered_set. n ≤ m → a n ≤≤ a m.
 intros 5 (C a Hs n m); elim m; [
   rewrite > (le_n_O_to_eq n (not_lt_to_le O n H));
-  intro X; cases (os_coreflexive ?? X);]
+  intro X; cases (hos_coreflexive ? (a n) X);]
 cases (le_to_or_lt_eq ?? (not_lt_to_le (S n1) n H1)); clear H1;
-[2: rewrite > H2; intro; cases (os_coreflexive ?? H1);
-|1: apply (le_transitive ???? (H ?) (Hs ?));
+[2: rewrite > H2; intro; cases (hos_coreflexive ? (a (S n1)) H1);
+|1: apply (hle_transitive ???? (H ?) (Hs ?));
     intro; whd in H1; apply (not_le_Sn_n n); apply (transitive_le ??? H2 H1);]
 qed.
 
-lemma trans_increasing_exc: 
-  ∀C:ordered_set.∀a:sequence C.a is_increasing → ∀n,m:nat_ordered_set. m ≰ n → a n ≤ a m.
+notation "'trans_increasing'" non associative with precedence 90 for @{'trans_increasing}.
+notation "'trans_decreasing'" non associative with precedence 90 for @{'trans_decreasing}.
+
+interpretation "trans_increasing" 'trans_increasing = (h_trans_increasing (os_l _)).
+interpretation "trans_decreasing" 'trans_decreasing = (h_trans_increasing (os_r _)).
+
+lemma hint_nat :
+ Type_of_ordered_set nat_ordered_set →
+   hos_carr (os_l (nat_ordered_set)).
+intros; assumption;
+qed.
+
+coercion hint_nat nocomposites.
+
+lemma h_trans_increasing_exc: 
+  ∀C:half_ordered_set.∀a:sequence C.increasing ? a → 
+   ∀n,m:nat_ordered_set. m ≰≰ n → a n ≤≤ a m.
 intros 5 (C a Hs n m); elim m; [cases (not_le_Sn_O n H);]
 intro; apply H; 
-[1: change in n1 with (os_carr nat_ordered_set); (* canonical structures *) 
-    change with (n<n1); (* is sort elimination not allowed preserved by delta? *)
+[1: change in n1 with (hos_carr (os_l nat_ordered_set)); 
+    change with (n<n1);
     cases (le_to_or_lt_eq ?? H1); [apply le_S_S_to_le;assumption]
-    cases (Hs n); rewrite < H3 in H2; assumption (* ogni goal di tipo Prop non è anche di tipo CProp *)    
-|2: cases (os_cotransitive ??? (a n1) H2); [assumption]
+    cases (Hs n); rewrite < H3 in H2; assumption;    
+|2: cases (hos_cotransitive ? (a n) (a (S n1)) (a n1) H2); [assumption]
     cases (Hs n1); assumption;]
 qed.
 
-lemma strictly_increasing_reaches: 
-  ∀C:ordered_set.∀m:sequence nat_ordered_set.
+notation "'trans_increasing_exc'" non associative with precedence 90 for @{'trans_increasing_exc}.
+notation "'trans_decreasing_exc'" non associative with precedence 90 for @{'trans_decreasing_exc}.
+
+interpretation "trans_increasing_exc" 'trans_increasing_exc = (h_trans_increasing_exc (os_l _)).
+interpretation "trans_decreasing_exc" 'trans_decreasing_exc = (h_trans_increasing_exc (os_r _)).
+
+alias symbol "exists" = "CProp exists".
+lemma nat_strictly_increasing_reaches: 
+  ∀m:sequence nat_ordered_set.
    m is_strictly_increasing → ∀w.∃t.m t ≰ w.
 intros; elim w;
 [1: cases (nat_discriminable O (m O)); [2: cases (not_le_Sn_n O (ltn_to_ltO ?? H1))]
@@ -160,147 +164,243 @@ intros; elim w;
         apply (transitive_le ??? H2 Hp);]]
 qed.
      
-lemma selection: 
-  ∀C:ordered_set.∀m:sequence nat_ordered_set.m is_strictly_increasing →
-    ∀a:sequence C.∀u.a ↑ u → (λx.a (m x)) ↑ u.
+lemma h_selection_uparrow: 
+  ∀C:half_ordered_set.∀m:sequence nat_ordered_set.
+   m is_strictly_increasing →
+    ∀a:sequence C.∀u.uparrow ? a u → uparrow ? ⌊x,a (m x)⌋ u.
 intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split; 
-[1: intro n; simplify; apply trans_increasing_exc; [assumption] apply (Hm n);
+[1: intro n; simplify; apply (h_trans_increasing_exc ? a Ia); apply (Hm n);
 |2: intro n; simplify; apply Uu;
 |3: intros (y Hy); simplify; cases (Hu ? Hy);
-    cases (strictly_increasing_reaches C ? Hm w); 
-    exists [apply w1]; cases (os_cotransitive ??? (a (m w1)) H); [2:assumption]  
-    cases (trans_increasing_exc C ? Ia ?? H1); assumption;]
+    cases (nat_strictly_increasing_reaches ? Hm w); 
+    exists [apply w1]; cases (hos_cotransitive ? (a w) y (a (m w1)) H); [2:assumption]  
+    cases (h_trans_increasing_exc ?? Ia w (m w1) H1); assumption;]
 qed.     
-    
+
+notation "'selection_uparrow'" non associative with precedence 90 for @{'selection_uparrow}.
+notation "'selection_downarrow'" non associative with precedence 90 for @{'selection_downarrow}.
+
+interpretation "selection_uparrow" 'selection_uparrow = (h_selection_uparrow (os_l _)).
+interpretation "selection_downarrow" 'selection_downarrow = (h_selection_uparrow (os_r _)).
+
 (* Definition 2.7 *)
-alias symbol "exists" = "CProp exists".
-alias symbol "and" = "constructive and".
 definition order_converge ≝
   λO:ordered_set.λa:sequence O.λx:O.
-   ∃l:sequence O.∃u:sequence O.
-    l is_increasing ∧ u is_decreasing ∧ l ↑ x ∧ u ↓ x ∧
-    ∀i:nat. (l i) is_infimum (λw.a (w+i)) ∧ (u i) is_supremum (λw.a (w+i)).
+   exT23 (sequence O) (λl.l ↑ x) (λu.u ↓ x)
+     (λl,u:sequence O.∀i:nat. (l i) is_infimum ⌊w,a (w+i)⌋ ∧ 
+                   (u i) is_supremum ⌊w,a (w+i)⌋).
     
-notation < "a \nbsp (\circ \atop (\horbar\triangleright)) \nbsp x" non associative with precedence 50 
+notation < "a \nbsp (\cir \atop (\horbar\triangleright)) \nbsp x" non associative with precedence 45 
   for @{'order_converge $a $x}.
-notation > "a 'order_converges' x" non associative with precedence 50 
+notation > "a 'order_converges' x" non associative with precedence 45 
   for @{'order_converge $a $x}.
-interpretation "Order convergence" 'order_converge s u =
- (cic:/matita/dama/supremum/order_converge.con _ s u).   
+interpretation "Order convergence" 'order_converge s u = (order_converge _ s u).   
     
 (* Definition 2.8 *)
+record segment (O : Type) : Type ≝ {
+   seg_l_ : O;
+   seg_u_ : O
+}.
 
-definition segment ≝ λO:ordered_set.λa,b:O.λx:O.
-  (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (x ≤ b) (a ≤ x)).
+notation > "𝕦_term 90 s p" non associative with precedence 45 for @{'upp $s $p}.
+notation "𝕦 \sub term 90 s p" non associative with precedence 45 for @{'upp $s $p}. 
+notation > "𝕝_term 90 s p" non associative with precedence 45 for @{'low $s $p}.
+notation "𝕝 \sub term 90 s p" non associative with precedence 45 for @{'low $s $p}. 
+definition seg_u ≝
+ λO:half_ordered_set.λs:segment O.λP: O → CProp.
+   wloss O ? (λl,u.P u) (seg_l_ ? s) (seg_u_ ? s).
+definition seg_l ≝
+ λO:half_ordered_set.λs:segment O.λP: O → CProp.
+   wloss O ? (λl,u.P u) (seg_u_ ? s) (seg_l_ ? s). 
+interpretation "uppper" 'upp s P = (seg_u (os_l _) s P).
+interpretation "lower" 'low s P = (seg_l (os_l _) s P).
+interpretation "uppper dual" 'upp s P = (seg_l (os_r _) s P).
+interpretation "lower dual" 'low s P = (seg_u (os_r _) s P).
+definition in_segment ≝ 
+  λO:half_ordered_set.λs:segment O.λx:O.
+    wloss O ? (λp1,p2.p1 ∧ p2) (seg_u ? s (λu.u ≤≤ x)) (seg_l ? s (λl.x ≤≤ l)).
 
-notation "[a,b]" non associative with precedence 50 
-  for @{'segment $a $b}.
-interpretation "Ordered set sergment" 'segment a b =
-  (cic:/matita/dama/supremum/segment.con _ a b).
+notation "‡O" non associative with precedence 90 for @{'segment $O}.
+interpretation "Ordered set sergment" 'segment x = (segment x).
 
-notation "hvbox(x \in break [a,b])" non associative with precedence 50 
-  for @{'segment2 $a $b $x}.
-interpretation "Ordered set sergment in" 'segment2 a b x=
-  (cic:/matita/dama/supremum/segment.con _ a b x).
+interpretation "Ordered set sergment in" 'mem x s = (in_segment _ s x).
 
-coinductive sigma (A:Type) (P:A→Prop) : Type ≝ sig_in : ∀x.P x → sigma A P.
+definition segment_ordered_set_carr ≝
+  λO:half_ordered_set.λs:‡O.∃x.x ∈ s.
+definition segment_ordered_set_exc ≝ 
+  λO:half_ordered_set.λs:‡O.
+   λx,y:segment_ordered_set_carr O s.hos_excess_ O (\fst x) (\fst y).
+lemma segment_ordered_set_corefl:
+ ∀O,s. coreflexive ? (wloss O ? (segment_ordered_set_exc O s)).
+intros 3; cases x; cases (wloss_prop O);
+generalize in match (hos_coreflexive O w);
+rewrite < (H1 ? (segment_ordered_set_exc O s));
+rewrite < (H1 ? (hos_excess_ O)); intros; assumption;
+qed.
+lemma segment_ordered_set_cotrans : 
+  ∀O,s. cotransitive ? (wloss O ? (segment_ordered_set_exc O s)).
+intros 5 (O s x y z); cases x; cases y ; cases z; clear x y z;
+generalize in match (hos_cotransitive O w w1 w2);
+cases (wloss_prop O); 
+do 3 rewrite < (H3 ? (segment_ordered_set_exc O s));
+do 3 rewrite < (H3 ? (hos_excess_ O)); intros; apply H4; assumption;
+qed.  
+  
+lemma half_segment_ordered_set: 
+  ∀O:half_ordered_set.∀s:segment O.half_ordered_set.
+intros (O a); constructor 1;
+[ apply (segment_ordered_set_carr O a);
+| apply (wloss O);
+| apply (wloss_prop O);
+| apply (segment_ordered_set_exc O a);
+| apply (segment_ordered_set_corefl O a);
+| apply (segment_ordered_set_cotrans ??);
+]
+qed.
 
-definition pi1 : ∀A.∀P.sigma A P → A ≝ λA,P,s.match s with [sig_in x _ ⇒ x].  
+lemma segment_ordered_set: 
+  ∀O:ordered_set.∀s:‡O.ordered_set.
+intros (O s); 
+apply half2full; apply (half_segment_ordered_set (os_l O) s); 
+qed.
 
-notation < "'fst' \nbsp x" non associative with precedence 50 for @{'pi1 $x}.
-notation < "'snd' \nbsp x" non associative with precedence 50 for @{'pi2 $x}.
-notation > "'fst' x" non associative with precedence 50 for @{'pi1 $x}.
-notation > "'snd' x" non associative with precedence 50 for @{'pi2 $x}.
-interpretation "sigma pi1" 'pi1 x = 
- (cic:/matita/dama/supremum/pi1.con _ _ x).
-interpretation "Type exists" 'exists \eta.x =
-  (cic:/matita/dama/supremum/sigma.ind#xpointer(1/1) _ x).
+notation "{[ term 19 s ]}" non associative with precedence 90 for @{'segset $s}.
+interpretation "Ordered set segment" 'segset s = (segment_ordered_set _ s). 
 
-lemma segment_ordered_set: 
-  ∀O:ordered_set.∀u,v:O.ordered_set.
-intros (O u v); apply (mk_ordered_set (∃x.x ∈ [u,v]));
-[1: intros (x y); apply (fst x ≰ fst y);
-|2: intro x; cases x; simplify; apply os_coreflexive;
-|3: intros 3 (x y z); cases x; cases y ; cases z; simplify; apply os_cotransitive]
+(* test :
+ ∀O:ordered_set.∀s: segment (os_l O).∀x:O.
+   in_segment (os_l O) s x
+   =
+   in_segment (os_r O) s x.
+intros; try reflexivity;
+*)
+
+definition hint_sequence: 
+  ∀C:ordered_set.
+    sequence (hos_carr (os_l C)) → sequence (Type_of_ordered_set C).
+intros;assumption;
+qed.
+
+definition hint_sequence1: 
+  ∀C:ordered_set.
+    sequence (hos_carr (os_r C)) → sequence (Type_of_ordered_set_dual C).
+intros;assumption;
+qed.
+
+definition hint_sequence2: 
+  ∀C:ordered_set.
+    sequence (Type_of_ordered_set C) → sequence (hos_carr (os_l C)).
+intros;assumption;
+qed.
+
+definition hint_sequence3: 
+  ∀C:ordered_set.
+    sequence (Type_of_ordered_set_dual C) → sequence (hos_carr (os_r C)).
+intros;assumption;
+qed.
+
+coercion hint_sequence nocomposites.
+coercion hint_sequence1 nocomposites.
+coercion hint_sequence2 nocomposites.
+coercion hint_sequence3 nocomposites.
+
+(* Lemma 2.9 - non easily dualizable *)
+
+lemma x2sx:
+  ∀O:half_ordered_set.
+   ∀s:segment O.∀x,y:half_segment_ordered_set ? s.
+    \fst x ≰≰ \fst y → x ≰≰ y.
+intros 4; cases x; cases y; clear x y; simplify; unfold hos_excess;
+whd in ⊢ (?→? (% ? ?) ? ? ? ?); simplify in ⊢ (?→%);
+cases (wloss_prop O) (E E); do 2 rewrite < E; intros; assumption;
 qed.
 
-notation "hvbox({[a, break b]})" non associative with precedence 90 
-  for @{'segment_set $a $b}.
-interpretation "Ordered set segment" 'segment_set a b = 
- (cic:/matita/dama/supremum/segment_ordered_set.con _ a b).
+lemma sx2x:
+  ∀O:half_ordered_set.
+   ∀s:segment O.∀x,y:half_segment_ordered_set ? s.
+    x ≰≰ y → \fst x ≰≰ \fst y.
+intros 4; cases x; cases y; clear x y; simplify; unfold hos_excess;
+whd in ⊢ (? (% ? ?) ? ? ? ? → ?); simplify in ⊢ (% → ?);
+cases (wloss_prop O) (E E); do 2 rewrite < E; intros; assumption;
+qed.
 
-(* Lemma 2.9 *)
-lemma segment_preserves_supremum:
-  ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}. 
-    (λn.fst (a n)) is_increasing ∧ 
-    (fst x) is_supremum (λn.fst (a n)) → a ↑ x.
+lemma h_segment_preserves_supremum:
+  ∀O:half_ordered_set.∀s:segment O.
+   ∀a:sequence (half_segment_ordered_set ? s).
+    ∀x:half_segment_ordered_set ? s. 
+      increasing ? ⌊n,\fst (a n)⌋ ∧ 
+      supremum ? ⌊n,\fst (a n)⌋ (\fst x) → uparrow ? a x.
 intros; split; cases H; clear H; 
-[1: apply H1;
+[1: intro n; lapply (H1 n) as K; clear H1 H2;
+    intro; apply K; clear K; apply (sx2x ???? H);
 |2: cases H2; split; clear H2;
-    [1: apply H;
-    |2: clear H; intro y0; apply (H3 (fst y0));]]
+    [1: intro n; lapply (H n) as K; intro W; apply K;
+        apply (sx2x ???? W);
+    |2: clear H1 H; intros (y0 Hy0); cases (H3 (\fst y0));[exists[apply w]]
+        [1: change in H with (\fst (a w) ≰≰ \fst y0); apply (x2sx ???? H);
+        |2: apply (sx2x ???? Hy0);]]]
 qed.
 
-(* Definition 2.10 *)
-coinductive pair (A,B:Type) : Type ≝ prod : ∀a:A.∀b:B.pair A B. 
-definition first : ∀A.∀P.pair A P → A ≝ λA,P,s.match s with [prod x _ ⇒ x].
-definition second : ∀A.∀P.pair A P → P ≝ λA,P,s.match s with [prod _ y ⇒ y].
-  
-interpretation "pair pi1" 'pi1 x = 
- (cic:/matita/dama/supremum/first.con _ _ x).
-interpretation "pair pi2" 'pi2 x = 
- (cic:/matita/dama/supremum/second.con _ _ x).
-
-notation "hvbox(\langle a, break b\rangle)" non associative with precedence 91 for @{ 'pair $a $b}.
-interpretation "pair" 'pair a b = 
- (cic:/matita/dama/supremum/pair.ind#xpointer(1/1/1) _ _ a b).
-notation "a \times b" left associative with precedence 60 for @{'prod $a $b}.
-interpretation "prod" 'prod a b = 
- (cic:/matita/dama/supremum/pair.ind#xpointer(1/1) a b).
-lemma square_ordered_set: ordered_set → ordered_set.
-intro O; apply (mk_ordered_set (O × O));
-[1: intros (x y); apply (fst x ≰ fst y ∨ snd x ≰ snd y);
-|2: intro x0; cases x0 (x y); clear x0; simplify; intro H;
-    cases H (X X); apply (os_coreflexive ?? X);
-|3: intros 3 (x0 y0 z0); cases x0 (x1 x2); cases y0 (y1 y2) ; cases z0 (z1 z2); 
-    clear x0 y0 z0; simplify; intro H; cases H (H1 H1); clear H;
-    [1: cases (os_cotransitive ??? z1 H1); [left; left|right;left]assumption;
-    |2: cases (os_cotransitive ??? z2 H1); [left;right|right;right]assumption]]
-qed.
+notation "'segment_preserves_supremum'" non associative with precedence 90 for @{'segment_preserves_supremum}.
+notation "'segment_preserves_infimum'" non associative with precedence 90 for @{'segment_preserves_infimum}.
 
-notation < "s  2 \atop \nleq" non associative with precedence 90
-  for @{ 'square $s }.
-notation > "s 'square'" non associative with precedence 90
-  for @{ 'square $s }.
-interpretation "ordered set square" 'square s = 
- (cic:/matita/dama/supremum/square_ordered_set.con s).
+interpretation "segment_preserves_supremum" 'segment_preserves_supremum = (h_segment_preserves_supremum (os_l _)).
+interpretation "segment_preserves_infimum" 'segment_preserves_infimum = (h_segment_preserves_supremum (os_r _)).
+
+(* TEST, ma quanto godo! *)
+lemma segment_preserves_infimum2:
+  ∀O:ordered_set.∀s:‡O.∀a:sequence {[s]}.∀x:{[s]}. 
+    ⌊n,\fst (a n)⌋ is_decreasing ∧ 
+    (\fst x) is_infimum ⌊n,\fst (a n)⌋ → a ↓ x.
+intros; apply (segment_preserves_infimum s a x H);
+qed.
+*)
+           
+(* Definition 2.10 *)
+alias symbol "pi2" = "pair pi2".
+alias symbol "pi1" = "pair pi1".
 definition square_segment ≝ 
-  λO:ordered_set.λa,b:O.λx:square_ordered_set O.
-  (cic:/matita/logic/connectives/And.ind#xpointer(1/1)
-   (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (fst x ≤ b) (a ≤ fst x))
-   (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (snd x ≤ b) (a ≤ snd x))).
+  λO:ordered_set.λa,b:O.λx: O squareO.
+    And4 (\fst x ≤ b) (a ≤ \fst x) (\snd x ≤ b) (a ≤ \snd x).
  
 definition convex ≝
-  λO:ordered_set.λU:O square → Prop.
-  ∀p.U p → fst p ≤ snd p → ∀y. square_segment ? (fst p) (snd p) y → U y.
+  λO:ordered_set.λU:O squareO → Prop.
+    ∀p.U p → \fst p ≤ \snd p → ∀y. 
+      square_segment O (\fst p) (\snd p) y → U y.
   
 (* Definition 2.11 *)  
 definition upper_located ≝
-  λO:ordered_set.λa:sequence O.∀x,y:O. y ≰ x → 
-    (∃i:nat.a i ≰ x) ∨ (∃b:O.y≰b ∧ ∀i:nat.a i ≤ b).
-    
+  λO:half_ordered_set.λa:sequence O.∀x,y:O. y ≰≰ x → 
+    (∃i:nat.a i ≰≰ x) ∨ (∃b:O.y ≰≰ b ∧ ∀i:nat.a i ≤≤ b).
+
+notation < "s \nbsp 'is_upper_located'" non associative with precedence 45 
+  for @{'upper_located $s}.
+notation > "s 'is_upper_located'" non associative with precedence 45 
+  for @{'upper_located $s}.
+interpretation "Ordered set upper locatedness" 'upper_located s = 
+  (upper_located (os_l _) s).
+
+notation < "s \nbsp 'is_lower_located'" non associative with precedence 45 
+  for @{'lower_located $s}.
+notation > "s 'is_lower_located'" non associative with precedence 45
+  for @{'lower_located $s}.
+interpretation "Ordered set lower locatedness" 'lower_located s = 
+  (upper_located (os_r _) s).
+      
 (* Lemma 2.12 *)    
-lemma uparrow_located:
-  ∀C:ordered_set.∀a:sequence C.∀u:C.a ↑ u → upper_located ? a.
+lemma h_uparrow_upperlocated:
+  ∀C:half_ordered_set.∀a:sequence C.∀u:C.uparrow ? a u → upper_located ? a.
 intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
-cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
+cases H3 (H4 H5); clear H3; cases (hos_cotransitive ??? u Hxy) (W W);
 [2: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
 |1: right; exists [apply u]; split; [apply W|apply H4]]
-qed. 
+qed.
 
-     
-    
\ No newline at end of file
+notation "'uparrow_upperlocated'" non associative with precedence 90 for @{'uparrow_upperlocated}.
+notation "'downarrow_lowerlocated'" non associative with precedence 90 for @{'downarrow_lowerlocated}.
+
+interpretation "uparrow_upperlocated" 'uparrow_upperlocated = (h_uparrow_upperlocated (os_l _)).
+interpretation "downarrow_lowerlocated" 'downarrow_lowerlocated = (h_uparrow_upperlocated (os_r _)).