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.
Similar content being viewed by others
References
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.
R. M. Burstall and J. Darlington. A transformation system for developing recursive programs. Journal of the ACM, 24(1):44–67, January 1977.
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.
Y. Deville. Logic Programming: Systematic Program Development. Addison-Wesley, 1990.
H. Fujita. An algorithm for partial evaluation with constraints. Technical Memorandum TM-0367, ICOT, Tokyo, Japan, 1987.
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.
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.
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.
N. D. Jones, C. K. Gomard, and P. Sestoft. Partial Evaluation and Automatic Program Generation. Prentice Hall, 1993.
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.
M. Leuschel and B. Martens. Global control for partial deduction through characteristic atoms and global trees. Report CW 220, K.U. Leuven, Belgium, 1995.
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).
J. W. Lloyd and J. C. Shepherdson. Partial evaluation in logic programming. Journal of Logic Programming, 11:217–242, 1991.
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.
A. Pettorossi and M. Proietti. Transformation of logic programs: Foundations and techniques. Journal of Logic Programming, 19, 20:261–320, 1994.
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).
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.
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.
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.
D. Sahlin. Mixtus: An automatic partial evaluator for full Prolog. New Generation Computing, 12:7–51, 1993.
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.
H. Seki. Unfold/fold transformation of stratified programs. Theoretical Computer Science, 86:107–139, 1991.
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.
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.
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.
V. F. Turchin. The concept of a supercompiler. ACM TOPLAS, 8(3):292–325, 1986.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1997 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Pettorossi, A., Proietti, M., Renault, S. (1997). Enhancing partial deduction via unfold/fold rules. In: Gallagher, J. (eds) Logic Program Synthesis and Transformation. LOPSTR 1996. Lecture Notes in Computer Science, vol 1207. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-62718-9_9
Download citation
DOI: https://doi.org/10.1007/3-540-62718-9_9
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-62718-0
Online ISBN: 978-3-540-68494-7
eBook Packages: Springer Book Archive