home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / X_PROLOG.LZH / X_PROLOG / XPROLOG.DOC < prev   
Text File  |  1990-08-13  |  24KB  |  777 lines

  1.  
  2.  
  3.             X Prolog Vers. 2.0
  4.  
  5.     This software is copyrighted by Andreas Toenne.
  6.     It may be copied free of charge iff this copyright notice
  7.     is left at it's place.
  8.  
  9.     Andreas Toenne
  10.     Computer Science Department
  11.     University of Dortmund, W-Germany
  12.     
  13.     E-mail : 
  14.         at@unido.uucp
  15.         at@unido.bitnet
  16.         ...!seismo!unido!at
  17.         
  18.     Please note : Some mailers don't like the address at@unido
  19.     (at is an old fashion alias for @, so you might end up with
  20.      @@unido :-)
  21.     Write to toenne@unido.uucp then.
  22.  
  23.  
  24.     ***********************************************************
  25.     
  26.     Note ! This manual is just a quick hack to make Xprolog
  27.     available as fast as possible.
  28.     Sections that are missing are stated in '<' and '>'
  29.     Xprolog follows mostly the cprolog standard, thus the
  30.     Cprolog manual could be of some help to the novice user
  31.  
  32.     ***********************************************************
  33.     
  34.  
  35.     1. Getting started.
  36.     
  37.     This program was developed with the Mark Williams C-Compiler Vers. 2.0
  38.     It was designed to live on a hard disk!
  39.     To start Xprolog simply double click xprolog.ttp without arguments.
  40.     Xprolog will try to read it's default image as : C:\BIN\PBOOT
  41.     If you don't have this directory or wish to start with another
  42.     image, enter the name as an argument for Xprolog.
  43.     You may set the enviroment variable BOOTFILE as well.
  44.     
  45.     1.1 Booting XProlog
  46.     
  47.     If you start Xprolog for the very first time, you must create
  48.     your own image.
  49.     This is done by calling Xprolog with the option -b.
  50.     Make sure that the bootfile _boot is present in the current directory.
  51.     You may save the image with 'save(Imagename).' then.
  52.     
  53.     1.2 Options
  54.     
  55.     You can specify the sizes of the various data areas with the
  56.     following options. The new size must be given in bytes.
  57.     
  58.     -p<size>     prototype space
  59.     -f<size>    functor space
  60.     -r<size>    number of rules (not bytes!)
  61.     -c<size>    copystack
  62.     -s<size>    THE STACK
  63.     -t<size>    trailstack
  64.     
  65.     The builtin predicate 'statistics' shows the current sizes of
  66.     all data areas.
  67.  
  68.     1.3 General
  69.     
  70.     The enviroment variable SHELL may be set if you don't have
  71.     msh.prg    or want to specify another shell.  (cf.  'system', 'sh')
  72.     <Control>C may be pressed anytime during computation.
  73.     Xprolog performs an abort then. (cf. 'abort')
  74.     
  75.     1.4 Explanation of Data Areas
  76.     
  77.     Prototype: a term in a prolog program
  78.     Prototype space: contains all prototypes. Forms a heap.
  79.     Rule space: contains descriptors for prolog rules. (clause space)
  80.         The rule's terms are kept in the prototype space.
  81.     Functor: general descriptor for prolog terms. Contains the name, arity
  82.         optional operator definitions and a link to it's rules.
  83.         Functors are kept in an avl-tree.
  84.     Copystack: keeps copies of prototypes. Grows during unification and
  85.         shrinks only upon backtracking.
  86.     THE STACK: keeps the computation data that makes up the resolution
  87.         tree. Highly dynamic !!
  88.     Trailstack: keeps trails (references) for variables that must be
  89.         preserved for backtracking. Usually very small.
  90.  
  91.     1.5 Limitations and Default Values
  92.     
  93.     - max. 20 arguments in a term
  94.     - max. 50 variables (without anonymous) in a prototype term
  95.     - max. 15 open streams
  96.     - the reader can read terms upto 8000 bytes
  97.     - max. 256 characters in a name
  98.     - the cpu stack is 32000 bytes wide
  99.     
  100.     - default shell is 'c:\bin\msh.prg'
  101.     - default bootimage is 'c:\bin\pboot'
  102.     - default prototype space size is 30000 bytes
  103.     - default copystack size if 50000 bytes
  104.     - default STACK size is 50000 bytes
  105.     - default trailstack size is 800 trail entries
  106.     - default number of clauses is 1000
  107.     - default functor space is 30000 bytes
  108.  
  109.     2.0 Error Handling and Debugging
  110.     
  111.     2.0.1 Fatal Errors
  112.     
  113.     Fatal errors are :
  114.     - not enough memory
  115.     - prototype space overflow
  116.     - missing main goal to start the machine
  117.     - main goal has stopped
  118.     - clause space overflow
  119.     - missing error goal, iff an recoverable error happens
  120.     - functor space overflow
  121.     - bad data during boot phase
  122.     - invalid prolog image
  123.     
  124.     Fatal errors print an message and terminate Xprolog.
  125.     
  126.     2.0.2 Lesser Errors
  127.     
  128.     These are :
  129.     - STACK overflow
  130.     - Trailstack overflow
  131.     - Copystack overflow
  132.     
  133.     These errors cause an abort of the current goal. (cf. 'abort')
  134.     They are usually caused by an loop or by generally insuffient memory.
  135.     
  136.     2.0.3 Recoverable Errors
  137.     
  138.     Recoverable Errors are counted as :
  139.     1. Unknown clause.
  140.     2. IO failure.
  141.     3. Read past EOF.
  142.     4. Bad syntax.
  143.     5. Too many args/vars.
  144.     6. Bad arguments.
  145.     7. No valid expression. 
  146.     8. User break. (control)C
  147.     
  148.     Except error 1 these error are caused by builtin predicates.
  149.     They have the following meanings :
  150.     
  151.     1. The current goal refers to an unknown clause. This is normaly due
  152.        to a typo or an incomplete program.
  153.     2. Some sort of general nastiness. Watch out !!
  154.     3. If a read, get, etc. hits the end of the current input stream,
  155.        it's argument will be unified with 'end_of_file'.
  156.        Note ! This differs from other prolog implementations.
  157.        If the programs attemps to read from this stream again, error 3
  158.        is the result.
  159.     4. This error is due to bad syntax in an prolog term.
  160.        Look at the detailed error description of the reader.
  161.     5. Xprolog has hard coded limitations for the number of arguments
  162.        of a term and the number of variables in a prototype term.
  163.        See section 1.5 'Limitations and Default Values'
  164.     6. The arguments failed the parameter check for builtins.
  165.     7. The user typed <control>C
  166.  
  167.     When an recoverable error occurs, a new goal is set up.
  168.     This is 'error(NumberOfTheError, GoalThatCausedTheError)'.
  169.     The clause error should normally print a message on the screen and
  170.     fail. However it is possible to correct the error and succeed then.
  171.     (Note that error 1 should always lead to a failure)
  172.  
  173.     2.1 Debugging Predicates
  174.     
  175.     There are few of them right now.
  176.     'debug' switches tracing on.
  177.     'nodebug' switches tracing off.
  178.     'leash(Value)' sets the amount of tracing data.
  179.     The initial value after debug is switched on is 'half'.
  180.     The following leash modes exists :
  181.     - full    trace on call, retry, exit and fail
  182.     - tight    trace on call, retry and fail
  183.     - half    trace on call and retry
  184.     - loose    trace on call
  185.     - off    no trace
  186.     
  187.     < it is assumed that the reader is familiar with the procedure >
  188.     < box control flow model. cf. the prolog primer by Clocksin and >
  189.     < Mellish >
  190.  
  191.     3. Reader and Syntax
  192.     
  193.     <far too short>
  194.  
  195.     Generally the reader expects every goal and every program term
  196.     to be finished by a dot and a new line!
  197.         
  198.     To read a prolog program (not an image), you should type
  199.     'consult(filenameinsinglequotes).'
  200.     If you want to read several files you can shorten the command to
  201.     '[filename, filename, ...].'. (cf. list syntax)
  202.     The goal 'reconsult(filenameinsinglequotes)' rereads clauses.
  203.     That means it abolishes the old clauses before asserting them
  204.     from the file. (cf. 'abolish' and 'assert')
  205.     The same effect is achieved by preceeding the filename in the
  206.     short notation by a '-'.
  207.     A special file (cf. IO predicates) is 'user'. This stands for
  208.     the terminal.
  209.     
  210.     When Xprolog is in the top level loop, it reads goals from
  211.     the terminal and tries to satisfy them.
  212.     When Xprolog consultes a file, it reads terms and tries to assert
  213.     them. You can execute goals by preceeding them by ?- or :- .
  214.     The only difference between ?- and :- is, that :- generates no
  215.     answer (ie. 'no' or 'yes') and no alternatives are tried.
  216.     
  217.     3.1 Prolog Syntax
  218.     
  219.     3.1.1 Terms
  220.     
  221.     Terms are
  222.     - constants
  223.     - variables
  224.     - structures (generally known as compound terms)
  225.     
  226.     Constants are
  227.     - integers    (all natural numbers that fit in two machine words)
  228.     - atoms        (actual atoms are structures without arguments)
  229.     The name for an atom must start with a lowercase letter and may
  230.     contain any letter, digit and the '_'.
  231.     If you want to use any character, you should enclose the name in
  232.     single quotes.
  233.     < there are some special 'standalone' character which form a >
  234.     < valid name. cf. CM 'Programming in Prolog' >
  235.     
  236.     Variables must start with an uppercase letter or with an '_'.
  237.     If you need a variable only once, you may use the anonymous
  238.     variable '_'.
  239.     
  240.     Structures comprises of a functor and a sequence of terms, it's
  241.     arguments.
  242.     A functor is characterised by the name and the arity.
  243.     (Number of arguments)
  244.     The sequence of terms must be written comma seperated in round
  245.     brackets. eg. testfunctor(first, second, third).
  246.  
  247.     3.1.2 Lists
  248.     
  249.     As lists are the most used data structures in prolog, the reader
  250.     offers a simple way of writing them.
  251.     Lists are either the empty list [] or a structure with the binary
  252.     functor '.' and two arguments, the head and tail of the list.
  253.     The standart syntax for a list like
  254.     
  255.         .
  256.            / \
  257.         first .
  258.              / \
  259.          second .
  260.                 / \
  261.          third    []
  262.          
  263.     is .(first, .(second, .(third, []))).
  264.     The simpler syntax is [first, second, third].
  265.     If the tail of the above example is not the empty list, but a
  266.     random term one can write
  267.     [first, second, third | RandomTermIsTailOfTheList].
  268.     Thus the above example could be written
  269.     [first, second, third | []] as well.
  270.     
  271.     Another notation for lists is the string.
  272.     Strings are lists of integers which correspond to ASCII characters.
  273.     Strings are written in double quotes.
  274.     "Prolog" is the same as [80, 114, 111, 108, 111, 103].
  275.  
  276.     3.2 Operators
  277.  
  278.     It is possible to declare unary and binary functors as operators.
  279.     These operators are only of interest to the reader and do not add
  280.     any computational power to Xprolog.
  281.     For instance the valid prolog term +(1,2) may as well be written
  282.     as 1 + 2.
  283.     An operator comprises of the sort of operator, the preccedence
  284.     and of the atom that should be an operator.
  285.     < For a detailed description of operators see CM >
  286.  
  287.     The following operators are hard coded in Xprolog :
  288.     (List from Xprolog sources, file init.c)
  289.     { ":-", &XFXFUNCTOR, 255},
  290.     { "?-", &FXFUNCTOR, 255},
  291.     { ":-", &FXFUNCTOR, 255},
  292.     { ";", &XFYFUNCTOR, 254},
  293.     { ",", &XFYFUNCTOR, 253},
  294.     { "spy", &FXFUNCTOR, 250},
  295.     { "nospy", &FXFUNCTOR, 250},
  296.     { "\\", &FXFUNCTOR, 60},        /* a single backslash !!! */
  297.     { "not", &FXFUNCTOR, 60},
  298.     { ".", &XFYFUNCTOR, 51},
  299.     { "is", &XFXFUNCTOR, 40},
  300.     { "=..", &XFXFUNCTOR, 40},
  301.     { "=", &XFXFUNCTOR, 40},
  302.     { "\\=", &XFXFUNCTOR, 40},
  303.     { "<", &XFXFUNCTOR, 40},
  304.     { "=<", &XFXFUNCTOR, 40},
  305.     { ">=", &XFXFUNCTOR, 40},
  306.     { ">", &XFXFUNCTOR, 40},
  307.     { "==", &XFXFUNCTOR, 40},
  308.     { "\\==", &XFXFUNCTOR, 40},
  309.     { "=:=", &XFXFUNCTOR, 40},
  310.     { "=\\=", &XFXFUNCTOR, 40},
  311.     { "@<", &XFXFUNCTOR, 40},
  312.     { "@>", &XFXFUNCTOR, 40},
  313.     { "@=<", &XFXFUNCTOR, 40},
  314.     { "@>=", &XFXFUNCTOR, 40},
  315.     { "-", &FXFUNCTOR, 31},
  316.     { "-", &YFXFUNCTOR, 31},
  317.     { "+", &YFXFUNCTOR, 31},
  318.     { "/\\", &YFXFUNCTOR, 31},
  319.     { "\\/", &YFXFUNCTOR, 21},
  320.     { "*", &YFXFUNCTOR, 21},
  321.     { "/", &YFXFUNCTOR, 21},
  322.     { "mod", &XFXFUNCTOR, 11},
  323.     { "<<", &XFXFUNCTOR, 11},
  324.     { ">>", &XFXFUNCTOR, 11},
  325.  
  326.     An operator declaration may be overwritten but cannot be erased.
  327.     Operator types are : fx fy xf yf xfx xfy yfx yfy.
  328.     Operators are declared by :
  329.     'op(precedence, type, atom)'.
  330.     The precedence may be in the range 1-255. (cf. above)
  331.     
  332.     - Brackets must be seperated from an operator by a blank.
  333.     - Arguments to a structure may have a maximal precedence of 254.
  334.       If it is necessary to have higher precedences, enclose the term
  335.       in brackets.
  336.     - To use an operator as an ordinary atom, enclose it in brackets too.
  337.  
  338.     4.0 System Hooks and Hacks
  339.     
  340.     The following builtin (c defined) predicates are not intended for
  341.     use in a 'normal' prolog program but are used for interaction
  342.     and manipulation of the underlying system.
  343.     
  344.     halt.
  345.         The proper way to stop Xprolog and return to the desktop.
  346.  
  347.     abort.
  348.         Aborts the current pending goals, cleans the trail, copy
  349.         and resolutionstack and restarts the main goal.
  350.         
  351.     fileerrors. (no function)
  352.         After fileerrors was called, any error during io leads
  353.         to an error message and to an abort.
  354.         
  355.     nofilerrors. (no function)
  356.         After nofilerrorsw as called, io error lead to an failure
  357.         of the builtin predicate.
  358.         
  359.     sh.
  360.         Invokes a command shell. If the enviroment variable SHELL
  361.         is not set, the default shell will be used.
  362.         
  363.     system(atom).
  364.         Invokes the command atom through a command shell.
  365.         
  366.     statistics.
  367.         Returns some usefull statistics.
  368.         
  369.     prompt(old, new).
  370.         Unifies old and new to the old an new prompt. Usefull for
  371.         determine the current prompt or changeing the prompt.
  372.         (see _boot for an example)
  373.         
  374.     $clause(head, body, don't_touch_me)
  375.         Hook for implementing 'clause(head, body)'.
  376.         If invoked from the call port, the third argument must be
  377.         an unbound variable.
  378.         $clause tries to unify head and body with the head and body
  379.         of the first fitting clause descriptor.
  380.         The third argument is then CHANGED(literally!) to an
  381.         integer with the adress of the current clause descriptor as
  382.         it's value.
  383.         If $clause is reinvoked from the retry port, the next fitting
  384.         clause descriptor is searched and the integer is advanced.
  385.         Thus it is possible to find all clauses in the database.
  386.         If there is no further clause, the third argument is
  387.         recreated as a fresh variable.
  388.  
  389.     debug.
  390.         Switches debug mode on. Leash is set to half.
  391.         
  392.     nodebug.
  393.         Switches debug mode off.
  394.         
  395.     $functor(name, arity, don't_touch_me)
  396.         General hook. (Used in 'listing' for instance)
  397.         The third argument is used as in $clause, but holds now
  398.         the adress of the last tried functor.
  399.         $functor returns all known functors. (through backtracking)
  400.         
  401.     $goalvars(list)
  402.         Hook for the toplevel interpreter loop.
  403.         When the reader reads a prolog term, all encountered
  404.         variables and their names are stored in an internal
  405.         symbol table.
  406.         To save these variables for later purposes (prompting
  407.         the results) one should call $goalvars.
  408.         $goalvars builds a list of ',' terms that hold the variable's
  409.         name and the variable itself.
  410.         For example the term 'test(FirstVariable, _, _234)'
  411.         results in [('FirstVariable', _23), ('_234', _24)].
  412.  
  413.     $more(variable)
  414.         Hook for the toplevel interpreter loop.
  415.         $more unifies the argument with 'yes' iff there is
  416.         a backtrack log for a goal that was called after the
  417.         parents goal was called. (difficult ?)
  418.         Example: in the conjunction of goals
  419.         a, b, call(C), more(VARIABLE), d.
  420.         the VARIABLE is set to yes iff the goals a, b or the
  421.         meta goal C offers untried alternatives.
  422.         Thus $more is used to determine if the user's goal had
  423.         some alternatives.
  424.         (see _boot for a working example)
  425.  
  426.     $prompt(atom)
  427.         $prompt is used to write a prompt. It is a hack for
  428.         a programming mistake that makes Xprolog sometimes think
  429.         it has just read an empty line.
  430.         (And then it shows a new prompt which is unwanted)
  431.         < this bug will probably be removed in later versions >
  432.         
  433.     protect(list_of_structures)
  434.         All given structures (precisely their functors) are
  435.         marked as protected.
  436.         Afterwards they cannot be removed by abolish or retract.
  437.         Hint : use anonymous variables or integers as arguments.
  438.         
  439.     unprotect(list_of_structures)
  440.         Reverse the effect of protect.
  441.         
  442.     hide(list_of_structures)
  443.         All given structures are marked as hidden.
  444.         They won't be returned by $functor.
  445.         
  446.     reveal(list_of_structures)
  447.         Reverse the effects of hide.
  448.         
  449.     save(atom)
  450.         Saves the current data in the prototype space,
  451.         clause space and functorspace in a image with the given name.
  452.         Note that images between different processor types are
  453.         incompatible.
  454.         The current sizes of all data areas are saved too.
  455.         If Xprolog is started with such an image, the options are
  456.         all inoperabel but the saved area sizes are used instead.
  457.         
  458.     reboot
  459.         Restarts Xprolog without loading it again.
  460.         Usefull after the database was screwed up.
  461.         
  462.     $leash(number)
  463.         Sets the port bitmask for the tracer.
  464.         (the following lines are from Xprolog sources, prolog.h)
  465.         #define CALL_PORT     0x1
  466.         #define FAIL_PORT    0x2
  467.         #define RETRY_PORT    0x4
  468.         #define EXIT_PORT    0x8
  469.         With $leash it is possible to trace a selected set of
  470.         ports.
  471.         
  472.     reconsulting(number)
  473.         Sets the reconsulting flag to number.
  474.         If 1, reconsult mode is active, if 0 it is inactive.
  475.  
  476.     5.0 IO Predicates
  477.     
  478.     Up to 15 streams may be open at any one time.
  479.     Everytime one stream is the current input stream and another
  480.     stream the current output stream.
  481.     If no stream is opened, the users terminal acts like a file.
  482.     This is the default stream 'user'.
  483.     Filenames must be specified as in the underlying operating system.
  484.     Filenames are simple atoms, and must be quoted if necessary.
  485.     Normaly IO error cause an abort, but if 'nofileerrors' was called,
  486.     the predicate simply fails.
  487.     The end of file of the current input stream is signalled by the
  488.     atom 'end_of_file'.
  489.     
  490.     5.1 Reading Programs
  491.     
  492.     consult(filename)
  493.         Reads the clauses in the file and asserts them. (cf. sect. 3.0)
  494.  
  495.     reconsult(filename)
  496.         Like consult, except that the procedures that will be
  497.         redefined are deleted before asserting the new clauses.
  498.         
  499.     [filename|filenames]
  500.         Each specified file in the list is consulted, or reconsulted
  501.         if the filename is preceeded by a '-'.
  502.         
  503.     5.2 File Handling
  504.     
  505.     see(filename)
  506.         The file becomes the new current input stream.
  507.         If the file was not opened yet, it will be opened.
  508.         
  509.     seeing(filename)
  510.         The filename will be unified with the name of the
  511.         current input stream.
  512.         
  513.     seen
  514.         The current input stream is closed and user becomes
  515.         the new current input stream.
  516.         
  517.     tell(filename)
  518.         Opens the file (if not open) and makes it the new
  519.         current output stream.
  520.         
  521.     telling(filename)
  522.         The filename will be unified with the name of the
  523.         current output stream.
  524.         
  525.     told
  526.         The current ouput stream is closed and user
  527.         becomes the new current output stream.
  528.         
  529.     close(filename)
  530.         Closes filename.
  531.         
  532.     fileerrors
  533.         Any IO error will cause an abort.
  534.         
  535.     nofileerrors
  536.         Any IO error will just fail the predicate.
  537.         
  538.     exists(filename)
  539.         Succeeds if the file exists and is writeable.
  540.         
  541.     rename(old, new)
  542.         Renames the file old to new.
  543.         If new is [], then old is removed.
  544.         
  545.     5.3 Input Output
  546.     
  547.     read(Term)
  548.         The Term (delimited by '.' and a new line) is read and
  549.         unified with Term.
  550.         
  551.     write(Term)
  552.         The Term is written to the output stream.
  553.         
  554.     writeq(Term)
  555.         The Term is written with it's names quoted where
  556.         necessary. The output of writeq can be reread by the
  557.         reader.
  558.         
  559.     display(Term)
  560.         Same as write, but only the prefix notation of terms
  561.         is used.
  562.         
  563.     print(Term)
  564.         Hook for including a pretty printer.
  565.         Variables are printed with write, but other terms
  566.         are written with 'portray(Term)'.
  567.         
  568.     nl.
  569.         A new line is started on the output stream.
  570.         
  571.     get0(char)
  572.         The next character is read and it's ASCII code is unified
  573.         with char.
  574.         Note that on a end of file on the current input stream
  575.         get0 returns not an integer but 'end_of_file'.
  576.         
  577.     get(char)
  578.         Same as get0, but only nonblank printable characters are
  579.         read. Other character are skipped.
  580.         
  581.     skip(char)
  582.         Skips characters until char is found.
  583.         
  584.     put(char)
  585.         Prints the character with the ASCII code char.
  586.         
  587.     tab(N)
  588.         Prints N spaces on the output stream.
  589.  
  590.     flush
  591.         Flushes the current output stream. Usefull
  592.         for buffered IO.
  593.         
  594.     seek(X)
  595.         Unifies the current position in the current input
  596.         stream with X.
  597.  
  598.     get_key(char, scancode)
  599.         Special predicate only for Atari ST.
  600.         Reads any character for the keyboard without echo!!
  601.         Returns the ASCII code in char and the scancode.
  602.         The scancode is the position information from the
  603.         keyboard. (see your copy of the Atari ST internals)
  604.  
  605.     6.0 Arithmetic
  606.     
  607.     Note that Xprolog has only integers and not floats as in
  608.     Cprolog.
  609.     
  610.     Arithmetic is performed by builtins which take arithmetic
  611.     expressions as arguments.
  612.     Valid arithmetic expresssions are (when x and y are expressions) 
  613.     
  614.     x+y        addition
  615.     x-y        subtraction
  616.     x*y        multiplication
  617.     x/y        integer division
  618.     x mod y     x modulo y
  619.     - x        minus
  620.     x /\ y        bitwise conjunction
  621.     x \/ y        bitwise disjunction
  622.     x << y        bitwise leftshift of x by y bits
  623.     x >> y        bitwise rightshift
  624.     \x        bitwise negation
  625.     cputime        number of milliseconds since Xprolog started
  626.     heapused    used space in the prototype space in bytes
  627.     [character]    the ASCCI code of the character
  628.     any Number
  629.     
  630.     Builtin predicates that evaluate expressions are
  631.     
  632.     Z is X
  633.         X is evaluated and Z is unified with the result.
  634.         
  635.     X =:= Y
  636.         The values of X and Y are equal.
  637.         
  638.     X =\= Y
  639.         The values of X and Y are not equal.
  640.         
  641.     X < Y
  642.         The value of X is less the value of Y.
  643.         
  644.     X > Y
  645.     
  646.     X =< Y
  647.     
  648.     X >= Y
  649.  
  650.     7.0 Convenience and Control
  651.     
  652.     P , Q
  653.         P and Q.
  654.         
  655.     P ; Q
  656.         P or Q.
  657.         
  658.     true.
  659.         Always succeeds.
  660.         
  661.     fail.
  662.         Never succeeds.
  663.         
  664.     X = Y
  665.         X is unified with Y. Defined as 'X=Y.'
  666.         
  667.     !
  668.         The cut. Discard all pending choices since the parent
  669.         goal was startet.
  670.         
  671.     repeat
  672.         Has infinite choices.
  673.         Defined as if by :
  674.         repeat.
  675.         repeat :- repeat.
  676.  
  677.     8.0 Meta Logic
  678.     
  679.     var(X)
  680.         X is a variable.
  681.         
  682.     nonvar(X)
  683.         X is not a variable.
  684.     
  685.     atom(X)
  686.         X is an atom.
  687.         
  688.     integer(X)
  689.         X is an integer.
  690.         
  691.     atomic(X)
  692.         X is an atom or an integer.
  693.  
  694.     builtin(X)
  695.         X is a builtin predicate
  696.         
  697.     functor(Term, Name, Arity)
  698.         If Term is given, Name and Arity are set to the name and
  699.         arity of the Term's functor.
  700.         If Term is not given (ie. a unbound variable) a structure
  701.         is generated (with anonymous variables as arguments)
  702.         with the given name and arity.
  703.         
  704.     arg(N, Term, X)
  705.         Unifies X with the N's argument of Term.
  706.         
  707.     Term =.. List
  708.         List is a List whose head is an atom corresponding to
  709.         the functor of Term and its tail is the argument list of Term.
  710.         If Term is not given, List must be instantiated.
  711.         Examples:
  712.         product(0,N,N-1) =.. [product,0,N,N-1].
  713.         X =.. [1,a,b] will fail as 1 is no valid name.
  714.         
  715.     name(Atom, List)
  716.         If Atom is given, List will be unified with the list
  717.         of the ASCII codes of Atom's name.
  718.         If Atom is not given, it is unified with an atom whose
  719.         name is build by the list of ASCII codes.
  720.         i.e. name(prolog, "prolog").
  721.         
  722.     call(Goal)
  723.         The Goal is executed as if the Goal appeared in the
  724.         place of call(Goal). Note that the Cut ('!') is local
  725.         to the Goal.
  726.         
  727.     
  728.     9.0 Term Comparison
  729.     
  730.     X == Y
  731.         Test if X and Y are strictly equal.
  732.         
  733.     X \== Y
  734.         Test if X and Y are not strictly equal.
  735.         
  736.     X @< Y
  737.         Test if X is less than Y in the standard order.
  738.         < standard order as in Cprolog >
  739.         
  740.     X @> Y
  741.     
  742.     X @=< Y
  743.     
  744.     X @>= Y
  745.     
  746.     compare(Op, X, Y)
  747.         Aplies Op to X and Y.
  748.         Op may be '<', '>', '='.
  749.  
  750.     10.0 Database
  751.     
  752.     assert(Clause)
  753.         Same as assertz.
  754.         
  755.     asserta(Clause)
  756.         Adds the clause as the first clause of the procedure.
  757.         
  758.     assertz(Clause)
  759.         Adds the clause as the last clause of the procedure.
  760.         
  761.     clause(Head, Body)
  762.         Head must be bound to a structure.
  763.         The Database is searched for a matching clause.
  764.         Body is the unified with the body of the found clause.
  765.         If we found a fact, Body will be unified with 'true'.
  766.         Clause may be retried to get all matching clauses.
  767.         
  768.     retract(Head)
  769.         The first matching clause is remove from the database.
  770.         
  771.     abolish(Name, Arity)
  772.         Removes all clauses whose name is Name and arity is Arity.
  773.         
  774.     !! Note !! Currently no check is made to prevent a program
  775.     from retracting itself. Clauses are removed immediately.
  776.     This may result even in a crash of Xprolog !!!!
  777.