Definition naive_sch : forall (n : Z) (t : Z_btree), {occ n t} + {~ occ n t}.
simple induction t.
right; auto with searchtrees.
intros z t0 H0 t1 H1.
case (Z_eq_dec n z).
simple induction 1; left; auto with searchtrees.
case H0; case H1; intros; auto with searchtrees.
right; intro H; elim (occ_inv H); auto with searchtrees.
tauto.
Defined.
Extraction naive_sch.
(* let rec naive_sch n = function Z_leaf -> right | Z_bnode (z1, z0, z) -> (match Z_eq_dec n z1 with left -> left | right -> (match naive_sch n z0 with left -> left | right -> naive_sch n z)) *)
Inductive min (z : Z) (t : Z_btree) : Prop :=
min_intro : (forall z' : Z, occ z' t -> (z < z')%Z) -> min z t.
Hint Resolve min_intro: searchtrees.
(* p is greater than every member of t *)
Inductive maj (z : Z) (t : Z_btree) : Prop :=
maj_intro : (forall z' : Z, occ z' t -> (z' < z)%Z) -> maj z t.
Hint Resolve maj_intro: searchtrees.
Inductive search : Z_btree -> Prop :=
| leaf_search : search Z_leaf
| bnode_search :
forall (z : Z) (t1 t2 : Z_btree),
search t1 ->
search t2 -> maj z t1 -> min z t2 -> search (Z_bnode z t1 t2).
Hint Resolve leaf_search bnode_search: searchtrees.

Lemma maj_leaf : forall z : Z, maj z Z_leaf.
Hint Resolve maj_leaf: searchtrees.