(* An enumeration of R reaches any open interval of R, extract the first two real numbers in it. *)
Definition first_in_holed_interval (u : nat -> R) (v : R -> nat) (a b h : R)
: enumeration R u v -> Rlt a b
-> { n : nat | in_holed_interval a b h u n
/\ forall k : nat, in_holed_interval a b h u k -> n <= k }.
Definition first_two_in_interval (u : nat -> R) (v : R -> nat) (a b : R)
(pen : enumeration R u v) (plow : Rlt a b)
: prod R R :=
let (first_index, pr) := first_in_holed_interval u v a b b pen plow in
let (second_index, pr2) := first_in_holed_interval u v a b (u first_index) pen plow in
if Rle_dec (u first_index) (u second_index) then (u first_index, u second_index)
else (u second_index, u first_index).

Lemma first_two_in_interval_works (u : nat -> R) (v : R -> nat) (a b : R)
(pen : enumeration R u v) (plow : Rlt a b) :
let (c,d) := first_two_in_interval u v a b pen plow in
Rlt a c /\ Rlt c b
/\ Rlt a d /\ Rlt d b
/\ Rlt c d
/\ (forall x:R, Rlt a x -> Rlt x b -> x <> c -> x <> d -> v c < v x).