1
votes

For a school project I am attempting to write what is described as an "interactive diagnosis environment" using prolog. The user will enter a symptom, and a list of diseases that match the symptom will be printed to the screen. The user will then list another symptom, and diseases will be removed from the previous list if they do not match the second symptom, forming a new list. The new list is then printed.

example user input:
SYMPTOM_IN(fever, 150).
SYMPTOM_IN(vomiting, 1).

A list of possible diseases is printed after each input.

This process is repeated until a diagnosis is made or until it is somehow determined that it can't, at which point tests will be suggested and the user can input data regarding the tests in a similar manner, ultimately arriving at a diagnosis.

So far, all I have is a list of facts that will compile and that I can then interact with, but I really don't understand how I am supposed to carry over the list of diseases from one input to the next. I also don't understand how to move from taking symptom input to suggesting tests, although maybe that will be evident once I understand how to do the symptom input portion.

I would really appreciate any help.

Thanks.

EDIT:

Could I take the two values from the SYMPTOM_IN call, use them to do something like symptom(X, fever, 150)., and assert the output from that to store it (like in the answer to this question)? Then maybe I can do the same thing for the next call and take the union of the two lists?

1

1 Answers

0
votes

You want to create an expert system. There is a lot of info about it on the net. For example:

https://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_17.html http://www.amzi.com/ExpertSystemsInProlog/02usingprolog.php

There is also a lot of good info on Stack Overflow.

In short: you need to know how to use assert and retract in proper way.