Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

start:- hypothesis(Transportation),

write('I believe it is:'),

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).

/*How to ask questions*/

ask(Question) :-

write('Does the transportation have the following characteristics:'),

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.

You might also like