prolog - Prolog 中的谓词逻辑是如何表示的?

标签 prolog logic

可能是一个奇怪而广泛的问题,而不是 100% 的编程问题,但我希望这没问题。我最近讨论过,Prolog 中的许多程序不遵循严格的谓词逻辑(Frege),但通常是“面向对象的”,我试图掌握这一点。
我知道 Prolog 基于一阶谓词逻辑,尤其是 Horn 子句,并且它们是一种特殊形式的 modus ponens。单独出现的事实和规则只是从句,但是一旦我添加了多个出现,它们就变成了谓词。
一般而言,一阶谓词逻辑的量词如何表示并与事实、规则、谓词或 Prolog 概念相关?仿函数表达什么以及与谓词逻辑相关的参数是什么。谓词逻辑和一阶谓词逻辑在Prolog中是如何体现的,prolog的概念在哪里?例如我将如何在谓词逻辑和一阶谓词逻辑中定义点、线和垂直线。
我如何在谓词逻辑和一阶谓词逻辑中表述它之间的语义和逻辑区别是什么

vertical(line).
line(vertical).
或者在这个例子中是一条线和一个点。点和线不是谓词逻辑吗?
对我来说,它是“点(X)所有点的集合”,当我选择一个具体点时“存在一个点(110、12)”。
point(X,Y).
line(point(W,X), point(Y,Z)).

vertical(line(point(X,Y), point(X,Z))).
horizontal(line(point(X,Y), point(Z,Y))).
任何信息都有帮助!非常感谢,H

最佳答案

一章Programming in Prolog由 W.Clocksin 和 C.Mellish 编写,致力于解释 Prolog 与逻辑的关系。从那里引用

If we wish to discuss how Prolog is related to logic, we must first establish what we mean by logic. Logic was originally devised as a way of representing the form of arguments, so that it would be possible to check in a formal way whether or not they are valid. Thus we can use logic to express propositions, the relations between propositions and how one can validly infer some propositions from others. The particular form of logic that we will be talking about here is called the Predicate Calculus. We will only be able to say a few words about it here. There are scores of good basic introductions to logic you can turn to for background reading.

If we wish to express propositions about the world, we must be able to describe the objects that are involved in them. In Predicate Calculus, we represent objects by terms. A term is of one of the following forms:

  • A constant symbol. This is a symbol that stands for a single individual or concept. We can think of this as a Prolog atom, and we will use the Prolog syntax. So greek, agatha, and peace are constant symbols.
  • A variable symbol. This is a symbol that we may want to stand for different individuals at different times. Variables are really only introduced in conjunction with quantifiers, which are discussed below. We can think of them as Prolog variables and will use the Prolog syntax. Thus X, Man, and Greek are variable symbols.
  • A compound term. A compound term consists of a function symbol, together with an ordered set of terms as its arguments. The idea is that the compound term represents some individual that depends on the individuals represented by the arguments. The function symbol represents how the first depends on the second. For instance, we could have a function symbol standing for the notion of "distance" and two arguments. In this case, the compound term stands for the distance between the objects represented by the arguments. We can think of a compound term as a Prolog structure with the function symbol as the functor. We will write Predicate Calculus compound terms using the Prolog syntax, so that, for instance, wife(henry) might mean Henry's wife, distance(point1, X) might mean the distance between some particular point and some other place to be specified, and classes(mary, dayafter(W)) might mean the classes that Mary teaches on the day after some day W to be specified.

Thus in Predicate Calculus the ways of representing objects are just like the ways available in Prolog.


把整章放在这里似乎不太合适……还有一个程序,非常有说明性,在附录 B 中,它执行 WFF 的自动翻译。 s 成子句。
这本书可读性很强,可惜不在Free Prolog Programming Books的书名之列。部分。

关于prolog - Prolog 中的谓词逻辑是如何表示的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62620171/

相关文章:

prolog - 子句开头的算术运算

pdf - 如何使用 Prolog 打印 PDF 文件

Prolog - 更简洁的规则定义方式

prolog - 如何在序言中实现相应的功能

c++ - << 的运算符重载需要 const;产生头痛

security - 使用本地服务器为程序提供基于浏览器的 GUI 会带来哪些安全风险?

c - 确定 32 位 int 的符号

java - 字符串数组大小和 for 循环访问元素

c# - 字符串数组搜索

java - 使用 3 个数学运算符的所有可能组合填充 2D 数组