實驗一 Prolg簡介及簡單程序設(shè)計_第1頁
實驗一 Prolg簡介及簡單程序設(shè)計_第2頁
實驗一 Prolg簡介及簡單程序設(shè)計_第3頁
實驗一 Prolg簡介及簡單程序設(shè)計_第4頁
實驗一 Prolg簡介及簡單程序設(shè)計_第5頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、實驗一 Prolog簡介及簡單程序設(shè)計一、實驗?zāi)康?、掌握Visual Prolog軟件并調(diào)試運行程序;2、熟悉Prolog語言的基本結(jié)構(gòu);3、理解Prolog程序的推理機制;4、學(xué)會用Prolog語言編寫簡單的程序。二、實驗原理1、Visual Prolog語言的基本知識及開發(fā)環(huán)境。2、謂詞邏輯表示知識的方法、事實和規(guī)則的表示方法。3、簡單邏輯推理機制。三、實驗設(shè)備1、計算機PC 一臺2、Visual Prolog 5.2 四、實驗內(nèi)容和步驟1、熟悉Visual Prolog軟件的使用;新建文件夾:命令“File | New”,產(chǎn)生一個標(biāo)題為"NONAME"的文件;運行程

2、序:GOAL write("Hello world"),nl. Project | Test Goal或Ctrl+G。2、運行程序1,找出程序中的錯誤并進(jìn)行修改;記錄執(zhí)行目標(biāo)1、2所得的結(jié)果;完成練習(xí)1(Exercises1)中的內(nèi)容。3、運行程序2,記錄執(zhí)行結(jié)果;思考:若要問目標(biāo)2、3、4時,如何來修改程序(選做);完成練習(xí)2(Exercises2)中的內(nèi)容。4、運行程序3、4,記錄執(zhí)行結(jié)果;理解程序中普通變量和匿名變量的使用方法。5、運行程序5,記錄執(zhí)行結(jié)果;執(zhí)行目標(biāo)2、3并記錄其結(jié)果;理解復(fù)合目標(biāo)(合取和析?。┑谋硎痉椒?。6、自己編寫一個簡單的Prolog程序。五、附

3、錄示例程序:predicates /*謂詞段,對要用的謂詞名和參數(shù)進(jìn)行說明*/likes(symbol, symbol) - nondeterm (o,i),nondeterm (i,i)friend(symbol, symbol) - nondeterm (i,o)clauses /*子句段,存放所有的事實和規(guī)則*/likes(bell,sports). /*前4行是事實*/likes(mary,music).likes(mary,sports).likes(jane,smith).friend(john,X):-likes(X,sports),likes(X,music). /*本行是規(guī)則

4、*/goal /*目標(biāo)段,進(jìn)行提問*/ friend(john,X).程序1:predicates likes(symbol,symbol) - nondeterm (i,i)clauses likes(ellen,tennis). likes(john,football). likes(tom,baseball). likes(eric,swimming,6). likes(mark,tennis). likes(bill,Activity):- #likes(tom, Activity).goal likes(bill,baseball). %目標(biāo)1 %likes(bill, tennis

5、). %目標(biāo)2Exercises1:Write natural language sentences that represent what these Prolog facts might convey to a human reader. (Remember that, to the computer, these facts are simple pieces of information that can be used for matching answers to questions.)1.likes(jeff, painting).2.male(john).3.building(

6、"Empire State Building", new_york).4.person(roslin, jeanie, "1429 East Sutter St.","Scotts Valley", "CA", 95066).Write Visual Prolog facts that represent the following natural language statements:1. Helen likes pizza.2. San Francisco is in California.3. Amy

7、9;s telephone number is 476-0299.4. Len's father is Alphonso Grenaldi.程序2:predicates can_buy(symbol,symbol) - nondeterm (o,o) person(symbol) - nondeterm (o) car(symbol) - nondeterm (o) likes(symbol,symbol) - nondeterm (i,i) for_sale(symbol) - nondeterm (i)clauses can_buy(X,Y):-person(X),car(Y),l

8、ikes(X,Y), for_sale(Y). person(kelly). person(judy). person(ellen). person(mark). car(lemon). car(hot_rod). likes(kelly, hot_rod). likes(judy, pizza). likes(ellen, tennis). likes(mark, tennis). for_sale(pizza). for_sale(lemon). for_sale(hot_rod).goal can_buy(Who,What). %can_buy(judy, What). %目標(biāo)2 %ca

9、n_buy(kelly, What). %目標(biāo)3 %can_buy(Who, hot_rod). %目標(biāo)4Exercises2:Write natural-language sentences corresponding to the following Visual Prolog rules:eats(Who, What):- food(What), likes(Who, What).pass_class(Who):- did_homework(Who), good_attendance(Who).does_not_eat(toby, Stuff):- food(Stuff), greasy

10、(Stuff).owns(Who, What):- bought(Who, What).Write Visual Prolog rules that convey the meaning of these natural-language sentences:a.A person is hungry if that person's stomach is empty.b.Everybody likes a job if it's fun and it pays well.c.Sally likes french fries if they're cooked.d.Eve

11、rybody owns a car who buys one, pays for it, and keeps it.程序3:predicates likes(symbol,symbol) - nondeterm (o,i), nondeterm (i,i)clauses likes(ellen,reading). likes(john,computers). likes(john,badminton). likes(leonard,badminton). likes(eric,swimming). likes(eric,reading).goal likes(Person,reading),

12、likes(Person,swimming).程序4:predicates male(symbol) - nondeterm (o) female(symbol) - nondeterm (o) parent(symbol,symbol) - nondeterm (o,o)clauses male(bill). male(joe). female(sue). female(tammy). parent(bill,joe). parent(sue,joe). parent(joe,tammy).goal parent(Parent,_).程序5:predicates car(symbol,lon

13、g,integer,symbol,long) - nondeterm (o,o,o,o,i) truck(symbol,long,integer,symbol,long) - nondeterm (o,o,o,o,i) vehicle(symbol,long,integer,symbol,long) - nondeterm (o,o,o,o,i)clauses car(chrysler,130000,3,red,12000). car(ford,90000,4,gray,25000). car(datsun,8000,1,red,30000). truck(ford,80000,6,blue,8000). truck(datsun,50000,5,orange,20000). truck(toyota,25000,2,black,25000). vehicle(Make,Odometer,Age,Color,Price):-car(Make,Odometer,Age,Color,Price);truck(Make,Odometer,Age,Color,Price).goal car(Make,Odometer,Years_on_road,Body,25000)

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論