Hostname: page-component-cd9895bd7-gxg78 Total loading time: 0 Render date: 2024-12-26T06:36:42.307Z Has data issue: false hasContentIssue false

Efficient local unfolding with ancestor stacks*

Published online by Cambridge University Press:  18 January 2010

GERMÁN PUEBLA
Affiliation:
School of Computer Science, Technical University of Madrid, E28660-Boadilla del Monte, Madrid, Spain (e-mail: german@fi.upm.es)
ELVIRA ALBERT
Affiliation:
School of Computer Science, Complutense University of Madrid, E28040-Profesor José García Santesmases, s/n, Madrid, Spain (e-mail: elvira@sip.ucm.es)
MANUEL HERMENEGILDO
Affiliation:
School of Computer Science, Technical University of Madrid, E28660-Boadilla del Monte, Madrid, Spain (e-mail: herme@fi.upm.es) Madrid Institute for Advanced Studies in Software Development Technology, IMDEA Software, E28660-Boadilla del Monte, Madrid, Spain (e-mail: manuel.hermenegildo@imdea.org)

Abstract

The most successful unfolding rules used nowadays in the partial evaluation of logic programs are based on well quasi orders (wqo) applied over (covering) ancestors, i.e., a subsequence of the atoms selected during a derivation. Ancestor (sub)sequences are used to increase the specialization power of unfolding while still guaranteeing termination and also to reduce the number of atoms for which the wqo has to be checked. Unfortunately, maintaining the structure of the ancestor relation during unfolding introduces significant overhead. We propose an efficient, practical local unfolding rule based on the notion of covering ancestors which can be used in combination with a wqo and allows a stack-based implementation without losing any opportunities for specialization. Using our technique, certain nonleftmost unfoldings are allowed as long as local unfolding is performed, i.e., we cover depth-first strategies. To deal with practical programs, we propose assertion-based techniques which allow our approach to treat programs that include (Prolog) built-ins and external predicates in a very extensible manner, for the case of leftmost unfolding. Finally, we report on our implementation of these techniques embedded in a practical partial evaluator, which shows that our techniques, in addition to dealing with practical programs, are also significantly more efficient in time and somewhat more efficient in memory than traditional tree-based implementations.

Type
Regular Papers
Copyright
Copyright © Cambridge University Press 2010

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

References

Aho, A. V., Sethi, R. and Ullman, J. D. 1986. Compilers – Principles, Techniques and Tools. Addison-Wesley.Google Scholar
Albert, E., Hanus, M. and Vidal, G. 2002. A practical partial evaluation scheme for multi-paradigm declarative languages. Journal of Functional and Logic Programming 2002, 134.Google Scholar
Albert, E., Puebla, G. and Gallagher, J. 2006. Non-leftmost unfolding in partial evaluation of logic programs with impure predicates. In Fiftheenth International Symposium on Logic-based Program Synthesis and Transformation (LOPSTR'05). Hill, Patricia M., Ed. Lecture Notes in Computer Science, vol. 3901. Springer-Verlag, 115132.Google Scholar
Bruynooghe, M. 1991. A practical framework for the abstract interpretation of logic programs. Journal of Logic Programming 10, 91124.CrossRefGoogle Scholar
Bruynooghe, M., Schreye, D. D. and Martens, B. 1992. A general criterion for avoiding infinite unfolding during partial deduction. New Generation Computing 1, 11, 4779.CrossRefGoogle Scholar
Bueno, F., Cabeza, D., Carro, M., Hermenegildo, M., López-García, P. and Puebla, G. (Eds.) 2004. The Ciao System. Reference Manual. Vol. 1.10. Technical report, School of Computer Science (UPM). URL: http://www.ciaohome.org.Google Scholar
Bueno, F., Cabeza, D., Carro, M., Hermenegildo, M., López-García, P. and Puebla, G. (Eds.) 2009. The Ciao System. Reference Manual. Vol. 1.13. Technical report URL: http://www.ciaohome.org.Google Scholar
Christensen, N. H. and Glück, R. 2004. Offline partial evaluation can be as accurate as online partial evaluation. ACM Transactions on Programming Languages and Systems 26, 1, 191220.CrossRefGoogle Scholar
Craig, S.-J., Gallagher, J. P., Leuschel, M. and Henriksen, K. S. 2005. Fully automatic binding-time analysis for prolog. In LOPSTR. Lecture Notes in Computer Science, vol. 3573. Springer, 5368.Google Scholar
De Schreye, D., Glück, R., Jørgensen, J., Leuschel, M., Martens, B. and Sørensen, M. H. 1999. Conjunctive partial deduction: Foundations, control, algorithms and experiments. Journal of Logic Programming 41, 2 & 3 (November), 231277.CrossRefGoogle Scholar
Etalle, S., Gabbrielli, M. and Marchiori, E. 1997. A transformation system for CLP with dynamic scheduling and CCP. In Proc. of the ACM Sigplan PEPM'97. ACM Press, New York, 137150.CrossRefGoogle Scholar
Gallagher, J. 1993. Tutorial on specialisation of logic programs. In Proc. of PEPM'93, the ACM Sigplan Symposium on Partial Evaluation and Semantics-Based Program Manipulation. ACM Press, 8898.Google Scholar
Hermenegildo, M., Puebla, G., Bueno, F. and López-García, P. 2005. Integrated program debugging, verification, and optimization using abstract interpretation (and the ciao system preprocessor). Science of Computer Programming 58, 1–2 (October), 115140.CrossRefGoogle Scholar
Jones, N., Gomard, C. and Sestoft, P. 1993. Partial Evaluation and Automatic Program Generation. Prentice Hall, New York.Google Scholar
Kruskal, J. 1960. Well-quasi-ordering, the tree theorem, and vazsonyi's conjecture. Transactions of the American Mathematical Society 95, 210225.Google Scholar
Le Charlier, B., Rossi, S. and Van Hentenryck, P. 2002. Sequence based abstract interpretation of prolog. Theory and Practice of Logic Programming 2, 1, 2584.CrossRefGoogle Scholar
Leuschel, M. 1994. Partial evaluation of the “real thing”. In Proc. of LOPSTR'94 and META'94. Fribourg, Laurent and Turini, Franco, Eds. Lecture Notes in Computer Science, vol. 883. Springer-Verlag, 122137.Google Scholar
Leuschel, M. 1996–2002a. The ecce partial deduction system and the dppd library of benchmarks. Obtainable via URL: http://www.ecs.soton.ac.uk/~mal.Google Scholar
Leuschel, M. 1998. On the power of homeomorphic embedding for online termination. In Proceedings of SAS'98, Levi, G., Ed. Lecture Notes in Computer Science, vol. 1503. Springer-Verlag, Pisa, Italy, 230245.Google Scholar
Leuschel, M. 2002b. Homeomorphic embedding for online termination of symbolic methods. In The Essence of Computation – Essays Dedicated to Neil Jones, Mogensen, T. Æ., Schmidt, D. and Sudborough, I. H., Eds. Lecture Notes in Computer Science, vol. 2566. Springer-Verlag, 379403.Google Scholar
Leuschel, M. and Bruynooghe, M. 2002. Logic program specialisation through partial deduction: Control issues. Theory and Practice of Logic Programming 2, 4 & 5 (July & September), 461515.CrossRefGoogle Scholar
Leuschel, M., Craig, S., Bruynooghe, M. and Vanhoof, W. 2004. Specialising interpreters using offline partial deduction. In Program Development in Computational Logic. Bruynooghe, Maurice and Lau, Kung-Kiu, Eds. Lecture Notes in Computer Science, vol. 3049. Springer, 340375.CrossRefGoogle Scholar
Leuschel, M., Jørgensen, J., Vanhoof, W. and Bruynooghe, M. 2004. Offline specialisation in prolog using a hand-written compiler generator. TPLP 4, 1–2, 139191.Google Scholar
Lloyd, J. 1987. Foundations of Logic Programming. Springer, 2nd, extended ed.CrossRefGoogle Scholar
Lloyd, J. W. and Shepherdson, J. C. 1991. Partial evaluation in logic programming. The Journal of Logic Programming 11, 217242.CrossRefGoogle Scholar
Martens, B. and De Schreye, D. 1996. Automatic finite unfolding using well-founded measures. The Journal of Logic Programming 28, 2 (August), 89146.CrossRefGoogle Scholar
Puebla, G., Bueno, F. and Hermenegildo, M. 2000. An assertion language for constraint logic programs. In Analysis and Visualization Tools for Constraint Programming. Deransart, Pierre, Hermenegildo, Manuel V. and Maluszynski, Jan, Eds. Lecture Notes in Computer Science, vol. 1870. Springer, 2361.CrossRefGoogle Scholar
Sahlin, D. 1993. Mixtus: An automatic partial evaluator for full prolog. New Generation Computing 12, 1, 751.CrossRefGoogle Scholar
Sørensen, M. and Glück, R. 1995. An algorithm of generalization in positive supercompilation. In Proc. of ILPS'95. The MIT Press, 465479.Google Scholar
Venken, R. and Demoen, B. 1988. A partial evaluation system for prolog: Some practical considerations. New Generation Computing 6, 279290.CrossRefGoogle Scholar