Simple Function on binary trees

Consider the following definition of binary trees the nodes of which are labelled with integers
Inductive Zbtree : Type :=
|  leaf 
|  bnode (r:Z)(t1 t2: Zbtree).

(** Checks whether t is a leaf *)
is_leaf (t: Zbtree) : bool :=


(** Returns the total number of nodes (binary nodes and leaves) of t *)
size (t: Zbtree) : nat :=

(** returns the heigth of t *)
height (t:Zbtree) : nat :=

(** returns the mirror of t *)
mirror (t:Zbtree) : Zbtree 

(** Checks whether n labels some node of t *)
memb (n:Z)(t: Zbtree) : bool 

(** Computes the list of t's labels (in infix order) *)
infix_list (t:Zbtree) : list Z 

(** Checks whether t is a search tree *)
is_searchtree (t:Zbtree) : bool

(** Checks whether n labels some node of t . This function is more efficient
   than memb, but is correct  only is applied to to a search tree *)
memb_in_searchtree  (n:Z)(t: Zbtree) : bool 

(** Transforms a list of integers into a searchtree *)
list_to_searchtree (l:list Z) : Zbtree 

Notes

You may require some libraries :

Comments

This exercise will be extended in several directions:

Solution

See this file