English

A Prolog Program for Bottom-up Evaluation

Programming Languages 2025-02-14 v1 Databases Logic in Computer Science

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.

Keywords

Cite

@article{arxiv.2502.09223,
  title  = {A Prolog Program for Bottom-up Evaluation},
  author = {David S. Warren},
  journal= {arXiv preprint arXiv:2502.09223},
  year   = {2025}
}

Comments

In Proceedings ICLP 2024, arXiv:2502.08453