序言谓词 [英] Prolog predicates

查看:59
本文介绍了序言谓词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在学习 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.

  1. A 和 B 结婚了
  2. B 喜欢 C
  3. C和D结婚了
  4. D 喜欢 E
  5. F 喜欢 B
  6. E 喜欢 B
  7. E 和 G 结婚了
  8. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆