arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1107.5408cs.PL
收藏

Prolog的结构化替代方案,具有简单的组合语义

A structured alternative to Prolog with simple compositional semantics

António Porto

摘要:

Prolog非常有用的表达能力是传统的逻辑编程语义所不能捕捉的,主要是由于cut、goal和子句顺序。已经提出了几种替代语义,暴露了计算状态的操作细节。我们建议,而不是重新设计Prolog结构化的替代方案,以削减和条款,保持表达能力和计算模型,但组成的指称语义更简单的状态,只是变量绑定。这大大简化了程序员和工具(如部分求值器)对程序的推理,并通过谓词定义安全地展开调用。if-then-else across子句取代了cut的大多数用法,但cut的全部功能是通过until结构实现的。析取、合取、until和统一是基本的目标类型,具有组合语义,产生变量绑定解决方案的序列。这通过最小不动点构造的通常技术扩展到程序。一个简单的解释器Prolog的替代语言,直到在Prolog的定义,建立了相同的表达能力的两种语言。许多有用的控制结构都是从原语中派生出来的,语义框架阐明了对替代结构的讨论。形式化依赖于具有变量抽象的术语语言,如λ-演算中。子句是调用参数、延续和局部变量的抽象。它可以是包含性的,也可以是排他性的,表示通过析取或if-then-else绑定到延续的局部情况。子句是开放的定义,由简单的函数应用(β-归约)组成(和封闭)。这为灵活的模块组合机制的简单说明铺平了道路。Cube是一种具有公开原则的具体语言,已经实现。

英文摘要:

Prolog's very useful expressive power is not captured by traditional logic programming semantics, due mainly to the cut and goal and clause order. Several alternative semantics have been put forward, exposing operational details of the computation state. We propose instead to redesign Prolog around structured alternatives to the cut and clauses, keeping the expressive power and computation model but with a compositional denotational semantics over much simpler states-just variable bindings. This considerably eases reasoning about programs, by programmers and tools such as a partial evaluator, with safe unfolding of calls through predicate definitions. An if-then-else across clauses replaces most uses of the cut, but the cut's full power is achieved by an until construct. Disjunction, conjunction and until, along with unification, are the primitive goal types with a compositional semantics yielding sequences of variable-binding solutions. This extends to programs via the usual technique of a least fixpoint construction. A simple interpreter for Prolog in the alternative language, and a definition of until in Prolog, establish the identical expressive power of the two languages. Many useful control constructs are derivable from the primitives, and the semantic framework illuminates the discussion of alternative ones. The formalisation rests on a term language with variable abstraction as in the λ-calculus. A clause is an abstraction on the call arguments, a continuation, and the local variables. It can be inclusive or exclusive, expressing a local case bound to a continuation by either a disjunction or an if-then-else. Clauses are open definitions, composed (and closed) with simple functional application (β-reduction). This paves the way for a simple account of flexible module composition mechanisms. Cube, a concrete language with the exposed principles, has been implemented.

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

↑