Enhancing partial deduction via unfold/fold rules

  • Alberto Pettorossi
  • Maurizio Proietti
  • Sophie Renault
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1207)

Abstract

We show that sometimes partial deduction produces poor program specializations because of its limited ability in (i) dealing with conjunctions of recursively defined predicates, (ii) combining partial evaluations of alternative computations, and (iii) taking into account unification failures. We propose to extend the standard partial deduction technique by using versions of the definition rule and the folding rule which allow us to specialize predicates defined by disjunctions of conjunctions of goals. We also consider a case split rule to take into account unification failures. Moreover, in order to perform program specialization via partial deduction in an automatic way, we propose a transformation strategy which takes as parameters suitable substrategies for directing the application of every transformation rule.

Finally, we show through two examples that our partial deduction technique is superior to standard partial deduction. The first example refers to the automatic derivation of the Knuth-Morris-Pratt string matching algorithm, and the second example refers to the construction of a parser for a given regular expression. In both examples, the specialized programs are derived starting from naive, non-deterministic initial programs, whereas standard partial deduction can derive similar specialized programs only when complex, deterministic initial programs are provided.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    A. Bossi and N. Cocco. Preserving universal termination through unfold/fold. In Proceedings ALP '94, Lecture Notes in Computer Science 850, pages 269–286. Springer-Verlag, 1994.Google Scholar
  2. 2.
    R. M. Burstall and J. Darlington. A transformation system for developing recursive programs. Journal of the ACM, 24(1):44–67, January 1977.CrossRefGoogle Scholar
  3. 3.
    J. Cook and J. P. Gallagher. A transformation system for definite programs based on termination analysis. In L. Fribourg and F. Turini, editors, Proceedings of LOPSTR'94 and META'94, Pisa, Italy, Lecture Notes in Computer Science 883, pages 51–68. Springer-Verlag, 1994.Google Scholar
  4. 4.
    Y. Deville. Logic Programming: Systematic Program Development. Addison-Wesley, 1990.Google Scholar
  5. 5.
    H. Fujita. An algorithm for partial evaluation with constraints. Technical Memorandum TM-0367, ICOT, Tokyo, Japan, 1987.Google Scholar
  6. 6.
    J. P. Gallagher. Tutorial on specialization of logic programs. In Proceedings of ACM SIGPLAN Symposium on Partial Evaluation and Semantics Based Program Manipulation, PEPM '93, Copenhagen, Denmark, pages 88–98. ACM Press, 1993.Google Scholar
  7. 7.
    M. Gergatsoulis and M. Katzouraki. Unfold/fold transformations for definite clause programs. In M. Hermenegildo and J. Penjam, editors, Proceedings Sixth International Symposium on Programming Language Implementation and Logic Programming (PLILP '94), Lecture Notes in Computer Science 844, pages 340–354. Springer-Verlag, 1994.Google Scholar
  8. 8.
    R. Glück and A. V. Klimov. Occam's razor in metacomputation: the notion of a perfect process tree. In P. Cousot, M. Falaschi, G. Filé, and A. Rauzy, editors, 3rd International Workshop on Static Analysis, Padova, Italy, September 1993, Lecture Notes in Computer Science 724, pages 112–123. Springer-Verlag, 1993.Google Scholar
  9. 9.
    N. D. Jones, C. K. Gomard, and P. Sestoft. Partial Evaluation and Automatic Program Generation. Prentice Hall, 1993.Google Scholar
  10. 10.
    M. Leuschel, D. De Schreye, and A. de Waal. A conceptual embedding of folding into partial deduction: Towards a maximal integration. In M. Maher, editor, Proceedings of the Joint International Conference and Symposium on Logic Programming, Bonn, Germany, pages 319–332. MIT Press, 1996.Google Scholar
  11. 11.
    M. Leuschel and B. Martens. Global control for partial deduction through characteristic atoms and global trees. Report CW 220, K.U. Leuven, Belgium, 1995.Google Scholar
  12. 12.
    M. Leuschel and M. H. Sørensen. Redundant argument filtering of logic programs. In J. Gallagher, editor, Logic Program Synthesis and Transformation, Proceedings LOPSTR '96, Stockholm, Sweden. Report no. 96-020 Stockholm University., pages 63–77. Springer-Verlag, 1996. (To appear).Google Scholar
  13. 13.
    J. W. Lloyd and J. C. Shepherdson. Partial evaluation in logic programming. Journal of Logic Programming, 11:217–242, 1991.Google Scholar
  14. 14.
    T. Mogensen and A. Bondorf. Logimix: A self-applicable partial evaluator for Prolog. In K.-K. Lau and T. Clement, editors, Logic Program Synthesis and Transformation, Proceedings LOPSTR '92, Manchester, U.K., Workshops in Computing, pages 214–227. Springer-Verlag, 1993.Google Scholar
  15. 15.
    A. Pettorossi and M. Proietti. Transformation of logic programs: Foundations and techniques. Journal of Logic Programming, 19, 20:261–320, 1994.Google Scholar
  16. 16.
    A. Pettorossi, M. Proietti, and S. Renault. Reducing nondeterminism while specializing logic program. In Proc. 24-th ACM Symposium on Principles of Programming Languages, Paris, France. ACM Press, 1997. (To appear).Google Scholar
  17. 17.
    S. Prestwich. Online partial deduction of large programs. In Proceedings ACM Sigplan Symposium on Partial Evaluation and Semantics-Based Program Manipulation, PEPM '93, Copenhagen, Denmark, pages 111–118. ACM Press, 1993.Google Scholar
  18. 18.
    M. Proietti and A. Pettorossi. Semantics preserving transformation rules for Prolog. In ACM Symposium on Partial Evaluation and Semantics Based Program Manipulation, PEPM '91, Yale University, New Haven, Connecticut, USA, pages 274–284. ACM Press, 1991.Google Scholar
  19. 19.
    M. Proietti and A. Pettorossi. Unfolding-definition-folding, in this order, for avoiding unnecessary variables in logic programs. Theoretical Computer Science, 142(1):89–124, 1995.Google Scholar
  20. 20.
    D. Sahlin. Mixtus: An automatic partial evaluator for full Prolog. New Generation Computing, 12:7–51, 1993.Google Scholar
  21. 21.
    T. Sato and H. Tamaki. Examples of logic program transformation and synthesis. Case studies of transformation and synthesis of logic programs done up to Feb. 85, 1985.Google Scholar
  22. 22.
    H. Seki. Unfold/fold transformation of stratified programs. Theoretical Computer Science, 86:107–139, 1991.Google Scholar
  23. 23.
    D. A. Smith. Partial evaluation of pattern matching in constraint logic programming languages. In Proceedings ACM Symposium on Partial Evaluation and Semantics Based Program Manipulation, PEPM '91, New Haven, CT, USA, SIGPLAN Notices, 26, 9, pages 62–71. ACM Press, 1991.Google Scholar
  24. 24.
    M. H. Sørensen, R. Glück, and N. D. Jones. Towards unifying partial evaluation, deforestation, supercompilation, and GPC. In D. Sannella, editor, Fifth European Symposium on Programming Languages and Systems, ESOP '94, Lecture Notes in Computer Science 788, pages 485–500. Springer-Verlag, 1994.Google Scholar
  25. 25.
    H. Tamaki and T. Sato. Unfold/fold transformation of logic programs. In S.-Å. Tärnlund, editor, Proceedings of the Second International Conference on Logic Programming, Uppsala, Sweden, pages 127–138. Uppsala University, 1984.Google Scholar
  26. 26.
    V. F. Turchin. The concept of a supercompiler. ACM TOPLAS, 8(3):292–325, 1986.Google Scholar

Copyright information

© Springer-Verlag 1997

Authors and Affiliations

  • Alberto Pettorossi
    • 1
  • Maurizio Proietti
    • 2
  • Sophie Renault
    • 1
  1. 1.Department of InformaticsUniversity of Roma Tor VergataRomaItaly
  2. 2.IASI-CNRRomaItaly

Personalised recommendations