specifies relationships among data values (this constitutes a logic program) and then poses queries to
the execution environment (usually an interactive interpreter) in order to see whether certain relationships
hold. Putting this in another way, a logic program, through explicit facts and rules, defines a base of knowledge
from which implicit knowledge can be extracted. This style of programming is popular for data base
interfaces, expert systems, and mathematical theorem provers. In this tutorial you will be introduced to
Prolog, the primary logic programming language, through the interactive SWI-Prolog system (interpreter).
You will notice that Prolog has some similarities to a functional programming language such as Hugs. A
functional program consists of a sequence of function definitions — a logic program consists of a sequence
of relation definitions. Both rely heavily on recursive definitions. The big difference is in the underlying
execution “engine” — i.e., the imperative parts of the languages. The execution engine of a functional
language evaluates an expression by converting it to an acyclic graph and then reducing the graph to a
normal form which represents the computed value. The Prolog execution environment, on the other hand,
doesn’t so much “compute” an answer, it “deduces” an answer from the relation definitions at hand. Rather
than being given an expression to evaluate, the Prolog environment is given an expression which it interprets
as a question:
For what parameter values does the expression evaluate to true?
You will see that Prolog is quite different from other programming languages you have studied. First,
Prolog has no types. In fact, the basic logic programming environment has no literal values as such. Identifiers
starting with lower-case letters denote data values (almost like values in an enumerated type) while all other
identifiers denote variables. Though the basic elements of Prolog are typeless, most implementations have
been enhanced to include character and integer values and operations. Also, Prolog has mechanisms built
in for describing tuples and lists. You will find some similarity between these structures and those provided
in Hugs.
CSCI
0 comments: on "Prolog"
Post a Comment