arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1412.3480cs.PLcs.LO
收藏

超越Prolog的逻辑编程

Logic programming beyond Prolog

M. H. van Emden

摘要:

逻辑程序是一种可执行的规范。例如,合并排序在纯Prolog中是一个逻辑公式,但在长链表上显示出值得信赖的性能。但这种可执行的规范是一种妥协:逻辑被算法考虑扭曲,但只能通过抽象机器间接执行。本文介绍了关系编程,一种通过关注点分离解决逻辑编程困难的方法。它需要三个文本:(1)公理,一个指定问题并且不受算法考虑影响的逻辑公式,(2)定理,一个表达算法思想并遵循公理的逻辑公式,以及(3)代码,将定理转录为过程语言。代码的正确性依赖于定理与公理的逻辑关系,并依赖于定理到过程语言的准确转录。排序是关系编程具有更高抽象度优势的一个例子:要排序的数据可以是C++(我们在示例中使用的过程语言)中满足线性顺序公理的任何数据类型,而纯Prolog版本仅限于链接单元格形式的数据结构。我们展示了关系程序的另一个优点:它们具有模型理论和不动点语义,它们彼此等价,并且类似于纯Prolog程序。

英文摘要:

A logic program is an executable specification. For example, merge sort in pure Prolog is a logical formula, yet shows creditable performance on long linked lists. But such executable specifications are a compromise: the logic is distorted by algorithmic considerations, yet only indirectly executable via an abstract machine. This paper introduces relational programming, a method that solves the difficulty with logic programming by a separation of concerns. It requires three texts: (1) the axioms, a logical formula that specifies the problem and is not compromised by algorithmic considerations, (2) the theorem, a logical formula that expresses the idea of the algorithm and follows from the axioms, and (3) the code, a transcription of the theorem to a procedural language. Correctness of the code relies on the logical relationship of the theorem with the axioms and relies on an accurate transcription of the theorem to the procedural language. Sorting is an example where relational programming has the advantage of a higher degree of abstractness: the data to be sorted can be any data type in C++ (the procedural language we use in our examples) that satisfies the axioms of linear order, while the pure-Prolog version is limited to data structures in the form of linked cells. We show another advantage of relational programs: they have a model-theoretic and fixpoint semantics equivalent to each other and analogous to those of pure Prolog programs.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑