Summary
Given are a directed edge-labelled graph G with a distinguished node n o , 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 o → n 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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
A. V. Aho, R. Sethi, and J. D. Ullman: Compilers: Principles, Techniques and Tools. Addison-Wesley, 1985.
A. W. Appel: Modern Compiler Implementation in ML. Cambridge University Press, 1998.
U. Assmann: How to uniformly specify program analysis and transformation with graph rewrite systems. In P. Fritzson, editor, Compiler Construction 1996, Lecture Notes in Computer Science 1060. Springer, 1996.
R. Backhouse: Fusion on languages. In 10 th European Symposium on Programming, ESOP 2001, Lecture Notes in Computer Science 2028, 107–121. Springer, 2001.
R. C. Backhouse and B. A. Carré: Regular algebra applied to path-finding problems. Journal of the Institute of Mathematics and its Applications, 15:161–186, 1975.
A. J. C. Bik, P. J. Brinkhaus, P. M. W. Knijnenburg, and H. A. G. Wijshoff: Transformation mechanisms in MT1. Technical report, Leiden Institute of Advanced Computer Science, 1998.
R. S. Bird and O. De Moor: Relational program derivation and context-free language recognition. In A. W. Roscoe, editor, A Classical Mind: Essays dedicated to C.A.R. Hoare, 17–35. Prentice-Hall International, 1994.
B. Bloom and R. Paige: Transformational design and implementation of a new efficient solution to the ready simulation problem. Science of Computer Programming, 24(3):189–220, 1995.
J. M. Boyle, K. W. Dritz, M. M. Muralidharan, and R. Taylor: Deriving sequential and parallel programs from pure LISP specifications by program transformation. In L. G. L. T. Meertens, editor, Proceedings of the IFIP TC2/WG 2.1 Working Conference on Program Specification and Transformation, 1–19. North-Holland, 1987.
P. Buneman, M. Fernandez, and D. Suciu: UnQL: A query language and algebra for semistructured data based on structural recursion. VLDB Journal, 9(1):76–110, 2000.
J. Cai, P. Facon, F. Henglein, R. Paige, and E. Schonberg: Type analysis and data structure selection. In B. Möller, editor, Constructing Programs from Specifications, 126–164. North-Holland, 1991.
J. Cai and R. Paige: Towards increased productivity of algorithm implementation. ACM Software Engineering Notes, 18(5):71–78, 1993.
J. Cai, R. Paige, and R. Tarjan: More efficient bottom-up multi-pattern matching in trees. Theoretical Computer Science, 106(1):21–60, 1992.
C. Chang and R. Paige: From regular expressions to DFAs using compressed NFAs. Theoretical Computer Science, 178(1–2):1–36, 1997.
W. N. Chin: Fusion and tupling transformations: Synergies and conflicts (Invited paper). In Fuji International Workhsop on Functional and Logic Programming, 176–195. World Scientific, 1995.
M. Codish, B. Demoen, and K. Sagonas: Xsb as the natural habitat for general purpose program analysis. Technical report, KU Leuven, 1996.
J. R. Cordy, I. H. Carmichael, and R. Halliday: The TXL programming language, version 8. Legasys Corporation, April 1995.
O. de Moor, D. Lacey, and E. Van Wyk: Universal regular path queries. Higher Order and Symbolic Computation, 16(1–2):15–35, Special issue dedicated to Robert Paige. March – June 2003.
S. Eilenberg and J. B. Wright: Automata in general algebras. Information and Control, 11(4):452–470, 1967.
R. E. Faith, L. S. Nyland, and J. F. Prins: KHEPERA: A system for rapid implementation of domain-specific languages. In Proceedings USENIX Conference on Domain-Specific Languages, 243–255, 1997.
D. Hanson, C. W. Fraser, and T. A. Proebsting: Engineering a simple, efficient code generator generator. ACM Letters on Programming Languages and Systems, 1(3):213–226, 1992.
C. A. R. Hoare and J. He: The weakest prespecification, I. Fundamenta Informaticae, 9(1):51–84, 1986.
C. A. R. Hoare and J. He: The weakest prespecification, II. Fundamenta Informaticae, 9(2):217–251, 1986.
J. E. Hopcroft and J. D. Ullman: Introduction to Automata Theory, Languages, and Computation. Addison-Wesley, 1979.
M. Jourdan, D. Parigot, Julié, O. Durin, and C. Le Bellec: Design, implementation and evaluation of the FNC-2 attribute grammar system. In Conference on Programming Languages Design and Implementation. Published as ACM Sigplan Notices, 25(6), 209–222, 1990.
J. P. Keller and R. Paige: Program derivation with verified transformations — a case study. Communications on Pure and Applied Mathematics, 48(9–10), 1996.
M. Klein, J. Knoop, D. Koschützski, and B. Steffen: DFA & OPT-METAFrame: a toolkit for program analysis and optimization. In Tools and Algorithms for the Construction and Analysis of Systems (TACAS ’96), Lecture Notes in Computer Science 1055, 418–421. Springer, 1996.
D. Lacey, N. D. Jones, E. Van Wyk, and C. C. Frederiksen: Proving correctness of compiler optimizations by temporal logic. In Proc. 29 th ACM Symposium on Principles of Programming Languages, 283–294. ACM Press, 2002.
D. Lacey, N. D. Jones, E. Van Wyk, and C. C. Frederiksen: Compiler optimization correctness by temporal logic. Higher Order and Symbolic Computation, 17(3):173–206, September 2003.
D. Lacey and O. de Moor. Imperative program transformation by rewriting: In R. Wilhelm, editor, Proceedings of the 10 th International Conference on Compiler Construction, Lecture Notes in Computer Science 2027, 52–68. Springer, 2001.
P. Lipps, U. Mönke, and R. Wilhelm: OPTRAN — a language/system for the specification of program transformations: system overview and experiences. In Proceedings 2 nd Workshop on Compiler Compilers and High Speed Compilation, Lecture Notes in Computer Science 371, 52–65, 1988.
Y. A. Liu, T. Rothamel, F. Yu, S. D. Stoller, and N. Hu: Parametric regular path queries. In PLDI ’04: Proceedings of the ACM Sigplan 2004 Conference on Programming language design and implementation, 219–230, New York, ACM Press, 2004.
Y. A. Liu and S. D. Stoller: From datalog rules to efficient programs with time and space guarantees. In PPDP ’03: Proceedings 5 th ACM Sigplan International Conference on Principles and practice of declaritive programming, 172–183, New York, ACM Press, 2003.
Y. A. Liu and S. D. Stoller: Querying complex graphs. In P. V. Hentenryck, editor, 8 th International Symposium on Practical Aspects of Declarative Languages (PADL), 16–30. ACM Press, 2006.
E. Meijer, M. Fokkinga, and R. Paterson: Functional programming with bananas, lenses, envelopes and barbed wire. In J. Hughes, editor, Proceedings of the 1991 ACM Conference on Functional Programming Languages and Computer Architecture, Lecture Notes in Computer Science 523, 124–144. Springer, 1991.
T. Milo and D. Suciu: Index structures for path expressions. In International Conference on Database Theory ’99, Lecture Notes in Computer Science 1540, 277–295. Springer, 1999.
S. Muchnick: Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997.
R. Paige: Programming with invariants. IEEE Software, 3(1):56–69, 1986.
R. Paige: Real-time simulation of a set machine on a RAM. In N. Janicki and W. Koczkodaj, editors, Computing and Information, volume 2, 69–73. Canadian Scholars’ Press, 1989.
R. Paige: Viewing a program transformation system at work. In M. Hermenegildo and J. Penjam, editors, Joint 6 th International Conference on Programming Language Implementation and Logic Programming (PLILP) and 4 th International conference on Algebraic and Logic Programming (ALP), Lecture Notes in Computer Science 844, 5–24. Springer, 1991.
R. Paige: Future directions in program transformations. Computing Surveys, 28A(4), 1996.
R. Paige and S. Koenig: Finite differencing of computable expressions. ACM Transactions on Programming Languages and Systems, 4(3):401–454, 1982.
R. Paige, R. Tarjan, and R. Bonic: A linear time solution to the single function coarsest partition problem. Theoretical computer science, 40(1):67–84, 1985.
H. A. Partsch: Transformational program development in a particular problem domain. Science of Computer Programming, 7(2):99–241, 1986.
A. Pettorossi: Methodologies for transformations and memoing in applicative languages. Ph.D. thesis CST-29-84, University of Edinburgh, Scotland, 1984.
I. V. Ramakrishnan, P. Rao, K. F. Sagonas, T. Swift, and D. S. Warren: Efficient tabling mechanisms for logic programs. In International Conference on Logic Programming, 697–711, 1995.
T. W. Reps and T. Teitelbaum: The Synthesizer Generator: A system for constructing language-based editors. Texts and Monographs in Computer Science. Springer, 1989.
K. Saganos: The XSB system v2.4: Programmer’s Manual. 2001.
G. Sittampalam, O. de Moor, and K. F. Larsen: Incremental execution of transformation specifications. In POPL ’04: Proceedings of the 31 st ACM Sigplan-Sigact Symposium on Principles of programming languages, 26–38. ACM Press, 2004.
B. Steffen: Data flow analysis as model checking. In Proceedings of Theoretical Aspects of Computer Science (TACS ’91), Lecture Notes in Computer Science 526, 346–364. Springer, 1991.
R. E. Tarjan: Fast algorithms for solving path problems. Journal of the Association for Computing Machinery, 28(3):594–614, 1981.
S. W. K. Tjiang and J. L. Hennessy: Sharlit — a tool for building optimizers. In ACM Sigplan Conference on Programming Language Design and Implementation, 1992.
M. Verbaere, R. Ettinger, and O. de Moor: JunGL: a scripting language for refactoring. In D. Rombach and M. L. Soffa, editors, 28 th International Conference on Software Engineering (ICSE). ACM Press, 2006.
E. Visser, Z. Benaissa, and A. Tolmach: Building program optimizers with rewriting strategies. In International Conference on Functional Programming ’98, ACM Sigplan, 13–26. ACM Press, 1998.
D. Whitfield and M. L. Soffa: An approach for exploring code-improving transformations. ACM Transactions on Programming Languages and Systems, 19(6):1053–1084, 1997.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2008 Springer
About this chapter
Cite this chapter
de Moor, O., Lacey, D., Van Wyk, E. (2008). Universal Regular Path Queries. In: Danvy, O., Mairson, H., Henglein, F., Pettorossi, A. (eds) Automatic Program Development. Springer, Dordrecht. https://doi.org/10.1007/978-1-4020-6585-9_11
Download citation
DOI: https://doi.org/10.1007/978-1-4020-6585-9_11
Publisher Name: Springer, Dordrecht
Print ISBN: 978-1-4020-6584-2
Online ISBN: 978-1-4020-6585-9
eBook Packages: Computer ScienceComputer Science (R0)