]> matita.cs.unibo.it Git - helm.git/commitdiff
duality is a joke
authorEnrico Tassi <enrico.tassi@inria.fr>
Sat, 25 Oct 2008 14:00:27 +0000 (14:00 +0000)
committerEnrico Tassi <enrico.tassi@inria.fr>
Sat, 25 Oct 2008 14:00:27 +0000 (14:00 +0000)
helm/software/matita/contribs/dama/dama/bishop_set.ma
helm/software/matita/contribs/dama/dama/nat_ordered_set.ma
helm/software/matita/contribs/dama/dama/ordered_set.ma
helm/software/matita/contribs/dama/dama/supremum.ma

index 3522a3bb206d93615a489b7317244b846aea45bd..d69bb2732b3f1a4a023aa21bdd54fc4635c3b7b7 100644 (file)
@@ -67,30 +67,6 @@ lemma le_le_eq: ∀E:ordered_set.∀a,b:E. a ≤ b → b ≤ a → a ≈ b.
 intros (E x y L1 L2); intro H; cases H; [apply L1|apply L2] assumption;
 qed.
 
-(*
-definition lt ≝ λE:half_ordered_set.λa,b:E. a ≤ b ∧ a # b.
-
-interpretation "ordered sets less than" 'lt a b = (lt _ a b).
-
-lemma lt_coreflexive: ∀E.coreflexive ? (lt E).
-intros 2 (E x); intro H; cases H (_ ABS);
-apply (bs_coreflexive ? x ABS);
-qed.
-
-lemma lt_transitive: ∀E.transitive ? (lt E).
-intros (E); unfold; intros (x y z H1 H2); cases H1 (Lxy Axy); cases H2 (Lyz Ayz);
-split; [apply (le_transitive E ??? Lxy Lyz)] clear H1 H2;
-cases Axy (H1 H1); cases Ayz (H2 H2); [1:cases (Lxy H1)|3:cases (Lyz H2)]clear Axy Ayz;
-[1: cases (hos_cotransitive E ?? y H1) (X X); [cases (Lxy X)|cases (hos_coreflexive E ? X)]
-|2: cases (hos_cotransitive E ?? x H2) (X X); [right;assumption|cases (Lxy X)]]
-qed.
-
-theorem lt_to_excess: ∀E:ordered_set.∀a,b:E. (a < b) → (b ≰ a).
-intros (E a b Lab); cases Lab (LEab Aab); cases Aab (H H);[cases (LEab H)]
-assumption;
-qed.
-*)
-
 definition bs_subset ≝ λO:bishop_set.λP,Q:O→Prop.∀x:O.P x → Q x.
 
 interpretation "bishop set subset" 'subseteq a b = (bs_subset _ a b). 
index d4aa1d57d18780367e650b63dc9ad37eb0109a72..dfeaa6d35074c8cddc99f7798a332ba8bdc21b66 100644 (file)
@@ -44,8 +44,9 @@ cases (nat_discriminable x z); [2: left; assumption] cases H1; clear H1;
 qed.
   
 lemma nat_ordered_set : ordered_set.
-letin hos ≝ (mk_half_ordered_set nat nat_excess ? nat_excess_cotransitive);[
-  intro x; intro H; apply (not_le_Sn_n ? H);]
+letin hos ≝ (mk_half_ordered_set nat (λT:Type.λf:T→T→CProp.f) ? nat_excess ? nat_excess_cotransitive);
+[ intros; left; intros; reflexivity;
+| intro x; intro H; apply (not_le_Sn_n ? H);]
 constructor 1;  
 [ apply hos; | apply (dual_hos hos); | reflexivity]
 qed.
@@ -63,17 +64,3 @@ lemma nat_le_to_os_le:
 intros 3; apply (le_to_not_lt a b);assumption;
 qed.
 
-(*
-lemma nat_lt_to_os_lt:
-  ∀a,b:nat_ordered_set.a < b → lt nat_ordered_set a b.
-intros 3; split;
-[1: apply nat_le_to_os_le; apply lt_to_le;assumption;
-|2: right; apply H;]
-qed.
-
-lemma os_lt_to_nat_lt:
-  ∀a,b:nat_ordered_set. lt nat_ordered_set a b → a < b.
-intros; cases H; clear H; cases H2;
-[2: apply H;| cases (H1 H)]
-qed.
-*)
\ No newline at end of file
index 233df16f6b2c320f7980279c5e3b9a0c31353238..a4b40be7a4ba844f3d774583e5890a9561862ec5 100644 (file)
@@ -27,37 +27,48 @@ interpretation "" ' = ( (os_r _)).
 (* Definition 2.1 *)
 record half_ordered_set: Type ≝ {
   hos_carr:> Type;
-  hos_excess: hos_carr → hos_carr → CProp;
-  hos_coreflexive: coreflexive ? hos_excess;
-  hos_cotransitive: cotransitive ? hos_excess 
+  wloss: ∀A:Type. (A → A → CProp) → A → A → CProp;
+  wloss_prop: (∀T,P,x,y.P x y = wloss T P x y) ∨ (∀T,P,x,y.P y x = wloss T P x y); 
+  hos_excess_: hos_carr → hos_carr → CProp;
+  hos_coreflexive: coreflexive ? (wloss ? hos_excess_);
+  hos_cotransitive: cotransitive ? (wloss ? hos_excess_)
 }.
 
+definition hos_excess ≝ λO:half_ordered_set.wloss O ? (hos_excess_ O). 
+
+lemma find_leq : half_ordered_set → half_ordered_set.
+intro O; constructor 1;
+[1: apply (hos_carr O);
+|2: apply (λT:Type.λf:T→T→CProp.f); 
+|3: intros; left; intros; reflexivity;
+|4: apply (hos_excess_ O);
+|5: intro x; lapply (hos_coreflexive O x) as H; cases (wloss_prop O);
+    rewrite < H1 in H; apply H;
+|6: intros 4 (x y z H); cases (wloss_prop O);
+    rewrite > (H1 ? (hos_excess_ O)) in H ⊢ %; 
+    rewrite > (H1 ? (hos_excess_ O)); lapply (hos_cotransitive O ?? z H);
+    [assumption] cases Hletin;[right|left]assumption;]
+qed.
+
 definition dual_hos : half_ordered_set → half_ordered_set.
 intro; constructor 1;
 [ apply (hos_carr h);
-| apply (λx,y.hos_excess h y x);
+| apply (λT,f,x,y.wloss h T f y x); 
+| intros; cases (wloss_prop h);[right|left]intros;apply H; 
+| apply (hos_excess_ h);
 | apply (hos_coreflexive h);
-| intros 4 (x y z H); simplify in H ⊢ %; cases (hos_cotransitive h ?? z H);
+| intros 4 (x y z H); simplify in H ⊢ %; cases (hos_cotransitive h y x z H);
   [right|left] assumption;]
 qed.
 
 record ordered_set : Type ≝ {
-  os_l_ : half_ordered_set;
+  os_l : half_ordered_set;
   os_r_ : half_ordered_set;
-  os_with : os_r_ = dual_hos os_l_
+  os_with : os_r_ = dual_hos os_l
 }.
 
-definition os_l : ordered_set → half_ordered_set.
-intro h; constructor 1; 
-[ apply (hos_carr (os_l_ h));
-| apply (λx,y.hos_excess (os_l_ h) x y);
-| apply (hos_coreflexive (os_l_ h));
-| apply (hos_cotransitive (os_l_ h));
-]
-qed.
-
 definition os_r : ordered_set → half_ordered_set.
-intro o; apply (dual_hos (os_l_ o)); qed.
+intro o; apply (dual_hos (os_l o)); qed.
 
 lemma half2full : half_ordered_set → ordered_set.
 intro hos;
@@ -84,26 +95,26 @@ interpretation "Ordered set excess" 'nleq a b = (hos_excess (os_l _) a b).
 notation "'exc_coreflexive'" non associative with precedence 90 for @{'exc_coreflexive}.
 notation "'cxe_coreflexive'" non associative with precedence 90 for @{'cxe_coreflexive}.
 
-interpretation "exc_coreflexive" 'exc_coreflexive = (hos_coreflexive (os_l _)).
-interpretation "cxe_coreflexive" 'cxe_coreflexive = (hos_coreflexive (os_r _)).
+interpretation "exc_coreflexive" 'exc_coreflexive = ((hos_coreflexive (os_l _))).
+interpretation "cxe_coreflexive" 'cxe_coreflexive = ((hos_coreflexive (os_r _))).
 
 notation "'exc_cotransitive'" non associative with precedence 90 for @{'exc_cotransitive}.
 notation "'cxe_cotransitive'" non associative with precedence 90 for @{'cxe_cotransitive}.
 
-interpretation "exc_cotransitive" 'exc_cotransitive = (hos_cotransitive (os_l _)).
-interpretation "cxe_cotransitive" 'cxe_cotransitive = (hos_cotransitive (os_r _)).
+interpretation "exc_cotransitive" 'exc_cotransitive = ((hos_cotransitive (os_l _))).
+interpretation "cxe_cotransitive" 'cxe_cotransitive = ((hos_cotransitive (os_r _))).
 
 (* Definition 2.2 (3) *)
 definition le ≝ λE:half_ordered_set.λa,b:E. ¬ (a ≰≰ b).
 
 notation "hvbox(a break ≤≤ b)" non associative with precedence 45 for @{ 'leq_low $a $b }.
-interpretation "Ordered half set less or equal than" 'leq_low a b = (le _ a b).
+interpretation "Half ordered set greater or equal than" 'leq_low a b = ((le _ a b)).
 
-interpretation "Ordered set greater or equal than" 'geq a b = (le (os_r _) a b).
-interpretation "Ordered set less or equal than" 'leq a b = (le (os_l _) a b).
+interpretation "Ordered set greater or equal than" 'geq a b = ((le (os_r _) a b)).
+interpretation "Ordered set less or equal than" 'leq a b = ((le (os_l _) a b)).
 
 lemma hle_reflexive: ∀E.reflexive ? (le E).
-unfold reflexive; intros 3 (E x H); apply (hos_coreflexive ?? H);
+unfold reflexive; intros 3; apply (hos_coreflexive ? x H);
 qed.
 
 notation "'le_reflexive'" non associative with precedence 90 for @{'le_reflexive}.
@@ -124,7 +135,7 @@ intros; apply le_reflexive. qed.
 *)
 
 lemma hle_transitive: ∀E.transitive ? (le E).
-unfold transitive; intros 7 (E x y z H1 H2 H3); cases (hos_cotransitive ??? y H3) (H4 H4);
+unfold transitive; intros 7 (E x y z H1 H2 H3); cases (hos_cotransitive E x z y H3) (H4 H4);
 [cases (H1 H4)|cases (H2 H4)]
 qed.
 
@@ -136,10 +147,10 @@ interpretation "ge transitive" 'ge_transitive = (hle_transitive (os_r _)).
 
 (* Lemma 2.3 *)
 lemma exc_hle_variance: 
-  ∀O:half_ordered_set.∀a,b,a',b':O.a ≰≰ b → a ≤≤ a' → b' ≤≤ b → a' ≰≰ b'.
+  ∀O:half_ordered_set.∀a,b,a',b':O.a ≰≰ b → a ≤≤ a' → b' ≤≤ b → a' ≰≰ b'. 
 intros (O a b a1 b1 Eab Laa1 Lb1b);
-cases (hos_cotransitive ??? a1 Eab) (H H); [cases (Laa1 H)]
-cases (hos_cotransitive ??? b1 H) (H1 H1); [assumption]
+cases (hos_cotransitive ? a b a1 Eab) (H H); [cases (Laa1 H)]
+cases (hos_cotransitive ? ?? b1 H) (H1 H1); [assumption]
 cases (Lb1b H1);
 qed.
 
@@ -149,16 +160,26 @@ notation "'exc_ge_variance'" non associative with precedence 90 for @{'exc_ge_va
 interpretation "exc_le_variance" 'exc_le_variance = (exc_hle_variance (os_l _)).
 interpretation "exc_ge_variance" 'exc_ge_variance = (exc_hle_variance (os_r _)).
 
+definition square_exc ≝
+ λO:half_ordered_set.λx,y:O×O.\fst x ≰≰ \fst y ∨ \snd x ≰≰ \snd y.
+
 lemma square_half_ordered_set: half_ordered_set → half_ordered_set.
 intro O;
 apply (mk_half_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 (hos_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 (hos_cotransitive ??? z1 H1); [left; left|right;left]assumption;
-    |2: cases (hos_cotransitive ??? z2 H1); [left;right|right;right]assumption]]
+[1: apply (wloss O);
+|2: intros; cases (wloss_prop O); [left|right] intros; apply H;
+|3: apply (square_exc O); 
+|4: intro x; cases (wloss_prop O); rewrite < (H  ? (square_exc O) x x); clear H;
+    cases x; clear x; unfold square_exc; intro H; cases H; clear H; simplify in H1;
+    [1,3: apply (hos_coreflexive O h H1);
+    |*: apply (hos_coreflexive O h1 H1);]
+|5: intros 3 (x0 y0 z0); cases (wloss_prop O);
+    do 3 rewrite < (H  ? (square_exc O)); clear H; cases x0; cases y0; cases z0; clear x0 y0 z0;
+    simplify; intro H; cases H; clear H;
+    [1: cases (hos_cotransitive ? h h2 h4 H1); [left;left|right;left] assumption;
+    |2: cases (hos_cotransitive ? h1 h3 h5 H1); [left;right|right;right] assumption;
+    |3: cases (hos_cotransitive ? h2 h h4 H1); [right;left|left;left] assumption;
+    |4: cases (hos_cotransitive ? h3 h1 h5 H1); [right;right|left;right] assumption;]]
 qed.
 
 lemma square_ordered_set: ordered_set → ordered_set.
index 4ba3ca3afa678e4e9878ebd20e166e582606b068..7a52e5f064260f1a9f04463a4414e8b0c7b6962a 100644 (file)
@@ -63,16 +63,6 @@ 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).
   
-(* se non faccio il bs_of_hos perdo dualità qui *)  
-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.
-
 (* Fact 2.5 *)
 lemma h_supremum_is_upper_bound: 
   ∀C:half_ordered_set.∀a:sequence C.∀u:C.
@@ -87,14 +77,6 @@ notation "'infimum_is_lower_bound'" non associative with precedence 90 for @{'in
 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 _)).
 
-(* TEST DUALITY
-lemma test_infimum_is_lower_bound_duality: 
-  ∀C:ordered_set.∀a:sequence C.∀u:C.
-   u is_infimum a → ∀v.v is_lower_bound a → u ≥ v. 
-intros; lapply (infimum_is_lower_bound a u H v H1); assumption;
-qed.
-*)
-
 (* Lemma 2.6 *)
 definition strictly_increasing ≝ 
   λC:half_ordered_set.λa:sequence C.∀n:nat.a (S n) ≰≰ a n.
@@ -116,16 +98,8 @@ interpretation "Ordered set strict decreasing"  'strictly_decreasing s    =
 definition uparrow ≝
   λC:half_ordered_set.λs:sequence C.λu:C.
    increasing ? s ∧ supremum ? s u.
-(*   
-notation < "a \uparrow \nbsp u" non associative with precedence 45 for @{'sup_inc $a $u}.
-notation > "a \uparrow u" non associative with precedence 45 for @{'sup_inc $a $u}.
-*)
-interpretation "Ordered set uparrow" 'funion s u = (uparrow (os_l _) s u).
 
-(*
-notation < "a \downarrow \nbsp u" non associative with precedence 45 for @{'inf_dec $a $u}.
-notation > "a \downarrow u" non associative with precedence 45 for @{'inf_dec $a $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: 
@@ -133,9 +107,9 @@ lemma h_trans_increasing:
    ∀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 (hos_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 (hos_coreflexive ?? H1);
+[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.
@@ -146,23 +120,24 @@ notation "'trans_decreasing'" non associative with precedence 90 for @{'trans_de
 interpretation "trans_increasing" 'trans_increasing = (h_trans_increasing (os_l _)).
 interpretation "trans_decreasing" 'trans_decreasing = (h_trans_increasing (os_r _)).
 
-(* TEST DUALITY
-lemma test_trans_decreasing_duality: 
-  ∀C:ordered_set.∀a:sequence C.a is_decreasing → 
-   ∀n,m:nat_ordered_set. n ≤ m → a m ≤ a n.
-intros; apply (trans_decreasing ? H ?? H1); qed.
-*)
+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.
+   ∀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 (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;    
-|2: cases (hos_cotransitive ??? (a n1) H2); [assumption]
+|2: cases (hos_cotransitive ? (a n) (a (S n1)) (a n1) H2); [assumption]
     cases (Hs n1); assumption;]
 qed.
 
@@ -198,8 +173,8 @@ intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split;
 |2: intro n; simplify; apply Uu;
 |3: intros (y Hy); simplify; cases (Hu ? Hy);
     cases (nat_strictly_increasing_reaches ? Hm w); 
-    exists [apply w1]; cases (hos_cotransitive ??? (a (m w1)) H); [2:assumption]  
-    cases (h_trans_increasing_exc ?? Ia ?? H1); assumption;]
+    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}.
@@ -222,55 +197,87 @@ notation > "a 'order_converges' x" non associative with precedence 45
 interpretation "Order convergence" 'order_converge s u = (order_converge _ s u).   
     
 (* Definition 2.8 *)
-definition segment ≝ λO:half_ordered_set.λa,b:O.λx:O.(x ≤≤ b) ∧ (a ≤≤ x).
+record segment (O : Type) : Type ≝ {
+   seg_l_ : O;
+   seg_u_ : O
+}.
+
+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 "[term 19 a,term 19 b]" non associative with precedence 90 for @{'segment $a $b}.
-interpretation "Ordered set sergment" 'segment a b = (segment (os_l _) 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 [term 19 a, term 19 b])" non associative with precedence 45 
-  for @{'segment_in $a $b $x}.
-interpretation "Ordered set sergment in" 'segment_in a b x= (segment (os_l _) a b x).
+interpretation "Ordered set sergment in" 'mem x s = (in_segment _ s x).
 
 definition segment_ordered_set_carr ≝
-  λO:half_ordered_set.λu,v:O.∃x.segment ? u v x.
+  λO:half_ordered_set.λs:‡O.∃x.x ∈ s.
 definition segment_ordered_set_exc ≝ 
-  λO:half_ordered_set.λu,v:O.
-   λx,y:segment_ordered_set_carr ? u v.\fst x ≰≰ \fst y.
+  λ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,u,v. coreflexive ? (segment_ordered_set_exc O u v).
-intros 4; cases x; simplify; apply hos_coreflexive; qed.
+ ∀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,u,v. cotransitive ? (segment_ordered_set_exc O u v).
-intros 6 (O u v x y z); cases x; cases y ; cases z; simplify; apply hos_cotransitive;
+  ∀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.∀u,v:O.half_ordered_set.
-intros (O u v); apply (mk_half_ordered_set ?? (segment_ordered_set_corefl O u v) (segment_ordered_set_cotrans ???));
+  ∀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.
 
 lemma segment_ordered_set: 
-  ∀O:ordered_set.∀u,v:O.ordered_set.
-intros (O u v); 
-apply half2full; apply (half_segment_ordered_set (os_l O) u v); 
+  ∀O:ordered_set.∀s:‡O.ordered_set.
+intros (O s); 
+apply half2full; apply (half_segment_ordered_set (os_l O) s); 
 qed.
 
-(*
-notation < "hvbox({[a, break b]/})" non associative with precedence 90 
-  for @{'h_segment_set $a $b}.
-notation > "hvbox({[a, break b]/})" non associative with precedence 90 
-  for @{'h_segment_set $a $b}.
-interpretation "Half ordered set segment" 'h_segment_set a b = 
-  (half_segment_ordered_set _ a b).
+notation "{[ term 19 s ]}" non associative with precedence 90 for @{'segset $s}.
+interpretation "Ordered set segment" 'segset s = (segment_ordered_set _ s). 
+
+(* 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;
 *)
 
-notation < "hvbox({[a, break b]})" non associative with precedence 90 
-  for @{'segment_set $a $b}.
-notation > "hvbox({[a, break b]})" non associative with precedence 90 
-  for @{'segment_set $a $b}.
-interpretation "Ordered set segment" 'segment_set a b = 
-  (segment_ordered_set _ a b).
-  
 definition hint_sequence: 
   ∀C:ordered_set.
     sequence (hos_carr (os_l C)) → sequence (Type_of_ordered_set C).
@@ -301,27 +308,56 @@ coercion hint_sequence2 nocomposites.
 coercion hint_sequence3 nocomposites.
 
 (* Lemma 2.9 - non easily dualizable *)
-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 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.
+
+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 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.
 
-lemma segment_preserves_infimum:
-  ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}. 
+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}.
+
+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; split; cases H; clear H; 
-[1: apply H1;
-|2: cases H2; split; clear H2;
-    [1: apply H;
-    |2: clear H; intro y0; apply (H3 (\fst y0));]]
+intros; apply (segment_preserves_infimum s a x H);
 qed.
+*)
            
 (* Definition 2.10 *)
 alias symbol "pi2" = "pair pi2".