The Semantics of Metapropramming in Prolog

David S. Warren
{"title":"The Semantics of Metapropramming in Prolog","authors":"David S. Warren","doi":"arxiv-2408.07652","DOIUrl":null,"url":null,"abstract":"This paper describes a semantics for pure Prolog programs with negation that\nprovides meaning to metaprograms. Metaprograms are programs that construct and\nuse data structures as programs. In Prolog a primary mataprogramming construct\nis the use of a variable as a literal in the body of a clause. The traditional\nProlog 3-line metainterpreter is another example of a metaprogram. The account\ngiven here also supplies a meaning for clauses that have a variable as head,\neven though most Prolog systems do not support such clauses. This semantics\nnaturally includes such programs, giving them their intuitive meaning. Ideas from M. Denecker and his colleagues form the basis of this approach.\nThe key idea is to notice that if we give meanings to all propositional\nprograms and treat Prolog rules with variables as the set of their ground\ninstances, then we can give meanings to all programs. We must treat Prolog\nrules (which may be metarules) as templates for generating ground propositional\nrules, and not as first-order formulas, which they may not be. We use\nparameterized inductive definitions to give propositional models to Prolog\nprograms, in which the propositions are expressions. Then the set of\nexpressions of a propositional model determine a first-order Herbrand Model,\nproviding a first-order logical semantics for all (pure) Prolog programs,\nincluding metaprograms. We give examples to show the applicability of this theory. We also\ndemonstrate how this theory makes proofs of some important properties of\nmetaprograms very straightforward.","PeriodicalId":501197,"journal":{"name":"arXiv - CS - Programming Languages","volume":"8 1","pages":""},"PeriodicalIF":0.0000,"publicationDate":"2024-08-14","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"arXiv - CS - Programming Languages","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/arxiv-2408.07652","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

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.
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
Prolog中的元成语语义学
本文描述了纯 Prolog 程序的否定语义,它为元程序提供了意义。元程序是将数据结构作为程序来构造和使用的程序。在 Prolog 中,一个主要的元编程构造是在子句的主体中使用变量作为字面形式。传统的Prolog三行元解释器是元编程的另一个例子。尽管大多数 Prolog 系统都不支持以变量为首的子句,但这里给出的解释也为这种子句提供了一个含义。这种语义自然地包含了这类程序,赋予了它们直观的含义。来自德内克(M. Denecker)及其同事的想法构成了这一方法的基础。关键的想法是,如果我们给所有命题程序赋予意义,并将带有变量的 Prolog 规则视为其基础实例的集合,那么我们就能给所有程序赋予意义。我们必须把 Prolog 规则(可能是元规则)当作生成基础命题规则的模板,而不是一阶公式,因为它们可能不是一阶公式。我们使用参数化的归纳定义来给出 Prolog 程序的命题模型,其中的命题是表达式。然后,命题模型的表达式集决定了一阶 Herbrand 模型,为包括元程序在内的所有(纯)Prolog 程序提供了一阶逻辑语义。我们举例说明了这一理论的适用性。我们还演示了这一理论如何使元程序的一些重要属性的证明变得非常直接。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
Memory Consistency and Program Transformations No Saved Kaleidosope: an 100% Jitted Neural Network Coding Language with Pythonic Syntax Towards Quantum Multiparty Session Types The Incredible Shrinking Context... in a decompiler near you Scheme Pearl: Quantum Continuations
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1