answer-set-programming - 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 条规则来获取答案集:
满足Π的规则。换句话说,如果你相信规则的主体,就相信它的头部。
不要相信矛盾。
坚持“理性原则”,即“什么都不相信,你不是被迫相信”。</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).
- 那么为什么我们需要这种否定作为失败呢?
- 我们可以只使用经典否定吗?
解决方案
我们可以只使用经典否定吗?
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.
推荐阅读
- javascript - 在没有验证错误的情况下自动清理 Formik 中的值
- swift - 由于 AKMIDIEvent 数据包长度,AKMIDIListener 未触发
- java - QueryException:JPA 样式的位置参数不是一个完整的序数
- java - Apache POI 模块未找到编译错误
- javascript - 例如,如何将已解析的承诺对象以字符串形式映射到按钮上
- ajax - 向 yii2 界面添加 loader/spinner
- android - 地理编码器地址中的类型不匹配
- weka - SMOTE 在 WEKA 中不可用
- mysql - mysql存储过程无法检索临时表
- android - 由于错误的实施,我是否有可能使我的应用程序中的 Stripe 支付变得不那么安全?