Springer - Logic Programming With Prolog (2005)
Contents 1. Getting Started 1 1.1 Starting Prolog 1 1.2 Prolog Programs 3 1.3 Data Objects in Prolog: Prolog Terms 8 Practical Exercise 1 12 2. Clauses and Predicates 13 2.1 Clauses 13 2.2 Predicates 15 2.3 Loading Clauses 19 2.4 Variables 21 Practical Exercise 2 27 3. Satisfying Goals 29 Introduction 29 3.1 Unification 31 3.1.1 Unifying Call Terms 32 3.2 Evaluating Goals 35 3.3 Backtracking 39 3.4 Satisfying Goals: A Summary 50 3.5 Removing Common Variables 52 3.6 A Note on Declarative Programming 52 Practical Exercise 3 55 4. Operators and Arithmetic 57 4.1 Operators 57 4.2 Arithmetic 59 4.3 Equality Operators 63 4.4 Logical Operators 66 Practical Exercise 4 68 xii Contents 5. Input and Output 69 Introduction 69 5.1 Outputting Terms 69 5.2 Inputting Terms 71 5.3 Input and Output Using Characters 72 5.4 Outputting Characters 73 5.5 Inputting Characters 73 5.6 Using Characters: Examples 74 5.7 Input and Output Using Files 77 5.8 File Output: Changing the Current Output Stream 77 5.9 File Input: Changing the Current Input Stream 78 5.9.1 Reading from Files: End of File 78 5.9.2 Reading from Files: End of Record 79 5.10 Using Files: Examples 79 Practical Exercise 5 82 6. Loops 85 Introduction 85 6.1 Looping a Fixed Number of Times 85 6.2 Looping Until a Condition Is Satisfied 89 6.2.1 Recursion 89 6.2.2 Using the 'repeat' Predicate 91 6.3 Backtracking with Failure 94 6.3.1 Searching the Prolog Database 94 6.3.2 Finding Multiple Solutions 96 Practical Exercise 6 97 7. Preventing Backtracking 99 Introduction 99 7.1 The Cut Predicate 99 7.2 Cut with Failure 106 Practical Exercise 7 108 8. Changing the Prolog Database 109 8.1 Changing the Database: Adding and Deleting Clauses 109 8.2 Adding Clauses 110 8.3 Deleting Clauses 111 8.4 Changing the Database: Example 112 8.5 Maintaining a Database of Facts 114 Practical Exercise 8 118 Contents xiii 9. List Processing 119 9.1 Representing Data as Lists 119 9.2 Notation for Lists 120 9.3 Decomposing a List 122 9.4 Built-in Predicate: member 125 9.5 Built-in Predicate: length 126 9.6 Built-in Predicate: reverse 126 9.7 Built-in Predicate: append 127 9.8 List Processing: Examples 129 9.9 Using findall/3 to Create a List 133 Practical Exercise 9 136 10. String Processing 137 10.1 Converting Strings of Characters To and From Lists 137 10.2 Joining Two Strings 139 10.3 Trimming a String 139 10.4 Inputting a String of Characters 141 10.5 Searching a String 142 10.6 Dividing a String into Its Component Parts 144 Practical Exercise 10 147 11. More Advanced Features 149 Introduction 149 11.1 Extending Prolog: Arithmetic 149 11.2 Extending Prolog: Operations on Strings 155 11.3 Extending Prolog: Sets 157 11.4 Processing Terms 160 Practical Exercise 11 166 Appendix 1. Built-in Predicates 167 Appendix 2. Built-in Operators 179 Appendix 3. Specimen Solutions to Practical Exercises 185 Appendix 4. Glossary 209 Index 221
- cutegirl062014-12-19这本书不错。文字清晰,内容页很详细,多学习prolog很有帮助
- 粉丝: 37
- 资源: 42
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助