下面是该规则集所形成的(部分)推理网络: 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,"In"), 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). animal_is(tiger):- it_is(carnivore), positive(has,tawny_color), positive (has,black stripes). animalis(giraffe):- it_is(ungulate), positive (has,long_neck), positive(has,long_legs), positive(has,dark_spots). animal is(zebra): it_is(ungulate), positive (has,black_stripes). animal is(ostrich):- it_is(bird), negative(does,fly),下面是该规则集所形成的(部分)推理网络: 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). animal_is(tiger):- it_is(carnivore), positive(has, tawny_color), positive(has, black_stripes). animal_is(giraffe):- it_is(ungulate), positive(has, long_neck), positive(has, long_legs), positive(has, dark_spots). animal_is(zebra):- it_is(ungulate), positive(has, black_stripes). animal_is(ostrich):- it_is(bird), negative(does, fly)