艾伯特Introduction to Prolog

艾伯特Introduction to Prolog

ID:7821892

大小:180.70 KB

页数:28页

时间:2018-02-26

艾伯特Introduction to Prolog_第1页
艾伯特Introduction to Prolog_第2页
艾伯特Introduction to Prolog_第3页
艾伯特Introduction to Prolog_第4页
艾伯特Introduction to Prolog_第5页
资源描述:

《艾伯特Introduction to Prolog》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、troInductiontoPrologWhatisProlog?{Prolog(ProgramminginLogic)isaprogramminglanguageforAIandumericalnon-nprogrammingingeneral.Whatisnew?{tionalConven(wellestablished,standard)languagesareprocedurallyoriented,whilePrologintroducesthedeclarativeview.1.taxSynofProlo

2、g(a)clausesAPrologprogramconsistsofclauses.APrologclauseisaHornclause.Eachclauseterminateswithafullstop.Prologclausesareofthreetypes:rules,facts,andquestions.Example1:rule{o spring(X,Y):-parent(Y,X).Example2:fact{parent(tom,ann).Example3:questions{parent(X

3、,ann).(b)proceduresAgroupofclauseshwhictheheadofeachclausearethesameiscalledaprocedure.Example:connects(san_francisco,oakland,bart_tran).connects(san_francisco,fremont,bart_tran).connects(concord,daly_city,bart_tran).(c)rulesAruleisaclausewithoneormoreconditio

4、ns.orFaruletobetrue,allofitsconditionsmustalsobetrue.Theright-handsideoftheruleisaconditionandtheleft-handsideoftheruleistheconclusion.The`:-'signmeans`if'.TheclauseinExample1canbestatedasXisano springofYifYisaparentofX.Theleft-handsideiscalledtheheadoftherule

5、andtheright-handsideiscalledthebodyoftherule.Thebodyofaruleisalistofgoalsseparatedbycommas.Commasareunderstoodasconjunctions.Example:p:-q,r,s,t.meanspistrueifqandrandsandtaretrue.(d)factsactsFarealwaysunconditionallytrue.Itonlyhasaheadpart(theconclusion)withan

6、emptybody.1www.aibbt.com让未来触手可及Example:has(student,books).(e)questionsQuestionsarequeriesforretrievingfactsthroughrules.Itonlyhasthebody(thegoals).Example: y(penguin).(f)argumentsArgumentscanbeanatom,anumber,aariable,vorastructure.(g)atomsAtomsareconcreteobj

7、ects(butumbersnareNOTatoms).The rstletterofanatomisaysalwasmallletter.Stringsofletters:tom,nil,x25,x25AB,x,xy,toppartStringsofspecialcharacters:<

8、>,===>,...,.:.(withcaution)Quotedstrings:om','T'SouthAmerica'(h)numbersThesyntaxofintegersissimpleexceptonemustr

9、ememberthattherangeofintegersislimitedtoanal,tervininSICSTUSProlog,eenbetw-16383to16383.Examples:3.1416,-0.001,22.223,100(i)ariablesvariablesVaregeneralobjec

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。