% mpqtest.pl -- test file for MPQ

diagnosis(P,Diseases) :-
  bagof(D,(disease(D),
           demo(hasDisease(P,D))),
        Diseases).

%these are all the diseases
disease(commonCold).
disease(flu).
disease(colic).

% diagnostic rules.
hasDisease(P,commonCold)  if  
  symptom(P,fever) and 
  symptom(P,congestion) and 
  ~(hypocondriac(P)).

hasDisease(P,flu)  if  
  symptom(P,vomiting) and 
  symptom(P,fever).

hasDisease(P,colic)  if   
  infant(P) and 
  symptom(P,abdominalPain) and 
  ~(symptom(P,vomiting)).

% interaction support.
askable(symptom(_,_)).
toAsk(symptom(P,S),
      askYesNo("Does ~p show any signs of ~p?", [P,S])).

askable(hypocondriac(_)).
toAsk(hypocondriac(P),
      askYesNo("Is ~p a hypocondriac?", [P])).

askable(infant(_)).
toAsk(infant(P), 
      askYesNo("Is ~p less than one year old?", [P])).

