如何在 Prolog 中取反 [英] How to negate in Prolog

查看:50
本文介绍了如何在 Prolog 中取反的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 PROLOG 的新手,正处于 此页面.鉴于规则父(X,Y)和男性(X),我试图将规则母亲(X,Y)定义为

I'm new to PROLOG and am at the very beginning of the exercises on this page. Given the rules parent(X, Y) and male(X), I'm trying to define a rule mother(X, Y) as

mother(X, Y) :-
    not(male(X)),
    parent(X, Y).

但是,在 GNU Prolog 中,我收到以下错误:

However, in GNU Prolog I get the following error:

| ?- mother(lina, julia).
uncaught exception: error(existence_error(procedure,not/1),mother/2)
| ?- 

推荐答案

\+/1 是 ISO Prolog 谓词否定".请注意,否定"在这里表示此时不可证明.

\+/1 is the ISO Prolog predicate to "negate". Note that "negate" means here not provable at that point.

您可以参考@false 的这个极好的答案以了解更多信息主题

You can refer to this excellent answer by @false for more on the subject

这篇关于如何在 Prolog 中取反的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆