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

Prolog中元编程的语义

The Semantics of Metapropramming in Prolog

David S. Warren

AI总结:

该研究基于M. Denecker等人的思路,提出一种带否定的纯Prolog程序语义,通过参数化归纳定义构建命题模型与一阶Herbrand模型,为含变量头子句的元程序赋予直观含义,简化相关性质证明。

摘要:

本文描述了一种带否定的纯Prolog程序的语义,该语义为元程序赋予含义。元程序是将数据结构作为程序来构建和使用的程序。在Prolog中,一种主要的元编程结构是在子句体中使用变量作为文字。传统的Prolog三行元解释器是元程序的另一个例子。本文提出的语义还为以变量作为头的子句赋予了含义,尽管大多数Prolog系统并不支持这类子句。该语义自然地涵盖了这类程序,并赋予其直观含义。\n 该方法以M. Denecker及其同事的研究思路为基础。核心思路是注意到,如果我们为所有命题程序赋予含义,并将带变量的Prolog规则视为其基例的集合,那么我们就能为所有程序赋予含义。我们必须将Prolog规则(可能是元规则)视为生成基命题规则的模板,而非一阶公式(它们可能并非一阶公式)。我们使用参数化归纳定义为Prolog程序提供命题模型,其中命题是表达式。随后,命题模型的表达式集合确定了一个一阶Herbrand模型,为所有(纯)Prolog程序(包括元程序)提供了一阶逻辑语义。\n 我们通过示例展示了该理论的适用性。我们还证明了该理论如何让元程序一些重要性质的证明变得非常简单。

英文摘要:

This paper describes a semantics for pure Prolog programs with negation that provides meaning to metaprograms. Metaprograms are programs that construct and use data structures as programs. In Prolog a primary mataprogramming construct is the use of a variable as a literal in the body of a clause. The traditional Prolog 3-line metainterpreter is another example of a metaprogram. The account given here also supplies a meaning for clauses that have a variable as head, even though most Prolog systems do not support such clauses. This semantics naturally includes such programs, giving them their intuitive meaning. Ideas from M. Denecker and his colleagues form the basis of this approach. The key idea is to notice that if we give meanings to all propositional programs and treat Prolog rules with variables as the set of their ground instances, then we can give meanings to all programs. We must treat Prolog rules (which may be metarules) as templates for generating ground propositional rules, and not as first-order formulas, which they may not be. We use parameterized inductive definitions to give propositional models to Prolog programs, in which the propositions are expressions. Then the set of expressions of a propositional model determine a first-order Herbrand Model, providing a first-order logical semantics for all (pure) Prolog programs, including metaprograms. We give examples to show the applicability of this theory. We also demonstrate how this theory makes proofs of some important properties of metaprograms very straightforward.

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

↑