序言谓词 [英] Prolog predicates
问题描述
我目前正在学习 Prolog 中的谓词逻辑.我在回答有关该主题的问题时遇到问题,想知道使用 Prolog 谓词解决此类问题所采取的步骤.我有一个场景,必须在 Prolog 谓词中仅使用两个不同的谓词名称来表示.
I am currently learning about predicate logic in Prolog. I am having trouble answering a question on the topic and would like to know the steps one one take to solve such a question using Prolog predicates. I have a scenario which must be represented in Prolog predicates using only two different predicate names.
- A 和 B 结婚了
- B 喜欢 C
- C和D结婚了
- D 喜欢 E
- F 喜欢 B
- E 喜欢 B
- E 和 G 结婚了
- A 喜欢 G
推荐答案
只需写下内容即可.
are_married(a,b).
likes(b,c).
等等.到目前为止,我们已经使用了两个谓词名称.
And so on. We've used two names of predicates so far.
在 Prolog 中,原子由以小写字母开头的标识符表示.以大写字母或下划线开头的标识符 _
表示逻辑变量.
In Prolog, atoms are denoted by identifiers starting with a lower case letter. Identifiers starting with an upper case letter or an underscore _
denote logical variables.
这篇关于序言谓词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!