Learn something new every day More Info... by email
Prolog is a computer programming language that is based on logic. Most computer languages are based on the steps needed to solve a problem. The Prolog language, on the other hand, is a "declarative" language which indicates the logical relationships between entities. The way to solve the problem is left to the computer. The name Prolog comes from the French PROgrammation en LOGique, that is, PROgramming LOGic.
The following is a simple Prolog program:
ancestor(F, C) :- father(F, C)
ancestor(P, Q) :- father(P, R), ancestor(R, Q)
The above program indicates truisms. If F is father of C, then F is an ancestor of C. If P is the father of some person R who is an ancestor of Q, then P is an ancestor of Q. A number of true facts are then given, such as john being the father of jim. If then a problem question is posed as to whether john is an ancestor of jeff, we get the response "Yes" as below:
?- ancestor(john, jeff).
If the ancestors of joshua are of interest, then the program displays all the ancestors as follows:
?- ancestor(A, joshua)
A = jason
A = jerry
A = jim
A = john
Note that in both the above instances, the program did not tell how to do the evaluation. For example, it did not indicate whether to start at the older person and work its way to the younger person or vice versa. Also interchanging the parts as below:
ancestor(P, Q) :- ancestor(R, Q), father(P, R)
It would make no difference to the program, as both these parts on the right side need to be true in order for the left side to be true.
The Prolog language thus focuses on the relationships, and not on how to solve the problem. During program execution, Prolog builds up a number of true statements, creating a knowledgebase. In the example above, the knowledgebase, in no particular order, would have ancestor(john, jim), ancestor(jim, jerry), ancestor(john, jerry), ancestor(jim, jason), ancestor(john, jason), and so on. This knowledgebase can continue building up as the program executes, and can be searched efficiently to get solutions. The execution can use parallel processing, simultaneous execution by multiple computers.
The Prolog language is used in a number of areas. It started off in systems geared for natural languages such as English; natural language is one of the areas of Artificial Intelligence. The Prolog language is also used in symbolic mathematics, including algebra. It is used in proving theorems, in expert systems, and in control systems, among many other applications.
One of our editors will review your suggestion and make changes if warranted. Note that depending on the number of suggestions we receive, this can take anywhere from a few hours to a few days. Thank you for helping to improve wiseGEEK!