如何将信息放入prolog

时间:2013-01-26 20:53:39

标签: prolog logic weblogic-10.x

> The father sat to the right of the person who had corn, 
> who sat to the right of the person who ate pork, who sat to the right of the
> person who had baked potato, who sat to the right of the person who
> had peas.

如何将其转换为Prolog谓词?有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

我首先要说的是“对于有玉米的人是父亲的权利。吃猪肉的人就是拥有玉米的人。”然后使用谓词右(x,y)表示“对x是y的权利”。最终结果是:

right(corn, father).
right(pork, corn).
right(potato, pork).
right(peas, potato).