From: ELB
Subject: Prolog expert shell help required
Date: 
Message-ID: <a0ujkp$13q$1@paris.btinternet.com>
The problem I have is as follows:

To create an expert shell to read in the following



The predicate 'disease' has 4 arguments: a reference number for the disease,
followed by its name, its prior probability in the absence of any other
 information and a symptom list.

   The symptom list comprises a series of numbers in groups of three, one
group
   for each symptom associated with the disease, in the following order:

   (a) The reference number of the symptom
   (b) The probability of the symptom being present in patients who have
         the disease
   (c) The probability of the symptom being present in patients who do not
         have the disease

e.g)

disease(1,'Common
cold',0.02,[1,0.9,0.05,2,0.8,0.02,3,0.8,0.02,5,0.6,0.01,6,0.99,0.01,7,0.2,0.
01,8,0.5,0.01,15,0.8,0.01,34,0.01,0.01]).

The 'symptom' predicate has two arguments: a reference number for the
symptom,
   followed by a question that can be used to ask the user whether or not
the
   symptom is present

e.g)

symptom(1,'Are you sneezing a lot?').


I have used the following coding below before to calculate the probability
using bayes theroem, but I am stuck as to how to modify the following code
to calculate the probability to a symptom relating to a disease and how once
such calculations have been performed how to select an apporriate disease
and display it to the user.  All I'm looking for is the basics to get my
past this stage as I've been stuck for about a week and am a maths student
not a programmer (I need all the help I can get)

find_prob(Disease,Prob):-
   start_prob(Disease,Prior),calcprob(Disease,Prior,Prob),!.

calcprob(Disease,Prior,Post):-
findall([PEH,PEnotH],symptom(Disease,_,PEH,PEnotH),Problist),
calcprob2(Prior,Problist,Post).

calcprob2(Prior,[],Prior):-!.

calcprob2(Prior,[[PEH,PEnotH]|Rest],Post):-
Newval is (PEH*Prior)/((PEH*Prior)+(PEnotH)*(1-Prior)),
calcprob2(Newval,Rest,Post),!.

start_prob(brain_tumour,0.00002).
symptom(brain_tumour,headache,0.7,0.1).
symptom(brain_tumour,unsteadiness,0.1,0.01).
symptom(brain_tumour,depression,0.4,0.25).

Please can you offer any help (I only have 8 days till I have to produce a
working example ..ahh)

ELB