xpositive(symbol,symbol).
xnegative(symbol,symbol).
run:-animal_is(X), !,write("\nYour animal may be a"),write(X),nl, nl, clear_facts.
run:-write("\nUnable to determine what"),clear_facts.
positive(X,Y):-write("\npositive(X,Y)0\n"),xpositive(X, Y), ! .
positive(X,Y):-write("\npositive(X,Y)1\n"),not(xnegative(X, Y)),ask(X, Y).
negative(X,Y):-write("\nnegative(X,Y)0\n"),xnegative(X, Y), !.
negative(X,Y):-write("\nnegative(X,Y)1\n"),not(xpositive(X, Y)),ask(X, Y).
ask(X,Y):-write("\nask \n"),write(X),write(" it "),write(Y),readln(R),write("\n0000000000000\n"),new_rules(X,Y,R).
new_rules(X, Y, y):-write("\n01111111111110\n"),assert(xpositive(X, Y)).
new_rules(X, Y, n):-write("\n02222222222220\n"),assert(xnegative(X, Y)), fail.
clear_facts:-retract(xpositive(_,_)) , fail.
clear_facts:-retract(xnegative(_,_)), fail.
clear_facts:-write("\nExit\n").
it_is(mammal):-write("\nit_is(mammal)0\n"),positive( has, hair).
it_is(mammal):-write("\nit_is(mammal)1\n"),positive( does, give_milk).
it_is(bird):-positive( has, feathers).
it_is(bird):-positive( does, fly),positive(does, lay_eggs).
it_is(carnivore):-positive(does, eat_meat).
it_is(carnivore):-positive(has, pointed_teeth),positive(has, claws),positive(has, forward_eyes).
it_is(ungulate):-it_is(mammal),positive( has, hooves).
it_is(ungulate):-it_is( mammal),positive( does, chew_cud).
animal_is(cheetah):-it_is( mammal) , it_is( carnivore),positive( has, tawny_color),positive(has, black_spots).
animal_is( tiger) :-it_is( mammal),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) .
above is my prolog code(download from the Internet),these line:
ask(X,Y):-write("\nask \n"),write(X),write(" it "),write(Y),readln(R),write("\n0000000000000\n"),new_rules(X,Y,R).
new_rules(X, Y, y):-write("\n01111111111110\n"),assert(xpositive(X, Y)).
new_rules(X, Y, n):-write("\n02222222222220\n"),assert(xnegative(X, Y)), fail.
means to ask user questions and then to assert new facts into the system. But the predict "new_rules" cannot be satisfied because "011111110" or "02222220" cannot be print onto the screen,thus the system cannot use the answer!! I just do not know why!!Thanks very much for all your suggestions!!!!!!