如果对于一个事实的每个真值,另一个事实也为真,则为真

True if for every true value of a fact another fact is also true

我试过这个 hello,但我认为它不起作用。

kng_bck(1).
kng_bck(2).
kng_bck(3).

:- dynamic(p/1).

hello :- kng_bck(X), p(X).

% true if p(1). p(2). and p(3). are all defined, 
% that is for every true value of kng_bck(X), p(X) is
also true.

尝试使用 hello 的以下定义:

hello :- \+ (kng_bck(X), \+ p(X)).

下面的查询应该 return 为真:

?- assert(p(1)), assert(p(2)), assert(p(3)), hello.
当无法证明目标时,

\+/1 为真,因此 hello 的定义正在检查是否存在 notkng_bck(X) 不是 p(X)".


根据评论反馈更新:

您也可以使用 forall/2 来实现。示例:

?- assert(p(1)), assert(p(2)), assert(p(3)), forall(kng_bck(X), p(X)).