首页 > 解决方案 > Prolog 查询:- true,失败;不真实,不失败;真实,不失败

问题描述

我正在解决一个考试的测试,我得到了这个问题,答案如下:

在 shell 中运行它我得到 True,但我不明白这个答案是如何获得的。我得到了第一部分true, fail;,但其余部分是一个谜。我应该只看最后一部分true, not fail吗?

标签: prolog

解决方案


true, fail; not true, not fail; true, not fail

可以翻译成如下逻辑表达式:

(true and false) or (((not true) and (not false)) or (true and (not false)))

我们可以逐步简化...

(true and false) or ((false and true) or (true and true))

false or (false or true)

false or true

true


推荐阅读