i am new to Prolog. I mabaged to understand how to do simple expert system, like
go :- hypothesize(Vehicle),
write('I guess that the Vehicle is: '),
write(Vehicle), nl, undo.
hypothesize(car) :- car, !.
hypothesize(van) :- van,!.
hypothesize(bike) :- bike, !.
hypothesize(mini) :- mini, !.
hypothesize(tank) :-tank, !.
hypothesize(sau) :- sau, !.
hypothesize(excavator) :- excavator, !.
hypothesize(bulldozer) :- bulldozer, !.
hypothesize(rocket) :- rocket, !.
hypothesize(shuttle) :- shuttle , !.
hypothesize(destroyer) :- destroyer, !.
hypothesize(civil_plane) :- civil_plane, !.
hypothesize(unknown).
/* Vehicle identification rules */
sau :- grounder,
verify(has_gun),
verify(long_fire).
tank :- grounder,
verify(has_gun),
verify(short_fire).
excavator :- grounder,
verify(no_gun),
verify(have_ladle).
bulldozer :- grounder,
verify(no_gun),
verify(no_ladle).
car :- grounder,
verify(big_body),
verify(for_passengers).
van :- grounder,
verify(big_body),
verify(for_cargo).
bike :- grounder,
verify(small_body),
verify(two_wheels).
mini :- grounder,
verify(small_body),
verify(four_wheels).
rocket :- flying,
verify(cosmos_flying),
verify(can_return).
shuttle :- flying,
verify(cosmos_flying),
verify(cant_return).
destroyer :- flying,
verify(air_flying),
verify(warmade).
civil_plane :- flying,
verify(air_flying),
verify(civil).
/* classification rules */
grounder :- verify(has_wheels), !.
grounder :- verify(have_engine).
flying :- verify(has_wings), !.
flying :- verify(has_jets).
/* how to ask questions */
ask(Question) :-
write('Does the vehicle have the following attribute: '),
write(Question), write('? '),
read(Response), nl,
( (Response == yes ; Response == y)
-> assert(yes(Question)) ;
assert(no(Question)), fail).
:- dynamic yes/1,no/1.
/* How to verify something */
verify(S) :- (yes(S) -> true ; (no(S) -> fail ; ask(S))).
/* undo all yes/no assertions */
undo :- retract(yes(_)),fail.
undo :- retract(no(_)),fail.
undo.
And this is good, but the question is - how to do "back" output, like, i will type "tank" in prolog window, and he will give all the parts this tanks consist - like, gun - yes, short rifle - yes, wings - no, e.t.c
Is it possible to do in expert system like this, or i have to do another programm?
Thank you for your reply