(* Definitions 
**************)

(* p is less than every member of t *)

Inductive min (p : nat) (t : nat_tree) : Prop :=
    min_intro : (forall q : nat, occ t q -> p < q) -> min p t.(* Definitions 
**************)

(* p is less than every member of t *)

Inductive min (p : nat) (t : nat_tree) : Prop :=
    min_intro : (forall q : nat, occ t q -> p < q) -> min p t.(* p is greater than every member of t *)

Inductive maj (p : nat) (t : nat_tree) : Prop :=
    maj_intro : (forall q : nat, occ t q -> q < p) -> maj p t.(* p is greater than every member of t *)

Inductive maj (p : nat) (t : nat_tree) : Prop :=
    maj_intro : (forall q : nat, occ t q -> q < p) -> maj p t.Inductive search : nat_tree -> Prop :=
  | nil_search : search NIL
  | bin_search :
      forall (n : nat) (t1 t2 : nat_tree),
      search t1 -> search t2 -> maj n t1 -> min n t2 -> search (bin n t1 t2).Inductive search : nat_tree -> Prop :=
  | nil_search : search NIL
  | bin_search :
      forall (n : nat) (t1 t2 : nat_tree),
      search t1 -> search t2 -> maj n t1 -> min n t2 -> search (bin n t1 t2).Inductive search : nat_tree -> Prop :=
  | nil_search : search NIL
  | bin_search :
      forall (n : nat) (t1 t2 : nat_tree),
      search t1 -> search t2 -> maj n t1 -> min n t2 -> search (bin n t1 t2).

(* Specifications: *)
Lemma min_nil : forall p : nat, min p NIL.
Lemma maj_nil : forall p : nat, maj p NIL.
Lemma maj_not_occ : forall (p : nat) (t : nat_tree), maj p t -> ~ occ t p.
Lemma min_not_occ : forall (p : nat) (t : nat_tree), min p t -> ~ occ t p.
Lemma search_l : search t1.
Lemma search_r : search t2.
Lemma maj_l : maj n t1.
Lemma min_r : min n t2.
Lemma not_right : forall p : nat, p <= n -> ~ occ t2 p.
Lemma not_left : forall p : nat, n <= p -> ~ occ t1 p.
Lemma go_left : forall p : nat, occ (bin n t1 t2) p -> p < n -> occ t1 p.
Lemma go_right : forall p : nat, occ (bin n t1 t2) p -> n < p -> occ t2 p.
Lemma search_inv : forall P : Prop, (search t1 -> search t2 -> maj n t1 -> min n t2 -> P) -> P.