


1 PROLOG

 Invoke the VAX Prolog system.  This  software  has  been  written  by
 P.Leroy at ELEC/ENST, Paris.

 Format:

   Prolog [File-spec] (...)

2 Parameters

 Specify the name of a Prolog source file.  If the /COMPILE  qualifier
 is  specified,  this file will be compiled before entering the Prolog
 interpreter.  If it is omitted, the file  will  be  consulted  before
 entering  the  interpreter.   If  you do not specify a file type, the
 default filetype PRO is assumed.

2 Qualifiers


/COMPILE
   /COMPILE

   The /COMPILE qualifier enables  use  of  the  Prolog/APE  compiler.
   When it is specified, both predicates 'compile' and 'link' are made
   available.  If a file name was given in the  Prolog  command,  this
   file will be compiled before entering the interpreter.

   If you specify /COMPILE, you cannot specify /INIT or /LOAD.

/INIT
   /INIT[=File-spec]
   /NOINIT (D)

   The  /INIT  qualifier  causes  the   Prolog   interpreter   to   be
   initialized.   The  Initializer  Commands  are  read  in  the  file
   specified in parameter.  If the parameter is  omitted,  a  standard
   initialization  file  is  used.   If  the file type is omitted, the
   default file type PRO is assumed.  The qualifiers /INIT  and  /LOAD
   mutualy exclude.

   The  /NOINIT  qualifier  starts  the  Prolog  interpreter  using  a
   knowledge base possibly specified by qualifier LOAD.

/INPUT
   /INPUT=File-spec

   The /INPUT qualifier defines  the  initial  input  stream  used  by
   Prolog.  By default, the input stream is SYS$INPUT.

/LIBRARY
   /LIBRARY=Dir-Spec

   The  /LIBRARY  qualifier  defines  the  directory  into  which  the
   Prolog/APE  compiler  will put the files created during compilation
   and link.  If this qualifier is omitted, the library is assumed  to
   be denoted by the logical name PRO$LIB.  If the specified directory
   is not a valid Prolog library, a warning will be emitted during the
   next compilation or link.  A request will then be issued to confirm
   creation or resetting of the library.

   This qualifier may also be used to define Prolog the library  whose
   image has to be executed when calling compiled predicates.

/LINK
   /LINK

   The /LINK qualifier enables use of the Prolog/APE  compiler.   When
   it  is  specified,  both  predicates  'compile' and 'link' are made
   available.  No file name may be given  in  the  Prolog  command  if
   /LINK  is  specified.   Before entering the interpreter, the object
   files contained in the Prolog library will be linked to produce  an
   executable image.

   If you specify /LINK, you cannot specify /INIT or /LOAD.

/LOAD
   /LOAD[=File-spec]

   The /LOAD qualifier defines the file  on  which  Prolog  reads  its
   initial  knowledge  base, when activated.  If the file specifier is
   omitted, or if  both  qualifier  /LOAD  and  /INIT  are  absent,  a
   standard  knowledge base is used.  If the file type is omitted, the
   default file type PKB is assumed.  The qualifiers /INIT  and  /LOAD
   mutualy exclude.

/LOG
   /LOG=[File-spec]
   /NOLOG (D)

   The /LOG qualifier defines the file on which  Prolog  echoes  every
   line it reads and copies every data it writes.  If the file type is
   omitted, the default  file  type  LOG  is  assumed.   If  the  file
   specifier is onitted, the log file name PROLOG.LOG is used.

/OUTPUT
   /OUTPUT=File-spec

   The /OUTPUT qualifier defines the initial  output  stream  used  by
   Prolog.  By default, the output stream is SYS$OUTPUT.

/SAVE
   /SAVE[=File-spec]

   The /SAVE qualifier defines the file on  which  Prolog  stores  its
   knowledge  base  when  a  'save' subcommand is issued.  If the file
   specifier is  omitted,  and  the  qualifier  /LOAD  is  present  or
   defaulted,  the  save  file  has the same file name and type as the
   loaded file, and a version  number  one  higher  than  the  highest
   existing  version  of  the file.  If the file specifier is omitted,
   and the /INIT qualifier is present, the save file has the same file
   name  as  the initialization file, the file type PKB, and a version
   number one higher than the highest existing version of the file.

/WARNINGS
   /WARNINGS
   /NOWARNINGS (D)

   The /WARNINGS qualifier enables emission of warning messages.   The
   /NOWARNINGS qualifier disables emission of warning messages.  These
   messages may be helpful when developing Prolog programs,  but  when
   using  such  programs,  they may be considered verbose.  By default
   warning messages are not displayed.
2 Built-in

3 abolish

 This goal is used to get rid of the definition of a predicate.

 Format:

   abolish(Name, Arity)

 The first argument, Name, must  be  instantiated  to  an  atom.   The
 second  argument, Arity, must be instantiated to a number.  This goal
 removes all of the clauses and recorded items for the predicate whose
 name is Name and whose number of arguments is Arity.  Afterwards, the
 predicate behaves as though it has never been defined before.

3 abort

 This goal terminates the current demonstration.

 Format:

   abort


3 arg

 This goal is  used  to  get  hold  of  a  particular  argument  of  a
 structure.

 Format:

   arg(N,Structure,Argument)

 The first argument, N, must be instantiated to an integer, specifying
 the  rank  of the argument required.  The second argument, Structure,
 must be instantiated to a structure.  The goal succeeds  if  the  Nth
 argument of Structure matches with Argument.

3 asserta

 Add a new clause at the end of the database.

 Format:

   asserta(Clause)

 The argument, Clause, must be instantiated to something  representing
 a  clause.  It must be instantiated enough so that the main predicate
 can be established.

3 assertz

 Add a new clause at the beginning of the database.

 Format:

   assertz(Clause)

 The argument, Clause, must be instantiated to something  representing
 a  clause.  It must be instantiated enough so that the main predicate
 can be established.

3 atom

 This goal succeeds if X currently stands for an atom.

 Format:

   atom(X)

3 atomic

 This goal succeeds if X currently stands for either an integer or  an
 atom.

 Format:

   atomic(X)

3 bagof

 This predicate yields the set of all solutions to the given goal.

 Format:

   bagof(Pattern, Goal, Bag)

 Pattern may be any Prolog expression.  Goal must be a predicate.  The
 list  containing  instantiations of Pattern for each demonstration of
 Goal is unified with the third argument, Bag.  This predicate doesn't
 perform ordering of the resulting list.

3 break

 Get a new invocation of the Prolog interpreter.

 Format:

   break

 This goal suspends the current computation and  returns  you  to  the
 interactive  interpreter.   You  may perform demonstrations or modify
 the database.  The next 'exit' goal will reactivate  the  interrupted
 computation.

3 call

 This goal attempts to satisfy its argument.

 Format:

   call(Goal)

 The argument, Goal, must be  instantiated  to  a  term  that  can  be
 interpreted  as  a  goal.  The goal succeeds if an attempt to satisfy
 Goal succeeds, and fails otherwise.  It is  possible  to  call  goals
 that  have  a  functor  that  is unknown at the time you type in your
 program.

3 check

 Set the "occur check" on.

 Format:

   check

 Occur check is a check performed during pattern-matching.   Since  it
 is  expensive,  it can be removed.  Initially, the occur check is not
 set.

3 chr

 Converts a character into its ASCII code and conversely.

 Format:

   chr(Char,Code)

 If the first argument, Char, is  instantiated  to  a  character,  the
 second  argument,  Code,  is  unified  with  the  ASCII code for this
 character.  If Char is an uninstantiated variable, Code  must  be  an
 integer.  Char is then unified with the character whose ASCII code is
 Code.

3 clause

 Matches the arguments with the head and body of an existing clause in
 the database.

 Format:

   clause(Head,Body)

 The first argument, Head, must be instantiated  enough  so  that  the
 main  predicate  of the clause is known.  If there are no clauses for
 the predicate, the goal just fails.  If there is more than one clause
 that matches, Prolog will pick the first one at first invocation.  At
 each attempt to resatisfy this goal, the next matching clause in  the
 database  will  be  chosen.   If  a  clause  has  no body, the second
 argument, Body, is unified with 'true'.

3 clock

 Returns the amount of CPU time used since the last call to 'clock' or
 the invocation of the interpreter.

 Format:

   clock(CPU_time)

 The argument must be an uninstantiated variable.  It  is  unified  to
 the amount of CPU used, in milliseconds.

3 compile

 Use the 'compile' predicate when you want the clauses in some file to
 be compiled into the Prolog/APE library.

 Format:

   compile(File_spec)

 This predicate is only available if one of the qualifiers /COMPILE or
 /LINK  was specified when invoking the Prolog system.  File_spec must
 be instantiated to atom giving the name of the file the  clauses  are
 to  be  taken from.  Therefore, it must be a valid RMS filename.  The
 default filetype PRO is used when none is given.  The  built-in  file
 'user' represents the terminal keyboard.

3 consult

 Use the predicate 'consult' when you want the clauses in some file to
 augment those already in the database.

 Format:

   consult [(File_spec)]

 File_spec must be instantiated to atom giving the name  of  the  file
 the  clauses are to be taken from.  Therefore, it must be a valid RMS
 filename.  The default filetype PRO is used when none is given.   The
 built-in  file  'user' represents the terminal keyboard.  If you omit
 File_spec, an attempt is made to read clauses from the file currently
 assigned to PRO$SOURCE.

3 cut

 The cut symbol (written '!') removes certain choices that the  Prolog
 system has made.

 Format:

   !

 This predicate is described in details in "Programming in Prolog", by
 W.F.  Clocksin and C.S.  Mellish, Berlin 1981.

3 dcl

 Execute a DCL command.

 Format:

   dcl [(Command)]

 The argument, Command, must be instantiated to  an  atom  giving  the
 command to be executed by DCL.  If you omit Command, a new process is
 spawned, to which you are attached.  To exit this  process,  use  the
 DCL 'logout' command.

3 debugging

 List currently active spy points.

 Format:

   debugging


3 display

 Write a term on the current output stream, ignoring operators.

 Format:

   display(Term)

 Any uninstantiated variables in the argument, Term,  are  written  as
 uniquely numbered variables beginning with an underscore (e.g.  _35).
 Sharing variables have the same number when  they  are  printed  out.
 This predicate ignores any operator declarations.

3 erase

 Erase an item from the database.

 Format:

   erase(Ref)

 The item  whose  internal  reference  is  Ref  is  removed  from  the
 database.  Any subsequent access to this item will result in an error
 message being displayed.

3 exit

 Exit the Prolog system.

 Format:

   exit

 This goal may also be used to leave an invocation of the  interpreter
 that  was  activated  by 'break'.  Notice that typing ^Z has the same
 effect as 'exit'.

3 fail

 This goal always fails.

 Format:

   fail

3 flush

 Flush output stream.

 Format:

   flush

 Writes the contents of the internal  output  buffer  on  the  current
 output stream.

3 functor

 This goal can be used either to create or to analyze a structure.

 Format:

   functor(Structure,Functor,Arity)

 If the first argument, Structure, is instantiated to  an  atom  or  a
 structure,  Functor  is  matched  with the functor and Arity with the
 number of arguments of the structure.  Note that in this context,  an
 atom  is  considered  to  be  a structure with arity 0.  If the first
 argument  is  uninstantiated,  the  two  other  arguments   must   be
 instantiated,   specifying   an   atom  and  a  number  of  arguments
 respectively.  Structure will become instantiated to a structure with
 the functor and arity provided.

3 get

 Get the next printing character on the current input stream.

 Format:

   get(Char)

 This goal succeeds if the argument, Char, can  be  matched  with  the
 next  printing  character encountered on the input stream.  Otherwise
 it fails.   Every  non-priting  character  on  the  input  stream  is
 skipped.   Non-printing characters are control-characters, space, and
 delete character.  Notice that when the end of the input line is met,
 Char  is  unified  with  'end_of_line', and when the end of the input
 stream is encountered, Char is unified with 'end_of_file'

3 get0

 Get the next character on the current input stream.

 Format:

   get0(Char)

 This goal succeeds if the argument, Char, can  be  matched  with  the
 next  character encountered on the input stream.  Otherwise it fails.
 Notice that when the end of the input line is met,  Char  is  unified
 with  'end_of_line',  and  when  the  end  of  the  input  stream  is
 encountered, Char is unified with 'end_of_file'

3 help

 Provides information about built-in predicates.

 Format:

   help [(Topic)]

 The argument, Topic, must be instantiated to an atom giving the topic
 you want information about.  If you omit Topic, you enter the general
 Prolog help.

3 if

 This goal allows conditionnal statements in Prolog.

 Format:

   X -> Y ; Z

 The three arguments, X, Y, Z, must be instantiated to  Prolog  goals.
 If  X  can  be  satisfied (only considering its first solution), Y is
 invoked, otherwise Z is tried.  Note that backtracking  can  generate
 alternative  solutions  for Y and Z (whichever is chosen), but cannot
 generate alternatives to X.

3 instance

 Get an instance of an item in the database.

 Format:

   instance(Ref,Term).

 The second argument, Term, is unified with the item in  the  database
 whose internal reference is Ref.

3 integer

 This goal succeeds if X currently stands for an integer.

 Format:

   integer(X)


3 is

 Evalute arithmetic expressions.

 Format:

   X is Expr

 The second term, Expr, must be instantiated to a structure  that  can
 be  interpreted  as an arithmetic expression.  The operators that can
 be used to make up this structure are:

     + Y    : no operation
     - Y    : unary minus
   Y + Z    : addition
   Y - Z    : subtraction
   Y * Z    : multiplication
   Y / Z    : division
   Y ** Z   : exponentiation
   Y mod Z  : integer remainder
   lcm(Y,Z) : lowest common multiple
   gcd(Y,Z) : greatest common divisor

 In these expressions, both Y and Z must be instantiated either to  an
 integer  or  to  an arithmetic expression.  The goal 'is' succeeds if
 its first argument, X, matches with the result of the  evaluation  of
 Expr.

3 length

 Get the length of a list.

 Format:

   length(List, Length)

 The first argument, List, must be instantiated to a list.  The second
 argument, Length, is matched with the number of elements in List.  If
 List is empty, its length is zero.

3 link

 Link objects stored into the Prolog/APE library.

 Format:

   link

 This predicate links the objects created into the Prolog/APE  library
 by  previous  compilations,  thus  making the predicates they contain
 callable  from  within  the  interpreter.   This  predicate  is  only
 available  if  one  of the qualifiers /COMPILE or /LINK was specified
 when invoking the Prolog system.

3 listing

 List clauses in the database.

 Format:

   listing [(A)]

 If the argument A is present, it must be  instantiated  to  an  atom.
 All  the  clauses  with the argument as predicate are written out, as
 Prolog terms, on the current output  file,  regardless  of  how  many
 arguments  their main predicate has.  If the argument is omitted, all
 clauses existing in the database are written out.

3 load

 Load the binary image of a Prolog database.

 Format:

   load [(File_spec)]

 File_spec must be instantiated to an atom giving the name of the file
 the  database is to be taken from.  Therefore, it must be a valid RMS
 filename.  The default filetype PKB is used when none is  given.   If
 you  omit  File_spec,  an  attempt is made to read data from the file
 defined by the qualifier /LOAD at invocation of the interpreter.

3 name

 This goal can be used either to find the characters for a given  atom
 or to find the atom that has some given characters.

 Format:

   name(Atom,List)

 If the first argument, Atom, is currently instantiated with an  atom,
 the  second  is  matched with the list of characters standing for its
 name.  Otherwise, Prolog uses the list to make an atom  for  Atom  to
 stand for.

3 nl

 New line.

 Format:

   nl

 Writes on the current output stream the internal output  buffer,  and
 skips a line.

3 nocheck

 Set the "occur check" off.

 Format:

   nocheck

 Occur check is a check performed during pattern-matching.   Since  it
 is  expensive,  it can be removed.  Initially, the occur check is not
 set.

3 nodebug

 Remove all spy points.

 Format:

   nodebug


3 nonvar

 This goal succeeds if its argument is not currently an uninstantiated
 variable.

 Format:

   nonvar(X)


3 nospy

 Remove spy points.

 Format:

   nospy [Arg,...]
   nospy(Name,Arity)

 The spy points are used to pay special attention to  goals  involving
 some  specific  predicates.   If no argument is given, all spy points
 are removed.  The argument(s) may have one of the following forms:

 1.  A list of structures separated by commas.  Each structure is made
     up  of an atom optionally followed by a slash and a number.  This
     stands for a predicate with the specified  atom,  and  the  arity
     given  by the number (e.g.  sort/2 stands for sort(_,_)).  If the
     slash and arity  are  omitted,  spy  point  are  removed  on  all
     predicates  with  the  atom,  however  many  arguments  are used.
     Notice that 'nospy' used this way is an  operator,  thus  doesn't
     need parentheses.

 2.  Two  arguments,  Name,  instantiated  to  an  atom,  and   Arity,
     instantiated  to  a  number.   The  spy  point  is removed on the
     predicate whose name is Name and whose  number  of  arguments  is
     Arity.


3 not

 Logical negation.

 Format:

   not(Goal)

 The argument, Goal, must be  instantiated  to  a  term  that  can  be
 interpreted  as  a  goal.  The goal succeeds if an attempt to satisfy
 Goal fails, and fails otherwise.

3 numbervars

 Bind variables of a term.

 Format:

   numbervars(Term, Nfirst, Nlast)

 The first argument,  Term,  may  be  any  Prolog  term.   The  second
 argument,  Nfirst,  must  be  instantiated  to  a  number.  Each free
 variable in Term is bound to an expression of  the  form  $var(N),  N
 being  a  number.   Sharing variables are given the same number.  The
 numbers allocated to the variables range from Nfirst to Nlast-1.  The
 last argument is matched with the computed number.

3 notrace

 Turn off exhaustive trace.

 Format:

   notrace


3 op

 Declare a new operator.

 Format:

   op(Priority,Associativity,Name)

 The first argument, Priority, must be  instantiated  to  an  integer,
 specifying  the  precedence of the operator.  The priority must be in
 the range 0 to  255,  the  highest  priority  being  0.   The  second
 argument   specifies  the  associativity  and  the  position  of  the
 operator.  It must be one the following atoms:

   fy  yf  yfx  xfy  fx  xf  xfx

 The third argument, Name, is an atom standing for  the  name  of  the
 operator to be defined.

 The following operators are implicitly defined at invocation  of  the
 interpreter:

     priority    associativity    name(s)

     255         fy               '?-'
                 xfy              ':-'    '-->'
     254         fy               'dcl'   'help'  'spy'   'nospy'
                 xfy              ';'
     253         xfy              '->'
     252         xfy              ','
     249         fy               'not'   '\+'
     51          xfy              '.'
     40          xfy              'is'    '=..'    '='    '\='    '<'
                                  '=<'    '>='     '>'    '=='    '\=='
                                  '=:='   '=\='    '@<'   '@=<'   '@>='
                                  '@>'
                 yfx              '+'     '-'      '/'    'div'   '*'
     10          xfy              'mod'   '^'
     5           fy               '+'     '-'

3 phrase

 Parses a sentence according to a Definite Clause Grammar.

 Format:

   phrase(NT,Sentence)

 The first argument, NT, must be instantiated to  a  structure  giving
 the  non-terminal  of the grammar used for parsing the sentence.  The
 second argument, Sentence, is the sentence to be  parsed,  considered
 as a list of terminals of the grammar.

3 put

 Writes a character on the current output stream.

 Format:

   put(Char)

 The argument, Char, must be instantiated to a character or a  number.
 If it is a character, this character is written on the current output
 stream.  If it is a number, the character with  this  ASCII  code  is
 written  on  the  current  output  stream,  thereby  allowing to edit
 non-printing characters.

3 read

 Reads a term on the current input stream.

 Format:

   read(Term)

 This goal read the next term form the input stream,  and  matches  it
 with  the  argument,  Term.  The term must be followed by a dot which
 does not become a part of it.  If the end  of  the  input  stream  is
 encountered, Term is unified to the atom 'end_of_file'.

3 reconsult

 Use the predicate 'reconsult' when you want the clauses in some  file
 to supersede any existing clause for the same predicate.

 Format:

   reconsult [(File_spec)]

 File_spec must be instantiated to an atom giving the name of the file
 the  clauses are to be taken from.  Therefore, it must be a valid RMS
 filename.  The default filetype PRO is used when none is given.   The
 built-in  file  'user' represents the terminal keyboard.  If you omit
 File_spec, an attempt is made to read clauses from the file currently
 assigned to PRO$SOURCE.

3 recorda

 Add a new item at the beginning of the database.

 Format:

   recorda(Key,Term,Ref)

 The first argument, Key, must be instanciated to a  structure.   Only
 the  principal  functor  of  this structure is significant.  The term
 Term is recorded in the database as the first item for the given key.
 Ref is instanciated to a internal reference for this item.

3 recorded

 Search for an item in the database.

 Format:

   recorded(Key,Term,Ref)

 The first argument, Key, must be instanciated to a  structure.   Only
 the  principal  functor  of this structure is significant.  The items
 recorded under this key are  successively  unified  with  the  second
 argument,  Term,  in  the  order  they occur in the database, until a
 match is found.  At the same time, Ref is instanciated to an internal
 reference  for  this  item.   An  attempt to resatisfy this goal will
 yield the next matching item for the given key.

3 recordz

 Add a new item at the end of the database.

 Format:

   recordz(Key,Term,Ref)

 The first argument, Key, must be instanciated to a  structure.   Only
 the  principal  functor  of  this structure is significant.  The term
 Term is recorded in the database as the last item for the given  key.
 Ref is instanciated to a internal reference for this item.

3 repeat

 The 'repeat' predicate is  provided  as  an  extra  way  to  generate
 multiple solutions through backtracking.

 Format:

   repeat

 This goal always succeeds, and is able  to  succeed  infinitely  many
 times on backtracking.

3 retract

 Remove clauses from the database.

 Format:

   retract(Clause)

 The argument, Clause, must be instantiated to something  representing
 a  clause.  It must be instantiated enough so that the main predicate
 can be established.  The first clause in the  database  that  can  be
 matched with the argument is removed.

3 save

 Saves the binary image of a Prolog database.

 Format:

   save [(File_spec)]

 File_spec must be instantiated to atom giving the name  of  the  file
 the  database is to be written to.  Therefore, it must be a valid RMS
 filename.  The default filetype PKB is used when none is  given.   If
 you  omit  File_spec,  data  is  written  to  the file defined by the
 qualifier /SAVE at invocation of the interpreter.

3 see

 Define current input stream.

 Format:

   see(File_spec)

 File_spec must be instantiated to atom giving the name of the file to
 become  the  new  input  stream.   Therefore,  it must be a valid RMS
 filename, or a logical name.

3 seeing

 Show current input stream.

 Format:

   seeing(File_spec)

 This goal succeeds if the argument, File_spec, matches with the  name
 of the current input stream, as defined by the last 'see' predicate.

3 seen

 Close current input stream.

 Format:

   seen

 This goal closes the current input stream and defines the  new  input
 stream to be the terminal keyboard, i.e.  SYS$INPUT.

3 setof

 This predicate yields the sorted set of all solutions  to  the  given
 goal.

 Format:

   setof(Pattern, Goal, Set)

 Pattern may be any Prolog expression.  Goal must be a predicate.  The
 list  containing  instantiations of Pattern for each demonstration of
 Goal is created.  This set is then sorted according to  the  standard
 ordering  of term, and duplicates are removed.  The resulting list is
 finally unified with the third argument, Set.

3 skip

 Skip over characters from the current input stream.

 Format:

   skip(Char)

 This goal skips  over  characters  from  the  input  stream  until  a
 character is encountered that matches with the argument, Char.

3 sort

 This goal sorts a list.

 Format:

   sort(List, Sorted)

 The first argument, List, must be instantiated to a Prolog list.   It
 is  sorted  according to the standard Prolog ordering, duplicates are
 removed, and the resulting list is unified with Sorted.

3 spy

 Set spy points.

 Format:

   spy [Arg,...]
   spy(Name,Arity)

 The spy points are used to pay special attention to  goals  involving
 some  specific  predicates.   If no argument is given, a spy point is
 set on every defined predicate.  The argument(s) may have one of  the
 following forms:

 1.  A list of structures separated by commas.  Each structure is made
     up  of an atom optionally followed by a slash and a number.  This
     stands for a predicate with the specified  atom,  and  the  arity
     given  by the number (e.g.  sort/2 stands for sort(_,_)).  If the
     slash and arity are omitted, spy point are set on all  predicates
     with  the  atom,  however  many  arguments are used.  Notice that
     'spy'  used  this  way  is  an  operator,   thus   doesn't   need
     parentheses.

 2.  Two  arguments,  Name,  instantiated  to  an  atom,  and   Arity,
     instantiated  to  a  number.  A spy point is set on the predicate
     whose name is Name and whose number of arguments is Arity.


3 system

 This goal indicates whether a predicate is built-in.

 Format:

   system(Pred)

 The first argument, Pred, must be instantiated to a predicate.   This
 goal succeeds if Pred denotes a built-in predicate.

3 tab

 Tabulate.

 Format:

   tab [(Number)]

 The argument, Number, must be instantiated to an integer.  A quantity
 of  Number spaces is written on the current output stream.  If Number
 is omitted, a ^I character is written on the current output stream.

3 tell

 Define current output stream.

 Format:

   tell(File_spec)

 File_spec must be instantiated to atom giving the name of the file to
 become  the  new  output  stream.   Therefore, it must be a valid RMS
 filename, or a logical name.

3 telling

 Show current output stream.

 Format:

   telling(File_spec)

 This goal succeeds if the argument, File_spec, matches with the  name
 of  the  current  output  stream,  as  defined  by  the  last  'tell'
 predicate.

3 told

 Close current output stream.

 Format:

   told

 This goal closes the current output stream and defines the new output
 stream to be the terminal keyboard, i.e.  SYS$OUTPUT.

3 trace

 Turn on exhaustive trace.

 Format:

   trace


3 true

 This goal always succeeds.

 Format:

   true


3 univ

 This goal, written '=..',  provides  an  alternative  way  to  access
 arguments of general structures.

 Format:

   X =..  List

 If X is instantiated, Prolog creates a list consisting of the functor
 of  X followed by the arguments of X, and matches it with List.  If X
 is uninstantiated, the  list  List  will  be  used  to  construct  an
 appropriate structure for X to stand for.

3 var

 This goal succeeds if its argument  is  currently  an  uninstantiated
 variable.

 Format:

   var(X)


3 version

 This goal writes out the banner of the  interpreter,  indicating  the
 release number.

 Format:

   version


3 write

 Writes a term  on  the  current  output  stream,  taking  account  of
 operators.

 Format:

   write(Term)

 Any uninstantiated variable in the argument,  Term,  are  written  as
 uniquely numbered variables beginning with an underscore (e.g.  _35).
 Sharing variables have the same number when  they  are  printed  out.
 This predicate takes account of current operator declarations.

3 general_comparison

 Compare Prolog terms.

 Format:

   X @<  Y
   X @>  Y
   X @=< Y
   X @>= Y

 These predicates define the standard ordering of Prolog  terms,  also
 used  by  'sort' and 'setof'.  X and Y may be any Prolog terms.  This
 is the standard ordering, from the smallest to the largest:

   Free variables
   Numbers
   Nil
   Lists
   Structures

 Numbers are sorted by increasing values.  Lists are ordered according
 to  their head first.  Structures are ordered according to their name
 (alphabetically), their arity, and  their  arguments,  from  left  to
 right.

3 value_comparison

 Compare numeric expressions.

 Format:

   X <  Y
   X >  Y
   X =< Y
   X >= Y

 These predicates first evaluate their arguments  the  same  way  'is'
 does.   Then  the resulting integers are compared.  The goals succeed
 if the logical assertion is true.

3 formal_equality

 These goals compare two structures without matching.

 Format:

   X ==  Y
   X \== Y

 These  predicates  represent  a  strict  equality.   They  will  only
 consider   an   uninstantiated   variable  to  be  equal  to  another
 uninstantiated variable that is already sharing with it.  So they are
 unable to instantiate variable.  Their behaviour is as follow:

 1.  The goal X == Y succeeds if X and Y are formally equals.

 2.  The goal X \== Y succeeds if X and Y are not formally equals.


3 value_equality

 These goals evaluate their arguments and then compare  the  resulting
 numbers.

 Format:

   X =:= Y
   X =\= Y

 These predicates first evaluate their arguments  the  same  way  'is'
 does.  Then the resulting integers are compared.

 1.  The goal X =:= Y succeeds  if  X  and  Y  evaluate  to  the  same
     integer.

 2.  The goal X =\= Y succeeds if X and Y do not evaluate to the  same
     integer.


3 =

 Test of matching.

 Format:

   X = Y
   X \= Y


 1.  The goal X = Y succeeds if X and Y can be matched together.

 2.  The goal X \= Y succeeds if X and Y can not be matched together.


3 ,

 The ',' operator specifies a conjunction of goals.

 Format:

   X , Y

 The goal X,Y succeeds if X succeeds and then Y succeeds.

3 ;

 The ';' operator specifies a disjunction of goals.

 Format:

   X ; Y

 If X succeeds, so does X;Y.  If  X  fails,  an  attempt  is  made  to
 satisfy Y.  If Y then fails, the entire disjunction fails.  Otherwise
 it succeeds.

2 Syntax

3 Backus-Naur-Form

 The following rules describe the grammar defining Prolog terms.   The
 metasymbol   ::=   indicates   a  production  of  the  grammar.   The
 metasymbols < and > bracketing a sentence indicate that it may appear
 zero  or more time.  Non-terminals are English words starting with an
 uppercase letter.  Other characters are terminals.  The symbol EOL is
 a terminal used to denote the end of the input line.  Characters sets
 are defined using a Pascal-like syntax.

          Question     ::= ?- Predicate < , Predicate > .
          Comment      ::= /* < Char > */
          Comment      ::= % < Char > EOL
          Clause       ::= Predicate :- Predicate < , Predicate > .
          Clause       ::= Predicate.
          Predicate    ::= Atom
          Predicate    ::= Atom ( Expression < , Expression > )
          Expression   ::= []
          Expression   ::= [ Expression < , Expression > ]
          Expression   ::= [ Expression < , Expression > | Expression ]
          Expression   ::= " < Char > "
          Expression   ::= Number
          Expression   ::= Predicate
          Expression   ::= ( Expression )
          Expression   ::= Expression Operator Expression
          Expression   ::= Operator Expression
          Expression   ::= Expression Operator
          Expression   ::= Variable
          Operator     ::= Atom

          GrammarRule  ::= GrammarHead --> .
          GrammarRule  ::= GrammarHead --> GrammarGoal < , GrammarGoal > .
          GrammarGoal  ::= [ Terminal < , Terminal > ] < , NonTerminal >
          NonTerminal  ::= { Predicate < , Predicate > }
          NonTerminal  ::= Predicate < , Predicate >
          NonTerminal  ::= { Predicate < , Predicate > } , Predicate < , Predicate >
          Terminal     ::= Atom

          Variable ::= UppercaseCharacter < LetterOrDigits >
          Atom     ::= ' Char < Char > '
          Atom     ::= LowercaseCharacter < LetterOrDigits >
          Atom     ::= ReservedCharacter
          Atom     ::= SpecialCharacter < ReservedOrSpecialCharacter >
          Number   ::= Digit < Digit >

          LetterOrDigit              ::= UppercaseCharacter
          LetterOrDigit              ::= LowercaseCharacter
          LetterOrDigit              ::= Digit
          ReservedOrSpecialCharacter ::= ReservedCharacter
          ReservedOrSpecialCharacter ::= SpecialCharacter

          UppercaseCharacter ::= [ '_' , 'A' .. 'Z' ]
          LowercaseCharacter ::= [ '$' , 'a' .. 'z' ]
          ReservedCharacter  ::= [ '.' , '!' , ';' , ',' ]
          SpecialCharacter   ::= [ '^' , '~' , '\' , '`' , '%' , '/' ,
                                   '@' , '*' , '&' , '<' , '>' , '=' ,
                                   ':' , '?' , '+' , '-' , '#' ]
3 ATOM

 An atom may be either:

 1.  A string  containing  any  graphic  character,  enclosed  between
     quotes.   A  quote  may  be  included  in  the name of an atom by
     repeating it twice.

 2.  A string starting with a either a  Dollar  sign  or  a  lowercase
     letter and containing either letters, digits or characters Dollar
     and Underscore.

 3.  A string of special characters without blank, letters or digits.

 The followings are legal Prolog atoms:

 'Don''t do it'
 $Prolog2
 hello
 /\
3 LIST

 A list is enclosed between square brakets '[' and  ']'.   It  may  be
 empty,  thus denoting the Prolog 'nil'.  It may contain any number of
 expressions separated by commas, optionnaly followed  by  a  vertical
 bar  '|'  and  an  expression.   The  leading  expressions are normal
 elements of the list.  The expression following the bar denotes every
 remaining term in the list.  The followings are legal Prolog lists:

 []
 [ Head | Tail ]
 [ A+1, A+2, A+3 | R ]
3 NUMBER

 A number is a string of digits which is not enclosed between  quotes.
 The  associated  number must be smaller than 2**31-1.  The followings
 are legal Prolog numbers:

 1789
 0
3 PREDICATE

 A predicate is an atom optionnaly followed by an argument list.   The
 argument  list  contains  a  left  parenthesis, a list of expressions
 separated by commas, and a right  parenthesis.   The  followings  are
 legal Prolog predicates:

 hello
 sin(X)
 sort(_,_)
3 STRING

 A string is a list of characters enclosed between double  quotes.   A
 double  quote  character  may be inserted in a string by repeating it
 twice.  The string has actually a Prolog list structure, so the  list
 [  a  , b ] and the string "ab" denote the same object.The followings
 are legal Prolog strings:

 "_"
 "1789"
 """"
3 VARIABLE

 A variable is a string starting  with  either  an  Underscore  or  an
 uppercase  letter, and containing only letters, digits, Underscore or
 Dollar.  The followings are legal Prolog variables:

 _
 Hello2
 X$0
2 Compiler

 The Prolog/APE compiler allows you to generate native  VAX  code  for
 your Prolog programs, instead of merely interpreting them.  This will
 improve their speed, together with the space required  to  run  them.
 Moreover,  it  makes  possible  to call Prolog programs directly from
 programs written in other languages.

 The two predicates 'compile' and 'link' are made available  when  you
 use the Prolog/APE compiler.  They allow you to compile Prolog source
 files, link them to create an executable image,  and  then  call  the
 compiled  predicates  from  within  the  interpreter  as if they were
 built-in.
3 Libraries

 The Prolog/APE compiler puts every  object  file  and  work  file  it
 creates  into  a  VMS  directory,  called  the  Prolog library.  This
 directory must either be denoted by  the  logical  name  PRO$LIB,  or
 specified  by  the /LIBRARY qualifier.  It is highly recommended that
 you do not store any of your own files into the Prolog library:  loss
 of  data or inconsistent behaviour may occur if you do.  For the same
 reason, you should never alter or destroy any of the library files.

 The Prolog library contains the following files:

 1.  'database' files used to  store  general  information  about  the
     programs you have already compiled.  These are:
     00PROLOG.APE
     00PROLOG.EXE
     00PROLOG.OBJ
     00PROLOG.OPT
     00PROLOG.PLB

 2.  'member' files created for each compiled file.  These are:
     MEMBER.APE
     MEMBER.OBJ
     MEMBER.OPT

3 Restrictions
 The Prolog/APE compiler being still under development,  there  are  a
 number  of  restrictions  you should comply with.  Be aware that, for
 the time being, the compiler and runtime  package  do  not  emit  any
 message.   Thus  you should make sure, by using the interpreter, that
 the programs you compile behave correctly.

 1.  It is not possible to backtrack on an invokation  of  a  compiled
     predicate.

 2.  The only built-in predicates that may be  called  by  a  compiled
     predicate are:
                    atom
                    atomic
                    fail
                    integer
                    is
                    nonvar
                    true
                    var   
                    !
                    =
                    =:=
                    <
                    =<
                    >=
                    >

3 Callable_Interface
 The callable interface allows you to  call  Prolog  subprograms  from
 programs  written  in  any  other VMS-supported language.  To achieve
 this, you simply have to  include  in  your  program  some  calls  to
 interface   routines,  and  then  link  your  object  file  with  the
 appropriate Prolog/APE object files.  The interface routines are used
 to create data structures passed to Prolog subprograms, to call these
 subprograms, and to retrieve the data structures created during their
 execution.   Use  of  the  callable  interface  is not recommended to
 unexperienced Prolog users.
4 PRO$CALL
 Calls a compiled Prolog subprogram.

 Format:

   PRO$CALL arity, entry_point

 Returns:

 type:  longword
 access:  write only
 mechanism:  by value

 This routines returns a condition value in r0.  This condition is odd
 if the call has succeeded, even if it has failed.

 Arguments:

 arity

 type:  longword
 access:  read only
 mechanism:  by immediate value

 The arity argument is the arity of the called predicate.

 entry_point

 type:  longword
 access:  read only
 mechanism:  by immediate value

 The entry_point argument is the value of the  symbol  whose  name  is
 made up as follow:

  o  the four characters PRO$

  o  the name of the called predicate

  o  the character .  (period)

  o  the arity of the called predicate, represented by an  hexadecimal
     digit.


 The symbol for the entry point of the  predicate  sort(_,_)  is  thus
 PRO$SORT.2

4 PRO$GET_IV
 Retrieves an instantiated variable.

 Format:

   PRO$GET_IV varnb

 Returns:

 type:  longword
 access:  write only
 mechanism:  by value

 This routines returns a condition value in r0.  This condition is odd
 if  an instantiated variable has been found, even if all instantiated
 variables have been processed.

 Arguments:

 varnb

 type:  longword
 access:  write only
 mechanism:  by reference

 The varnb argument is the address of a longword in  which  PRO$GET_IV
 stores the unique number of the next instantiated variable, if any.

4 PRO$GET_ATOM
 Attempts to read an atom from the current data structure.

 Format:

   PRO$GET_ATOM name

 Returns:

 type:  longword
 access:  write only
 mechanism:  by value

 This routines returns a condition value in r0.  This condition is odd
 if an atom has been found, even otherwise.

 Arguments:

 name

 type:  character string
 access:  write only
 mechanism:  by string descriptor

 The name argument is the address  of  a  string  descriptor  that  is
 filled by PRO$GET_ATOM to denote the name of the atom, if the current
 data is an atom.

4 PRO$GET_LIST
 Attempts to read a list from the current data structure.

 Format:

   PRO$GET_LIST

 Returns:

 type:  longword
 access:  write only
 mechanism:  by value

 This routines returns a condition value in r0.  This condition is odd
 if a list has been found, even otherwise.

4 PRO$GET_NIL
 Attempts to read an empty list (nil) from the current data structure.

 Format:

   PRO$GET_NIL

 Returns:

 type:  longword
 access:  write only
 mechanism:  by value

 This routines returns a condition value in r0.  This condition is odd
 if an empty list has been found, even otherwise.

4 PRO$GET_NUMBER
 Attempts to read a number from the current data structure.

 Format:

   PRO$GET_NUMBER value

 Returns:

 type:  longword
 access:  write only
 mechanism:  by value

 This routines returns a condition value in r0.  This condition is odd
 if a number has been found, even otherwise.

 Arguments:

 name

 type:  longword
 access:  write only
 mechanism:  by reference

 The  value  argument  is  the  address  of  a   longword   in   which
 PRO$GET_NUMBER stores the value of the number, if the current data is
 a number.

4 PRO$GET_STRUCTURE
 Attempts to read  a  structure  (predicate)  from  the  current  data
 structure.

 Format:

   PRO$GET_STRUCTURE name, arity

 Returns:

 type:  longword
 access:  write only
 mechanism:  by value

 This routines returns a condition value in r0.  This condition is odd
 if a structure has been found, even otherwise.

 Arguments:

 name

 type:  character string
 access:  write only
 mechanism:  by string descriptor

 The name argument is the address  of  a  string  descriptor  that  is
 filled  by  PRO$GET_STRUCTURE to denote the name of the structure, if
 the current data is a structure.

 arity

 type:  longword
 access:  write only
 mechanism:  by reference

 The  arity  argument  is  the  address  of  a   longword   in   which
 PRO$GET_STRUCTURE  stores  the arity of the structure, if the current
 data is a structure.

4 PRO$GET_VARIABLE
 Attempts to read an unbound variable from the current data structure.

 Format:

   PRO$GET_VARIABLE varnb

 Returns:

 type:  longword
 access:  write only
 mechanism:  by value

 This routines returns a condition value in r0.  This condition is odd
 if a variable has been found, even otherwise.

 Arguments:

 varnb

 type:  longword
 access:  write only
 mechanism:  by reference

 The  varnb  argument  is  the  address  of  a   longword   in   which
 PRO$GET_VARIABLE stores the unique number of the variable.

4 PRO$PUT_ATOM
 Puts an atom into the current data structure.

 Format:

   PRO$PUT_ATOM rank, name

 Arguments:

 rank

 type:  longword
 access:  read only
 mechanism:  by immediate value

 The rank argument is the rank of the data  structure  in  the  called
 subprogram:   the  first argument has the rank 1, the second the rank
 2, etc.

 name

 type:  character string
 access:  read only
 mechanism:  by string descriptor

 The name argument is the address of a string descriptor for the  name
 of the atom.

4 PRO$PUT_LIST
 Puts a list into the current data structure.

 Format:

   PRO$PUT_LIST rank

 Arguments:

 rank

 type:  longword
 access:  read only
 mechanism:  by immediate value

 The rank argument is the rank of the data  structure  in  the  called
 subprogram:   the  first argument has the rank 1, the second the rank
 2, etc.

4 PRO$PUT_NIL
 Puts an empty list (nil) into the current data structure.

 Format:

   PRO$PUT_NIL rank

 Arguments:

 rank

 type:  longword
 access:  read only
 mechanism:  by immediate value

 The rank argument is the rank of the data  structure  in  the  called
 subprogram:   the  first argument has the rank 1, the second the rank
 2, etc.

4 PRO$PUT_NUMBER
 Puts a number into the current data structure.

 Format:

   PRO$PUT_NUMBER rank, value

 Arguments:

 rank

 type:  longword
 access:  read only
 mechanism:  by immediate value

 The rank argument is the rank of the data  structure  in  the  called
 subprogram:   the  first argument has the rank 1, the second the rank
 2, etc.

 value

 type:  longword
 access:  read only
 mechanism:  by immediate value

 The value argument contains the integer value of the number.

4 PRO$PUT_STRUCTURE
 Puts a strcuture into the current data structure.

 Format:

   PRO$PUT_STRUCTURE rank, name, arity

 Arguments:

 rank

 type:  longword
 access:  read only
 mechanism:  by immediate value

 The rank argument is the rank of the data  structure  in  the  called
 subprogram:   the  first argument has the rank 1, the second the rank
 2, etc.

 name

 type:  character string
 access:  read only
 mechanism:  by string descriptor

 The name argument is the address of a string descriptor for the  name
 of the structure.

 arity

 type :  longword
 access:  read only
 mechanism:  by immediate value

 The arity argument contains the arity of the structure.

4 PRO$PUT_VARIABLE                                               
 Puts a variable into the current data structure.

 Format:

   PRO$PUT_VARIABLE rank, varnb

 Arguments:

 rank

 type:  longword
 access:  read only
 mechanism:  by immediate value

 The rank argument is the rank of the data  structure  in  the  called
 subprogram:   the  first argument has the rank 1, the second the rank
 2, etc.

 varnb

 type:  longword
 access:  read only
 mechanism:  by immediate value

 The  varnb  argument  contains  the  unique  number  identifying  the
 variable.  atom.

4 Example
 The following example shows the routine  calls  needed  to  call  the
 Prolog  subprogram 'fib' with arguments 10 and V, and to retrieve the
 value of V.  The example is in Pascal:

 [external(PRO$FIB.2)]procedure PROFIB;extern;

 ...

 PRO$PUT_NUMBER(1,10); (* first argument:  number 10 *)
 PRO$PUT_VARIABLE(2,21); (* second argument:  variable number 21 *)
 PRO$CALL(2,PROFIB);
 if PRO$GET_IV(VARNB) (* if V is bound, VARNB becomes 21 *)
  then
    if PRO$GET_NUMBER(VAL)
      then ...  (* if V is a number, its value is now stored in VAL *)
      else ...  (* V is not bound to a number *)
  else ...  (* V is not bound *)
4 Overview
 In order to use the callable interface, you should be  aware  of  the
 way  data  structures  are  encoded by the compiled code.  Any object
 manipulated by Prolog falls into one of the six following classes:

  o  Variable
     A variable is identified by a unique number given by the  calling
     subprogram.

  o  Atom
     An atom is characterized  by  its  name,  which  is  a  character
     string.

  o  Non-empty List

  o  Empty list
     Empty lists are called Nil in the context of the compiler.

  o  Number
     A number is characterized by its value, a 32-bit integer.

  o  Structure
     A structure (also called predicate) is characterized by its  name
     (a character string) and its arity.


 The routines whose name starts with PRO$PUT allow  you  to  build  up
 Prolog  data  structures  using these six classes of data.  The first
 argument of each of these routines is the rank of the data  structure
 in  the called subprogram:  the first argument has rank 1, the second
 has rank 2, etc.
 These routines must be  called  depth-first,  i.e.   the  sons  of  a
 structure  must  be given immediately after this structure.  The same
 holds for lists.

 The PRO$CALL routine allows you to call a Prolog  subprogram.   Since
 the  compiled  subprograms  do  not  use  the  standard  VMS  calling
 sequence, you should not attempt to call them directly.

 The routines whose name starts with PRO$GET allow you to examine  the
 value  of  the  variables  passed  by  PRO$PUT_VARIABLE.  The routine
 PRO$GET_IV must  be  called  first  to  find  the  next  instantiated
 variable and build the associated data structure.  The other routines
 may then be called to  test  the  class  of  the  current  data,  and
 possibly  retrieve  its  value.   The  data  structures  are explored
 depth-first.
4 Linking
 To link your own  program  with  code  generated  by  the  Prolog/APE
 compiler, you should perform the following operations:

  o  Compile your main program with the appropriate language processor
     so as to obtain an object file, say MAIN.OBJ

  o  Compile all the required Prolog files in a  single  library  (see
     PROLOG/COMPILE)

  o  Link  the  files  contained  in  the  Prolog/APE   library   (see
     PROLOG/LINK)

  o  Link all these object files together by typing:

     $ LINK MAIN.OBJ,SYS$PROLOG:PROLOG/LIB,PRO$LIB:00PROLOG.OPT/OPT

