Category: 

What Is Prolog Language?

Article Details
  • Written By: Archana Khambekar
  • Edited By: C. Wilborn
  • Last Modified Date: 24 October 2014
  • Copyright Protected:
    2003-2014
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
In Laos and China, deep-fried scorpion is a popular street food.  more...

November 26 ,  1789 :  Thanksgiving Day was celebrated in the US for the first time.  more...

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)
father(john, jim).
father(jim, jerry).
father(jerry, jason).
father(jerry, jeff).
father(jason, joshua).

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).
Yes

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

Ad

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.

Ad

More from Wisegeek

You might also Like

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email