Information Technology Reference
In-Depth Information
3
The Prolog Language
The previous chapter showed how a procedure called back-chaining could draw logi-
cal conclusions from atomic and conditional sentences. It was the first demonstration
of how a simple form of thinking could be seen as computation. But so far this
computation has not involved computers.
This chapter and the next explain how to write computer programs in a language
called Prolog. These programs will end up being knowledge bases like those in
chapter 2, but formulated in a new way. Queries will direct a computer to perform
back-chaining, just as was done “by hand” in the previous chapter. If nothing else,
this will confirm that thinking, as presented in this topic, really is a procedure that
can be carried out purely mechanically.
Prolog, which stands for pro gramming in log ic, is a language for writing programs
that was developed by Alain Colmerauer and colleagues. There are several dialects
of Prolog with minor notational differences. This topic uses a popular one called
SWI-Prolog. (See appendix D for details on this and other dialects of Prolog.)
Learning a programming language like Prolog is a bit like learning a foreign lan-
guage. It is painstaking and often tedious to memorize not just the new vocabulary
but all the rules and regulations of the new language.
Consider a French-speaking person learning English. There will be rules of spelling
to learn (like “use 'i' before 'e' except after 'c' ”), and many more involving grammar.
To take just one example, consider talking about the parent of a child. In French, one
chooses between the possessive adjectives son and sa depending on whether the parent
in question is male or female: sa mere (mother), son pere (father). In English, on the
other hand, one learns that the choice of possessive adjective depends on whether the
child in question is male or female: for a boy, it's his mother, his father; for a girl, it's
her mother, her father.
There is good news and bad news about learning Prolog. The good news is that
there are only a few rules to be memorized to get all the spelling and grammar of
Prolog right. A complete description of the language fits on one page (see figure 3.10).
 
 
Search WWH ::




Custom Search