Skip to main content
Log in

Universal Regular Path Queries

  • Published:
Higher-Order and Symbolic Computation

Abstract

Given are a directed edge-labelled graph G with a distinguished node n 0, and a regular expression P which may contain variables. We wish to compute all substitutions Φ (of symbols for variables), together with all nodes n such that all paths n 0n are in Φ(P). We derive an algorithm for this problem using relational algebra, and show how it may be implemented in Prolog. The motivation for the problem derives from a declarative framework for specifying compiler optimisations.

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. Aho, A.V., Sethi, R., and Ullman, J.D. Compilers: Principles, Techniques and Tools. Addison Wesley, 1985.

  2. Appel, A.W. Modern Compiler Implementation in ML. Cambridge University Press, 1998.

  3. Assmann, U. How to uniformly specify program analysis and transformation with graph rewrite systems. In Compiler Construction 1996, vol. 1060 of Lecture Notes in Computer Science, P. Fritzson (Ed.). Springer, 1996.

  4. Backhouse, R. Fusion on languages. In 10th European Symposium on Programming, ESOP 2001, vol. 2028 of Lecture Notes in Computer Science, Springer, 2001, pp. 107–121.

  5. Backhouse, R.C. and Car?e, B.A. Regular algebra applied to path-finding problems. Journal of the Institute of Mathematics and its Applications, 15 (1975) 161–186.

    Google Scholar 

  6. Bik, A.J.C., Brinkhaus, P.J., Knijnenburg, P.M.W., and Wijshoff, H.A.G. Transformation mechanisms in MT1. Technical Report, Leiden Institute of Advanced Computer Science, 1998.

  7. Bird, R.S. and De Moor, O. Relational program derivation and context-free language recognition. In A Classical Mind: Essays dedicated to C.A.R. Hoare, A.W. Roscoe (Ed.). Prentice Hall International, 1994, pp. 17–35.

  8. Bloom, B. and Paige, R. Transformational design and implementation of a new efficient solution to the ready simulation problem. Science of Computer Programming, 24(3) (1995) 189–220.

    Google Scholar 

  9. Boyle, J.M., Dritz, K.W., Muralidharan, M.M., and Taylor, R. Deriving sequential and parallel programs from pure LISP specifications by program transformation. In Proceedings of the IFIP TC2/ WG 2.1 working conference on Program Specification and Transformation, L.G.L.T. Meertens (Ed.). North-Holland, 1987, pp. 1–19.

  10. Buneman, P., Fernandez, M., and Suciu, D. UnQL: A query language and algebra for semistructured data based on structural recursion. VLDB Journal, 9(1) (2000) 76–110.

    Google Scholar 

  11. Cai, J., Facon, P., Henglein, F., Paige, R., and Schonberg, E. Type analysis and data structure selection. In Constructing Programs from Specifications, B. Möller (Ed.). North-Holland, 1991, pp. 126–164.

  12. Cai, J. and Paige, R. Towards increased productivity of algorithm implementation. ACM Software Engineering Notes, 18(5) (1993) 71–78.

    Google Scholar 

  13. Cai, J., Paige, R., and Tarjan, R. More efficient bottom-up multi-pattern matching in trees. Theoretical Computer Science, 106(1) (1992) 21–60.

    Google Scholar 

  14. Chang, C. and Paige, R. From regular expressions to DFAs using compressed NFAs. Theoretical Computer Science, 178(1/2) (1997) 1–36.

    Google Scholar 

  15. Chin W.N. Fusion and tupling transformations: Synergies and conflicts (invited paper). In Fuji International Workhsop on Functional and Logic Programming, World Scientific, 1995, pp. 176–195.

  16. Codish, M., Demoen, B., and Sagonas, K. Xsb as the natural habitat for general purpose program analysis. Technical Report, KU Leuven, 1996.

  17. Cordy, J.R., Carmichael, I.H., and Halliday, R. The TXL programming language, version 8. Legasys Corporation, 1995.

  18. Eilenberg, S. and Wright, J.B. Automata in general algebras. Information and Control, 11(4) (1967) 452–470.

    Google Scholar 

  19. Faith, R.E., Nyland, L.S., and Prins, J.F. KHEPERA: A system for rapid implementation of domain-specific languages. In Proceedings USENIX Conference on Domain-Specific Languages, 1997, pp. 243–255.

  20. Hanson, D., Fraser, C.W., and Proebsting, T.A. Engineering a simple, efficient code generator generator. ACM Letters on Programming Languages and Systems, 1(3) (1992) 213–226.

    Google Scholar 

  21. Hoare, C.A.R. and He, J. The weakest prespecification, I. Fundamenta Informaticae, 9(1) (1986a) 51–84.

    Google Scholar 

  22. Hoare, C.A.R. and He, J. The weakest prespecification, II. Fundamenta Informaticae, 9(2) (1986b) 217–251.

    Google Scholar 

  23. Hopcroft, J.E. and Ullman, J.D. Introduction to Automata Theory, Languages, and Computation. Addison-Wesley, 1979.

  24. Jourdan, M., Parigot, D., Julié, Durin, O., and Le Bellec, C. Design, implementation and evaluation of the FNC-2 attribute grammar system. In Conference on Programming Languages Design and Implementation, 1990, pp. 209–222. Published as ACM SIGPLAN Notices, 25(6).

  25. Keller, J.P. and Paige, R. Program derivation with verified transformations—a case study. Communications on Pure and Applied Mathematics, 48(9/10) (1996).

  26. Klein, M., Knoop, J., Koschützski, D., and Steffen, B. DFA & OPT-METAFrame: A toolkit for program analysis and optimization. In Proceedings of the 2nd International Workshop on Tools and Algorithms for the Construction and Analysis of Systems (TACAS’ 96), vol. 1055 of Lecture Notes in Computer Science, Springer, 1996, pp. 418–421.

  27. Lacey, D. and de Moor, O. Imperative program transformation by rewriting. In Compiler Construction, R. Wilhelm (Ed.). Vol. 2027 of Lecture Notes in Computer Science, Springer Verlag, 2001, pp. 52–68.

  28. Lacey, D., Jones, N., Van Wyk, E., and Frederiksen, C.C. Proving correctness of compiler optimizations by temporal logic. In Proc. of ACM 29th Symp. on Principles of Programming Languages, Portland, OR, Association of Computing Machinery, 2002.

    Google Scholar 

  29. Lipps, P., Mönke, U., and Wilhelm, R. OPTRAN—a language/system for the specification of program transformations: system overview and experiences. In Proceedings 2nd Workshop on Compiler Compilers and High Speed Compilation, vol. 371 of Lecture Notes in Computer Science, 1988, pp. 52–65.

  30. Meijer, E., Fokkinga, M., and Paterson, R. Functional programming with bananas, lenses, envelopes and barbed wire. In Proceedings of the 1991 ACM Conference on Functional Programming Languages and Computer Architecture, J. Hughes (Ed.). Vol. 523 of Lecture Notes in Computer Science, Springer-Verlag, 1991, pp. 124–144.

  31. Milo, T. and Suciu, D. Index structures for path expressions. In International Conference on Database Theory'99, vol. 1540 of Lecture Notes in Computer Science, Springer, 1999, pp. 277–295.

  32. Muchnick, S. Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997.

  33. Paige, R. Programming with invariants. IEEE Software, 3(1) (1986) 56–69.

    Google Scholar 

  34. Paige, R. Real-time simulation of a set machine on a RAM. In Computing and Information, N. Janicki and W. Koczkodaj (Eds.). Vol. 2, Canadian Scholars’ Press, 1989, pp. 69–73.

  35. Paige, R. Viewing a program transformation system at work. In Joint 6th International Conference on Programming Language Implementation and Logic Programming (PLILP) and 4th International conference on Algebraic and Logic Programming (ALP), M. Hermenegildo and J. Penjam (Eds.). Vol. 844 of Lecture Notes in Computer Science, Springer, 1991, pp. 5–24.

  36. Paige, R. Future directions in program transformations. Computing Surveys, 28A(4) (1996).

  37. Paige, R. and Koenig, S. Finite differencing of computable expressions. ACM Transactions on Programming Languages and Systems, 4(3) (1982) 401–454.

    Google Scholar 

  38. Paige, R., Tarjan, R., and Bonic, R. A linear time solution to the single function coarsest partition problem. Theoretical Computer Science, 40(1) (1985) 67–84.

    Google Scholar 

  39. Partsch, H.A. Transformational program development in a particular problem domain. Science of Computer Programming, 7(2) (1986) 99–241.

    Google Scholar 

  40. Pettorossi, A. Methodologies for transformations and memoing in applicative languages. Ph.D. Thesis CST-29-84, University of Edinburgh, Scotland, 1984.

  41. Ramakrishnan, I.V., Rao, P., Sagonas, K.F., Swift, T., and Warren, D.S. Efficient tabling mechanisms for logic programs. In International Conference on Logic Programming, 1995, pp. 697–711.

  42. Reps T.W. and Teitelbaum, T. The Synthesizer Generator:ASystem for Constructing Language-Based Editors. Texts and Monographs in Computer Science. Springer-Verlag, 1989.

  43. Saganos, K. The XSB system v2.4: Programmers manual, 2001.

  44. Steffen, B. Data flow analysis as model checking. In Proceedings of Theoretical Aspects of Computer Science, 1991, pp. 346–364.

  45. Tarjan, R.E. Fast algorithms for solving path problems. Journal of the Association for Computing Machinery, 28(3) (1981) 594–614.

    Google Scholar 

  46. Tjiang, S.W.K. and Hennessy, J.L. Sharlit—A tool for building optimizers. In ACM SIGPLAN Conference on Programming Language Design and Implementation, 1992.

  47. Visser, E., Benaissa, Z., and Tolmach, A. Building program optimizers with rewriting strategies. In International Conference on Functional Programming'98, ACM Press, 1998, pp. 13–26.

  48. Whitfield, D. and Soffa, M.L. An approach for exploring code-improving transformations. ACM Transactions on Programming Languages and Systems, 19(6) (1997) 1053–1084.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

About this article

Cite this article

de Moor, O., Lacey, D. & Van Wyk, E. Universal Regular Path Queries. Higher-Order and Symbolic Computation 16, 15–35 (2003). https://doi.org/10.1023/A:1023063919574

Download citation

  • Issue Date:

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

Navigation