A Prolog Program for Bottom-up Evaluation

📅 2025-02-11
🏛️ Electronic Proceedings in Theoretical Computer Science
📈 Citations: 0
✨ Influential: 0
📄 PDF
🤖 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.

Technology Category

Knowledge Representation and Reasoning: Logic ProgrammingConstraint Satisfaction and Optimization: Satisfiability Modulo TheoriesReasoning under Uncertainty: Probabilistic Programming

Application Category

Semantics and Knowledge: Methods, algorithms and applications for the development of semantic models, knowledge graphs and other forms of structured data models with machine-interpretable semanticsGraph Algorithms and Modeling for the Web: Efficient manipulation of static and dynamic Web-related graphsUser Modeling, Personalization and Recommendation: Explainable and interpretable methods for personalization
📝 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.
Problem

Research questions and friction points this paper is trying to address.

Prolog program for bottom-up evaluation
Transforms object rules into metarules
Uses metainterpreter to compute program model
Innovation

Methods, ideas, or system contributions that make the work stand out.

Prolog metainterpreter for bottom-up evaluation
Transforms object rules into metarules
Semi-naive bottom-up evaluation algorithm