• No results found

Hierarchical Graph Transformation

N/A
N/A
Protected

Academic year: 2019

Share "Hierarchical Graph Transformation"

Copied!
16
0
0

Loading.... (view fulltext now)

Full text

(1)

This is a repository copy of

Hierarchical Graph Transformation

.

White Rose Research Online URL for this paper:

http://eprints.whiterose.ac.uk/127096/

Version: Accepted Version

Proceedings Paper:

Plump, Detlef orcid.org/0000-0002-1148-822X, Drewes, Frank and Hoffmann, Berthold

(2000) Hierarchical Graph Transformation. In: Proceedings Foundations of Software

Science and Computation Structures (FOSSACS 2000). Lecture Notes in Computer

Science . Springer , pp. 98-113.

https://doi.org/10.1007/3-540-46432-8_7

[email protected]

https://eprints.whiterose.ac.uk/

Reuse

Items deposited in White Rose Research Online are protected by copyright, with all rights reserved unless

indicated otherwise. They may be downloaded and/or printed for private study, or other acts as permitted by

national copyright laws. The publisher or other rights holders may allow further reproduction and re-use of

the full text version. This is indicated by the licence information on the White Rose Research Online record

for the item.

Takedown

If you consider content in White Rose Research Online to be in breach of UK law, please notify us by

(2)

Hierarhial Graph Transformation

FrankDrewes 1

,BertholdHomann 1

,andDetlefPlump 2??

1

FahbereihMathematik/Informatik,UniversitatBremen Postfah330440, D-28334Bremen,Germany

fdrewes,hofginformatik.uni-bremen.de

2

DepartmentofComputingandEletrialEngineering Heriot-WattUniversity,EdinburghEH14 4AS,Sotland

detee.hw.a.uk

Abstrat. We present an approah for the rule-based transformation ofhierarhiallystrutured(hyper)graphs.Inthesegraphs,distinguished hyperedgesontaingraphsthatanbehierarhialagain.Ourframework extendsthedouble-pushoutapproahfromattohierarhialgraphs.In partiular,weshowhowtoonstrutreursivelypushoutsandpushout omplementsofhierarhialgraphsandgraphmorphisms.Tofurther en-hanetheexpressivenessoftheapproah,wealsointrodueruleshemata withvariableswhihallowtoopyandtoremovehierarhialsubgraphs.

1 Introdution

Reently, the idea of using rule-based graph transformation as a framework forspeiationandprogramminghasreeivedsomeattention,and several re-searhershaveproposed struturingmehanismsfor graphtransformation sys-temstomakeprogresstowardsthisgoal(seeforexample[2,8,10℄).Struturing mehanismswill beindispensableto managelargenumbersof rulesandto de-velop omplex systems from small omponents that are easy to omprehend. Moreover,webelievethat itwill beneessarytostruture thegraphsthat are subjettotransformation, too, inorder to opewithappliations ofarealisti size.Amehanismforhiding(orabstratingfrom)subgraphsinlargegraphswill failitateboththeontrolofruleappliationsandthevisualizationofgraphs.

Inthis paperweintroduehierarhialhypergraphsinwhihertain hyper-edges, alled frames, ontain hypergraphs that an be hierarhialagain, with an arbitrary depth of nesting. We show that the well-known double-pushout approah to graph transformation [5, 3℄ extends smoothly to these hierarhi-al (hyper)graphs,by givingreursiveonstrutions forpushouts and pushout omplementsintheategoryofhierarhialgraphs.Hierarhialtransformation rules onsist of hierarhial graphs and an be applied at all levels of the hi-erarhy,where the\dangling ondition"known from thetransformationofat graphsis adaptedinanaturalway.

?

This work has been partiallysupported by the ESPRIT Working Group Applia-tions ofGraphTransformation (Appligraph)andbythe TMRResearhNetwork GetgratsthroughtheUniversityofBremen.

??

(3)

for programming purposes (without damaging the theory), we also introdue rule shemata ontaining frame variables. These variables an be instantiated with framesontaininghierarhialgraphs,andanbeused toopyorremove frames withoutlooking at theirontents. Ourrunningexampleof aqueue im-plementation indiates thatthis oneptis useful,asit allowstodelete and to dupliatequeueentriesregardlessoftheirstrutureandsize.

Finally,werelatehierarhialgraphtransformationtotheonventional trans-formationofatgraphsbyintroduingaatteningoperation.Flattening reur-sivelyreplaeseahframeinahierarhialgraphbyitsontents,yieldingaat graphwithoutframes.Everytransformationsteponhierarhialgraphs|under amildassumption onthetransformedgraph|givesriseto aonventionalstep ontheattenedgraphsbyusingtheattenedrule.

2 Graph Transformation

IfS isaset,thesetofallnitesequenesoverS,inludingtheemptysequene ,isdenotedbyS

.Theithelementofasequenesisdenotedbys(i),andits length byj sj. If f: S ! T is afuntion then theanonial extensions of f to the powerset of S and to S

are also denoted by f. The omposition gÆf of funtions f:S!T andg:T !U isdenedby(gÆf)(s)=g(f(s)) fors2S.

Apushout in aategoryC (see, e.g.,[1℄)is atuple (m 1 ;m 2 ;n 1 ;n 2

)of mor-phismsm

i

:O!O i andn i :O i !O 0 withn 1 Æm 1 =n 2 Æm 2

,suh thatforall morphisms n

0 i

: O i

!P (i2 f1;2g)with n 0 1 Æm 1 =n 0 2 Æm 2

there is aunique morphismn:O

0

!P satisfyingnÆn 1

=n 0 1

andnÆn 2

=n 0 2

.

LetL beanarbitrarybut xedsetoflabels.A hypergraph H isaquintuple (V H ;E H ;att H ;lab H ;p H

)suhthat

{ V H

andE H

arenitesetsofnodesand hyperedges,respetively, { att H :E H !V H

istheattahment funtion,

{ lab H

:E H

!Listhelabelling funtion,and { p

H 2V

H

isasequeneofnodes,alled thepoints ofH.

Inthefollowing,wewillsimplysaygraphinsteadofhypergraphandedgeinstead of hyperedge. Wedenote by A

H

the set V H

[E H

of atoms of H. In order to makethis auseful notation, we shallalwaysassumewithout lossof generality that V

H andE

H

aredisjoint,foreverygraphH.

A morphism m:G ! H between graphs G and H is a pair (m V ;m E ) of mappings m V : V G ! V H and m E : E G ! E H

suh that m V

(p G

) = p H

and, for alle2E

G , lab

H (m

E

(e))=lab G

(e)andatt H

(m E

(e))=m V

(att G

(e)). Suh amorphism isinjetive (surjetive,bijetive)if bothm

V

andm E

are injetive (respetivelysurjetiveorbijetive).Ifthereisabijetivemorphismm:G!H then G and H are isomorphi, whih is denoted by G

=

H. Fora morphism m: G ! H and a 2 A

G

we let m(a) denote m V

(a) if a 2 V G

and m E

(4)

G H thegraph(V

G [V H ;E G [E H

;att;lab;p G ),where att(e)= att G

(e) ife2E G att

H

(e)otherwise

and lab(e)=

lab G

(e)ife2E G lab

H

(e)otherwise

for all edges e 2 E G

[E H

. (If A G

\A H

6= ;, we assume that some impliit renaming of atoms takes plae.) Notie that this operation is assoiative but doesnot ommutesineG+H inheritsitspointsfromtherstargument.

Wereallthefollowingwell-knownfatsaboutpushoutsandpushout omple-mentsintheategoryofgraphsandgraphmorphisms(see[5℄).Letm

1

:G!H 1 and m

2

: G!H 2

be morphisms.Then there is agraphH and there are mor-phisms n

1 :H

1

!H and n 2

:H 2

!H suh that (m 1 ;m 2 ;n 1 ;n 2

)isapushout. Furthermore,H and the n

i

are determined asfollows. Let H 0

be the disjoint union of H

1 and H

2

, and let be the equivalene relation on A H

0

generated by theset of all pairs(m

1 (a);m

2

(a)) suh that a2 A G

. Then H is thegraph obtainedfrom H

0

byidentifying allatoms a;a 0

suh that aa 0

(i.e.,H isthe quotiontgraphH

0

=).Moreover,fori2f1;2ganda2A Hi

,n i

(a)=[a℄

,where [a℄

denotestheequivalenelassofaaordingto .

Inordertoensuretheexisteneanduniquenessofpushoutomplements(i.e., theexisteneand uniquenessof m

2 and n 2 ifm 1 andn 1

are given),additional onditions must be satised. Below, we only need the ase where both of the given morphisms are injetive. In this ase it is suÆient to assume that the dangling ondition is satised.Twomorphismsm

1

: G!H 1 and n 1 : H 1 !H satisfythedanglingonditionifnoedgee2E

H nn

1 (E

H1

)isattahedtoanode inn

1 (V

H1 )nn

1 (m

1 (V

G

)).Itiswell-knownthat,ifm 1

andn 1

areinjetive,then there are m

2 and n

2

suh that (m 1 ;m 2 ;n 1 ;n 2

)is apushout,if andonly ifm 1 and n

1

satisfythedanglingondition.Furthermore,iftheyexist,then m 2

and n

2

areuniquelydetermined(up toisomorphism).

Atransformationrule (rule,forshort) isapairt:L l

I r

!R ofmorphisms l:I ! L and r:I !R suh that l is injetive.L, I, and R are the left-hand side, interfae,and right-hand side of t.A graphG anbetransformedinto a graph H by an appliation of t, denoted by G )

t

H, if there is an injetive morphismo:L!G,alled anourrenemorphism,suhthat twopushouts

L I R

G K H

l

r

o

exist.Itfollowsfromthefatsaboutpushoutsandpushoutomplementsrealled above that suh a diagram exists if and only if l and o satisfy the dangling ondition,andinthisaseH isuniquelydetermineduptoisomorphism.Notie thatweonlyonsiderinjetiveourrenemorphisms,whihisdoneinorderto avoidadditionaldiÆultieswhenonsideringthehierarhialase.Ontheother

(5)

Graphsasdened in theprevioussetionareat.If someonewished to imple-ment,say,someompliatedabstratdatatypebymeansofgraph transforma-tion,there would benostruturingmehanismsavailable,exeptforthe possi-bilities thegraphsthemselvesprovide. Thus, anystrutural informationwould havetobeodedintothegraphs,asolutionwhihisusuallyinappropriateand error-prone.Tooveromethislimitation,weintroduegraphswithanarbitrarily deep hierarhial struture. This is ahieved bymeans of speial edges, alled frames, whih may ontain hierarhial graphs again. In fat, it turns out to beusefulto beevenmoregeneralbyallowingsomeframestoontainvariables insteadofgraphs.Thesestrutureswill bealledhierarhialgraphs.

LetX be aset of symbols alled variables. The lass H (X) of hierarhial graphs with variables in X onsists oftriples H = hG;F;tsi suh that Gis a graph (the root of the hierarhy), F E

G

is the set of frame edges (or just frames), and ts: F ! H (X)[X assigns to eah frame f 2 F its ontents ts(f) 2 H (X)[X. Formally, H (X) is dened indutively over the depth of framenesting,asfollows.AtripleH =hG;F;tsiasaboveisinH

0

(X)ifF =;. In this ase, H maybe identied with thegraph G. Fori > 0,H 2H

i (X) if ts(f)2H

i 1

(X)[X for everyframef 2F. Finally, H (X)denotestheunion of all these lasses: H (X) =

S i0

H i

(X). (Notie that H i

(X) H i+1

(X) for all i 0. We have H

0

(X) H 1

(X) beausean empty set of frames trivially satises the requirement; using this, H

i

(X) H i+1

(X) follows by an obvious indution oni0.) Thesets H (;)andH

i

(;) (i0) arebrieydenoted byH andH

i

,respetively.Thesevariable-free hierarhialgraphsarethosein whih wearemainlyinterested.

Notiethat,toavoidunneessaryrestritions,thedenitionofahierarhial graph H = hG;F;tsi does not impose any relation between the nodes and edges ofGand thoseof ts(f),f 2F. Restritionsofthis kindmaybeadded forspeiappliationareas,buttheresultsofthispaperholdingeneral.

Example 1 (Queue graphs). As a running example, we show how queues and their typial operationsanbeimplemented using hierarhial graph transfor-mation.Twokindsofframesareusedtorepresentqueuesashierarhialgraphs: Unaryitemframes ontainthegraphsstoredinthequeue;binaryqueueframes ontainaqueuegraph,whihisahainofedgesonnetingtheirbegin pointto theirend point,everynodein betweenarryinganitemframe.

Figure 1showstwo queueframes. Nodes aredrawn asirles, and lled if theyarepoints.Edgesaredrawnasboxes,andonnetedtotheirattahments

(6)

lines,andtheirontentsisdrawninside.Plainbinaryedgesaredrawnasarrows fromtheirrsttotheirseondattahment(asinsimplegraphs).Inourexamples, theirlabelsdonotmatter,andareomitted.(Intheitemgraphs,thearrowheads areomittedtoo.) Framelabelsarenotdrawneither,asqueueand itemframes anbedistinguishedbytheirarity.

Notethatitemframesmayontaingraphsofanyarity;inFigure1(b),they have1,2,andnopoints,respetively.

Unless they are expliitly named, the three omponents of a hierarhial graphH aredenoted byH,F

H

,andts H

,respetively.ThenotationsV H ,E H , att H , lab H , p H

, and A H

are used as abbreviations denoting V H , E H , att H , lab H , p H

, and A H

, respetively. Furthermore, we denote by X H

the set ff 2 F

H jts

H

(f)2Xgofvariable frames ofH andby

var(H)=ts H (X H )[ [ f2F H nX H var(ts H (f))

thesetofvariablesourringin H.

LetG and H be hierarhial graphssuh that A G

\A H

=;. Thedisjoint union of G and H is denoted by G+H and yields the hierarhialgraph K suh thatK =G+H,F

K =F

G [F

H

, and ts K

(f) equalsts G

(f) iff 2F G andts

H

(f)iff 2F H

.ForahierarhialgraphGandaset S=fH 1

;:::;H n

g ofhierarhialgraphs,wedenoteG+H

1

++H n

byG+ P

H2S

H.(Notie that,althoughthedisjointunionofhierarhialgraphsdoesnotommute,this iswelldenedasitdoesnotdependontheorderofH

1 ;:::;H

n ).

We will now generalize the onept of morphisms to the hierarhial ase. Thedenitionisquitestraightforward.Suhahierarhialmorphismh:G!H onsistsof anordinarymorphism onthetopmostleveland, reursively, hierar-hial morphisms from the ontents of non-variable frames to the ontents of theirimages.Naturally,onlyvariableframesanbemappedtovariableframes, but theyanalsobemappedtoanyotherframearryingtherightlabel.

Formally, letG;H 2 H (X). A hierarhial morphism h:G ! H is a pair h=hh;(h

f )

f2FGnXG iwhere

{ h:G!H isamorphism, { h(f)2F

H

forallframesf 2F G

,where h(f)2X H

impliesf 2X G ,and { h f :ts G

(f)!ts H

(h(f))isahierarhialmorphismforeveryf 2F G

nX G

.

Foratoms a2A G

, weusually write h(a)insteadof h(a). Furthermore,a hier-arhialmorphismh: G!H forwhihG;H 2H

0

isidentied withh.

TheompositionhÆg ofhierarhialmorphismsg:G!H andh: H !L isdenedintheobviousway.Ityieldsthehierarhialmorphisml: G!Lsuh that l=hÆg and,forallframesf 2F

G nX G ,l f =h g(f) Æg f

.Thehierarhial morphismgisinjetive ifgisinjetiveand,forallf 2F

G nX G ,g f isinjetive. It is surjetive upto variables ifg issurjetiveand,for allf 2F

(7)

alledanisomorphism,andG;H 2Haresaidtobeisomorphi,G

=H,ifthere isanisomorphismm:G!H.

Let H be the ategory whose objets are variable-free hierarhial graphs andwhosemorphismsarethehierarhialmorphismsh: G!H withG;H 2H (whih is indeed a ategory, asone aneasily verify). The main result we are goingtoestablishinordertoobtainanotionofhierarhialgraphtransformation isthatH haspushouts.Forthis,lookingattheindutivedenitionofhierarhial graphsandtheirmorphisms,itisaratherobviousideatoproeedbyindution on the depth of the frame nesting. The indution basis is then provided by the non-hierarhial ase realled in Setion 2. In order to use the indution hypothesis,wehavetoreduethedepthofahierarhialgraphinsomeway.This anbedone on thebasisof a rathersimple onstrution.Givena hierarhial graph H 2H

i

, wetakethe ontentsof its frames outof these frames (whih, thereby, beome ordinaryedges) andadd themdisjointlyto H, thus obtaining ahierarhialgraphin H

i 1

(provided that i >0). Denotingthis mappingby ',wegetthedesiredtheorem,whihisthemainresultofthissetion.Itstates that theategoryH haspushouts,and theproofshowshowto onstrutthem eetively.

Theorem1. Foreverypairm 1

:G!H 1

andm 2

:G!H 2

ofmorphisms inH therearemorphisms n

1 :H

1

!H andn 2

:H 2

!H inH (forsomehierarhial graphH)suhthat (m

1 ;m 2 ;n 1 ;n 2

)isapushout.Furthermore,(m 1 ;m 2 ;n 1 ;n 2 ) isapushout inthe ategoryof graphs.

Proofsketh. Theproofworksbyindution oni,where H 1

;H 2

2H i

.Thease i=0isthenon-hierarhialone,anditiseasytoseethateverypushoutinthe ategoryof non-hierarhial graphsand morphisms is apushout in H aswell. Thus, let i >0. Extending ' to morphisms in the anonial way, one obtains '(m

1 )=(m

0 1 :G 0 !H 0 1

) and'(m 2

)=(m 0 2 :G 0 !H 0 2

) where H 0 1 ;H 0 2 2H i 1 . By the indution hypothesis, this yields a pushout (m

0 1 ;m 0 2 ;n 0 1 ;n 0 2

) for some n 0 j : H 0 j ! H 0

(j 2 f1;2g). Now, it anbe shown that n 0 j

= '(n j

) for hierar-hial morphisms n

j :H

j

!H, yielding a ommuting square (m 1 ;m 2 ;n 1 ;n 2 ). Intuitively,thepartsofH

0

whihstemfromtheontentsofaframef inH j

an bestored in n

0 j

(f), turning this edge into aframe of thehierarhialgraphH onstruted.Themainpartoftheproofisto showthatH andthehierarhial morphismsn

j

obtainedinthiswayarewelldened.

Finally,onehastoverifytheuniversalpushoutpropertyof(m 1 ;m 2 ;n 1 ;n 2 ). Letl 1 :H 1

!Land l 2

:H 2

!Lbesuhthat (m 1 ;m 2 ;l 1 ;l 2

)ommutesandlet '(l

j ) = (l

0 j : H 0 ! L 0

) for j 2 f1;2g. Then (m 0 1 ;m 0 2 ;l 0 1 ;l 0 2

) ommutes aswell. Therefore, the pushout property of (m

0 1 ;m 0 2 ;n 0 1 ;n 0 2

) yields aunique morphism l 0 :H 0 !L 0

suhthat l 0 j =l 0 Æn 0 j

. Again,l 0

anbeturnedintol:H !L with l

0

='(l)and l j

=lÆn j

forj 2f1;2g.Furthermore,fork:H !L withk6=l wehave'(k)6='(l),whihshowsthat lisunique,bytheuniquenessofl

0 . ut

(8)

ase where m 1

and m 2

are injetive. Obviously, in this ase the hierarhial morphisms m 0 1 and m 0 2

in the proof are also injetive. As a onsequene, it

followsthat (m f 1 ;m f 2 ;n m1(f) 1 ;n m2(f) 2

)isapushout foreveryframef 2F G

.This yieldsthefollowingspeializationofTheorem1.

Corollary 1. Letm 1

:G!H 1

andm 2

:G!H 2

beinjetivehierarhial mor-phisms inH. Then,one anonstruthierarhial morphisms n

1 :H

1

!H and n

2 : H

2

!H suhthat(m 1 ;m 2 ;n 1 ;n 2

)isapushout,asfollows:

{ n 1

andn 2

aresuhthat (m 1 ;m 2 ;n 1 ;n 2

)isapushout,

{ for every frame f 2 F G , n m 1 (f) 1 and n m 2 (f) 2

are onstruted reursively in

suhaway that(m f 1 ;m f 2 ;n m 1 (f) 1 ;n m 2 (f) 2

)isapushout,and

{ forevery framef 2F Hi

nm i

(F G

)(i2f1;2g),n f i

isan isomorphism.

Next,weshallseehowpushoutomplementsanbeobtained.Forsimpliity, weonsideronlythe asewherethetwogivenhierarhialmorphismsare both injetive. This enablesus to make use of Corollary1 in an easy way, whereas themoregeneralasewouldbeunreasonablyompliated asitrequireda hier-arhialversionoftheso-alledidentiationondition[5℄.

Clearly, in order to ensure the existene of pushout omplements, a hier-arhial version of the dangling ondition must be satised. However, for the hierarhialase it must also be requiredthat, intuitively, no frameis deleted unless itsontentsisdeleted aswell.LetH

1

2H (X)and G;H 2H(right be-low,weshallonlyusethefollowingdenitionforH

1

2H ,butlateronthemore general ase H

1

2 H (X) will turn out to be valuable, too). Two hierarhial morphismsm:I !Landn:L!Gsatisfythehierarhial dangling ondition (danglingondition,forshort) if

{ mandnsatisfythe(non-hierarhial)danglingondition, { foreveryframef 2F

L n(m(F

I )[X

L ),n

f

isbijetiveuptovariables,and { foreveryframef 2F

I nX I ,m f andn m(f)

satisfythedanglingondition.

Notie that this onditionoinides with the usual one in the speial ase wheremandnareordinarygraphmorphisms,beauseinthisaseonlytherst requirement is relevant asthere are no frames. Intuitively, the seond part of theonditionstatesthat,asmentionedabove,aframeanbedeletedonlyifits ontentsisdeleted aswell (atleastin theasewhere L2H ;themoregeneral aseisnotyetouronern).Astheproofbelowshows,thisorrespondstothe lastitemin Corollary1(andisthusindeed neessary).

Theorem2. Let m 1

: G ! H 1

and n 1

: H 1

! H be injetive hierarhial morphisms in H. Then there are hierarhial morphisms m

2

: G ! H 2 and n 2 : H 2

!H suhthat (m 1 ;m 2 ;n 1 ;n 2

) isa pushout,if and only if m 1

andn 1 satisfy the danglingondition. Inthis asem

2 andn

2

areuniquelydetermined.

Proof. LetG2H i

. Again,weproeedbyindution oni.Clearly,ifm 2

andn 2 exist,thenm

2

mustbeinjetivesinen 1 Æm 1 =n 2 Æm 2

isinjetive.ByCorollary1 thismeans thatm

2 and n

2

(9)

2 2 1 2 1 2

(2) for every frame f 2 F G

, the hierarhial morphisms m f 2

and n m2(f) 2

are

onstrutedreursively,sothat(m f 1

;m f 2

;n m1(f) 1

;n m2(f) 2

)isapushout,and

(3) foreveryframef 2F Hi

nm i

(F G

)(i2f1;2g),n f i

isanisomorphism.

Asm 1

andn 1

satisfythedanglingondition,m 2

andn 2

existandareuniquely determined(sinem

1 andn

1

satisfythedanglingonditionfornon-hierarhial morphisms), and (3) is satised for i = 1 (beause of the seond part of the danglingondition).Furthermore,theindution hypothesisyields therequired

hierarhialmorphisms m f 2

and n m

2 (f) 2

satisfying (2), forevery framef 2F G

. Togetherwiththeremainingrequirementin (3)(i.e.,theasewherei=2) this determinesm

2 andn

2

uptoisomorphism,thus nishingtheproof. ut

4 Hierarhial Graph Transformation

Basedontheresultspresentedintheprevioussetionwearenowabletodene rules and their appliation in thestyleof thedouble-pushout approah. From

nowon,arulet: L l

I r

!Risassumedtoonsistoftwohierarhialmorphisms l:I !L andr: I !R ,where L;I;R 2Hand lis injetive.The hierarhial graphsL, I, andRarealledtheleft-handside, interfae,andright-hand side.

The appliation of rules is dened by means of the usual double-pushout onstrution,withoneessentialdierene. Inorder tomakesurethat transfor-mationsan takeplae onanarbitrarylevelin the hierarhyof frames(rather thanonlyontoplevel)onehastoemployreursion.

Denition1 (Transformation of hierarhial graphs).Lett: L l

I r !R bearule.A hierarhialgraphG2Histransformedinto ahierarhialgraph H 2Hbymeansoft,denotedbyG)

t

H,ifoneofthefollowingholds:

(1) Thereisaninjetivehierarhialmorphismo: L!G,alled anourrene morphism,suh thattherearetwopushouts

L I R

G K H

l

r

o

inH, or

(2) H =

G via some isomorphismm: G ! H, and there is a frame f 2 F G suh that ts

G (f))

t ts

H

(m(f)) andts H

(m(f 0

)) =ts

G (f

0

) forall f 0

2 F

G nffg.

(10)

0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 !

0

5 1

6 2

7 3

8 4

9

# # #

onat

dequeue dequeue

!

dequeue

Fig.2.Theonatenationruleanditsappliation

Example 2 (Conatenationofqueues).InFigure2,weshowaonatenationrule forqueuesthatidentiestwoqueueframesandonatenatestheirontents,and atransformationwiththisrule.Thedigitsintheruleindiatehowthenodesof thegraphshavetobemappedontoeahother.

Itshould benotied that thedenitionof transformationstepsrequires o-urrene morphisms to be injetive. Therefore, we need three variants of this rulewherenode1isidentiedwithnode2,or7with8,orboth1with2and7 with8.(Similarvariantsareneededfortherulesinthesubsequentexamples.)

Sineourrenemorphismsareinjetive,wegetthefollowingtheoremasa onsequeneofTheorems 1and2.

Theorem 3. Lett:L l

I r

!R bearule, G2H , ando:L!Gan ourrene morphism.ThenthetwopushoutsinDenition1(1)existifandonlyifosatises the dangling ondition.

1

Furthermore, in this ase the pushouts are uniquely determineduptoisomorphism.

Proof. ByTheorem2thepushout ontheleft existsifand onlyifthedangling ondition is satised,and ifit exists then itis uniquely determined upto iso-morphism.Finally,byTheorem1thepushout ontherightalwaysexists,andit isageneralfat knownfrom ategorytheorythatapushout(m

1 ;m

2 ;n

1 ;n

2 )is uniquelydetermined(uptoisomorphism) bythemorphismsm

1 andm

2 . ut

Thereadershould also notie that, asaonsequeneofthe eetiveness of the results presented in Setion 3, given a tranformation rule, a hierarhial graph,and anourrenemorphismsatisfying thedanglingondition,onean eetivelyonstruttherequiredpushouts.

1

If the rule t:L l

I r

(11)

expressiveenough to be satisfatoryfor ertain programmingpurposes. There aresomenaturaleetsthatonewouldertainlyliketobeabletoimplementas single transformationsteps, but whih annot be expressed by rules.Consider theexampleofqueues,forinstane.Itshouldbepossibletodesignaruledequeue whihremovestherstiteminaqueue,regardlessofitsontents.However,this is not possible asthe dangling onditionrequires theourrene morphism to bebijetiveontheontentsofdeleted frames.Conversely,anotherruleenqueue should take an item frame, again regardlessof its ontents,and add it to the queue|preferablywithoutaetingtheoriginalitem frame. Inorder to imple-ment this, onehas to irumvent twoobstales. First, hierarhialmorphisms preservetheframehierarhy,whihimpliesthat, intuitively,rulesannotmove frames aross frame boundaries. Seond, by now it is simply not possible to dupliateframestogetherwiththeirontents.

Thisis wherevariables startto playanimportantrole. Theideais to turn from rules to rule shemata and to transform hierarhialgraphs by applying instanesoftheseruleshemata.Inordertomakesurethatanourrene mor-phismsatisfyingthedanglingonditionalwaysyieldsawell-dened transforma-tion, we restritourselvesto left-linearrule shemata. Forthis, a hierarhial graphH isalled linear ifnovariable ours twiein H.

A variable instantiation for H 2H (X) is amapping:var(H) !H . The appliationoftoH isdenotedbyH.Itturnseveryvariableframef 2X

H into aframewhoseontentsis (ts

H

(f)).Bythedenitionofhierarhialmorphisms, foreveryhierarhialmorphismh:G!H suhthat G2Handeveryvariable instantiation for H, han aswell beunderstood as ahierarhialmorphism fromGtoH .Inthefollowing,thishierarhialmorphismwillbedenotedbyh. Basedonthisobservation,rule shemataandtheirappliation anbedened.

Denition2 (Transformationbyruleshemata).Aruleshema,denoted

by t: L l

I r

!R , is apair onsisting of hierarhialmorphisms l:I ! L and r:I !R ,whereL;R2H (X), I 2H ,Lis linear,and var(R )var(L). Ifis

avariableinstantiationforLthentherulet 0

: L l

I r

!R isaninstane oft. A rule shema t transforms G 2 H into H 2 H , denoted by G V

t H, if G )

t 0

H for some instane t 0

of t. For a set T of rule shemata we write GV

T

H ifGV t

H forsomet2T.

Example 3 (The rule shemata enqueue and dequeue). In Figure 3, we show a rule shema that inserts a framed item graph at the tail of a queue graph, and a transformation with that rule. Theitem frame ontains the variable x. Otherwise,itwouldnotbepossibletodupliatetheitemgraph,andtomoveit intothequeueframe.

InFigure 4, we show arule shema that removesthe rstitem frame in a queue graph. The item graph is denoted by the variable x so that it an be removedentirely.

(12)

x

!

x x

# # #

enqueue

dequeue dequeue

!

dequeue

Fig.3.Theruleshemaenqueueanditsappliation

dequeue

x

1 1

!

1

Fig.4.Theruleshemadequeue

variable. Therefore, the naive approah to implement V t

by onstruting all its instanes and then testing eah of them for appliability does not work. However,thereisquiteanobviouswayhowoneandobetterthanthat.Consider somelinearhierarhialgraphL2H (X) andahierarhialgraphG2H , and let o: L ! G be a hierarhialmorphism. Then, due to the linearity of L, o indues avariable instantiation

o

:var(L) ! Hand an ourrene morphism inst(o):L

o

!G,asfollows.Forallx 2var(L), ifthere issomef 2X L

suh that ts

L

(f) = x then o

(x) = ts G

(o(f)). Otherwise, o

(x) = o

f(x), where f 2 F

L nX

L

is the unique frame suh that x 2 var(ts L

(f)). Furthermore,

inst(o)=oandforallf 2F L

,inst(o) f

istheidentityonts G

(o(f))iff 2X L andinst(o)

f

=inst(o f

)otherwise.

Thetheorem below statesthat the transformationsgiven byarule shema

t: L l

I r

!R an beobtainedby onsideringourrenemorphisms o: L!G that satisfythedanglingondition.

Theorem 4. Lett:L l

I r

!R bearuleshema andG2H .

1. If o: L ! G is an ourrene morphism satisfying the dangling ondition, theninst(o) isanourrenemorphism for L

o

(13)

on-morphism satisfying the dangling ondition, then = o

and q = inst(o) (uptoisomorphism) forsomeourrenemorphismo: L!Gsatisfyingthe danglingondition.

Theproofbyindutiononi,whereL2H i

(X),isratherstraightforwardand isthereforeskippedinthisshort version.

5 Flattening

A natural operation on hierarhial graphs is the attening operation whih removes the hierarhy by reursively replaing every frame with its ontents. Forthis,weusethewell-knownoneptofhyperedgereplaement(see[9,4℄)in aslightlygeneralizedform.Flatteningissimilar to (a reursiveversionof)the operation'onsideredinSetion3,butitremovesallframesandidentiestheir attahed nodeswiththeorrespondingpointsoftheirontents.If thenumbers ofattahednodesandpointsdier,theadditionalnodesofthelongersequene aretreatedlikeordinarynodes.Inaddition, atteningforgetsaboutthepoints ofitsargument,sothat theresultinggraphis \unpointed".

Itwillbeshowninthissetionthat,undermodestassumptions,hierarhial graphtransformationisompatiblewiththeatteningoperation:A transforma-tionG)

t

H induesaorrespondingtransformationG 0

) t

0 H

0

,whereG 0

,H 0

, andt

0

aretheattened versionsofG,H,andt,respetively.

Inordertoproeed,werstneedtodenehyperedgereplaementon hierar-hialgraphs.LetH beahierarhialgraphandonsideramapping:E!H suhthatEE

H

,alledahyperedgesubstitutionforH.Hyperedgereplaement yieldsthehierarhialgraphH[℄obtainedfromH+

P e2E

(e)bydeletingthe edges in E and identifying, forall e2E, theith node ofatt

H

(e) withthe ith pointofp

(e)

,foralli suhthat boththesenodesexist. Finally, forall H 2H ,let(H)=H[℄where :F H

! His given indu-tivelyby(f)=(ts

H

(f))forallf 2F H

.Then,theatteningofH yieldsthe graphat(H)=hV

(H) ;E

(H) ;att

(H) ;lab

(H)

;i.Formostof the onsidera-tionsbelow,itissuÆienttostudythemapping,whihremovesthehierarhy withoutforgettingpoints,insteadofat.

Weanattenmorphismsaswell.Considerahierarhialmorphismh:G! H with G;H 2 H and let = Æts

G

and = Æts H

. Then, (h) is the morphism m: (G) ! (H) dened indutively, as follows. For all a 2 A

(G)

, if a 2 A G

then m(a) = h(a), and if a 2 A (f)

for some f 2 F G

then

m(a)= (h f

)(a). Furthermore,at(h) =(m 0

:at(G) !at(H))is givenby m

0

(a) = m(a)for alla 2A at(G)

. (Notiethat, although the two asesin the denition ofm(a)aboveinterset,theyareonsistentwitheahother.)

(14)

the attahed nodes of the frame aredistint, hyperedge replaementidenties them(byidentifyingeahwiththesamepointoftheontents).Thus,attening may turn an ourrene morphism into a non-injetive morphism, making it impossibletoapplytheorrespondingattenedrule.Infat,thedualsituation where there are idential attahed nodes of a frame while the orresponding points ofitsontentsaredistint, mustalso beavoided. Thereasonliesin the reursivepartofthedenitionof)

t

.Ifaruleisappliedtotheontentsofsome frame, but the replaement of the frame identies two distint points of the ontentsbeausethe orrespondingattahed points of theframe are idential, theattenedruleannotbeapplied either.

For this, all ahierarhialgraph H 2 H identiation onsistent ifevery framef 2F

H

satisesthefollowing:

(1) Foralli;j2[min(jatt H

(f)j; p

ts H

(f)

)℄,att H

(f)(i)=att H

(f)(j)ifandonly ifp

ts H

(f) (i)=p

ts H

(f)

(j),and (2) ts

H

(f)isidentiationonsistent.

The reader ought to notie that identiation onsisteny is preserved by

the appliation ofa rulet: L l

I r

!R ifR is identiation onsistentand r is injetive.Thus, if werestrit ourselvesto systemswith rules ofthis kind then allderivablehierarhialgraphsareidentiation onsistent(provided thatthe initialones are).

ItisnotverydiÆulttoverifythefollowingtwolemmas.

Lemma1. For every injetive hierarhial morphism h:G !H (G;H 2 H ) suhthat H isidentiation onsistent,(h) isinjetive.

Lemma2. If (m 1

;m 2

;n 1

;n 2

) is a pushout in H, then (at(m 1

);at(m 2

); at(n

1

);at(n 2

))isapushoutas well.

Asaonsequene,oneobtainsthemaintheoremofthissetion:Ifarulean beapplied toanidentiation onsistenthierarhialgraph,then theattened rulean beappliedtotheattenedgraph,withtheexpetedresult.

Theorem5. Let t: L l

I r

!R be a rule and let t 0

: L 0

l 0

I 0

r 0 !R

0

be the rule given by l

0

=at(l) and r 0

=at(r). For every transformation G) t

H suh thatGisidentiationonsistent,thereisatransformationat(G))

t 0

at(H).

Proofsketh. ConsideratransformationstepG) t

H.Due tothedenition of )

t

(15)

turalinformationsothatthereisnohanetoprovetheonverseofthetheorem.

6 Conlusion

We onludethis paper by briey mentioningsome related work and possible diretionsforfuture researh.

Pratt[15℄wasprobablythersttoonsideraoneptofhierarhialgraph transformation,where heusedaertainkindofnodereplaementtodenethe semantis of programming languages. His graph onept was extended in [6℄ byallowingedgesbetweensubgraphsontainedin dierentnodes, butwithout dening transformation.

Adierentoneptofgraphnestingisgivenbytheabstrationmehanisms of the (old) graph transformation system Agg [12℄ and the multi-level graph grammarsof[13℄, providingatgraphswith severalviewswhiharerelatedby arigidlayeringandapartialinlusion ordering,respetively.

Anindiretnestingoneptanbefoundintheframeworkof[16℄andthenew Aggsystem[7℄,where nestingisrealizedbylabelsandattributes, respetively. The idea of using variables to extend the double-pushout approah with non-loal eets, likeopyingandremovalof subgraphs,is alsofollowedin the so-alledsubstitution-basedapproahtographtransformation[14℄(workingon athypergraphs).

Onediretion forfutureworkonhierarhialgraphtransformationistolift to thehierarhialsetting thelassialresultsofthe double-pushoutapproah, like sequential and parallel ommutativity, resultson parallelism, onurreny andamalgamation,et.Anotherimportanttaskistoombinehierarhialgraph transformationinanorthogonalwaywithoneptsforstruturingand ontrol-ling systems of rules. As mentionedin the introdution, several suh onepts (mainlyforatgraphs)havereentlybeenproposedintheliterature.

A further topi of researh is to develophierarhial graphtransformation towardsobjet-orientedgraphtransformation,asoutlinedin[11℄.Theretheidea istorestritthevisibilityofframessothatonlyrulesdesignatedtosomeframe typemayinspetorupdatetheontentsofframesofthistype.Suhframetypes ome lose to\lasses", and thedesignated rulesorrespondto \methods".In thiswayframesanbeseenasobjetsoftheirtypesthatanonlybemanipulated byinvoking themethods ofthelass.

Aknowledgement Wethanktherefereesfortheirhelpfulomments.

Referenes

[1℄ J.Adamek,H.Herrlih,andG.Streker.AbstratandConreteCategories. John Wiley,New York,1990.

(16)

approahestographtransformation|PartI:Basioneptsanddoublepushout approah.InG.Rozenberg,editor,HandbookofGraphGrammarsandComputing byGraph Transformation, volume1,hapter 3,pages163{245.WorldSienti, 1997.

[4℄ F.Drewes, A.Habel, andH.-J.Kreowski. Hyperedge replaement graph gram-mars. InG. Rozenberg, editor, Handbook of Graph Grammars and Computing by Graph Transformation, volume 1,hapter 2,pages 95{162. World Sienti, Singapore,1997.

[5℄ H.Ehrig.Introdutiontothealgebraitheoryofgraphgrammars.InPro. Graph-GrammarsandTheirAppliationtoComputerSieneandBiology,volume73of LetureNotesinComputerSiene,pages1{69.Springer-Verlag,1979.

[6℄ G. Engels and A. Shurr. Enapsulated hierahial graphs, graph types, and meta types. InA. Corradini and U. Montanari, editors, Pro. Joint COMPU-GRAPH/SEMAGRAPH Workshop on Graph Rewriting and Computation, vol-ume2ofEletroniNotesinTheoretialComputerSiene.Elsevier,1995. [7℄ C. Ermel,M. Rudolf, and G. Taentzer. The agg approah: Languageand

en-vironment. InH. Ehrig,G.Engels, H.-J.Kreowski, and G.Rozenberg,editors, Handbook of Graph Grammars and Computing by Graph Transformation, vol-ume2,pages551{603.WorldSienti,1999.

[8℄ P.FradetandD.L.Metayer. StruturedGamma.SieneofComputer Program-ming,31(2/3):263{289, 1998.

[9℄ A. Habel. Hyperedge Replaement: Grammars and Languages, volume 643 of LetureNotesinComputerSiene. Springer-Verlag,Berlin,1992.

[10℄ R.Hekel,H. Ehrig,and G.Taentzer. Classiationand omparisonof module onepts for graph transformation systems. InH. Ehrig, G.Engels, H.-J. Kre-owski,andG.Rozenberg,editors,HandbookofGraphGrammarsandComputing byGraphTransformation,volume2,hapter17,pages669{689.WorldSienti, 1999.

[11℄ B. Homann. Fromgraphtransformation to rule-basedprogrammingwith dia-grams. InM.NaglandA.Shurr,editors, Pro.Int'lWorkshoponAppliations ofGraphTransformationswithIndustrialRelevane (Agtive'99),LetureNotes inComputerSiene,1999. Toappear.

[12℄ M.LoweandM.Beyer. AGG|animplementationofalgebraigraphrewriting. InC.Kirhner,editor,Pro.Rewriting TehniquesandAppliations,volume690 ofLeture NotesinComputerSiene,pages451{456,1993.

[13℄ F.Parisi-PresieandG.Piersanti. Multi-levelgraphgrammars.InE.W.Mayr, G.Shmidt, andG.Tinhofer, editors, Graph-Theoretial Conepts in Computer Siene(WG'94),volume903ofLetureNotesinComputerSiene,pages51{64, 1995.

[14℄ D.PlumpandA.Habel.Graphuniationandmathing.InPro.Graph Gram-marsandTheir AppliationtoComputer Siene,volume1073ofLeture Notes inComputerSiene,pages75{89.Springer-Verlag,1996.

[15℄ T.W.Pratt. Pairgrammars,graphlanguages andstring-to-graphtranslations. JournalofComputerandSystemSienes,5:560{595,1971.

References

Related documents

CSD will review complaints from homeowners who have had rehabilitation work performed under the Harris County Home Repair Program. A determination will be made by HCIS whether

In particular the French Rugby Federation and the Argentinian Rugby Association want to see what designs you can create for their new Home and Away kits for the upcoming World

As stated in the NRC Strategic Plan, “Timely, high-quality information is critical to the achievement of the NRC’s safety and security mission.” Without fully supported and

It is based on local mesh modifications and an anisotropic version of Delaunay kernel for vertex insertion and, starting from a given tetrahedral mesh, it produces a

– Acid activation forms chlorine dioxide in batch Acid activation forms chlorine dioxide in

Development of robotic instruments for bone removal will definitely improve the application of the surgical robot in fields like spine surgery and anterior skull base surgery,

You are invited to attend a launch event to mark the closer working relationship with the Walton Centre and to update people on the new services that Neurosupport are now able to

The System Security Awareness for Transit Employees course is designed for front-line employees and supervisors who have direct contact with the public or the vehicles and