% A binary tree is represented by tree(Element, Left, Right).
% The empty tree is represented by the constant void.

% is_binary_tree(Tree) means that Tree is a binary tree
is_binary_tree(void).

is_binary_tree(tree(_Element, Left, Right)) :-
    is_binary_tree(Left),
    is_binary_tree(Right).


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tree_member(Element, Tree) means that
%    Element is a member of the binary tree Tree
%
tree_member(X, tree(X, _Left, _Right)) :- !.

tree_member(X, tree(_Y, Left, _Right)) :-
    tree_member(X, Left).

tree_member(X, tree(_Y, _Left, Right)) :-
    tree_member(X, Right).


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tree_member2(Element, Tree) differs from tree_member(Element, Tree)
%     in that no cut is used
%
tree_member2(X, tree(X, _Left, _Right)).

tree_member2(X, tree(_Y, Left, _Right)) :-
    tree_member2(X, Left).

tree_member2(X, tree(_Y, _Left, Right)) :-
    tree_member2(X, Right).


