Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Prolog evolved out of research at the University of Aix-Marseille back in the late 60's
and early 70's. Alain Colmerauer and Phillipe Roussel, both of University of Aix-
Marseille, colaborated with Robert Kowalski of the University of Edinburgh to create the
underlying design of Prolog as we know it today. Kowalski contributed the theoretical
framework on which Prolog is founded while Colmerauer's research at that time
provided means to formalize the Prolog language.
1972 is referred to by most sources as the birthdate of Prolog. Since its birth it has
branched off in many different dialects. Two of the main dialects of Prolog stem from the
two Universities of its origin: Edinburgh and Aix-Marseille. At this time the first Prolog
interpreter was built by Roussel. The first Prolog compiler was credited to David
Warren, an expert on Artificial Intelligence at the University of Edinburgh.
To this day Prolog has grown in use throughout North America and Europe. Prolog was
used heavily in the European Esprit programme and in Japan where it was used in
building the ICOT Fifth Generation Computer Systems Initiative. The Japanese
Government developed this project in an attempt to create intelligent computers. Prolog
was a main player in these historical computing endeavours.
Prolog became even more pervasive when Borland's Turbo Prolog was released in the
1980's. The language has continued to develop and be used by many scientists and
industry experts. Now there is even and ISO Prolog standardisation (1995) where all of
its individual parts have been defined to ensure that the core of the language remains
fixed.
Special Features
Prolog is a rich collection of data structures in the language and human reasoning, and
a powerful notation for encoding end-user applications. It has its logical and declarative
aspects, interpretive natur, compactness, and inherent modularity.
• Intelligent Systems - programs which perform useful tasks by utilizing artificaial
intelligence techniques.
• Expert Systems - intelligent systems which reproduce decision-making at the
level of a human expert.
• Natural Language Systems - which can analys and respond to statements
made in ordinary language as opposed to approved keywords or menu
selections.
• Relational Database Syst
Fields of Application
Prolog is the highest level general-purpose language widely used today. It is taught with
a strong declarative emphasis on thinking of the logical relations between objects or
entities relevant to a given problem, rather than on procedural steps necessary to solve
it. The system decides the way to solve the problem, including the sequences of
instructions that the computer must go through to solve it. It is easier to say what we
want done and leave it to the computer to do it for us. Since a major criterion in the
commercial world today is speed of performance, Prolog is an ideal prototyping
language. Its concept makes use of parallel architectures. It solves problems by
searching a knowledge base (or more correctly a database) which would be greatly
improved if several processors are made to search different parts of the database.
Prolog variables
A Prolog variable can be instantiated to any term, regardless of whether the term is a
constant, a variable or a structure. During goal execution, Prolog variables are
instantiated to terms by unification and therefore assume all the attributes of these
terms. This instantiation remains in force during goal execution and is not undone until
backtracking takes place. Any attempt to instantiate an already instantiated variable to
another value will lead to the failure of the unification and will initiate backtracking to the
last choice point. If two variables are instantiated to each other, they will be regarded as
identical in subsequent processing.
Data types
Prolog's single data type is the term. Terms are
either atoms, numbers, variables or compound terms.
Source Code
// the main program (this is a comment)
Hello:-
nl,
write('Hello world!' ).
}
repeat loop
Recursion
Recursion is a technique that must be learned as programming in Prolog depends
heavily upon it.
We have already met a recursive definition in section 2.2. Here are some more:
One of my ancestors is one of my parents or one of their ancestors.
talks_about(A,B):-
knows(A,B).
talks_about(P,R):-
knows(P,Q),
talks_about(Q,R).
Roughly translated:
You talk about someone either if you know them or you know
someone who talks about them
If you look at the AND/OR tree of the search space you can see that
• There is a subtree which is the same shape as the whole tree
reflecting the single recursive call to talks_about/2.
• The solution of a given problem depends on being able to stop
recursing at some point. Because the leftmost path down the
tree is not infinite in length it is reasonable to hope for a
solution.
using the goal
talks_about(X,Y)
If we ask for repeated solutions to this goal, we get, in the order shown:
X= bill Y= jane
X= jane Y= pat
X= jane Y= fred
X= fred Y= bill
X= bill Y= pat
and so on
The search strategy implies that Prolog keep on trying to satisfy the
subgoal knows(X,Y) until there are no more solutions to this. Prolog then finds that,
in the second clause for talks_about/2, it can satisfy the talks_about(X,Y) goal by
first finding a third party who X knows. It
satisfies knows(X,Z) with X=bill, Z=jane and then recurses looking for a solution to
the goal talks_about(jane,Z). It finds the solution by matching against the
second knows/2 clause.
The above AND/OR tree was formed by taking the top level goal and, for each clause
with the same predicate name and arity, creating an OR choice leading to subgoals
constructed from the bodies of the matched clauses. For each subgoal in a conjunction
of subgoals we create an AND choice.
Note that we have picked up certain relationships holding between the (logical)
variables but we have had to do some renaming to distinguish between attempts to
solve subgoals of the formtalks_about(A,B) recursively.
% my_for(start_value,end_value,increment,action)
my_for(V,V,_,_) :- !.
my_for(Start,End,Inc,Action) :-
End > Start,
NewValue is Start+Inc,
call(Action),
my_for(NewValue,End,Inc,Action).
For loop