On structured graph grammars. I

In most m5dels of (sequential graph gramm~s the app~~~tj5n of a rule r to a graph N consists of the f&owing sequence of steps: CHCWSE an occurrence of the feft-hand side of I in M; CHEClE the appiication ccmiition (which seprares irvaliP from “invalid” cmurrenca of rf; REMOVE certain parts of the occurrence of r; ADD to the remaining part of M the right-hand side of r; CONNECT the remaining part of M and the added right-hand side by “connecting edges.” ‘l%is paper presents a antion of a (seq~e~tial~ graph grammar which formalizes the graph rewriting process based on the above sequence of steps. In this way a framework is provided which (1) should enhance the understanding of the basic features of graph grammars and (2) provides a basis for singling out the essential differences and similarities between various notions of a graph grammar studied in the literature (to iflusstrate this aspect of our model, many sorts of graph grammars are interpreted within our framework). In the literature one e~co~~t~rs quite a variety af different types of graph grammars. Most of them were motivated by application areas such as pattern recognition, semantics of ~rogr~ g languages, compiler description, database systems, s~~fic~~o~ of data types, developmc~t~ biology, etc. Other were motivated by rn~~ern~tic~ ~~s~dcr~t~o~s such as providing sound mathea1990 by H.-J. Kreowski and G. Rozenberg 186 HANS-JijRG KREOWSKI AND GRZEGORZ ROZENBERG matical bases for formal studies of graph grammars. A good insight into the variety of different types (models) of graph grammars is given in [l, 3, 41. In this paper we will be concerned with sequential graph grammars (roughly speaking, these are graph grammars in which, in a direct derivation step, one rule is applied to one occurrence of its left-hand side). The basic “action” of a graph grammar is a direct derivation step, which consists of an application of a rule (from a given grammar) to a graph. Although, technically speaking, such an application is done quite differently in different models of grammars, in most (if not all) cases it consists of the following sequence of five steps (where the way a step is “implemented” may differ very much in different models). Let M be a graph one wants to rewrite. Then we (i) CHOOSE an occurrence (in M) of the left-hand side of a rule to be applied; (ii) CHECK the application condition, distinguishing in this way between “ valid” and “invalid” occurrences (in M) of the left-hand side; (iii) REMOVE certain parts of the fixed occurrence [chosen by (i) and validated by (ii) above] in the way specified by the rule, (iv) ADD to the remaining part of M (called the remainder) the right-hand side of the rule (in general the add operation does not mean a disjoint union of graphs) ; (v) CONNECT the remainder and the right-hand side of the rule. One can distinguish a number of basic features within each of the steps (i) through (v) above. Informally speaking, a production p is an ordered pair of graphs: its first element is referred to as the left-hand side of p and its second element as the right-hand side of p; a production equipped with additional information (components) is called a rule. (i) [CHOOSE]: Before a rule r can be applied to a graph M, an occurrence of its left-hand side L in M must be located. In general this is done by choosing a graph homomorphism g and then finding g(L) as a subgraph of M-let z be this occurrence of g(L) (actually we refer to L as an occurrence of L). (ii) [CHECK]: Whether or not the given occurrence z in M is valid is decided on the basis of the application condition. For example, an application condition may require that g be a graph isomorphism. Another type of application condition may require that a certain structural restriction on (the “position of”) z in M holds. Such a restriction may demand that among the nodes of M adjacent to z some nodes be (or not be) labeled by certain labels. Or it can be required that nodes of z adjacent to the “rest of” M be within the specified part of z-this part is often referred to as a contact part, and the condition itself as a contact condition. ON STRUCTURED GRAPH GRAMMARS. I 187 (iii) [REMOVE]: Roughly speaking, one could consider an application of r to M as the “replacement” within M of z by the right-hand side R of r. Hence one removes L from M, destroying (“cutting through”) all the edges connecting z with the rest of M. This corresponds to one extreme-we refer to it as the destructive approach. At the other extreme one could preserve (protect) the whole occurrence of z and (in later steps) only add R to it-we refer to this as the totally protective approach. In general one would use an “in-between approach,” specifying_certain parts of z as protected, which then (through g) yields only a part of L as the part to be removed. (iv) [ADD]: After the specified paJ_f of z has been removed from M, R is added to the remainder of M (let M denote this remainder). In general, one does not have to add the whole of R; rather one adds to a a part of R only. This is accomplished by allowing the identification of (gluing together) a part of R with a part of z; such a gluing “prescription” is specified on the level of r for L and R, and then it is carried over (through g) to z and R. (v) [CONNECT]: If the removing of (a part of) z caused the destruction of (some) connections (i.e. edges) between L and the rest of M, then one may want to restore (some of the) destroyed edges by establishing edges between the new nodes of R and the nodes of a that were adjacent to the removed part of z. A possible (re)connection mechanism may require establishing an (incoming) edge labeled by p between a node x of R and a node y of M (that was adjacent to a node z in the removed part of z by an edge labeled by q) only if the tuple (a, p, h, q, c), where u, b, c are labels of x, y, and z respectively, belongs to an (incoming) connection relation fixed for r. In this paper we introduce and investigate a notion of a graph grammar formalizing the five-step direct derivation outlined above. We hope to provide in this way a general framework which will allow one to understand better the existing “tower of Babel” of various types of graph grammars encountered in the literature. We feel that fundamental research into basic features of graph grammars is very much needed in a systematic development of the theory of graph grammars. The present paper is the first of a two-paper series. This paper I is organized as follows. Section 1 recalls some basic notions and establishes the basic notation concerning graphs to be used in this paper. In Section 2 our notion of a graph grammar is introduced, and Section 3 provides three examples illustrating various features of this approach. Finally, in Section 4 the relationship between various models of graph grammars encountered in the literature and our model is discussed. 188 HANS-JijRG KREOWSKI AND GRZEGORZ ROZENBERG In the second paper we present an investigation of basic features of our model. This paper is intended for two types of readers: (1) A reader familiar with the theory of graph grammars. The framework we provide should help such a reader to see various types of graph grammars encountered in the literature in a more uniform light. (2) A reader who wants to start the study uj the area of graph grammars by first learning about a uniform fram~ork and then staying particuIar types of graph grammars from the Iiterat~e, not as separate mode& but rather ar instances of this framework. Such a reader could use our interpretation of various models (in our framework) as an introduction to these models and then study them in depth from the references we point out in the text.