0% found this document useful (0 votes)
36 views

Prolog

Prolog is a relational language where calls express relations between arguments, unlike functional languages where calls are mathematical functions. Prolog aims to provide a computer-executable form of mathematical logic. A Prolog program consists of facts and rules. Facts are objects and relationships expressed as predicates, like lectures(turing, 9020). Rules use ":-" to relate a head to bodies, like likes(Jaya, Food):-delicious(Food). Prolog is applied to intelligent databases, natural language understanding, expert systems, and other domains involving automated reasoning.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Prolog

Prolog is a relational language where calls express relations between arguments, unlike functional languages where calls are mathematical functions. Prolog aims to provide a computer-executable form of mathematical logic. A Prolog program consists of facts and rules. Facts are objects and relationships expressed as predicates, like lectures(turing, 9020). Rules use ":-" to relate a head to bodies, like likes(Jaya, Food):-delicious(Food). Prolog is applied to intelligent databases, natural language understanding, expert systems, and other domains involving automated reasoning.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Subject: Intelligent System Academic Year: 2018-19

Prolog

Prolog is a relational language. That is, a Prolog call may be regarded as expressing a relation
between its arguments. This can be contrasted with functional languages where a call may be
regarded as a mathematical function. Both functional and relational languages however are
considered declarative, that is they break away from the idea of a programming language as a set
of instructions to manipulate the memory of a computer (such languages are referred to as
imperative), and instead concentrate on providing a precise notation in which computation is a
form of reasoning. Prolog originates from attempts to provide a computer-executable form of
mathematical logic notation (its name comes from Programming in Logic), thus it and similar
languages are often referred to as the logic languages.
To return to the idea of relations, in a functional language we might have the function square,
which takes an integer and squares it; a call square(5) is considered as rewriting to 25, expressing
the functional relation square(5)→25. The equivalent in Prolog is a call square(5,X). Here X is a
Prolog variable. If a correct program for square has been loaded, typing square(5,X). will cause
X = 25 to be printed, indicating that X must have the value 25 for the relation square(5,X) to be
true. You need to type a carriage return after this to get the prompt for the next call (you will see
why later). A program for square consists of just the single line: square(X,Y) :- Y is X*X. This
says that X and Y are in the relationship square if Y is X*X evaluated arithmetically. Considering
declarative languages in terms of the imperative language like C, a functional language may be
considered as programming in terms of functions which return values but do not have any side-
effects. A logic language may be considered as programming in procedures which do not return
values directly (void in C terminology) and in which variable parameters are always passed by
reference (preceded by & in C terminology) though the variables can only be assigned new
values within the procedure if they were unassigned when the procedure was called.

Facts
 Properties of objects, or relationships between objects;
 "Dr Turing lectures in course 9020", is written in Prolog as:

lectures(turing, 9020). is also called a predicate

 Notice that:
o names of properties/relationships begin with lower case letters.

o the relationship name appears as the first term

o objects appear as comma-separated arguments within parentheses.

o A period "." must end a fact.

o objects also begin with lower case letters. They also can begin with digits (like
9020), and can be strings of characters enclosed in quotes (as in reads(fred, "War
and Peace")).

Department of Information Technology


Subject: Intelligent System Academic Year: 2018-19
It is very simple to convert English sentence into Prolog facts. Some examples are explained in
the following table.

English Statements Prolog Facts

Dog is barking barking(dog)

Jaya likes food if it is delicious. likes( Jaya, Food):-delicious(Food)

In the above table, the statement 'Dog is barking' is a fact, while the statement 'Jaya likes food
if it is delicious' is called rule. In this statement, variable like 'Food' has a first letter in capital,
because its value came from previous fact. The symbol ':-' is used to denote that “Jaya likes
delicious food”.
Applications of Prolog
Some applications of Prolog are:
 intelligent data base retrieval
 natural language understanding
 expert systems
 specification language
 machine learning
 robot planning
 automated reasoning
 problem solving

Department of Information Technology

You might also like