没有合适的资源?快使用搜索试试~ 我知道了~
首页Visual Prolog编译环境的教程
资源详情
资源评论
资源推荐
Visual Prolog 7.3 for Tyros
Eduardo Costa
PREFACE
This book started as a personal project. My intention was simply to
write a tutorial on Logic Programming for my son. The success of the book,
however, was immense, and I received many suggestions on how to improve
the text, or the code, and encouragement to continue with the work. Mail
came from Saudi Arabia, China, Russia, Spain, France, Brazil, Canada, and
many other places. Although the space is too short to list everyone who wrote
me about the book, I want to acknowledge the collaboration and enthusiasm
of the following persons:
• Elena Efimova, who made many corrections on the text, and in the
historical background of Mathematics and Logics.
• Mark Safronov, who translated the book to Russian, and made many
corrections on the contents of the original. By the way, the Russian
translation has a much better layout than the English original.
• Thomas W. de Boer, who prepared a parallel edition of the book, with
longer explanations, and a text appropriate to rank beginners.
• Stuart Cumming. I often give examples that show what one should
avoid from the point of software engineering. Stuart pointed out that
people could be misled by these examples; he suggests that, whenever
an implementation is not robust, I should emphasize its weak points.
Although I agree with Stuart, I thought it better to remove the negative
examples altogether.
• Rose Shapiro, who corrected my Latin, and my description of many
historical events.
• Yuri Ilyin, who helped me with his expertise; without him, this book
would not be written.
• Reny Cury, who went through the manuscript correcting typos.
• Philippos Apolinarius who helped me with his knowledge of Botanical
Latin, and Chinese.
• Thomas Linder Puls and Elizabeth Safro, from PDC, for support and
encouragement.
• Benjamin Emer from Kenosha, Wisconsin. Masters in Teaching, el-
ementary school teacher and teacher of English. He helped with the
grammar, editing and fluency of this book.
Contents
I Savoir-faire 11
1 Introduction 13
1.1 Creating a project in VIP . . . . . . . . . . . . . . . . . . . . 13
1.1.1 Create a new GUI project: name . . . . . . . . . . . . 14
1.1.2 Compile and execute the program . . . . . . . . . . . . 14
1.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.3 Notions of Logics: Ancient Greeks . . . . . . . . . . . . . . . . 16
2 Forms 17
2.1 Create a form: folder/name . . . . . . . . . . . . . . . . . . . . 17
2.2 Enable the task menu: e.g. File/New option . . . . . . . . . . . 17
2.3 In CodeExpert, add code to project tree item . . . . . . . . . . 18
2.4 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5 Notions of Logics: Aristotle’s Syllogistic . . . . . . . . . . . . 22
2.5.1 Valid syllogisms . . . . . . . . . . . . . . . . . . . . . . 24
2.6 Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3 Mouse events 31
3.1 Add code to MouseDownListener . . . . . . . . . . . . . . . . 31
3.2 onPaint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.4 Notions of Logics: Boolean algebra . . . . . . . . . . . . . . . 34
3.5 Argument forms . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4 Less Figures 37
4.1 Task menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.2 Project Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.2.1 Code Expert . . . . . . . . . . . . . . . . . . . . . . . . 39
4.3 Create Project Item . . . . . . . . . . . . . . . . . . . . . . . . 40
4.4 Create a new class: folder/name . . . . . . . . . . . . . . . . . 43
4.5 Edit field contents . . . . . . . . . . . . . . . . . . . . . . . . . 43
1
2 CONTENTS
4.6 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.7 Notions of Logics: Predicate calculus . . . . . . . . . . . . . . 44
5 Horn Clauses 45
5.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.2 Predicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.3 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.4 Multi-solutions . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.4.1 A program that uses multi-solution predicates . . . . . 51
5.5 Logical junctors . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.6 Implication . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.7 Horn Clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.8 Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.9 Drawing predicates . . . . . . . . . . . . . . . . . . . . . . . . 57
5.10 GDI Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.11 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.12 Notions of Logics: Meaning of Horn clauses . . . . . . . . . . . 60
6 Console Applications 61
6.1 Cut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
6.2 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.3 List schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
6.4 Reasoning about programs . . . . . . . . . . . . . . . . . . . . 72
6.5 String operations . . . . . . . . . . . . . . . . . . . . . . . . . 75
—Parsing into tokens: fronttoken . . . . . . . . . . . . . . . . . . 75
—String concatenation: concatList . . . . . . . . . . . . . . . . . 75
—String concatenation: concat/2 and concat/3 . . . . . . . . . . 75
—Term to String conversion: toTerm . . . . . . . . . . . . . . . . 76
—Term to String conversion: hasdomain . . . . . . . . . . . . . . 76
—Term to String conversion: toString . . . . . . . . . . . . . . . . 76
—Term to String conversion: format . . . . . . . . . . . . . . . . . 77
—String processing: Useful predicates . . . . . . . . . . . . . . . . 78
6.6 Notions of Logics: Grammar for Predicates . . . . . . . . . . . 83
7 Grammars 85
7.1 Parsing grammar . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.2 Generating grammar . . . . . . . . . . . . . . . . . . . . . . . 87
7.3 Why Prolog? . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.5 Notions of Logics: Natural deduction . . . . . . . . . . . . . . 90
CONTENTS 3
8 Painting 93
8.1 onPainting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
8.2 Custom Control . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.3 Notions of Logics: Resolution principle . . . . . . . . . . . . . 99
9 Data types 101
9.1 Primitive data types . . . . . . . . . . . . . . . . . . . . . . . 101
9.2 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
9.3 Sets of numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 103
9.4 Irrational Numbers . . . . . . . . . . . . . . . . . . . . . . . . 106
9.5 Real Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
9.6 Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
9.7 Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
9.8 domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
9.8.1 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
9.8.2 Functors . . . . . . . . . . . . . . . . . . . . . . . . . . 110
9.9 Notions of Logics: Horn clauses . . . . . . . . . . . . . . . . . 114
10 How to solve it in Prolog 115
10.1 Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
11 Facts 135
11.1 Class file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
11.1.1 Reading and writing a string . . . . . . . . . . . . . . . 138
11.2 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
12 Classes and Objects 141
12.1 Object facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
12.2 Generic Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . 144
12.3 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
12.4 Generic Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . 148
13 Giuseppe Peano 151
13.1 Turtle graphics . . . . . . . . . . . . . . . . . . . . . . . . . . 151
13.2 Turtle states . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
13.3 Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
13.4 Peano’s curve . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
13.5 Latino Sine Flexione . . . . . . . . . . . . . . . . . . . . . . . 155
13.6 Quotations from Key to Interlingua . . . . . . . . . . . . . . . 156
13.7 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
剩余269页未读,继续阅读
guoluxiao
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- JSBSim Reference Manual
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论5