我试图在Prolog中做以下事情:给出疾病知识库清单:
symptom(x, a).
symptom(x, b).
symptom(x, c).
symptom(y, b).
symptom(y, d).
symptom(z, c).
symptom(z, e).
现在,给出一系列症状[a, b]
,诊断可能的疾病:
diagnose(Symptom, Issue) :- symptom(Issue, Symptom).
diagnose([S|Tail], Issue) :- diagnose(S, Issue), diagnose(Tail, Issue).
通过SWI-Prolog运行,我收到了:
?- diagnose([a,b], Issue).
false.
预期:
Issue = x
问题1:我做错了什么? 问题2:如何修改它以返回x和y?即所有包含至少一种特定症状的潜在疾病?