Welcome to the free medical advice (MAD) program.
Enter name of patient:
sneezy
Enter symptom (or hit return if no more symptoms):
fever
Enter symptom (or hit return if no more symptoms):
chest pain
Enter symptom (or hit return if no more symptoms):
Was patient in accident? (yes or no):
no
Patient: sneezy
Diagnosis: pneumonia
Prescribe: aspirin, antibiotic
Thank you for consulting MAD.
Final note: here is the only medical knowledge that should be encoded in your KB: Prescribe aspirin for fever, antibiotic for pneumonia, soup for flu or a cold, and pain killer for broken ribs. A patient with a fever and aches has flu. A patient with a fever and runny nose has a cold. A patient with chest pain and fever has pneumonia. A patient with chest pain and who was in an accident has broken ribs.
Additional information (added 2/11/03):
i. If your program gets an error message something like "No permission to modify static procedure" because the program tried to assert a predicate foobar, you need to include a directive at the top of your program declaring the predicate to be a dynamic predicate. For example, if your predicate is called 'symptom' and it takes 2 arguments, you would need the following directive:
:- dynamic symptom/2.
ii. Instead of having the user hit return to end entering symptoms,
you can have the user enter a special symbol.
iii. You may require the user to start the program by entering a special
query, e.g.
?- start.
Welcome to the ...
iv. If your program needs to handle multiple word input such as 'chest
pain', you may require the user to enclose the input in single quotes.
Also, you may require the user to enter a period to end the input.
2. Define a Prolog predicate called memberall(X, L)
that succeeds if and only if X is contained at some level of
nesting in list L. For example, your procedure should return the
following answers:
?- memberall( b, [a,b,c]).
yes
?- memberall( [b], [a,b,c]).
no
?- memberall( c, [a, b, [c]).
yes.
?- memberall( b, [a, [[b], c]).
yes.
?- memberall( [b], [a, [[b], c]).
yes.
?- memberall( [a], [a, [[b], c]).
no.