chapter 2 - dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.frankdrewes.preprint.pdf ·...

68
Chapter 2 HYPEREDGE REPLACEMENT GRAPH GRAMMARS F. DREWES, H.-J. KREOWSKI Universit¨ at Bremen, Fachbereich 3, D–28334 Bremen (Germany) E-mail: {drewes,kreo}@informatik.uni-bremen.de A. HABEL Universit¨ at Hildesheim, D–31141 Hildesheim (Germany) E-mail: [email protected] In this survey the concept of hyperedge replacement is presented as an elementary approach to graph and hypergraph generation. In particular, hyperedge replace- ment graph grammars are discussed as a (hyper)graph-grammatical counterpart to context-free string grammars. To cover a large part of the theory of hyperedge re- placement, structural properties and decision problems, including the membership problem, are addressed. Contents 2.1 Introduction .................................... 97 2.2 Hyperedge replacement grammars ............. 100 2.3 A context-freeness lemma ..................... 111 2.4 Structural properties .......................... 116 2.5 Generative power .............................. 124 2.6 Decision problems ............................. 132 2.7 The membership problem ..................... 141 2.8 Conclusion .................................... 155 References .......................................... 156 95

Upload: others

Post on 10-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

Chapter 2

HYPEREDGE REPLACEMENT

GRAPH GRAMMARS

F. DREWES, H.-J. KREOWSKIUniversitat Bremen, Fachbereich 3, D–28334 Bremen (Germany)

E-mail: {drewes,kreo}@informatik.uni-bremen.de

A. HABELUniversitat Hildesheim, D–31141 Hildesheim (Germany)

E-mail: [email protected]

In this survey the concept of hyperedge replacement is presented as an elementaryapproach to graph and hypergraph generation. In particular, hyperedge replace-ment graph grammars are discussed as a (hyper)graph-grammatical counterpart tocontext-free string grammars. To cover a large part of the theory of hyperedge re-placement, structural properties and decision problems, including the membershipproblem, are addressed.

Contents

2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

2.2 Hyperedge replacement grammars . . . . . . . . . . . . . 100

2.3 A context-freeness lemma . . . . . . . . . . . . . . . . . . . . . 111

2.4 Structural properties . . . . . . . . . . . . . . . . . . . . . . . . . . 116

2.5 Generative power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

2.6 Decision problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

2.7 The membership problem . . . . . . . . . . . . . . . . . . . . . 141

2.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

95

Page 2: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges
Page 3: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.1. INTRODUCTION 97

2.1 Introduction

Graph grammars have been developed as an extension of the concept of for-mal grammars on strings to grammars on graphs. Among string grammars,context-free grammars have proved extremely useful in practical applicationsand powerful enough to generate a wide spectrum of interesting formal lan-guages. It is therefore not surprising that analogous notions have been devel-oped also for graph grammars. Corresponding to the different graph-grammarformalisms in the literature, and to the differing opinions about what the term“context-free” means, a number of different types of graph grammars havebeen given this attribute (cf. Feder [1], Pavlidis [2], Della Vigna and Ghezzi[3], Janssens and Rozenberg [4], Slisenko [5], Bauderon and Courcelle [6], Ha-bel and Kreowski [7,8], Montanari and Rossi [9], Lautemann [10], Engelfriet[11,12], and Lengauer and Wanke [13]). Among the most general, there arethe C-edNCE graph grammars surveyed in Chapter 1 and the hyperedge re-placement grammars dealt with in this chapter.

Hyperedge replacement is an elementary approach of graph and hyper-graph rewriting. It was introduced in the early seventies by Feder [1] andPavlidis [2] (under other names) and has been intensively studied since thelate seventies (starting with the special case of edge replacement) by Bauderon,Courcelle, and Engelfriet [6,14,15,16,17], Engelfriet, Heyker, Leih, and Rozen-berg [18,19,20,21,22,23], Drewes, Habel, Kreowski, Lautemann, and Vogler[24,25,7,26,10,27,28,29,30,31,32,33,34], Lengauer and Wanke [35,36,13], andothers.

A hyperedge is an atomic item with a fixed number of tentacles, called thetype of the hyperedge. It can be attached to any kind of structure coming witha set of nodes by attaching each of its tentacles to a node. The hyperedgecontrols the sequence of these attachment nodes and can play the role of aplace holder, which may be replaced with some other structure eventually. Insuch a hyperedge replacement , the hyperedge is removed, and the replacingstructure R is embedded into the original structure. For this purpose, theconsidered structures are equipped with sequences of external nodes. R is thenglued to the remainder of the original structure by fusing each external nodewith the corresponding attachment node. For this, the number of externalnodes in R is required to equal the type of the replaced hyperedge. Thus,referring to the distinction between gluing and connecting approaches discussedin the introduction of Chapter 1, hyperedge replacement belongs to the gluingapproaches.

Page 4: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

98 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

The replacement of a hyperedge by some structure can be iterated if theoriginal structure or the replacing one is equipped with further hyperedges. Ifthe hyperedges are labelled we may define productions . They consist of a labelas left-hand side and a replacing structure as right-hand side. Hyperedge re-placement grammars mainly consist of a start structure and a finite set of suchproductions. If a hyperedge labelled with the left-hand side of a productionis replaced with the right-hand side this is called a direct derivation. If sucha grammar, besides the set of productions and the start structure, providesa specification of terminal structures, it can generate a language: the set ofterminal structures derivable from the start structure.

The aim of this survey is to present the theory of hyperedge replacementgraph grammars. To keep the technicalities as simple as possible, we deal withhypergraphs that consist of sets of nodes and sets of hyperedges as describedabove, rather than with hybrid objects where some underlying structures areequipped with hyperedges in addition. Hypergraphs are general and flexibleenough to cover many interesting cases. In particular, the ordinary directedgraphs are special hypergraphs because hyperedges of type 2 are just directededges. Clearly, undirected graphs can also be handled as a special case.

If a hyperedge is replaced its context is not affected. Therefore, hyperedgereplacement provides a context-free type of rewriting (as long as no additionalapplication conditions are employed). This is the main reason for the fact thatseveral structural results for hyperedge replacement grammars and languagesare quite similar to the properties of context-free string grammars and lan-guages and that many interesting problems turn out to be decidable. In thissurvey we try to cover some typical parts of the theory of hyperedge replace-ment. In particular, we consider structural properties and decision problems.It turns out that the generative power is increasing with the type of hyperedgesinvolved in the derivation process even if one wants to generate only graphsor even string graphs. The generative power of hyperedge replacement gram-mars generating string graphs can be characterized in terms of tree-walkingtransducers.

Concerning decision problems we discuss two types of questions. First,one can ask whether the hypergraphs generated by a given hyperedge replace-ment grammar satisfy a property π of interest. This question—and relatedones—are of course interesting for any kind of language generating device sincethe languages are usually infinite sets. In the case of hyperedge replacementgrammars one can find a large class of such properties π for which the men-tioned question is decidable (closely related results are discussed in Section 5.6of Chapter 5). The second decision problem we are going to address is theclassical membership problem: Does a given hypergraph belong to the con-

Page 5: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.1. INTRODUCTION 99

sidered language? As the reader probably expects, the problem is decidablefor hyperedge replacement languages. However, there is an important differ-ence to context-free string grammars: The membership problem turns out tobe NP-complete. Only restricted subclasses lead to polynomial membershipalgorithms.

Two further, equally important parts of the theory are left out here. Theycan be found in other chapters of this volume. The relation of hyperedge re-placement and node replacement is discussed in Sections 3.3 and 3.4 of Chap-ter 1 and in Section 5.5 of Chapter 5. Furthermore, monadic second-orderlogic on graphs, its relation with hyperedge replacement, and its use in con-nection with hyperedge replacement is presented in Chapter 5 (see in particularSections 5.5–5.7 of that chapter).

The introduction above should have made clear that the chapter presentsan overview of the theory of hyperedge replacement graph grammars ratherthan of their practical use. However, it must be pointed out that hyperedgereplacement is not only a concept of mathematical beauty, but is useful alsofrom a practical point of view. This is no surprise at all. Graphs are usedsuccessfully in all branches of computer science, and context-free generationmechanisms of formal languages are not less important. This opens a wide areaof potential applications. Just to mention some examples, hyperedge replace-ment can be used to model and support the design of VLSI circuits (see, for ex-ample, [13,37] by Lengauer and Wanke), and it has been used in a generator fordiagram editors to describe the context-free part of the syntax of diagrams (see[38,39,40] by Minas and Viehstaedt). An early application to the generationof semi-structured control-flow diagrams was given by Farrow, Kennedy, andZucconi [41] (see also Example 2.2.2). In general, wherever classes of graphs orhypergraphs are to be specified, generated, manipulated, etc. it seems a goodidea to distinguish between context-free aspects and non-context-free ones, andto describe the former by a context-free rewriting mechanism like hyperedgeor node replacement (see also Chapter 1).

The survey is organized in the following way. Section 2.2 provides the basicnotions and notations of hyperedge replacement grammars. In Section 2.3,the context-freeness lemma is presented stating that derivations in hyperedgereplacement grammars do not interfere with each other as long as they concerndifferent hyperedges. This is the key result to the major part of the theory ofhyperedge replacement as discussed in this chapter. Some structural properties(including a fixed-point theorem, a pumping lemma and a Parikh theorem) arepresented in Section 2.4, while the generative power is considered in Section 2.5.Sections 2.6 and 2.7 are devoted to decision problems. While in Section 2.7the membership problem is discussed, Section 2.6 concerns the decidability

Page 6: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

100 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

of properties of hypergraphs and hypergraph languages. Each of the mainsections ends with bibliographic notes and hints to further results.

2.2 Hyperedge replacement grammars

In this section, we introduce hyperedge replacement grammars as hypergraphmanipulating and hypergraph-language generating devices. A simple examplemay perhaps be useful to illustrate the idea. Let us consider directed graphswith multiple edges having two distinguished nodes begin and end . We canreplace an edge e of a graph G with another graph G′ by removing e fromG, adding G′ disjointly, and fusing the begin-node of G′ with the source of eand the end -node of G′ with the target of e. The resulting graph is denotedby G[e/G′]. An example is given in Figure 2.1. Note that G[e/G′] keeps the

begin ende begin

end

begin end

G G′ G[e/G′]

Figure 2.1: The replacement of an edge.

begin- and end -nodes of G.Now, let us allow in addition to label edges with arbitrary symbols. Then

we can build productions whose left-hand sides are labels and whose right-handsides are graphs. A production S ::=G′ is applied to a graph G by choosing anedge e labelled with S and replacing it with G′, which yields a direct derivationG=⇒G[e/G′]. The productions shown in Figure 2.2, for instance, generatethe set of series-parallel graphs (which describe a simple type of concurrentprocesses) if we start with a single, S-labelled edge and apply productionsuntil no S-labelled edge is left. A sample derivation beginning with a slightlylarger graph is shown in Figure 2.3. Here, =⇒∗ denotes the transitive andreflexive closure of =⇒, as usual.

The notion of replacement discussed so far is commonly called edge re-placement , for obvious reasons. It is a special case of the notion of hyperedgereplacement presented in this chapter. In the remainder of this section the

S ::=begin end

S ::=begin end

S S S ::= begin end

S

S

Figure 2.2: Productions to generate series-parallel graphs.

Page 7: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.2. HYPEREDGE REPLACEMENT GRAMMARS 101

begin endS S =⇒

begin endS S

S=⇒

begin endS S S

S=⇒∗

begin endS=⇒

begin endS S

=⇒∗

begin end

Figure 2.3: A derivation using the productions of Figure 2.2.

approach will be defined formally. The first paragraph provides the basic no-tions concerning hyperedges and hypergraphs. In the introduced approach, ahyperedge is an atomic item with a label and an ordered set of tentacles. Aset of nodes together with a collection of such hyperedges (usually with vary-ing numbers of tentacles) forms a hypergraph if each tentacle is attached toa node. Directed and labelled graphs, undirected and unlabelled graphs aswell as strings can be considered as special cases of hypergraphs. For technicalreasons, we assume that the labels are typed by non-negative integers in sucha way that, for each hyperedge, the type of its label and the number of itstentacles coincide.

Moreover, a hypergraph is equipped with a sequence of external nodes,which is used to construct the replacement of hyperedges by hypergraphs.The external nodes correspond to the nodes begin and end in the exampleabove. To make the construction simpler, we assume in addition that theattachment nodes of each hyperedge on the one hand and the external nodeson the other hand are pairwise distinct. It must be pointed out, however, thatthis restriction is no vital one. If it is dropped one can prove normal-formresults yielding systems of the type considered here.

Similar to the example presented above, the replacement of some hyper-edges of a hypergraph by other hypergraphs yields an expanded hypergraph byremoving the chosen hyperedges, adding the replacing hypergraphs and fusingtheir external nodes with the corresponding attachment nodes of the replacedhyperedges. This notion of hyperedge replacement yields the basic steps inthe derivation process of a hyperedge replacement grammar, where the pairof the label of each replaced hyperedge and the replacing hypergraph form aproduction of the grammar.

Page 8: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

102 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

2.2.1 Hypergraphs

By N we denote the set of all natural numbers, including 0. For a set A,A∗ denotes the set of all strings over A, including the empty string λ; A+ =A∗ − {λ} denotes the set of all strings over A, except the empty string λ.For w ∈ A∗, |w| denotes the length of w, [w] denotes the set of all symbolsoccurring in w, and w(i) denotes the i-th symbol in w, for 1 ≤ i ≤ |w|. Thefree symbolwise extension f∗ : A∗ → B∗ of a mapping f : A → B is defined byf∗(a1 · · · ak) = f(a1) · · · f(ak) for all k ∈ N and ai ∈ A (i = 1, . . . , k).

In the following, let C be an arbitrary, but fixed set of labels and lettype : C → N be a typing function for C. A (hyperedge-labelled, multi-pointed)hypergraph H over C is a tuple (V,E, att , lab, ext) where V is a finite set ofnodes , E is a finite set of hyperedges , att : E → V ∗ is a mapping assigning asequence of pairwise distinct attachment nodes att(e) to each e ∈ E, lab : E →C is a mapping that labels each hyperedge such that type(lab(e)) = |att(e)|,and ext ∈ V ∗ is a sequence of pairwise distinct external nodes.

The components of a hypergraph H may be denoted by VH , EH , attH ,labH , extH , respectively. Furthermore, given a set X ⊆ C of labels we denoteby EX

H the set {e ∈ EH | labH(e) ∈ X} of hyperedges of H with labels in X.The number of nodes plus the number of hyperedges of H is called the size ofH, denoted by |H|. The class of all hypergraphs over C is denoted by HC .

If the hypergraph in question is understood, we say that e ∈ E is an m-edge for some m ∈ N and m is its type, denoted by type(e), if type(lab(e)) = m.In order to avoid confusion we may also write typeH(e) if H is the hypergraphreferred to. H ∈ HC is an n-hypergraph for some n ∈ N and n its type, denotedby type(H), if |extH | = n.

The sequence of external nodes may be empty so that ordinary hyper-graphs (without external nodes) may be seen as 0-hypergraphs and in this wayas special cases of hypergraphs with external nodes. An n-hypergraph H overC is considered as a (directed) n-graph if all hyperedges of H are 2-edges.The first node of the attachment nodes of a 2-edge corresponds to the sourceand the second one to the target. The two external nodes of a 2-graph G aredenoted by beginG and endG in this order.

As a convention, an unlabelled hyperedge is a hyperedge labelled with aspecial label ␣ which we do not draw in figures. Subject to this convention,unlabelled graphs and hypergraphs turn out to be special cases of the sort ofhypergraphs defined above.

A graph G = ({v0, v1, . . . , vn}, {e1, . . . , en}, att , lab, v0vn) over C is calleda string graph if v0, v1, . . . , vn are pairwise distinct and att(ei) = vi−1vi fori = 1, . . . , n. If w = lab(e1) · · · lab(en), then G is called the string graph

Page 9: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.2. HYPEREDGE REPLACEMENT GRAMMARS 103

1

f1

2

3

g1

2 3

h1

2

01

01

Figure 2.4: A hypergraph denoting the expression f(g(0, 0), h(g(0, 0))).

induced by w and is denoted by w•. Such a string graph provides a uniquegraph representation of the string w ∈ C+.

In drawings of hypergraphs, a dot (•) represents an external node, inter-nal nodes are drawn as circles, and a box depicts a hyperedge with attachmentnodes, where the label is inscribed in the box, and the i-th tentacle is attachedto the i-th attachment node (i = 1, . . . ,m). In other words, the graphical rep-resentation makes use of the one-to-one correspondence between hypergraphsand bipartite graphs. As an example, see the 1-hypergraph in Figure 2.4, whichrepresents a functional expression with sharing. A 2-edge may also be drawnas an arrow pointing from its first attached node to the second.

An m-hypergraph H with m nodes (that is, all nodes are external) and asingle hyperedge e is said to be a handlea if attH(e) = extH . If labH(e) = A,then H is said to be the handle induced by A and is denoted by A•.

Let H,H ′ ∈ HC . Then H is a sub-hypergraph of H ′, denoted by H ⊆ H ′,if VH ⊆ VH′ , EH ⊆ EH′ , attH(e) = attH′(e), and labH(e) = labH′(e) for alle ∈ EH . Note that nothing is assumed about the relation of the external nodes.H and H ′ are isomorphic if there is a pair h = (hV , hE) of bijective mappingshV : VH → VH′ and hE : EH → EH′ with h∗

V (attH(e)) = attH′(hE(e)) andlabH(e) = labH′(hE(e)) for all e ∈ EH as well as h∗

V (extH) = extH′ .

aNote that this notion of handles differs from the one used in Section 1.4.3 of Chapter 1.

Page 10: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

104 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

2.2.2 Hyperedge replacement

Let H ∈ HC be a hypergraph, B ⊆ EH be a set of hyperedges to be replaced.Let repl : B → HC be a mapping with type(repl(e)) = type(e) for all e ∈ B.Then the replacement of B inH by repl yields the hypergraphH[repl] obtainedby removing B from EH , adding the nodes and hyperedges of repl(e) for eache ∈ B disjointly and fusing the i-th external node of repl(e) with the i-thattachment node of e for each e ∈ B and i = 1, . . . , type(e). All hyperedgeskeep their labels and attachment nodes; the external nodes of H[repl] are thoseof H. If B = {e1, . . . , en} and repl(ei) = Ri for i = 1, . . . , n, then we also writeH[e1/R1, . . . , en/Rn] instead of H[repl].

If, for each e ∈ B, the replacing hypergraph repl(e) consists of the attach-ment nodes as external nodes and nothing else, the replacement of B in Hremoves B and adds nothing. Hence, the result may be denoted by H − B inthis case. The replacement of some hyperedges is illustrated in Figure 2.5.

1 2

3 4

e1

12

3 e2

e3

1

23 e4H −B =⇒

R1

R2

R3

R4H −B

Figure 2.5: The replacement of (unlabelled) hyperedges e1, . . . , e4 with R1, . . . , R4.

Note that the result of a hyperedge replacement is defined only up toisomorphism. Therefore, to keep the technicalities as simple as possible, weusually do not distinguish between isomorphic copies of a hypergraph.

Hyperedge replacement enjoys some nice properties well-known from otherrule-based formalisms. First of all, we have a sequentialization and paralleliza-tion property. It does not matter whether we replace some hyperedges of ahypergraph one after another, or simultaneously. The second property is con-fluence. Hyperedges of a hypergraph can be replaced in any order, withoutaffecting the result. (In fact, this follows already from the sequentializationand parallelization property. If we replace hyperedges simultaneously there isno order among them at all.) The last and maybe most important property

Page 11: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.2. HYPEREDGE REPLACEMENT GRAMMARS 105

is associativity. If a hyperedge is replaced and afterwards a hyperedge of thenew part is replaced with a third hypergraph, the same is obtained by firstreplacing the latter hyperedge and then replacing the first one with the result.These properties are stated formally below.

Sequentialization and parallelization. Let H be a hypergraph with pairwisedistinct e1, . . . , en ∈ EH and let Hi be a hypergraph with type(Hi) = typeH(ei)for i = 1, . . . , n. Then

H[e1/H1, . . . , en/Hn] = H[e1/H1] · · · [en/Hn].

Confluence. Let H be a hypergraph with distinct e1, e2 ∈ EH and let Hi bea hypergraph with type(Hi) = typeH(ei) for i ∈ {1, 2}. Then

H[e1/H1][e2/H2] = H[e2/H2][e1/H1].

Associativity. Let H,H1, H2 be hypergraphs with e1 ∈ EH and e2 ∈ EH1,

such that typeH(e1) = type(H1) and typeH1(e2) = type(H2). Then

H[e1/H1][e2/H2] = H[e1/H1[e2/H2]].

2.2.3 Hyperedge replacement derivations, grammars, and languages

Let N ⊆ C be a set of nonterminals . A production over N is an ordered pairp = (A,R) with A ∈ N , R ∈ HC and type(A) = type(R). A is called theleft-hand side of p and is denoted by lhs(p); R is called the right-hand side andis denoted by rhs(p).

Let H ∈ HC and let P be a set of productions. Let e ∈ EH and(labH(e), R) ∈ P . Then H directly derives H ′ = H[e/R]. In this case, wewrite H =⇒P H ′, or just H =⇒H ′ if P is clear from the context, and call thisa direct derivation. Examples of direct derivations have already been discussedin the beginning of this section (see Figure 2.3).

A sequence of direct derivations H0 =⇒ · · ·=⇒Hk is called a derivation oflength k from H0 to Hk and is denoted by H =⇒∗

P H ′ or H0 =⇒∗ Hk. If thelength of the derivation matters, we write H0 =⇒k Hk. Additionally, if H ′

0 isisomorphic to H0, we speak of a derivation from H0 to H ′

0 of length 0.Using the concepts of productions and derivations, hyperedge replacement

grammars and languages can be introduced in a straightforward way. This isdone below.

Page 12: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

106 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

Definition 2.2.1 (hyperedge replacement grammar) A hyperedgereplacement grammar is a system HRG = (N,T, P, S) where N ⊆ C is a setof nonterminals, T ⊆ C with T ∩N = ∅ is a set of terminals, P is a finite setof productions over N and S ∈ N is the start symbol.

The hypergraph language L(HRG) generated by HRG is LS(HRG), wherefor all A ∈ N , LA(HRG) consists of all hypergraphs in HT derivable from A•

by applying productions of P :

LA(HRG) = {H ∈ HT |A• ∗=⇒P

H}.

We denote the class of all hyperedge replacement grammars by HRG andthe class of all hyperedge replacement languages byHRL. A hyperedge replace-ment grammar HRG = (N,T, P, S) is said to be of order r (for some r ∈ N)if for all (A,R) ∈ P , type(R) ≤ r. A hyperedge replacement language L is oforder r (for some r ∈ N) if there is a hyperedge replacement grammar HRG oforder r with L(HRG) = L. The classes of all hyperedge replacement grammarsand languages of order r are denoted by HRGr and HRLr, respectively. Ahyperedge replacement grammar ERG = (N,T, P, S) such that all right-handsides of productions in P are graphs is also called an edge replacement gram-mar . Note that, if given such an edge replacement grammar, one may alwaysassume without loss of generality that all nonterminal labels except perhapsthe start symbol have type 2. The class of all edge replacement grammars isdenoted by ERG.

Even if one wants to generate graph languages (or string-graph languages)rather than hypergraph languages, one may use nonterminal hyperedges be-cause the generative power of hyperedge replacement grammars increases withtheir order (see Section 2.5). By definition of derivations the set L(HRG) isclosed under isomorphisms. Moreover, L(HRG) is homogeneous, that is, all itshypergraphs are of the same type. Therefore, non-homogeneous languages andlanguages not closed under isomorphism cannot be generated by the grammarsintroduced above.

Example 2.2.2 (generation of semi-structured control-flow graphs)Control-flow graphs of so-called semi-structured programs are useful for dataflow analysis, as shown by Farrow, Kennedy, and Zucconi [41]. These control-flow graphs (seen as hypergraphs) are generated by the hyperedge replacementgrammar FLOW -GRAPHS = ({C,D}, {c, d}, P, C), where P contains the pro-ductions given in Figure 2.6 in a kind of Backus-Naur-Form. (The types ofnonterminal labels are those of the corresponding right-hand sides.) A deriva-tion deriving a multi-exit loop is given in Figure 2.7, where tentacle numbersare omitted.

Page 13: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.2. HYPEREDGE REPLACEMENT GRAMMARS 107

C ::=

1

2

C

C

1

2

D

1

2 3

1

2

D

1

2

3

1

2

c

D ::=

1

2 3

D

C

1

2 3

1

2 3

D

C

1

2

3

1

2 3

D

D

1

2

3

1

2 3

1

2 3

D

D

1

2

3

1

2

3

1

2 3

D

C

1

2

3

1

2 3

D

D

1

2

31

2 3

1

2 3

D

D

1

2

31

2

3

1

2 3

d

1

2 3

Figure 2.6: Productions of the hyperedge replacement grammar FLOW -GRAPHS .

Page 14: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

108 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

1

2

C =⇒

1

2

D

=⇒

1

2

D

D =⇒

1

2

D

D

D

=⇒∗

1

2

D

D

D

...

D. . .

=⇒∗

1

2

d

d

d

...

d

cc

c

c

. . .

Figure 2.7: A derivation in the hyperedge replacement grammar FLOW -GRAPHS .

Page 15: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.2. HYPEREDGE REPLACEMENT GRAMMARS 109

S ::=

1

2

a

b

cA

1

2

3

4

1

2

a

b

c

A ::=

1

2

3

4

a

b

c A

1

2

3

4

1

2

3

4

a

b

c

Figure 2.8: Productions of the hyperedge replacement grammar AnBnC

n.

Example 2.2.3 (generation of a string-graph language) hyperedge re-placement grammar AnBnCn = ({S,A}, {a, b, c}, P, S) where P consists of theproductions depicted in Figure 2.8. Beginning with S•, the application of thesecond production yields the string graph (abc)•. By applying the first produc-tion, then applying the third production n−1 times, followed by an applicationof the fourth production, we obtain the derivation in Figure 2.9. Furthermore,the only hypergraphs in L(AnBnCn) are string graphs of the form (anbncn)•

for n ≥ 1. Thus, L(AnBnCn) = {(anbncn)• |n ≥ 1}.

2.2.4 Bibliographic notes

The kind of introduction chosen here is similar to the one in [42]. It must benoted, however, that the notion of direct derivations chosen here is a purely se-quential one. A direct derivation replaces only one hyperedge. Instead, one can

Page 16: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

110 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

S• =⇒

1

2

a

b

cA

1

2

3

4

=⇒

1

2

a

b

c

a

b

c A

1

2

3

4

=⇒∗

1

2

· · ·

· · ·

· · ·

a

b

c

a

b

c A

1

2

3

4

=⇒

1

2

· · ·

· · ·

· · ·

a

b

c

a

b

c

a

b

c

Figure 2.9: A derivation in AnBnC

n.

as well use a notion of parallel direct derivations, where arbitrarily many hyper-edges can be replaced in one step. More precisely, we could say H =⇒P H[repl ]if repl : B → HC is a mapping with B ⊆ EH and (labH(e), repl(e)) ∈ P for alle ∈ B. Using the sequentialization property of hyperedge replacement quotedabove, it is clear that every derivation consisting of this type of parallel directderivations can be transformed into a derivation using only direct derivationsas defined here. In particular, both notions of direct derivations lead to hyper-edge replacement grammars of equal generative power.

The hyperedge replacement approach presented here is described on aset-theoretical level. Since hyperedge replacement may be seen as a specialcase of hypergraph replacement in the double-pushout approach (see [43]) andthe double-pushout approach has an algebraic description (see Chapter 3),hyperedge replacement has an algebraic description, too. The relation betweenhyperedge replacement languages, logical definability of hypergraph languages,and recognizability has been intensively studied by Courcelle (see Chapter 5).

Courcelle, Engelfriet, and Rozenberg [44] studied the notion of separated

Page 17: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.3. A CONTEXT-FREENESS LEMMA 111

handle-rewriting hypergraph grammars (see also Section 1.4.3 of Chapter 1).These grammars combine the rewriting mechanisms of vertex- and hyperedgereplacement graph grammars. If we restrict our attention to the generationof graphs, handle rewriting grammars are as powerful as the C-edNCE graphgrammars discussed in Chapter 1 and are thus more powerful than hyper-edge replacement grammars. Looking at the more general situation where hy-pergraphs are generated, hyperedge replacement and handle-rewriting graphgrammars turn out to be incomparable, though.

In [23] Engelfriet shows how regular tree grammars can be used to generategraphs, by generating expressions that denote graphs. Top-down and bottom-up tree transducers can then be used as a tool for proving properties of suchgraph generating tree grammars.

As mentioned in the introduction, the idea of hyperedge replacement canalso be applied to structures other than hypergraphs. Considering pictures(that is, subsets of Rd for some d ∈ N) as underlying structures Habel andKreowski [45] introduced the so-called collage grammars. These allow to gen-erate and to study (approximations of) fractal images and other sorts of pic-tures (see the work by Dassow, Drewes, Habel, Kreowski, and Taubenberger[46,47,48,49]).

2.3 A context-freeness lemma

In this section, we present a context-freeness lemma for hyperedge replacementgrammars and languages. Furthermore, we employ the lemma in order to in-troduce derivation trees as a helpful and intuitive representation of derivations.

2.3.1 Context freeness

Most of the results presented in this survey (as, for example, the fixed-pointtheorem and the pumping lemma) are mainly based on the context-free natureof hyperedge replacement. Suppose we are given any notion of replacementallowing to replace primitive components of certain objects with other suchobjects. In the string case the objects would be strings and the primitive com-ponents would be the individual letters. In the case of hyperedge replacementwe have hypergraphs as objects and hyperedges as primitive components. In-tuitively, context-freeness means that in a derivation of an object O′ from andobject O we can consider the primitive components of O separately to derivefrom them the corresponding parts of O′. More precisely, O derives O′ if andonly if each nonterminal component x derives an object repl(x) such that O′

is the object obtained by replacing each nonterminal x of O with repl(x).

Page 18: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

112 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

In the case of type-2 string grammars we can derive a string w fromA1 · · ·An if and only if w = repl(A1) · · · repl(An), where each repl(Ai) is astring derivable from Ai. In the case of hyperedge replacement grammars thesituation is similar, though not as completely obvious. Intuitively, during aderivation that derives a hypergraph H from a hypergraph R the nonterminalhyperedges of R are turned step by step into larger hypergraphs. Thus, eachnonterminal hyperedge of R gives rise to a particular sub-hypergraph of H.The important point is that the applicability of a production depends onlyon the existence of a hyperedge with the required label, and nothing but thishyperedge is affected by the application of the production. Therefore, if weare given a nonterminal hyperedge e ∈ EN

R we may simply forget about thecontext of e in R, keeping only the handle labR(e)•, and restrict the originalderivation accordingly. In this way we get for every e ∈ EN

R a sub-derivationlabR(e)• =⇒∗ repl(e) such that R[repl ] = H. Clearly, the converse is also true:If we are given the hypergraphs repl(e) with labR(e)• =⇒∗ repl(e) (e ∈ EN

R )then the hypergraph R[repl ] is derivable from R. This property justifies to callhyperedge replacement grammars context-free.

Below, we state the result in a recursive version especially suitable forinductive proofs. If a derivation starts in a handle A• it must necessarilyhave the form A• =⇒R=⇒∗ H, where (A,R) is a production. The remainderR=⇒∗ H can now be decomposed as described above.

For the rest of this chapter let us employ the following assumption.

General assumption. Let N , T be two disjoint subsets of the alphabet C.

Theorem 2.3.1 (context-freeness lemma) A ∈ N , and k ∈ N. Then thereis a derivation A• =⇒k+1 H if and only if there is a production (A,R) ∈ P anda mapping repl : EN

R → HC with H = R[repl ], such that labR(e)• =⇒k(e) repl(e)for all e ∈ EN

R and!

e∈ENRk(e) = k.

ProofWe shall prove this result in detail because of central character. By definitionof direct derivations, if a derivation A• =⇒k+1 H exists it must have the formA• =⇒R=⇒k H for some (A,R) ∈ P . Hence, the proof is finished if we canshow the following.

Let G,G′ be hypergraphs. Then we have G=⇒k G′ if and onlyif there is some repl : EN

G → HC with G′ = G[repl ], such thatlabG(e)• =⇒k(e) repl(e) for all e ∈ EN

G and!

e∈ENGk(e) = k.

Page 19: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.3. A CONTEXT-FREENESS LEMMA 113

We proceed by induction on k. For k = 0 both directions are triv-ial, so let us assume k > 0. Proving first the only-if direction, we musthave G=⇒G0 =⇒k−1 G′ where G0 = G[e0/R0] for some e0 ∈ EN

G and some(labG(e0), R0) ∈ P . The induction hypothesis yields a mapping repl0 : E

NG0

HC with G′ = G0[repl0], such that labG0(e)• =⇒k0(e) repl0(e) for all e ∈ EN

G0,

where the sum of the k0(e) is k−1. Now, let repl(e) = repl0(e) for e ∈ ENG \{e0}

and repl(e0) = R0[repl′0], where repl ′0 is the restriction of repl0 to EN

R0. Then,

if repl ′′0 is the restriction of repl0 to EG \ {e0} we get G′ = G0[repl0] =G[e0/R0][repl0] = G[repl ′′0 ][e0/R0][repl

′0] = G[repl ′′0 ][e0/repl(e0)] = G[repl ], as

required.

For the if direction, let G′ = G[repl ] with labG(e)• =⇒k(e) repl(e) for alle ∈ EN

G and!

e∈ENGk(e) = k. We may assume without loss of generality

that k(e) > 0 for all e ∈ ENG (otherwise, consider the restriction of repl to

those hyperedges). Suppose ENG = {e1, . . . , en}. Then there are hypergraphs

Gi (i = 1, . . . , n) such that labG(ei)• =⇒Gi =⇒k(ei)−1 repl(ei) for i = 1, . . . , n.Making use of the (already proved) only-if direction there are repl i : E

NGi

→ HC

for i = 1, . . . , n such that Gi[repl i] = repl(ei), labGi(e)• =⇒ki(e) repl i(e) for all

e ∈ ENGi, and

!

e∈ENGi

ki(e) = k(ei)− 1.

Let G0 = G[e1/G1, . . . , en/Gn] and repl0(e) = repl i(e) for all e ∈ ENGi

(i =1, . . . , n). Then we get G′ = G[repl ] = G[e1/G1[repl1], . . . , en/Gn[repln]] =G[e1/G1, . . . , en/Gn][repl0] = G0[repl0]. By the induction hypothesis thisyields a derivation G0 =⇒k−n G′ and by construction of G0 we have G=⇒n G0,which completes the proof. !

The possibility of decomposing a derivation as stated in the context-freeness lemma may be illustrated as in Figure 2.10. The context-freenesslemma can also be formulated as a characterization of the languages generatedfrom handles, which yields an alternative method of deriving hypergraphs.

Corollary 2.3.2 Let HRG = (N,T, P, S) ∈ HRG. For all A ∈ N let rhs(A) ={R ∈ HT | (A,R) ∈ P}. Then

LA(HRG)=

"

R∈rhs(A)

#

R[repl : ENR → HT ]

$

$ repl(e) ∈ LlabR(e)(HRG) for e ∈ ENR

%

.

ProofApply the context-freeness lemma to terminal graphs which are the elementsof the languages LA(HRG) for A ∈ N . !

Page 20: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

114 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

A

1

2 3

1

2 3

B1

2 3

e1

C1 2

3 4

e2

1

2 3

B1

2 3

e1

1 2

3 4

C1 2

3 4

e2

1

2 3

H(e1)

1 2

3 4

H(e2)

1

2 3

H(e1)

H(e2)

&

&

&

&

'

k+1======⇒

k(e1)==⇒

k(e2)==⇒

Figure 2.10: Decomposition of a derivation according to the context-freeness lemma

2.3.2 Derivation trees

The context-freeness lemma allows us to introduce the concept of derivationtrees as a convenient representation of derivations. Consider some derivationA• =⇒∗ H. If k = 0 then H = A• and we may represent the derivation by aone-node tree whose only node is the label A. Otherwise, the context-freenesslemma states that the derivation has the form A• =⇒R=⇒∗ R[repl ], where(A,R) is a production and labR(e)• =⇒∗ repl(e) for all e ∈ EN

R . Thus, thederivation gives rise to a tree whose root is the production (A,R) and whosesubtrees are the trees obtained recursively from the derivations labR(e)• =⇒∗

repl(e) for e ∈ ENR . Thus, derivation trees represent derivations up to some

reordering of direct derivation steps (which does not affect the result of aderivation, as we know). The resulting hypergraph of a derivation tree is thengiven by R[repl ], where R is the right-hand side of the production in its rootand repl(e) is recursively obtained as the result of the subtree correspondingto e ∈ EN

R .

Definition 2.3.3 (derivation tree) The set TREE (P ) of derivation treesover P is recursively defined as follows.

Page 21: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.3. A CONTEXT-FREENESS LEMMA 115

• N ⊆ TREE (P ) with root(A) = A and result(A) = A• for A ∈ N .

• For every production (A,R) ∈ P and every mapping branch : ENR →

TREE (P ) such that we have type(e) = type(root(branch(e))) for all e ∈EN

R , the triple t = (A,R, branch) is in TREE (P ).

Furthermore, we let root(t) = A and result(t) = R[repl ] where, for alle ∈ EN

R , repl(e) = result(branch(e)).

One should notice that a derivation tree contains nonterminal labels A ∈ Nas subtrees if and only if its result is not terminal. The theorem below statesthe expected correspondence between derivations and derivation trees.

Theorem 2.3.4 Let P be a set of productions over N , let A ∈ N and H ∈ HT .Then there is a derivation A• =⇒∗ H if and only if there is a derivation tree tover P with root(t) = A and result(t) = H.

ProofFor the first direction, suppose t is a derivation tree over P with root(t) = Aand result(t) = H. The proof is by induction. If t = A then root(t)• =A• =⇒0 A• = result(t). If t = (A,R, branch), using the induction hypothesiswe get a derivation root(branch(e))• =⇒∗ result(branch(e)) for all e ∈ EN

R . Bythe context-freeness lemma, this yields a derivation root(t)• = A• =⇒∗ R[repl ] =result(t) with repl(e) = result(branch(e)) for all e ∈ EN

R .The proof for the other direction can be done in a similar way by induction

on the length of derivations using the other direction of the context-freenesslemma. !

An interesting consequence of Theorem 2.3.4 is obtained by considering theroot and the result of a derivation tree over P as a new production. Formally,let P ∗ = {(root(t), result(t)) | t ∈ TREE (P )}. Then, A• =⇒P∗ H if and only ifA• =⇒∗

P H, by Theorem 2.3.4. By induction on the length of derivations thisyields, for every label A and all hypergraphs H,

A=⇒∗P H if and only if A=⇒∗

P∗ H.

This property will be used in Section 2.7 in order to obtain a cubic mem-bership algorithm for a certain class of edge replacement languages.

2.3.3 Bibliographic notes

To emphasize their context-freeness, hyperedge replacement grammars aresometimes called context-free hypergraph grammars (see, for example, [26,18]

Page 22: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

116 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

and Chapter 1 of this handbook). The context-freeness lemma was first for-mulated and proved for edge replacement grammars (see [7]); a formulationfor hyperedge replacement grammars can be found in [26,42]. In [50] Cour-celle presents an axiomatic definition of context-free rewriting. The definitionrequires that a context-free notion of replacement be associative and conflu-ent. As mentioned in Section 2.2 hyperedge replacement indeed satisfies theserequirements. Thus, hyperedge replacement is a context-free rewriting mech-anism in Courcelle’s sense. In fact, though in a somewhat different way, The-orem 2.3.1 also expresses nothing else than associativity and confluence ofhyperedge replacement. It says that the order in which productions are ap-plied is not important (on one side of the equivalence there is no order) andthat we can first build the results of the sub-derivations and afterwards replacethe hyperedges of the initial hypergraph with these results instead of doing itstep by step (which is associativity).

In the literature, some suggestions concerning non-context-free extensionsof hyperedge replacement are encountered. The parallel mode of rewriting asknown from L-systems with tables may be employed. This was studied byEhrig and Tischer [51] for edge replacement and by Kreowski [52] for hyper-edge replacement. David, Drewes, and Kreowski [53] combined this with arendezvous mechanism. Here, nodes of different right-hand sides added in aparallel step can be fused in a certain way whenever the replaced hyperedgesare neighbours. This allows to overcome most of the restrictions. Besidesthe parallel case and other application conditions, Kreowski [54] discusses hy-peredge replacement as a means to specify infinite (hyper)graphs by infinitederivations, which were first investigated by Bauderon [55,56].

Derivation trees as they are defined here are closely related to rule treesas introduced and investigated by Kreowski [25].

2.4 Structural properties

In this section, we discuss some structural properties of hyperedge replace-ment languages. They demonstrate that several results well-known for context-free string languages (like the fixed-point theorem, the pumping lemma, andParikh’s theorem) can be generalized to hyperedge replacement languages.

2.4.1 A fixed-point theorem

We start with a fixed-point theorem for hyperedge replacement languages gen-eralizing Ginsburg’s and Rice’s fixed-point theorem for context-free string lan-guages [57]. It is shown that hyperedge replacement languages are the least

Page 23: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.4. STRUCTURAL PROPERTIES 117

fixed points of their generating productions (considered as a system of languageequations).

In the following, for every set C of labels let us denote by HLC the set ofall languages of hypergraphs over C, that is, HLC is the powerset of HC .

Definition 2.4.1 (system of equations and fixed-point) Let N,T ⊆ Cbe sets of labels with N ∩ T = ∅. A system of equations over N is a mappingEQ : N → HLN∪T . A mapping L : N → HLT is a fixed-point of EQ if, forall A ∈ N ,

L(A) =(

R∈EQ(A)

#

R[repl : ENR → HT ]

$

$ repl(e) ∈ L(labR(e)) for e ∈ ENR

%

.

L : N → HLT is a least fixed-point of EQ if L is a fixed-point of EQ andL(A) ⊆ L′(A) for all A ∈ N and all fixed-points L′ of EQ.

Remarks:

1. A system of equations EQ : N → HLN∪T over N may be denoted byA = EQ(A) for A ∈ N to emphasize the name. Actually, it is nothing elsethan a representation of a set P of productions over N . For P , there is anassociated system of equations EQP : N → HLN∪T defined as EQP (A) ={R | (A,R) ∈ P}. Conversely, a system of equations EQ : N → HLN∪T

over N yields a set of productions P (EQ) = {(A,R) |R ∈ EQ(A)}.

2. The language family L : N → HLT generated by a hyperedge replacementgrammar HRG is given by L(A) = LA(HRG) for A ∈ N .

According to Corollary 2.3.2, the language family generated by a hyperedgereplacement grammar is a fixed-point of the system of equations associatedwith the set of productions of the grammar. Even better, the following holds.

Theorem 2.4.2 (fixed-point theorem) Let HRG = (N,T, P, S) be a hy-peredge replacement grammar, EQP : N → HLN∪T the system of equationsassociated with P , and L : N → HLT the language family generated by HRG.Then L is the least fixed-point of EQP .

ProofLet L′ : N → HLT be a fixed-point of EQ . We have to show L(A) ⊆ L′(A) forall A ∈ N , that is, H ∈ L′(A) for all H ∈ HT with A• =⇒∗

P H. This can beshown by induction on the length of derivations. A• =⇒1

P H implies (A,H) ∈ Pwith H ∈ HT , so that H[empty ] = H is defined for the empty mappingempty : ∅ → HT . Because L′ is a fixed-point of EQ , H = H[empty ] ∈ L′(A).

Page 24: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

118 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

Consider now A• =⇒k+1P H. Due to the context-freeness lemma, there are

(A,R) ∈ P , and derivations labR(e)• =⇒k(e) repl(e) for e ∈ ENR with k(e) ≤ k

and H = R[repl ]. By the induction hypothesis, repl(e) ∈ L′(labR(e)). There-fore, H = R[repl ] ∈ L′(A) because L′ is a fixed-point of EQ . !

2.4.2 A pumping lemma

We now present a pumping lemma for hyperedge replacement languages. Itsays that each sufficiently large hypergraph belonging to a hyperedge replace-ment language can be decomposed into three hypergraphs FIRST , LINK ,and LAST , so that a suitable composition of FIRST , k samples of LINK foreach natural number k, and LAST yields also a member of the language. Thistheorem generalizes the well-known pumping lemma for context-free string lan-guages (see, for instance, [58,59]). As in the string case, the pumping lemmacan be used to show that certain languages are no hyperedge replacementlanguages.

A hypergraph H is substantial if VH = [extH ] or |EH | > 1. A hyperedgereplacement grammar each of whose productions has a substantial right-handside is growing . A growing hyperedge replacement grammar generates onlysubstantial hypergraphs. Note that all except a finite number of hypergraphs ina hyperedge replacement language L are substantial, since {|extH | |H ∈ L} isfinite. Using a straightforward extension of the proof for the well-known resultsaying that one can eliminate empty and chain productions from context-freeChomsky grammars it is not hard to prove the following normal-form result,which is used later on.

Lemma 2.4.3 For every hyperedge replacement grammar HRG we can effec-tively construct a growing hyperedge replacement grammar HRG ′ of the sameorder satisfying L(HRG ′) = {H ∈ L(HRG) |H substantial}.

Definition 2.4.4 (composition and iterated composition)

1. Let X ∈ C. Then H ∈ HC is said to be X-handled if there is a uniquetype(X)-edge e ∈ EH with label X. In this case, e is called the X-handleof H; the hypergraph without the X-handle, H − {e}, is denoted by H⊖.

2. Let H ∈ HC be a hypergraph with X-handle e and let H ′ ∈ HC be atype(X)-hypergraph. Then the hypergraph H[e/H ′] is called the compo-sition of H and H ′ with respect to e and is abbreviated by H ⊗H ′.

Page 25: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.4. STRUCTURAL PROPERTIES 119

3. Let H ∈ HC be an X-handled type(X)-hypergraph. Then for k ∈ N,Hk ∈ HC is recursively defined by H0 = X• and Hi+1 = H ⊗ Hi fori ≥ 0.

Note that, in the definition above, Hi is X-handled, thus Hi+1 is well-defined.

Theorem 2.4.5 (pumping lemma) Let L be some hyperedge replacementlanguage of order r (for some r ∈ N). Then there exist constants p and qsuch that the following is true: For every hypergraph H in L with |H| > pthere are an X-handled hypergraph FIRST, a substantial X-handled type(X)-hypergraph LINK, and a type(X)-hypergraph LAST for some X ∈ C withH = FIRST ⊗ LINK ⊗ LAST, |LINK ⊗ LAST | ≤ q, and type(LINK ) ≤ r,such that FIRST ⊗LINK k ⊗LAST ∈ L for all k ∈ N. Furthermore, for everyhypergraph H in L with |VH | > p we can choose LINK in such a way thatVLINK \ [extLINK ] = ∅.

ProofLet HRG = (N,T, P, S) ∈ HRGr with L(HRG) = L and n the number ofnonterminals. Since there are only finitely many non-substantial hypergraphsin L(HRG) we may assume HRG is growing. Let max be the size of thelargest right-hand side of HRG . Let t ∈ TREE (P ) with root(t) = S and H =result(t) ∈ HT . If |H| > maxn, then t contains a path from the root to a leaflonger than n such that one of the nonterminals, say X, occurs twice. In otherwords, t has a subtree t′ with rootX which has a proper subtree t′′ with rootX.Choose LAST = result(t′′), LINK = result(t′− t′′) and FIRST = result(t− t′)where t′ − t′′ is obtained from t′ by removing the subtree t′′ and t − t′ byremoving t′ from t. Then, FIRST and LINK are X-handled, LINK and LASTare type(X)-hypergraphs, and H = FIRST ⊗ LINK ⊗ LAST . Since HRG isgrowing, LINK must be substantial. As in the case of the pumping lemma forcontext-free string languages one can now show FIRST ⊗LINK k⊗LAST ∈ Lfor all k ∈ N.

If we even have |VH | > p we may choose t′−t′′ in such a way that result(t′−t′′) has at least one internal node. This is because, in this case it suffices toconsider the nodes of the derivation tree of which the corresponding right-handsides have internal nodes. This yields the second statement of the theorem andthus finishes the proof. !

The composition of H using FIRST , LINK , and LAST can be depictedas shown in Figure 2.11. The pumped hypergraphs have the shape depictedin Figure 2.12. Note that FIRST⊖, LINK⊖, and LAST are not necessarilyconnected hypergraphs (see Example 2.4.6 below).

Page 26: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

120 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

FIRST⊖ LINK⊖ LAST

Figure 2.11: The result of composing FIRST , LINK , and LAST .

FIRST⊖ LINK⊖ LINK⊖

· · ·

· · ·

· · ·

LINK⊖ LAST

Figure 2.12: The hypergraph obtained by composing FIRST⊖, k samples of LINK⊖, andLAST .

As in the case of context-free string grammars, the pumping lemma canbe used to show that the finiteness problem is decidable for hyperedge re-placement languages. Another helpful consequence of the pumping lemmais the linear growth within hyperedge replacement languages. More explic-itly, let L be an infinite hyperedge replacement language. Then the pumpingof a large enough member of L yields an infinite sequence of hypergraphsin L, say H0, H1, H2, . . ., and constants c, d ∈ N with c + d > 0 such that$

$VHi+1

$

$ = |VHi|+ c and

$

$EHi+1

$

$ = |EHi|+ d, for all i ≥ 0.

Example 2.4.6 First, we want to illustrate the pumping property for thestring-graph language L = {(anbncn)• |n ≥ 1} that can be generated by a hy-peredge replacement grammar of order 4, as shown in Example 2.2.3. Forn ≥ 3, the string graph (anbncn)• can be decomposed as indicated in Fig-ure 2.13 for the case n = 4.

FIRST is a 2-hypergraph containing the two external nodes of the stringgraph as external nodes. It consists of three chains of edges of length n − 2,an a-chain, a b-chain, and a c-chain, where the a-chain is attached to the firstexternal node and the c-chain is attached to the end of the b-chain. Moreover,it may be seen as 4-handled, where the first pair of tentacles is attached tothe end of the a-chain and the beginning of the b-chain and the second pair oftentacles is attached to the end of the c-chain and the second external node.

Page 27: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.4. STRUCTURAL PROPERTIES 121

1

2

a a a a

bbbb

c c c

cFIRST⊖

LINK⊖

LAST

Figure 2.13: Decomposition of (a4b4c4)•.

1

2

a a a a a

bbbbb

c c c c

c

FIRST⊖

LINK⊖LINK⊖

· · ·

· · ·

· · · LAST

Figure 2.14: Pumping of (a4b4c4)•.

It is composed with the LINK -component with respect to this 4-handle. TheLINK -component possesses a 4-handle which is attached to the target of the a-edge, the source of the b-edge, the target of the c-edge and the second externalnode. Note that neither FIRST⊖ (FIRST without the 4-handle) nor LINK⊖

(LINK without the 4-handle) nor LAST is connected. Moreover, LINK isnon-trivial.

The pumped 2-hypergraphs have the shape shown in Figure 2.14. Obviously,each resulting 2-hypergraph is a string graph of the form (anbncn)• for somen ≥ 1.

One of the main uses of results like the pumping lemma is to prove thatspecific hypergraph languages are no hyperedge replacement languages. Thereis, for example, no hyperedge replacement language of unbounded connectivity.To see this, assume such a language is generated by a hyperedge replacementgrammar of order r. Then, a sufficiently large graph of connectivity greater

Page 28: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

122 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

than r could be written as FIRST⊗LINK⊗LAST , where |LINK ⊗ LAST | ≤ qfor some fixed q, type(LINK ) ≤ r, and LINK contains at least one internalnode. But since q is fixed we may assume that FIRST contains more than rnodes, so FIRST⊗LINK⊗LAST is of connectivity at most r because removingthe external nodes of LINK from the graph yields at least two components.

As another example, the string-graph language {(an2

)• |n ≥ 1} cannot begenerated by a hyperedge replacement grammar because the growth of thenumber of edges is not linear. The pumping lemma can also be used to showthat the string-graph language {(an1 · · · a

n2k)

• |n ∈ N} cannot be generated byany hyperedge replacement grammar of order less than 2k, for k ≥ 1. Thiswill be done in Section 2.5 (see Example 2.5.3).

2.4.3 Parikh’s theorem

As a third structural result, we present the hyperedge replacement versionof Parikh’s theorem [60] which relates hyperedge replacement languages tosemilinear sets. The proof makes use of Parikh’s theorem for context-free stringlanguages by mapping hyperedge replacement grammars to context-free stringgrammars. In the following, for x = (x1, . . . , xn) and y = (y1, . . . , yn) in Nn andc ∈ N, let us define x+y = (x1+y1, . . . , xn+yn), x−y = (x1−y1, . . . , xn−yn),and cx = (cx1, . . . , cxn).

Definition 2.4.7 (Parikh mapping and semilinear set)

1. Let T = {a1, . . . , an} be an alphabet and ψ : HT → Nn be the map-ping given by ψ(H) = (#a1

(H), . . . ,#an(H)), where #ai

(H) denotesthe number of ai-labelled hyperedges in H ∈ HT . Then ψ is called aParikh mapping. For every language L ⊆ HT , ψ(L) denotes the setψ(L) = {ψ(H) |H ∈ L}.

2. A set S ⊆ Nn is linear if S is of the form

S = {x0 +k

)

i=1

cixi | c1, . . . , ck ∈ N},

where k ≥ 1 and x1, . . . , xk ∈ Nn.

3. S ⊆ Nn is semilinear if it is the union of a finite number of linear sets.

Theorem 2.4.8 (Parikh’s theorem) For all hyperedge replacement languagesL and every Parikh mapping ψ, the set ψ(L) is semilinear.

Page 29: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.4. STRUCTURAL PROPERTIES 123

ProofLet L be a hyperedge replacement language and HRG = (N,T, P, S) be ahyperedge replacement grammar with L = L(HRG). We construct a context-free string grammar G as follows: Let str : HN∪T → (N ∪ T )∗ be the map-ping assigning the string str(H) = labH(e1) · · · labH(en) to a hypergraphH with EH = {e1, . . . , en} (ordered in some arbitrary way) and let G =(N,T, str(P ), S) with str(P ) = {(A, str(R)) | (A,R) ∈ P}. Then ψ(L(HRG)) =ψstr (L(G)) where ψstr denotes the usual Parikh mapping for string languages.By Parikh’s theorem for context-free string languages, the set ψstr (L(G)) issemilinear. Consequently, the set ψ(L(HRG)) = ψ(L) is semilinear. !

It is perhaps interesting to notice that one may attach a 1-edge with aspecial label to each internal node of a right-hand side of a production. Thencounting the hyperedges with the special label means counting the number of(internal) nodes. Consequently, counting the number of nodes in hypergraphsof a hyperedge replacement language yields a semilinear set, too. As a secondremark, it is not hard to see that there are several languages L (such as theset of all graphs) which have the semilinearity property but are no hyperedgereplacement languages.

2.4.4 Bibliographic notes

The fixed-point theorem for hyperedge replacement languages was formulatedfor edge replacement in [7] by Habel and Kreowski and for hyperedge replace-ment by Bauderon and Courcelle in [6] (in a slightly different form). Thereader should compare the fixed-point theorem with the way in which Cour-celle defines HR sets of hypergraphs in Section 5.5 of Chapter 5. HR sets ofhypergraphs are just the least fixed-points of systems of equations. However,the allowed equations do not make use of hyperedge replacement. They arebuilt upon a more primitive set of operations, which nevertheless give riseto the same least fixed-points. Thus, HR sets of hypergraphs are hyperedgereplacement languages and vice versa.

The pumping lemma is based on the pumping lemma for edge replacementlanguages given in Kreowski [24]. A hyperedge replacement version was firstgiven in [26] and proved in [42]. Moreover, a number of consequences of thepumping lemma for hyperedge replacement languages can be found in [42].In particular, it is shown that for hyperedge replacement languages of simplegraphs the clique size and the minimum degree is bounded.

Page 30: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

124 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

The extension of Parikh’s theorem to hyperedge replacement languageswas first published in [42]. Extensions of Parikh’s theorem are also discussedin Section 5.6.3 of Chapter 5.

2.5 Generative power

In this section, we discuss the generative power of hyperedge replacement gram-mars, dependent on their order. By definition, HRL0 ! HRL1 ! HRL2 ! · · ·since there cannot occur any hypergraph of type k in a language L ∈ HRLk′ ,for k > k′. In the following the generative power of graph and of string-graphgenerating hyperedge replacement grammars is studied.

2.5.1 Graph-generating hyperedge replacement grammars

We first show that the generative power of hyperedge replacement grammarsdepends on their order, that is, on the maximum number of tentacles involvedin the replacement of hyperedges, even if only graph-generating grammars areconsidered. For example the set of all (partial) k-trees can easily be shownto be in HRLk. Using the pumping lemma it turns out that this languageis not in HRLk−1. In other words, the family (HRLk)k∈N forms an infinitehierarchy of classes of hypergraph languages, that remains proper if restrictedto graph languages because k-trees are graphs.

Example 2.5.1 (k-tree and partial k-tree) As usual, let us call two nodesof a graph adjacent if they are connected by an edge. A k-clique of a graph isa subset of k pairwise adjacent nodes of this graph. For k ≥ 1, the set kTREEof all k-trees (see Rose [61]) is recursively defined as follows:

• Every complete graph with k nodes is a k-tree on k-nodes.

• Given a k-tree H on n nodes and a k-clique G ⊆ H, a k-tree on n + 1nodes is obtained when a new (n + 1)-th node is made adjacent to eachnode of G.

A partial k-tree is an undirected graph that is obtained from a k-tree by remov-ing an arbitrary number of edges. The set of all partial k-trees is denoted bykTREEp. For arbitrary, but fixed positive k, one can easily find a hyperedgereplacement grammar HRGkTREE of order k generating the set of all k-trees.The grammar simulates the recursive construction of a k-tree: There is oneproduction that produces a new node new and k + 1 hyperedges indicating theold k-clique and the k newly created k-cliques. The second production allows to

Page 31: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.5. GENERATIVE POWER 125

S ::=

1

2 3

S

1

2

3

S

1

2

3

S1

2

3

S1

2 3

1

2 3

Figure 2.15: Productions to generate 3-trees.

replace a hyperedge by a k-clique. For k = 3 this yields productions as shown inFigure 2.15. Thus, for k ≥ 1, the set kTREE can be generated by a grammarof order k. Suppose kTREE is a language of order k−1. Then, except perhapsa finite number, all elements in kTREE are of connectivity ≤ k− 1 due to thepumping lemma. On the other hand, each k-tree with at least k+1 nodes is ofconnectivity k, a contradiction.

Furthermore, for k ≥ 2, the addition of a production removing an ordinaryedge yields a hyperedge replacement grammar HRGkTREEp of order k generat-ing the set of all partial k-trees. Hence, by the same arguments as above, fork ≥ 2 the set pkTREE of all partial k-trees can be generated by a grammar oforder k, but not by a grammar of order k − 1.

Let LGRAPH be the class of all graph languages. As an immediate conse-quence of Example 2.5.1, we get the following result, saying that the classesGLk = HRLk ∩ LGRAPH (k ∈ N) of hyperedge replacement graph languagesof order k form a proper hierarchy.

Theorem 2.5.2 (hierarchy theorem 1)GLk ! GLk+1 for all k ∈ N.

2.5.2 String-generating hyperedge replacement grammars

Let us now turn to the classes of string-graph languages generated by hyperedgereplacement grammars of order k. We denote by SLk the set of all hyperedgereplacement languages of order k which solely consist of string graphs. Com-pared with the situation encountered above, these classes turn out to behave

Page 32: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

126 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

slightly different. We show that the family (SL2k)k≥1 forms an infinite hierar-chy that starts with the class of context-free string languages (represented asstring-graph languages), but SL2k+1 = SL2k for all k ∈ N.

It is quite obvious that, for a given string language L, L• is in SL2 ifand only if L is context-free. If L is context-free, just choose the set of allproductions (A,w•) for which (A,w) is a production in the given context-free grammar to build an edge replacement grammar yielding L•. For theother direction, using standard techniques one can remove productions thatjust delete an edge. Afterwards, it is not hard to see that every right-handside of a production applied in a derivation yielding a string graph must bea string graph, and the productions of this kind obviously induce the neededcontext-free productions for the string case.

In the following, we present an example of a string-graph language thatcan be generated by a grammar of order 2k, but not by a grammar of smallerorder. As a consequence, we get a proper language hierarchy.

Example 2.5.3 The string-graph language Lk = {(an1 · · · an2k)

• |n ∈ N} canbe generated by the hyperedge replacement grammar of order 2k, for every k ≥1. The construction is a straightforward generalization of the one presented inExample 2.2.3. Thus, Lk is a string-graph language of order 2k. Making useof the pumping lemma, it can be shown that Lk is no string-graph languageof order 2k − 1. To see this, assume Lk is a languageof order 2k − 1. LetFIRST , LINK , and LAST be as in the pumping lemma, for some sufficientlylarge member of Lk. Then LINK has type less than 2k and is substantial. Thelatter implies ELINK⊖ = ∅ because |VH | = |EH |+ 1 for all H ∈ Lk.

Since FIRST ⊗ LINK ⊗ LAST is a string graph the connected compo-nents of LINK⊖ must be paths whose first and last nodes are in [extLINK ] ∪[attLINK(e)], where e is the X-handle of LINK . Hence, the number of con-nected components of LINK⊖ which contain at least one edge is at most k−1.Moreover, none of these connected components can contain edges with differ-ent labels, since otherwise pumping obviously yields graphs not in Lk. Butthen LINK⊖ lacks at least one of the labels, so FIRST ⊗ LINK ⊗ LAST ∈ Limplies FIRST ⊗ LAST ∈ L because ELINK⊖ = ∅.

A similar reasoning as in the previous example shows that the string-graphlanguage W k = {(wk)• |w ∈ T+} is of the same type. It can be generated bya hyperedge replacement grammar of order 2k but not by any one of order2k − 1. The example proves the second hierarchy theorem.

Page 33: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.5. GENERATIVE POWER 127

Theorem 2.5.4 (hierarchy theorem 2)For all k ∈ N, SL2k ! SL2(k+1).

The obvious question is, of course, whether one can also prove SLk !SLk+1. More general, which string-graph languages are generated by hyper-edge replacement grammars of order k? In the following, we want to give acharacterization by Engelfriet and Heyker [19] of these languages by means ofdeterministic tree-walking transducers , a class of finite automata operating ontrees that was introduced by Aho and Ullman. These transducers act on regu-lar sets of terms (that we may also consider as sets of ordered trees over someranked alphabet). A regular set of terms is generated by a regular tree grammar(see [62]) R = (Σ,Γ,Ψ, γ0), where Σ is a ranked alphabet, Γ is a set of nonter-minals with γ0 ∈ Γ (the start symbol), and Ψ is a finite set of productions ofthe form γ→ f(γ1, . . . , γn), for γ, γ1, . . . , γn ∈ Γ and f ∈ Σ of rank n. The lan-guage L(R) of terms generated by R is defined in the obvious way. It containsall terms over Σ that can be derived from γ0 by considering the productions asterm rewrite rules. The set occ(t) of occurrences of a term t over Σ is defined asusual: If t = f(t1, . . . , tn) then occ(t) = {λ} ∪ {io | 1 ≤ i ≤ n and o ∈ occ(ti)}.We denote by o(t) the symbol at occurrence o ∈ occ(t) and by t/o the subtermof t whose root is the occurrence o in t. The parent occurrence of oi (i ∈ N) iso and the parent occurrence of λ is ⊥.

Definition 2.5.5 (deterministic tree walking transducer) A determin-istic tree walking transducer (dtwt) is a tuple M = (Q,R,∆, δ, q0, F ), whereQ is a finite set of states with q0 ∈ Q (the initial state) and F ⊆ Q (theset of final states), R = (Σ,Γ,Ψ, γ0) a regular tree grammar, ∆ the out-put alphabet, and δ : Q × Σ → Q × D × ∆∗ the transition function withD = {stay , up} ∪ {down(i) | i ≥ 1}.

A configuration of M is a tuple (q, t, o, w) with q ∈ Q, t ∈ L(R), o ∈occ(t) ∪ {⊥}, and w ∈ ∆∗. A step of M turns (q, t, o, w) into (q′, t, o′, ww′) ifwe have δ(q, o(t)) = (q′, d, w′) and either

• d = up and o′ is the parent occurrence of o, or

• d = stay and o′ = o, or

• o(t) is of rank ≥ i, d = down(i), and o′ = oi.

If M , starting with configuration (q0, t,λ,λ), finally reaches a configuration(q, t,⊥, w) with q ∈ F then the computation is successful and yields the outputw. L(M) denotes the language of all outputs of M , and DT WT + denotes theclass of all dtwt’s M with λ ∈ L(M).

Page 34: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

128 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

A property of dtwt’s that will turn out to be related to the order of hy-peredge replacement grammars is the so-called crossing number. Consider asuccessful run of M on t. Every move from an occurrence o to an occurrence o′

or from o′ to o, where o′ is the parent occurrence of o, is a crossing of the edgebetween o and o′. If k ∈ N is such that for no successful run on any input tree,an edge is crossed more than 2k times then M is said to be k-crossing. Notethat every dtwt is k-crossing for some k ∈ N, for if a computation crosses anedge more than |Q| times, a node is visited twice with the same state, so thecomputation cannot end. Let us denote by DT WT +

k the set of all k-crossingM ∈ DT WT +. Then, the following can be shown.

Lemma 2.5.6For all k ∈ N, SL2k+1 ⊆ L(DT WT +

k ).

ProofWe roughly sketch the basic idea underlying the construction. One first provesthat a given hyperedge replacement grammar HRG = (N,T, P, S) generatinga string-graph language can be modified (without changing the order), suchthat for every A ∈ N there is some outA ∈ {0, 1}type(A) such that for allH ∈ LA(HRG) the out-degree of extH(i) is outA(i), for i = 1, . . . , type(A).Furthermore, one can ensure by a straightforward construction that for everyright-hand side R in HRG and all distinct e, e′ ∈ EN

R we have labR(e) =labR(e′). Then one can construct a dtwt M = (Q,R, T, δ, q0, F ) ∈ DT WT +

k

with L(M) = L(HRG), as follows.R is designed so that, roughly speaking, L(R) is the set of derivation trees

of HRG . The nonterminals of R are those of HRG , the start symbol is S,and the alphabet is P , where every (A,H) ∈ P has rank

$

$ENH

$

$. For everyproduction p = (A,H) ∈ P , choose an arbitrary (but fixed) order e1, . . . , en onEN

H , and let R contain the production A→ p(labH(e1), . . . , labH(en)). Now, Mis constructed to walk on the trees t ∈ L(R). Every node of a right-hand sideof a production in P is a state of M . If M is at occurrence o of t ∈ L(R) ando(t) = (A,H), then the current state is a node v of H. M works by searchingfor the occurrence in t generating the terminal edge e whose first attached nodeis the image of v in the generated string graph. If there is some e ∈ ET

H withattH(e, 1) = v, the occurrence has been found. M follows e by changing itsstate to attH(e, 2), outputs labH(e), and stays at the same occurrence of t. Ifthere is no such edge, but there is ei ∈ EN

H and j ∈ {1, . . . , type(labH(ei))} withattH(ei, j) = v and out labH(ei)(j) = 1, then M moves to the i-th subtree by adown(i)-move and proceeds in state extH′(j) (where H ′ is the right-hand sideof the new occurrence). If neither one of these two possibilities holds, the edgesought is not generated within the current subtree, so v must be an external

Page 35: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.5. GENERATIVE POWER 129

node extH(i) of H (since a string graph is generated). Then M performs anup-move and—if H ′ is the right-hand side of the occurrence reached thereby—assumes state attH′(e, i), where e is the (unique) A-labelled hyperedge of H ′.

In order to implement the down- and up-moves correctly we have to usesome auxiliary states that remember i and (A, i), respectively, since we do notknow H ′ in advance. Since M enters and leaves the occurrences of an inputtree in states which are external nodes of the right-hand sides, and none ofthese external nodes is used twice it is not hard to see that M is k-crossing. !

Lemma 2.5.7 For all k ∈ N, L(DT WT +k ) ⊆ SL2k.

ProofThe construction is based on the following ideas. First, one shows that itsuffices to consider transducers M without stay-moves that produce exactlyone output symbol in each step. (The latter is due to the fact that for L•

1 ∈ SLk

the image L2 of L1 under a string homomorphism satisfies L•2 ∈ SLk, provided

λ ∈ L2.) Now, ifM satisfies these requirements and is k-crossing, every subtreet/o of an input tree t is visited at most k times, where a visit to t/o is consideredto start at occurrence o at the time it is entered from its parent occurrence o′

and ends at o′ at the time o′ is reached the next time. During each visit, a(nonempty) substring of the output string is produced. The visit—and thusthe string produced —- is composed of the visits to the immediate subtrees,which are connected by the steps where M is at occurrence o, leaving it down-or upwards.

To exploit these observations, one designs a hyperedge replacement gram-mar HRG whose derivation trees are more or less the trees in L(R), suchthat the result of a derivation tree corresponding to t/o is the disjoint unionof the l ≤ k substrings generated by the l visits of M to t/o. The 2l endnodes of the strings are the external nodes, and the substrings resulting fromthe different visits are generated in parallel. Consistency can be ensured byguessing (using the nonterminal labels) the states M is in when the i-th visitbegins and ends, respectively. The productions of HRG corresponding to arule γ0 → f(γ1, . . . , γn) of R are of the form (X0, H), where H has nonterminalhyperedges e1, . . . , en labelled with X1, . . . , Xn. Every label Xi is of the form⟨γi, begini(1)end i(1) · · · begini(li)end i(li)⟩, where li ≤ k and begini(j), end i(j)are the guessed states for the start and the end of the i-th visit to the treegenerated by γi. The type of Xi is 2li and VH =

!ni=0{begini(1), end i(1), . . . ,

begini(li), end i(li)}, where we define attH(ei) = begini(1)end i(1) · · · begini(li)end i(li) for i = 1, . . . , n. In addition, H contains edges labelled with the out-put symbols M generates when leaving the node f , that is, the root of the

Page 36: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

130 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

end0(j) →

begin0(j) and end i(j) →

begini(j) →

2 4

1

a b b

c

3

a

c

⟨γ1, q1q1q2q2⟩ ⟨γ2, q3q3q4q4⟩

Figure 2.16: A Right-hand side in the grammar constructed to simulate a dtwt. The tentaclesof hyperedges are to be numbered from left to right.

subtree generated by γ0, down- or upwards.As an example, see the hypergraph in Figure 2.16. For this to be a consis-

tent right-hand side obtained from γ0 → f(γ1, γ2) we must have, for instance,δ(q1, f) = (q3, down(2), b). !

Lemmas 2.5.6 and 2.5.7 have a number of interesting consequences, ofwhich we mention only two. First of all, it follows that, indeed, the stringgenerating power of hyperedge replacement grammars increases only everysecond step.

Theorem 2.5.8 For all k ∈ N, SL2k = L(DT WT +k ) = SL2k+1.

As mentioned above, every dtwt is k-crossing for some k ∈ N, so we getthe following characterization of the class of all hyperedge replacement string-graph languages.

Theorem 2.5.9 SL = L(DT WT +).

2.5.3 Further results and bibliographic notes

Most of the results concerning the generative power are formulated in [26] andproved in [42].

Page 37: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.5. GENERATIVE POWER 131

The notion of tree-walking transducers was invented by Aho and Ullman([63]; see also [64]). Lemmas 2.5.6 and 2.5.7 and their consequences are takenfrom a paper by Engelfriet and Heyker [19], where the results are proved indetail. (Figure 2.16 is also from [19], although slightly modified.) Engelfrietand Heyker mention a number of additional consequences, including results forlinear hyperedge replacement grammars that generate string-graph languages.Roughly speaking, one obtains the same results as presented here, by lookingat two-way deterministic generalized sequential machines instead of dtwt’s.(The former can be seen as dtwt’s whose second component is a linear regulartree grammar.) From results known for dtwt’s Engelfriet and Heyker alsoobtain the corollary that the class SL, its linear counterpart, and SL2k aresubstitution-closed full AFLs (see [65]).

Asking similar questions for term-generating rather than string-generatinghyperedge replacement grammars Engelfriet and Heyker show in [20] that hy-peredge replacement grammars have the same term-generating power as at-tribute grammars. In this context one should also mention the work by Engel-friet and Vogler [66]. They define the so-called tree-to-graph-to-tree transduc-ers, a sort of tree transducers making use of hyperedge replacement in order toconstruct the computed output trees. The main result of [66] states that thesetransducers—in the deterministic total case—have the same power as macrotree transducers (for the later see [67].

Quite a lot is also known about the generative power of hyperedge replace-ment grammars compared with other graph generating types of grammars. Acomparison of hyperedge replacement grammars and boundary edNCE graphgrammars is established by Engelfriet and Rozenberg in [18]. It is shown thathyperedge replacement grammars and boundary graph grammars of boundednonterminal degree have the same power, both for generating sets of graphsand for generating sets of hypergraphs. Arbitrary boundary graph grammarshave more generating power than hyperedge replacement grammars, but theyhave the same hypergraph generating power (subject to a representation ofhypergraphs as bipartite graphs).

In [68], Engelfriet and Heyker compare the power of hyperedge replacementgrammars and separated handle hypergraph grammars (or S-HH grammars)to generate hypergraph languages of bounded degree. It is shown that everyS-HH language of bounded degree can be generated by a (separated) hyperedgereplacement grammar. This implies that those two types of grammars generatethe same class of graph languages of bounded degree. In the general case,incomparable classes of hypergraph languages are generated.

Page 38: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

132 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

In [22], Engelfriet, Heyker, and Leih show that hyperedge replacementgraph languages of bounded degree are generated by apex graph grammars.

In [16], Courcelle separates vertex replacement from hyperedge replace-ment: A set of graphs generated by vertex replacement is a hyperedge re-placement language if and only if its graphs do not contain arbitrarily largecomplete bipartite graphs Kn,n as subgraphs if and only if its graphs have anumber of edges that is linearly bounded in terms of the number of vertices.These properties can be shown to be decidable.

In [17], Courcelle and Engelfriet give a grammar independent characteriza-tion of hyperedge replacement languages (see also Section 1.4.2 of Chapter 1).These are exactly the images of the recognizable sets of finite trees under cer-tain graph transformations definable in monadic second-order logic. Severalresults follow saying that sets of graphs defined by vertex-replacement satisfy-ing additional conditions (like bounded degree, planarity, bounded tree-width,or closure under subgraphs or minors) are hyperedge replacement languages.

2.6 Decision problems

A hyperedge replacement grammar specifies a hypergraph language. Unfor-tunately, the derivation process never produces more than a finite subset ofthe language explicitly (and even this may consume much time before sig-nificant members of the language occur). Hence, one may wonder what thehyperedge replacement grammar can tell about the generated language. As amatter of fact, the context-freeness lemma leads the way. Given a hyperedgereplacement grammar and an arbitrary terminal hypergraph H with derivationA• =⇒R=⇒∗ H, we get a decomposition of H into smaller components whichare derivable from the handles of the hyperedges in R. This can be employedif one wants to reason about certain graph-theoretic properties or numericalfunctions on (hyper)graphs. The first leads to the notion of compatible prop-erties , the second to compatible functions.

2.6.1 Compatible properties

If a graph-theoretic property can be tested for each H generated by a hyper-edge replacement grammar by testing the property (or related properties) forthe components and composing the results to a result for H, it is called com-patible. It can be shown that compatibility implies decidability of the followingquestions:

Page 39: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.6. DECISION PROBLEMS 133

• Is there a hypergraph in the generated language having the property?

• Do all hypergraphs in the generated language (except perhaps for a finitenumber) have the property?

• Are there only a finite number of hypergraphs in the generated languagehaving the property?

These decision problems are reduced to the emptiness problem and to thefiniteness problem by a filter theorem that shows that the intersection of ahyperedge replacement language with the set of hypergraphs that satisfy acompatible property is a hyperedge replacement language, too.

As an illustrating example, let us consider the property that two externalnodes of a hypergraph are connected by a path. Let H ∈ HC and v, v′ ∈ VH . Avv′-path (in H) is an alternating sequence v0e1v1 · · · envn with v0, . . . , vn ∈ VH ,e1, . . . , en ∈ EH , v = v0, and v′ = vn such that, for i = 1, . . . , n, vi−1 and viare attachment nodes of ei. If there is such a path, H is called vv′-connected .

Let HRG = (N,T, P, S) ∈ HRG, and consider A• =⇒R=⇒∗ H with(A,R) ∈ P and H ∈ HT as well as labR(e)• =⇒∗ H(e) for e ∈ EN

R givenby the context-freeness lemma. Hence we can assume H = R[repl ].

If H is vv′-connected, there is a path p = v0e1v1 · · · envn connecting v andv′. Then either ei ∈ ET

R or ei ∈ Erepl(e) for some e ∈ ENR (i = 1, . . . , n).

Replace now, for all e ∈ ENR , each longest subpath vi(e)ei(e)+1 · · · ej(e)vj(e) of p

in repl(e) where i(e) < j(e) with vi(e) e vj(e). This yields a vv′-path in R suchthat repl(e) is vi(e)vj(e)-connected for each e ∈ EN

R on this path. Conversely,if one has such paths in R and in the components repl(e), one gets obviouslya vv′-path in H.

This means that the vv′-connectedness of H can be checked by looking fora vv′-path in R and checking corresponding connectedness properties for somecomponents of H. If v and v′ are external nodes of H, one obtains a terminat-ing recursive procedure because the components have shorter derivations thanH. Moreover, connectedness needs to be considered for only a finite numberof pairs of natural numbers because the external nodes of a hypergraph areordered and their number is bounded by the order of the given grammar if theinvolved hypergraph is derived from a handle.

Definition 2.6.1 (compatible predicate) Let C ⊆ HRG and let I be a (pos-sibly infinite) index set, such that there is an effective procedure constructingfor every HRG = (N,T, P, S) ∈ C a finite subset IHRG of I, together with

Page 40: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

134 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

some distinguished index i(type(S)) ∈ IHRG . Let PROP ′ be a decidable predi-cate defined on triples (R, ass, i), with R ∈ HC , ass : EN

R → I a mapping, andi ∈ I, and let PROP(H, i) = PROP ′(H, empty , i) for H ∈ HT and i ∈ I.

Then PROP is (C,PROP ′)-compatible if for every HRG = (N,T, P, S) ∈C, all derivations A• =⇒R=⇒∗ H with H ∈ HT , and all i ∈ IHRG we havethat PROP(H, i) holds if and only if there is a mapping ass : EN

R → IHRG suchthat PROP ′(R, ass, i) holds and PROP(H(e), ass(e)) holds for all e ∈ EN

R .The unary predicate PROP0 that holds on H ∈ HT with type(H) = k if

and only if PROP(H, i(k)) holds, is called C-compatible.

It is not difficult to see that compatible predicates are closed under booleanoperations. In addition to the properties of hyperedge replacement languagesdiscussed in Section 2.4, one can now show one more structural property inconnection with compatible properties: The set of all hypergraphs from ahyperedge replacement language satisfying a compatible property is again ahyperedge replacement language.

Theorem 2.6.2 (filter theorem) Let PROP0 be a C-compatible predicatefor some C ⊆ HRG. For every HRG ∈ C there is a hyperedge replacementgrammar HRGPROP0

such that L(HRGPROP0) = {H ∈ L(HRG) |PROP0(H)}.

ProofLet HRG = (N,T, P, S) and let IHRG , PROP ′, and i(type(S)) be as in Def-inition 2.6.1. Then we construct a hyperedge replacement grammar HRG ′ =(N ′, T, P ′, S′) as follows.

• N ′ = N × IHRG ;

• P ′ is the set of all pairs ((A, i), (R, ass)) such that (A,R) ∈ P , ass(e) ∈IHRG for e ∈ EN

R , i ∈ IHRG , and PROP ′(R, ass , i) holds, where (R, ass)denotes the hypergraph (VR, ER, attR, lab, extR) with lab(e) = labR(e) iflabR(e) ∈ T and lab(e) = (labR(e), ass(e)) if labR(e) ∈ N ;

• S′ = (S, type(S)).

It remains to show L(HRG ′) = {H ∈ L(HRG) |PROP(H, type(S))}, whichcan be done by induction on the length of derivations in HRG and HRG ′

respectively, in a straightforward way. !

The Filter Theorem can be used to get several decidability results.

Page 41: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.6. DECISION PROBLEMS 135

Theorem 2.6.3 (decidability of compatible properties) Let PROP0 beC-compatible with respect to some class C of hyperedge replacement grammars.Then for all HRG ∈ C, it is decidable whether

1. PROP0 holds for some H ∈ L(HRG);

2. PROP0 holds for all H ∈ L(HRG);

3. PROP0 holds for no H ∈ L(HRG) except perhaps a finite number;

4. PROP0 holds for all H ∈ L(HRG) except perhaps a finite number.

ProofBy the Filter Theorem, for every hyperedge replacement grammar HRG ∈ C,we can effectively construct hyperedge replacement grammars HRGPROP0

andHRG¬PROP0

generating the sets

L(HRGPROP0) = {H ∈ L(HRG) |PROP0(H)}

andL(HRG¬PROP0

) = {H ∈ L(HRG) | ¬PROP0(H)},

respectively. Now PROP0 holds for some hypergraph H ∈ L(HRG) if andonly if L(HRGPROP0

) is not empty. PROP0 holds for a finite number ofhypergraphs H ∈ L(HRG) if and only if L(HRGPROP0

) is finite. PROP0

holds for all H ∈ L(HRG) if and only if L(HRG¬PROP0) is empty. And

PROP0 holds for all H ∈ L(HRG) except perhaps a finite number if and onlyif L(HRG¬PROP0

) is finite. As a consequence of the pumping lemma, it wasnoted above that the finiteness problem for hyperedge replacement languagesis decidable. Furthermore, the emptiness problem is decidable using the sameproof as in the string case. Altogether, these facts yield the claimed results. !

2.6.2 Compatible functions

We now turn to the discussion of compatible functions, which generalize com-patible predicates. A function on hypergraphs is said to be compatible with thederivation process of hyperedge replacement grammars if it can be computedin the way a compatible predicate can be tested. We restrict the discussion toa certain type of compatible functions that are composed of minima, maxima,sums, and products on natural numbers. They induce compatible predicatesof the form: the function value of a graph exceeds a given fixed integer, orthe function value does not exceed a fixed integer. Consequently, we get thecorresponding decidability results for these predicates as a corollary.

Page 42: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

136 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

Given a function on hypergraphs (like the size, the maximum degree, thenumber of components, etc.) and considering the set of values for a hypergraphlanguage, one may wonder whether this set is finite or not. The question iswhether the language is bounded with respect to the given function. It canbe shown that this boundedness problem is decidable for a class of hyperedgereplacement grammars if the function is compatible and composed of sums,products and maxima of natural numbers.

In order to discuss this result, it is appropriate to enrich N by a specialvalue ⋄. This additional element is useful because sometimes the functionsone would like to consider have no sensible integer value for some arguments.For example, if we are interested in computing the shortest path between twoexternal nodes of a hypergraph we have to take into account that there isperhaps no path at all between these nodes. Therefore, let N⋄ = N+ {⋄} withthe following properties for every index set I and n, ni ∈ N⋄ for i ∈ I, whereI ′ = {i ∈ I |ni = ⋄}:

• ⋄ ≤ n,

•!

i∈I ni = ⋄ and*

i∈I ni = ⋄ if and only if nj = ⋄ for some j ∈ I,

• mini∈I ni = mini∈I′ ni and maxi∈I ni = maxi∈I′ ni, and

• mini∈I ni = ⋄ and maxi∈I ni = ⋄ for I = ∅.

Now, the notion of a compatible function is defined as follows.

Definition 2.6.4 (compatible function)

1. Let C ⊆ HRG and let I be a (possibly infinite) index set, such that there isan effective procedure which constructs for every HRG = (N,T, P, S) ∈ Ca finite subset IHRG of I and a distinguished index i(type(S)) ∈ IHRG .Let VAL be a set of values, f ′ be a function on triples (R, ass, i) with R ∈HC , ass : EN

R × I → VAL, and i ∈ I, and let f(H, i) = f ′(H, empty , i)for H ∈ HT and i ∈ I.

Then f is (C, f ′)-compatible if for all HRG = (N,T, P, S) ∈ C, allderivations A• =⇒R=⇒∗ H with H ∈ HT , and all i ∈ IHRG , f(H, i) =f ′(R, ass, i), where ass : EN

R ×I → VAL is given by ass(e, j) = f(H(e), j)for e ∈ EN

R and j ∈ IHRG .

The function f0 : HT → VAL given by f0(H) = f(H, i(k)) for all H ∈ HT

with type(H) = k is called C-compatible.

Page 43: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.6. DECISION PROBLEMS 137

2. A function f : HT × I → N⋄ is said to be (C,min,max,+, ·)-compatibleif there exists a function f ′ such that f is (C, f ′)-compatible and for eachright-hand side R of some production in C and each i ∈ I, f ′(R,−, i)corresponds to an expression formed with variables ass(e, j) (e ∈ EN

R ,j ∈ I) and constants from N by addition, multiplication, minimum, andmaximum. The function f is (C,max,+, ·)-compatible if the operationmin does not occur.

The function f0 : HT → N⋄ given by f0(H) = f(H, i(k)) for all H ∈HT with type(H) = k is (C,min,max,+, ·)-compatible, or (C,max,+, ·)-compatible, respectively.

Remark:Let f0 : HT → N⋄ be a (C,min,max,+, ·)-compatible function, let n ∈ N⋄,and let ◃▹ be one of the binary predicates ≤, <, =, ≥, and >. Then it isnot difficult to see that the predicate PROP (f0, ◃▹) given for H ∈ HT byPROP (f0, ◃▹)(H) ⇐⇒ f0(H) ◃▹ n is C-compatible. This together with thedecidability results of the previous section yields the solution of some particulardecision problems. For all HRG ∈ C it is decidable whether

• f0(H) ◃▹ n holds for some H ∈ L(HRG);

• f0(H) ◃▹ n holds for only a finite number of hypergraphs H ∈ L(HRG).

• f0(H) ◃▹ n holds for all H ∈ L(HRG).

• f0(H) ◃▹ n holds for all H ∈ L(HRG) except a finite number.

As an example, let us have a look at the function that yields the numberof simple paths of a 2-graph connecting the two external nodes. Given a graphG, a path is called simple if each node appears only once. Let PATHG denotethe set of all simple beginGendG-paths of G and let numpath(G) = |PATHG|be its cardinality. Using the Context-freeness Lemma, if A• =⇒R=⇒∗ G weget PATHG =

"

p∈PATHR{replace(p, path) | path : EN

R → PATHG(e)}, where

replace(p, path) denotes the path obtained from p by replacing all edges e ∈ ENR

on p by the corresponding paths path(e). This obviously yields

numpath(G) =)

p∈PATHR

+

e∈ENR on p

numpath(G(e)).

These observations can be reformulated in terms of compatible functions. LetC be the class of all edge replacement grammars, I = {np}, VAL = N⋄, and

Page 44: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

138 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

f ′ be the function given by f ′(R, ass ,np) =!

p∈PATHR

*

e∈ENR on p ass(e,np).

Then we have f(G,np) = f ′(G, empty ,np) =!

p∈PATHG1 = numpath(G)

and f(G,np) = f ′(R, ass ,np) with ass(e,np) = f(G(e),np) (e ∈ ER), so fturns out to be (ERG, f ′)-compatible. Consequently, the function numpath =f(−,np) is (ERG,max,+, ·)-compatible.

Other compatible functions are the number of nodes, the size, the densityof a hypergraph, that is, the ratio of the number of edges and the numberof nodes, the minimum-path length (of paths connecting external nodes), themaximum-simple-path length (of paths connecting external nodes), the numberof simple cycles, the minimum-cycle length, the maximum-simple-cycle length,the minimum degree, the maximum degree and the number of components.

Theorem 2.6.5 (meta-theorem for boundedness problems) Let f0 be a(C,max,+, ·)-compatible function for a class C of hyperedge replacement gram-mars. Then, for all HRG ∈ C, it is decidable whether there is a natural numbern ∈ N such that f0(H) ≤ n for all H ∈ L(HRG).

ProofLet f , f ′ be the required functions, so that f is (C, f ′)-compatible and f0(H) =f(H, i(type(H))) for H ∈ HT . Let HRG = (N,T, P, S) ∈ C. Then one canshow that f0 is unbounded on L(HRG) if and only if there are A ∈ N , j ∈ IHRG

and A-handled hypergraphs X and Y withX0, Y0 ∈ HT such that the followinghold:

1. A• =⇒∗ H for some H ∈ HT .

2. S• =⇒∗ Y such that f(H, j) ≤ f(Y ⊗H, i0) = f0(Y ⊗H) for all H ∈ HT

with A• =⇒∗ H.

3. A• =⇒∗ X such that f(H, j) < f(X ⊗H, j) for all H ∈ HT that satisfyA• =⇒∗ H.

To check for such A, j, X and Y , one has to inspect the finite number of deriva-tions that start in handles and are of length up to the number of nonterminals.The somewhat tedious technical details are omitted. !

2.6.3 Further results and bibliographic notes

Results which are closely related to those discussed in this section are surveyedin Section 5.6 of Chapter 5 (see also the remarks on inductive predicates andinductively computable functions below). The results about compatibility aretaken from [27,30] by Habel, Kreowski, and Vogler. It must be mentioned,however, that a finite index set was used in these papers. For the case of

Page 45: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.6. DECISION PROBLEMS 139

compatible predicates an infinite index set was first used by Habel, Kreowski,and Lautemann in [34].

The Filter Theorem is published in [28,42]. A corresponding result canbe found in [15]. The statements (1) and (2) of the decidability result arepublished in [27]. In that paper, a direct proof is given which is based on theidea of constructing the set of handles from which a hypergraph with the de-sired property can be derived and checking whether the start handle belongs tothe constructed set. The statements (3) and (4) of the decidability result arepresented in [28,42]. In [31] Lautemann shows how these and several relatedresults in connection with tree decompositions and bounded tree-width canby systematized by the use of finite tree automata and well-known character-izations of recognizability. Some of the methods for finite tree automata arecarried over to deal with certain tree automata with infinite state sets. In thisway it is shown that graph properties defined by formulae of monadic secondorder logic with arithmetic can be decided efficiently for graphs of boundedtree-width, a result which was first shown (in somewhat more general form)by Arnborg, Lagergren, and Seese [69].

In [13], Lengauer and Wanke consider efficient ways of analyzing graphlanguages generated by so-called cellular graph grammars. Cellular graphgrammars are in fact hyperedge replacement graph grammars, defined in aslightly different way. In particular, they generate the same class of graphlanguages. A characteristic of graph properties called finiteness is defined, andcombinatorial algorithms are presented for deciding whether a graph languagegenerated by a given cellular graph grammar contains a graph with a givenfinite graph property. Structural parameters are introduced that bound thecomplexity of the decision procedure and special cases for which the decisioncan be made in polynomial time are discussed. The results provide explicitand efficient combinatorial algorithms.

In [15], Courcelle introduces the notion of a recognizable set of graphs.Every set of graphs definable in monadic second-order logic is recognizable,but not vice versa. It is shown that the monadic second-order theory of hyper-edge replacement languages is decidable. The notion of F -inductive predicatesstudied in [15] is closely related to the concept of compatible properties (seealso Section 5.6.2 of Chapter 5).

In [34], Habel, Kreowski, and Lautemann compare compatible, finite, andinductive graph properties and show that the three notions are essentiallyequivalent. Consequently, three lines of investigation in the theory of hyperedgereplacement—including the one discussed here—merge into one.

Page 46: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

140 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

In [70], Wanke and Wiegers investigate the decidability of the bandwidthproblem on linear hyperedge replacement languages. In particular, they showthe following. Let HRGlin denote the class of all linear hyperedge replacementgrammars generating graphs. Then it is undecidable whether an instance gram-mar HRG ∈ HRGlin generates a graph G having bandwidth k, for any fixedinteger k ≥ 3. The result implies that the bandwidth-k property for k ≥ 3 isnot HRGlin-compatible.

Theorem 2.6.5 is published in [30]. Related work is done in [71] by Cour-celle and Mosbah, who investigate monadic second-order evaluations on tree-decomposable graphs and come up with a general method to translate theseevaluations of graph expressions over suitable semirings. Their method allowsthe derivation of polynomial algorithms for a large number of problems onfamilies of graphs, and especially on graphs definable by hyperedge replace-ment. The notion of inductively computable functions introduced by Courcelleand Mosbah ([71], see also Section 5.6.3 of Chapter 5) is a generalization ofthe concept of inductive predicates which corresponds closely to the notion ofcompatible functions.

Boundedness problems for hyperedge replacement grammars correspondclosely to boundedness problems for finite tree automata with cost functionsover a suitable semiring, investigated by Seidl in [72]. Cost functions for treeautomata are mappings from transitions to polynomials over some semiring or,in the so-called k-dimensional case, to k-tuples of polynomials. (The dimen-sions correspond to the different indices used in the definition of a compatiblefunction.) Four semirings are considered, namely the semiring N over N withaddition and multiplication, the semiring A over N∪ {∞} with maximum andaddition, the semiring T over N ∪ {−∞} with minimum and addition, andthe semiring F over the finite subsets of N with union and addition. It turnsout that for the semirings N and A, it is decidable in polynomial time (if thedimension k is fixed) whether or not the costs of accepting computations isbounded; for F, it is decidable in polynomial time whether or not the cardi-nalities of occurring cost sets are bounded. In all three cases, explicit upperbounds are derived. Moreover, for the semiring T, the decidability of bound-edness is proved, but a polynomial-time algorithm is obtained only in the casethat the degrees of occurring polymonials are at most 1.

In [37], Wanke considers another type of decidability problems on hyper-edge replacement grammars, called integer subgraph problems. The main ideais to transform the decidability problem on hyperedge replacement languagesconcerning function values of graph×subgraph pairs to a decidability problemover semilinear sets.

Page 47: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.7. THE MEMBERSHIP PROBLEM 141

Finally, one should mention an approach to generalize the idea of com-patible functions that was invented by Engelfriet and Drewes [23,73,49,74,75].The approach is based on the observation that the definition of a compatiblefunction can be considered as a tree transduction. The input trees are deriva-tion trees of the hypergraphs in question and the output trees are expressionsusing maximum, addition, and multiplication (viewed as trees), that denotethe computed numbers. Both the derivation trees (denoting hypergraphs) andthe expressions (denoting natural numbers) may be viewed as terms in appro-priate algebras (over hypergraphs and natural numbers, respectively). Thus,the idea is to consider such computations by tree transductions in general. Amapping f : A → B between two algebras A and B is said to be computed bya tree transducer if every term denoting an element a of A is transformed intoa term denoting f(a) in B.

2.7 The membership problem

In this section the possibilities for (efficient) algorithmic solutions to the mem-bership problem for hyperedge replacement languages are discussed. We con-sider membership with respect to a given hyperedge replacement grammarHRG , so the membership problem is defined as follows.

Given: A hyperedge replacement grammar HRG .Instance: A hypergraph H.Question: Is H in the language generated by HRG?

Algorithms that solve the membership problem are called membership al-gorithms. In many cases, one would also wish to parse hypergraphs withrespect to a given grammar, that is, to find a derivation tree for a given hyper-graph, if possible. For technical convenience, we concentrate on the member-ship problem here, but it is easy to see that both the presented algorithms canbe extended in a straightforward way to yield solutions to the parsing problemas efficiently as they solve the membership problem.

2.7.1 NP-completeness

It is not hard to see that the membership problem is in NP for every hyperedgereplacement grammar HRG , because for every such grammar there is a linearfunction f such that, for every hypergraph H of size n, if H ∈ L(HRG) thenH has a derivation of length at most f(n). Thus we can simply use nonde-terminism to guess an appropriate derivation and test whether the generatedhypergraph is isomorphic to H (again using nondeterminism).

Page 48: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

142 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

Clearly, one would like to have more efficient algorithms than the one justsketched, and in particular deterministic ones. It turns out, however, that thecomplexity of the membership problem marks one of the few areas where theresults for hyperedge replacement grammars differ significantly from what weknow about context-free Chomsky grammars. Whereas, for the latter we havethe well-known membership algorithm by Cocke, Kasami, and Younger, whichruns in cubic time, hyperedge replacement grammars are able to generate NP-complete graph languages. Thus, one can expect that there is no generallyapplicable membership algorithm for hyperedge replacement languages. In-tuitively, the reason for this is that, in a string, symbols that result fromone and the same nonterminal form a substring, and there are only O(n2)many substrings of a given string of length n. In contrast, from a nonter-minal hyperedge a somewhat disconnected subgraph may be generated in ahyperedge replacement grammar, so that, in general, there are exponentiallymany possible choices for a subgraph to be generated from a given hyperedge.There are simply too many combinations to be tested, which leads to the twoNP-completeness results presented below. For this, let us call a hyperedgereplacement grammar linear if none of its right-hand sides has more than onenonterminal hyperedge. The node degree of a graph is the maximal numberof edges attached to a node of this graph, and the node degree of a graphlanguages is the maximum node degree of graphs in that language.

Theorem 2.7.1 (NP-completeness 1) There is a linear edge replacementgrammar that generates an NP-complete graph language of degree 2.

ProofWe reduce the NP-complete Hamiltonian path problem (see Garey, Johnson[76], problem GT39, p. 199) to the membership problem for a particular edgereplacement language generated by a linear grammar. In fact, there is aslightly easier way to prove Theorem 2.7.1 using the NP-complete problem3-PARTITION (see [77]). However, we are going to use a modified versionof the proof in order to obtain another theorem below. As we do not knowhow this can be done using 3-PARTITION the Hamiltonian path problem isemployed here.

Let us first define the Hamiltonian path problem. We use a slightly moregeneral version on undirected hypergraphs. An undirected, unlabelled hyper-graph is a triple h = (Vh, Eh, atth), where Vh and Eh are the finite sets ofvertices and hyperedges, respectively, and atth is a mapping assigning to everyhyperedge e ∈ Eh the set atth(e) ⊆ Vh of attached nodes. Now, the Hamilto-nian path problem can be formulated as follows.

Page 49: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.7. THE MEMBERSHIP PROBLEM 143

Instance: An undirected, unlabelled hypergraph h.Question: Is there a Hamiltonian path in h, that is, is there an alternatingsequence v0e1v1 . . . envn of pairwise distinct nodes and hyperedges of h suchthat Vh = {v0, . . . , vn} and vi−1, vi ∈ atth(ei) for all i, 1 ≤ i < n?

Clearly, the generalization to hypergraphs does not affect the NP-hardnessof the problem. Let us define S to be the set of all finite sets S = {s1, . . . , sn}such that the si (1 ≤ i ≤ n) are strings of equal length of the form ui-ui, whereui ∈ {0, 1}∗. We say that ui-ui is word adjacent to uj-uj if ui(l) = uj(l) forsome l, 1 ≤ l ≤ |ui|.

Every S ∈ S defines an undirected, unlabelled hypergraph h(S). If S is asabove, with |si| = 2m + 1 for i = 1, . . . , n, the set of nodes of h(S) is S andthe set of hyperedges is {1, . . . ,m}. Node si is in the set of attachments ofhyperedge j if ui(j) = 1. By definition, two nodes are adjacent in h(S) if thecorresponding strings are word adjacent, so h(S) has a Hamiltonian path if andonly if there is a sequence i1, . . . , in with {i1, . . . , in} = {1, . . . , n} such that,for i = 1, . . . , n− 1, si and si+1 are word adjacent. Clearly, every undirected,unlabelled hypergraph h is represented by some S ∈ S. Furthermore, givenany sensible representation of h we can compute some Sh ∈ S with h = h(Sh)in polynomial time.

We are going to construct a linear edge replacement grammar such thateach of the generated graphs is a string graph, except that some of the edgesare missing. Thus, such a graph represents a multiset of strings. The individualstrings of the multisets generated have the form w-w′, where w,w′ ∈ {0, 1}∗.The multisets themselves will be of the form

{w0-w111w12,w′

111w′12-w211w22,

w′211w

′22-w311w32,

. . .w′

n11w′n2-w1}

where each wi1 is generated along with the corresponding w′i1, and each wi2 is

generated together with the corresponding w′i2. This is used to ensure that wij

and w′ij are of equal length, so that the digit 1 between wi1 and wi2 appears

at the same position as the one between w′i1 and w′

i2. Thus, if such a multisetS is in S it defines a hypergraph with a Hamiltonian path passing the nodesrepresented by the strings above one after the other.

Consider the grammar ERG = ({S,A,B,C,D}, {-, 0, 1}, P, S), where allterminals and nonterminals are of type 2, except for S, which is of type 0,and where P consists of the productions given in Figure 2.17. (In Figure 2.17,

Page 50: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

144 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

S ::= 0/1 A

A ::=1 2

0/1 A1 2

- B

B ::=1 2

0/1

B

0/11 2

1

C

1

C ::=1 2

0/1

C

0/11 2

-B

1 2- D

D ::=1 2

0/1 D1 2

0/1

Figure 2.17: Productions of ERG in the proof of Theorem 2.7.1.

a right-hand side some of whose edges are labelled with “0/1” stands for allright-hand sides in which the respective edges are labelled with 0 or 1.) If weinterpret the graphs in L(ERG) as multisets of strings in the obvious way, thisyields a set S(ERG) whose elements are these multisets. It is not too hard tosee that, as explained above, all these multisets are of the form

{w0-w111w12, w′111w

′12-w211w22, w′

211w′22-w311w32, . . . , w′

n11w′n2-w1}.

The wi1 and w′i1 are generated using the nonterminal B, and the wi2 and w′

i2

result from a nonterminal C. As a consequence, wij and w′ij are indeed of

equal length, so that the 1 between wi1 and wi2 appears in the same positionas the one between w′

i1 and w′i2. Therefore, one can show that the following

holds:

S(ERG) ∩ S is the set of all {s1, . . . , sn} ∈ S for which there isan ordering i1, . . . , in of 1, . . . , n such that sij is word adjacent tosij+1

for all i, 1 ≤ i < n.

Page 51: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.7. THE MEMBERSHIP PROBLEM 145

Clearly, for all S ∈ S some graph H(S) representing S in the same way asabove can be constructed in polynomial time. Now, H(S) ∈ L(ERG) if andonly if h(S) has a Hamiltonian path. We have thus reduced the Hamiltonianpath problem to the membership problem for L(ERG), as required. !

If we drop the requirement of bounded degree in Theorem 2.7.1 we caneven generate an NP-complete language of connected graphs, as one can seeby an easy modification of the grammar used.

Theorem 2.7.2 (NP-completeness 2) There is an edge replacement gram-mar that generates an NP-complete graph language of connected graphs.

ProofWe construct an edge replacement grammar ERG ′ that generates for everygraph H ∈ L(ERG), where ERG is the edge replacement grammar in theproof of Theorem 2.7.1, a graph obtained from H as follows. First, a new nodev0 is added. Then, every edge e labelled - is removed and its two attached nodesare identified, yielding a new node ve. Finally, for each ve a new unlabellededge with attachment v0ve is added. The correspondence between the graphs inL(ERG) and their counterparts in L(ERG ′) constructed this way is a bijectionthat can be computed in polynomial time. Therefore, it remains to give anappropriate grammar ERG ′. We may choose for this the grammar ERG ′ =({S,A,B,C,D}, {0, 1}, P ′, S), where the types of symbols are as in ERG andthe productions are the ones given in Figure 2.18. In order to understand howthe grammar works, the reader should notice that, applying in a first phaseonly the productions with left-hand sides S, A, and B yields a hypergraph asin Figure 2.19. Now, it is easy to see that the remaining productions yield justthe type of graphs aimed at. !

2.7.2 Two polynomial algorithms

In view of Theorems 2.7.1 and 2.7.2 there is not much hope that one can findan efficient solution to the membership problem for arbitrary hyperedge re-placement grammars (and not even for linear edge replacement grammars),since this would require P=NP. It is therefore natural to look for restrictionsthat can be imposed on the languages or grammars to allow for efficient mem-bership algorithms. The proofs of Theorem 2.7.1 and 2.7.2 give a hint. Itseems that, in the first case, the high complexity of the generated language iscaused by the fact that the graphs are disconnected, whereas in the the sec-ond case the potentially unbounded degree of nodes seems to be responsible.In fact, the two cases do not differ too much: The unbounded degree in the

Page 52: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

146 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

S ::=

B

AA ::=

1 20/1 A

1 20/1

B ::=1 2

CB

1

2

A

C ::=

1 2

0/1 0/1

C

1 2

1 1

D

D ::=

1 2

0/1 0/1

D

1 2

Figure 2.18: The productions of ERG′ in the proof of Theorem 2.7.2.

0/1 0/1

C

C

C

Figure 2.19: An intermediate graph generated by the productions in Figure 2.18.

Page 53: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.7. THE MEMBERSHIP PROBLEM 147

second case is nothing else than a hidden disconnectedness that reappears ifa single node is deleted. Later on, this observation will lead to the notion ofk-separability, which is needed to formulate a condition under which the firstmembership algorithm we will discuss runs in polynomial time. As opposed tothe string case both algorithms we are going to present rely on the fact thatthe grammar considered is supposed to be fixed. It is easy to see that therunning time of these algorithms becomes exponential if the grammar is madepart of the input.

In the following, we use the notation H = H0<e1/H1, . . . , en/Hn> to ex-press the fact that H = H0[e1/H1, . . . , en/Hn], where VH = VH0

∪ · · · ∪ VHn,

EH = EH0∪ · · · ∪ EHn

, extH = extH0, and labH(e) = labHi

(e), attH(e) =attHi

(e) for all e ∈ EH ∩ EHi, 0 ≤ i ≤ n. In other words, H0< · · ·> is hyper-

edge replacement on concrete hypergraphs without the possibility to take iso-morphic copies (and is hence not always defined). The notion of X-candidatesis central to the first algorithm we are going to present.

Definition 2.7.3 (X-candidate) Let H be hypergraph and let X ∈ V ∗H . A

hypergraph H ′ ⊆ H is an X-candidate of H if extH′ = X and for everyinternal node v of H ′ and every hyperedge e ∈ EH with v ∈ [attH(e)] we havee ∈ EH′ .

By definition of hyperedge replacement, every hyperedge of a hypergraphH0<e1/H1, . . . , en/Hn> that is attached to an internal node of Hi for somei, 1 ≤ i ≤ n, is a hyperedge of Hi. This can be used to prove that, inH0<e1/H1, . . . , en/Hn>, every Hi (1 ≤ i ≤ n) is an attH0

(ei)-candidate of Hfor i = 1, . . . , n. This fact restricts the number of sub-hypergraphs to be testedrecursively in the membership algorithm below. We formulate the algorithmfor growing hyperedge replacement grammars. By Lemma 2.4.3 this means noloss of generality.

Algorithm 2.7.4Given: A growing hyperedge replacement grammar HRG = (N,T, P, S).Input: A hypergraph H over T .Output: Derive(S, H), where Derive(A,H) =

(1) if A• =⇒R with VR ⊆ VH and ETR ⊆ EH

(where {e1, . . . , en} = ENR )

(2) such that there are substantial attR(ei)-candidates Hi of H(i = 1, . . . , n) with

(3) 1. H = R<e1/H1, . . . , en/Hn>(4) 2. for i = 1, . . . , n we have Derive(labR(ei), Hi)(5) then return true else return false

Page 54: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

148 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

Theorem 2.7.5 For all hypergraphs H ∈ HT Algorithm 2.7.4 terminates andyields true if H ∈ L(HRG), and false otherwise.

ProofSince HRG is growing all hypergraphs that can be derived from A• are substan-tial. Therefore, Algorithm 2.7.4 is nothing else than an algorithmic formulationof the context-freeness lemma. Since the hypergraph R chosen in step (1) andthe attR(ei)-candidates Hi of step (2) are substantial we have |Hi| < |H| fori = 1, . . . , n, so the algorithm must eventually terminate. !

Since there is only a finite set of productions in HRG there are only poly-nomially many possibilities to consider in step (1), and the equality in step (3)can also be tested in polynomial time (note that the test is for equality, not iso-morphy). Hence, there is only a single point that causes an exponential runningtime of the algorithm: the number of X-candidates to be tested. Therefore, weaim at a condition to be imposed on L(HRG) that implies a polynomial upperbound on the number of X-candidates. Let us denote by H \ V , where H isa hypergraph and V ⊆ VH , the hypergraph (VH \ V,EH , att , labH ,λ), whereatt(e) is the restriction of attH(e) to V , for all e ∈ E. A connected componentof H is a maximal connected sub-hypergraph of H. (Note that a 0-edge is aconnected component on its own.)

Definition 2.7.6 (k-separability) For k ∈ N the k-separability k-sep(H) ofa hypergraph H is the maximum number of connected components of H \ V ,where V ranges over all subsets of VH of size at most k. For every languageL of hypergraphs, k-sepL : N → N is defined by

k-sepL(n) = max{k-sep(H) |H ∈ L and |H| ≤ n}.

The following theorem says that logarithmic k-separability of L(HRG)(where HRG is of order k) results in a polynomial upper bound on the runningtime of Algorithm 2.7.4.

Theorem 2.7.7 Let HRG ∈ HRGk be growing. If k-sepL(HRG) ∈ O(log n)

then Algorithm 2.7.4 can be implemented to run in polynomial time in$

$H$

$.

ProofLet H ∈ HT and X ∈ V ∗

Hwith |X| ≤ k. By definition of X-candidates, if

a node of a connected component G of H \ [X] occurs in an X-candidate Hof H, then G ⊆ H. Since there are only a logarithmic number of connected

Page 55: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.7. THE MEMBERSHIP PROBLEM 149

components in H \ [X] this yields a polynomial bound on the number of X-candidates in H if H ∈ L(HRG). Since the number of sequences X ∈ V ∗

Hwith

|X| ≤ k is bounded by |VH |k this yields a polynomial bound on the numberof X-candidates to be considered in the algorithm (that is, if there are moreX-candidates in the input graph it can be rejected immediately).

We are now able to make use of the well-known idea underlying the mem-bership algorithm for context-free Chomsky grammars by Cocke, Kasami, andYounger. In an initial phase, we compute the set of all X-candidates of H,where |X| ≤ k. This can be done in polynomial time since it essentially sufficesto determine all combinations of connected components of the hypergraphsH \ V , where |V | ≤ k. Now, every call to Derive with parameters A and H isperformed only once and the result is stored in a list which is looked up whenrepeated calls occur. As a consequence, the algorithm runs in polynomial timein the number of X-components, which is polynomial in

$

$H$

$, as required. !

The major drawback of Algorithm 2.7.4 is that, even if k-sepL(HRG) isa constant, the running time is bounded by a polynomial whose degree mayvary with HRG . In view of step (1) of the algorithm, for instance, the degreedepends on the size of right-hand sides used in the grammar. We now want todiscuss a membership algorithm for edge replacement grammars that alwaysruns in cubic time. It applies to all input graphs that are almost 2-connected ,a notion to be defined below. Again, the algorithm exploits the idea by Cocke,Kasami, and Younger.

From now on, let us consider some arbitrary (but fixed) edge replacementgrammar (N,T, P, S) with type(A) = 2 for all A ∈ N ∪T . (In particular, everygraph is assumed to be of type 2 in the following, without mentioning.)

Definition 2.7.8 (almost k-connected hypergraph) A hypergraph H is al-most k-connected for some k ∈ N if

• |VH | ≥ k and

• for all hypergraphs H1, H2 and every hyperedge e ∈ EH1, if we have H =

H1[e/H2] and VH1\ [attH1

(e)] = ∅ = VH2\ [extH2

] then type(H2) ≥ k.

Intuitively, almost k-connectedness means that a graph cannot be decom-posed into non-trivial parts using hypergraphs of type less than k. The graphH shown in Figure 2.20, for example, is almost 2-connected, but H ′ is not.

A substantial graph H (of type 2) is a bond if VH = extH , that is, if Hconsists of at least two edges between the external nodes. A substantial string

Page 56: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

150 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

1 2 1 2

H H ′

Figure 2.20: H is almost 2-connected while H′ is not.

graph is said to be a chain. H is called a block if it is almost 3-connected,|VH | > 3, and [attH(e)] = [extH ] for all e ∈ EH . Notice that bonds, chains,and blocks are substantial and that these three classes of graphs are mutuallydisjoint. The smallest bonds and chains are those with two edges. We havethe following theorem about almost 2-connected graphs, that we state withoutproof.

Lemma 2.7.9

1. Let H = H0<e/H1> for substantial graphs H0 and H1. Then H isalmost 2-connected if and only if both H0 and H1 are almost 2-connected.

2. Every substantial 2-connected graph H can be written as H0<e/H1>, forsubstantial graphs H0, H1, unless H is a bond or chain with two edges,or a block.

In the following, let us reserve a label τ to be used as a special one in someconstructions, that is, we assume τ ∈ N ∪ T . For the algorithm we are goingto explain the following notions are of basic importance.

Definition 2.7.10 (total and collapsed split tree) Let H be a hypergraphover T .

1. A total split tree of H is a derivation tree for H over Pt, where Pt isthe set of all productions over {τ} whose right-hand sides are bonds andchains with two edges, and blocks.

2. Let Pc be the set of all productions over {τ} whose right-hand sides arebonds, chains, or blocks. A collapsed split tree of H is a derivation treefor H over Pc such that no edge in this derivation tree connects two bondsor two chains.

By definition, the result of a (total or collapsed) split tree t is a substantial,almost 2-connected graph. Since the left-hand side of productions in a splittree is always τ we may consider a split tree as a pair (H, branch) rather

Page 57: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.7. THE MEMBERSHIP PROBLEM 151

than as a triple (τ, H, branch). Using Lemma 2.7.9 it is not hard to see thatevery substantial, almost 2-connected graph has some total split tree. Froma total split tree one can obtain a collapsed one as follows: As long as asubtree (H, branch) exists with branch(e) = (H ′, branch ′) for some e ∈ EN

H ,where both H and H ′ are bonds or both are chains, replace the subtree by(H[e/H ′], branch ′′), where

branch ′′(e′) =

,

branch(e′) if e′ ∈ EHN − {e}

branch ′(e′) if e′ ∈ EH′

N .

Then H[e/H ′] is a bond (chain, respectively), so the procedure eventuallyleads to a collapsed split tree. As a consequence, every substantial, almost2-connected graph has a total as well as a collapsed split tree, and for every(total or collapsed) split tree t the graph result(t) is substantial and almost2-connected.

The algorithm we are going to present makes use of a result by MacLane[78] saying that collapsed split trees are unique in a certain sense. It is easyto see that collapsed split trees cannot be really unique. This is because, if Hand H ′ are graphs with e ∈ EH , and we let G and G′ be obtained from themby reversing e in H and interchanging the external nodes of H ′ we obviouslyobtain H[e/H ′] = G[e/G′]. Hence, for split trees we must allow to reversenonterminal edges if at the same time the external nodes of the graphs thatreplace them are interchanged. This is stated more precisely below.

Definition 2.7.11 (similar split trees) split trees with ENH = {e1, . . . , en}

and, for i = 1, . . . , n, branch(ei) = (Hi, branchi). Then t and t′ are similar ifthere is some I ⊆ {1, . . . , n} such that the following hold.

1. The graph obtained from H by reversing all ei with i ∈ I is isomorphicto H ′ via some isomorphism h.

2. For all i ∈ I, (H ′i, branchi) and branch(hE(ei)) are similar, where H ′

i isobtained from Hi by reversing extHi

if i ∈ I and H ′i = Hi otherwise.

As one can easily show by induction, similarity of t and t′ implies thatresult(t) and result(t′) are isomorphic. The algorithm we are developing isbased on the following result by MacLane [78].

Fact 2.7.12 (uniqueness of collapsed split trees) All collapsed split treesof a substantial, almost 2-connected graph are similar.

Page 58: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

152 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

Using Theorem 2.7.12 we want to prove the following.

Theorem 2.7.13 Let ERG be an edge replacement grammar. Then there isa cubic algorithm that takes as input a graph H and decides whether H is analmost 2-connected member of L(ERG). In particular, if all graphs in L(ERG)are almost 2-connected, the algorithm decides whether H ∈ L(ERG).

We are now going to develop the means to prove Theorem 2.7.13. Let usfirst assume some edge replacement grammar ERG = (N,T, P, S) as in thetheorem is given. By Lemma 2.4.3 it may be assumed that ERG is growing.We modify ERG as follows.

(1) Remove all productions whose right-hand side is not almost 2-connected.By Lemma 2.7.9 we are allowed to do so because this modification doesnot affect the set of almost 2-connected graphs in the language generated.

(2) As long as there is a production (A,R) such that H = R[e/H ′] forsome substantial H and H ′, choose a new nonterminal label A′ for ein H and replace (A,R) by the two productions (A,H) and (A′, H ′).Obviously, such a modification does not influence the generated language.By Lemma 2.7.9 the right-hand sides of the grammar obtained are bondsand chains with two edges, and blocks.

(3) Complete the grammar as follows: For every label A (nonterminal aswell as terminal ones), add a new label A, and add for all productions(A,R) in the grammar obtained in step (2), all productions (X,H), whereX ∈ {A, A} and H is obtained from R by reversing some edges whilechanging their label from labR(e) to labR(e), and reversing extR ifX = A.

Let the edge replacement grammar resulting from steps (1)–(3) be given byERG0 = (N0, T0, P0, S). Then it follows by a straightforward induction thatthe set of graphs over T generated by ERG0 coincides with the one of thegrammar obtained by steps (1) and (2), that is, L(ERG0) = L(ERG). Forevery derivation tree t over P ∗

0 (see page 115 for the definition of P ∗0 ) let us

denote by unlabel(t) the derivation tree we obtain by replacing all nonterminallabels with τ . We have the following lemma.

Lemma 2.7.14 Let H ∈ HT0and A ∈ N0. If A• =⇒∗

P0H and t is a collapsed

split tree of H, then there is a derivation tree t′ over P ∗0 with root A such that

unlabel(t′) = t.

ProofLet t0 be a derivation tree for H in ERG0. As remarked above, by modification

Page 59: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.7. THE MEMBERSHIP PROBLEM 153

(2) unlabel(t0) is a total split tree for every derivation tree t0 over P0. Hencethere is some derivation tree t′0 over P ∗

0 such that unlabel(t′0) is a collapsedsplit tree. (We can construct t′0 from t0 in the same way a collapsed split treecan be constructed from a total one; see the paragraph after Definition 2.7.10.)By Theorem 2.7.12 the given collapsed split tree t and unlabel(t′0) are simi-lar. By modification (3) this means there is a derivation tree t′ over P ∗

0 withunlabel(t′) = t. !

We are now able to sketch the construction of the cubic algorithm weaimed at, thereby proving Theorem 2.7.13.

Proof of Theorem 2.7.13 To find out whether an input graph H is in L(ERG0),where ERG0 is constructed as above, proceed as follows. First, compute acollapsed split tree t of H. By a result proved by Hopcroft and Tarjan [79] thiscan be done in linear time. By Lemma 2.7.14, if H ∈ L(ERG0) (and, of course,only then) we can exchange every τ in t by an appropriate nonterminal labelto obtain a derivation tree over P ∗

0 for H whose root is S. To find out whetherthis is possible, for all subtrees t′ of t we compute by a bottom-up approachthe set poslab(t′) of all A ∈ N0 such that A• =⇒∗

P0result(t′). This can be

done efficiently, as follows. Suppose t′ = (R, branch) with branch(e) = te fore ∈ EN

R , and we have already computed poslab(te) for all e ∈ ENR . Then, we

have to decide whether A• =⇒∗P0

R1 for some R1 obtained from R by labellingevery edge labelled with τ in R with one of the labels in poslab(te). Since R iseither a bond, a chain, or a block there are three possible cases to consider.

1. R is a bond.Construct R′ from R by giving a hyperedge e ∈ ER the label {labR(e)} iflabR(e) ∈ T0 and the label poslab(te) if labR(e) = τ . Let R′′ be the graphobtained from R′ by reversing all edges e with attR′(e) = endR′beginR′ ,while exchanging labR′(e) with {A |A ∈ labR′(e)}. By the completionperformed in modification (3) and Theorem 2.4.8 it is not hard to seethat A ∈ poslab(t′) if and only if ψ(R′′) is in some fixed semilinear setassociated with A. (To be able to apply Theorem 2.4.8, add productions(A,X•), where X ⊆ N0 and A ∈ X, or A ∈ T0 and X = {A}. Then wehave to decide whether A• =⇒∗

P0R′′.) Due to results by Fischer, Meyer,

and Rosenberg [80] membership in a semilinear set can be decided inlinear time.

2. R is a chain.Then, since in a derivation A• =⇒∗

P0R1 we cannot use any production

with a substantial right-hand side which is not a chain, we can usethe well-known algorithm by Cocke, Kasami, and Younger to find out

Page 60: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

154 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

S ::=1

S

S1

Figure 2.21: A hyperedge replacement grammar with componentwise derivations.

poslab(t′). (Note that we do not have to consider all the possible R1

separately, because the CKY-algorithm works with sets of nonterminalslike our poslab(te) provide.) Since the CKY-algorithm runs in cubic timethis step takes cubic time in the size of R.

3. R is a block.Here, we only have to test a finite number of possibilities since R mustbe isomorphic to a right-hand side in ERG0, up to the labelling. Hence,this case can be handled in constant time.

Altogether, we need at most a cubic number of steps (in |H|) in order to findposlab(t), and accept H if S ∈ poslab(t). !

2.7.3 Further results and bibliographic notes

The proof of NP-completeness given in the beginning of this section was foundby Lange and Welzl [81], who presented it for string grammars with discon-necting rather than for edge replacement, as we did here.

Algorithm 2.7.4 is due to Lautemann [29]. The paper contains a sec-ond variant of the algorithm that does not rely on logarithmic k-separability.Instead, it is required that the considered hyperedge replacement grammarhas componentwise derivations. Roughly speaking, this means that an X-candidate is derivable from A• if and only if each of the connected componentsthis X-candidate consists of is derivable from A•. As an example, one mayconsider the grammar HRG = ({S}, {␣}, P, S) (where “␣” means “unlabelled”)whose productions are the two given in Figure 2.21. L(HRG) is the set of all(rooted, directed) trees, and a graph as in Figure 2.22 on the left is derivablefrom S• if and only if each of its components (shown on the right) can bederived from S•. Under the condition that the grammar satisfies this require-ment, we may look at the (linear number of) individual connected componentsrather than at all X-candidates, which yields a polynomial algorithm. AsLautemann remarks in his paper, more sophisticated notions of component-wise derivations, that still lead to polynomial algorithms, may more or lessobviously be thought of.

Page 61: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.8. CONCLUSION 155

1

H components of H

Figure 2.22: A graph generated by HRG and its components.

The cubic membership algorithm was presented by Vogler in [82]. Asshown by Drewes [33], Theorem 2.7.13 and the results used to prove it can begeneralized to hyperedge replacement grammars of order k generating almostk-connected k-hypergraphs, where a k-hypergraph is a hypergraph all of whosehyperedges are of type k. This yields the case treated here by choosing k = 2.It may be interesting to notice that the generalized version of the algorithm isstill cubic; the exponent does not depend on the order of the grammar.

As mentioned, the generalization works only for k-hypergraphs. It is there-fore natural to wonder whether this restriction can be avoided. Is there stilla polynomial algorithm if a grammar of order k generates, for instance, a lan-guage of almost k-connected graphs? Unfortunately, it is likely that this ques-tion has to be answered negatively, since it was shown by Drewes [32] that thiscase is again NP-complete for all k > 2. (For k = 2, we have Theorem 2.7.13.)Intuitively, this is caused by the fact that, if we replace every hyperedge in ak-connected k-hypergraph by, say, a clique on the k attached nodes, we retaink-connectedness, but loose the information which of the resulting edges belongtogether, so that a unique reconstruction of the hypergraph is not possible.

2.8 Conclusion

In this survey, we have outlined the theory of hyperedge replacement as a gram-matical device for the generation of hypergraph, graph, and string languageswith an emphasis on the sequential mode of rewriting. Hyperedge replace-ment (without application conditions) has a context-free nature which is thekey for an attractive mathematical theory including structural properties anddecidability results.

Although several interesting (hyper)graph languages occurring in com-puter science and graph theory can be generated by hyperedge replacementgrammars, their generative power is bound to be restricted. As we saw in

Page 62: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

156 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

Section 2.4 there is, for instance, no way to generate a language of unboundedconnectivity. As mentioned in the bibliographic notes of Section 2.3, exten-sions can be found in the literature, which make it possible to overcome one orthe other deficiency. However, one cannot expect to get additional power forfree. Normally, extensions lack some of the useful properties of hyperedge re-placement, or their rewriting mechanisms are more complicated and thereforeharder to reason about. In many cases hyperedge replacement seems to be agood compromise between the wish to have a nicely developed mathematicaltheory and the demand for reasonable generative power.

Acknowledgement

We thank Grzegorz Rozenberg and the anonymous referee for helpful commentson a draft of this chapter. The work presented here has been supported byESPRIT Basic Research Working Group 7183 (COMPUGRAPH II).

References

1. Jerome Feder. Plex languages. Information Sciences, 3:225–241, 1971.2. Theodosios Pavlidis. Linear and context-free graph grammars. Journal

of the ACM, 19(1):11–23, 1972.3. Pierluigi Della Vigna and Carlo Ghezzi. Context-free graph grammars.

Information and Control, 37:207–233, 1978.4. Dirk Janssens and Grzegorz Rozenberg. Restrictions, extensions and

variations of NLC grammars. Information Sciences, 20:217–244, 1980.5. A.O. Slisenko. Context-free graph grammars as a tool for describing

polynomial-time subclasses of hard problems. Information ProcessingLetters, 14:52–56, 1982.

6. Michel Bauderon and Bruno Courcelle. Graph expressions and graphrewriting. Mathematical Systems Theory, 20:83–127, 1987.

7. Annegret Habel and Hans-Jorg Kreowski. Characteristics of graph lan-guages generated by edge replacement. Theoretical Computer Science,51:81–115, 1987.

8. Annegret Habel and Hans-Jorg Kreowski. May we introduce to you:Hyperedge replacement. In H. Ehrig, M. Nagl, G. Rozenberg, andA. Rosenfeld, editors, Graph-Grammars and Their Application to Com-puter Science, volume 291 of Lecture Notes in Computer Science, pages15–26, 1987.

9. Ugo Montanari and Francesca Rossi. An efficient algorithm for the so-lution of hierarchical networks of constraints. In H. Ehrig, M. Nagl,

Page 63: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.8. CONCLUSION 157

G. Rozenberg, and A. Rosenfeld, editors, Graph-Grammars and TheirApplication to Computer Science, volume 291 of Lecture Notes in Com-puter Science, pages 440–457, 1987.

10. Clemens Lautemann. Efficient algorithms on context-free graph lan-guages. In T. Lepisto and A. Salomaa, editors, Automata, Languagesand Programming, volume 317 of Lecture Notes in Computer Science,pages 362–378, 1988.

11. Joost Engelfriet. Context-free NCE graph grammars. In J. Csirik,J. Demetrovics, and F. Gecseg, editors, Fundamentals of ComputationTheory, volume 380 of Lecture Notes in Computer Science, pages 148–161, 1989.

12. Joost Engelfriet. A characterization of context-free NCE graph languagesby monadic second-order logic on trees. In H. Ehrig, H.-J. Kreowski,and G. Rozenberg, editors, Graph Grammars and Their Application toComputer Science, volume 532 of Lecture Notes in Computer Science,pages 311–327, 1991.

13. Thomas Lengauer and Egon Wanke. Efficient decision procedures forgraph properties on context-free graph languages. Journal of the ACM,40:368–393, 1993.

14. Bruno Courcelle. Graph rewriting: An algebraic and logical approach.In J. van Leeuwen, editor, Handbook of Theoretical Computer Science,volume Vol. B., pages 193–242. Elsevier, Amsterdam, 1990.

15. Bruno Courcelle. The monadic second-order logic of graphs I: Recog-nizable sets of finite graphs. Information and Computation, 85:12–75,1990.

16. Bruno Courcelle. Context-free graph grammars: Separating vertex re-placement from hyperedge replacement. In Z. Esik, editor, Fundamentalsof Computation Theory, volume 710 of Lecture Notes in Computer Sci-ence, pages 181–193, 1993.

17. Bruno Courcelle and Joost Engelfriet. A logical characterization of thesets of hypergraphs defined by hyperedge replacement systems. Mathe-matical Systems Theory, 28:515–552, 1995.

18. Joost Engelfriet and Grzegorz Rozenberg. A comparison of boundarygraph grammars and context-free hypergraph grammars. Informationand Computation, 84:163–206, 1990.

19. Joost Engelfriet and Linda Heyker. The string generating power ofcontext-free hypergraph grammars. Journal of Computer and SystemSciences, 43:328–360, 1991.

20. Joost Engelfriet and Linda Heyker. Context-free hypergraph grammarshave the same term-generating power as attribute grammars. Acta In-

Page 64: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

158 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

formatica, 29:161–210, 1992.21. Joost Engelfriet. A Greibach normal form for context-free graph gram-

mars. In W. Kuich, editor, Automata, Languages and Programming,volume 623 of Lecture Notes in Computer Science, pages 138–149, 1992.

22. Joost Engelfriet, Linda Heyker, and George Leih. Context-free graphlanguages of bounded degree are generated by apex graph grammars.Acta Informatica, 31:341–378, 1994.

23. Joost Engelfriet. Graph grammars and tree transducers. In CAAP’94,volume 787 of Lecture Notes in Computer Science, pages 15–36, 1994.

24. Hans-Jorg Kreowski. A pumping lemma for context-free graph lan-guages. In V. Claus, H. Ehrig, and G. Rozenberg, editors, Graph-Grammars and Their Application to Computer Science and Biology, vol-ume 73 of Lecture Notes in Computer Science, pages 270–283, 1979.

25. Hans-Jorg Kreowski. Rule trees represent derivations in edge replace-ment systems. In G. Rozenberg and A. Salomaa, editors, The Book ofL, pages 217–232. Springer-Verlag, Berlin, 1986.

26. Annegret Habel and Hans-Jorg Kreowski. Some structural aspects ofhypergraph languages generated by hyperedge replacement. In F. Bran-denburg, G. Vidal-Naquet, and M. Wirsing, editors, STACS 87, volume247 of Lecture Notes in Computer Science, pages 207–219, 1987.

27. Annegret Habel, Hans-Jorg Kreowski, and Walter Vogler. Metatheoremsfor decision problems on hyperedge replacement graph languages. ActaInformatica, 26:657–677, 1989.

28. Annegret Habel and Hans-Jorg Kreowski. Filtering hyperedge-replacement languages through compatible properties. In M. Nagl,editor, Graph-Theoretic Concepts in Computer Science, volume 411 ofLecture Notes in Computer Science, pages 107–120, 1990.

29. Clemens Lautemann. The complexity of graph languages generated byhyperedge replacement. Acta Informatica, 27:399–421, 1990.

30. Annegret Habel, Hans-Jorg Kreowski, and Walter Vogler. Decidableboundedness problems for sets of graphs generated by hyperedge replace-ment. Theoretical Computer Science, 89:33–62, 1991.

31. Clemens Lautemann. Tree automata, tree decomposition, and hyperedgereplacement. In H. Ehrig, H.-J. Kreowski, and G. Rozenberg, editors,Graph Grammars and Their Application to Computer Science, volume532 of Lecture Notes in Computer Science, pages 520–537, 1991.

32. Frank Drewes. NP-completeness of k-connected hyperedge-replacementlanguages of order k. Information Processing Letters, 45:89–94, 1993.

33. Frank Drewes. Recognising k-connected hypergraphs in cubic time. The-oretical Computer Science, 109:83–122, 1993.

Page 65: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.8. CONCLUSION 159

34. Annegret Habel, Hans-Jorg Kreowski, and Clemens Lautemann. A com-parison of compatible, finite, and inductive graph properties. TheoreticalComputer Science, 110:145–168, 1993.

35. Thomas Lengauer and Egon Wanke. Efficient analysis of graph prop-erties on context-free graph languages. In T. Lepisto and A. Salomaa,editors, Automata, Languages and Programming, volume 317 of LectureNotes in Computer Science, pages 379–393, 1988.

36. Thomas Lengauer and Egon Wanke. Efficient solution of connectivityproblems on hierarchically defined graphs. SIAM Journal on Computing,17:1063–1080, 1988.

37. Egon Wanke. On the decidability of certain integer subgraph problemson context-free graph languages. Information and Computation, 113:26–49, 1994.

38. Mark Minas and Gerhard Viehstaedt. Specification of diagram edi-tors providing layout adjustment with minimal change. In Proc. IEEESymp. on Visual Languages (VL’93), pages 324–329. IEEE Comp. Soci-ety Press, 1993.

39. Mark Minas and Gerhard Viehstaedt. DiaGen: A generator for diagrameditors providing direct manipulation and execution of diagrams adjust-ment with minimal change. In Proc. IEEE Symp. on Visual Languages(VL’95). IEEE Comp. Society Press, 1995.

40. Gerhard Viehstaedt. A generator for diagram editors. Doctoral Disser-tation, University of Erlangen, Germany, 1995.

41. R. Farrow, K. Kennedy, and L. Zucconi. Graph grammars and globalprogram data flow analysis. In Proc. 17th Ann. IEEE Symp. on Found.of Comp. Sci., pages 42–56, Houston, 1976.

42. Annegret Habel. Hyperedge Replacement: Grammars and Languages,volume 643 of Lecture Notes in Computer Science. Springer-Verlag,Berlin, 1992.

43. Annegret Habel. Hypergraph grammars: Transformational and algorith-mic aspects. Journal of Information Processing and Cybernetics EIK,28:241–277, 1992.

44. Bruno Courcelle, Joost Engelfriet, and Grzegorz Rozenberg. Handle-rewriting hypergraph grammars. Journal of Computer and System Sci-ences, 46:218–270, 1993.

45. Annegret Habel and Hans-Jorg Kreowski. Collage grammars. InH. Ehrig, H.-J. Kreowski, and G. Rozenberg, editors, Graph Grammarsand Their Application to Computer Science, volume 532 of Lecture Notesin Computer Science, pages 411–429, 1991.

46. Frank Drewes, Annegret Habel, Hans-Jorg Kreowski, and Stefan Tauben-

Page 66: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

160 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

berger. Generating self-affine fractals by collage grammars. TheoreticalComputer Science, 145:159–187, 1995.

47. Jurgen Dassow, Annegret Habel, and Stefan Taubenberger. Chain-codepictures and collages generated by hyperedge replacement. In H. Ehrig,H.-J. Kreowski, and G. Rozenberg, editors, Proc. Fifth Intl. Workshopon Graph Grammars and Their Application to Comp. Sci., Lecture Notesin Computer Science. Springer, 1996. To appear.

48. Frank Drewes and Hans-Jorg Kreowski. (Un)decidability of propertiesof pictures generated by collage grammars. Fundamenta Informaticae,1996. To appear.

49. Frank Drewes. Language theoretic and algorithmic properties of d-dimensional collages and patterns in a grid. Journal of Computer andSystem Sciences, 1996. To appear.

50. Bruno Courcelle. An axiomatic definition of context-free rewriting andits application to NLC graph grammars. Theoretical Computer Science,55:141–181, 1987.

51. Hartmut Ehrig and Karl Wilhelm Tischer. Graph grammars and appli-cations to specialization and evolution in biology. Journal of Computerand System Sciences, 11:212–236, 1975.

52. Hans-Jorg Kreowski. Parallel hyperedge replacement. In G. Rozen-berg and A. Salomaa, editors, Lindenmayer Systems, pages 271–282.Springer-Verlag, Berlin Heidelberg New York, 1992.

53. Gnanamalar David, Frank Drewes, and Hans-Jorg Kreowski. Hyperedgereplacement with rendezvous. In P. Jouannaud, editor, Proc. Theoryand Practice of Software Development, volume 668 of Lecture Notes inComputer Science, pages 167–181, 1993.

54. Hans-Jorg Kreowski. Five facets of hyperedge replacement beyondcontext-freeness. In Z. Esik, editor, Fundamentals of Computation The-ory, volume 710 of Lecture Notes in Computer Science, pages 69–86,1993.

55. Michel Bauderon. Infinite hypergraphs I. Basic properties. TheoreticalComputer Science, 82:177–214, 1991.

56. Michel Bauderon. Infinite hypergraphs II. Systems of recursive equa-tions. Theoretical Computer Science, 103:165–190, 1992.

57. Seymour Ginsburg and Gordon Rice. Two families of languages relatedto ALGOL. Journal of the ACM, 9:350–371, 1962.

58. Y. Bar-Hillel, M. Perles, and E. Shamir. On formal properties of simplephrase-structure grammars. Zeitschrift fur Phonetik, Sprachwissenschaftund Kommunikationsforschung, 14:143–177, 1961.

59. John E. Hopcroft and Jeffrey D. Ullman. Formal Languages and Their

Page 67: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

2.8. CONCLUSION 161

Relation to Automata. Addison-Wesley, Reading, Mass., 1969.60. R.J. Parikh. On context-free languages. Journal of the ACM, 13:570–

581, 1966.61. Donald J. Rose. On simple characterizations of k-trees. Discrete Math-

ematics, 7:317–322, 1974.62. Ferenc Gecseg and Magnus Steinby. Tree Automata. Akademiai Kiado,

Budapest, 1984.63. Alfred V. Aho and Jeffrey D. Ullman. Translations on a context free

grammar. Information and Control, 19:439–475, 1971.64. Joost Engelfriet, Grzegorz Rozenberg, and Giora Slutzki. Tree transduc-

ers, L systems, and two-way machines. Journal of Computer and SystemSciences, 20:150–202, 1980.

65. John E. Hopcroft and Jeffrey D. Ullman. Introduction to AutomataTheory, Languages and Computation. Addison–Wesley, Reading, Mas-sachusetts, 1979.

66. Joost Engelfriet and Heiko Vogler. The translation power of top-downtree-to-graph transducers. Journal of Computer and System Sciences,49:258–305, 1994.

67. Joost Engelfriet and Heiko Vogler. Macro tree transducers. Journal ofComputer and System Sciences, 31:71–146, 1985.

68. Joost Engelfriet and Linda Heyker. Hypergraph languages of boundeddegree. Journal of Computer and System Sciences, 48:58–89, 1994.

69. Stefan Arnborg, Jens Lagergren, and Detlef Seese. Problems easy fortree-decomposable graphs. Journal of Algorithms, 12:308–340, 1991.

70. Egon Wanke and Manfred Wiegers. Undecidability of the bandwidthproblem on linear graph languages. Information Processing Letters,33:193–197, 1989.

71. Bruno Courcelle and Mohamed Mosbah. Monadic second-order eval-uations on tree-decomposable graphs. Theoretical Computer Science,109:49–82, 1993.

72. Helmut Seidl. Finite tree automata with cost functions. TheoreticalComputer Science, 126:113–142, 1994.

73. Frank Drewes. A lower bound on the growth of functions computed bytree transductions. Fundamenta Informaticae, 1996. To appear; shortversion in Lecture Notes in Computer Science 787 (CAAP 94).

74. Frank Drewes. The use of tree transducers to compute translationsbetween graph algebras. In Proc. Fifth Intl. Workshop on Graph Gram-mars and Their Application to Comp. Sci., Lecture Notes in ComputerScience. Springer, 1996. To appear.

75. Frank Drewes. Computation by tree transductions. Doctoral Disserta-

Page 68: Chapter 2 - Dagstuhlmaterials.dagstuhl.de/files/15/15122/15122.FrankDrewes.Preprint.pdf · replacement grammars do not interfere with each other as longastheyconcern different hyperedges

162 CHAPTER 2. HYPEREDGE REPLACEMENT GRAPH GRAMMARS

tion, University of Bremen, Germany, 1996.76. Michael R. Garey and David S. Johnson. Computers and Intractabil-

ity. A Guide to the Theory of NP-Completeness. W.H. Freeman andCompany, New York, 1979.

77. Ijsbrand Jan Aalbersberg, Andrzej Ehrenfeucht, and Grzegorz Rozen-berg. On the membership problem for regular DNLC grammars. Dis-crete Applied Mathematics, 13:79–85, 1986.

78. Saunders MacLane. A structural characterization of planar combinato-rial graphs. Duke Mathematical Journal, 3:460–472, 1937.

79. John E. Hopcroft and Robert E. Tarjan. Dividing a graph into tricon-nected components. SIAM Journal on Computing, 2(3):135–158, 1973.

80. Patrick C. Fischer, Albert R. Meyer, and Arnold L. Rosenberg. Countermachines and counter languages. Mathematical Systems Theory, 2:265–283, 1968.

81. Klaus-Jorn Lange and Emo Welzl. String grammars with disconnectingor a basic root of the difficulty in graph grammar parsing. DiscreteApplied Mathematics, 16:17–30, 1987.

82. Walter Vogler. Recognizing edge replacement graph languages in cubictime. In H. Ehrig, H.-J. Kreowski, and G. Rozenberg, editors, GraphGrammars and Their Application to Computer Science, volume 532 ofLecture Notes in Computer Science, pages 676–687, 1991.