Basic Prolog.ppt
《Basic Prolog.ppt》由会员分享,可在线阅读,更多相关《Basic Prolog.ppt(18页珍藏版)》请在麦多课文档分享上搜索。
1、Basic Prolog,Structure of Programs,Programs consist of procedures.Procedures consist of clauses.Each clause is a fact or a rule.Programs are executed by posing queries.,Clauses: Facts and Rules,“if“ “provided that“ “turnstile“,Head :- Body.,This is a rule.,Head.,This is a fact.,Full stop at the end.
2、,Body of a (Rule) Clause Contains Goals,Head,Body,Goals,:-,likes(mary, X),human(X), honest(X).,Example Program,elephant(george). elephant(mary). elephant(X) :- grey(X), mammal(X),hasTrunk(X).,Predicate,Procedure for elephant,Facts,Clauses can be interpreted in a declarative or a procedural way,Claus
3、e:Declarative reading:Procedural reading:,H :- G1, G2, , Gn.That H is provable follows fromgoals G1, G2, , Gn being provableTo execute procedure H, the procedures called by goals G1, G2, , Gn are executed first,Interpretation of Clauses,Interpretation of Clauses,Clauses can be interpreted in a decla
4、rative, or in a procedural way,Clause:Declarative reading:Procedural reading:,H :- G1, G2, , Gn.That H is provable follows fromgoals G1, G2, , Gn being provableTo execute procedure H, the procedures called by goals G1, G2, , Gn are executed first,Clauses,Clauses provide a convenient way to express c
5、ase analysis and non-determinism.Program clauses and data have the same form.A Prolog program can also be seen as a relational database containing rules and facts.The relational form of procedures makes it possible to define reversible procedures.,Unification,Term-manipulation that passes parameters
6、, returns results, selects and constructs data structuresBasic control flow model is backtrackingSometimes it is necessary to use control features that are not part of logic,Computation via Queries,Facts and rules are stored in a database They can be queried ?- likes(joe, fish). yes ?- likes(joe, ch
7、ocolate) no Important: no means “I know its false, or I dont know” yes means “I can prove it” asymmetric,Example Queries,Queries,Replies,?- elephant(george).Yes?- elephant(jane).no,Prologs Style,State the facts and rules Pose queries Prolog finds the answers by searching the facts deducing new facts
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- BASICPROLOGPPT
