Running SICStus Prolog

 

 

A version of Prolog by the Swedish Institute of Computer Science called SICStus Prolog is available on the HP & Linux workstations in CSEL. Programs are constructed using a text editor. SICStus Prolog is initiated with the command 'prolog'. If file 'xxx' contains a program you wish to use, then you enter the query 'consult(xxx).' --  this is referred to as “consulting” the file and all the clauses in the file are appended to your current program. You will be notified of errors.  Note that 'xxx' must not contain special characters (e.g., the pathname separator '/'); to use such names, enclose them in single quotes. As many files can be consulted as you wish. Alternatively, you may 'reconsult(xxx).' which replaces any current definitions with those in file xxx. A few basic utility predicate definitions are in our class directory.

 

After being started, Prolog prompts for a query which must be terminated with a '.', and then responds with a whole series of answers.  After each answer is reported, there is a pause -- if you enter only the "Return" key, the query is terminated; if you enter ';' followed by the "Return" key, then another answer is reported; when there are no more answers, 'no' is printed and a prompt for the next query is issued. Execution is interrupted by ^C, and Prolog is terminated by entering the end of file (^D) or query "halt.".

 

On-line documentation (html and pdf) is available in /usr/pkg/sicstus/doc or on the Web at http://www.sics.se/isl/sicstus.html. An abbreviated description of selected pre-defined predicates is as follows:

= and \= -- unification (or not), that is solving for variable values to make terms equal

== and \== -- check identical (or not) terms, no solving for variables

atom(X) -- checks if X is currently instantiated to an atom

number(X) -- checks if X is currently instantiated to a number

var(X) -- checks if X is currently uninstantiated

nonvar(X) -- checks if X is currently instantiated to a non-variable term

ground(X) -- checks if all variables are completely instantiated

is -- evaluate right-argument (term) and unify with left-argument (variable)

arithmetic operations: +, -, *, /, //, mod, plus functions abs, sqrt, exp, min, max, and others

numeric comparison: =:=, =\=, <, >, =<, >= -- evaluate expressions and compare numerically

sort(List1, List2) -- succeeds with List2 the sorted version (without duplicates) of List1

Goal1 ; Goal2 -- succeeds if either Goal1 or Goal2 succeeds

\+Goal -- negation as failure - succeeds if Goal fails, and vice-versa

findall(Term, Goal, List) -- finds all instantiations that make Goal true and creates List with each applied to Term

phrase(NonTerm, List, RemList) -- succeeds when List = a sequence derived by NonTerm concatenated with RemList

phrase(NonTerm, List -- same as phrase(NonTerm, List, [ ])

assert(Clause) -- adds Clause to the current program (predicate must be dynamic)

retract(Clause) -- the first program clause matching Clause is removed (predicate must be dynamic)

listing -- lists all clauses in current program

listing(A) -- lists all program clauses for argument A

trace -- turns on debugger in step mode

notrace -- turns off tracing

spy A -- sets spy point for predicate A

nospy A -- removes spy point A

debug -- initiates messages when spy points reached

nodebug -- disables spy points and turns off debugger

statistics -- reports resource usage