Getting started with Prolog
© 2004-2013 Jean-Marc Vanel - e-mail: Send your comments - My home page
Last update
TOC
There are numerous tutorials on Prolog on the Web, but they forget to tell
indispensable howtos .
To start a Prolog interpreter on Linux (or cygwin ) enter;
swipl # for SWI-Prolog yap # for YaP gprolog # for GNU Prolog
To enter rules from the command line, type this :
[user].
This puts you in a mode where you can enter facts and rules. Otherwise you
get this kind of message:
<>?- idiot(me).
ERROR: (user://2:121):
Undefined procedure: idiot/1
You can then enter facts, e.g. :
father(me,sarah).
Or rules, e.g. :
father(X,Y) :- male(X), parent(X,Y).
After having entered the knowledge, type CONTROL-D to come back to the mode where you can enter goals (questions). Then you can ask:
| ?- father(me,X). X = sarah yes
To quit:
halt.
Create a file father.pl containing what we entered in the "enter facts and rules" mode. Then you can load this file under Prolog by typing this:
[father].
You can then enter goals like before.
This will start a Prolog editor on a new file, with realtime syntax highlight and check :
edit(file('father.pl')).
Paste this in the Prolog editor :
% facts: male('Nat King Cole'). parent( 'Nat King Cole', 'Nathalie Cole'). father(me,sarah). % rules : father(X,Y) :- male(X), parent(X,Y).
Then select and click Compile / Compile buffer .
You can then ask queries in the command-line window :
?- father(X, Y). X = me, Y = sarah
Then type a semicolon (;) to get the next solution:
X = 'Nat King Cole', Y = 'Nathalie Cole'. ?-
A dot (.) is printed, as it is the last solution, and the prompt re-appears.
The official prolog FAQ is a wonderful resource: http://www.logic.at/prolog/faq< wbr>/faq.html
Graph structures and paths, part of a real nice Prolog course entirely by examples, by J.R. Fisher, mentioned in:
Tutoral list in the Prolog FAQ
Learning Prolog (Univ. Saarland)
Electronic books by : Nilsson, Artificial Intelligence through Prolog by Neil C. Rowe ( can be found here and there on the Web)
P-99: Ninety-Nine Prolog Problems, by Werner Hett
The First 10 Prolog Programming Contests
code from book "the Art of Prolog"
Solutions to some exercises in "The Art of Prolog"
http://www.cetus-links.org/oo_prolog.html
http://www.cs.kuleuven.be/~toms/PlanetProlog/
- Tom Schrivers, one author of CHR
http://www.cs.kuleuven.be/~bmd/ - home page of Bart
Demoen
GNU Prolog GNU Prolog is a free implementation (under GPL) of the logic programming language PROLOG. It can compile to native machine code which is extremely fast in execution. Another feature is the included constraint solver.
Logic Programming and Deductive Database system (Tabled Prolog) for Unix and Windows.
|
77.23% |
||
JLog is a standard Prolog interpreter written in Java, so it runs almost anywhere. It is quite fast, and perfectly suited for educational purposes. It includes built-in source editor, query panels, online help, animation primitives, and a GUI debugger |
JPL A set of Java classes and
C functions providing a bridge between Java and Prolog
jsprolog An
implementation of a Prolog inferencing
engine in browser-friendly javascript.
????
PESS - Prolog Expert System Shell The Prolog Expert System Shell (PESS) is a
software that generates ES using basically two components: Knowledge Base, used
by the ES to guide its decisions making, and Inference Machine, cable of
collection the rules and generating new facts.
The Datalog Educational System (DES) is a basic deductive database with Datalog as a query language developed for education. It can be used from most common Prolog interpreters and from executables (Windows and Unix/Linux). |
39.70% |
||
Prolog+CG is a Java implementation of Prolog with extensions implementing a subset of the Conceptual Graph (CG) theory of John Sowa. CGs are first-class datatypes on a par with terms. Object oriented extensions are also included. |
39.49% |
||
A Python extension embedding SWI-Prolog. |
18.45% |
||
Oopl (rhymes with "scruple") is an object-oriented extension for Prolog. This kernel now lets you write Prolog programs making use of all the advantages of working with classes, instances, attributes and service-like predicates. |