Concepts of Programming Languages

(Sean Pound) #1

80 Chapter 2 Evolution of the Major Programming Languages


One common use of Prolog is as a kind of intelligent database. This appli-
cation provides a simple framework for discussing the Prolog language.
The database of a Prolog program consists of two kinds of statements: facts
and rules. The following are examples of fact statements:

mother(joanne, jake).
father(vern, joanne).

These state that joanne is the mother of jake, and vern is the father of
joanne.
An example of a rule statement is

grandparent(X, Z) :- parent(X, Y), parent(Y, Z).

This states that it can be deduced that X is the grandparent of Z if it is true
that X is the parent of Y and Y is the parent of Z, for some specific values for
the variables X, Y, and Z.
The Prolog database can be interactively queried with goal statements, an
example of which is

father(bob, darcie).

This asks if bob is the father of darcie. When such a query, or goal, is
presented to the Prolog system, it uses its resolution process to attempt to
determine the truth of the statement. If it can conclude that the goal is true, it
displays “true.” If it cannot prove it, it displays “false.”

2.13.3 Evaluation


In the 1980s, there was a relatively small group of computer scientists who
believed that logic programming provided the best hope for escaping from
the complexity of imperative languages, and also from the enormous prob-
lem of producing the large amount of reliable software that was needed.
So far, however, there are two major reasons why logic programming has
not become more widely used. First, as with some other nonimperative
approaches, programs written in logic languages thus far have proven to
be highly inefficient relative to equivalent imperative programs. Second, it
has been determined that it is an effective approach for only a few relatively
small areas of application: certain kinds of database management systems and
some areas of AI.
There is a dialect of Prolog that supports object-oriented programming—
Prolog++ (Moss, 1994). Logic programming and Prolog are described in
greater detail in Chapter 16.
Free download pdf