Category : Files from Magazines
Archive   : PCTJ1285.ZIP
Filename : EXPERT.PRO
Output of file : EXPERT.PRO contained in archive : PCTJ1285.ZIP
nl,
writeln('Tiny sample expert system / M. Covington 1985'),
nl,
writeln('This program diagnoses why a car won''t start.'),
writeln('Answer all questions with ''yes.'' or ''no.'''),
writeln('(lower case, with period, without quotes).'),
!,
try_all_possibilities.
try_all_possibilities :-
/* The 'fail' at the end causes this predicate to */
/* backtrack through all possibilities. */
defect_may_be(Diagnosis),
explain(Diagnosis),
fail.
try_all_possibilities :-
/* If all paths through the previous definition */
/* have been exhausted, leave Prolog. */
halt.
explain(wrong_gear) :-
nl,
writeln('Check that the gearshift is set to Park or'),
writeln('Neutral. Try both Park and Neutral and see if'),
writeln('either of them works; try jiggling the gear'),
writeln('shift lever.').
explain(starting_system) :-
nl,
writeln('Check for a defective battery, voltage'),
writeln('regulator, or alternator; if any of these is'),
writeln('the problem, charging the battery or jump-'),
writeln('starting may get the car going temporarily.'),
writeln('Alternatively, the starter itself may be'),
writeln('defective.').
explain(drained_battery) :-
nl,
writeln('The battery has apparently become drained during'),
writeln('your attempts to start the car. Recharging or'),
writeln('jump-starting will be necessary. However, there'),
writeln('is probably nothing wrong with the battery'),
writeln('itself.').
explain(fuel_system) :-
nl,
writeln('Check whether there is fuel in the tank.'),
writeln('If so, check for a clogged fuel line or filter'),
writeln('or a defective fuel pump.').
explain(ignition_system) :-
nl,
writeln('Check the spark plugs, cables, distributor,'),
writeln('coil, and other parts of the ignition system.'),
writeln('If any of these are visibly defective or long'),
writeln('overdue for replacement, replace them; if this'),
writeln('does not solve the problem, consult a mechanic.').
defect_may_be(drained_battery) :-
starter_was_ok(yes),
starter_is_ok(no).
defect_may_be(wrong_gear) :-
starter_was_ok(no).
defect_may_be(starting_system) :-
starter_was_ok(no).
defect_may_be(fuel_system) :-
starter_was_ok(yes),
fuel_is_ok(no).
defect_may_be(ignition_system) :-
starter_was_ok(yes),
fuel_is_ok(yes).
starter_was_ok(unknown).
starter_was_ok(X) :-
retract(starter_was_ok(unknown)),
nl,
writeln('When you first started trying to start the car,'),
writeln('did the starter crank the engine normally? '),
read(Reply),
asserta(starter_was_ok(Reply)),
!,
X = Reply.
starter_is_ok(unknown).
starter_is_ok(no) :-
starter_was_ok(no).
starter_is_ok(X) :-
retract(starter_is_ok(unknown)),
nl,
writeln('Does the starter crank the engine normally now?'),
read(Reply),
asserta(starter_is_ok(Reply)),
!,
X = Reply.
fuel_is_ok(unknown).
fuel_is_ok(X) :-
retract(fuel_is_ok(unknown)),
nl,
writeln('Is fuel being delivered to the carburetor?'),
read(Reply),
asserta(fuel_is_ok(Reply)),
!,
X = Reply.
writeln(X) :-
write(X), nl.
?- writeln('Type ''start.'' to begin.').
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/