Specialising meta-level compositions of logic programs

  • Antonio Brogi
  • Simone Contiero
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1207)


Meta-level compositions of object logic programs are naturally implemented by means of meta-programming techniques. Metainterpreters defining program compositions however suffer from a computational overhead that is due partly to the interpretation layer present in all meta-programs, and partly to the specific interpretation layer needed to deal with program compositions. We show that meta-interpreters implementing compositions of object programs can be fruitfully specialised w.r.t. meta-level queries of the form Demo(E,G), where E denotes a program expression and G denotes a (partially instantiated) object level query. More precisely, we describe the design and implementation of a declarative program specialiser that suitably transforms such metainterpreters so as to sensibly reduce — if not to completely remove — the overhead due to the handling of program compositions. In many cases the specialiser succeeds in eliminating also the overhead due to meta-interpretation.


Logic Program Logic Programming Object Program Partial Evaluation Program Expression 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    J. Barklund. Metaprogramming in Logic. In A. Kent and J.G. Williams, editors, Encyclopedia of Computer Sciene and Technology, chapter 33, pages 205–227. Marcel Dekker, 1995.Google Scholar
  2. 2.
    K. Benkerimi and J.W. Lloyd. A Partial Evaluation Procedure for Logic Programs. In S. Debray and M. Hermenegildo, editors, Logic Programming: Proceedings of the 1990 North American Conference, pages 343–358. The MIT Press, 1990.Google Scholar
  3. 3.
    A. F. Bowers and C. A. Gurr. Towards Fast and Declarative Meta-Programming. In K. Apt and F. Turini, editors, Meta-Logics and Logic Progamming, chapter 2, pages 137–166. The MIT Press, 1995.Google Scholar
  4. 4.
    A. Brogi. Program Construction in Computational Logic. PhD thesis, Department of Computer Science, University of Pisa, 1993.Google Scholar
  5. 5.
    A. Brogi and S. Contiero. Composing logic programs by meta-programming in Gödel. In K. Apt and F.Turini, editors, Meta-programming and Logic Programming, chapter 7, pages 167–194. The MIT Press, 1995.Google Scholar
  6. 6.
    A. Brogi and S. Contiero. A Program Specialiser for Meta-level Compositions of Logic Programs. TR 96-20, Dpt. of Computer Science, University of Pisa, 1996.Google Scholar
  7. 7.
    A. Brogi, P. Mancarella, D. Pedreschi, and F. Turini. Modular Logic Programming. ACM Transactions on Programming Languages and Systems, 16(4):1361–1398, 1994.Google Scholar
  8. 8.
    A. Brogi, C. Renso, and F. Turini. Amalgamating Language and Meta-Language for Composing Logic Programs. In M. Alpuente, R. Barbuti, and I. Ramos, editors, Proc. of the GULP-PRODE'94 Joint Conference, vol.2, pages 408–422, 1994.Google Scholar
  9. 9.
    A. Brogi and F. Turini. Meta-Logic for Program Composition: Semantics Issues. In K.R. Apt and F. Turini, editors, Meta-logics and Logic Programming, chapter 4, pages 83–110. The MIT Press, 1995.Google Scholar
  10. 10.
    M. Bruynooghe, D. De Schreye, and B. Martens. A General Criterion for Avoiding Infinite Unfolding during Partial Evaluation. New Generation Computing, 11(1):47–79, 1992.Google Scholar
  11. 11.
    M. Bugliesi, E. Lamma, and P. Mello. Partial Deduction for Structured Logic Programming. Journal of Logic Programming, 16(1, 2):89–122, 1993.Google Scholar
  12. 12.
    S. Costantini, P. Dell'Acqua, and G. A. Lanzarone. Extending Horn Clauses Theories by Reflection Principles. In M. MacNish, D. Pearce, and L. M. Pereira, editors, Logics in Artificial Intelligence, LNAI 838, pages 400–413. Springer-Verlag, 1994.Google Scholar
  13. 13.
    Y. Futamura. Partial Computation of Programs. In J. Hartmanis and G. Goos, editors, RIMS Symp. on Software Science and Engineering, LNCS 147, pages 1–35. Springer-Verlag, 1982.Google Scholar
  14. 14.
    J. Gallagher. Transforming Logic Programs By Specialising Interpreters. In ECAI-86, pages 313–326, 1986.Google Scholar
  15. 15.
    J. Gallagher. A System For Specialising Logic Programs. Technical Report 91-32, University of Bristol, 1991.Google Scholar
  16. 16.
    J. Gallagher. Tutorial on Specialisation of Logic Programs. In Proceedings PEPM93, ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pages 88–98. ACM Press, 1993.Google Scholar
  17. 17.
    J. Gallagher and M. Bruynooghe. Some Low-Level Source Transformations for Logic Programs. In M. Bruynooghe, editor, Proceedings of the Second Workshop on Meta-Programming in Logic, Leuven, Belgium, pages 229–244, 1990.Google Scholar
  18. 18.
    J. Gallagher and M. Bruynooghe. The Derivation of an Alghoritm for Program Specialisation. New Generation Computing, 9(3–4):305–333, 1991.Google Scholar
  19. 19.
    C.A. Gurr. A Self-Applicable Partial Evaluator for the Logic Programming Language Gödel. PhD thesis, University of Bristol, 1994.Google Scholar
  20. 20.
    P. Hill and J. Gallagher. Metaprogramming in Logic programming. In A. Robinson and C. Hogger, editors, Handbook of Logic in Artificial Intelligence and Logic Programming, chapter 5. Oxford University Press, 1996.Google Scholar
  21. 21.
    P.M. Hill and J.W. Lloyd. Analysis of metaprograms. In H.D. Abramson and M.H. Rogers, editors, Metaprogramming in Logic Programming, pages 23–52. The MIT Press, 1989.Google Scholar
  22. 22.
    P.M. Hill and J.W. Lloyd. The Gödel Programming Language. The MIT Press, 1994.Google Scholar
  23. 23.
    J. Jørgensen, M. Leuschel, and B. Martens. Conjunctive Partial Deduction. In J. Gallagher (editor) Pre-proceedings of LOPSTR-96, pages 46–62, 1996.Google Scholar
  24. 24.
    J. Komorowski. An Introduction to Partial Deduction. In A. Pettorossi, editor, Meta-Programming in Logic, LNCS 649, pages 49–69. Springer-Verlag, 1996.Google Scholar
  25. 25.
    E. Lamma, P. Mello, and A. Natali. Reflection Mechanisms for Combining Prolog Databases. Software: Practice and Experience, 21(6):603–624, 1991.Google Scholar
  26. 26.
    M. Leuschel and B. Martens. Partial Deduction of the Ground Representation and its Application to Integrity Checking. In John Lloyd, editor, Proceedings of ILPS'95, pages 495–509. The MIT Press, 1995.Google Scholar
  27. 27.
    M. Leuschel and B. Martens. Global Control for Partial Deduction through Characteristic Atoms and Global Trees. In Proceedings of the 1996 Dagstuhl Seminar on Partial Evaluation, LNCS 1110, pages 263–283, 1996.Google Scholar
  28. 28.
    M. Leuschel and D. De Schreye. An Almost Perfect Abstract Operation for Partial Deduction Using Characteristic Trees. In Technical Report CW 215, October 1995.Google Scholar
  29. 29.
    G. Levi and G. Sardu. Partial Evaluation of Metaprograms in a “Multiple Worlds” Logic Language. New Generation Computing, 6(2,3):227–247, 1988.Google Scholar
  30. 30.
    J.W. Lloyd. Foundations of logic programming. Springer-Verlag, 2nd, 1987.Google Scholar
  31. 31.
    J.W. Lloyd and J.C. Shepherdson. Partial evaluation in logic programming. Journal of Logic Programming, 11:217–242, 1991.Google Scholar
  32. 32.
    B. Martens and J. Gallagher. Ensuring Global Termination of Partial Deduction while Allowing Flexible Polyvariance. In L. Sterling, editor, Proceedings of ICLP95, pages 597–611. The MIT Press, 1995.Google Scholar
  33. 33.
    B. Martens and D. De Schreye. Why untyped non-ground meta-programming is not (much of) a problem. Journal of Logic Programming, 22(1):47–99, 1995.Google Scholar
  34. 34.
    B. Martens and D. De Schreye. Automatic Finite Unfolding using Well-Founded Measures. In Journal of Logic Programming, 1996 (to appear).Google Scholar
  35. 35.
    B. Martens, D. De Schreye, and T. Horváth. Sound and Complete Partial Deduction with Unfolding Based on Well-Founded Measures. Theoretical Computer Science, 122(1–2):97–117, 1995.Google Scholar
  36. 36.
    L. Monteiro and A. Porto. Contextual logic programming. In G. Levi and M. Martelli, editors, Proceedings Sixth ICLP, pages 284–302. The MIT Press, 1989.Google Scholar
  37. 37.
    S. Owen. Issues in the Partial Evaluation of Meta-Interpreters. In H. Abramson and M.H. Rogers, editors, Meta-Programming in Logic Programming, pages 319–340. The MIT Press, 1989.Google Scholar
  38. 38.
    A. Pettorossi and M. Proietti. Transformations of logic programs: Foundations and techniques. The Journal of Logic Programming, 19 & 20:261–320, 1994.Google Scholar
  39. 39.
    D. Sahlin. An Automatic Partial Evaluator for Full Prolog. PhD thesis, KTH, Dpt. of Telecommunications and Computer Systems, Stockolm, Sweden, 1991.Google Scholar
  40. 40.
    M. Sørensen and R. Glück. An Algorithm of Generalization in Positive Supercompilation. In John Lloyd, editor, Proceedings of ILPS'95, the International Logic Programming Symposium, pages 465–479. The MIT Press, 1995.Google Scholar
  41. 41.
    L. Sterling and E. Shapiro. The Art of Prolog. The MIT Press, 1986.Google Scholar
  42. 42.
    A. Takeuchi. Affinity between meta interpreters and partial evaluation. In H.-J. Kugler, editor, Information Processing 86, pages 279–282. North-Holland, 1986.Google Scholar
  43. 43.
    A. Takeuchi and K. Furukawa. Partial evaluation of Prolog programs and its application to meta-programming. In H.-J. Kugler, editor, Information Processing 86, pages 415–420. North-Holland, 1986.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1997

Authors and Affiliations

  • Antonio Brogi
    • 1
  • Simone Contiero
    • 1
  1. 1.Dipartimento di InformaticaUniversità di PisaPisaItaly

Personalised recommendations