© Zhou Qingqing 2001
http://www.cs.toronto.edu/~zhouqq
Last modified: 2001-09-17
Read First (1 minute)
Let's begin (5 minute)
qew.cs>prolog
if you have the right to execute this program, you can enter it and you will see:| ?-
step2 >>> key in "write('Hello world!')." and press return key. Don't forget the last full stop: | ?- write('Hello world!').
Hello world!
yes
| ?-
qew.cs>Prolog interruption (h for help)?
if you press enter key now, it will show you the help message. If you press "^C" again, prolog will quit.So how about PROLOG, seems it is tender and not that difficult to use!
good(zhou). % zhou is good
man(zhou). % zhou is a man
good(X):-man(X). % for all X, if X is a man, then X is good.
Here, we pay attention to 2 points: (1) ':-' means the right part implicate the left part. (2) PROLOG regards all strings with capital initial as
| ?- consult(goodman).
% compiling file /a/11/zhouqq/goodman
* Clauses for good/1 are not together in the source file
* Approximate line: 5, file: '/a/11/zhouqq/goodman'
% goodman compiled in module user, 0.010 sec 456 bytes
yes
| ?-
'consult(
| ?- good(zhou).
yes
| ?- good(wang).
no
| ?- good(zhang).
no
So, your program works!
So far, we have learned how to enter/quit command line PROLOG environment; write/compile your first simple program and interact with it. This is the 1% of PROLOG. Now you can surf the Internet to find more about PROLOG you need!
Other links