Programming in PrologOriginally published in 1981, this was the first textbook on programming in the Prolog language and is still the definitive introductory text on Prolog. Though many Prolog textbooks have been published since, this one has withstood the test of time because of its comprehensiveness, tutorial approach, and emphasis on general programming applications. Prolog has continued to attract a great deal of interest in the computer science community, and has turned out to be the basis for an important new generation of programming languages and systems for Artificial Intelligence. Since the previous edition of Programming in Prolog, the language has been standardised by the International Organization for Standardization (ISO) and this book has been updated accordingly. The authors have also introduced some new material, clarified some explanations, corrected a number of minor errors, and removed appendices about Prolog systems that are now obsolete. |
Contents
Tutorial Introduction | 1 |
12 Objects and Relationships | 2 |
13 Programming | 3 |
14 Facts | 4 |
15 Questions | 6 |
16 Variables | 8 |
17 Conjunctions | 10 |
18 Rules | 16 |
613 Watching Prolog at Work | 143 |
More Example Programs | 145 |
72 Searching a Maze | 148 |
73 The Towers of Hanoi | 152 |
74 Parts Inventory | 153 |
75 List Processing | 155 |
76 Representing and Manipulating Sets | 159 |
77 Sorting | 161 |
19 Summary and Exercises | 22 |
A Closer Look | 25 |
211 Constants | 26 |
212 Variables | 27 |
22 Characters | 29 |
23 Operators | 30 |
24 Equality and Unification | 32 |
25 Arithmetic | 34 |
26 Summary of Satisfying Goals | 37 |
261 Successful satisfaction of a conjunction of goals | 38 |
262 Consideration of goals in backtracking | 42 |
263 Unification | 43 |
Using Data Structures | 47 |
32 Lists | 50 |
33 Recursive Search | 53 |
34 Mapping | 57 |
35 Recursive Comparison | 60 |
36 Joining Structures Together | 63 |
37 Accumulators | 67 |
38 Difference Structures | 70 |
Backtracking and the Cut | 73 |
41 Generating Multiple Solutions | 74 |
42 The Cut | 80 |
43 Common Uses of the Cut | 85 |
432 The cutfail Combination | 90 |
433 Terminating a generate and test | 92 |
44 Problems with the Cut | 96 |
Input and Output | 99 |
51 Reading and Writing Terms | 100 |
512 Writing Terms | 101 |
52 Reading and Writing Characters | 104 |
521 Reading Characters | 105 |
522 Writing Characters | 106 |
53 Reading English Sentences | 108 |
54 Reading and Writing Files | 111 |
541 Opening and closing streams | 112 |
542 Changing the current input and output | 113 |
543 Consulting | 115 |
55 Declaring Operators | 116 |
Builtin Predicates | 119 |
61 Entering New Clauses | 120 |
62 Success and Failure | 121 |
63 Classifying Terms | 122 |
64 Treating Clauses as Terms | 123 |
65 Constructing and Accessing Components of Structures | 127 |
66 Affecting Backtracking | 132 |
67 Constructing Compound Goals | 134 |
68 Equality | 136 |
69 Input and Output | 137 |
610 Handling Files | 138 |
611 Evaluating Arithmetic Expressions | 139 |
612 Comparing Terms | 140 |
78 Using the Database | 164 |
782 Gensym | 165 |
783 Findall | 167 |
79 Searching Graphs | 169 |
710 Sift the Twos and Sift the Threes | 174 |
711 Symbolic Differentiation | 177 |
712 Mapping Structures and Transforming Trees | 179 |
713 Manipulating Programs | 182 |
714 Bibliographic Notes | 185 |
Debugging Prolog Programs | 187 |
81 Laying out Programs | 188 |
82 Common Errors | 191 |
83 The Tracing Model | 194 |
84 Tracing and Spy Points | 200 |
841 Examining the Goal | 204 |
842 Examining the Ancestors | 205 |
843 Altering the Degree of Tracing | 206 |
844 Altering the Satisfaction of the Goal | 207 |
845 Other Options | 209 |
85 Fixing Bugs | 210 |
Using Prolog Grammar Rules | 213 |
92 Representing the Parsing Problem in Prolog | 216 |
93 The Grammar Rule Notation | 221 |
94 Adding Extra Arguments | 223 |
95 Adding Extra Tests | 227 |
96 Summary | 230 |
97 Translating Language into Logic | 231 |
98 More General Use of Grammar Rules | 233 |
The Relation of Prolog to Logic | 237 |
102 Clausal Form | 240 |
103 A Notation for Clauses | 246 |
104 Resolution and Proving Theorems | 248 |
105 Horn Clauses | 251 |
106 Prolog | 252 |
107 Prolog and Logic Programming | 254 |
Projects in Prolog | 259 |
112 Advanced Projects | 262 |
Answers to Selected Exercises | 267 |
Clausal Form Program Listings | 271 |
Writing Portable Standard Prolog Programs | 277 |
C2 Different Prolog Implementations | 278 |
C3 Issues to Look Out For | 279 |
C4 Definitions of some Standard Predicates | 280 |
C41 Character Processing | 281 |
C42 Directives | 283 |
C43 Stream InputOutput | 284 |
C44 Miscellaneous | 287 |
Code to Support DCGs | 289 |
D1 DCG Support Code | 290 |
295 | |
Other editions - View all
Programming in Prolog: Using the ISO Standard William F. Clocksin,Christopher S. Mellish Limited preview - 2012 |