Prolog 查询返回 H128 [英] Prolog Query returning H128
问题描述
在下面的查询中,首先我得到 X = H128
,它来自哪里?另外为什么它返回是?是不是因为变量 X
实际上没有定义而我们正在测试该条件?
In the query below, firstly I'm getting X = H128
, where does that come from? Also why is it returning yes? Is it because the variable X
is actually not defined and we are testing for that condition?
?- not(X==3).
X = H128
yes
推荐答案
您的查询正在使用未实例化的变量 (X).当检查 X 是否用术语 3 it (X==3) 实例化时,它失败,因为 X 未实例化.
Your query is using an uninstantiated variable (X). When checking whether X is instantiated with the term 3 it (X==3) it fails because X is uninstantiated.
因此,not(X==3) 会成功,因为 prolog 引擎无法证明 X==3.因此,您的序言解释器返回是"(由于解释器的失败方法否定),并且 X 保持未实例化.
Therefore, not(X==3) will succeed as the prolog engine cannot prove X==3. Your prolog interpreter is thus returning 'yes' (due to the negation as failure approach of the interpreter), and X remains uninstantiated.
这就是解释器显示 X = H128 的原因,其中 H128 是一个虚拟的未实例化变量.
That is why the interpreter shows X = H128, where H128 is a dummy uninstantiated variable.
这篇关于Prolog 查询返回 H128的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!