PROLOG FOR XLISP by M. Nilsson, P. Schachte, and R. Denney XLPROLOG is a PROLOG written in XLISP. It is currently pretty slow. The problem is mostly in prolog/resetbindings. Austin Code Works will pay $25 to the first suggestion for an extension to Xlisp that halves the speed of XLPROLOG. This file is not meant to be an introduction to PROLOG. PROGRAMMING IN PROLOG by Clocksin and Mellish is a good introductory text. This file is meant to be a reference aid to the features available in XLPROLOG. The .EXE file on the Xlisp distribution diskette has been build with the DeSmet C compiler. Due to the non-standard way the DeSmet runtime library handles setjmp and longjmp, we have included a custom version of setjmp and longjmp. 1 SYNTAX As a LISP PROLOG the syntax is a bit different from "regular" PROLOG. The regular PROLOG clause: above(X,Z) :- on(X,Y),on(Y,Z). is written like this in XLPROLOG: ((above ?x ?y)(on ?x ?y)(on ?y ?y)) Notice that variables in regular PROLOG begin with uppercase letters, while variables in XLPROLOG begin with a ?. All XLPROLOG code must be in lowercase. In examples in this file, system output will be in uppercase to distinguish it from user input. Facts in regular prolog look like: on(block1,block2). and in XLPROLOG like: ((on block1 block2)) Notice that facts are like rules with no bodies. 2 RUNNING XLPROLOG You will need files XLISP.EXE (version 1.4) and XLPROLOG.LSP. XLPROLOG is run by: C>run xlisp >(load "xlprolog.lsp") 3 MAKING ASSERTIONS To assert a rule do: >(assert '((loves ?x ?y)(man ?x)(woman ?y))) which says: all mem love all women. To assert facts do: >(assert '((man john))) >(assert '((woman mary))) which says that john is a man and mary is a woman. Facts and rules can be asserted interactively by doing: >(assert nil) ASSERT>((above ?x ?z)(on ?x ?y)(on ?y ?z)) ASSERTED. ASSERT>((on block1 block2)) ASSERTED. ASSERT>((on block2 block3)) ASSERTED. ASSERT>ok COMPLETED. > Uppercase is print from the system. Notice that the expressions are NOT quoted. The user terminates the session with "ok" or "OK". The user is left at XLISP prompt level after COMPLETED is printed. There is not currently a facility for modifying rules/facts that are asserted, but maybe this will help until an editor is implemented. Rules/facts are stored on the property list 'assertion of the predicate of the rule/fact. For example: (get 'man 'assertions) returns the list of rules/facts about "man". To clear out the set of assertions about "man" one could do: (setf (get 'man 'assertions) nil) "setf" is the XLISP function for doing property list actions, among other things. 4 PURSUING GOALS Computation in PROLOG is done by pursuing goals. The only goal pursuing mechanism currently implemented in XLPROLOG is the XLISP function "all" which has the form: (all '