(** sorted *)
Fixpoint sorted {T : Type} (Ord : T -> T -> Prop) (s : seq T) :=
match s with
| [::] | [:: _] => True
| h0 :: (h1 :: t1) as t0 => Ord h0 h1 /\ sorted Ord t0
end.

Lemma sorted_dec (s : seq R) x0 (x : R) :
sorted Rle s -> head x0 s <= x <= last x0 s ->
{i : nat | nth x0 s i <= x < nth x0 s (S i) /\ (S (S i) < size s)%nat}
+ {nth x0 s (size s - 2)%nat <= x <= nth x0 s (size s - 1)%nat}.