In this tutorial we just want to have a first shot at running Prolog...
likes(mary,food). likes(mary,wine). likes(john,wine). likes(john,mary).
Try to get this exactly as it is - don't add in any extra spaces or punctuation, and don't forget the full-stops: these are very important to Prolog. Also, don't use any capital letters - not even for people's names. Make sure there's at least one fully blank line at the end of the program.
Once you have typed this in, save it as intro.pl
(Prolog files usually end with ".pl", just as C files end with ".c")
GNU Prolog 1.2.18 By Daniel Diaz Copyright (C) 1999-2004 Daniel Diaz | ?-The Prolog interpreter is now running and waiting for you to type in some commands.
We've done the first two of these, so now we need to load the program into Prolog.
The program has been saved as "intro.pl", so in your Prolog window, type the following and hit the return key:
[intro].Don't forget the full-stop at the end of this!
This tells Prolog to read in the file called intro.pl - you should do this every time you change your program in the text editor. (If your program was called something else, like "other.pl", you'd type "other" instead of "intro" above).
You should now have something like the following on screen
| ?- [intro]. compiling /home/jpower/intro.pl for byte code... /home/jpower/intro.pl compiled, 5 lines read - 554 bytes written, 7 ms yes | ?-The "yes" at the end indicates that Prolog has checked your code and found no errors. If you get anything else (particularly a "no"), you should check that you have typed in the code correctly.
At any stage, you can check what Prolog has recorded by asking it for a listing:
| ?- listing. likes(mary, food). likes(mary, wine). likes(john, wine). likes(john, mary). yes | ?-
When you're finished you should leave Prolog by typing halt.
Written by James Power