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

用于自底向上求值的Prolog程序

A Prolog Program for Bottom-up Evaluation

David S. Warren

AI总结:

本文提出一种简单直观的Prolog元解释器程序,通过转换对象程序规则为元规则,以半朴素自底向上方式计算正Horn子句定义的语义,其使用assert/1谓词的方式内在易懂,是独特的Prolog编程案例。

摘要:

本文介绍了一个简单直观的Prolog元解释器程序,用于计算简单正Horn子句定义的自底向上语义。该程序将对象程序规则转换为元规则,再通过元解释器自底向上计算原始程序的模型,所得算法是半朴素自底向上求值的一种形式。作者讨论了该程序有趣的原因,特别指出其使用Prolog的assert/1谓词是内在、易懂且最优的,堪称Prolog编程珍珠。

英文摘要:

This short paper describes a simple and intuitive Prolog program, a metainterpreter, that computes the bottom up meaning of a simple positive Horn clause definition. It involves a simple transformation of the object program rules into metarules, which are then used by a metainterpreter to compute bottom up the model of the original program. The resulting algorithm is a form of semi-naive bottom-up evaluation. We discuss various reasons why this Prolog program is particularly interesting. In particular, this is perhaps the only Prolog program for which I find the use of Prolog's assert/1 to be intrinsic, easily understood, and the best, most perspicuous, way to program an algorithm. This short paper might be best characterized as a Prolog programming pearl.

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

↑