# Graph grammars and logic programming

## Abstract

In this paper we investigate the relationship between the algebraic definition of graph grammars and logic programming. In particular, we show that the operational semantics of any logic program can be faithfully simulated by a particular context-free hypergraph grammar. In the process of doing that, we consider the issue of representing terms, formulas, and clauses as particular graphs or graph productions, by first evaluating the approaches already proposed for Term Rewriting Systems (TRS), and then by giving an original extension of those approaches, to be able to deal with the unique features of logic programming. Actually, not only does our representation of definite clauses by graph productions allow us to deal correctly with logical unification, but also it overcomes some of the problems encountered by other approaches for representing TRS's as graph grammars. The main result of the paper states the soundness and completeness of the representation of clauses by productions, and this correspondence is extended to entire computations, showing how a context-free grammar (over a suitable category of graphs) can be associated with a logic program. The converse holds as well, i.e. given any context-free graph grammar (over that category), a logic program can be extracted from it.

## Keywords

Logic Programming Graph Grammars Term Rewriting Systems Hypergraphs Jungles Dags## Preview

Unable to display preview. Download preview PDF.

## 6. References

- [AM89]A. Asperti, S. Martini,
*Projections instead of variables, A category theoretic interpretation of logic programs*, Proc. 6^{th}Int. Conf. on Logic Programming, MIT Press, 1989, pp. 337–352.Google Scholar - [BC87]M. Bauderon, B. Courcelle,
*Graph Expressions and Graph Rewritings*, Mathematical System Theory**20**, 1987, pp. 83–127.CrossRefGoogle Scholar - [BvEGKPS87]H.P. Barendregt, M.C.J.D. van Eekelen, J.R.W. Glauert, J.R. Kennaway, M.J. Plasmeijer, M.R. Sleep,
*Term graph reduction*, in Proc. PARLE, LNCS 259, 1987, pp. 141–158.Google Scholar - [CER79]V. Claus, H. Ehrig, G. Rozenberg, (Eds.)
*Proceedings of the 1*^{st}International Workshop on Graph-Grammars and Their Application to Computer Science and Biology, LNCS 73, 1979.Google Scholar - [Cou88]B. Courcelle,
*On using context-free graph grammars for analyzing recursive definitions*, in*Programming of Future Generation Computers II*, K. Fuchi, L. Kott (Eds.), Elsevier-North-Holland, 1988, pp. 83–122.Google Scholar - [Eh83]H. Ehrig,
*Aspects of concurrency in graph grammars*, in [ENR83], pp. 58–81.Google Scholar - [Eh87]H. Ehrig,
*Tutorial introduction to the algebraic approach of graph-grammars*, in [ENRR87] pp. 3–14.Google Scholar - [EHKP91]H. Ehrig, A. Habel, H.-J. Kreowski, F. Parisi-Presicce,
*High-Level Replacement Systems*, in [EKR91].Google Scholar - [EKR91]H. Ehrig, H.-J. Kreowski, G. Rozenberg, (Eds.)
*Proceedings of the 4*^{th}International Workshop on Graph-Grammars and Their Application to Computer Science, LNCS, 1991, this volume.Google Scholar - [ENR83]H. Ehrig, M. Nagl, G. Rozenberg, (Eds.)
*Proceedings of the 2*^{nd}International Workshop on Graph-Grammars and Their Application to Computer Science, LNCS 153, 1983.Google Scholar - [ENRR87]H. Ehrig, M. Nagl, G. Rozenberg, A. Rosenfeld, (Eds.)
*Proceedings of the 3*^{rd}International Workshop on Graph-Grammars and Their Application to Computer Science, LNCS 291, 1987.Google Scholar - [EPS73]H. Ehrig, M. Pfender, H.J. Schneider,
*Graph-grammars: an algebraic approach*, Proc, IEEE Conf. on Automata and Switching Theory, 1973, pp. 167–180.Google Scholar - [FLMP89]M. Falaschi, G. Levi, M. Martelli, C. Palamidessi,
*Declarative Modeling of the Operational Behaviour of Logic Languages*, Theoretical Computer Science,**69**(3), 1989, pp. 289–318.CrossRefGoogle Scholar - [FLP84]M. Falaschi, G. Levi, C. Palamidessi,
*A Synchronization Logic: Axiomatics and Formal Semantics of Generalized Horn Clauses*, in Information and Control,**60**(1–3), Academic Press, 1984.Google Scholar - [Go89]J.A. Goguen,
*What is Unification? A Categorical View of Substitution, Equation and Solution*, in M. Nivat and H. Aït-Kaci (Eds.),*Resolution of Equations in Algebraic Structures*, Academic Press, 1989.Google Scholar - [Ha89]A. Habel,
*Hyperedge Replacement: Grammars and Languages*, Ph.D. Thesis, University of Bremen, 1989.Google Scholar - [HKP88]A. Habel, H-J. Kreowski, D. Plump,
*Jungle evaluation*, in Proc. Fifth Workshop on Specification of Abstract Data Types, LNCS 332, 1988, pp. 92–112.Google Scholar - [Ken87]J.R. Kennaway,
*On ‘On Graph Rewritings'*, Theoretical Computer Science,**52**, 1987, pp. 37–58.CrossRefGoogle Scholar - [Ken91]J.R. Kennaway,
*Graph rewriting in some categories of partial morphisms*, in [EKR91].Google Scholar - [Le88]G. Levi,
*Models, Unfolding Rules and Fixpoint Semantics*, in Proc. 5^{th}Int. Conf. Symp. on Logic Programming, Seattle, MIT Press, pp. 1649–1665, 1988.Google Scholar - [Ll87]J.W. Lloyd,
*Foundations of Logic Programming*, Springer Verlag, 1984, (Second Edition 1987).Google Scholar - [ML71]S. Mac Lane,
*Categories for the Working Mathematician*, Springer Verlag, New York, 1971.Google Scholar - [PEM87]F. Parisi-Presicce, H. Ehrig and U. Montanari,
*Graph Rewriting with Unification and Composition*, in [ENRR87], pp. 496–514.Google Scholar - [Rao84]J.C. Raoult,
*On Graph Rewritings*, Theoretical Computer Science,**32**, 1984, pp. 1–24.CrossRefGoogle Scholar - [RB85]D.E. Rydeheard, R.M. Burstall,
*A Categorical Unification Algorithm*, Proc. of the Workshop on Category Theory and Computer Programming, LNCS 240, 1985.Google Scholar