Prolog逻辑推理和翻译

时间:2013-08-19 14:07:34

标签: prolog logic rule-engine

我在一阶逻辑中有一组真正的语句和条件语句,我想用prolog来解决。但是,我无法优雅地表达我的事实和条件。

例如,假设我想表达以下内容:

He drinks tea.
she does not drink tea if he does not drink tea.
either she likes soda or tea but not both
if she likes soda then he does not like tea.

以上是一个愚蠢的例子,我注意到逻辑演绎感兴趣。我有兴趣直接翻译成prolog,以便我们可以开始演绎。这是我的尝试:

Drink_Tea(He).
/* I can't seem to find a not operator, so I'll use !*/
!Drink_Tea(She) :- !Drink_Tea(He).
likes(Soda, She) ; likes(tea, She) , !likes(Soda, She) , !likes(Tea, She).
!likes(Tea, He) :- likes(Soda, She).

非常感谢所有帮助!如果您需要更多信息,请与我们联系。

修改 在prolog文件中,为什么我不能为变量not(p) ; not(q)p编写诸如q之类的“事实”?

1 个答案:

答案 0 :(得分:0)

The Clocksin和Mellish Prolog一书中描述了一个逻辑命题的翻译,这个翻译的逻辑命题可能是有用的,或者至少可以给你一些想法。我有一个Logtalk示例,部分基于您可以使用的翻译器:

Logtalk Example