+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 l) (seg_u_ ? s) (seg_l_ ? s).
+definition seg_l ≝
+ λO:half_ordered_set.λs:segment O.λP: O → CProp.
+ wloss O ? (λl,u.P l) (seg_l_ ? s) (seg_u_ ? 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_l ? s (λl.l ≤≤ x)) (seg_u ? s (λu.x ≤≤ u)).
+
+notation "‡O" non associative with precedence 90 for @{'segment $O}.
+interpretation "Ordered set sergment" 'segment x = (segment x).
+
+interpretation "Ordered set sergment in" 'mem x s = (in_segment _ s x).
+
+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.