Concepts of Programming Languages

(Sean Pound) #1
/* Compute the average */
average = sum / listlen;
/* Count the input values that are > average */
for (counter = 0; counter < listlen; counter++)
if (intlist[counter] > average) result++;
/* Print result */
printf("Number of values > average is:%d\n", result);
}
else
printf("Error—input list length is not legal\n");
}

2.13 Programming Based on Logic: Prolog


Simply put, logic programming is the use of a formal logic notation to commu-
nicate computational processes to a computer. Predicate calculus is the notation
used in current logic programming languages.
Programming in logic programming languages is nonprocedural. Pro-
grams in such languages do not state exactly how a result is to be computed but
rather describe the necessary form and/or characteristics of the result. What is
needed to provide this capability in logic programming languages is a concise
means of supplying the computer with both the relevant information and an
inferencing process for computing desired results. Predicate calculus supplies
the basic form of communication to the computer, and the proof method,
named resolution, developed first by Robinson (1965), supplies the inferenc-
ing technique.

2.13.1 Design Process


During the early 1970s, Alain Colmerauer and Phillippe Roussel in the Artifi-
cial Intelligence Group at the University of Aix-Marseille, together with Robert
Kowalski of the Department of Artificial Intelligence at the University of Edin-
burgh, developed the fundamental design of Prolog. The primary components
of Prolog are a method for specifying predicate calculus propositions and an
implementation of a restricted form of resolution. Both predicate calculus and
resolution are described in Chapter 16. The first Prolog interpreter was devel-
oped at Marseille in 1972. The version of the language that was implemented
is described in Roussel (1975). The name Prolog is from programming logic.

2.13.2 Language Overview


Prolog programs consist of collections of statements. Prolog has only a few
kinds of statements, but they can be complex.

2.13 Programming Based on Logic: Prolog 79
Free download pdf