正在加载图片...
2.源程序 An Animal Classifying Expert System database xpositive(symbol, symbol) xnegative(symbol, symbol run animal is(symbol) positive(symbol, symbol negative (symbol, symbol) remember(symbol, symbol, symbol) ask(symbol, symbol) run run animal is(X),! write("\nYour animal may be a(n), X) nl, nl, clear facts write(\nUnable to determine what") write( your animal is. \n\n), clear facts. (X,Y) positive(X, Y): -not(xnegative(X, y)), ask(X, y) negative (X, Y): -xnegative(X, y) negative(X, Y): -not(xpositive(X, Y)), ask(X, Y) write(x, it Y,\n") readIn(Reply) remember(X, Y, Reply) remember(X, Y, y): -asserta(xpositive(, Y)) remember(X, Y, n): -assertaxnegative(X, Y)), fail. clear facts: -retract(xpositive(, )),fail clear facts: -retract(xnegative()),fail clear facts: -write(\n\nPlease press the space bar to Exit") Knowledge Base animal is(cheetah) it is(ca positive (has, tawny color) positive (has, black spots)4 2. 源程序 /* An Animal Classifying Expert System */ database xpositive(symbol,symbol) xnegative(symbol,symbol) predicates run animal_is(symbol) it_is(symbol) positive(symbol, symbol) negative(symbol, symbol) clear_facts remember(symbol, symbol, symbol) ask(symbol, symbol) goal run. clauses run:- animal_is(X),!, write("\nYour animal may be a(n) ", X), nl, nl, clear_facts. run:- write("\nUnable to determine what"), write("your animal is. \n\n"), clear_facts. positive(X, Y):-xpositive(X, Y),!. positive(X, Y):-not(xnegative(X, Y)), ask(X, Y). negative(X, Y):-xnegative(X,Y), !. negative(X, Y):-not(xpositive(X, Y)), ask(X, Y). ask(X, Y):- write(X, " it ", Y, "\n"), readln(Reply), remember(X, Y, Reply). remember(X, Y, y):-asserta(xpositive(X, Y)). remember(X, Y, n):-asserta(xnegative(X, Y)), fail. clear_facts:-retract(xpositive(_, _)), fail. clear_facts:-retract(xnegative(_, _)), fail. clear_facts:-write("\n\nPlease press the space bar to Exit"), readchar(_). /* Knowledge Base */ animal_is(cheetah):- it_is(carnivore), positive(has, tawny_color), positive(has, black_spots)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有