🤖 AI Summary
This paper addresses the bottom-up evaluation of positive Horn clause logic programs. Methodologically, it proposes a concise Prolog meta-interpreter that transforms original rules into meta-rules and employs `assert/1` to dynamically assert newly derived facts, thereby constructing the least Herbrand model via semi-naïve iteration. Crucially, `assert/1` is treated as semantically essential—not merely a pragmatic implementation device—enabling a natural and precise operational semantics for model construction. This design eliminates explicit set operations and complex control structures, preserving high code readability while guaranteeing semantic correctness. Experimental results demonstrate that the implementation achieves both theoretical clarity and engineering practicality. It establishes a novel paradigm for the principled modeling of side-effecting operations in logic programming and exemplifies the fruitful integration of Prolog metaprogramming with model-theoretic semantics.
📝 Abstract
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.