Skip to main content
Log in

Regular Tree Languages as an Abstract Domain in Program Specialisation

  • Published:
Higher-Order and Symbolic Computation

Abstract

On-line partial evaluation algorithms include a generalisation step, which is needed to ensure termination. In partial evaluation of logic and functional programs, the usual generalisation operation is the most specific generalisation (msg) of expressions. This can cause loss of information, which is especially serious in programs whose computations first build some internal data structure that is then used to control a subsequent phase of execution—a common pattern of computation. If the size of the intermediate data is unbounded at partial evaluation time then the msg will lose almost all information about its structure. Hence subsequent phases of computation cannot be effectively specialised.

In this paper the problem is tackled by introducing regular tree languages into a partial evaluation algorithm. A regular tree language is a set of terms defined by tree automata or tree grammars. In the algorithm, regular tree approximations of sets of terms encountered during partial evaluation are constructed. The critical point is that when generalisation is performed, the upper bound on regular tree languages can be combined with the msg, thus preserving recursive information about term structure. This approach also allows the specialisation of programs with respect to goals whose arguments range over regular tree languages.

The algorithm is presented as an instance of Leuschel's framework for abstract specialisation of logic programs. This provides a generic algorithm parameterised by an abstract domain—regular trees in this case. The correctness requirements from his framework are established. The extension of the algorithm to propagate regular approximations of answers as well as calls is also presented, increasing the amount of specialisation that can be obtained. Finally a technique for increasing precision based on “wrapper functions” is introduced.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Bruynooghe, M. A practical framework for abstract interpretation of logic programs. Journal of Logic Programming, 10(2) (1991) 91–124.

    Google Scholar 

  2. Codish, M., Marriott, K., and Taboch, C. Improving program analyses by structure untupling. The Journal of Logic Programming, 43(3) (2000) 251–263.

    Google Scholar 

  3. Comon, H., Dauchet, M., Gilleron, R., Jacquemard, F., Lugiez, D., Tison, S., and Tommasi, M. Tree Automata Techniques and Applications. 1999. http://www.grappa.univ-lille3.fr/tata.

  4. Cousot, P. and Cousot, R. Comparing the Galois connection and widening/narrowing approaches to abstract interpretation. In Proceedings of the 4th International Symposium on Programming Language Implementation and Logic Programming Leuven, Belgium, Springer-Verlag Lecture Notes in Computer Science, Vol. 631, 1992, pp. 269–295.

    Google Scholar 

  5. Cousot, P. and Cousot, R. Formal language, grammar and set-constraint-based program analysis by abstract interpretation. In Proceedings of the Seventh ACM Conference on Functional Programming Languages and Computer Architecture. La Jolla, California, 1995, pp. 170–181.

  6. De Schreye, D., Glück, R., Jø rgensen, J., Leuschel, M., Martens, B., and Sø rensen, M.H. Conjunctive partial deduction: Foundations, control, algorithms, and experiments. Journal of Logic Programming, 41 (1999) 231–277.

    Google Scholar 

  7. de Waal, D. and Gallagher, J. Specialisation of a unification algorithm. In Logic Program Synthesis and Transformation, LOPSTR-91, T. Clement and K.-K. Lau (Eds.). Manchester, 1992.

  8. Frühwirth, T., Shapiro, E., Vardi, M., and Yardeni, E. Logic programs as types for logic programs. In Proceedings of the IEEE Symposium on Logic in Computer Science, Amsterdam, 1991.

  9. Gallagher, J. A System for specialising logic programs. Technical Report TR–91–32, University of Bristol, 1991.

  10. Gallagher, J. Specialisation of logic programs: A tutorial. In Proceedings PEPM'93, ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation. Copenhagen, 1993, pp. 88–98.

  11. Gallagher, J., Codish, M., and Shapiro, E. Specialisation of prolog and FCP programs using abstract interpretation. New Generation Computing, 6 (1988) 159–186.

    Google Scholar 

  12. Gallagher, J. and de Waal, D. Fast and precise regular approximation of logic programs. In Proceedings of the International Conference on Logic Programming (ICLP'94), P. Van Hentenryck (Ed.). Santa Margherita Ligure, Italy, 1994.

  13. Gallagher, J. and Lafave, L. Regular approximation of computation paths in logic and functional languages. In Partial Evaluation, O. Danvy, R. Glück, and P. Thiemann (Eds.). Springer-Verlag Lecture Notes in Computer Science, Vol. 1110, 1996, pp. 115–136.

  14. Gurr, C.A. Specialising the ground representation in the logic programming language gödel. In Logic Program Synthesis and Transformation, LOPSTR'93, Y. Deville (Ed.). Louvain-La-Neuve, 1994.

  15. Heintze, N. and Jaffar, J. A finite presentation theorem for approximating logic programs. In Proceedings of the 17th Annual ACM Symposium on Principles of Programming Languages, San Francisco, 1990, pp. 197–209.

  16. Hill, P. and Gallagher, J.P. Meta-programming in logic programming. Handbook of Logic in Artificial Intelligence and Logic Programming, Vol. 5, Oxford University Press, 1998, pp. 421–498.

    Google Scholar 

  17. Janssens, G. and Bruynooghe, M. Deriving descriptions of possible values of program variables by means of abstract interpretation. Journal of Logic Programming, 13(2/3) (1992) 205–258.

    Google Scholar 

  18. Jones, N.D. Combining abstract interpretation and partial evaluation. In Symposium on Static Analysis (SAS'97), P. Van Hentenryck (Ed.). Springer-Verlag Lecture Notes in Computer Science, Vol. 1302, 1997, pp. 396–405.

  19. Jones, N.D. and Muchnick, S.S. A flexible approach to interprocedural data flow analysis and programs with recursive data structures. In Conference Record of the Ninth Symposium on Principles of Programming Languages, 1982, pp. 66–74.

  20. Kursawe, P. How to invent a prolog machine. New Generation Computing, 5 (1987) 97–114.

    Google Scholar 

  21. Lafave, L. A constraint-based partial evaluator for functional logic programs and its application. Ph.D. Thesis, Department of Computer Science, University of Bristol, 1998.

  22. Leuschel, M. Advanced techniques for logic program specialisation. Ph.D. Thesis, Department of Computer Science, K.U. Leuven, 1997.

    Google Scholar 

  23. Leuschel, M. Program specialisation and abstract interpretation reconciled. Technical Report Report CW259, Department of Computer Science, K.U. Leuven, 1997.

    Google Scholar 

  24. Leuschel, M. On the power of homeomorphic embedding for online termination. In Proceedings of the Symposium on Static Analysis (SAS'98), G. Levi (Ed.). Springer-Verlag Lecture Notes in Computer Science, Vol. 1503, 1998, pp. 230–245.

  25. Leuschel, M. Program specialisation and abstract interpretation reconciled. In Proceedings of the Joint International Conference and Symposium on Logic Programming JICSLP'98, J. Jaffar (Ed.). Manchester, UK, 1998, pp. 220–234.

  26. Leuschel, M. and De Schreye, D. Logic program specialisation: How to be more specific. In Programming Languages: Implementations, Logics, and Programs, 8th International Symposium, PLILP'96, Aachen, Germany, H. Kuchen and S. Doaitse Swierstra (Eds.). Springer-Verlag Lecture Notes in Computer Science, Vol. 1140, Sept. 24–27, 1996, pp. 137–151.

  27. Leuschel, M. and Martens, B. Global control for partial deduction through characteristic atoms and global trees. In Partial Evaluation, O. Danvy, R. Glück, and P. Thiemann (Eds.). Springer-Verlag Lecture Notes in Computer Science, Vol. 1110, 1996, pp. 263–283.

  28. Lloyd, J. Foundations of Logic Programming: 2nd edn. Springer-Verlag, Berlin, 1987.

    Google Scholar 

  29. Mildner, P. Type domains for abstract interpretation: A critical study. Ph.D. Thesis, Department of Computer Science, Uppsala University, 1999.

  30. Mishra, P. Towards a theory of types in prolog. In Proceedings of the IEEE International Symposium on Logic Programming, 1984.

  31. Mogensen, T.Æ . Partially static structures in a self-applicable partial evaluator. In Partial Evaluation and Mixed Computation, D. Bjø rner, A. Ershov, and N. Jones (Eds.). 1988, pp. 325–347.

  32. Muthukumar, K. and Hermenegildo, M. Compile-time derivation of variable dependency using abstract interpretation. Journal of Logic Programming 13(2/3) (1992) 315–347.

    Google Scholar 

  33. Peralta, J.C. Analysis and specialisation of imperative programs: An approach using CLP. Ph.D. Thesis, University of Bristol, Department of Computer Science, 2000.

  34. Peralta, J. and Gallagher, J. Imperative program specialisation: An approach using CLP. In Logic-Based Program Synthesis and Transformation (LOPSTR'99), A. Bossi (Ed.). Springer-Verlag Lecture Notes in Computer Science, Vol. 1817, 2000, pp. 103–118.

  35. Peralta, J., Gallagher, J., and Sağlam, H. Analysis of imperative programs through analysis of constraint logic programs. In Static Analysis. 5th International Symposium, SAS'98, Pisa, G. Levi (Ed.). Springer-Verlag Lecture Notes in Computer Science, Vol. 1503, 1998, pp. 246–261.

  36. Puebla, G., Hermenegildo, M., and Gallagher, J.P. An integration of partial evaluation in a generic abstract interpretation framework. In Proceedings of the ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation (PEPM'99), O. Danvy (Ed.). San Antonio, Texas, 1999, pp. 75–84.

  37. Reynolds, J.C. Automatic construction of data set definitions. In Information Processing 68, J. Morrell (Ed.). 1969, pp. 456–461.

  38. Reynolds, J.C. Transformational systems and the algebraic structure of atomic formulas. Machine Intelligence, B. Meltzer and D. Mitchie (Eds.). 1970, pp. 135–151.

  39. Sağlam, H. and Gallagher, J. Constrained regular approximation of logic programs. In Logic Program Synthesis and Transformation (LOPSTR'97), N. Fuchs (Ed.). Springer-Verlag Lecture Notes in Computer Science, Vol. 1463, 1998.

  40. Sahlin, D. An automatic partial evaluator for full prolog. Ph.D. Thesis, The Royal Institute of Technology, 1991.

  41. Sø rensen, M. and Glück, R. An algorithm of generalisation in positive supercompilation. In Proceedings of the International Symposium on Logic Programming (ILPS'95), J. Lloyd (Ed.). 1995.

  42. Tamaki, H. and Sato, T. Enumeration of success-patterns in logic programs. Theoretical Computer Science 34(1984) 227–240.

    Google Scholar 

  43. Tamaki, H. and Sato, T. Unfold/fold transformation of logic programs. In Proceedings of the Second International Logic Programming Conference, S.-A. Tarnlund (Ed.). 1984, pp. 127–138.

  44. Tamaki, H. and Sato, T. OLDT resolution with tabulation. In Proc. 3rd ICLP, London, E. Shapiro (Ed.). Springer-Verlag Lecture Notes in Computer Science, Vol. 225, 1986.

  45. Turchin, V. The algorithm of generalization in the supercompiler. In Proc. of the IFIP TC2 Workshop on Partial Evaluation and Mixed Computation, D. Bjø rner, A. Ershov, and N. Jones (Eds.). 1988, pp. 531–549.

  46. Van Hentenryck, P., Cortesi, A., and Le Charlier, B. Type analysis of prolog using type graphs. Journal of Logic Programming, 22(3) (1994) 179–210.

    Google Scholar 

  47. Vanhoof, W., Martens, B., Schreye, D.D., and Vlaminck, K.D. Specialising the other way around. In Proceedings of the Joint International Conference and Symposium on Logic Programming, J. Jaffar (Ed.). 1998, pp. 279–293.

  48. Yardeni, E. and Shapiro, E. A type system for logic programs. Journal of Logic Programming, 10(2) (1990) 125–154.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

About this article

Cite this article

Gallagher, J.P., Peralta, J.C. Regular Tree Languages as an Abstract Domain in Program Specialisation. Higher-Order and Symbolic Computation 14, 143–172 (2001). https://doi.org/10.1023/A:1012936614361

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1023/A:1012936614361

Navigation