我在序言中有以下事实。
p(cold,[flu,high_body_temp,headache,dizzy],0.3],
p(cold,[flu,not high_body_temp,headache,dizzy],0.2],
p(cold,[flu,high_body_temp,not headache,dizzy],0.4],
p(cold,[flu,high_body_temp,headache,not dizzy],0.1],
p(cold,[not flu,high_body_temp,headache,dizzy],0.3],
p(cold,[flu,not high_body_temp,headache,not dizzy],0.3],
p(diarrhea,[headache,not stomachache,dizzy,vomit],0.5),
p(diarrhea,[headache,stomachache,not dizzy,vomit],0.4),
p(diarrhea,[headache,stomachache,dizzy,not vomit],0.2),
p(diarrhea,[not headache,stomachache,dizzy,vomit],0.1),
p(diarrhea,[headache,not stomachache,not dizzy,not vomit],0.1),
以及在运行时生成的列表,例如:
[flu,headache]
我们应该从包含 [flu,headache] 的“真实”元素的两个事实中得到答案,而“不”意味着该元素不存在:
p(cold,[flu,not high_body_temp,headache,not dizzy],0.3],
p(diarrhea,[headache,not stomachache,not dizzy,not vomit],0.1),
答案应该是:
cold = 0.3
diarrhea = 0.1
我如何在 prolog 中编写代码来完成这项工作?请帮助。我完全被困住了。TQ。