Go backward to Infinite data structures
Go up to Top
Go forward to How to start SML

How to start SICStus Prolog

Below is a simple demonstration of how to start SICStus Prolog, how to enter facts directly into the Prolog database, and how to pose some simple queries.

You might find the Introduction to SICStus Prolog for CPSC322 Students helpful to get you started. This document contains much more information than you need right now, but you should read the "Running Prolog" section.

For a more detailed information (more than you will need for the course, but useful if you want to learn more about SICStus Prolog) see also the on-line SICStus Prolog manual.

cs312@keats <1%> sicstus             <=== TO START, TYPE sicstus
booting, please wait...                   AT THE UNIX PROMPT
SICStus 3  #5: Thu Jul 3 12:43:45 PDT 1997
| ?- owns(john,theArtOfProlog).      <=== NOTHING HAS BEEN ASSERTED YET!
{EXISTENCE ERROR: owns(john,theArtOfProlog): procedure user:owns/2 does not exist}
| ?- [user].                         <=== ENTER SOME FACTS INTO THE
| owns(john,theArtOfProlog).              PROLOG DATABASE
| owns(john,introToML).
| owns(mary,theArtOfProlog).
| {user consulted, 0 msec 512 bytes} <=== TYPE CTRL-D TO FINISH

yes
| ?- owns(john,theArtOfProlog).      <=== NOW TRY THE QUERY AGAIN

yes
| ?- owns(john,X).                   <=== TRY IT WITH A VARIABLE

X = theArtOfProlog ? ;               <=== THE ; ASKS FOR MORE SOLUTIONS

X = introToML ? ;

no
| ?- owns(Person,Thing).             <=== TRY IT WITH TWO VARIABLES

Person = john,
Thing = theArtOfProlog ? ;

Person = john,
Thing = introToML ? ;

Person = mary,
Thing = theArtOfProlog ? ;

no
| ?-                                 <=== TYPE CTRL-D TO FINISH
cs312@keats <2%>

horsch@cs.ubc.ca

Go backward to Infinite data structures
Go up to Top
Go forward to How to start SML