(* V:        INSERTION 
**********************************
**********************************


V.1   Definition of an INSERT predicate (a la  Prolog)
***************************************************


We begin with the definition of a predicate:

(INSERT n t t') if t' is a binary search tree containing exactly
  n and the elements of t *)


Inductive INSERT (n : nat) (t t' : nat_tree) : Prop :=
    insert_intro :
      (forall p : nat, occ t p -> occ t' p) ->
      occ t' n ->
      (forall p : nat, occ t' p -> occ t p \/ n = p) ->
      search t' -> INSERT n t t'.(* V:        INSERTION 
**********************************
**********************************


V.1   Definition of an INSERT predicate (a la  Prolog)
***************************************************


We begin with the definition of a predicate:

(INSERT n t t') if t' is a binary search tree containing exactly
  n and the elements of t *)


Inductive INSERT (n : nat) (t t' : nat_tree) : Prop :=
    insert_intro :
      (forall p : nat, occ t p -> occ t' p) ->
      occ t' n ->
      (forall p : nat, occ t' p -> occ t p \/ n = p) ->
      search t' -> INSERT n t t'.(* ZZZZ ! insert_rec is defined ! yep ! *)


(* the specification of an insertion algorithm *)

Definition INSERT_SPEC (n : nat) (t : nat_tree) :=
  {t' : nat_tree | INSERT n t t'}.

Lemma insert_nil : forall n : nat, INSERT n NIL (bin n NIL NIL).