Learn Prolog Now

Free Download

Authors:

ISBN: 9781904987178, 1904987176

Size: 2 MB (1711811 bytes)

Pages: 284/284

File format:

Language:

Publishing Year:

Category:

Patrick Blackburn, Johan Bos, Kristina Striegnitz9781904987178, 1904987176

Prolog is a programming language, but a rather unusual one. “Prolog” is short for “Programming with Logic”, and the link with logic gives Prolog its special character. At the heart of Prolog lies a surprising idea: don’t tell the computer what to do. Instead, describe situations of interest, and compute by asking questions. Prolog will logically deduce new facts about the situations and give its deductions back to us as answers. Why learn Prolog? For a start, its “say what the problem is, rather than how to solve it” stance, means that it is a very high level language, good for knowledge rich applications such as artificial intelligence, natural language processing, and the semantic web. So by studying Prolog, you gain insight into how sophisticated tasks can be handled computationally. Moreover, Prolog requires a different mindset. You have to learn to see problems from a new perspective, declaratively rather than procedurally. Acquiring this mindset, and learning to appreciate the links between logic and programming, makes the study of Prolog both challenging and rewarding. Learn Prolog Now! is a practical introduction to this fascinating language. Freely available as a web-book since 2002 (see www.learnprolognow.org) Learn Prolog Now! has became one of the most popular introductions to the Prolog programming language, an introduction prized for its clarity and down-to-earth approach. It is widely used as a textbook at university departments around the world, and even more widely used for self study. College Publications is proud to present here the first hard-copy version of this online classic. Carefully revised in the light of reader’s feedback, and now with answers to all the exercises, here you will find the essential material required to help you learn Prolog now.

Table of contents :
Learn Prolog Now!……Page 0
Table of Contents……Page 2
1 Facts, Rules, and Queries……Page 6
1.1 Some simple examples……Page 7
1.1.1 Knowledge Base 1……Page 8
1.1.2 Knowledge Base 2……Page 10
1.1.3 Knowledge Base 3……Page 13
1.1.4 Knowledge Base 4……Page 16
1.1.5 Knowledge Base 5……Page 19
1.2 Prolog Syntax……Page 21
1.2.1 Atoms……Page 22
1.2.2 Numbers……Page 23
1.2.3 Variables……Page 24
1.2.4 Complex terms……Page 25
1.3 Exercises……Page 27
1.4 Practical Session 1……Page 30
2 Matching and Proof Search……Page 34
2.1 Matching……Page 35
2.1.1 Examples……Page 38
2.1.2 The occurs check……Page 43
2.1.3 Programming with matching……Page 46
2.2 Proof Search……Page 49
2.3 Exercises……Page 56
2.4 Practical Session 2……Page 59
3 Recursion……Page 63
3.1 Recursive definitions……Page 64
3.1.1 Example 1: Eating……Page 65
3.1.2 Example 2: Descendant……Page 69
3.1.3 Example 3: Successor……Page 75
3.1.4 Example 3: Addition……Page 78
3.2 Clause ordering, goal ordering, and termination……Page 81
3.3 Exercises……Page 84
3.4 Practical Session 3……Page 87
4 Lists……Page 91
4.1 Lists……Page 92
4.2 Member……Page 97
4.3 Recursing down lists……Page 101
4.4 Exercises……Page 105
4.5 Practical Session 4……Page 108
5 Arithmetic……Page 111
5.1 Arithmetic in Prolog……Page 112
5.2 A closer look……Page 115
5.3 Arithmetic and lists……Page 118
5.4 Comparing integers……Page 121
5.5 Exercises……Page 125
5.6 Practical Session 5……Page 127
6 More Lists……Page 129
6.1 Append……Page 130
6.1.1 Defining append……Page 132
6.1.2 Using append……Page 136
6.2 Reversing a list……Page 139
6.2.1 Naive reverse using append……Page 141
6.2.2 Reverse using an accumulator……Page 142
6.3 Exercises……Page 144
6.4 Practical Session 6……Page 147
7 Definite Clause Grammars……Page 149
7.1 Context free grammars……Page 150
7.1.1 CFG recognition using append……Page 154
7.1.2 CFG recognition using difference lists……Page 158
7.2 Definite clause grammars……Page 161
7.2.1 A first example……Page 162
7.2.2 Adding recursive rules……Page 165
7.2.3 A DCG for a simple formal language……Page 168
7.3 Exercises……Page 170
7.4 Practical Session 7……Page 172
8 More Definite Clause Grammars……Page 174
8.1 Extra arguments……Page 175
8.1.1 Context free grammars with features……Page 176
8.1.2 Building parse trees……Page 183
8.1.3 Beyond context free languages……Page 187
8.2 Extra goals……Page 189
8.2.1 Separating rules and lexicon……Page 191
8.3 Concluding remarks……Page 194
8.4 Exercises……Page 196
8.5 Practical Session 8……Page 198
9 A Closer Look at Terms……Page 199
9.1 Comparing terms……Page 200
9.2 Terms with a special notation……Page 203
9.2.1 Arithmetic terms……Page 204
9.2.2 Lists as terms……Page 207
9.3 Examining Terms……Page 210
9.3.1 Types of Terms……Page 211
9.3.2 The Structure of Terms……Page 214
9.4 Operators……Page 218
9.4.1 Properties of operators……Page 219
9.4.2 Defining operators……Page 221
9.5 Exercises……Page 223
9.6 Practical Session……Page 226
10 Cuts and Negation……Page 230
10.1 The cut……Page 231
10.2 If-then-else……Page 240
10.3 Negation as failure……Page 241
10.4 Exercises……Page 246
10.5 Practical Session 10……Page 248
11 Database Manipulation and Collecting Solutions……Page 250
11.1 Database manipulation……Page 251
11.2 Collecting solutions……Page 257
11.2.1 findall/3……Page 259
11.2.2 bagof/3……Page 261
11.2.3 setof/3……Page 264
11.3 Exercises……Page 266
11.4 Practical Session 11……Page 269
12 Working With Files……Page 271
12.1 Splitting Programs Over Files……Page 272
12.1.1 Reading in Programs……Page 273
12.1.2 Modules……Page 275
12.1.3 Libraries……Page 278
12.2 Writing To and Reading From Files……Page 279
12.3 Practical Session……Page 282

Reviews

There are no reviews yet.

Be the first to review “Learn Prolog Now”
Shopping Cart
Scroll to Top