by Richard Banister
Step-by-step instructions for learning to program in Prolog
About the language
| Name: | Prolog |
| Year created: | 1972 |
| Created by: | Alain Colmerauer, Robert Kowalski |
| Paradigm: | Logical |
| Platform: | Runs on any platform that has an interpreter. Basic code should be platform-independent, so it should run the same on each interpreter across platforms. Interpreters exist for Unix-based systems, Windows systems, and Macintosh systems, among others. Also available is a Java interpreter applet. |
| Domain: | Natural language parsing, AI, expert systems |
| Advantages: | Logical paradigm |
| Disadvantages: | Logical paradigm - not terribly easy to mimic sequential design; standard is not freely available; harder to find good beginners tutorials and information online |
| Specification: | Official spec is not freely available online. Information about the spec can be found at http://pauillac.inria.fr/~deransar/prolog/docs.html |
| Grammar: | Again, the spec isn't available online. A few people have reverse-engineered the approximate grammar; it can be found at https://www.freytag.us/twiki/bin/view/Freytag/ISOStandardPrologGrammar |
Step 1. Download a Prolog Interpreter
Step 2. Writing a Program
consult('/path/filename'). in the interpreterpath is the directory on disk where your program is located, in unix-style notation
filename is the name of your fileconsult('/prolog/hello.pl').
['/prolog/hello.pl']. can be used as shorthand for the consult predicate[user].
Step 3. Write a "hello world" program
?- prompt, type write('hello world').
Step 4. Explore the possibilities
witch(X) :- burns(X), female(X). burns(X) :- wooden(X). wooden(X) :- floats(X). floats(X) :- sameweight(duck, X). female(girl). sameweight(duck,girl).
program --> evallist, eof. evallist --> evalexpr, evallist ; evalexpr. evalexpr --> ...
Learning more
Despite lacking an official site, there are a number of sources of information on Prolog online.
QuickStart Presentation
Download and view the QuickStart Prolog PowerPoint Presentation.
Back to QuickStart Languages