I am using ancient Turbo Prolog since it is included in our curriculum. Why is this program not working?
domains
    disease, indication = symbol
    Patient = string
    Fe,Ra,He,Ch,Vo,Ru = char
predicates
    hypothesis(Patient,disease)
    symptom(Patient,indication,char)
    response(char)
    go
clauses
    go:-
        write("What is patient's name?"),
        readln(Patient),
        symptom(Patient,fever,Fe),
        symptom(Patient,rash,Ra),   
        symptom(Patient,head_ache,He),  
        symptom(Patient,chills,Ch), 
        symptom(Patient,runny_nose,Ru),
        symptom(Patient,head_ache,He),  
        symptom(Patient,vomit,Vo),
        hypothesis(Patient,Disease),
        write(Patient," probably has ", Disease , "."),nl.
    go:-
        write("Sorry unable to seem to be diagnose disease"),nl.
    symptom(Patient,Fever,Feedback) :-
        Write("Does " , Patient , " have " , Fever , "(y/n) ?"),
        response(Reply),
        Feedback = Reply.
    hypothesis(Patient, chicken_pox) :-
        Fe = Ra = He = Ch = 'y'.
    hypothesis(Patient, caner) :-
        Ru = Ra = He = Vo = 'y'.
    hypothesis(Patient, measles) :-
        Vo = Ra = Ch = Fe = He = 'y'.
    response(Reply):-
        readchar(Reply),
        write(Reply),nl.
I get the warning variable is only used at all lines which contains symtoms. Isn't the parameter passing call by reference? When i pass Fe to symptoms the value should be copied to Fe and when i compare it in hypothesis it should work accordingly. = operator in Turbo Prolog works very strangely. When it is not bound to any variable, the statement a = 3 will assign 3 to a and when a already contains a value a = 5 will check whether a's value is 5 or not.
Kindly help me why is the program not working?
Thanks in advance :)
                        
The trouble is not with your
symptoms/3predicate, they will bind (unify) their 3rd argument to whatresponse/1gives. The problem is that these values are never passed into yourhypothesis/2procedure ingo/0so they are never used to try and generate a hypothesis. Prolog doesn't have global variables so you have to explicitly pass all values, though you can keep things in the database which can easily cause problems if you are not careful.This means that in
hypothesis/2you are not testing the values ofFe,Ra,He, etc but binding local variables with the same names. This is also why you get warnings of the variables only being referenced once, you bind them but never use them. Remember they are local, all variables are local to the clause in which they occur.All this applies to standard prolog, I have never used Turbo Prolog.