Professional Documents
Culture Documents
Transportation Prolog
Transportation Prolog
write(Transportation),
nl,
undo.
hypothesis(airplane):-airplane,!.
hypothesis(train):-train,!.
hypothesis(sinotruck):- sinotruck,!.
hypothesis(bajaj):- bajaj,!.
hypothesis(ship):-ship,!.
hypothesis(motorcycle):-motorcycle,!.
hypothesis(unknown).
airplane:-
verify(in_air),
verify(big_size),
verify(fast_speed),
verify(many_passengers).
train:-
verify(rail_way),
verify(long_height),
verify(long_distance),
verify(many_passengers).
sinotruck:-
verify(on_road),
verify(for_cargo),
verify(big_size),
verify(long_way).
bajaj:-
verify(three_tire),
verify(three_passengers),
verify(small_body_size),
verify(use_benzil).
ship:-
verify(on_water),
verify(long_way),
verify(cargo_and_passenger),
verify(low_speed).
motorcycle:-
verify(two_tire),
verify(two_passenger),
verify(small_body_size),
verify(use_benzil).
ask(Question) :-
write(Question),
write('? '),
read(Response),
nl,
->
assert(yes(Question)) ;
assert(no(Question)), fail).
:- dynamic yes/1,no/1.
verify(S):-
(yes(S)
->
true;
(no(S)
->
fail;
ask(S))).
undo:-retract(yes(_)),fail.
undo:-retract(no(_)),fail.
undo.