变量只使用一次

我使用古老的Turbo Prolog,因为它包含在我们的课程中。为什么这个程序不起作用?
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.
我得到的警告变量仅用于包含
symtoms
的所有行。参数是否通过引用传递调用?当我将
Fe
传递给
symptoms
时,该值应复制到
Fe
,当我在假设中对它进行比较时,它应该相应地起作用。 Turbo Prolog中的
=
操作员非常奇怪。当它没有绑定到任何变量时,语句
a = 3
将3分配给a,当a已经包含值
a = 5
时,将检查a的值是否为5。 请帮助我为什么程序不工作? 提前致谢 :)     
已邀请:
麻烦不在于你的
symptoms/3
谓词,他们会将他们的第三个参数绑定(统一)到
response/1
给出的。问题是这些值永远不会传递到
go/0
中的
hypothesis/2
程序中,因此它们永远不会用于尝试生成假设。 Prolog没有全局变量,因此您必须显式传递所有值,但是如果您不小心,可以将数据保存在数据库中,这很容易导致问题。 这意味着在
hypothesis/2
中,您没有测试
Fe
Ra
He
等的值,而是使用相同名称绑定局部变量。这也是为什么你得到只引用一次的变量的警告,你绑定它们但从不使用它们。记住它们是本地的,所有变量都是它们出现的子句的本地变量。 所有这些都适用于标准序言,我从未使用过Turbo Prolog。     

要回复问题请先登录注册