Skip to main content

1988 | Buch

Prolog by Example

How to Learn, Teach and Use It

verfasst von: Helder Coelho, José Carlos Cotta

Verlag: Springer Berlin Heidelberg

Buchreihe : Symbolic Computation

insite
SUCHEN

Über dieses Buch

Prolog has a declarative style. A predicate definition includes both the input and output parameters, and it allows a programmer to define a desired result without being concerned about the detailed instructions of how it is to be computed. Such a declarative language offers a solution to the software crisis, because it is shorter and more concise, more powerful and understandable than present-day languages. Logic highlights novel aspects of programming, namely using the same program to compute a relation and its inverse, and supporting deductive retrieval of informa­ tion. This is a book about using Prolog. Its real point is the examples introduced from Chapter 3 onwards, and so a Prolog programmer does not need to read Chapters 1 and 2, which are oriented more to teachers and to students, respec­ tively. The book is recommended for introductory and advanced university courses, where students may need to remember the basics about logic program­ ming and Prolog, before starting doing. Chapters 1 and 2 were also kept for the sake of unity of the whole material. In Chapter 1 a teaching strategy is explained based on the key concepts of Pro­ log which are novel aspects of programming. Prolog is enhanced as a computer programming language used for solving problems that involve objects and the relationships between objects. This chapter provides a pedagogical tour of pre­ scriptions for the organization of Prolog programs, by pointing out the main draw­ backs novices may encounter.

Inhaltsverzeichnis

Frontmatter
Chapter 1. Teaching Prolog
Abstract
Discussion of the ways of teaching and learning Prolog is a very important matter. There are several reasons for this. Most instructors (in common with most computer scientists) have had very little experience with Prolog and there is more than one point of view to consider. In general, programming language texts rarely discuss how a language should be taught. Moreover, the discussion is far from being clarified and several tactics were adopted after Prolog was commercialized. Several projects on computer aided instruction in Prolog are in progress (one in LNEC in Lisbon) for the so-called benefit of programmers. But, it seems the intentions of the lecturers do not match the desires of students.
Helder Coelho, José Carlos Cotta
Chapter 2. One or Two Things About Prolog
Abstract
Prolog is different from most programming languages in that it does not presuppose a von Neumann architecture and does not have assignment as the basic underlying operation (Warren 1981c). The primitive unit is not an instruction, but a theorem of first order logic, called a clause. Variables inside clauses are universally quantified and may be substituted by well-formed formulas, but predicates cannot be quantified. Unlike conventional languages such as FORTRAN and PASCAL, Prolog is well suited to parallel processing machines because program evaluations can be run in any order without regard to sequence.
Helder Coelho, José Carlos Cotta
Chapter 3. Using Prolog
Abstract
In this chapter we present some simple problems regarding the representation and the manipulation of the current data structures, such as lists, sets, stacks, queues, chains, networks and trees. And, we call the attention of the reader to the power of Prolog to describe labeled combinatorial objects, such as trees. We dedicate also some problems to the manipulation of relations, such as permutation and sorting. By doing this we introduce the basic building blocks that every programmer would like to see as a built-in predicate or in some library of routines. These small programs are useful for current applications, and our purpose is to make them independent so the reader may use them. Some of the programs are too compact and therefore difficult to read. Others are also difficult to understand because they are based on recursive definitions, which in all cases cover a complex machinery. But in all cases we give straight comments to improve the readability of these programs.
Helder Coelho, José Carlos Cotta
Chapter 4. Proving with Prolog
Abstract
Theorem proving is one of those activities able to help us achieve a better understanding of how a symbolic programming language can cope with reasoning tasks. Also, it teaches us how to have in a program a useable map of specific knowledge, and how to simulate intelligent behavior.
Helder Coelho, José Carlos Cotta
Chapter 5. Doing Arithmetic with Prolog
Abstract
Prolog is not a suitable language for expressing arithmetic calculations, or number crunching, because is not efficient. However, the following exercises show that it is possible to program arithmetic expressions based upon the Prolog arithmetic built-in predicates.
Helder Coelho, José Carlos Cotta
Chapter 6. Doing Algebra with Prolog
Abstract
As Richard Hamming stated, “the purpose of computing is insight, not numbers”. Insight is obtained by evaluating a mathematical expression. As a matter of fact, relations on quantities can be made clearer by algebraic means, and abstract symbols as well as numbers can be manipulated by a computer. One reason the algebraic capabilities of the computer have not been fully exploited is the lack of simple programming languages. This chapter gives evidence of the use of Prolog for algebraic processing, enhancing how a library of mathematical knowledge can be declared. These simple problems contribute to a better understanding of how algebraic processing can reduce numerical-processing time and how mathematical methods, such as those for solving differential equations, can be included in knowledge-based programs.
Helder Coelho, José Carlos Cotta
Chapter 7. Playing with Prolog
Abstract
Computer games consist of logic, strategy and rules. And, of course, there is a need for graphics to capture the imagination. All these crucial elements are available with the Prolog systems or can be easily written.
Helder Coelho, José Carlos Cotta
Chapter 8. Searching with Prolog
Abstract
Exploring and finding alternative paths through a network or a tree structure is often necessary while solving problems. Two issues become relevant: search, focusing on the methods for exploring the structures that describe the problem domains, and control, focusing on how the problem solver selects those methods and shifts attention among its subprocesses.
Helder Coelho, José Carlos Cotta
Chapter 9. Learning with Prolog
Abstract
This chapter concerns learning problem solving, and in particular adding knowledge and clause modification. The last issue involves modifying the logic of clauses and the conditions under which the individual clauses may be applied. The method of discrimination, used in various learning systems, is adopted to modify a given clause so that it would be applicable in some contexts and fail in others. This modification process enables a system to adapt its knowledge to specific requirements.
Helder Coelho, José Carlos Cotta
Chapter 10. Modeling with Prolog
Abstract
A representation is a set of conventions for describing objects. Experience has shown that the choice of a suitable formalism is the key to turning hard problems into simple ones.
Helder Coelho, José Carlos Cotta
Chapter 11. Designing with Prolog
Abstract
The purpose of this chapter is to exhibit some representative exercises of knowledge engineering. The first exercise has to do with civil engineering, the second deals with architecture, the third with pharmacology, and the fourth with sequences of numbers. Behind all the exercises there is a combinatorial problem.
Helder Coelho, José Carlos Cotta
Chapter 12. Drawing with Prolog
Abstract
The use of knowledge brings the programmer to an understanding of concepts like feedback, recursion, state and so on. In this chapter the examples involve search through a large number of alternatives. This feature is especially well suited for problems that can be modelled as graph search ones. This is also the basis for an approach to planning and simulation models using logic programming (see Chapters 13 and 18). The purpose is also to support the programmer with graphics in order to put forward the underlying intelligent machinery and to show how programs reason.
Helder Coelho, José Carlos Cotta
Chapter 13. Planning with Prolog
Abstract
A major theme in Artificial Intelligence is the quest for methods for reasoning about hypothetical sequences of activities (actions and their effects). Such methods are called automatic problem solvers, and their tasks are to find sequences of operators (plans) transforming the initial state of the world into a final state in which the goal statement is true.
Helder Coelho, José Carlos Cotta
Chapter 14. Seeing with Prolog
Abstract
Seeing and understanding what is seen is quite suitable for deep problem solving and program organization. This chapter introduces an exercise illustrating facts about vision processing and knowledge structures that are relevant for planning.
Helder Coelho, José Carlos Cotta
Chapter 15. Engineering Grammars with Prolog
Abstract
Within this chapter we explain how to write natural language grammars expressed in clausal logic. The notion of definite clause grammars (DCG’s) is behind this as a paradigm for organizing the knowledge required in understanding, which allows efficient parsing. In some exercises syntactic and semantic knowledge are applied concurrently to fill a logical structure that contains all the information for semantic interpretation. The syntax plays a guiding role in the processing, and the logical structure describes the meaning of the corresponding sentence by assembling well-formed formulae belonging to a logical system for representing a subset of the natural language considered.
Helder Coelho, José Carlos Cotta
Chapter 16. Constructing Personal Databases with Prolog
Abstract
Answering questions is one of the tasks that may show the ability to make logical deductions. In a question-answering system, facts are represented by unit clauses, say logical formulas. Then, to answer a question from the facts, it must be proved that a formula corresponding to the answer is derivable from the formulas representing the facts.
Helder Coelho, José Carlos Cotta
Chapter 17. Text Formatting with Prolog
Abstract
This chapter illustrates the use of Prolog features for word processing. The problems were selected from the book by (Welsh; Elder 1979), an introduction to PASCAL. The idea is to apply Prolog in a rather devious application domain, in what concerns the intended capabilities of logic programming. The general aim consists in testing whether Prolog can be compared to PASCAL in a matter where this programming language is quite able. Also, another intention is involved: to check how Prolog behaves in commercial applications, too involved with file manipulation, and often related to symbolic processing. We are convinced that such exercises are rather desirable because if Prolog goes commercial diverse situations arise in the design of real programs, and some knowledge about the ways Prolog copes and interacts with other special purpose programming languages is required.
Helder Coelho, José Carlos Cotta
Chapter 18. Management with Prolog
Abstract
The business world (management information systems and financial communities) has become attracted to Artificial Intelligence on account of its new way of approaching old problems. Also, AI has started to be considered as a new tool for doing things that could not have been done before.
Helder Coelho, José Carlos Cotta
Chapter 19. Building Up with Prolog
Abstract
Why use Prolog for writing interpreters, when C is so much better? The experience built up upon the DECsystem-10 Prolog interpreter and compiler establishes evidence that both programming languages are not comparable, in particular in what concerns machine efficiency. However, the following exercises put the case for Prolog as a tool for helping designers, i.e. as an aid in the learning process.
Helder Coelho, José Carlos Cotta
Backmatter
Metadaten
Titel
Prolog by Example
verfasst von
Helder Coelho
José Carlos Cotta
Copyright-Jahr
1988
Verlag
Springer Berlin Heidelberg
Electronic ISBN
978-3-642-83213-0
Print ISBN
978-3-642-83215-4
DOI
https://doi.org/10.1007/978-3-642-83213-0