首页 > 解决方案 > ASP 中如何将否定理解为失败?

问题描述

假设我们有以下程序:

human(socrates).
day(tomorrow).
die(X) :- human(X).
may_go_to_school(Y) :- day(Y), 
                       not holiday(Y).

如果我们运行 clgo 来获取程序的答案集,我们得到

Answer: 1
human(socrates) day(tomorrow) die(socrates) may_go_to_school(tomorrow)

我们知道grounder会先将所有变量实例化为常量,所以grounder之后的程序是:

human(socrates).
day(tomorrow).
die(socrates) :- human(socrates).
may_go_to_school(tomorrow) :- day(tomorrow), 
                              not holiday(tomorrow).

我在Gelfond 的书中读到它给出了 3 条规则来获取答案集:

  1. 满足Π的规则。换句话说,如果你相信规则的主体,就相信它的头部。

  2. 不要相信矛盾。

  3. 坚持“理性原则”,即“什么都不相信,你不是被迫相信”。</p>

在规则中:

may_go_to_school(tomorrow) :- day(tomorrow), 
                              not holiday(tomorrow).

我们被否定为失败not holiday(tomorrow)

如本书所示:

符号not是一个新的逻辑连接词,称为默认否定,(或否定为失败);not l 通常被解读为“不相信 l 是真的”。请注意,这并不意味着 l 被认为是错误的。p一个理性的推理者既不相信陈述也不相信它的否定,这是可以想象的,实际上是很正常的¬p

那么根据规则 1,我应该相信believe in the head of a rule if you believe in its body身体not holiday(tomorrow).,因为我既不相信holiday(tomorrow).也不相信¬holiday(tomorrow).

根据答案,我应该相信¬holiday(tomorrow).

标签: answer-set-programmingnegation-as-failure

解决方案


我们可以只使用经典否定吗?

Well it seems we can't. The problem is that we can't implement logical negation. The main idea is that Prolog generates a model (Herbrand model) for your program-theory. When we add negation, semantics of the program change so that Prolog may not be able to find a model using sld resolution. So negation as failure has the advantage that we can have a negation (not exactly logical negation) and still not having problems with program semantics like we had with classical negation.

You can take a look in my relevant question: Logical Negation in Prolog. This question does not ask exactly the same thing as this question, but @j4n bur53 in his answer describes why we can't have logical negation.


推荐阅读