[comp.lang.prolog] PROLOG Digest V5 #66

PROLOG-REQUEST@SUSHI.STANFORD.EDU (Chuck Restivo, The Moderator) (09/26/87)

PROLOG Digest           Saturday, 26 Sep 1987      Volume 5 : Issue 66

Today's Topics:
                       LP Library - PRO_LIB.DOC
----------------------------------------------------------------------

Date: Fri, 25 Sep 87 12:44:50 PDT
From: Edouard Lagache <lagache@violet.Berkeley.EDU> 
Subject: file: 'PRO_LIB.DOC'


                     =======================================
                     PROLOG Supplemental Predicate Libraries
                                  Users Manual
                            Release - I, July - 1987
                    ========================================













             Copyright (C) 1987 Edouard Lagache, ALL RIGHTS RESERVED




     Campus Address:                                   Home Address:

     Education in Math, Science,                       29 Altamount Drive
     and Technology (EMST)                             Orinda, CA, 94563
     School of Education
     4533 Tolman Hall
     University of California, Berkeley      Arpanet Electronic Mail:
     Berkeley, CA, 94720                     lagache@violet.berkeley.edu










                     PROLOG Supplemental Predicate Libraries

                                 Edouard Lagache
                     Copyright (C) 1987, ALL RIGHTS RESERVED

                            Release - I, July - 1987



                        T A B L E   O F   C O N T E N T S


     0.0  Abstract:  . . . . . . . . . . . . . . . . . . . . . . . . . .   3

     1.0 Copyright and Disclaimer Notices: . . . . . . . . . . . . . . .   3
          1.1  DISCLAIMER: . . . . . . . . . . . . . . . . . . . . . . .   3
          1.2  Bug Fixes and Updates:  . . . . . . . . . . . . . . . . .   4

     2.0  Introduction:  . . . . . . . . . . . . . . . . . . . . . . . .   4
          2.1  PROLOG Compatibility: . . . . . . . . . . . . . . . . . .   4
          2.2  Computer system Compatibility:  . . . . . . . . . . . . .   5
          2.4  References: . . . . . . . . . . . . . . . . . . . . . . .   5
          2.5  Documentation Format: . . . . . . . . . . . . . . . . . .   6
          2.6  Library interdependencies:  . . . . . . . . . . . . . . .   6

     3.0  Library File: ANSI_IO.PRO: . . . . . . . . . . . . . . . . . .   7

     4.0  Library File: ENV_FUNT.PRO:  . . . . . . . . . . . . . . . . .  12

     5.0  Library File: STDDEF.PRO:  . . . . . . . . . . . . . . . . . .  15

     6.0  Library File: STDIO.PRO: . . . . . . . . . . . . . . . . . . .  23

     7.0  Library File: STDLIST.PRO: . . . . . . . . . . . . . . . . . .  26

     8.0  Library File: WINDOW.PRO:  . . . . . . . . . . . . . . . . . .  39

     9.0  Installation procedures and Utilities. . . . . . . . . . . . .  42

     10.0 CONCLUSION:  . . . . . . . . . . . . . . . . . . . . . . . . .  45

     I N D E X . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  46










                                   Page - 2/46







                     PROLOG Supplemental Predicate Libraries

                                 Edouard Lagache
                     Copyright (C) 1987, ALL RIGHTS RESERVED

                            Release - I, July - 1987


     0.0  Abstract: This is the documentation for a set of libraries of
          PROLOG predicates that can be useful in a wide range of
          applications.  This set includes the following libraries: ANSI
          standard terminal manipulation, PROLOG environment functions,
          arithmetic and matching functions, generic input/output functions,
          list manipulation functions, and window device support.

      1.0 Copyright and Disclaimer Notices:  These libraries are copyrighted
          by the Author who retains all rights to its use and distribution
          in all conceivable form.  Permission is granted to freely
          distributed with the following restrictions:

          1.)  The library set must not be sold (or included with a package
               that is) without express written permission from the author.
          2.)  The library set must be distributed in its complete and
               original form, with all copyrights author credits intact.
               The following files make up the package:
                    ANSI_IO.PRO
                    ENV_FUNT.PRO
                    LD_LIB
                    LIST_SYM.PRO
                    PRO_LIB.DOC
                    READ.ME
                    STDDEF.PRO
                    STDIO.PRO
                    STDLIST.PRO
                    WINDOW.PRO

     1.1  DISCLAIMER: The PROLOG supplemental predicate libraries are
          distributed on a strictly "as is" basis without warranty of any
          kind.  The entire risk as to results and performance of these
          libraries is assumed by you.  Moreover,the author does not
          warrant, guarantee or make any representation regarding the use,
          or the results of the use of these libraries in terms of accuracy,
          reliability, correctness, or otherwise.  You rely on these
          libraries solely at your own risk.










                                   Page - 3/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     1.2  Bug Fixes and Updates:  Because these libraries are being
          distributed without charge, I will not be able to make much of an
          effort to fix bugs or make improvements.  Nor will I be able to
          port these libraries to non-standard PROLOGs.  Since these are
          source code libraries, competent PROLOG users should be able to
          perform these tasks for themselves.  I ask however, that users DO
          NOT distribute modified versions.  Doing so will flood the field
          with half-patched versions, and eventually make impossible to
          provide accurate documentation.  Please send all bug fixes, ports,
          or suggestions for improvement to me at any of the above
          addresses.  Please be patient however, because I must give my
          graduate work precedence over altruism!  I will give credit to any
          contributors in future releases of these libraries.

     1.3  Trademarks: The following trademarks are used in this document:
          IBM is a trademark of International Business Machines, Inc.  MS-
          DOS is a trademark of Microsoft Corporation,  VT is a trademark of
          Digital Equipment Corporation.  UNIX is a trademark of American
          Telephone and Telegraph.


     2.0  Introduction:  The PROLOG Supplemental Predicate Libraries are a
          set of general purpose predicates that can be convenient in a wide
          range of applications.  They were developed by the author as part
          of developing Intelligent Computer Assisted Instructional systems
          for a Master's Thesis at U.C. Berkeley.  There are two motivations
          for these libraries.  First, develop a set of portable PROLOG
          predicates that would overcome the language's somewhat
          impoverished set of built-in predicates.  Second, provide tools to
          assist in porting LISP type applications.  As it turns out, a sign
          of maturity in PROLOG programming is a decreasing need for
          crutches such as these libraries.  Nevertheless, these libraries
          are quite helpful in reducing the need to "reinvent the wheel"
          when programming in PROLOG, and the author cringes at the thought
          of trying to program in a PROLOG that isn't enriched by these
          libraries.

     2.1  PROLOG Compatibility:  These libraries were developed on a number
          of PROLOG systems including CPROLOG and UNSW PROLOG, but the bulk
          of development has been on VML PROLOG by Automata Design
          Associates (ADA) of Dresher, Pennsylvania.  VML PROLOG is a good
          implementation of CORE PROLOG as described by C.F. Clocksin and
          C.S. Mellish's, Programming in PROLOG.  Of course, VML PROLOG does
          contain a number of important extensions, code for both CORE
          PROLOG and VML PROLOG are provided whenever there is a significant
          advantage in using extension predicates.





                                   Page - 4/46





     Edouard Lagache                             PROLOG Libraries, Release-I



     2.2  Computer system Compatibility:  Most of the predicates in this
          library are computer system independent.  However, two of the
          libraries are intended for use with MS-DOS class computers.
          ANSI_IO contains predicates to control a console using the ANSI
          standard escape sequences.  MS-DOS Computers that do not support
          the ANSI standard directly can be made to do so by installing the
          ANSI.SYS device driver that is supplied on the MS-DOS system
          diskette.  Since most of the work on these libraries was done with
          a Texas Instruments Professional Computer, some of the predicates
          bear some idiosyncracies of that machine.  In particular,
          WINDOW.PRO is a supplemental library that supports the WINDOW.SYS
          device driver by Greg Haley of Texas Instruments.  Unfortunately,
          WINDOW.SYS will run only on a Texas Instruments Professional
          Computer.  If you own a TIPC, the WINDOW.SYS device driver should
          be available from any TIPC users group, or contact the author of
          this library for assistance.

     2.3  Credits:  A number of predicates in this library are taken from
          Clocksin and Mellish's book Programming in PROLOG.  This fact is
          reported in the comment header for those predicates.  One
          predicate is the solution to an assignment in Ivan Bratko's PROLOG
          Programming for Artificial Intelligence.  Finally, most of the
          work on these predicates was carried out while I was taking a
          series of courses from Professor L.A. Zadeh of the U.C. Berkeley
          Computer science department whose assistance and encouragement was
          invaluable in their creation.

     2.4  References:  The following books should be helpful to anyone
          attempting to learn the PROLOG language:

          W.F. Clocksin and C.S. Mellish, Programming in PROLOG, Springer-
               Verlag, 1981:
               Clocksin and Mellish is the standard reference text for
               PROLOG.  Unfortunately, it is now dated and falls very short
               of being a readable introduction to PROLOG.  However, it has
               many examples, and is well organized.

          Ivan Bratko, PROLOG Programming for Artificial Intelligence,
               Addison-Wesley, 1986:
               Bratko's book is a major improvement over Clocksin and
               Mellish, but it is not particularly easy reading either.  The
               book's strongest point is a wealth of applications including
               PROLOG solutions to: database systems, tree representation,
               search strategies, expert systems, and game playing.








                                   Page - 5/46





     PROLOG Libraries, Release-I                             Edouard Lagache




          For more information on VML PROLOG that is used to maintain this
          library, contact:

               Automata Design Associates
               1570 Arran way
               Dresher, PA, 19025
               (215) 646-4894

     2.5  Documentation Format:  Predicates are listed in alphabetical order
          within their respective libraries as they are in this document.
          Each predicate is described in a manner analogous to the UNIX
          programmers manual.  First, the predicate is listed with sample
          usage (synopsis), and purpose.  Then the predicate is described,
          special notes recorded, limitations listed, and any known bugs
          described.

               For brevity assume that all predicates are functors unless
          explicitly stated otherwise.  Where PROLOG operators are used,
          operator type but not precedence will be listed since invariably
          programmers will need to adjust precedence to suit their needs.

               The usage synopsis will indicate both the sort of arguments
          and their storage class.  The type of classes are:

          1.)  Atom.
          2.)  Number (integer in general).
          3.)  List.
          4.)  String.
          5.)  Expression (any valid PROLOG expression).
          6.)  Predicate (a valid call to a PROLOG predicate).

               To create meaningful names, sample variables will be created
          by adding a suffix of the above classes to a descriptive name.
          Thus, a value of the screen column becomes: 'Column_number'.

     2.6  Library interdependencies:  There are a number of predicates that
          depend on predicates in other libraries.  To be specific,
          'ENV_FUNT.PRO', and 'STDDEF.PRO' depend on the 'STDLIST.PRO'
          library.  This dependency can be eliminated by copying the
          required predicate to the other files, but this is not recommended
          unless a specific application already exists and a reduction of
          symbol space is required.









                                   Page - 6/46





     Edouard Lagache                             PROLOG Libraries, Release-I



     3.0  Library File: ANSI_IO.PRO:

          DESCRIPTION:   This library contains predicates that permit users
               of PC class microcomputers to perform basic screen
               manipulation.  Apparently, these sequences will also work on
               a VT100 terminal.  Screen manipulations are performed by
               escape character sequences defined by the ANSI standards
               committee.  For these predicates to work on many PC's, the
               ANSI.SYS device driver must be installed (see your MS-DOS
               manual).  Other PC's (like the Texas Instruments Professional
               Computer) have the ANSI device driver built into the
               hardware.

          NOTES:    ADA VML PROLOG has a set of built-in predicates that are
               specific to the IBM PC and compatibles.  The color attribute
               settings are probably specific to the Texas Instruments
               Professional Computer, but should be easily adaptable to
               other computers.

     ----------------------------------------


     3.1  PREDICATE:     center_stg/1

          SYNOPSIS:      center_stg(String).

          PURPOSE:       Display a line of text that is centered in an
                         eighty column monitor where the text is a PROLOG
                         string.


          DESCRIPTION:   'center_stg' is a useful predicate in developing
               more attractive PROLOG user interfaces.  The predicate first
               calls the predicate 'comp_tabs' to determine how many spaces
               to move over.  Then the appropriate number of spaces are
               moved over and the predicate 'prtstr' is used to print out
               the string.  A newline is supplied after the expression.

          NOTES:    'prtstr' is also part of this library.

          LIMITATIONS:   Cannot handle monitors with more or less than 80
                         columns at this time.

          BUGS:     No Known Bugs.


     ----------------------------------------





                                   Page - 7/46





     PROLOG Libraries, Release-I                             Edouard Lagache



     3.2  PREDICATE:     clear_end/0

          SYNOPSIS:      clear_end.

          PURPOSE:       delete characters from the current cursor position
                         to the end of the screen.


          DESCRIPTION:   'clear_end' uses the ANSI escape sequence to clear
               the end of a monitor screen including the current cursor
               position.  'prtstr' is used to send the string.

          NOTES:    'prtstr' is also part of this library.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     3.3  PREDICATE:     clear_line/0

          SYNOPSIS:      clear_line.

          PURPOSE:       delete characters from the current cursor position
                         to the end of the line.


          DESCRIPTION:   'clear_line' uses the ANSI escape sequence to clear
               the end of a line including the current cursor position.
               'prtstr' is used to send the string.

          NOTES:    'prtstr' is also part of this library.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------











                                   Page - 8/46





     Edouard Lagache                             PROLOG Libraries, Release-I




     3.4  PREDICATE:     clear_screen/0

          SYNOPSIS:      clear_screen.

          PURPOSE:       Removes all characters from the screen and places
                         the cursor at the top left corner of the screen.


          DESCRIPTION:   'clear_screen' uses the ANSI escape sequence to
               clear the screen and reset the cursor position.  'prtstr' is
               used to send the string.

          NOTES:    'prtstr' is also part of this library.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     3.5  PREDICATE:     locate_cursor/2

          SYNOPSIS:      locate_cursor(Row_number, Column_number).

          PURPOSE:       Place the cursor anywhere on the monitor screen.


          DESCRIPTION:   'locate_cursor' allows the programmer to place the
               cursor anywhere on the monitor screen.  For most monitors the
               'Row_number' must remain between 1 and 24, and the
               'Column_number' must remain between 1 and 80.  'prtstr' and
               'write' are used to send the command string.

          NOTES:    'prtstr' is also part of this library.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.

     ----------------------------------------










                                   Page - 9/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     3.6  PREDICATE:     prtstr/1

          SYNOPSIS:      prtstr(String)

          PURPOSE:       Send a list of ASCII characters codes to the
                         current stream.


          DESCRIPTION:   'prtstr' sends a PROLOG string to the current
               output stream.  For efficiency the string is converted into a
               name before being output with the 'write' predicate.

          NOTES:    'prtstr' is built into VML PROLOG.

          LIMITATIONS: None.

          BUGS:     By using the predicate 'name' to turn a string into a
                    symbol, this predicate tends to clutter up the symbol
                    space.  However, it is much more efficient that the
                    Clocksin and Mellish implementation.


     ----------------------------------------

     3.7  PREDICATE:     push_up/1

          SYNOPSIS:      push_up(Line_number).

          PURPOSE:       Send the requested number of newlines to the
                         current output stream.


          DESCRIPTION:   'push_up' is a useful predicate for either monitor
               screen formatting or file formatting.  It simply sends
               'Line_number' number of newlines to what output stream is
               current.  It is device independent, but is not very
               efficient.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------





                                  Page - 10/46





     Edouard Lagache                             PROLOG Libraries, Release-I



     3.8  PREDICATE:     set_attribute/1

          SYNOPSIS:      set_attribute(Attribute_atom).

          PURPOSE:       Set screen attributes (colors and display modes).


          DESCRIPTION:   'set_attribute' allows the programmer to tailor the
               monitor display to his liking.  The 'Attribute_atom' can take
               on the following values: 'reset', 'underline', 'blinking',
               'reverse' (type of display), 'black', 'red', 'green',
               'yellow', 'blue', 'magenta', 'cyan', and 'white' (possible
               colors).  Any text sent to the monitor after setting an
               attribute will take on that attribute until changed.  Command
               strings are sent using 'prtstr'.

          NOTES:    'prtstr' is part of this library.  The colors listed are
               specific to the Texas Instruments Professional Computer.
               Some adjustment may be needed for other computers.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.





























                                  Page - 11/46





     PROLOG Libraries, Release-I                             Edouard Lagache



     4.0  Library File: ENV_FUNT.PRO:

          DESCRIPTION:   This library contains a number of predicates to
               facilitate the process of program modification and testing,
               and to improve access to the operating system environment.
               This particular library is very specific to VML PROLOG but
               the basic concept should be usable on any PROLOG running
               under MS-DOS 2.X or later, or a UNIX-like operating system.

          NOTES:    This particular set of predicates assumes an editor name
               of 'EDIT'.  To use these predicates with another editor,
               simply replace the word 'EDIT' with the name of your editor.


     ----------------------------------------

     4.1  PREDICATE:     dos/0

          SYNOPSIS:      dos.

          PURPOSE:       Temporarily exiting PROLOG to return to the
                         operating system.


          DESCRIPTION:   'dos' allows the PROLOG user to temporarily return
               to the operating system to perform what tasks are needed
               there.  To return to PROLOG from the operating system,
               something like the MS-DOS 'EXIT' command should be used
               (refer to your operating system manual for details).

          NOTES:    This predicate is based on MS-DOS conventions, but can
               be easily adapted to other UNIX-like conventions.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------













                                  Page - 12/46





     Edouard Lagache                             PROLOG Libraries, Release-I




     4.2  PREDICATE:     edit/1    (Operator class: fx)

          SYNOPSIS:      edit Filename_atom.

          PURPOSE:       Invoke editor from within PROLOG.


          DESCRIPTION:   'edit' is a convenient abbreviation for shell
               commands that permit the running of programs outside of
               PROLOG.  'edit' concatenates the '.PRO' extension to the
               filename to be edited, and then calls up a new shell to run
               the editor with the filename as an argument.

          NOTES:    'edit' should be renamed to the editor of your choice.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     4.3  PREDICATE:     ledit/1   (Operator class: fx)

          SYNOPSIS:      ledit Filename_atom.

          PURPOSE:       Invoke editor from within PROLOG and load corrected
                         file into the PROLOG environment.


          DESCRIPTION:   'ledit' is a straightforward extension of 'edit'.
               Once a file has been edited by an editor, that file is first
               cleared with 'forget' and then loaded into the PROLOG
               environment with 'consult'.

          NOTES:    Due to a somewhat unusual interpretation by ADA of the
               'reconsult' command, 'reconsult' will not have the same
               effect as first 'forget'ing the file and then 'consult'ing
               it.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------





                                  Page - 13/46





     PROLOG Libraries, Release-I                             Edouard Lagache



     4.4  PREDICATE:     run/1     (Operator class: fx)

          SYNOPSIS:      run OperatingSystemCommand_atom

          PURPOSE:       Streamline execution of operating system commands.


          DESCRIPTION:   'run' is simply an operator to replace the 'exec'
               functor.  Using run saves typing a set of parenthesis.

          NOTES:    VML PROLOG doesn't permit the 'exec' functor to be
               assigned an operator status.

          LIMITATIONS:   The command given to run must be a valid PROLOG
                         atom.  Thus, in many cases single quotes will be
                         needed.

          BUGS:     No Known Bugs.


































                                  Page - 14/46





     Edouard Lagache                             PROLOG Libraries, Release-I



     5.0  Library File: STDDEF.PRO:

          DESCRIPTION:   This library contains a number of general purpose
               predicates.  These predicates include: tools for collecting
               data from database clauses (such as 'findall'),  arithmetic
               predicates such as 'oddp', and miscellaneous other
               predicates.

          NOTES:


     ----------------------------------------

     5.1  PREDICATE:     call/1

          SYNOPSIS:      call(Goal_expression).

          PURPOSE:       Attempt to satisfy 'Goal_expression'.


          DESCRIPTION:   Older PROLOGs require the 'call' predicate whenever
               goals are constructed using '=..'.  In order to maintain
               compatibility with these older PROLOG it is advisable to use
               'call' even when it isn't required by your PROLOG.  This
               clause trivially implements 'call' by the following
               expression: 'call(X) :- X.'  Eventually, as these older
               PROLOGs become extinct, this predicate will be eliminated.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------
















                                  Page - 15/46





     PROLOG Libraries, Release-I                             Edouard Lagache




          PREDICATE:     concat/3

          SYNOPSIS:      concat(Name1,Name2,Newname).

          PURPOSE:       Concatenate two atom names into a new atom.


          DESCRIPTION:   'concat' builds new atoms by combining two names.
               This is done by first converting 'Name1' and 'Name2' into
               strings, 'append'ing the strings and converting the new
               string back into a name.

          NOTES:    ADA PROLOG supports a more powerful cousin of this
               predicate.  In general it is advisable to use built-in
               predicates for this purpose because this predicate is not
               particularly efficient.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     5.2  PREDICATE:     countmatch/2

          SYNOPSIS:      countmatch(Predicate, Count_number).

          PURPOSE:       Count the number of times 'Predicate' can be
                         satisfied.


          DESCRIPTION:   This predicate can be used to determine the number
               times that 'Predicate' can be satisfied in the current state
               of the database.  This is done by successively failing all
               attempt to satisfy 'Predicate' and count the number of
               failures that occur.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------





                                  Page - 16/46





     Edouard Lagache                             PROLOG Libraries, Release-I



     5.3  PREDICATE:     evenp/1

          SYNOPSIS:      evenp(Number).

          PURPOSE:       Test if a Number is even.


          DESCRIPTION:   This predicate is satisfied if the number is even.
               Number must be instantiated.  A division method is used to
               perform the evaluation.

          NOTES:    Function expects an integer argument.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     5.4  PREDICATE:     findall/3

          SYNOPSIS:      findall(Variable_atom, Predicate, Binding_list).

          PURPOSE:       generate a list of all values of 'Variable_atom'
                         that satisfy 'Predicate'.


          DESCRIPTION:   'findall' is the classic predicate for collecting
               all the values of 'Variable_atom' that are true of
               'Predicate'.  The values are returned on list 'Binding_list'.
               Both 'Binding_list', and 'Variable_atom' should be unbounded.

          NOTES:    PROLOG code is based on Clocksin and Mellish p 162.  The
               variable 'Variable_atom' must be some atom in the Predicate
               call.  For example, to build up the list of integers between
               1 and 10 the following call will do the trick:

                    findall(X,interval(1,X,10),Numberlist).

               (See the 'interval' function in this library.)

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------




                                  Page - 17/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     5.5  PREDICATE:     gensym/2

          SYNOPSIS:      gensym(Root_atom,NewSymbol_atom).

          PURPOSE:       Creating new PROLOG atoms.


          DESCRIPTION:   Many Artificial Intelligence applications need some
               ability to create new names for objects in the systems.  From
               the LISP tradition, new names have been created by appending
               a numerical suffix to a root name.  'gensym' performs this
               function by keeping tract of any previously created names
               (with a database clause), and generating a unique suffix to
               any root name presented to it.

          NOTES:    Two solutions are provided.  The "core" PROLOG solution
               is from Clocksin and Mellish pp 159-162.  However, VML PROLOG
               includes a symbol concatenate predicate that greatly
               simplifies the task of making new symbols.  A second solution
               is provided with the 'concat' predicate.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------
























                                  Page - 18/46





     Edouard Lagache                             PROLOG Libraries, Release-I




     5.6  PREDICATE:     interval/3

          SYNOPSIS:      interval(Lower_number,Value_number, Upper_number).

          PURPOSE:       Generate all integers between the 'Lower_number'
                         and the 'Upper_number'.


          DESCRIPTION:   There are times when it is desirable to work
               through a range of numbers.  'interval' generates all
               integers between 'Lower_number' and 'Upper_number' inclusive.
               If 'Value_number' is bound, then this predicate tests if the
               value lies within the interval.  If 'Value_number' is
               unbound, then it will be bounded to incrementally larger
               values starting at 'Lower_number'.

          NOTES:

          LIMITATIONS:   'interval' is a very inefficient test for "in-
                         range".

          BUGS:     No known bugs.


     ----------------------------------------

     5.7  PREDICATE:     max/3

          SYNOPSIS:      max(Number1,Number2,Max_number).

          PURPOSE:       Return the 'max' of the two numbers.


          DESCRIPTION:   'max' returns the larger of the first two integer
               arguments.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------







                                  Page - 19/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     5.8  PREDICATE:     min/3

          SYNOPSIS:      min(Number1,Number2,Min_number).

          PURPOSE:       Return the 'min' of the two numbers.


          DESCRIPTION:   'min' returns the smaller of the first two integer
               arguments.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     5.9  PREDICATE:     oddp/1

          SYNOPSIS:      oddp(Number).

          PURPOSE:       Test if a Number is odd.


          DESCRIPTION:   This predicate is satisfied if the number is odd.
               Number must be instantiated.  A division method is used to
               evaluate the argument.

          NOTES:    Function expects an integer argument.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------













                                  Page - 20/46





     Edouard Lagache                             PROLOG Libraries, Release-I




     5.10 PREDICATE:     stringp/1

          SYNOPSIS:      stringp(String).

          PURPOSE:       Test for a string argument.


          DESCRIPTION:   Since PROLOG implements strings as just a list of
               ASCII characters.  'stringp' is just tests if the argument is
               a list.  While 'stringp' is just a synonym for 'listp' (see
               STDLIST.PRO library), it is more mnemonic and makes source
               code more legible

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No test is made to distinguish between true strings and
                    mere lists.  Unfortunately doing so would involve
                    significant computation.


     ----------------------------------------




























                                  Page - 21/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     5.11 PREDICATE:     sum_match/3

          SYNOPSIS:      sum_match(SumVariable_atom, Predicate, Sum_number).

          PURPOSE:       Collecting the sum of integer field
                         'SumVariable_atom' of 'Predicate'.


          DESCRIPTION:   There are database applications in which the sum of
               a field in a predicate is needed.  'sum_match' performs this
               service by trying to satisfy 'Predicate'.  If 'Predicate' can
               be satisfied, then the value of the variable will be
               accumulated to the sum and the process will continue.  When
               Predicate is no longer satisfiable, then the sum is computed
               and the value is returned in 'Sum_number'.

          NOTES:    For 'sum_match' to work correctly.  'SumVariable_atom'
               must be some variable in the predicate call.  For example, to
               compute the sum of integers from 1 to 10 the following call
               will do the trick:

                    sum_match(X,interval(1,X,10),Sum10).

               (See the 'interval' function in this library).

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.























                                  Page - 22/46





     Edouard Lagache                             PROLOG Libraries, Release-I



     6.0  Library File: STDIO.PRO:

          DESCRIPTION:   This library contains a "poor man's" set of
               input/output predicates that can be used with just about any
               device.  While they are suitable for simple utilities and
               rough prototyping, it is best to switch to a more complete
               set of I/O functions such as 'ANSI_IO.PRO'.  All predicates
               in this library have equivalents in 'ANSI_IO.PRO'.

          NOTES:


     ----------------------------------------

     6.1  PREDICATE:     center_stg/1

          SYNOPSIS:      center_stg(String).

          PURPOSE:       Print out a string centered on an 80 column
                         display.


          DESCRIPTION:   'center_stg' is a useful predicate in developing
               more attractive PROLOG user interfaces.  The predicate first
               calls the predicate 'comp_tabs' to determine how many spaces
               to move over.  Then the appropriate number of spaces are
               moved over and the predicate 'prtstr' is used to print out
               the string.  A newline is supplied after the expression.

          NOTES:    See 'prtstr' which is also in this library.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------















                                  Page - 23/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     6.2  PREDICATE:     clear_screen/0

          SYNOPSIS:      clear_screen.

          PURPOSE:       Clear the computer display.


          DESCRIPTION:   In library 'STDIO.PRO' clearing the screen is
               accomplished by sending 25 newline characters.  While not
               particularly elegant, it is effective.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     6.3  PREDICATE:     prtstr/1

          SYNOPSIS:      prtstr(String)

          PURPOSE:       Send a list of ASCII characters codes to the
                         current stream.


          DESCRIPTION:   'prtstr' sends a PROLOG string to the current
               output stream.  For efficiency the string is converted into a
               name before being output with the 'write' predicate.

          NOTES:    'prtstr' is built into VML PROLOG.

          LIMITATIONS: None.

          BUGS:     By using the predicate 'name' to turn a string into a
                    symbol, this predicate tends to clutter up the symbol
                    space.  However it is much more efficient that the
                    Clocksin and Mellish implementation.


     ----------------------------------------








                                  Page - 24/46





     Edouard Lagache                             PROLOG Libraries, Release-I




     6.4  PREDICATE:     push_up/1

          SYNOPSIS:      push_up(Line_number).

          PURPOSE:       Send the requested number of newlines to the
                         current output stream.


          DESCRIPTION:   'push_up' is a useful predicate for either monitor
               screen formatting or file formatting.  It simply sends
               'Line_number' number of newlines to what output stream is
               current.  It is device independent, but is not very
               efficient.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.
































                                  Page - 25/46





     PROLOG Libraries, Release-I                             Edouard Lagache



     7.0  Library File: STDLIST.PRO:

          DESCRIPTION:   This library contains a fairly extensive set of
               list manipulation predicates inspired mostly by analogous
               LISP functions.  They are intended to provide useful
               paradigms for handling lists and to assist users of LISP to
               port algorithms to PROLOG.

          NOTES:    Many of these predicates rely strongly on tail recursion
               which is computationally expensive.  If one is performing a
               repetitive task with lists, it is probably advisable to
               optimize any code used from this library.  More often than
               not, modularity must be sacrificed for efficiency.


     ----------------------------------------

     7.1  PREDICATE:     assoc/3

          SYNOPSIS:      assoc(Atom, Assoc_list, Binding).

          PURPOSE:       Associate an atom with some value in an "associate"
                         list.


          DESCRIPTION:   One way to associate a name with a value is to make
               a list of the pair.  Associate lists can be built up out of
               these pairs, and used to create the equivalent of variable
               bindings.  'assoc' looks up the value associated with 'Atom'
               in 'Assoc_list', and returns the atom value pair as
               'Binding'.  For example, the call 'assoc(a,[[a,1],[b,2]],X)'
               would bound the value '[a,1]' to 'X'.

          NOTES:    This scheme of implementing bindings is not particularly
               efficient for PROLOG.  Large collections of data should be
               stored as facts in the database, rather than as associative
               lists.  The predicate 'make_assoc_list' (in this library) is
               a useful tool for creating associate lists.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------







                                  Page - 26/46





     Edouard Lagache                             PROLOG Libraries, Release-I




     7.2  PREDICATE:     append/3

          SYNOPSIS:      append(Source_list1,Source_list2,Result_list).

          PURPOSE:       Create a new list that appends the contents of the
                         second list to that of the first.


          DESCRIPTION:   This classic predicate from Clocksin and Mellish (p
               63) performs a simple but important task.  Unfortunately
               'append' is very recursive, and thus is quite expensive to
               use.  Most predicates that require appending two lists
               together do so as part of other processes.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     7.3  PREDICATE:     delete/3

          SYNOPSIS:      delete(Expression,List,Result_list).

          PURPOSE:       Delete all occurrences of 'Expression' from the top
                         level of a list


          DESCRIPTION:   This predicate is also straight from Clocksin and
               Mellish (p 151).  'delete' simply traverses down a list and
               copies all items that are not 'Expression' in 'List' to the
               'Result_list'.

          NOTES:    See 'delete/4' for a variant of this predicate.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------







                                  Page - 27/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     7.4  PREDICATE:     delete/4

          SYNOPSIS:      delete(Expression,List,Number,Result_list).

          PURPOSE:       Delete no more than 'Number' 'Expression's from the
                         top level of  'List'


          DESCRIPTION:   'delete/4' is a slight variant of the above
               predicate.  Instead of deleting all occurrences of
               'Expression', it deletes the first 'Number' of the
               expressions.  If there are less expressions than 'Number',
               than all expressions are deleted.

          NOTES:    If the number of items to be deleted is known, then
               'delete/4' is slightly more efficient than 'delete/3', since
               it stops traversing the list when the last element to delete
               is found rather than traversing the whole list.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     7.5  PREDICATE:     flatten/2

          SYNOPSIS:      flatten(Source_list,Result_list).

          PURPOSE:       Create a new list with all embedded sublists
                         eliminated from 'Source_list'


          DESCRIPTION:   Embedded sublists represent one way of inducing
               structure into data.  However, there are times when one needs
               to access the data directly without the embedded structure.
               'flatten' can be used to convert a list with embedded
               sublists into a list containing only atoms.

          NOTES:    This predicate is the solution to exercise 3.11 in
               Bratko's book.  Also, it is doubly recursive, and is thus
               very expensive computationally.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.




                                  Page - 28/46





     Edouard Lagache                             PROLOG Libraries, Release-I






     7.6  PREDICATE:     get_head/3

          SYNOPSIS:      get_head(Source_list,Number,FrontPartof_list).

          PURPOSE:       Extract the first 'Number' elements of a list.


          DESCRIPTION:   'get_head' copies the first 'Number' elements of
               the 'Source_list' to a new list.  If the 'Source_list' has
               less than 'Number' elements then the whole list is returned

          NOTES:    This predicate is particularly useful for "pruning"
               lists for display purposes.  To get access to the end of a
               list see the 'get_tail' predicate in this library.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     7.7  PREDICATE:     get_index/3

          SYNOPSIS:      get_index(Expression,List,Index_number).

          PURPOSE:       Determine the places where 'Expression' is located
                         in list.


          DESCRIPTION:   This predicate allows the locations in list where
               'Expression' is located to be mapped out for future access.
               This predicate will return the first location where
               'Expression' occurs and can be resatisfied to find other
               locations.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------





                                  Page - 29/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     7.8  PREDICATE:     get_tail/3

          SYNOPSIS:      get_tail(List,Number,Tailof_list).

          PURPOSE:       Retrieving 'Number' of elements from the tail of a
                         list.


          DESCRIPTION:   'get_tail' performs the analogous task of
               'get_head' for the end of a list.  'get_tail' returns
               'Number' elements from the tail of 'List'.  If the length of
               'List' is less than 'Number', than the whole list is
               returned.

          NOTES:    The predicate 'nthcdr' in this library is used to cut
               the list down to the desired number of elements.  Because
               'nthcdr' is used, this predicate is computationally expensive
               on long lists.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     7.9  PREDICATE:     nthcdr/3

          SYNOPSIS:      nthcdr(List,Number,Result_list).

          PURPOSE:       Remove the 'Number' elements from the front of a
                         list.


          DESCRIPTION:   'nthcdr' returns the result of removing the first
               'Number' elements from 'List'.  In LISP this is the same as
               applying the 'cdr' function 'Number' times; thus the name:
               'nthcdr'.  This is a predicate that is better suited for
               implementing other predicates than it is for direct use.
               'nthcdr' fails if  'Number' is greater than the length of the
               list.

          NOTES:    'nthcdr' is inefficient for large values of 'Number'

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.




                                  Page - 30/46





     Edouard Lagache                             PROLOG Libraries, Release-I






     7.10 PREDICATE:     last/2

          SYNOPSIS:      last(List,Last_element).

          PURPOSE:       Retrieve the last element in a list.


          DESCRIPTION:   The 'last' function is becoming fairly standard in
               LISP function libraries, and there are a number of algorithms
               that are much more straightforward with a 'last' function.
               Quite simply, 'last' returns the last element of 'List' in
               'Last_element'.

          NOTES:    Because this predicate must remove all elements before
               the last, it is computationally expensive for large lists.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     7.11 PREDICATE:     length/2

          SYNOPSIS:      length(List,Number).

          PURPOSE:       Retrieve the number of elements (length) in the top
                         level of 'List'.


          DESCRIPTION:   The 'length' function is now a defacto standard
               predicate for PROLOG.  The code for length is supplied here
               for the sake of completeness, but it is probably unnecessary.

          NOTES:    'length' will probably be removed from these libraries
               in the near future.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------





                                  Page - 31/46





     PROLOG Libraries, Release-I                             Edouard Lagache



     7.12 PREDICATE:     listp/1

          SYNOPSIS:      listp(Expression).

          PURPOSE:       Test if 'Expression' is in fact a list.


          DESCRIPTION:   It is possible to test directly if an object is a
               list by matching it with the forms '[]' and '[_|_]'.
               However, there may be times when explicitly performing those
               matches would be impractical or obscure the meaning of the
               code.  'listp' performs precisely the matches described.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     7.13 PREDICATE:     make_assoc_list/3

          SYNOPSIS:      make_assoc_list(Name_list,Value_list,Assoc_list).

          PURPOSE:       merge two lists into a associative list for use
                         with the 'assoc' predicate.


          DESCRIPTION:   'make_assoc_list' takes two lists of items.  The
               first is expected to be a list of names.  The second is
               expected to be a list of values to be assigned to those
               names.  The two lists are merged so that names and values are
               placed in sublists in the same correspondence in the original
               lists.  For example, 'make_assoc_list([a,b,c],[1,2,3],X)'
               would result in 'X' being bound to: '[[a,1],[b,2],[c,3]]'.

          NOTES:    To access an associative list, see the 'assoc' predicate
               in this library.  Also the 'merge' function performs much the
               same task without creating the sublists (also in this
               library).

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.






                                  Page - 32/46





     Edouard Lagache                             PROLOG Libraries, Release-I





     7.14 PREDICATE:     member/2

          SYNOPSIS:      member(Expression,List).

          PURPOSE:       Determine whether 'Expression' is an element in the
                         top level of 'List'


          DESCRIPTION:   'member', like 'length', is becoming a fairly
                         standard predicate on most PROLOG systems.
                         'member' is also the standard introduction to
                         PROLOG recursion since Clocksin and Mellish (p 55).
                         The predicate returns true if 'Expression' can be
                         matched to an element in the top level of 'List'.

          NOTES:    It is likely that this predicate will also "go away" in
                    the near future.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     7.15 PREDICATE:     merge/3

          SYNOPSIS:      merge(List1,List2,Result_list).

          PURPOSE:       merge two list of equal length so that elements are
                         placed in one to one correspondence.


          DESCRIPTION:   'merge' is very similar to 'make_assoc_list'.  The
               only difference is that 'merge' does not wrap pairs of
               elements in sublists.  Instead, 'merge' takes one element
               from each list and puts them next to each other in the
               'Result_list'.  For example, 'merge([a,b,c],[1,2,3],X)' would
               result in 'X' being bound to: '[a,1,b,2,c,3]'.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.





                                  Page - 33/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     7.16 PREDICATE:     nthelem/3

          SYNOPSIS:      nthelem(List,Index_number,Item).

          PURPOSE:       Retrieve 'Item' at location 'Index_number' in
                         'List'.


          DESCRIPTION:   'nthelem' allows for the retrieving of elements in
               list based on their location in the list.  'nthelem' "cdrs"
               down the list 'Index_number' of times, and then returns the
               element at the head of the list.  For example,
               'nthelem([a,b,c,d,e,f],4,X)' will bind the value of 'd' to
               'X'.

          NOTES:    'nthelem' performs the inverse operation of 'get_index'.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     7.17 PREDICATE:     quicksort/2

          SYNOPSIS:      quicksort(Unsorted_list,Sorted_list)

          PURPOSE:       Sort a list of numbers into ascending order.


          DESCRIPTION:   This is Clocksin and Mellish's implementation of
               quicksort (p 157).  While the predicate is rather complex,
               the execution time is quite reasonable since the number of
               recursive calls increases quite slowly for larger lists.

          NOTES:    To reverse sort order, first sort and then use the
               'reverse' predicate, or use 'quicksort/3' (also in this
               library). 'quicksort/2' calls the 'quisort1/3' predicate to
               perform the sort.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------




                                  Page - 34/46





     Edouard Lagache                             PROLOG Libraries, Release-I




     7.18 PREDICATE:     quicksort/3

          SYNOPSIS:      quicksort(Unsorted_list,Predicate,Sorted_list).

          PURPOSE:       Sort element of 'Unsorted_list' into order based on
                         comparison predicate 'Predicate'.


          DESCRIPTION:   'quicksort/3' is the natural extension of
               'quicksort/2'.  'quicksort/3' executes exactly the same
               algorithm as 'quicksort/2' except that 'Predicate' is used to
               make the comparisons.  For example if the following clause
               are added to the database: 'order(A,B) :- atom(A).', then
               quicksort([a,1,b,2],order,X) would bound 'X' to '[2,1,a,b]'.

          NOTES:    'quicksort/3' calls the 'quisort2/4' predicate to
               perform the sort.  The predicate 'split2/4' is used to
               partition the list.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     7.19 PREDICATE:     reverse/2

          SYNOPSIS:      reverse(Source_list,Reversed_list).

          PURPOSE:       Reverse the elements in the list.


          DESCRIPTION:   Many algorithms can be implemented easily if it is
               possible to reverse the order of elements in a list.
               'reverse' performs this service in a reasonably efficient
               manner.

          NOTES:    This code is based on Clocksin and Mellish p 150.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------





                                  Page - 35/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     7.20 PREDICATE:     shift_l/2

          SYNOPSIS:      shift_l(Source_list, Rotated_list).

          PURPOSE:       rotate the elements of 'Source_list' so that first
                         element of the list becomes the last element.


          DESCRIPTION:   Many algorithms developed for assembly language use
               a shift operation.  This operation was carried over to LISP,
               and is now being provided for PROLOG.  'shift_l' moves all
               elements over to the left.  For example,
               'shift_l([1,2,3,4],X)' binds '[2,3,4,1]' to 'X'.

          NOTES:    See 'shift_r' also in this library.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     7.21 PREDICATE:     shift_r/2

          SYNOPSIS:      shift_r(Source_list, Rotated_list).

          PURPOSE:       Rotate the elements of 'Source_list' so that the
                         last element becomes the first element.


          DESCRIPTION:   'shift_r preforms the inverses operation of
               'shift_l'.  'shift_r' moves all elements over to the right.
               For example, 'shift_l([1,2,3,4],X)' binds '[4,1,2,3,]' to
               'X'.

          NOTES:    'shift_r' is significantly slower than 'shift_l' due to
               the difficulty of accessing the last element of a list in
               PROLOG.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------





                                  Page - 36/46





     Edouard Lagache                             PROLOG Libraries, Release-I



     7.22 PREDICATE:     subst/4

          SYNOPSIS:      subst(Expression1,Expression2,List,Result_list).

          PURPOSE:       Replacing expressions in the top level of a list.


          DESCRIPTION:   'subst' searches for elements matching
               'Expression1' in 'List' and replaces them with 'Expression2'.
               'subst/4' replaces all occurrences of 'Expression1'.

          NOTES:    This predicate is taken from Clocksin and Mellish (p
               151).  See 'subst/5' in this library.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     7.23 PREDICATE:     subst/5

          SYNOPSIS:       subst(Express1,Express2,Number,List,New_list).

          PURPOSE:       Replace a specific number of occurrences of
                         'Express1' by 'Express2'.


          DESCRIPTION:   'subst/5' is a extension of 'subst/4 in that it now
               permits the user to specify how many occurrences of
               'Express1' should be replaced by 'Express2'.  If there are
               less than 'Number' occurrences of 'Express1', then all
               occurrences are replaced.

          NOTES:    As with the pair of 'delete' predicates, there is a
               slight efficiency gain in using this form when the number of
               substitutions is known.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------







                                  Page - 37/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     7.24 PREDICATE:     sumlist/2

          SYNOPSIS:      sumlist(Number_list, SumofList_number).

          PURPOSE:       Sum up a list of numbers.


          DESCRIPTION:   'sumlist' computes the sum of all the numbers in a
               list of numbers.  The predicate will fail if it is given a
               list that contains objects that are not numbers.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.



































                                  Page - 38/46





     Edouard Lagache                             PROLOG Libraries, Release-I



     8.0  Library File: WINDOW.PRO:

          DESCRIPTION:   This library contains a set of predicates to extend
               the 'ANSI_IO.PRO' library to support Grey Haley's
               'WINDOW.SYS' windows device driver.  This device was
               developed by Texas Instruments for the TIPC and will not work
               on other computers.  'WINDOW.SYS' accepts a logical extension
               of the ANSI escape sequences, and those sequences are coded
               into the predicates listed below.

          NOTES:    'WINDOW.SYS' supports ANSI escape sequences within any
               created window.  Thus, the ANSI_IO.PRO should be used with
               this library in order obtain complete control over the
               display.  Also, the predicate 'start_window' should be used
               before any attempts to access windows is made.  Equally, the
               predicate 'end_window' should be used once window activity is
               completed.


     ----------------------------------------

     8.1  PREDICATE:     change_window/1

          SYNOPSIS:      change_window(Window_number).

          PURPOSE:       Change the active window.


          DESCRIPTION:   Only one window may be accessed at a time with the
               WINDOW.SYS driver. 'change_window' allows the user to select
               which window will be used for subsequent input/output.
               'Window_number' is the number of the window to be used.
               Those number are assigned in the order of creation.

          NOTES:

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------










                                  Page - 39/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     8.2  PREDICATE:     close_window/0

          SYNOPSIS:      close_window.

          PURPOSE:       Close the last created window.


          DESCRIPTION:   'close_window' closes the last created window, and
               removes it from the screen.

          NOTES:    Closing the last window does not deactivate the
               'WINDOW.SYS' device.  Once one is finished with windows, the
               'end_window' predicate should be called for that purpose.

          LIMITATIONS:   Windows must be closed in the reverse order of
                         their creation.  This is a limitation of
                         'WINDOW.SYS' device, and not of this predicate.

          BUGS:     No Known Bugs.


     ----------------------------------------

     8.3  PREDICATE:     end_window/0

          SYNOPSIS:      end_window.

          PURPOSE:       Deactivate the WINDOW.SYS device driver.


          DESCRIPTION:   'end_window' restores the standard 'CON' device to
               make it available for future use.  Failure to execute this
               predicate after using this device could scramble subsequent
               Input/Output.

          NOTES:    All windows should be closed before issuing this
               command.  If windows were accessed directly by using the
               '_WINDOWS' device, then this command isn't necessary.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------






                                  Page - 40/46





     Edouard Lagache                             PROLOG Libraries, Release-I




     8.4  PREDICATE:     make_window/4

          SYNOPSIS:      make_window(StRow_num,StCol_num,Tall_num,Wide_num).

          PURPOSE:       Create a window with specified dimensions.


          DESCRIPTION:   'make_window' issues the sequence to create a
               window.  The predicate requires the coordinates of the left
               uppermost corner of the window to be created
               (StRow_num,StCol_num), and the size of the rectangle in rows
               and columns (Tall_num, Wide_num).  When a window is created,
               a number is assigned to it for future access, that number is
               based on order of creation starting with 1.

          NOTES:    Up to 32 windows may be opened with WINDOW.SYS.  It is
               up to the programmer to keep track of which window has which
               number.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.


     ----------------------------------------

     8.5  PREDICATE:     start_window/0

          SYNOPSIS:      start_window.

          PURPOSE:       Initialize the WINDOW.SYS device driver.


          DESCRIPTION:   This command tells the device to take over the
               'CON' device that directs input/output to the display.  The
               escape sequence must be directed to the '_WINDOWS' device.

          NOTES:    This instruction can be skipped if all input/output is
               done through the '_WINDOWS' device instead of the standard
               PROLOG 'user' stream.

          LIMITATIONS:   None.

          BUGS:     No Known Bugs.







                                  Page - 41/46





     PROLOG Libraries, Release-I                             Edouard Lagache



     9.0  Installation procedures and Utilities.

          INTRODUCTION:  These libraries can be treated like any other valid
               PROLOG source file.  For standard PROLOG, the 'consult'
               command will load up a file of PROLOG statements.  If you
               find these libraries to be convenient you might want to set
               up your PROLOG to load in these libraries upon startup.
               Auto-initialization is very implementation dependent, but
               usually command can be put into a command file that is
               supplied at the time PROLOG is invoked.  It will be necessary
               to examine your PROLOG documentation for full details.

                    A initialization file is supplied for ADA PROLOG.  This
               file uses mechanisms unique to ADA PROLOG and thus won't run
               with other PROLOGs.  One ADA extension that is used in the
               initialization file is a "UNIX-like" symbol directory system.
               This system is intended to overcome unmanageable symbol
               tables by imposing an hierarchical structure on symbols.
               Unfortunately, ADA PROLOG doesn't support the concept of
               "public" symbols in any way, thus implementing a set of
               public access predicates is somewhat awkward.

                    Nevertheless, with some help from some simple tools it
               is possible to still get the fully benefit of the directory
               system, while minimizing its awkwardness.  Those tools are
               described in the following sections:


     ----------------------------------------























                                  Page - 42/46





     Edouard Lagache                             PROLOG Libraries, Release-I




     9.1  FILE:     LD_LIB

          SYNOPSIS:      PROLOG LD_LIB

          PURPOSE:       Load the libraries: 'ansi_io.pro', 'env_funt.pro',
                         'stddef.pro', 'stdlist.pro', and 'windows.pro' into
                         the 'system' directory of ADA PROLOG.


          DESCRIPTION:   'LD_LIB' is an initialization file for ADA PROLOG
               that puts the most popular combination of libraries into the
               'system' symbol directory and links them to the 'user'
               directory.  This is carried out in six steps: first the setup
               file initializes the PROLOG file system, and prints out an
               opening prompt, next it changes to the 'system' directory,
               and proceeds to consult the above listed files.  Once the
               symbols are loaded into 'system' they are 'export'ed to the
               'root' directory, finally 'LD_LIB' changes to the 'user'
               directory and imports the symbols from 'root' to complete the
               link.  The process does take some time, the bulk of the time
               is taken to load 800+ lines of code.  Prompts keep the user
               posted of the status of loading.

          NOTES:    The file 'LD_LIB' can serve as the skeleton for
               developing custom initialization files for ADA PROLOG.  The
               main changes that are needed are to substitute the
               appropriate filenames to consult, and to list the symbols to
               be exported and imported.  The symbols list is the same and
               should include any symbol that might be needed in the 'user'
               directory (including constants, and facts).  In general
               getting this list is rather tedious, the predicate
               'store_symbols' greatly streamlines the process by generating
               a file of symbol names.

          LIMITATIONS:   Any new subdirectories created "below" 'user' will
                         need to have symbols exported to it before the
                         libraries can be used there.

          BUGS:     No Known Bugs.


     ----------------------------------------









                                  Page - 43/46





     PROLOG Libraries, Release-I                             Edouard Lagache




     9.2  UTILITIES TO ASSIST IN IMPLEMENTING DIRECTORY SCHEMES:  In the ADA
          Symbol directory scheme, every symbol that is exported to other
          directories must be explicitly listed on an 'export' command.
          When exporting a large number of predicates, this becomes quite
          tedious.  Fortunately, it is possible to get VML PROLOG to
          generate a file with all symbols currently in the system. In order
          to facilitate that process, the predicate 'store_symbols' created:

          PREDICATE:     store_symbols/1     (File: 'LIST_SYM.PRO')

          SYNOPSIS:      store_symbols(Filename_atom).

          PURPOSE:       generate a listing of all predicates in the current
                         symbol directory and store it a file.


          PROCEDURE:     To use 'store_symbols' first invoke VML PROLOG, and
               then consult all files that are supposed to be exported.
               Next consult the file 'LIST_SYM.PRO', and run the predicate
               'store_symbols' with the filename of your choice.  This will
               create a disk file with all the symbols in the current
               directory.  Exit PROLOG, and edit the file with your text
               editor or word processor.  The following items should be
               deleted from the list: 'store_symbols', 'printall', and
               'list_sym'.  Also, any symbols that correspond to filenames
               should also be deleted.  Finally, some reformatting is
               suggested before incorporating the list into your command
               file.

          NOTES:    'store_symbols' sets up the file handling facilities for
               the 'printall' predicate.  'printall' works on the same
               general principle as the 'findall' predicate: resatisfying
               the same clause through deliberate failure.  Depending on
               your text processing capabilities, you may wish to adjust
               'printall' to output the symbols in a different format.

          LIMITATIONS:   None.

          BUGS:     'store_symbols' stores symbols related to itself.
                    Unfortunately these is not a convenient method to
                    prevent this.










                                  Page - 44/46





     Edouard Lagache                             PROLOG Libraries, Release-I



     10.0 CONCLUSION:  For various obscure reasons there is a tendency for
               people to become emotionally attached to a programming
               language to the exclusion of any other possibilities.  In the
               world of Artificial Intelligence, it seems that people either
               love or hate PROLOG with very little room in between.  This
               state of affairs is counterproductive for all concerned,
               since any successful computer language clearly offers some
               useful perspective on the types of problems it is well suited
               for; thus understanding that language offers insight into the
               problem solving process irregardless of the language used.

                    It is hoped that these libraries will encourage the
               greater use of PROLOG by all ranks of the computer science
               community.  In addition it is hoped that such libraries will
               further the process of creating more unified environments
               where the unique advantages of each programming language are
               integrated rather than pitted against each other.  One fact
               that is painfully clear is that the problems of computer
               science are not getting any easier; thus the need for even
               more powerful tools cannot be overestimated.

     Edouard Lagache,     July 30, 1987






























                                  Page - 45/46





     PROLOG Libraries, Release-I                             Edouard Lagache





                                    I N D E X

     ADA PROLOG    6, 7, 10, 12, 14,         member/2                     33
                     16, 18, 24, 42,         merge/3                      33
                              43, 44         min/3                        20
     append/3                     27         MS-DOS              4, 5, 7, 12
     assoc/3                      26         nthcdr/3                     30
     Bratko, Ivan                  5         nthelem/3                    34
     call/1                       15         oddp/1                       20
     change_window/1              39         operator              6, 13, 14
     clear_end/0                   8         PRO-LIB.DOC                   3
     clear_line/0                  8         prtstr/1                 10, 24
     clear_screen/0            9, 24         push_up/1                10, 25
     Clocksin, W.F.                5         quicksort/2              34, 35
     close_window/0               40         quicksort/3              34, 35
     Compatibility          4, 5, 15         READ.ME                       3
     concat/3                     16         reverse/2                    35
     countmatch/2                 16         run/1                        14
     CPROLOG                       4         set_attribute/1              11
     delete/3                 27, 28         shift_l/2                    36
     delete/4                 27, 28         shift_r/2                    36
     dos/0                        12         start_window/0               41
     edit/1                       13         STDDEF.PRO         3, 6, 15, 43
     end_window/0                 40         STDIO.PRO             3, 23, 24
     ENV_FUNT.PRO          6, 12, 43         STDLIST.PRO    3, 6, 21, 26, 43
     evenp/1                      17         store_symbols/1              44
     findall/3                    17         stringp/1                    21
     flatten/2                    28         subst/4                      37
     gensym/2                     18         subst/5                      37
     get_head/3                   29         sum_match/3                  22
     get_index/3                  29         sumlist/2                    38
     get_tail/3                   30         TIPC               5, 7, 11, 39
     IBM PC                        7         UNIX               4, 6, 12, 42
     Interdependencies             6         VML PROLOG     (See ADA PROLOG)
     interval/3                   19         VT100                         7
     last/2                       31         WINDOW.PRO             3, 5, 39
     ledit/1                      13         WINDOW.SYS             5, 39-41
     length/2                     31         Zadeh, L.A.                   5
     LISP      4, 18, 26, 30, 31, 36
     LIST_SYM.PRO              3, 44
     listp/1                      32
     locate_cursor/2               9
     make_assoc_list/3            32
     make_window/4                41
     max/3                        19
     Mellish, C.S.              4, 5




                                  Page - 46/46


------------------------------

End of PROLOG Digest
********************