Datalog、CLIPS、Prolog

发布于 2024-09-27 10:44:59 字数 173 浏览 0 评论 0原文

和很多程序员一样,我在大学里学过 Prolog,但只学了很少的部分。我理解Prolog和Datalog密切相关,但是Datalog更简单?另外,我相信我读到 Datalog 不依赖于逻辑子句的顺序,但我不确定为什么这是优点。 CLIPS 据说完全不同,但它对我来说太微妙了,无法理解。有人可以提供这些语言相对于其他语言的一般亮点吗?

As many programmers I studied Prolog in university, but only very little. I understand that Prolog and Datalog are closely related, but Datalog is simpler? Also, I believe that I read that Datalog does not depend on ordering of the logic clauses, but I am not sure why this is advantages. CLIPS is supposedly altogether different, but it is too subtle for me to understand. Can someone please to provide a general highlights of the languages over the other languages?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雪化雨蝶 2024-10-04 10:44:59

CLIPS 和 Prolog/Datalog 之间的区别在于,CLIPS 是一个通过前向链接运行的“产生式规则系统”:给定一组事实和规则,它将尝试对新事实进行各种可能的推导并将它们存储在内存中。然后通过检查查询是否与事实存储中的某些内容匹配来回答查询。因此,在 CLIPS 中,如果您有(伪语法):

parent(X,Y) => child(Y,X)
parent(john,mary)

它将立即派生 child(mary,john) 并记住这一事实。这可能非常快,但会限制可能的规则集并占用内存。

Prolog和Datalog通过向后链接进行操作,这意味着通过尝试证明查询来回答查询(谓词调用),即运行Prolog/Datalog程序。 Prolog是图灵完备的编程语言,因此任何算法都可以用它实现。

Datalog 是 Prolog 的非图灵完备子集,例如不允许否定。它的主要优点是每个 Datalog 程序都会终止(没有无限循环)。这使得它对于所谓的“演绎数据库”非常有用,即除了事实之外还具有规则的数据库。

The difference between CLIPS and Prolog/Datalog is that CLIPS is a "production rule system" that operates by forward chaining: given a set of facts and rules, it will try to make every possible derivation of new facts and store those in memory. A query is then answered by checking whether it matches something in the fact store. So, in CLIPS, if you have (pseudo-syntax):

parent(X,Y) => child(Y,X)
parent(john,mary)

it will immediately derive child(mary,john) and remember that fact. This can be very fast, but puts restrictions on the possible ruleset and takes up memory.

Prolog and Datalog operate by backward chaining, meaning that a query (predicate call) is answered by trying to prove the query, i.e. running the Prolog/Datalog program. Prolog is a Turing complete programming language, so any algorithm can be implemented in it.

Datalog is a non-Turing complete subset of Prolog that does not allow, e.g., negation. Its main advantage is that every Datalog program terminates (no infinite loops). This makes it useful for so-called "deductive databases," i.e. databases with rules in addition to facts.

海拔太高太耀眼 2024-10-04 10:44:59

datalog 是 prolog 的子集。数据日志携带的子集要考虑两件事:

  1. 采用支持规则和查询的 API
  2. ,确保所有查询终止

序言都是图灵完备的。数据记录不是。

抛开数据记录,让我们看看序言与剪辑的比较。

prolog的专长是“解决问题”,而clips是“专家系统”。如果我理解正确的话,“解决问题”涉及使用代码和数据的专业知识。 “专家系统”大多使用数据结构来表达专业知识。请参阅http://en.wikipedia.org/wiki/Expert_system#Comparison_to_problem-solving_systems

另一种查看方式事实是:

专家系统的运行前提是大多数(如果不是全部)结果都是已知的。所有这些结果都被编译成数据,然后输入专家系统。给专家系统一个场景,专家系统根据编译的数据(也称为知识库)计算结果。这始终是一种“偶数加偶数总是偶数”的想法。

问题解决系统对问题的看法不完整。因此,我们从建模数据和行为开始,这将构成知识库(这合理地解释了“极端情况”一词),最后得到“如果我们将二加六,我们最终得到八。八可以被两个?那么它是偶数”

datalog is a subset of prolog. the subset which datalog carries has two things in mind:

  1. adopt an API which would support rules and queries
  2. make sure all queries terminate

prolog is Turing complete. datalog is not.

getting datalog out of the way, let's see how prolog compares with clips.

prolog's expertise is "problem solving" while clips is an "expert system". if i understand correctly, "problem solving" involves expertise using code and data. "expert systems" mostly use data structures to express expertise. see http://en.wikipedia.org/wiki/Expert_system#Comparison_to_problem-solving_systems

another way to look at it is:

expert systems operate on the premise that most (if not all) outcomes are known. all of these outcomes are compiled into data and then is fed into an expert system. give the expert system a scenario, the expert system computes the outcome from the compiled data, aka knowledge base. it's always a "an even number plus an even number is always even" kind of thinking.

problem solving systems have an incomplete view of the problem. so one starts out with modeling data and behavior, which would comprise the knowledge base (this gives justice to the term "corner case") and ends up with "if we add two to six, we end up with eight. is eight divisible by two? then it is even"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文