Forward logic evaluation: Compiling a partially evaluated meta-interpreter into the WAM

  • Knut Hinkelmann
Technical Papers
Part of the Lecture Notes in Computer Science book series (LNCS, volume 671)


Forward chaining of a logic program is specified by a meta-interpreter written in Prolog. Premises of forward rules are verified by Prolog's backward proof procedure. Since meta-interpreters in general suffer from the overhead of the additional meta-layer, a well-known technique, partial evaluation of the metainterpreter wrt the object-level program, is applied to reduce this overhead. Still several sources of inefficiency can be identified after this transformation. To compile the forward program into the Warren Abstract Machine (WAM) in an efficient way, the WAM is modified by splitting the code area into a backward and forward code area and by adding a new stack to record derived facts. This shows how an efficient implementation of meta-interpreters can have an effect on compilation and even on the design of the target machine.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [Ban88]
    Bancilhon, F. and Ramakrishnan, R. Performance Evaluation of Data Intensive Logic Programs. In Foundations of Deductive Databases and Logic Programming. Morgan Kaufmann Publishers, Minker, J., pp. 441–517, Los Altos, CA, 1988.Google Scholar
  2. [Bol90]
    Boley, H. A relational/functional Language and its Compilation into the WAM. SEKI Report SR-90-05, Universität Kaiserslautern, 1990.Google Scholar
  3. [Cha87]
    Chan, D., Dufresne, P., and Enders, R. Report on PHOCUS. Technical Report TR-LP-21-02, ECRC, Arabellastraße, München, April, 1987.Google Scholar
  4. [Cos91]
    Cosmadopoulos, Y., Sergot, M., and Southwick,R.W. In PDK'91 — International Workshop on Processing Declarative Knowledge, 1991.Google Scholar
  5. [Emd76]
    Van Emden and Kowalski, R. The Semantics of Predicate Logic as a Programming Language Journal of the ACM, Vol. 23, No. 4, October 1976.Google Scholar
  6. [Fin89]
    Finin, T., Fritzson, R., and Matuszek, D. Adding Forward Chaining and Truth Maintenance to Prolog. In Artificial Intelligence Applications Conference, IEEE, Miami, March 1989, pp. 123–130.Google Scholar
  7. [For82]
    Forgy, C.L. Rete: A Fast Algorithm for the Many Pattern/Many Object Pattern Match Problem. Artificial Intelligence 19 (1982), pp. 17–37.CrossRefGoogle Scholar
  8. [Fur89]
    Furukawa, K., Fujita, H., and Shintani, T. Deriving an Efficient Production System by Partial Evaluation. In NACLP 89, 1989, pp. 661–671.Google Scholar
  9. [Gra89]
    Raisonment sur les contraintes en programmation Logique, PhD Thesis, University of Nice, 1989.Google Scholar
  10. [Har89]
    van Harmelen, F. On the Efficiency of Meta-level Inference. PhD Thesis, University of Edinburgh, 1989.Google Scholar
  11. [Hin91]
    Hinkelmann, K. Bidirectional Reasoning of Horn Clause Programs: Transformation and Compilation. Technical Memo TM-91-02, DFKI GmbH, January, 1991.Google Scholar
  12. [Hin91b]
    Hinkelmann, K. Forward Logic Evauation: Developing a Compiler from a Partially Evaluatred Meta-Interpreter. Technical Memo TM-91-13, DFKI GmbH, 1991.Google Scholar
  13. [Kom82]
    Komorowski, H.J. Partial Evaluation as a means for Inferencing Data Structures in an Applicative Language: A Theory and Implementation in the Case of Prolog. In POPL 82, 1982, pp. 255–267.Google Scholar
  14. [Llo87]
    Lloyd, J.W. Foundations of Logic Programming, Springer-Verlag, Berlin, Heidelberg, New York (1987).Google Scholar
  15. [Mir87]
    Miranker, D.P. TREAT: A Better Match Algorithm for AI Production Systems. In Proc. of AAAI-87, Philadelphia, PA, 1987, pp. 42–47.Google Scholar
  16. [Mor81]
    Morris, P. A Forward Chaining Problem Solver. Logic Programming Newsletter 2(Autumn 1981), pp. 6–7.Google Scholar
  17. [Naq89]
    Naqvi, S.A. and Tsur, S. A Logical Language for Data and Knowledge Bases, W.H. Freeman (1989).Google Scholar
  18. [Shi88]
    Shintani, T. A Fast Prolog-Based Production System KORE/IE. In Proceedings of the Fifth International Conference and Symposium on Logic Programming, 1988, pp. 26–41.Google Scholar
  19. [Tam84]
    Tamaki, H. and Sato, T. Unfold/Fold Transformations of Logic Programs. In Proceedings of the Second International Conference on Logic Programming, Uppsala, 1984, pp. 127–138.Google Scholar
  20. [Ull89]
    Ullman J. Principles of Database and Knowledge Base Systems, Computer Science Press (1989).Google Scholar
  21. [War83]
    Warren, D.H.D. An Abstract Prolog Instruction Set. Technical Note 309, SRI International, Menlo Park, CA, October, 1983.Google Scholar
  22. [Yam86]
    Yamamoto, A. and Tanaka, H. Translating Production Rules into a Forward Reasoning Prolog Program. New Generation Computing 4(1986), pp. 97–105.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1993

Authors and Affiliations

  • Knut Hinkelmann
    • 1
  1. 1.DFKIKaiserslauternGermany

Personalised recommendations