not(symptom(lights_work))
Download
Report
Transcript not(symptom(lights_work))
Rapid Prototyping
Expert System using
Prolog
Lab10
Dr.M.G.Srikanthan
Expert System
Expert System
Inference Engine
User
Knowledge Base
User Interface
Expert System Shell
Domain Expert
Knowledge Engineer
Knowledge Base
Questions
Knowledge Base
Rules
Reply
Questions
Knowledge Base
Questions
/* These facts relate questions to symptoms */
question('Do the headlights come on?',lights_work).
question('Does the starter motor turn the engine',engine_turns).
question('Is there a spark at the distributor points?',distrib_spark).
question('Is there a spark at the spark plugs?',plug_spark).
question('Do the headlights dim when you use the starter?',lights_dim).
question('Does the pointer move on the petrol gauge?',gauge_reads).
question('Is there petrol in the float chamber?',petrol_in_float_chamber).
question('Do the spark plugs look wet?',plugs_wet).
Rules
rule(1,batt_flat):not(symptom(lights_work)),
not(symptom(engine_turns)).
rule(2,low_voltage_fault):symptom(lights_work),
not(symptom(distri_spark)),
symptom(engine_turns).
Knowledge Base
Rules
rule(3,high_voltage_fault):symptom(lights_work),
symptom(distrib_spark),
symptom(engine_turns),
not(symptom(plug_spark)).
Rules
rule(4,starter_motor_fault):- symptom(lights_work),
not(symptom(engine_turns)),
not(symptom(lights_dim)).
rule(5,out_of_petrol):- not(symptom(gauge_reads)),
not(symptom(petrol_in_float_chamber)).
rule(6,blocked_jet):- symptom(gauge_reads),
symptom(petrol_in_float_chamber),
not(symptom(plug_wet)).
rule(7,feed_pipe_blocked):- symptom(gauge_reads),
not(symptom(petrol_in_float_chamber)).
rule(8,engine_flooded):- symptom(gauge_reads),
symptom(plug_wet).
rule(9,engine_seized):- not(symptom(engine_turns)),
symptom(lights_work),
symptom(lights_dim).
Reply
Knowledge Base
Reply
/* These facts relate a fault to be output */
reply(batt_flat,'The battery is flat.').
reply(low_voltage_fault,'There is a fault in the low-voltage ignition circuit‘ ).
reply(high_voltage_fault,'Fault in the high valtage ignition circuit‘ ).
reply(starter_motor_fault,'The starter motor is jammed or faulty‘ ).
reply(out_of_petrol,'You have run out of petrol‘ ).
reply(blocked_jet,'There is a blocked jet in the carburettor‘ ).
reply(feed_pipe_blocked,'Blocked feed pipe from petrol tank to carburettor‘ ).
reply(engine_flooded,'The engine is flooded‘ ).
reply(engine_seized,'The engine seems to be seized up‘ ).
Inference Engine
go:- initialise,
collect_symptoms,
rule(Number,Disease),
reply(Disease,Reply),
write(Reply),nl,
write('The rule used was number '),
write(Number),nl,nl,
retractall(symptom(_)).
go:- write('Sorry can''t help'),nl,nl,
retractall(symptom(_)).
Inference Engine
User Interface
initialise:- put(12),
write('*** Toy Medical Expert System ***'),nl,nl,
write('Please answer the following questions'),
write('with y (yes) or n (no).'),nl,nl.
collect_symptoms:- question(Ques,Sympt),write(Ques),nl,
getyesno(Yesno),nl,Yesno = y,
assertz(symptom(Sympt)),fail.
User Interface
collect_symptoms.
getyesno(X):- repeat,write('Please answer y or n: '),
read(Z),nl,check(Z),X = Z,!.
check(y). check(n).
Thank you