(************************************************************)
(* II.2 membership ******************************************* (occ t p) means: "t has an occurrence of p" *)
Inductive occ : nat_tree -> nat -> Prop :=
| occ_root : forall (n : nat) (t1 t2 : nat_tree), occ (bin n t1 t2) n
| occ_l :
forall (n p : nat) (t1 t2 : nat_tree), occ t1 p -> occ (bin n t1 t2) p
| occ_r :
forall (n p : nat) (t1 t2 : nat_tree), occ t2 p -> occ (bin n t1 t2) p.
Hint Resolve occ_root occ_l occ_r: searchtrees.
Definition member (n : nat) (t : nat_tree) := occ t n.
Derive Inversion_clear OCC_INV with
(forall (n p : nat) (t1 t2 : nat_tree), occ (bin n t1 t2) p).
(* Coq < Check OCC_INV. OCC_INV : (P:nat->nat->nat_tree->nat_tree->Prop) (n,p:nat)(t1,t2:nat_tree) (P p p t1 t2) ->((occ t1 p)->(P n p t1 t2)) ->((occ t2 p)->(P n p t1 t2)) ->(occ (bin n t1 t2) p)->(P n p t1 t2) *)

Lemma occ_inv :
forall (n p : nat) (t1 t2 : nat_tree),
occ (bin n t1 t2) p -> n = p \/ occ t1 p \/ occ t2 p.