End MEM_BETWEEN.
Section ELEMENTS_BETWEEN.
(** [elements_between above below s] returns the set of elements of [s] that belong to the interval [above,below]. *)
Variable above_low_bound: elt -> bool.
Variable below_high_bound: elt -> bool.
Fixpoint raw_elements_between (m: Raw.tree) : Raw.tree :=
match m with
| Raw.Leaf => Raw.Leaf
| Raw.Node _ l x r =>
if above_low_bound x then
if below_high_bound x then
Raw.join (raw_elements_between l) x (raw_elements_between r)
else
raw_elements_between l
else
raw_elements_between r
end.
Remark In_raw_elements_between_1:
forall x m,
Raw.In x (raw_elements_between m) -> Raw.In x m.

(* Specifications: *)
Lemma raw_elements_between_ok:
forall m, Raw.bst m -> Raw.bst (raw_elements_between m).
Lemma raw_elements_between_ok:
forall m, Raw.bst m -> Raw.bst (raw_elements_between m).