:- module(avltrees,[]).  %% converted djd
:- style_check(-singleton). % added djd

% Copyright (C) Goedel Group, University of Bristol, June 1992.
% Title and ownership of all Goedel software originating from the Goedel
% Group at the University of Bristol remains with the Goedel Group.
%
% The Goedel language was designed by P.M. Hill and J.W. Lloyd, and the 
% language was implemented by A. Bowers and J. Wang. The design and 
% implementation of the language was partly supported by the ESPRIT Basic 
% Research Action 3012 (Compulog), a SERC Grant GR/F/26256, and the 
% University of Bristol.
%
% This software is available ONLY for research and educational purposes.
% In particular, it may not be used for any commercial purpose whatsoever.
% The software is free and is provided "as is", without warranty of any kind.
% Users of the software are free to modify and experiment with it for 
% research and educational purposes. However, users may not distribute 
% the software (modified or not) to third parties without the express 
% permission of the Goedel Group. The normal method of obtaining this 
% software is by ftp from ftp.cs.kuleuven.ac.be.
%
% Any enquiries about this copyright notice or the use of this software 
% should be directed to J.W. Lloyd at jwl@compsci.bristol.ac.uk.


/* 
Subject:	the compiled avlTree routines.
Date:		20 Feb 1992
	
================================================================================
*/

%% '$$module'('@(#)avltrees.pl 1.5 last updated 93/05/20 18:13:38 by jiwei').


'avlTrees.adjustment.p4'('avlTrees.eq.c0', 'avlTrees.left.c0', 'avlTrees.lh.c0', 'avlTrees.no.c0') :- !.
'avlTrees.adjustment.p4'('avlTrees.eq.c0', 'avlTrees.right.c0', 'avlTrees.rh.c0', 'avlTrees.no.c0') :- !.
'avlTrees.adjustment.p4'('avlTrees.lh.c0', 'avlTrees.left.c0', _, 'avlTrees.yes.c0') :- !.
'avlTrees.adjustment.p4'('avlTrees.lh.c0', 'avlTrees.right.c0', 'avlTrees.eq.c0', 'avlTrees.no.c0') :- !.
'avlTrees.adjustment.p4'('avlTrees.rh.c0', 'avlTrees.left.c0', 'avlTrees.eq.c0', 'avlTrees.no.c0') :- !.
'avlTrees.adjustment.p4'('avlTrees.rh.c0', 'avlTrees.right.c0', _, 'avlTrees.yes.c0') :- !.
'avlTrees.avlJoin.P3'(A, B, C) :-
        'avlTrees.avlJoinAux.P3'(B, A, C).
'avlTrees.avlInsert.p4'(A, B, C, D) :-
        'avlTrees.insert.P5'(A, B, C, D, _).
'avlTrees.avlAmend.P6'(A, B, C, D, E, F) :-
        'avlTrees.amend.P7'(A, B, C, D, E, F, _).
'avlTrees.avlDelete.P3'(A, B, C) :-
        'avlTrees.DeleteKey.p4'(A, B, C, _).
'avlTrees.avlIsEmpty.P1'('avlTrees.Null.c0').
'avlTrees.avlSearch.P3'('avlTrees.Node.F5'(_,A,B,_,_), C, D) :-
        call_residue(C=A, E),
        (   E=[] ->
            true
        ;   user:flounder_commit(E)
        ), !,
        D=B.
'avlTrees.avlSearch.P3'('avlTrees.Node.F5'(A,B,_,_,_), C, D) :-
        call_residue('Strings.<.P2'(C,B), E),
        (   E=[] ->
            true
        ;   user:flounder_commit(E)
        ), !,
        'avlTrees.avlSearch.P3'(A, C, D).
'avlTrees.avlSearch.P3'('avlTrees.Node.F5'(_,A,_,_,B), C, D) :-
        call_residue('Strings.>.P2'(C,A), E),
        (   E=[] ->
            true
        ;   user:flounder_commit(E)
        ), !,
        'avlTrees.avlSearch.P3'(B, C, D).
'avlTrees.avlMember.P3'('avlTrees.Node.F5'(_,A,B,_,_), A, B).
'avlTrees.avlMember.P3'('avlTrees.Node.F5'(A,_,_,_,_), B, C) :-
        'avlTrees.avlMember.P3'(A, B, C).
'avlTrees.avlMember.P3'('avlTrees.Node.F5'(_,_,_,_,A), B, C) :-
        'avlTrees.avlMember.P3'(A, B, C).
'avlTrees.avlJoinAux.P3'('avlTrees.Null.c0', A, A).
'avlTrees.avlJoinAux.P3'('avlTrees.Node.F5'(A,B,C,_,D), E, F) :-
        'avlTrees.amend.P7'(E, B, C, _, G, _, _),
        'avlTrees.avlJoinAux.P3'(A, G, H),
        'avlTrees.avlJoinAux.P3'(D, H, F).
'avlTrees.avlUpdate.P5'('avlTrees.Node.F5'(A,B,C,D,E), F, G, H, I) :-
        call_residue(F=B, J),
        (   J=[] ->
            true
        ;   user:flounder_commit(J)
        ), !,
        H='avlTrees.Node.F5'(A,B,G,D,E),
        I=C.
'avlTrees.avlUpdate.P5'('avlTrees.Node.F5'(A,B,C,D,E), F, G, H, I) :-
        call_residue('Strings.<.P2'(F,B), J),
        (   J=[] ->
            true
        ;   user:flounder_commit(J)
        ), !,
        'avlTrees.avlUpdate.P5'(A, F, G, K, I),
        H='avlTrees.Node.F5'(K,B,C,D,E).
'avlTrees.avlUpdate.P5'('avlTrees.Node.F5'(A,B,C,D,E), F, G, H, I) :-
        call_residue('Strings.>.P2'(F,B), J),
        (   J=[] ->
            true
        ;   user:flounder_commit(J)
        ), !,
        'avlTrees.avlUpdate.P5'(E, F, G, K, I),
        H='avlTrees.Node.F5'(A,B,C,D,K).
'avlTrees.avlToBinary.P2'('avlTrees.Null.c0', 'avlTrees.Empty.c0').
'avlTrees.avlToBinary.P2'('avlTrees.Node.F5'(A,B,C,_,D), 'avlTrees.Tree.F4'(E,B,C,F)) :-
        'avlTrees.avlToBinary.P2'(A, E),
        'avlTrees.avlToBinary.P2'(D, F).
'avlTrees.Adjust.P6'('avlTrees.no.c0', A, B, _, B, A).
'avlTrees.Adjust.P6'('avlTrees.yes.c0', A, B, C, D, E) :-
        'avlTrees.adjustment.p4'(B, C, D, F),
        'avlTrees.Rebalance.p4'(F, A, D, E).
'avlTrees.DeleteKey.p4'('avlTrees.Node.F5'(A,B,C,D,E), F, G, H) :-
        call_residue('Strings.<.P2'(F,B), I),
        (   I=[] ->
            true
        ;   user:flounder_commit(I)
        ), !,
        'avlTrees.DeleteKey.p4'(A, F, J, K),
        'avlTrees.Adjust.P6'(K, 'avlTrees.Node.F5'(J,B,C,D,E), D, 'avlTrees.right.c0', L, G),
        'avlTrees.HeightDecreased.P3'(D, L, H).
'avlTrees.DeleteKey.p4'('avlTrees.Node.F5'(A,B,C,D,E), F, G, H) :-
        call_residue('Strings.>.P2'(F,B), I),
        (   I=[] ->
            true
        ;   user:flounder_commit(I)
        ), !,
        'avlTrees.DeleteKey.p4'(E, F, J, K),
        'avlTrees.Adjust.P6'(K, 'avlTrees.Node.F5'(A,B,C,D,J), D, 'avlTrees.left.c0', L, G),
        'avlTrees.HeightDecreased.P3'(D, L, H).
'avlTrees.DeleteKey.p4'('avlTrees.Node.F5'(A,B,_,C,D), E, F, G) :-
        call_residue(E=B, H),
        (   H=[] ->
            true
        ;   user:flounder_commit(H)
        ), !,
        'avlTrees.Combine.P5'(A, C, D, F, G).
'avlTrees.BalanceTable2.P3'('avlTrees.lh.c0', 'avlTrees.eq.c0', 'avlTrees.rh.c0').
'avlTrees.BalanceTable2.P3'('avlTrees.rh.c0', 'avlTrees.lh.c0', 'avlTrees.eq.c0').
'avlTrees.BalanceTable2.P3'('avlTrees.eq.c0', 'avlTrees.eq.c0', 'avlTrees.eq.c0').
'avlTrees.BalanceTable1.P3'('avlTrees.eq.c0', 'avlTrees.rh.c0', 'avlTrees.lh.c0').
'avlTrees.BalanceTable1.P3'('avlTrees.lh.c0', 'avlTrees.eq.c0', 'avlTrees.eq.c0').
'avlTrees.BalanceTable1.P3'('avlTrees.rh.c0', 'avlTrees.eq.c0', 'avlTrees.eq.c0').
'avlTrees.amend.P7'('avlTrees.Null.c0', A, B, C, 'avlTrees.Node.F5'('avlTrees.Null.c0',A,B,'avlTrees.eq.c0','avlTrees.Null.c0'), C, 'avlTrees.yes.c0').
'avlTrees.amend.P7'('avlTrees.Node.F5'(A,B,C,D,E), F, G, H, I, J, K) :-
        call_residue('Strings.<.P2'(F,B), L),
        (   L=[] ->
            true
        ;   user:flounder_commit(L)
        ), !,
        'avlTrees.amend.P7'(A, F, G, H, M, J, N),
        'avlTrees.Adjust.P6'(N, 'avlTrees.Node.F5'(M,B,C,D,E), D, 'avlTrees.left.c0', O, I),
        'avlTrees.HeightIncreased.P3'(D, O, K).
'avlTrees.amend.P7'('avlTrees.Node.F5'(A,B,C,D,E), F, G, H, I, J, K) :-
        call_residue('Strings.>.P2'(F,B), L),
        (   L=[] ->
            true
        ;   user:flounder_commit(L)
        ), !,
        'avlTrees.amend.P7'(E, F, G, H, M, J, N),
        'avlTrees.Adjust.P6'(N, 'avlTrees.Node.F5'(A,B,C,D,M), D, 'avlTrees.right.c0', O, I),
        'avlTrees.HeightIncreased.P3'(D, O, K).
'avlTrees.amend.P7'('avlTrees.Node.F5'(A,B,C,D,E), F, G, _, H, I, J) :-
        call_residue(F=B, K),
        (   K=[] ->
            true
        ;   user:flounder_commit(K)
        ), !,
        H='avlTrees.Node.F5'(A,F,G,D,E),
        I=C,
        J='avlTrees.no.c0'.
'avlTrees.Combine.P5'('avlTrees.Null.c0', _, A, A, 'avlTrees.yes.c0') :- !.
'avlTrees.Combine.P5'(A, _, 'avlTrees.Null.c0', A, 'avlTrees.yes.c0') :- !.
'avlTrees.Combine.P5'(A, B, C, D, E) :-
        call_residue((user:not_equal([],[A],A,'avlTrees.Null.c0'),user:not_equal([],[C],C,'avlTrees.Null.c0')), F),
        (   F=[] ->
            true
        ;   user:flounder_commit(F)
        ), !,
        'avlTrees.Removerightmost.P5'(A, G, H, I, J),
        'avlTrees.Adjust.P6'(J, 'avlTrees.Node.F5'(I,G,H,B,C), B, 'avlTrees.right.c0', K, D),
        'avlTrees.HeightDecreased.P3'(B, K, E).
'avlTrees.insert.P5'('avlTrees.Null.c0', A, B, 'avlTrees.Node.F5'('avlTrees.Null.c0',A,B,'avlTrees.eq.c0','avlTrees.Null.c0'), 'avlTrees.yes.c0').
'avlTrees.insert.P5'('avlTrees.Node.F5'(A,B,C,D,E), F, G, H, I) :-
        call_residue('Strings.<.P2'(F,B), J),
        (   J=[] ->
            true
        ;   user:flounder_commit(J)
        ), !,
        'avlTrees.insert.P5'(A, F, G, K, L),
        'avlTrees.Adjust.P6'(L, 'avlTrees.Node.F5'(K,B,C,D,E), D, 'avlTrees.left.c0', M, H),
        'avlTrees.HeightIncreased.P3'(D, M, I).
'avlTrees.insert.P5'('avlTrees.Node.F5'(A,B,C,D,E), F, G, H, I) :-
        call_residue('Strings.>.P2'(F,B), J),
        (   J=[] ->
            true
        ;   user:flounder_commit(J)
        ), !,
        'avlTrees.insert.P5'(E, F, G, K, L),
        'avlTrees.Adjust.P6'(L, 'avlTrees.Node.F5'(A,B,C,D,K), D, 'avlTrees.right.c0', M, H),
        'avlTrees.HeightIncreased.P3'(D, M, I).
'avlTrees.insert.P5'('avlTrees.Node.F5'(A,B,C,D,E), F, G, H, I) :-
        call_residue(F=B, J),
        (   J=[] ->
            true
        ;   user:flounder_commit(J)
        ), !,
        G=C,
        H='avlTrees.Node.F5'(A,B,C,D,E),
        I='avlTrees.no.c0'.
'avlTrees.HeightIncreased.P3'('avlTrees.rh.c0', 'avlTrees.eq.c0', 'avlTrees.no.c0') :- !.
'avlTrees.HeightIncreased.P3'('avlTrees.lh.c0', 'avlTrees.eq.c0', 'avlTrees.no.c0') :- !.
'avlTrees.HeightIncreased.P3'('avlTrees.eq.c0', 'avlTrees.lh.c0', 'avlTrees.yes.c0') :- !.
'avlTrees.HeightIncreased.P3'('avlTrees.eq.c0', 'avlTrees.rh.c0', 'avlTrees.yes.c0') :- !.
'avlTrees.HeightIncreased.P3'(A, A, 'avlTrees.no.c0') :- !.
'avlTrees.HeightDecreased.P3'('avlTrees.lh.c0', 'avlTrees.rh.c0', 'avlTrees.no.c0') :- !.
'avlTrees.HeightDecreased.P3'('avlTrees.rh.c0', 'avlTrees.lh.c0', 'avlTrees.no.c0') :- !.
'avlTrees.HeightDecreased.P3'('avlTrees.lh.c0', 'avlTrees.eq.c0', 'avlTrees.yes.c0') :- !.
'avlTrees.HeightDecreased.P3'('avlTrees.rh.c0', 'avlTrees.eq.c0', 'avlTrees.yes.c0') :- !.
'avlTrees.HeightDecreased.P3'('avlTrees.eq.c0', _, 'avlTrees.no.c0') :- !.
'avlTrees.HeightDecreased.P3'(A, A, 'avlTrees.no.c0') :- !.
'avlTrees.Removerightmost.P5'('avlTrees.Node.F5'(A,B,C,D,E), F, G, H, I) :-
        call_residue(user:not_equal([],[E],E,'avlTrees.Null.c0'), J),
        (   J=[] ->
            true
        ;   user:flounder_commit(J)
        ), !,
        'avlTrees.Removerightmost.P5'(E, F, G, K, L),
        'avlTrees.Adjust.P6'(L, 'avlTrees.Node.F5'(A,B,C,D,K), D, 'avlTrees.left.c0', M, H),
        'avlTrees.HeightDecreased.P3'(D, M, I).
'avlTrees.Removerightmost.P5'('avlTrees.Node.F5'(A,B,C,_,'avlTrees.Null.c0'), B, C, A, 'avlTrees.yes.c0') :- !.
'avlTrees.Rebalance.p4'('avlTrees.no.c0', 'avlTrees.Node.F5'(A,B,C,_,D), E, 'avlTrees.Node.F5'(A,B,C,E,D)).
'avlTrees.Rebalance.p4'('avlTrees.yes.c0', A, B, C) :-
        'avlTrees.Restructure.P3'(A, B, C).
'avlTrees.Restructure.P3'('avlTrees.Node.F5'(A,B,C,'avlTrees.rh.c0','avlTrees.Node.F5'(D,E,F,G,H)), I, J) :-
        call_residue(user:not_equal([],[G],G,'avlTrees.lh.c0'), K),
        (   K=[] ->
            true
        ;   user:flounder_commit(K)
        ), !,
        J='avlTrees.Node.F5'('avlTrees.Node.F5'(A,B,C,L,D),E,F,I,H),
        'avlTrees.BalanceTable1.P3'(G, L, I).
'avlTrees.Restructure.P3'('avlTrees.Node.F5'('avlTrees.Node.F5'(A,B,C,D,E),F,G,'avlTrees.lh.c0',H), I, J) :-
        call_residue(user:not_equal([],[D],D,'avlTrees.rh.c0'), K),
        (   K=[] ->
            true
        ;   user:flounder_commit(K)
        ), !,
        J='avlTrees.Node.F5'(A,B,C,I,'avlTrees.Node.F5'(E,F,G,L,H)),
        'avlTrees.BalanceTable1.P3'(D, I, L).
'avlTrees.Restructure.P3'('avlTrees.Node.F5'(A,B,C,'avlTrees.rh.c0','avlTrees.Node.F5'('avlTrees.Node.F5'(D,E,F,G,H),I,J,'avlTrees.lh.c0',K)), 'avlTrees.eq.c0', 'avlTrees.Node.F5'('avlTrees.Node.F5'(A,B,C,L,D),E,F,'avlTrees.eq.c0','avlTrees.Node.F5'(H,I,J,M,K))) :- !,
        'avlTrees.BalanceTable2.P3'(G, L, M).
'avlTrees.Restructure.P3'('avlTrees.Node.F5'('avlTrees.Node.F5'(A,B,C,'avlTrees.rh.c0','avlTrees.Node.F5'(D,E,F,G,H)),I,J,'avlTrees.lh.c0',K), 'avlTrees.eq.c0', 'avlTrees.Node.F5'('avlTrees.Node.F5'(A,B,C,L,D),E,F,'avlTrees.eq.c0','avlTrees.Node.F5'(H,I,J,M,K))) :- !,
        'avlTrees.BalanceTable2.P3'(G, L, M).
