Prolog
PROgramming in LOGic
Dateline: 01/20/00
Prolog is one of the most frequently used symbolic programming languages for Artificial Intelligence. It owes much of its popularity to the Japanese "Fifth-Generation Computer Systems" project, announced in 1982 with the aim of building parallel knowledge-based machines using Prolog as a kernel language. Many similar projects soon begun elsewhere, and Prolog found the way into many research and commercial institutions.
Prolog syntax is simple and similar to first order predicate logic. It is a declarative programming language that differs in many ways from more widespread procedural languages. Languages following this paradigm have their commands executed in the order necessary to achieve the solution, not the order that can be easily followed from the source code. In other words, the important aspect is the expression of what is the solution and not how to solve the problem.
Prolog consists of a set of facts (predicates), which are information about objects in the real world, and (inference) rules which are relations among these objects. Predicates and constants must start by lower-case letters, while variables must be capitalized. Predicate looks like
likes(john, ann).
On the other hand, rules have the form of
conclusion :- premises
where the :- sign means "if" and the commas between premises mean "and". There is also a special predicate, not, that can be used to negate predicates. For example:
grandparent_of(X, Z) :-
parent_of(X, Y),
parent_of(Y, Z).
parent_of(X, Y) :-
mother_of(X, Y).
parent_of(X, Y) :-
father_of(X, Y).
To make a long story short, you'll have to declare a set of facts and some generic rules to relate sets of objects. Prolog will combine given set of rules with the set of the facts in order to answer queries under the closed world assumption. This means that only the stated facts and rules represent the truth - if something is not clearly stated, we can say it is false.
As a very high-level language Prolog can be really interesting to learn for a programmer inclined towards writing AI applications (especially Natural Language Processing and similar fields). In fact, there is not any programming language called Prolog, but many variants resembling the "original" Prolog. Prolog dialect which eventually developed into the standard is called Edinburgh Prolog, as opposed to older Marseille Prolog. I suggest visiting some of the links listed below - there are lot of freeware implementations and great tutorials that will help you enter the world of logic programming.
Of course, I didn't forget Lisp, language that is older than Prolog and also widely accepted in the AI community: expect more on Lisp in the following articles. For more information on this or any other AI related topic, see what's happening at Artificial Intelligence Bulletin Board.
Other sites of interest:
- Amzi!
The Prolog language is ideally suited for implementing a variety of rule-based and other intelligent applications. The Amzi! Logic Server is the technology that allows Prolog components to be easily integrated with other applications/environments.
- Prolog and Goedel
An overview, origins, history and development of the two declarative logic programming languages, Prolog and Goedel.
- LPA
Logic Programming Associates, producers of the famous LPA Prolog that goes right back to the days of CP/M and 8-bit processors. The current implementations are 32-bit compilers for Windows (NT, 95 and 3.1) and the Macintosh, and support self-contained development environments, as well as links to C/C+, Delphi, Visual Basic, Java and other languages.
- Adventures in Prolog
Great Prolog online tutorial text.
- BinProlog
Internet oriented Prolog compiler with ability to generate C/C++ code and standalone executables.
- Kernel Prolog
Free lightweight Java based Prolog interpreter.
- Strawberry Prolog
Freeware Prolog compiler for the Windows 95/NT that supports COM and ActiveX.
- Introduction to Prolog for Mathematicians
Another good tutorial text targeted at mathematicians.
- Brain Aid Prolog
Parallel Prolog environment for Transputer systems of any size.
- IF/Prolog
An advanced Prolog engineered for use in industrial and commercial environments.
- prolog :- tutorial
Comprehensive tutorial by J.R.Fisher.
- Free/Shareware Prolog implementations
Sources for a large collection of Prolog implementations from CMU.
- ALS
Applied Logic Systems, Inc. is offering a wide range of Prolog tools.
- Logic Programming
This web page is devoted to the development of the use of logic programming and Prolog world-wide.
- Trinc-Prolog
Trinc-Prolog R3 is the latest release of Trinc-Prolog, a development tool for the programming language Prolog. Release R3 supports the complete
ISO Prolog Standard, Object Orientation, Prolog Application embedding and automated blackbox and whitebox testing by means of recording and replaying test scripts.
- Visual Prolog
Visual Prolog is a programming environment for the Prolog programming language. It contains everything needed for building large scale commercial applications including compiler, linker and a large library with bindings to a range of specialized APIs.
- Be Prolog
BeProlog is a Prolog interpreter currently in Alpha release. BeProlog intend to bring to BeOS the ability to build powerfull expert system.
- GNU Prolog
GNU Prolog is a free Prolog compiler with constraint solving over finite domains developed by Daniel Diaz. GNU Prolog accepts Prolog+constraint programs and produces native binaries (like gcc does from a C source). The obtained executable is then stand-alone.