(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
Global Set Asymmetric Patterns.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Standard Proposition Elimination Names.
Require Extraction.
Require Export ZArith_base.
Inductive Z_btree : Set :=
| Z_leaf : Z_btree
| Z_bnode : Z -> Z_btree -> Z_btree -> Z_btree.
Inductive Binp : Z_btree -> Prop :=
Binp_intro : forall (n : Z) (t1 t2 : Z_btree), Binp (Z_bnode n t1 t2).
Hint Resolve Binp_intro: searchtrees.
Inductive occ (n : Z) : Z_btree -> Prop :=
| occ_root : forall t1 t2 : Z_btree, occ n (Z_bnode n t1 t2)
| occ_l :
forall (p : Z) (t1 t2 : Z_btree), occ n t1 -> occ n (Z_bnode p t1 t2)
| occ_r :
forall (p : Z) (t1 t2 : Z_btree), occ n t2 -> occ n (Z_bnode p t1 t2).
Hint Resolve occ_root occ_l occ_r: searchtrees.
Derive Inversion_clear OCC_INV with
(forall (z z' : Z) (t1 t2 : Z_btree), occ z' (Z_bnode z t1 t2)).

Lemma occ_inv :
forall (z z' : Z) (t1 t2 : Z_btree),
occ z' (Z_bnode z t1 t2) -> z = z' \/ occ z' t1 \/ occ z' t2.