Logic DLV/Prolog中谓词和命题的映射

Logic DLV/Prolog中谓词和命题的映射,logic,predicate,zebra-puzzle,answer-set-programming,Logic,Predicate,Zebra Puzzle,Answer Set Programming,我很难理解怎么做 想象一下,我有3头驴子,每头驴子都有一块自己喜欢的布,在自己喜欢的操场上玩耍 如果我给这些驴子一个约束,哪一个操场可能是它最喜欢的操场,比如操场A、B或C,或者甚至通过一个提示,比如驴子汉弗莱最喜欢的布料肯定不是T恤,我该怎么做呢 也就是说,到目前为止我的想法是 cloth(tshirt). cloth(socks). cloth(hat). playground(a). playground(b). playground(c). donkey(alphred). do

我很难理解怎么做

想象一下,我有3头驴子,每头驴子都有一块自己喜欢的布,在自己喜欢的操场上玩耍

如果我给这些驴子一个约束,哪一个操场可能是它最喜欢的操场,比如操场A、B或C,或者甚至通过一个提示,比如驴子汉弗莱最喜欢的布料肯定不是T恤,我该怎么做呢

也就是说,到目前为止我的想法是

cloth(tshirt).
cloth(socks).
cloth(hat).


playground(a).
playground(b).
playground(c).


donkey(alphred).
donkey(pumba).
donkey(sylvester).


%Would mapping be something like this?
donkeys(Donkey, Playground, Clothing) v donkeys(Donkey, Playground, Clothing) donkeys(Donkey, Playground, Clothing) :- donkey(Donkey), playground(Playground), cloth(Clothing).

%how would i add constraints based off this, such as alphreds favorite cloth is a tshirt but he hates playground b?

cloth(tshirt) :- donkey(alphred).
~playground(b) :- donkey(alphred).

%how do i also make sure no two donkeys have the same cloth and playground in the answer set?

我使用dlv作为我的答案集求解器

我是在dlv中完成的,但是dlv是基于prolog的,它们是类似的。没有问题,文档很难掌握,这就是我遇到问题的原因。地图上色的例子是我试图遵循的,你可以看一下