Regular Description of ContextFree

Graph Languages

Jo ost Engelfriet and Vincent van Oostrom

Department of Computer Science Leiden University

POBox RA Leiden The Netherlands

email engelfriwileidenunivnl

Abstract A of lab eled graphs can b e dened by a regular tree

language and one regular string language for each p ossible edge lab el as

follows For each tree t from the regular tree language the graph g r t

has the same no des as t with the same lab els and there is an edge

with lab el from no de x to no de y if the string of lab els of the no des on

the shortest path from x to y in t b elongs to the regular string language

for Slightly generalizing this denition scheme we allow g r t to have

only those no des of t that have certain lab els and we allow a relab eling

of these no des It is shown that in this way exactly the class of CedNCE

graph languages generated by CedNCE graph grammars is obtained

one of the largest known classes of contextfree graph languages

Introduction

There are many kinds of contextfree graph grammars see eg ENRR EKR

Some are no de rewriting and others are edge rewriting In b oth cases a pro duc

tion of the grammar is of the form X D C Application of such a pro duction

to a lab eled graph H consists of removing a no de or edge lab eled X from H

replacing it by the graph D and connecting D to the remainder of H accord

ing to the embedding pro cedure C Since these grammars are contextfree in

the sense that one no de or edge is replaced their derivations can b e mo d

eled by derivation trees as in the case of contextfree grammars for strings

However in particular for certain types of no de rewriting grammars the gram

mar may still b e contextsensitive in the sense that the edges of the graph

generated according to the derivation tree may dep end on the order in which

the pro ductions are applied A graph grammar that do es not suer from this

quite disastrous contextsensitivity is said to b e conuent or to have the

nite ChurchRosser prop erty see Cou for a uniform treatment Thus for a

conuent graph grammar G each derivation tree of G yields a unique graph

?

The rst author was supp orted by ESPRIT BRWG No COMPUGRAPH I I

??

The present address of the second author is Faculty of Mathematics and Computer

Science Vrije Universiteit de Bo elelaan a HV Amsterdam The Nether

lands email o ostromcsvunl

in the graph language generated by G Due to this close relationship to deriva

tion trees the generated graph language can b e describ ed in terms of a reg

ular tree language the set of derivation trees and a nite number of regular

string languages to simulate the embedding pro cedure We will show this for

the particular case of the no de rewriting edNCE graph grammars studied in

Kau Bra Bra ELR ELR Schu ELW EL EL ER CER Thus we

dene the notion of a regular path description of a graph language mainly deter

mined by a regular tree language and a nite number of regular string languages

and prove that regular path descriptions have the same p ower as the conuent

edNCE grammars or CedNCE grammars The idea of using regular tree and

string languages for the description of graphs was introduced in Wel and in

vestigated in ELW for sp ecial cases of the CedNCE grammar

The structure of this pap er is as follows In Section we dene the edNCE

grammar and in particular the conuent edNCE grammar In Section we in

tro duce the notion of a regular path description of a graph language generalizing

the regular path descriptions of Wel ELW In Sections and also some ex

amples and some easy lemmas can b e found Section contains the pro of of the

main result the characterization of the CedNCE graph languages by regular

path descriptions We use this result to show that the b oundary edNCE gram

mars or BedNCE grammars cf eg RW ELW have less generating p ower

than the CedNCE grammars In Section we consider a number of sp ecial cases

of the main result In particular we dene sp ecial types of regular path descrip

tions that characterize the b oundary ap ex and linear edNCE graph languages

In Section we investigate the string generating p ower of CedNCE grammars

we view a graph grammar as a generator of all the strings that lab el directed

paths in the generated graphs We use the main result to show that the class of

string languages generated by CedNCE grammars in this way equals the class

of output languages of nondeterministic treewalking transducers This implies

that this string generating metho d is more p owerful than the one of EH that

gives the output languages of deterministic treewalking transducers

The main result of this pap er strengthens our b elief that the class of CedNCE

graph languages which seems to b e the largest known class of graph languages

that can b e generated by contextfree graph grammars where contextfree is

taken in the sense of Cou is a robust class of contextfree graph languages

it can b e characterized in several dierent ways Other characterizations can b e

found in CER by handle rewriting hypergraph grammars and in Oos Eng

by monadic second order logic

The results of this pap er were established in and presented in Oos

and in Eng The only added result is the characterization of ap ex edNCE

languages Theorem which uses EHL More recent work on the class of

CedNCE graph languages or its sub classes can b e found in eg Bra Cou

Cou Eng Eng SW SW KL For a survey see ER

The reader is assumed to b e familiar with the basic concepts of formal lan

guage theory see eg HU and of regular tree languages see eg GS

Conuent edNCE Graph Grammars

In this subsection we give formal denitions for the edNCE graph grammars

and in particular for the conuent edNCE CedNCE graph grammars These

grammars generate directed graphs with lab eled no des and lab eled edges

Let b e an alphab et of no de lab els and an alphab et of edge lab els A

graph over and is a tuple H V E where V is the nite set of no des

E fv w j v w V v w g is the set of edges and V is

the no de lab eling function The comp onents of H are also denoted as V E

H H

and resp ectively Thus we consider directed graphs without lo ops multiple

H

edges b etween the same pair of no des are allowed but they must have dierent

lab els A graph is undirected if for every v w E also w v E Graphs

with unlab eled no des andor edges can b e mo deled by taking andor to b e

a singleton resp ectively

The set of all graphs over and is denoted GR A subset of GR is

called a graph language

As usual two graphs H and K are disjoint if V V Also as usual

H K

H and K are isomorphic if there is a bijection f V V such that E

H K K

ff v f w j v w E g and for all v V f v v The

H H K H

reader is assumed to b e familiar with the way in which concrete graphs are used

as representatives of abstract graphs which are equivalence classes of concrete

graphs with resp ect to isomorphism We are usually interested in abstract graphs

but mostly discuss concrete ones For instance whereas a graph language is

dened to b e a set of concrete graphs we usually view it as a set of abstract

graphs

After these preliminaries we turn to the denition of edNCE graph gram

mar The name of these grammars can b e explained as follows NCE stands for

neighbourhood controlled embedding the d stands for directed graphs and the

e means that not only the no des but also the edges of the graphs are lab eled in

particular the e stresses the fact that the edNCE grammar allows for dynamic

edge relabeling Thus edNCE grammars are graph grammars with neighbour

hood controlled embedding and dynamic edge relabeling They were introduced in

Nag Nag Nag as depth contextfree graph grammars and studied in

eg Kau Bra Bra Schu They were also investigated as generalizations of

NLC graph grammars in eg EL EL ELW

Denition An edNCE grammar is a tuple G P S where

is the alphab et of no de lab els is the alphab et of terminal no de lab els

is the alphab et of edge lab els is the alphab et of nal edge lab els

P is the nite set of pro ductions and S is the initial nonterminal

A pro duction is of the form X D C with X D GR and

C V fin outg ut

D

Elements of are called nonterminal no de lab els and elements of

nonnal edge lab els A no de with a terminal or nonterminal lab el is said

to b e a terminal or nonterminal no de resp ectively and similarly for nal and

nonnal edges For a pro duction p X D C X is the lefthand side of

p D is the righthand side of p and C is its connection relation We write

lhsp X rhsp D and conp C Each element x d of C with

x V and d fin outg is a connection instruction of

H

p To improve readability a connection instruction x d will always b e

written as x d In the literature the elements of a connection instruction

are often listed in another order Two pro ductions X D C and X

D C are called isomorphic if X X and there is an isomorphism f from

D to D such that C f f x d j x d C g We will assume

that P do es not contain distinct isomorphic pro ductions By copyP we denote

the innite set of all pro ductions that are isomorphic to a pro duction in P an

element of copyP will b e called a production copy of G

The pro cess of rewriting in an edNCE grammar is dened through the appli

cation of pro ductions or rather pro duction copies in the usual way Informally

a rewriting step according to a pro duction p X D C consists of removing

a no de v lab eled X the mother no de from the given hostgraph H substi

tuting D the daughter graph in its place and connecting D to the remainder

of H in a way sp ecied by the connection instructions in C Together with v all

edges incident with v are removed to o A connection instruction x out

of C means that if there was a lab eled edge from the mother no de v to a no de

w with lab el in H then the connecting pro cess will establish a lab eled edge

from x to w And similarly for in instead of out where in refers to incoming

edges of v and out to outgoing edges of v Note in particular that the edge

lab el is changed from into which explains the notation The formal

denition is as follows

Denition Let G P S b e an edNCE grammar Let H and

0

H b e graphs in GR let v V and let p X D C b e a pro duction

H

0

copy of G such that D and H are disjoint Then we write H H or just

v p

0 0 0

H H or H H if v X and H is the graph V E in GR

p H

such that

V V fv g V

H D

E fx y E j x v y v g E

H D

fw x j w v E w x in C g

H H

fx w j v w E w x out C g

H H

x x if x V fv g and x x if x V

H H D D

0

H H is called a derivation step and a sequence of such derivation steps is

v p

called a derivation A derivation

H H H

n v p v p v p

n n 2 2 1 1

n is creative if the graphs H and rhsp i n are mutually disjoint

i

 0

We wil l restrict ourselves to creative derivations Thus we write H H if

0

there is a creative derivation as ab ove with H H and H H Let snS z

n

denote the graph with a single S lab eled no de z and no edges A sentential form



of G is a graph H such that snS z H for some z The set of all sentential

forms of G is denoted SF G The graph language generated by G is



LG fH GR j snS z H for some z g

ut

0 

It is not dicult to show that if H and H are isomorphic and snS z H

0  0 0

then snS z H for some z Thus LG is closed under taking isomorphic

copies



An edNCE grammar is nonblocking if LG fH GR j snS z

H for some z g This means that if a sentential form H has terminal no des only

ie cannot b e rewritten any more then all its edges are nal Note that we do

not assume that edNCE grammars are nonblocking as opp osed to Eng Eng

Example To draw a pro duction X D C of an edNCE grammar we draw

the graph D in the usual fashion with no des represented by dots and edges

by arrows and we add C to D in the following way a connection instruction

x in C is represented by a dashed arrow from a symbol to the dot

representing x with lab el for the connection instruction x out

the direction of the arrow is reversed

As a rst example consider the edNCE grammar G P S

with fS X i n f g fi n f g f g f g

and P consists of the three pro ductions drawn in Fig Thus pro duction p is

X D C with V fx y g E fx y g x n y f and

D D D D

C fn x in n y outg LG consists of all ladders of the form

shown in Fig with at least six no des Note that intuitively stand

for right left down and up resp ectively

As another example consider the edNCE grammar G P S

with fS X ng fng f g and P consists of the three

pro ductions p p p shown in Fig A dashed arrow from or to X n repre

a b c

sents two connection instructions one for X and one for n in the obvious way

G generates all ro oted binary trees with lab eled edges from each parent to

its children with additional lab eled edges from each leaf to the ro ot and with

additional lab eled edges that chain the leaves of the tree An example of such

a treelike graph is given in Fig except that the lab els a b b c c of all

l r l r

no des should b e replaced by n Note that in a derivation of G the lab eled

edges to the ro ot are created by pro duction p are passed from nonterminal

a

no de to nonterminal no de by pro duction p and are nally attached to the leaves

b

by pro duction p

c

0

Let G b e the edNCE grammar that is obtained from G by erasing all edges

0

and connection instructions that involve It should b e clear that LG consists

of all ro oted binary trees with additional edges from the leaves to the ro ot ie

all graphs of LG without their lab eled edges

As a third and nal example consider the edNCE grammar G

P S with fS ng fng f g and P consists

of the three pro ductions p p p shown in Fig An undirected edge b etween

a b n

i n

p S

X

n

n

n

n

p X

X

n

n

n

n

p X

n

f

Fig Pro ductions of G

i n n n

n n n f

Fig A ladder generated by G

x and y stands for two directed edges one from x to y and one from y to x

and similarly for connection instructions LG is the set of all cographs see

CLS It is the smallest set of unlab eled undirected graphs that contains the

oneno de graph and is closed under the op erations of join and disjoint union

The oneno de graph corresp onds to pro duction p the join op eration ie tak

n

ing the disjoint union of two graphs and joining every no de of the one graph

with every no de of the other graph corresp onds to pro duction p and the op

a

eration of disjoint union corresp onds to pro duction p An example of a cograph

b

is the square it is the join of two discrete graphs each of which is the disjoint

n

p S

a

X X

n

n

n n

p X

b

X n X n

X X

n n

X n p X X n

c

n

Fig Pro ductions of G

a

c b

r l

c b

l r

c c

l r

Fig A treelike graph generated by G where all no de lab els should b e n

S n S n

p S

a

S S

S n S n

p S

b

S S

S n

p S

n

n

Fig Pro ductions of G

union of two oneno de graphs ut

The edNCE grammar has certain undesirable noncontextfree prop erties This

is caused by the fact that it need not be conuent ie that the result of a

derivation may dep end on the order in which the pro ductions are applied This

problem turns up in sentential forms that have edges b etween two nonterminal

no des as in the following example

Example Consider an edNCE grammar G P S with

0 0

fS A B a bg fa bg f g f g and the following

three pro ductions X D C

p X S V fu v g E fu v g u A v B and C

S D D D D

p X A V fxg E x a and

A D D D

0

C fB x out b x outg

p X B V fy g E y b and

B D D D

C fA y in a y ing

The application of pro ductions p p p in that order gives a derivation

S A B

H where H is rhsp and H is the H H snS z

S v p up z p

B A S

graph with two no des x and y lab eled a and b resp ectively and one edge

x y However interchanging the application of p and p to no des u and v

A B

H where H H resp ectively gives a derivation snS z

up v p z p

A B S

0

H is the same as H except that its edge is x y Since the order of appli

cation of pro ductions results in two dierent graphs H and H the grammar

is not conuent ut

In the literature it is customary to give a dynamic denition of conuence see

eg Kau Schu Bra Cou Eng Eng CER Here we prop ose a static one

that can easily b e checked on the embedding relations of the pro ductions of the

grammar cf Denition of EJKR and Lemma of Cou

Denition An edNCE grammar G P S is conuent or a

CedNCE grammar if for all pro ductions X D C and X D C in

and all edge lab els the following and x V P all no des x V

D D

2 1

equivalence holds

x x in C X x out C and

D

1

x x out C ut X x in C and

D

2

By CedNCE we denote the class of graph languages generated by CedNCE

grammars

All grammars discussed in Example are CedNCE grammars Many other

sets of graphs with treelike graph theoretic prop erties can b e dened by C

edNCE grammars For example seriesparallel graphs transitive VSP graphs

complete bipartite graphs maximal outerplanar graphs edge complements of

trees and for xed k k trees graphs of treewidth k pathwidth k cutwidth

k bandwidth k cyclic bandwidth k and top ological bandwidth k see

eg RW EL

A symbolic picture of Denition is given in Fig Intuitively the denition

means that if the two pro ductions are applied to a graph with a single edge

v v where v is lab eled X then the same edges x x are established

i i

b etween no des of their righthand sides indep endent of the order in which the

pro ductions are applied From this intuition the following characterization of

conuence easily follows the result of a derivation do es not dep end on the order

in which the pro ductions are applied

X X

0

x x

Fig Conuence

Prop osition An edNCE grammar G P S is conuent if and

only if the fol lowing holds for every graph H GR

H are creative deriva H H and H H if H

v p v p v p v p

1 1 2 2 2 2 1 1

tions of G with v v V and v v then H H

H

The denition of conuence from the literature where it is also called the nite

ChurchRosser or fCR prop erty is exactly the same as the previous prop osition

except that H is restricted to b e a sentential form of G let us call this dynamic

conuence Although there are more dynamically conuent than conuent ed

NCE grammars it can b e shown that they generate the same class CedNCE of

graph languages see ER Although dynamic conuence is a decidable prop

erty of edNCE grammars see Kau the advantage of our notion of conuence

is that it is completely static

It is shown in SW that for every CedNCE grammar an equivalent non

blo cking CedNCE grammar can b e constructed This fact will not b e used but

will b e a consequence of our pro ofs cf the discussion after Theorem

Several natural sub classes of the CedNCE grammars have b een investigated

in the literature We will consider three of them Whenever we dene an X

edNCE grammar for some X XedNCE will denote the class of graph languages

generated by XedNCE grammars

An edNCE grammar G P S is boundary or a BedNCE gram

mar if for every pro duction X D C D do es not contain edges b etween

nonterminal no des and C do es not contain connection instructions x d

where is nonterminal Obviously the second condition implies that b ound

ary grammars are conuent A BedNCE grammar G P S is

apex or an AedNCE grammar if for every pro duction X D C and every

connection instruction x d C x and are terminal The b ound

ary restriction on graph grammars was introduced in RW the ap ex restriction

was rst considered in ELR An edNCE grammar G P S is

linear or a LINedNCE grammar if for every pro duction X D C D has at

most one nonterminal no de It is easy to see that LINedNCE BedNCE It is

shown in EL that AedNCE and LINedNCE are incomparable sub classes of

BedNCE The class BedNCE also contains the BNLC languages of RW and

as shown eg in ER the hyperedge replacement HR graph languages of

BC HK Hab

0

Grammar G from Example is b oth linear and ap ex Grammar G is b ound

ary but not linear or ap ex Grammars G and G are not b oundary

The class AedNCE can b e characterized within the class CedNCE there

is a simple condition on a graph language L CedNCE that expresses mem

b ership of L in AedNCE viz that L is of b ounded degree ie that there is a

number k such that all no des in all graphs of L have degree at most k This

characterization was shown in EHL see also Eng

Prop osition For every graph language L CedNCE

L AedNCE if and only if L is of bounded degree

The class CedNCE of graph languages generated by CedNCE grammars has a

large number of nice closure prop erties Here we need a very simple one closure

0

under edge relab eling Let b e an edge relab eling ie a mapping

0

where and are edge lab el alphab ets For a graph H GR we dene

0

to b e the graph V E with E fv w j v w H GR

H H

E g

H

Prop osition CedNCE is closed under edge relabelings ie if is an edge

relabeling and L CedNCE then L CedNCE The classes BedNCE

AedNCE and LINedNCE are also closed under edge relabelings

0

Proof Let G P S b e a CedNCE grammar and let

0

b e an edge relab eling It can b e assumed that

0

is dened to b e the graph For a graph D GR D GR

[

V E such that

D D

E fv w j v w E v and and w g

D D D

fv w E j v or or w g

D D D

Thus only the nal edges b etween terminal no des are relab eled Similarly for a

connection relation C V fin outg we dene the connection

D

relation C to b e

f x d j x d C x and and g

D

f x d C j x or or g

D

0 0 0 0

We now construct the edNCE grammar G P S with

0

P fX D C j X D C is in P g Using the conuence of G it

0

is easy to verify that G is still conuent in Denition rst consider the case

that x and x are terminal and is nal and then the remaining case Clearly

the b oundary ap ex and linear prop erties are preserved It is also easy to see that

0

the derivations of G starting with snS z are of the form snS z H

H where snS z H H is a derivation of G Formally

n n

0

this can b e proved by induction on n It shows that LG LG ut

Regular Path Descriptions

As observed b efore all graphs generated by a CedNCE grammar are tree

like An alternative grammar indep endent way of describing a set of treelike

graphs H is by taking a tree t from some regular tree language dening the no des

of H as a subset of the vertices of t and dening an edge b etween no des u and

v of H if the string of vertex lab els on the shortest undirected path b etween u

and v in t b elongs to some regular string language Such a description of a graph

language will b e called a regular path description This idea was introduced in

Wel for linear graph grammars and investigated for LINeNCE and BeNCE

grammars in ELW where the missing d means that the generated graphs are

undirected Note that the no des of trees will also b e called vertices in order

not to confuse them with the no des of the graphs involved

Let us rst dene the regular tree languages The following denition of a

regular tree grammar as a sp ecial type of edNCE grammar is equivalent in

generating p ower with the usual one in tree language theory see GS The

ro oted ordered trees from tree language theory will b e viewed here as usual

as a sp ecial type of graph each vertex of the tree has a directed edge to each

of its k children k and the order of the children is indicated by using the

numbers k to lab el these edges

As usual a ranked alphabet is an alphab et together with a mapping rank

f g By m we denote the maximal number rank

Denition An edNCE grammar G P S is a regular tree gram

mar or a REGT grammar if is a ranked alphab et f m g

and for every pro duction X D C in P

V fx x x g for some k

D k

x is in and has rank k and for every i k

D

either x is in or x is in and has rank

D i D i

E fx i x j i k g and

D i

C f ii x in j i g

G is in normal form if x for all i k ut

D i

Since and are uniquely determined by we will sp ecify a REGT grammar

as P S

Thus for a pro duction p of a regular tree grammar G rhsp consists of a

terminal parent x and k terminal or nonterminal children x x Edges

k

lead from the parent to each child and the children are ordered by numbering

their edges from to k Such a pro duction X D C can mo dulo isomor

phism b e denoted uniquely as X with x and x

k D i D i

for i k Every sentential form of G is a tree of which all internal ver

tices are terminal thus only leaves are rewritten into an internal vertex with

k children

A graph language generated by a REGT grammar is a regular tree language

It is easy to see and well known that every regular tree language can b e

generated by a regular tree grammar in normal form For a ranked alphab et

we denote by T the set of all trees over ie the regular tree language

generated by the REGT grammar with one nonterminal S and all pro ductions

k

S S for every where k rank

It is obvious that every REGT grammar is a conuent edNCE grammar

b ecause it is even an AedNCE grammar Hence every regular tree language is

an AedNCE graph language

We now turn to the regular path description of graph languages An essential

concept to b e used is the string of lab els on the shortest undirected path from

one vertex u of a tree to another vertex v Clearly such a path rst ascends from

u to the least common ancestor of u and v and then descends to v In the string

we indicate this change of direction by barring the lab el of the least common

ancestor

Denition Let b e a ranked alphab et and let f j g For t T

 

as follows Let z V b e the least and u v V we dene path u v

t t

t

common ancestor of u and v in t Let u u m and v v n

m n

b e the vertices on the directed paths in t from z to u and from z to v resp ectively

thus z u v u u and v v Then

m n

z v v path u v u u

t t t n t m t

t

ut

We are now ready for the denition of a regular path description

Denition A regular path description is a tuple R T h W

where is a ranked alphab et and are alphab ets of no de and edge lab els

resp ectively T T is a regular tree language h is a partial function from

to and W is a mapping from to the class of regular string languages such

 

that for every W

The graph language described by R is LR fg r t j t T g where g r t

R R

is the graph H GR such that

V is the set of vertices v of t for which v is in the domain of h

H t

v h v for v V and

H t H

E is the set of all edges u v with path u v W ut

H

t

Note that LR GR Note that h is used b oth to determine which vertices

of the tree t are no des of the graph g r t and to dene their lab els in that

R

graph on the basis of their lab els in the tree Note that for each edge lab el

W is the regular string language that denes the graph edges with lab el

Note nally that LR is closed under taking isomorphic copies b ecause T is

Let RPD denote the class of graph languages that are describ ed by regular

path descriptions The main result of this pap er is that CedNCE RPD

We now dene some natural sub classes XRPD of RPD by restricting the

regular path descriptions to b e of type X

Let BRPD b e the sub class of RPD obtained by restricting every W to

 

This means for a regular path description of type B b e a subset of

that graph edges are only established b etween tree vertices of which one is a

descendant of the other We will show that BedNCE BRPD essentially the

same result is shown in Theorem of ELW for undirected graphs

Let ARPD b e the sub class of RPD obtained by restricting every W to

b e nite Thus for a regular path description of type A graph edges can only

b e established b etween tree vertices that are at a b ounded distance from each

other We will show that AedNCE ARPD

Let LINRPD b e the sub class of RPD obtained by restricting the symbols

of the ranked alphab et to have rank or This means that the trees in

the regular tree language are in fact strings Thus a regular path description of

type LIN uses regular string languages only Note that obviously LINRPD

BRPD We will show that LINedNCE LINRPD as for B essentially the

same result for undirected graphs is shown in Theorem of ELW

Example We will give regular path descriptions of the graph languages gener

ated by the CedNCE grammars of Example

The language LG of all ladders can b e describ ed by the regular

path description R T h W of type LIN with fi n a f g

ranki rankn ranka rankf fi n f g f g



T ianana nf where we have written the trees as strings in prex notation

h is the total function with hi i hn ha n and hf f and W

ian nang W fna nf g W ff na anag and is given by W f

ig W fa

a a a

i f

n n n

Fig Regular path description of a ladder

Note that R is not only of type LIN but also of type B and of type A To

see how R works see Fig Assuming that a n this gure represents the

t of the tree t ianananf which is in fact the ladder of Fig graph g r

R

1

The tree t itself is not drawn but is suggested as a horizontal chain with the

ro ot at the left and the leaf at the right

The graph language LG of all binary trees with additional edges is

describ ed by the regular path description R T h W with

fa b b c c g ranka rankb rankb rankc rankc

l r l r l r l r

fng f g T LG where G is the regular tree grammar with

pro ductions S aLR L b LR R b LR L c and R c with

l r l r

nonterminals S L R of which S is the initial one h is the total function with

a b b b b c c h n for all and W is dened by W

l r l r l r

  

W c c b b a and W c b b c a b b b b c c

l r l r r l l l r r l r

r

l

To see how R works see Fig Taking all no de lab els to b e n the gure

t of the tree t ab c b c c c in prex notation represents the graph g r

l l r l r r R

2

The tree t itself is not drawn but equals the tree spanned by the lab eled edges

apart from the edge lab els which should b e or

Note that R is not of type B A or LIN Removing from and W

0 0

is obtained that is of type B of LG from W a regular path description R

but not of type A or LIN

The graph language LG of all cographs is describ ed by the regular path

description R T h W with fa b ng ranka rankb

and rankn fng f g T T hn n ha and hb are

 

undened and W na b aa b n

To see how R works see Fig Disregarding the dotted lines the gure

represents the tree t abnnbnn in prex notation generated by G The no des

a

b b

n n n n

Fig Regular path description of a cograph

with lab el n together with the dotted undirected edges form the cograph

t which is the square By the denition of W two leaves of t are g r

R

3

connected by an edge in g r t if their least common ancestor is lab eled a This

means that R formalizes the usual cotree representation of cographs see CLS

In fact the cotrees in LG can b e viewed as expressions with a representing

the join op eration b disjoint union and n the oneno de graph ut

We need the following easy closure prop erty of RPD

Lemma Let L be a graph language in RPD with L GR

0 0

0 0

is in RPD for al l and Then L GR

A similar statement holds for BRPD ARPD and LINRPD

Proof Let L LR for the regular path description R T h W

0 0

0 0 0 0

LR where g Obviously L GR Dene T ft T j g r t GR

R

0 0

R T T h W Since the regular tree languages are closed under

0 0

intersection it suces to show that T is regular Now T T T where T

0 0

g Clearly T is ft T j g r t GR g and T ft T j g r t GR

R R

0

0

where f j h is undened or h the regular tree language T

S

0

T where T is the set of all t T such that g Also T T

0

2

g r t has at least one edge with lab el Since the regular tree languages are

R

closed under union and complement it suces to show that T is regular for

every Clearly T is the set of all t T such that there exist u v V

t

with path u v W Since W is a regular string language there is a

t

nite automaton A that accepts W It is not dicult to write a regular

tree grammar G that generates T G decides nondeterministically that it is

generating the least common ancestor z of some u and v guesses a state of A

and then simulates the b ehaviour of A on the path from z to v where it should

arrive in a nal state of A and simulates the b ehaviour of A backwards on the

path from z to u where it should arrive in an initial state of A We leave the

details of G as an exercise to the reader ut

The Main Result

In this section we prove the main result RPD CedNCE We start with the

inclusion of RPD in CedNCE We rst consider a dierent but strongly related

kind of graph description The edge lab els of the graphs are restricted to b e pairs

of states of a nite automaton

It is convenient to consider nite automata that are deterministic except that

they have an arbitrary number of initial states A nite automaton is a tuple

A Q I F where Q is the nite set of states is the input alphab et

Q Q is the transition function I Q is the set of initial states

and F Q is the set of nal states The transition function is extended in the



usual way to a mapping Q Q and the language recognized by A is



LA fw j i I i w F g

Denition An automaton path description is a tuple R T h A

where is a ranked alphab et is an alphab et T is a regular tree language

I F is a in T h is a partial function from to and A Q

 

nite automaton with LA The graph language described by R is

LR fg r t j t T g where g r t is the graph H GR such that

R R I F

V is the set of vertices v of t for which v is in the domain of h

H t

v h v for v V and

H t H

E is the set of all edges u hq q i v such that q path u v q q I

H

t

and q F ut

Lemma If R is an automaton path description then LR CedNCE

Proof Let R T h A and A Q I F Moreover let G

N P S b e a regular tree grammar in normal form generating T where

N disjoint with is the set of nonterminals of G We construct a CedNCE

0 0 0

grammar G N Q Q I F P S such that LG LR The idea

0

is that G simulates G generating the appropriate vertices of the tree t generated

0

by G To generate the edges of g r t G simulates the b ehaviour of A in its

R

edge lab els through the use of the dynamic edge relab eling feature of edNCE

0

grammars To this aim G also keeps edges b etween nonterminal vertices u

and v of a sentential form s generated by G viz all edges u hq q i v such

0 0

that q path u v q where path u v is obtained from path u v by

s s s

erasing the lab els of u and v note that all nonterminal vertices are leaves of s

0

Similarly G keeps edges from each nonterminal vertex u to each terminal vertex

v with q F and only the lab el of u erased and from each terminal vertex u

to each nonterminal vertex v with q I and only the lab el of v erased

0

The set of pro ductions P is dened as follows Let p X X X

k

b e a pro duction of G with V fx x x g x and

k

rhsp rhsp

x X N for i k With this pro duction p P we asso ciate

i i

rhsp

0 0

one pro duction p P We rst consider the case that h is dened Then

0

p X D C where

V fx x x g

D k

E fx hq q i x j i j q q g

D i j

fx hq q i x j i q I q q g

i

q g fx hq q i x j i q F q

i

x h and x X for i k

D D i i

0 0

C f hq q ihq q i x out j q q i g

i

0 0 0

f hq q ihq q i x out j q q q I g

0 0

f hq q ihq q i x in j q q i g

i

0 0 0

f hq q ihq q i x in j q q q F g

where we have used to denote an arbitrary element of N In the case that

0

h is undened the ab ove denition of p should b e changed in the obvious

way by dropping x from V and restricting all other comp onents accordingly

D

such that only the rst part of E the second part of and the rst and

D D

third parts of C remain

0 0

This ends the denition of G It is straightforward to verify that G is con

0

uent Intuitively the reason is that every edge in a sentential form s of G is of

the form u hq q i v Moreover if u is rewritten then the edge lab el changes

0 0

and the connection instructions do not insp ect q or q i for some q into hq

0 0

v Similarly if v is rewritten it changes into hq q i for some q and q and

s

u are not insp ected As a consequence if b oth u and v are rewritten the

s

0 0

edge lab el will b e hq q i indep endent of the order of rewriting In fact this idea

is formalized in Lemma of ER

To show the correctness of the construction we extend the denition of g r

R

to sentential forms of G Let s b e a sentential form of G Note that s is a

tree with the nonterminals having rank We dene g r s to b e the graph

R

H GR such that

N [QQ

V is the union of the set of nonterminal vertices of s and the set of terminal

H

vertices v of s for which v is in the domain of h

s

v v for a nonterminal vertex v v h v for a terminal

H s H s

vertex v and

0

E is the set of all edges u hq q i v such that q path u v q and if

H

s

0

u is terminal then q I and if v is terminal then q F where path u v is

s

obtained from path u v by erasing all elements of N

s

It can now b e shown by induction on the length of the derivations that



for every graph H GR snS z H if and only if there exists

0

N [QQ

G



s T such that snS z s and H g r s Since g r s GR

N [ R R I F

G

0

i s T this implies that LG LR This proves the lemma

Note that if g r s GR then s T and hence g r s GR

R QQ R I F

0

This shows that G is nonblocking cf the denition of the nonblocking prop erty

just after Denition ut

Having done most of the work we now show that RPD is included in CedNCE

Lemma RPD CedNCE

Proof Let R T h W b e a regular path description Since for every

W is regular there is a nite automaton with one initial state that

recognizes W By putting all these automata disjointly together it should

I F such that b e clear that there exists a nite automaton A Q



I and for every W fw j w F g Now consider

0

the automaton path description R T h A and let I F b e

0

the edge relab eling such that q q q Obviously LR LR Hence

by Lemma and Prop osition LR is in CedNCE This proves the lemma

It is easy to see that the construction in the pro of of Prop osition preserves

the nonblocking prop erty of the edNCE grammars Together with the remark at

the end of the pro of of Lemma this shows that LR can b e generated by a

nonblocking CedNCE grammar ut

To prove that CedNCE RPD we will rst develop a few technical to ols First

of all in order to nd a regular path description for a given CedNCE grammar

it is convenient to assume that all no des of a righthand side of a pro duction have

distinct lab els It is easy to do this for the nonterminal no des for the terminal

no des a no de relab eling is needed to reestablish the original lab els Let b e

0 0

a no de relab eling ie a mapping where and are no de lab el

0

alphab ets For a graph H GR we dene H GR to b e the graph

V E where v v for every v V Let us say that a graph

H H H H

D is uniquely labeled if for all u v V if u v then u v And let

D D D

us say that a CedNCE grammar is uniquely lab eled if all righthand sides of its

pro ductions are uniquely lab eled

Lemma For every CedNCE grammar G one can construct a uniquely la

0 0

beled CedNCE grammar G and a node relabeling such that LG LG

The same is true for BedNCE AedNCE and LINedNCE grammars

Proof Let G P S and let m b e an upp er b ound on the number

of no des with the same lab el in the righthand sides of the pro ductions in P

0 0

Let b e any alphab et and let b e any surjective mapping such that

m for every where A is the cardinality of a nite set A

0 0 0 0 0 0 0

Then we construct G P S where S is any

0

element of S and P is dened as follows Let p X D C b e in P

0 0

0

Construct a uniquely lab eled graph D GR such that D D Dene

0 0 0 0 0

C f x d j x d C g Then corresp onding to p

0 0 0 0 0

P contains the pro ductions X D C for every X X

0

It can easily b e veried that G is conuent and that the construction pre

serves the b oundary ap ex and linear prop erties It should also b e clear that

0 0 0 0

LG LG where is the restriction of to ut

In the ab ove lemma the no de relab eling is not really needed for the case of

arbitrary CedNCE grammars In fact the grammar can rst b e transformed

into an equivalent one in which each righthand side of a pro duction contains at

most one terminal no de see eg Oos ER

The following lemma is obvious it suces to comp ose the function h of the

regular path description with the no de relab eling

Lemma RPD is closed under node relabelings The same holds for BRPD

ARPD and LINRPD

Thus in the remainder of this section it suces to consider uniquely lab eled

CedNCE grammars

The main idea in the construction of a regular path description R for a

CedNCE grammar G is to use the set of derivation trees of G as the regular

tree language of R In our case it is convenient to dene derivation trees in

such a way that the internal vertices are lab eled by pro ductions of G whereas

the leaves are lab eled by the no de lab els of G Intuitively if H is generated

by G according to a derivation tree t the pro ductions that are used in the

generation are on the lab els of the internal vertices of t whereas the leaves of t

represent the no des of H The edges b etween two no des u and v of H can then b e

determined by verifying that path u v b elongs to a certain

t

Note that path u v consists of the two sequences of pro ductions that are used

t

to generate u and v and of the lab els of u and v which determine u and v in

the righthand sides of the pro ductions that are applied last It suces to know

this information in order to simulate the connection instructions that build the

edges b etween u and v and this simulation can b e done by a nite automaton

We rst dene a regular tree grammar that generates the derivation trees of

a CedNCE grammar

Denition Let G P S b e a uniquely lab eled CedNCE gram

mar We will view the elements of P and also as symbols of a ranked alphab et

where the rank of a pro duction p is the number of no des of rhsp and the rank of

every is The derivation tree grammar of G is the regular tree grammar

0 0 0 0 0 0 0 0 0

G P S where P P S S and P consists

of all pro ductions X p with p P X lhsp k V and

k

rhsp

f g f v j v V g The order of the no de lab els of rhsp

k

rhsp rhsp

0

in this pro duction of P is arbitrary but xed Note that all are distinct

i

b ecause rhsp is uniquely lab eled ut

We now dene the set of all p ossible lab els of paths from a vertex to a leaf in a

derivation tree of G

Denition Let G P S b e a uniquely lab eled CedNCE gram

mar The set PS G of path strings of G is dened to b e the set of all strings



p p P such that n p P for i n for every

n i

i n there is a unique no de in rhsp with lab el lhsp and if

i i

n there is a unique no de in rhsp with lab el

n

Let p p PS G Let y y b e the unique no des describ ed ab ove

n n

with y rhsp Then we dene rstp p y where we assume that

i i n

n We also dene connp p f d j

n n

and y d conp for all i ng And we

n i i i i

dene lhsp p lhsp if n and if n ut

n

Recall that conp is the connection relation of the pro duction p Intuitively

i i

p p PS G is the sequence of lab els of the vertices on a path from a

n

0

vertex to a leaf in a sentential form of the derivation tree grammar G of G the

internal vertices are lab eled by pro ductions p p and the leaf is lab eled by

n

The set connp p formalizes the total eect of the connection instructions

n

that are used when the pro ductions are applied and pro duce the leaf y Note

n

that for n conn f d j d fin outgg Note also

that connp f d j y d conp g where y is the unique

no de of rhsp with lab el

It should b e clear that PS G is regular it is easy to dene a nite automaton

that checks the requirements in its denition The following fact is obvious from

the denition of conn



Lemma Let w w PS G with w P and Then d

i

connw w if and only if there exists such that d connw

and d connw where lhsw

In the next lemma we show that the prop erty of conuence can b e generalized

to two arbitrary sequences of pro ductions rather than just two pro ductions

Although this is a wellknown fact we need it here in the following technical

form

Lemma Let G P S be a uniquely labeled CedNCE gram



mar For al l path strings w w PS G with w P and and

i i

al l edge labels the fol lowing equivalence holds where X lhsw

i i i

X out connw and in connw

X in connw and out connw

Proof For w w P the ab ove equivalence is exactly the one in the denition

of conuence Denition For w ie the empty string b oth conditions

say that in connw and similarly for w

For the remaining cases we use induction on the sum of the lengths of w

and w The basis of the induction has already b een treated In the induction

step we may assume that w and w are nonempty Or viewed in another way



consider p w and p w in PS G with p P w P and Let

i i i

lhsw Intuitively it should now b e p ossible to change the sequence of

i i i

pro ductions p w p w into the sequence p p w w by interchanging w and p

then changing it into p p w w by interchanging b oth p p and w w and

nally changing it into p w p w by interchanging p and w Formally this is

proved as follows

X out connp w and in connp w

by Lemma twice

0

X out connp

X out connw

0

in connp and

0

in connw

by induction for the second and third line

0

X out connp

in connp

0

out connw and

0

in connw

by conuence for the rst two lines and by induction for the last two lines

0

X in connp

out connp

0

in connw and

0

out connw

by induction for the second and third line

0

X in connp

X in connw

0

out connp and

0

out connw

by Lemma twice

X in connp w and out connp w ut

We are now ready to show the inclusion of CedNCE in RPD

Lemma CedNCE RPD

Proof By Lemmas and it suces to consider a uniquely lab eled CedNCE

grammar G P S Instead of constructing a regular path descrip

tion of LG we will construct one of SF G GR the set of sentential

forms of G This is sucient by Lemma b ecause LG SF G GR

0

We dene the regular path description R P S F G h W where

0 0

G P P P S is the derivation tree grammar of G and h is the

identity mapping on It remains to dene W

0

Thus we use the set of sentential forms of G as the regular tree language

of R and it should b e clear that it is indeed regular By the denition of h

0

the no des of g r t are exactly the leaves of the sentential form t of G to b e

R

honest this is not entirely true if the righthand side of a pro duction p is the

empty graph then p is of rank and hence may b e the lab el of a leaf of t



For a string w P we denote by we the reverse of w ie if w p p p

n

then we p p p For we dene

n



W f wf pw j p P w w P

pw pw PS G and for x rstpw

i i i

x x E

rhs p

x out connw and

rhsp

in connw g

It is straightforward to show that W is regular The main p oint is that

connw can b e computed by a nite automaton

This ends the denition of the regular path description R To prove that

LR SF G it can b e shown by induction on the length of the derivations



H if and only if there exists t T that for every H GR snS z

P [

G



such that snS z t and g r t H For the induction step it suces to

0

R

G

show the following statement for every t T

P [

0 0 0 0 0

0

t in G then g r t H if g r t H H H in G and t

R R v p v p

0 0

where p is the pro duction of G of the form X p Note that since

k

g r t H every no de of H and in particular v is also a vertex of t Let

R

0

us sketch the pro of of the ab ove statement To b e more precise p and p are

0

pro duction copies and we may assume that the righthand side of p has ver

tices x x x with lab els p resp ectively where x x are

k k k

0

the no des of rhsp with the same lab els Thus t is obtained from t by replac

0

t t

u u

x p v X

x x x

i k i k

Fig A derivation step

ing the leaf v by the internal vertex x with children x x cf Fig and

k

0

H is obtained from H by replacing the no de v by the no des x x and of

k

course executing the connection instructions From this and the denition of

0 0

h it should b e clear that g r t and H have the same no des with the same

R

lab els It remains to show that they have the same edges Note that since G is

uniquely lab eled the lab els of x x are all distinct Let u and u

k k

0

b e two leaves of t It should b e clear that if u and u are b oth leaves of t then

0

path u u path u u and hence they have the same edges in g r t

0

R

t t

0

and g r t since they also have the same edges in H and H by Denition

R

0 0

they have the same edges in g r t and H If u x and u x for some

R i j

p Since clearly p W if and i j k then path u u

0

j i j i

t

0 0

only if x x E u and u have the same edges in g r t and H

i j R

rhsp

The last and most imp ortant case to consider is that u is a leaf of t and u x

i

0 0

for some i k see Fig Let us rst show that g r t and H have the

R

0

p w p with same edges u x from u to u Clearly path u x wf

0

i i i

t

0

p w X recall that X is the lab el of v Now path u v wf

t

0

u x E

i

g r t

denition of W

0

x x E

rhsp

0

x out connw and

rhs p

in connw p

i

0 0

where x rstp w and x rstp w p

i

Lemma

0

x x E

rhsp

0

x out connw

rhs p

in connw X and

in connp

i

denition of W and denition of conn

u v E and x in conp

i

g r t

g r t H

u v E and x in conp

H i

Denition

0

u x E

i H

0 0

Finally it has to b e shown that g r t and H have the same edges x u

R i

0

from u to u In this case we have path x u pwf p w and path v u

0

i i

t t

0

X wf p w Trying the same pro of as ab ove would not work b ecause the deni

tion of W forces the execution of w p b efore the execution of w which do es

not allow the reduction to the case of w and w However Lemma allows us

to interchange the order of these executions To b e more precise by Lemma

the last two lines of the denition of W can b e changed into

x in connw and

rhs p

out connw

Using this alternative denition of W the pro of is completely analogous

to the one ab ove syntactically change u x into x u x x into

i i

x x u v into v u and interchange in and out

0 0

This shows that g r t H and ends the pro of ut

R

Lemmas and give the main result

Theorem CedNCE RPD

As can b e seen from the remarks at the end of the pro ofs of Lemma and

Lemma we have also shown that for every CedNCE grammar there is an

equivalent nonblocking CedNCE grammar The essence of this fact is contained

in the pro of of Lemma

As an application of Theorem we show that BedNCE is a prop er sub

class of CedNCE For a graph H its edge complement is the graph comH

V E where E is the set of all v w v w that are not in E It is

H H H

easy to see that RPD is closed under edge complement ie if L RPD then

fcomH j H Lg RPD In fact it suces to change each W into the

 

W Hence by Theorem CedNCE is regular string language

closed under edge complement The class of BedNCE languages is not closed

under edge complement see Theorem of ELW This proves that BedNCE

is a prop er sub class of CedNCE A concrete example of a graph language in

CedNCE that is not in BedNCE is the set of edge complements of binary trees

Theorem BedNCE is a proper subclass of CedNCE

Sp ecial Cases

In this section we consider a number of variations of the main result

It follows from the pro of of Theorem and in particular from the pro of of

Lemma that for a regular path description R T h W we may

always assume that h is only dened for symbols in of rank This means

that for every tree t T all the no des of g r t are leaves of t In fact if

R

LR do es not contain the empty graph then we may even assume that the

domain of h is exactly the set of symbols in of rank b ecause it is easy to

show that a CedNCE language without the empty graph can b e generated by a

CedNCE grammar of which all righthand sides of pro ductions are nonempty

That means that the no des of g r t are exactly the leaves of t It is an open

R

problem whether it may always b e assumed that h is a total function ie that

the no des of g r t are exactly all vertices of t again assuming that the empty

R

graph is not in LR In the following prop osition we treat a sp ecial case

Prop osition Let G be a CedNCE grammar such that every righthand side

of a production has exactly one terminal node Then there is a regular path

description R of LG such that h of R is a total function

Proof Note rst that the two prop erties are preserved by Lemmas and

resp ectively Now consider the construction in the pro of of Lemma followed

by the one in the pro of of Lemma This shows that LG has a regular path

description R which can b e obtained from R in the pro of of Lemma by

changing the regular tree language of R into some regular tree language T

0

LG Thus R P T h W where h is the identity on and

W is dened as in the pro of of Lemma for every Clearly we

may assume that for every internal vertex v of every tree t T the last child

of v is a leaf whereas the other children are not leaves The no des of g r t

R

are exactly the leaves of t The idea is now to prune all leaves from t and to

let each former internal vertex v take over the role of its former last child

0 0 0

Formally we dene the regular path description R P T h W such

that the rank of a pro duction p of G is the number of nonterminal no des of rhsp

0 0

T fpr t j t T g where pr t is obtained from t by removing all its leaves h

0

is the total function from P to such that for every p P h p x

p

rhs p

0

where x is the unique terminal no de of rhsp and W is the set of all strings

p



pw with w P and p P such that wf pw W where is the wf

i i

lab el of the terminal no de of the righthand side of the last pro duction of pw

i

0 0

Using the regularity of T and W it is easy to show that T and W are

regular It should b e clear that LR LG This proves the prop osition

As an example we observe that the regular path description R of Exam

ple is obtained from the CedNCE grammar G of Example by the ab ove

construction Note that G satises the assumption of this prop osition The reg

ular tree grammar G that generates the regular tree language of R is obtained

from G as follows apply the construction of Lemma to G in order to make

it uniquely lab eled replacing X by L and R take the derivation tree grammar

of the resulting CedNCE grammar and prune the terminal leaves from the pro

ductions of the resulting regular tree grammar Note that a b b c c are the

l r l r

pro ductions of the uniquely lab eled CedNCE grammar ut

Let us now consider the class BedNCE of graph languages generated by b ound

ary edNCE grammars see Section for the denition Recall from Section

the denition of the class BRPD of regular path descriptions of type B every

 

W is a subset of

Theorem BedNCE BRPD

Proof First the inclusion BRPD BedNCE Let us say that an automaton

 

path description R T h A is of type B if LA Now

consider the pro of of Lemma for R of type B It should b e clear that the gram

0

mar G need not keep edges b etween nonterminal vertices any more Hence in

0 0

the denition of the pro duction p X D C of G the edges x hq q i x

i j

can b e dropp ed from E Then the in the connection instructions of C can b e

D

0

restricted to This turns G into a BedNCE grammar It should b e clear that

the construction in the pro of of Lemma changes a regular path description of

type B into an automaton path description of type B

We now turn to the second inclusion BedNCE BRPD It is shown in

Theorem of ELW that every BedNCE language not containing the empty

graph can b e generated by a BedNCE grammar of which the righthand side of

every pro duction contains exactly one terminal no de the pro of is for undirected

graphs but can b e adapted in a straightforward way to directed graphs This

allows us to use the construction in the pro of of Prop osition To this aim

we rst have to check the construction in the pro of of Lemma Consider the

pw is in W then denition of W in that pro of We claim that if wf

either w or w where is the empty string In fact if x is a

nonterminal no de then w b ecause x out connw

rhs p

and G is a BedNCE grammar if on the other hand x is a terminal no de then

 

P PP w b ecause x lhsw This shows that W P

Hence for the regular path description R in the pro of of Prop osition we

0  

obtain that W P P PP which shows that R is of type B ut

Next we consider the class LINedNCE of graph languages generated by linear

edNCE grammars see again Section for the denition Recall again from

Section the denition of the class LINRPD of regular path descriptions of

type LIN the symbols of have rank or

Theorem LINedNCE LINRPD

Proof It is easy to check the pro ofs to see that they preserve linearity The

inclusion LINedNCE LINRPD is based on the fact shown in Theorem of

ELW for undirected graphs that every LINedNCE language can b e generated

by a LINedNCE grammar of which the righthand side of every pro duction

contains exactly one terminal no de Then all elements of the ranked alphab et P

of R in the pro of of Prop osition have rank or ut

We nally consider the class AedNCE of graph languages generated by ap ex

edNCE grammars see again Section Recall again from Section the den

ition of the class ARPD of regular path descriptions of type A every W is

nite The next result solves a conjecture on p of ELW

Theorem AedNCE ARPD

Proof To show that ARPD AedNCE we use Prop osition By this prop osi

tion and the inclusion of RPD in CedNCE Theorem it suces to show that

every graph language in ARPD is of b ounded degree Let R T h W

b e a regular path description such that W is nite for every Let k

b e the maximal length of the strings in the W s Consider some t T and

u V In g r t if there is an edge b etween u and v then either path u v

t R

t

or path v u is in W for some Hence the distance b etween u and all

t

such vertices v is at most k Let m b e the maximal rank of the elements of

k

Then there are at most m vertices within distance k from u Hence u is

k

of degree at most m in g r t

R

To show that AedNCE ARPD consider the pro of of Lemma If G is

an AedNCE grammar then W is nite for every In fact it is easy

to see from Denition that in that case if n then connp p

n

b ecause all y must b e terminal This implies that all path strings in W

i

have length at most and even b ecause at least one of the strings w in the

i

denition of W is empty cf the pro of of Theorem ut

It can b e shown using a slightly more complicated construction than the one

in the pro of of Prop osition that every regular path description of type A is

 

The equivalent to one for which every W is a nite subset of

basic idea is to remove all children of an internal vertex v that are leaves and

replace them by a sequence of unary vertices ab ove v

String Languages

It is well known that an edge lab eled graph can b e used to dene a regular string

language consisting of the strings of edge lab els along all directed paths in H

from certain initial no des of H to certain nal no des of H In fact this is just

another way of saying that the graph H is viewed as a nondeterministic nite

automaton To dene nonregular string languages one might use a set of graphs

rather than just one graph Clearly allowing arbitrary sets of graphs would give

arbitrary string languages Thus it would b e more natural to use only graph lan

guages that can b e generated by certain graph grammars Here we investigate

the string generating p ower in the ab ove sense of CedNCE graph grammars

We will show that in this way they generate the class of output languages of non

deterministic treewalking transducers cf ERS The LINedNCE grammars

generate the class of checking stack languages cf Gre To simplify the pro ofs

we will allow the edges of the graphs to b e lab eled by arbitrary strings including

the empty string This corresp onds to nite automata that can read an arbi

trary p ossibly empty string in one step It is formalized by applying a string

homomorphism to the language recognized by an ordinary nite automaton

Denition Let H GR and let i f Then path H is dened

if



to b e the set of all such that there is a directed path with no des

n

v v v n in H with v i v f and v v E

n H H n j j j H

for all j n

Let K b e a class of graph languages Then PathK is the class of all string

languages path L fpath H j H Lg where L K and i f are

if if

arbitrary no de lab els And HPathK is the class of string languages L where

L PathK and is an arbitrary string homomorphism ut

As an example for the graph language LG of ladders from Example

n n m n n

1 1

k k

with k path LG is the set of all strings

if

m and n m for all j k Clearly this language is not regular

j

not even contextfree but it is a checking stack language guess the number

m on the checking stack walk up and down part of the stack k times and walk

up the whole stack

We now describ e the treewalking transducer in an informal way detailed

denitions can b e found in eg ERS A treewalking transducer abbreviated

twt is a nondeterministic automaton with a nite control an input tree and an

output tap e The input trees are taken from a given regular tree language over

some ranked alphab et At any moment of time the automaton is at a certain

vertex of the input tree Dep ending on the state of its nite control and the

lab el of the vertex it changes state outputs a string to the output tap e and

either moves to the parent or to a sp ecic child of the vertex The automaton

starts in its initial state at the ro ot of the input tree and halts whenever it

reaches a nal state In this way it nondeterministically translates the input tree

into an output string The output language of the automaton is the set of all

output strings that are translations of input trees from the given regular tree

language By OUTTWT we denote the class of all output languages of tree

walking transducers From a slightly dierent p oint of view one could view a

twt as computing a relation b etween trees and strings OUTTWT is the class

of images of regular tree languages under such twt relations In the case that

the lab els of the input tree all have rank or the input tree can b e viewed

as a twoway input tap e and the twt as a nondeterministic twoway gsm ie a

nite state transducer with a twoway input tap e gsm abbreviates generalized

sequential machine see eg HU By OUTGSM we denote the class of all

output languages of twoway gsms It is well known that OUTGSM equals

the class of oneway checking stack languages in fact the input tap e and

output tap e of the twoway gsm can b e viewed as the checking stack and the

oneway input tap e of the checking stack automaton resp ectively For more

details on the ab ove see ERS where the twt is called checking

or cttransducer and the twoway gsm is called checking string transducer or

cstransducer

We now use our main result Theorem to show that CedNCE grammars

have the same string generating p ower as treewalking transducers For LIN

edNCE grammars we use Theorem to show that they have the same string

generating p ower as twoway gsms or checking stack automata The pro of will

b e as informal as the description of the twt ab ove

Theorem HPathCedNCE OUTTWT and

HPathLINedNCE OUTGSM

Proof In this pro of whenever we consider a regular tree language T T

either of a regular path description or of a twt we will assume that there is a

mapping num f g such that for every vertex x of a tree t T if

num x j then either x is not the ro ot and j is the lab el of the incoming

t

edge of x ie x is the j th child of its parent or x is the ro ot of t and j

Clearly this assumption can b e made without loss of generality

We rst show that HPathRPD OUTTWT and HPathLINRPD

OUTGSM Let R T h W b e a regular path description let



i f and let b e a string homomorphism with domain It is not dicult

to construct a twt M with input tree language T and with output language

path LR For a given input tree t T M rst nondeterministically

if

walks to a vertex x of t such that h x i Then rep eatedly M chooses a

t

symbol outputs and nondeterministically walks to another vertex

y for which h y is dened walking along the shortest undirected path from

t

x to y and using its nite control to check that path x y is in W Finally

t

M halts after checking that h x f for the current vertex x Note that

t

when walking from x to y along the shortest path from x to y M rst ascends

to the least common ancestor z of x and then in general descends to y to do

this M has to store the number num x of the child x of z of which x is a

t

descendant in its nite control in order to b e able to descend to another child

y of z of which y will b e a descendant

Next we show that OUTTWT HPathRPD Let M b e a twt with input

tree language T T and output alphab et Since a string homomorphism

is incorp orated into the denition of HPathRPD it clearly suces to assume

that M outputs exactly one symbol from at each move and to prove that

the output language of M is in PathRPD Also we may assume that M never

reenters its initial state and that it has exactly one nal state Let Q b e the

set of states of M and let i f Q i f b e its initial and nal state resp ec

0 0

tively We construct a regular path description R T h W such

0

that path LR is the output language of M The trees of T are obtained

if

0 0

from those of T as follows for a tree t T we construct the tree t T by adding

Q new children to every vertex x of t lab eled distinctly with the ele

ments of Q fig and adding one more new child with lab el i if x is the ro ot of

t Such a new child with lab el q Q intuitively represents the fact that M is at

0

0

vertex x of t in state q Thus Q where rank rank Q

0

for every with num rank rank Q for every

0

with num and rankq for every q Q Clearly T is a regular tree

0 0

language We take and we take h to b e the identity on Finally

for every W is a nite language obtained from the nite control of

M as follows If M in state q and reading vertex lab el may go into state

p output and move to the parent then W contains the string q p for

every If M in state q and reading vertex lab el may go into state p

p for output and move to the j th child then W contains the string q

every such that num j From this construction of R it should b e

clear that path LR is the output language of M Intuitively for a tree t a

if

0

directed path in the graph g r t represents a walk of M on t

R

Note that we have even shown that OUTTWT HPathARPD

To prove that OUTGSM HPathLINedNCE we rst construct R as

0

ab ove It is not dicult to see that the regular tree language T of R can b e

generated by a linear REGT grammar Consider the pro of of Lemma It

is left to the reader to show that it can b e adapted easily for an arbitrary

regular tree grammar G not necessarily in normal form the only thing that

0

changes is the denition of E for the pro duction p X D C Since the

D

pro ofs of Lemma and Prop osition b oth preserve linearity cf the pro of of

Theorem this shows that LR can b e generated by a LINedNCE grammar

ut

It can b e shown that HPathCedNCE PathCedNCE ie that the class

PathCedNCE is closed under homomorphisms but with the to ols we have

now the pro of is not easy to present and thus will not b e given here

Another way of generating string languages by graph grammars was investi

gated in EH Every string can b e viewed as a graph with n no des

n

that are connected into a directed chain by n edges lab elled In this

n

way every string language can b e viewed as a sp ecial type of graph language

For a class of graph languages K we denote by STR K the class of all string

languages in K The string languages generated by graph grammars in this way

were investigated in EH for another type of contextfree graph grammars

the hyperedge replacement grammars of Hab However it is known that these

grammars have the same string generating p ower in this sense as the CedNCE

grammars see eg Bra EH From this we nd that STRCedNCE

OUTDTWT the output languages of deterministic treewalking transducers

and STRLINedNCE OUTDGSM the output languages of deterministic

twoway gsms Hence this string generation metho d is weaker than the one

m n

discussed in this section For instance the language fa j m n g is in

OUTGSM guess m on the checking stack and then walk up and down the

whole stack n times or there is a LINedNCE grammar that generates the set

of all directed cycles This language is however not in OUTDTWT b ecause it

is not Parikh see ERS Note that in the other direction OUTDTWT con

tains all contextfree languages but OUTGSM do es not see Theorem

of Gre

References

BC MBauderon BCourcelle Graph expressions and graph rewritings Math Sys

tems Theory

Bra FJBrandenburg On partially ordered graph grammars in ENRR

Bra FJBrandenburg On p olynomial time graph grammars Pro c STACS Lec

ture Notes in Computer Science SpringerVerlag Berlin pp

Bra FJBrandenburg The equivalence of b oundary and conuent graph grammars

on graph languages of b ounded degree in Rewriting Technniques and Appli

cations RVBo ok ed Lecture Notes in Computer Science Springer

Verlag Berlin pp

CER BCourcelle JEngelfriet GRozenberg Handlerewriting hypergraph gram

mars J of Comp Syst Sci

CLS DGCorneil HLerchs LStewart Burlingham Complement reducible graphs

Discr Appl Math

Cou BCourcelle An axiomatic denition of contextfree rewriting and its applica

tion to NLC graph grammars Theor Comput Sci

Cou BCourcelle The monadic secondorder logic of graphs VI I Graphs as rela

tional structures Theor Comput Sci

Cou BCourcelle Structural prop erties of contextfree sets of graphs generated by

vertex replacement Inform and Comput

EH JEngelfriet LMHeyker The string generating p ower of contextfree hyper

graph grammars J of Comp Syst Sci

EH JEngelfriet LMHeyker Hyp ergraph languages of b ounded degree J of

Comp Syst Sci

EHL JEngelfriet LMHeyker GLeih Contextfree graph languages of b ounded

degree are generated by ap ex graph grammars Acta Informatica

EJKR HEhrig DJanssens HJKreowski GRozenberg Concurrency of no delab el

controlled graph transformations Rep ort University of Antwerp UIA

EKR HEhrig HJKreowski GRozenberg eds GraphGrammars and their Ap

plication to Computer Science Lecture Notes in Computer Science

SpringerVerlag Berlin

EL JEngelfriet GLeih Linear graph grammars p ower and complexity Inform

and Comput

EL JEngelfriet GLeih Complexity of b oundary graph languages RAIRO The

oretical Informatics and Applications

ELR JEngelfriet GLeih GRozenberg Ap ex graph grammars in ENRR

ELR JEngelfriet GLeih GRozenberg Nonterminal separation in graph gram

mars Theor Comput Sci

ELW JEngelfriet GLeih EWelzl Boundary graph grammars with dynamic edge

relab eling J of Comp Syst Sci

Eng JEngelfriet Contextfree NCE graph grammars Pro c FCT Lecture Notes

in Computer Science SpringerVerlag Berlin pp

Eng JEngelfriet A characterization of contextfree NCE graph languages by

monadic secondorder logic on trees in EKR

Eng JEngelfriet A Greibach normal form for contextfree graph grammars Pro c

ICALP WKuich ed Lecture Notes in Computer Science Springer

Verlag Berlin pp

Eng JEngelfriet Graph grammars and tree transducers Pro c CAAP STison

ed Lecture Notes in Computer Science SpringerVerlag Berlin

pp

ENRR HEhrig MNagl GRozenberg ARosenfeld eds GraphGrammars and

their Application to Computer Science Lecture Notes in Computer Science

SpringerVerlag Berlin

ER JEngelfriet GRozenberg A comparison of b oundary graph grammars and

contextfree hypergraph grammars Inform and Comput

ER JEngelfriet GRozenberg No de replacement graph grammars Chap

ter for the Handbook of Graph Transformations Volume I Foundations

GRozenberg ed World Scientic to app ear

ERS JEngelfriet GRozenberg GSlutzki Tree transducers L systems and two

way machines J of Comp Syst Sci

Gre SAGreibach Checking automata and oneway stack languages J of Comp

Syst Sci

Gre SAGreibach One way nite visit automata Theor Comput Sci

GS FGecseg MSteinby Tree automata Akademiai Kiado Budap est

Hab AHab el Hyperedge Replacement Grammars and Languages Lecture Notes in

Computer Science SpringerVerlag

HK AHab el HJKreowski May we introduce to you hyperedge replacement in

ENRR pp

HU JEHop croft JDUllman Introduction to Languages and

Computation AddisonWesley Reading Mass

Kau MKaul Syntaxanalyse von Graphen bei PrazedenzGraphGrammatiken Dis

sertation Universitat Osnabr uck

KL CKim DHLee Separating k separated eNCE graph languages Theor Com

put Sci

Nag MNagl Formal languages of lab elled graphs Computing

Nag MNagl A tutorial and bibliographical survey of graph grammars in Graph

Grammars VClaus HEhrig GRozenberg eds Lecture Notes in Computer

Science SpringerVerlag Berlin pp

Nag MNagl GraphGrammatiken Vieweg Braunschweig

Oos Vvan Oostrom Graph grammars and nd order logic in Dutch M Sc The

sis Leiden University January

RW GRozenberg EWelzl Boundary NLC graph grammars basic denitions

normal forms and complexity Inform and Control

Schu RSchuster Graphgrammatiken und Grapheinbettungen Algorithmen und

Komplexitat Technical Rep ort MIP Universitat Passau

SW KSkodinis EWanke Exp onential time analysis of conuent and b oundary

eNCE graph languages in GraphTheoretic Concepts in Computer Science

WG EWMayr GSchmidt GTinhofer eds Lecture Notes in Computer

Science SpringerVerlag Berlin pp

SW KSkodinis EWanke The b ounded degree problem for eNCE graph gram

mars th International Workshop on GraphGrammars and their Application

to Computer Science Williamsburg Virginia USA November

Wel EWelzl Boundary NLC and partition controlled graph grammars in ENRR

A

This article was pro cessed using the L T X macro package with LLNCS style

E