在DLV / Prolog中映射谓词和命题

时间:2015-11-09 23:49:19

标签: logic predicate zebra-puzzle answer-set-programming

我无法理解如何去做某事

想象一下,我有3头驴子,每只驴子都有一块最喜欢的布料,并在最喜欢的游乐场玩耍。

如果我给这些驴子限制哪个操场可以成为它最喜欢的游乐场,例如游乐场A,B或C,甚至可以通过暗示如Donkey humprhey最喜欢的布料来限制它最喜欢的布料。绝对不是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作为我的答案集解算器

0 个答案:

没有答案