• No results found

Volume 2: Petri Nets and Graph Transformations

N/A
N/A
Protected

Academic year: 2020

Share "Volume 2: Petri Nets and Graph Transformations"

Copied!
20
0
0

Loading.... (view fulltext now)

Full text

(1)

Proceedings of the

Workshop on Petri Nets and Graph Transformation

(PNGT 2006)

Event Structure Semantics for Dynamic Graph Grammars

Roberto Bruni, Hern´an Melgratti, and Ugo Montanari

19 pages

Guest Editors: Paolo Baldan, Hartmut Ehrig, Julia Padberg, Grzegorz Rozenberg Managing Editors: Tiziana Margaria, Julia Padberg, Gabriele Taentzer

(2)

Event Structure Semantics for Dynamic Graph Grammars

Roberto Bruni1, Hern´an Melgratti2, and Ugo Montanari1

1Dipartimento di Informatica, Universit`a di Pisa, Italia

2IMT Lucca Institute for Advance Studies, Italia.

Abstract: Dynamic graph grammars (DGGs) are a reflexive extension of Graph

Grammars that have been introduced to represent mobile reflexive systems and cal-culi at a convenient level of abstraction. Persistent graph grammars (PGGs) are a class of graph grammars that admits a fully satisfactory concurrent semantics thanks to the fact that all so-called asymmetric conflicts (between items that are read by some productions and consumed by other) are avoided. In this paper we introduce a slight variant of DGGs, calledpersistent dynamic graph grammars(PDGGs), that can be encoded in PGGs preserving concurrency. Finally, PDGGs are exploited to define a concurrent semantics for theJoincalculus enriched with persistent messag-ing (if preferred, the latter can be naively seen as dynamic nets with read arcs).

Keywords:Dynamic graph grammars, Event structures, Join calculus

1

Introduction

Petri nets and Graph Transformation Systems (GTSs) are two well-known models for concurrent systems. Petri nets, conceptually simpler, had became a reference model for experimenting with and developing new semantic approaches to concurrency, notably nonsequential processes, un-folding constructions, event structures and algebraic models. GTSs provide a more sophisticated and expressive framework for handling resource types, distribution, access control.

The close analogy between the two models neatly emerges when viewing Petri nets as par-ticular GTSs over discrete typed graphs: places form the nodes of the type graph, markings are typed graphs (whose nodes model tokens) and transitions are productions. This correspondence has facilitated the mutual transfer of concepts and techniques, like the development of process and unfolding semantics for GTSs obtained in [Bal00] by extending the chain of coreflections defined for Petri nets [NPW81] to graph grammars. However, general Double Pushout (DPO) grammars require a much more sophisticated notion of events, calledinhibitor event structures and the adjunction between unfolding and event structures breaks down to a functorial construc-tionEg in just one direction. A recent result [BCMR07] re-established the missing link for the

Single Pushout (SPO) approach, by defining an adjunction NsaEs between the category of

semi-weighted SPO occurrence grammars and the category of the so-calledasymmetric event structures. The category of prime algebraic domains is equivalent to the category of prime event structures (PES), thus all constructions can ultimately lead to PES, that offers a reference deno-tational model of true concurrency. This is summarized in the three upper rows of Figure1.

(3)

Safe Nets

U

//Occurrence

Nets

E

//

? _

o

o Prime Event

Structures L

//

N

o

o Domains

[NPW81] P

o

o

SW DPO Graph Grammars

Ug

//SW Occurrence

Grammars Eg

/

/

? _

o

o Inhibitor Event

Structures

Li

//Domains

[Bal00] Pi

o

o

SW SPO Graph Grammars

Us

//SW Occurrence

Grammars Es

//

? _

o

o Asymmetric Event

Structures

La

//

Ns

o

o Domains

[BCMR07] Pa

o

o

Persistent Graph Grammars

Up

//

Persistent Occurrence

Grammars Ep

//

? _

o

o Prime Event

Structures L

//

Np

o

o Domains

[BMM06] P

o

o

Figure 1: A recollection of event structure semantics.

concurrent constraint programming, and asynchronous systems. The second accounts for dy-namic changes in the topology of the net, like deploying new places and transitions, that can occur in highly dynamic environments like global computing. In the literature, Petri net seman-tics have been extended to cope with read arcs, while the mobile extension has not received yet a fully satisfactory assessment (some preliminary investigation is in [BM06b]).

Exploiting the analogy between nets and GTSs, here we first introduce persistent dynamic

graph grammars(PDGGs) as a suitable generalization of mobile nets with read arcs by

combin-ingdynamic graph grammars(DGGs) [BM06a] andpersistent productions[BMM06]. Then we

are able to equip PDGGs with a nice event structure semantics by exploiting: (i) the encoding of DGG in ordinary graph grammars given in [BM06a] and (ii) the coreflective event structure semantics forpersistent graph grammars(PGGs) given in [BMM06]). In DGGs, the applica-tion of a producapplica-tion can release fresh types and fresh producapplica-tions. The encoding in [BM06a] enriches configurations with additional run-time typing information for the dynamically gener-ated structure. We slightly refine it so to map PDGGs to PGGs and then show that it preserves concurrency. The main theorem of [BMM06] has shown that the construction of the prime event structure associated to a PGG is expressed by a chain of coreflections (see the bottom row in

Fig-ure1), and since PGGs are node preserving, the constructions under DPO and SPO approaches

coincide. By combining all results, we obtain a concurrent semantics for PDGGs.

As a case study we present a version of the Join calculus with persistent messages, which emerges as a rather elegant way of combining nets, read arcs, and mobility in a process calculus. In fact, it is well-known that dynamic nets are in one-to-one correspondence with processes of theJoincalculus [BS01], and we propose persistent messages as a disciplined mean to introduce reading primitives for multiple concurrent accesses to resources.

Structure of the paper:Section2recalls some important preliminaries about persistent graph

(4)

L

p:

m

(1)

K

l

o

o r //

k

(2)

R

h

G D

b

o

o

d //H

Figure 2: A DPO direct derivation.

2

Background

2.1 Persistent Graph Grammars

A(directed) graphis a tupleG=hNG,EG,sG,tGi, whereNGis a set ofnodes,EGis a set ofedges

(orarcs), andsG,tG:EG→NGare thesourceandtargetfunctions. We shall omit subscripts when

obvious from the context. Agraph morphism f :G→G0is a couple f=hfN:N→N0,fE :E→

E0isuch that:s0◦fE = fN◦sandt0◦fE = fN◦t.

Given a graph of types T, a T -typed graphis a pair h|G|,τGi, where |G|is the underlying

graph andτG:|G| →T is a total morphism. AmorphismbetweenT-typed graphs f:G1→G2 is a graph morphisms f :|G1| → |G2|such thatτG1 =τG2◦f. The category ofT-typed graphs

and their morphisms is denoted byT-Graph. Since we work only with typed notions, we will usually omit the qualification “typed”, and we will not indicate explicitly the typing morphisms. In GGs the graph|G|defines the configuration of the system and its items (nodes and edges) model resources, whileτGdefines thetypingof the resources. Hence, the underlying graph|G|

evolves dynamically, while the type graphT is statically fixed and cannot change at run-time. The key notion togluegraphs together is that of a categorical pushout. Roughly, a pushout pastes two graphs by injecting them in a larger graph that is (isomorphic to) their disjoint union modulo the collapsing of some common part. We recall that aspanis a pair(b,c)of morphisms

b:A→Bandc:A→C. A pushout of the span(b,c) is then an objectDtogether with two

(co-final) morphisms f :B→Dandg:C→Dsuch that: (i) f◦b=g◦cand (ii) for any other choice of f0:B→D0andg0:C→D0s.t. f0◦b=g0◦cthere is a uniqued:D→D0s.t. f0=d◦f

andg0=d◦g. If the pushout is defined, thencandgform thepushout complementofhb,fi.

Definition 1(DPO graph grammar) A(T -typed graph) DPO production p:(L←l K→r R)is a

span of injective graph morphismsl:K→Landr:K→R. TheT-typed graphsL,K, andRare called theleft-hand side, theinterface, and the right-hand sideof the production, respectively. The production is calledconsumingif the morphisml:K→Lis not surjective.

A(T -typed) DPO graph grammar Gis a tuplehT,Gin,Pi, whereGin is theinitial (T -typed)

graph,Pis a set of DPOproductions.

Given a graphG, a production p:(L←l K→r R), and amatch m:L→G, adirect derivation

δfrom G to H using p (based on m)exists, written δ:G⇒pH, if and only if the diagram in

(5)

H(as a pushout of(k,r)). The interfaceKspecifies both what is preserved and how fresh items must be glued to the existing part. The existence of the pushout complement ofhm,liis subject to the satisfaction of the followinggluing conditions[CMR+97]:

• identification condition:∀x,y∈Lifx6=yandm(x) =m(y)thenx,y∈l(K);

• dangling condition:no arc inG\m(L)should be incident to a node inm(L\l(K)).

The identification condition is satisfied byvalid matches: a match is not valid if it requires a single item to be consumed twice, or to be both consumed and preserved.

Aderivationis a sequenceγ={δi:Gi−1⇒pi−1 Gi}i∈{1,...,n}of direct derivations.

In what follows we will focus on semi-weighted GGs that enforce disambiguation in the se-mantics by preventing the generation of “equivalent” resources carrying the same history. A graph grammarG=hT,Gin,Piissemi-weightedifGinis injectively typed and the target of every

productionp∈Pis injective.

In [BMM06], we have introduced a particular class of Graph Grammars, called Persistent

Graph Grammars(PGGs), which allow us to obtain a PES via a chain of coreflections. The

remaining of this section is devoted to summarise PGGs and their event structure semantics. A type graphT ispersistentif its edges are partitioned in two subsets:ET+of persistent edges andET− of removable edges. In the following we assume a persistent type graph T is given. Given a T-typed graph G, we denote by EG+ andEG− the set of edges mapped respectively to persistent edges and to removable edges ofT.

Definition 2(Persistent graph grammar) A productionp:(L←l K→r R)ispersistentif:

• node persistence: NL=l(NK)(i.e., nodes are never deleted);

• removal of removable arcs: EK−=0/ (i.e., all matched removable arcs are deleted);

• preservation of persistent arcs: EL+=l(EK+)(i.e., all persistent arcs are preserved).

A(T -typed, DPO) graph grammarGispersistentif all its productions are consuming,

semi-weighted and persistent.

Theorem 1 (cfr. [BMM06])The construction of the prime event structure associated to a

per-sistent graph grammar is expressed by the chain of coreflections in the bottom row of Figure1.

Remark1 The Single Pushout approach (SPO) offers an alternative to DPO. A (T-typed) SPO

productionis an injective partial graph morphismq:LR(without loss of generality, assume thatq is just the partial inclusionL∩R⊆R). The key difference w.r.t. the DPO approach is that in SPO there is no dangling condition preventing a rule to be applied: when a node is deleted by the application of a rule, then all dangling edges are also deleted as some kind of side-effect. However, in the special case of node preserving rules, the effect of SPO and DPO is very close: there is an isomorphism between SPO and DPO node preserving grammars that maps each productionq:LRto pq:(L←-dom(q),→R). The isomorphism makes the PES

(6)

Remark2 For PGGs, the identification condition reduces to require the matching to be injective over removable arcs.

2.2 Dynamic Graph Grammars

In this section we describeDynamic Graph Grammars(DGGs) and their encoding into graph grammars as presented in [BM06a]. DGGs are graph grammars that dynamically modifies their graph of types and their set of productions. A T-typed dynamic production takes the form:

p:(LT

l

←KT

r

→GT0)where GT0 is a suitable (T0-typed) dynamic graph grammar. A dynamic

graph grammar can contain any number of such productions. In order to provide the formal definition we need the following notion of graph retyping.

Definition 3(Graph Retyping) Given aT-typed graphG=h|G|,τGiand a morphismσ:T →

T0we denote byσ·GtheT0-typed graphσ·G=h|G|,σ◦τGi.

The set of DGGs is formally defined as follows:

Definition 4 (Dynamic Graph Grammars) The domain of dynamic graph grammars can be

expressed as the least setDGGsatisfying the equation:

DGG={(T,Gin,P) | Gin∈GraphT∧

∀p:(LT l

←KT

r

→GTp)∈P.(LT,KT ∈GraphT ∧T⊂Tp∧GTp= (Tp,GTp,Pp)∈DGG)}

whereGraphT is the set ofT-typed graphs andr:ι·KT→GTp is a morphism betweenTp-typed

graphs, whereι:T ,→Tpdenotes the obvious sub-graph injection.

Any elementG= (T,Gin,P)∈DGGis called adynamic graph grammar.

WhenP=0/, then the grammar is roughly aT-typed graph, which is statically fixed and cannot

change. Such grammars are calledstatic. A productionpisstaticif its right-hand sideGTp is a

static grammar andTp=T. If all productions are static, then the grammar is calledshallowand

is essentially an ordinary GGs: the application of any production can neither change the type graph nor spawn new rules.

Example1 Figures3and4introduce a small dynamic graph grammar. LetTabe the singleton

type graph with just one nodea. LetTg⊃Taconsisting of nodesaandband two edges f:a→b,

andg:b→b.

Take the Ta-typed dynamic grammar Ga with the dynamic production p in Figure 3. For

simplicity, we take the inclusions as legs of the span and draw the typing (dotted lines) only once for each item. The left-hand side of pconsists of aTa-typed graph with just one noden1,

which is preserved by the context, and the right-hand side spawns a shallowTg-typed grammar

Gpwhose initial graph has, beside n1, one additional noden2 and one arch. The grammarGp

itself has just one static productionq∈Pp, illustrated in Figure4: the left-hand side is a graph

with three nodesm0andm1,m2, which are all preserved, and two arcsh1,h2, which are deleted, and the right-hand side spawns the staticTg-typed grammarGq(i.e., a graph) with one additional

(7)

)

)

p: n1 ←- n•1 ,→ n•1 h //•

n2

Pp={q}

• f vv //

a

Ta

Tg g

e

e

b

Figure 3: A dynamic productionp.

'

'

m1 •m1 •m1

'

'

h1rrr88

r r r

h2 //

q: m0 •

*

*

m2 ←- m0• •m2 ,→ m0• •

l

O

O

m2

Pq=0/

• &&** f //

a

Tg g

e

e ww

b

Figure 4: A static productionq.

The dynamics of DGGs relies on a notion of retyping, which can be used to generate fresh items in the type graph. In the following, when considering type graph constructions, we assume that a standard choice of pushout objects satisfying the following requirements is available: Let T ⊂T00andσ:T →T0 injective, then we denote by Tσ,T00 the pushout object of the inclusion

ι:T ,→ T00 and σ such that T0 embeds in Tσ,T00 via set-theoretical inclusion ισ,T00, while T00

embeds via an injectionρσ,T00 (see Figure5(a)) that renames items inT00\T with fresh names.

Whenσis the inclusionT ⊆T0we replace the subscripting(−)σ,T00 with(−)T0,T00.

Definition 5(Fresh Graph Retyping) LetT ⊂T00. Given aT00-typed graphG=h|G|,τGiand

an injectionσ:T →T0 we letσ·G=h|G|,ρσ,T00◦τGi.

Definition 6(Dynamic Retyping) Given aT-typed DGGG= (T,Gin,P)and an injective

mor-phism σ:T → T0 we denote by σ·G the T0-typed grammar defined recursively by letting

σ·G= (T0,σ·Gin,σ·P), withσ·P={σ·p|p∈P}whereσ·p:(σ·LT l ←σ·KT

r

→ρσ,Tp·GTp)for

any p:(LT l

←KT

r

→GTp). (Note thatρσ,Tp·GTp is aTσ,Tp-typed grammar andσ·pis aT

0-typed

production.)

In DGGs, productions are nested inside (the right-hand sides of) other productions, but only top-level productions can be applied, by finding a matching of their left-hand sides into the initial graph. When such a production pis applied, then fresh instances of the productionsPp,

nested one level belowp, become available at the top-level, and can be unwound themselves in successive steps. Given a DGGG= (T,Gin,P), a production p:(LT

l

←KT

r

→GTp)∈Pwith

GTp = (Tp,GTp,Pp), and a matchingm:LT→Ginthat satisfies the gluing conditions, we proceed

(8)

T

σ

 ι //

T00

ρσ,T00

T0  ι

σ,T00

/

/Tσ,T00

(a) Type construction.

LT m " "

ιT,Tp·p: KT l o o } } k o

o _ __ _ _ _//

_ K0

k0

r0 //

G0p

{

{ h

G0

p=ρT,Tp·GTp= (TT,Tp,G

0

p,P0)

T

idT

 ιp //

Tp

ρT,Tp

T  ι

T,Tp

/

/TT,Tp

Gin

<

<

G= (T,Gin,P)

D b o o b b o o ≡ _ _ _// _ _ _

_ D0

d

d

d //H

i

i

G0= (T

T,Tp,H,P

0

ιT,Tp·P)

(b) A direct dynamic derivation.

Figure 5: The dynamics of DGGs

• We build the pushout complement ofhm,li, obtaining aT-typed graphDwith morphisms

k:KT→Dandb:D→Gin.

• We build the standard type graphTT,Tp associated withσ=idT :T →T andιp:T ,→Tp.

Note thatιT,Tp=ρT,Tp◦ιp. Fresh items of the underlying graph produced by the application

ofpmust be typed overTT,Tp.

• We build the retyped graphs D0 =ιT,Tp·D and K

0 =

ιT,Tp·KT and take the morphism

k0:K0→D0induced byk.

• We build the retyped DGG G0p=ρT,Tp·GTp = (TT,Tp,G

0

p,P0) with G0p=ρT,Tp·GTp and

P0=ρT,Tp·Ppand take the morphismr

0:K0G0

pinduced byr:ιp·KT→GTp.

• The pushout ofk0andr0gives us aTT,Tp-typed graphHwithd:D

0Handh:G0

p→H.

• Finally, we build the DGGG0= (TT,Tp,H,P

0

ιT,Tp·P).

When all the above is applicable, we say that there is adirect dynamic derivationα fromG

toG0using p(based onm) and writeα:G⇒pG0. Adynamic derivationis a sequence of direct

dynamic derivations starting from the initial graph.

Example2 For the DGG introduced in Example1, assume the initial graph ofGa is a discrete

graphG0with one nodek typed overa. The application of the production p(with the obvious matching fromn1 tok) spawns a fresh instance G1p ofGp: the type graph becomesTg1 and the

underlying graph becomesG1⊃G0 with nodesk (typeda) andk1 (typedb1) connected by an arch1(typed f1). Moreover, a productionq1is now available besidep. A second application of pspawns another fresh instanceG2pofGp: the type graph becomesTg1∪Tg2 and the underlying

graph becomesG2⊃G1 with a new nodek2 and an arch2:k→k2. Again, a productionq2 is now available. Similarly, pcan be applied again and again (see Figure6). However, no suitable matching can ever be found for the application ofq1,q2, etc. In fact, it is not possible to find two arcs with the same type, say fi, and the identification condition prevents a non-injective matching

(9)

G0

k n

p •

h1

*

*

h2

2

2

hn

8

8

k

k1

...

k2

kn

Gn

• f1

4

4

f2

)

)

fn

'

'





a

Ta

Sn

i=1Tgi g

1

e

e

b1

•eeg2 ...

b2

•eegn

bn

Figure 6: A derivation where pis appliedntimes.

Note that the type graphs syntactically appearing inG= (T,Gin,P)∈DGGform a finite tree T(G)rooted inT, with parent relation given by immediate subsetting (i.e.,Ti is parent ofTj iff

Ti⊂Tj and no Tk appears inG such that Ti ⊂Tk ⊂Tj) and where leaves are associated with

static grammars. We remark that each type graph Tp ⊃T extends T with local declarations

Tp\T, whose scope is bounded by the specific production p. For simplicity, but without loss of

generality, we assume that all additional items introduced by different type graphs insideGare named differently.

Definition 7(Flat Type Graph) We letT(G) =S

Ti∈T(G)Ti denote theoverall flat type graphof

G, and letιTi :Ti,→T(G)denote the obvious sub-graph inclusion. Note that, by the structuring

ofT(G), the type graphT(G)is just the union of all the leaves ofT(G).

Similarly, all nested productions inGform the treeP(G)rooted inPwith parent relation given

by immediate inclusion (i.e., the set of productionsPi is the parent ofPp iff p:(LT l

←KT

r →

(Tp,GTp,Pp))∈Pi).

Definition 8 (Flattening) Given a T-typed dynamic production p:(LT

l

← KT

r

→GTp) with

GTp = (Tp,GTp,Pp)we say that the ordinaryT(G)-typed productionflat(p):(ιT·LT

l

←ιT·KT r →

ιTp·GTp)is theflattening of p. We letP(G) =

S

Pi∈P(G){flat(p)|p∈Pi}denote theoverall set of

flat productionsofG. TheT(G)-typed shallow grammarF(G) = (T(G),ιT·Gin,P(G))is called

theflattening ofG.

2.2.1 Encoding DGG into graph grammars

In what follows we provide an overview of the encoding of DGG into GGs. A detailed presenta-tion can be found in [BM06a].

The encoding of a DGGGrelies on the definition of a unique type graph expressive enough for distinguishing all the types generated dynamically byG. Such structure is called therefined

type graphand it is intuitively described as follows. Consider a chain of typesTdescribing the

evolution of the type graph ofG, i.e., a list of graph ordered by inclusions, e.g.,T1⊂T2⊂. . .⊂Tn,

(10)

• f // a • b1

• f //

a

Ta

Tg g

e

e

b

(a) ATg-typed Graph.

• s1,2 //

nTa

nTg

f0 //

ta@@

a

f1 //

tfkkkkkk55

k k k k k k k f •

tb1

@ @ b1

• s1,2 //

nTa

• nTg

f0

/

/

ta@@

a f1 / /

tkfkkkkkk55

k k k k k k f

• g0 ))

tg @ @ b g1 i i tb ^ ^ ===== g

(b) RefinedTg-Typed Graph.

Figure 7: A refinedT-Typed Graph.

list. Informally, any item (i.e., node or arc) ofTnis mapped to a node in{[Tn]}T. Every graphTi

in the chainTis also represented in{[Tn]}Tby a nodenTi. Moreover, any nodewcorresponding

to an itemkofTnhas an arctwto the nodenTi ifTi is the minimal type inTthat includesk. We

callTithetype of kinT. Formally, for anyk∈Tn, the type ofkisT(k) =Tiifk∈Ti\Ti−1.

Definition 9(Refined type graph) Given a type graphT and a chain of typesT=T1⊂. . .⊂Tn,

withTn=T, therefined type graphis{[T]}T=hNR,ER,sR,tRi, where:

• NR =NT∪ET∪ {nTi|Ti∈T}wherenTi are fresh names, i.e., the nodes of {[T]}T are the

nodes and arcs ofT plus one extra node for any type inT;

• ER={e0,e1|e∈ET} ∪ {tw|w∈NT∪ET} ∪ {si,i+1|0<i≤n−1}where all edge names are fresh. Source and target functions are defined s.t. the following holds:

– e0:sT(e)→e ande1 :e→tT(e), i.e., e0 connects the node e∈NR to its original

source inT whilee1connectseto its target;

– tw:w→nT(w), i.e.,twconnectswto the node representing its type;

– si,i+1:nTi→nTi+1 denotes the inclusion of typesTi⊂Ti+1.

Example 3 Consider the type graph Tg depicted in the bottom part of the Figure 7(a). The

refined type graph for the chainTa={a} ⊂Tg=Ta∪ {f,b,g}is shown at the bottom of

Fig-ure7(b). The original arc f (resp.g) ofTgis represented by the homonymous “squared” node f

(resp.g) and the pair of fresh arcsf0and f1(resp.g0andg1). The typesTaandTgare represented

by the fresh nodesnTa andnTg, while the inclusion relation Ta⊂Tg is denoted by the arcs1,2.

Finally, for any itemw,twconnectswto its type node.

Then, aT-typed graph is also mapped to a graph typed over the refined version of its typeT.

Definition 10(RefinedT-Typed Graph) Given a T-typed graphG=h|G|,τGiand a chainT=

(11)

• NH=NG∪EG∪ {nTi|Ti∈T}, i.e.,NHhas all items ofGplus nodes denoting types;

• EH={e0,e1|e∈EG} ∪ {tw|w∈NG∪EG} ∪ {si,i+1|0<i<n−1}, where:

– e0:sT(e)→eande1:e→tT(e);

– tw:w→nT(τG(w)), i.e.,twconnectswto the node representing its type inT, which

is obtained by using the typing morphismτG(w);

– si,i+1:nTi→nTi+1, for the inclusion of types. • The typing morphismτHis defined as follows

τH(k) = τG(k) if k∈G τH(nTi) = nTi

τH(ei) = τG(e)i i=0,1 τH(tw) = tτG(w) τH(si,i+1) = si,i+1

the nodesnTi and the arcstwandsi,i+1of a refined type graph (resp., a refinedT-typed graph)

are referred to as thelocation of the type graph(respectively,location of the graph).

Example4 Consider theTg-typed graphGshown in Figure7(a). The refined version ofGfor

the chainTa={a} ⊂Tg=Ta∪ {f,b,g}is shown in Figure7(b)(we omit the representation of

the obvious typing of arcs). The type graph corresponds to the refined version ofTgexplained in

Example3.

Definition 11(RefinedT-Typed DGG) LetG= (T,Gin,P)be a DGG, andT=T1⊂. . .⊂Tn,

withTn=Tbe a chain of types. Then, the refined version ofGis{[G]}T= ({[T]}T,{[Gin]}T,{[P]}T),

where{[P]}T={{[p]}T|p∈P}is obtained by encoding any productionp:(L←l K→r (T0,G0in,P0)) inPas follows:

{[p]}T:({[L]}T l 0

← {[K]}T r 0

→ {[(T0,G0in,P0)]}T⊂T0) (1)

where morphismsl0andr0are the obvious extensions oflandrwith the identity over the location of the graphs.

Example 5 Consider the production p in Figure 3. Its refined version is shown in Figure8.

Note that the type graphs correspond to the refined versions of the original type graphs, while the left-hand-side, the interface, and the right-hand-side correspond to the refined version of the original ones. In particular, note that the left-hand-side is typed over the refined version ofTa,

while the right-hand-side grammar is typed over the refined version ofTg. Moreover, the new

production{[q]}Ta⊂Tg created by the reduction correspond to the refined versions of the original

oneq(for clarity we do not draw the typing morphism, which is the obvious one).

The refined version of a grammar Grecreates the overall flat type graphT(G) as static tree of types (see Definition7). Any production p:(LT←KT→GT0) is encoded by considering the

path TofT(G)leading from the root of T(G) toT. Moreover, since previous definitions can be straightforwardly extended to consider the whole tree instead of a path, we will use{[ ]}T to denote also the refined versions obtained by considering the tree of typesT.

Definition 12(Encoding) LetG=hT,Gin,Pibe a DGG. Then, the equivalent graph grammar

(12)

{[p]}Ta :

nTa

-• nTa

,→

• s1,2 // nTa

{[Pp]}Ta⊂Tg ={{[q]}Ta⊂Tg}

nTg

tn1~~~??

~ ~ ~

n1

tn1 ~~~??

~ ~ ~

n1

tn1 ~~~??

~ ~ ~ h0 / / n1 th 7 7 o o o o o o o o o o o h1 / / h

• tn2

? ? ~ ~ ~ ~ ~ ~ n2

• s1,2 //

nTa

• nTg

f0

/

/

ta ~~~??

~ ~ ~ a f1 / / tf 4 4 i i i i i i i i i i i i i i i i i f

• g0 **

tg ? ? ~ ~ ~ ~ ~ ~ b g1 j j tb _ _ @@@@@@ g

{[q]}Ta⊂Tg:

tf @ @ @ @ @ @f1 // f

-•

tb1

b1

,→ •

tb1

b1

tb1

b1

• ta //

f0 ~~~??

~ ~ ~

f00 @@

@ @ @ @

a •

s1,2// nTa

•nTg •

ta //

a •

s1,2 // nTa

•nTg •

ta //

a •

s1,2 // nTa

• nTg

tg o o g1 _ _ ?????? g

tf0~~~??

~ ~ ~

f10

/

/

f0

tb2

O

O

b2

tb2

O

O

b2

tb2

O O g0 ? ?       b2

Figure 8: A refined production p.

3

Persistent Dynamic Graph Grammars

As done for GGs, we define the class of persistent DGGs by restricting the way in which re-sources are used. In particular, we assume that any type graph T is persistent if its edges are partitioned in two subsets:ET+of persistent edges andET−of removable edges. In the following assume any type graphT being persistent. Given aT-typed graphG, we denote byEG+andEG− the set of edges mapped respectively to persistent edges and to removable edges ofT.

Definition 13(Persistent DGG) A DGGGispersistent if all its productions are consuming,

semi-weighted and persistent, where a production p:(LT l

←KT

r

→GTp) ispersistent if all the

following conditions hold:

• node persistence: NL=l(NK);

• removal of removable arcs: EK−=0/;

(13)

• dynamic persistency:GTp is persistent.

Note that the three first conditions are the same as those in Definition 2. The fourth one requires persistency to hold recursively in the right-hand side of each production.

3.1 Encoding a PDGG into a PGG

In this section we show that by starting from a PDGG we can obtain a PGG, and hence, we can indirectly have the event structure semantics of PDGGs. The encoding is defined analogously to the original encoding of DGGs into GGs overviewed in Section 2.2.1. The only difference here is when encoding a production. Originally, a productionp:L←l K→r GTp is encoded as in

Equation (1). Note that for any edgeeinL, the encoding generates one nodee in{[L]}T, and three edgese0,e1andte. Nevertheless, wheneis not in the image ofl(that is,eis a removable

arc), the nodeein{[L]}Tis not preserved by{[p]}T. Therefore, we slightly modify the encoding of productions by requiring that for any removable arceinL, the production{[p]}Tpreserves the node encodingeto guarantee node persistency. Formally,

{[p]}T:({[L]}T← {l0 [K]}T]G r

0

→ {[(T0,G0in,P0)]}T⊂T0]G) (2)

whereGis the subgraph of{[L]}T containing the nodes encoding the removable arcs ofL(i.e., e∈EL−) and the nodes encoding the type of removable arcs (i.e., nT(τG(e)) for any e∈E

L).

Moreover, we considerl0andr0as the identity over elements inG.

Lemma 1 J K preserves behaviour, persistency, consumption and semi-weightedness.

Proof. (Sketch)

Behaviour: The proof follows as for the original encoding of DGGs in GGs in [BM06a], by showing that any reduction step that applies a production pin the original grammar corresponds to a reduction step on the encoded grammar obtained by applying the encoded version of the original productionp.

Persistency: Moreover,{[p]}T is persistent when pis such because nodes are now persistent,

and for edges we have that:

• Edgese0,e1, andteare removable ifeis removable. Otherwise they are preserved.

• Type inclusion edgessi,i+1are preserved.

Semi-weighted: (i) Since the initial graph is injectively typed and the encoding does not add multiple elements with the same type, then the initial graph of the encoded grammar is injectively typed. (ii) Similarly, since productions are injective, the encoding produces injective productions. Consumption: The proof follows by noting that the encoding preserves the name of edges, but the arcs connecting the name of an edge to its attachment points are actually consumed. Hence, if p is a rule of a PDGG, then it is consuming, and hence there is at least one deleted edge. Therefore the encoded form ofpconsumes at least two arcs.

(14)

Lemma 2 The encodingJ K preserves concurrency.

Proof. (Sketch) We prove that the encodingJ K preserves the shift equivalence. This follows

from the fact that for any two productions pandqthat are sequentially independent (i.e., they are not in conflict) in a PDGGG, then the corresponding rules inJGKare also sequentially in-dependent. This is proved by showing that the information added by the encoding of pandq corresponds to the location of the types and the names of edges, which will be always preserved by both generated rules.

4

Persistent Join

This section illustrates the use of PDGG for modelling a version of theJoincalculus enriched with persistent messages, calledPersistent Join(PJoin). Persistent messages are guaranteed not to be consumed after being produced [PSVV06], and hence are naturally useful for modelling situations like persistent, monotonic global stores such as in concurrent constraint programming. The syntax of PJoinrelies on an infinite setCof names for consumable messages ranged over by c,d, . . ., and a setPof names for persistent messages ranged over by p,q, . . .. We writex,y,z, . . .

to range overC∪P. The syntax of PJoinis given by the grammar

P ::= 0|xhyi |defDinP|P|Q D ::= J.P|D∧D J ::= xhyi|J|J

A basic form of processes is an asynchronous emission of a messagey on channelx, which is writtenxhyi. The input is performed by local definitionsx1hy1i|. . .|xnhyni.Pthat is enabled

when every channelxicontains a message (in this case the namesyidenote the formal parameters

of the input to be substituted inPwith the actual content of the messages).

Example6 The following process illustrates the definition of a constant that can be read

con-currently, and two concurrent accesses to it. We indicate persistent names by underlining their definitions.

P=def readhki |valhvi.khvi in valhci |readhk1i |readhk2i

The definitionreadhki|valhvi.khviintroduces two private channels: read andval. The mes-sagevalhcito the persistent channelvalsets the actual valuecof the constant, while the messages readhk1iandreadhk2irequest the value of the constant.

(15)

The semantics of the PJoinis given with thereflexive chemical abstract machinemodel [FG96]. In this model a solution is roughly a multiset of active definitionsJ.Pand messagesxhui (sepa-rated by comma). Moves are distinguished betweenstructural, which heat or cool processes, and reductions →, which are the basic computational steps. The multiset rewriting rules for PJoinare as follows:

0

P|Q P,Q

D ∧ E D,E

defDinP Dσdn(D),Pσdn(D) (range(σdn(D)) globally fresh)

J1|J2.P,(J1|J2)σ → J1|J2.P,J2σ,Pσ

Structural moves are identical to theJoincalculus, and allow for the rearrangement of terms inside a solution. In particular, a term denoting a process with local definitions can be represented by two terms (one for the definitions and other for the process) only when the locally defined ports are renamed by fresh names (this rule stands for the dynamic generation of new names). The only difference betweenJoinand PJoinis in the unique reduction rule that can be applied when the solution contains a reactionJ1|J2.Pand an instance(J1|J2)σof theJoinpatternJ1|J2: when such a match is found, the consumable messagesJ1σare removed from the solution, while

persistent messages J2σ are kept. Moreover, a suitable instance of the guarded processPσ is activated. We require σto substitute persistent (resp. consumable) names by persistent (resp.

consumable) names. We will writeP7→P0forP∗Q→Q0∗P0.

Example7 The process introduced in Example6behaves as follows

P = def readhki |valhvi.khvi in valhci |readhk1i |readhk2i

readhki |valhvi.khvi,valhci |readhk1i |readhk2i ∗ readhki |valhvi.khvi,valhci,readhk1i,readhk2i

At this point the system may reduce in two different ways. One alternative is the firing of the unique reactionreadhki |valhvi.khviwith the messagesvalhciandreadhk1i, and by producing

the messagek1hci, i.e.,

P7→ readhki |valhvi.khvi,valhci,k1hci,readhk2i.

Note thatvalhciis preserved while readhk1iis consumed. Similarly, the system may evolve

by firing the same reaction with the messagesvalhciandreadhk2i. In this way,

P7→ readhki |valhvi.khvi,valhci,k2hci,readhk1i.

We remark that such reductions can be computed concurrently since the messagevalhci in-volved in both reductions is always preserved, i.e.,

Differently, consider a variant ofPin whichvalhviis a consumable channel.

P0=def readhki |valhvi.khvi |valhvi in valhci |readhk1i |readhk2i

(16)

Example 8 This example illustrates the dynamic features of PJoin which are exploited for creating constants. In particular, the following definition is used for creating fresh constants that can be read concurrently.

D=newhwi . def readhki |valhvi.khvi in valhci |whreadi

The idea is that any message to the portnew will create a new constant with valuec, which will be read by accessing a fresh portread. (For simplicity, we create all constants with the same valuec, but it would be possible to write a slightly more complex process that allows to set an arbitrary initial value). Then, the following process

Q=defDinnewhk1i |newhk2i

may be rewritten as follows

Q ∗ D,newhk1i,newhk2i

By firingDwithnewhk1i, we obtain

Q 7→ D,def readhki |valhvi.khvi in valhci |k1hreadi,newhk2i

∗ D,readhki |valhvi.khvi, valhci,k1hreadi,newhk2i

By firingDagain withnewhk2i, we obtain

D,readhki |valhvi.khvi, valhci,k1hreadi,newhk2i

→ D,readhki |valhvi.khvi, valhci,k1hreadi,def readhki |valhvi.khvi in valhci |k1hreadi ∗ D,readhki |valhvi.khvi, valhci,k1hreadi,read0hki,val0hvi.khvi,val0hci,k1hread0i

Note that the heating of the solution renames the portsread andvalby the fresh namesread0 andval0, which assures any firing ofDto produce fresh instances of local names.

PJoinprocesses as DGGs. The encoding for PJoinis analogous to the encoding ofJoin

pre-sented in [BM06a]. For simplicity we assume definitions with different scopes not to share defined names. Any processP is encoded as a DGGGP=hTP,Gin,Qi. Generally speaking, a

channelxis encoded as a nodenx but the fact that the channel is namedxis denoted by an arc

x:nx→nx. If nodenx corresponds toxandnytoy, then a messagexhyiis represented with an

arcnx →ny. Any firing ruleJ.P will be encoded as a production. More formally, the initial

type graphTPis shown in Figure9(a), wherefn(P)∪bn(P) ={c1, . . . ,ck,p1, . . . ,pl}.TPhas two

nodescandpstanding respectively for consumable and persistent channels, four arcsmcc,mcp,

mpc, mpp for denoting different kinds of messages, where the subindexes indicate the type of

involved channels, one arccifor each consumable name infn(P)∪bn(P), and one arcpjfor any

persistent name infn(P)∪bn(P). We call thecontextofPtheTP-typed graphCP with one node

cci and one arcci:cci →cci for each consumable nameci∈fn(P)∪bn(P), and one nodeppi and

one arc pi:ppi → ppi for each persistent name pi∈fn(P)∪bn(P). Then, the initial graph Gin

and the set of productionsQofGP=hTP,Gin,Qiare defined by structural induction as follows:

(17)

• mcc ck Z Z c1 M

M tt

mpc c . . . • mpp p1 Z Z pl m m 4 4 mcp p . . .

(a) Initial Type Graph.

• x 99

cx • y D D / / mcp py

(b) Encoding ofxhyi.

• mcc D D x cx

(c) Encoding ofxhxi.

OO mcc

cd1 . . . •OO mcp

pqk •OO

mpc

cd10 . . . •OO mpp

pq0l

yh

Z

Z

nyh

-•

cd1 . . .pqk• •OO

mpc

cd10 . . . •OO mpp

pq0l

yh

Z

Z

nyh

,→ G0Pi

c1

Z

Z

cc1 •

ck

Z

Z

cck •

p1

Z

Z

pp1 •

pl

Z

Z

ppl •

c1

Z

Z

cc1 •

ck

Z

Z

cck •

p1

Z

Z

pp1 •

pl

Z

Z

ppl

(d) Encoding ofc1hd1i|. . .|ckhqki|p1hd10i|. . .|plhq0li.Pi.

Figure 9: Join processes as Dynamic Graph Grammars.

• [P=xhyi]. The encoding of a message depends on the type of involved names. There are four possibilities. Ifxis consumable andypersistent, thenGin=CP∪ {mcp:cx→ py}is

the graph shown in Figure9(b), with the typing morphism mappingcx intoc, py into p,

and being the identity on the remaining arcs. Remaining cases are analogous. Whenx=y, Gin=CP∪ {mcc:nx→nx}is as in Figure9(c). In all casesQ=0/.

• [P=defJ1.P1∧. . .∧Jn.PninP0]. LetGP0 =hTP0,G0in,Q0ibe the encoding ofP0, then

GP=hTP,CP∪G0in,Q

0S

1≤i≤n{ri}i, whereTP⊇TP0 (becauseJi.Pi may contribute free

names not present inP0) and each ri encodesJi.Pi. Assuming GPi =hTi,Gini,Qii and

the general shape for patternsJi=c1hd1i|. . .|ckhqki|p1hd10i|. . .|plhq0li(to expose all

com-binations of consumable and persistent names), then ri is shown in Figure 9(d), where

G0

Pi =hTi∪TP,G

0

ini,Q

0

iiextendsGPi over the type graphTi∪TP withG

0

ini being the union

ofGini and the items preserved by the production, and withQ

0

ibeing the suitable retyping

ofQi. The self-loop arcs naming the nodes dj, d0j, qj, andq0j are not included in ruleri

because the actual name of formal parameters is not known a priori and it will be provided by valid matchings. Moreover, the left-hand-side and the interface contain a nodenyh and

an arcyhfor any free nameyhofPinot bound inJi. In this way the context of the initial

graph ofGPi is bound to the names of the left-hand-side of the production. Note that the

production preserves all persistent messages, since the edges of typempcandmppare kept,

while consumable messages are removed, because edges of typemccandmcpare deleted.

• [P=P1|P2]. LetGP1=hT1,Gin1,Q1iandGP2=hT2,Gin2,Q2ibe the encoding ofP1andP2,

then the initial graph is the pushout object of the spanCP∪Gin1←-CP,→CP∪Gin2, andQ

is the union ofQ1andQ2(upon production retyping overTP).

Given a PJoinprocessP, it might be the case thatGPis not persistent. This may happen when

(18)

In particular, processes considered in our examples yield persistent grammars.

Example9 Consider the processQintroduced in Example8, the PDGG encoding the behaviour

ofQis shown in Figure10. The initial type graph is depicted in10(a): (i) nodespandcare the types of persistent and consumable channels respectively, (ii) edgesmcc, mcp,mpc andmpp are

the types of edges encoding messages, (iii) edgesc,k1 andk2 are the free names ofQ, and (iv) edgenewis the type of the unique defined name ofQ.

Figure10(b)shows the initial graph, which contains the nodes and edges corresponding to the three free names ofQ, i.e.,c,k1 andk2, and the unique defined namenew. Moreover, the initial graph contains the edgesm1ccandm2ccrepresenting the two initial messagesnewhk1iandnewhk2i. The encoding ofDis in Figure10(c). The graph on the left-hand side requires a message on portnew(arrowmcc). Moreover, it contains the nodecc and the edgecthat matches the namec

occurring free in the guarded process ofD. The namescandnewact as binders in the right-hand side of the productionGPi, which is detailed in Figures10(d),10(e), and10(f). The type graph of

GPiadds to the initial type graph (in Figure10(a)) the edges describing the namesread,w, andval

of the guarded process ofD. The initial graph ofGPiis shown in Figure10(e), which encodes the

messagesvalhciandwhreadiof the guarded process ofD. It is worth noting that the initial graph contains also a new edge namedwattached to the nodecw. In this way, an existing channel is

associated with a new name, a kind of local alias for that channel. Finally, the unique production ofGPi is shown in Figure10(f). For simplicity, the right-hand of the production shows only the

initial graph as we omit the type graph, which adds only the edgesk:c→candv:c→c. In this case, the right-hand side is static, i.e., adds no productions.

The following result hold up to aliasing of names, i.e., by removing aliasing from grammars.

Proposition 1 For any PJoinprocess P we have:

• If P7→P0using Ji.Pi, then∃Q s.t.GP⇒piGQand Q

P0;

• IfGP⇒piG

0, thenP0s.t. P7→P0using J

i.Pi andG0=GP0.

WhenGPis persistent, we can combine the results discussed in Sections2and 3to flatten the

PDGGGP into the PGGJGPK, and then take the PES semanticsEp(Up(JGPK))(see Figure1).

Example10 The PDGGGPassociated with the PJoinprocessPof Example6yields a PES with

just two concurrent events (sayeread(k1)coeread(k2)). Differently, the PDGGGP0 associated with

P0introduced in Example7would yield four events:e01st(k

1)ande

0

1st(k2)denoting respectively the

fact that the first served request isreadhk1iorreadhk2i, and similarlye02nd(k1)ande02nd(k2)for the

second served request; where the causal and (immediate) conflict relations are shown below:

e01st(k1) #

e01st(k2)

e02nd(k2) e02nd(k

(19)

• mcc k1 < < k2 N

N tt

mpc c \ \ new c mpp 4 4 mcp p

(a) Initial Type Graph.

• k1 99

ck1

•ee k2

ck2

• c 99

cc • new D D m1 cc W W ... ... m2

cc G G cnew

(b) Initial GraphGin.

OO

mcc cw • c Z Z cc ← -• cw • c Z Z cc

,→ GPi

new

Z

Z

cnew •

new

Z

Z

cnew

(c) Encoding ofD.

• mcc new read . . k1 < < k2 N N c \

\tt

mpc w n n • mpp 4 4 mcp val e e p

(d) Initial Type Graph ofGPi.

• read 99

cread • w Z Z mcc o

o cw •ee c

cc

new

Z

Z

cnew •

val Z Z mpc O O cval

(e) Initial Graph ofGPi.

OO

mcc

ck •OO

mpc

cv

-•

ck •OO

mpc cv ,→ • k

ck •OO

mpc v cv • read Z Z

cread •

val

Z

Zpval •

read

Z

Z

cread •

val

Z

Zpval •

read

Z

Z mcc//

cread •

val

Z

Zpval

(f) Unique Production ofGPi.

Figure 10: Join processes as Dynamic Graph Grammars.

5

Conclusions

(20)

References

[Bal00] P. Baldan.Modelling concurrent computations: From contextual Petri nets to graph grammars. PhD thesis, Computer Science Department, University of Pisa, 2000.

[BCMR07] P. Baldan, A. Corradini, U. Montanari, L. Ribeiro. Unfolding Semantics of Graph Transformation.Information and Computation, 2007. To appear.

[BM06a] R. Bruni, H. Melgratti. Dynamic Graph Transformation Systems. In Corradini et al. (eds.),Proceedings of ICGT 2006, 3rd International Conference on Graph Trans-formation. Lect. Notes in Comput. Sci. 4178, pp. 230–244. Springer Verlag, 2006.

[BM06b] R. Bruni, H. Melgratti. Non-sequential behaviour of dynamic nets. In Donatelli and Thiagarajan (eds.), Proceedings of ATPN 2006, 27th International Conference on Application and Theory of Petri Nets and Other Models Of Councurrency. Lect. Notes in Comput. Sci. 4024, pp. 105–124. Springer Verlag, 2006.

[BMM06] R. Bruni, H. Melgratti, U. Montanari. Event Structure Semantics for Nominal Cal-culi. In Baier and Hermanns (eds.),Proceedings of CONCUR 2006, 17th Interna-tional Conference on Concurrency Theory. Lect. Notes in Comput. Sci. Springer Verlag, 2006. To Appear.

[BS01] M. Buscemi, V. Sassone. High-level Petri nets as type theories in the Join calcu-lus. In Honsell and Miculan (eds.),Proceedings of FoSSaCS 2001, Foundations of Software Science and Computation Structures. Lect. Notes in Comput. Sci. 2030, pp. 104–120. Springer Verlag, 2001.

[CMR+97] A. Corradini, U. Montanari, F. Rossi, H. Ehrig, R. Heckel, M. L¨owe.Handbook of Graph Grammars and Computing by Graph Transformation. Vol. 1: Founda-tions. Chapter Algebraic Approaches to Graph Transformation I: Basic Concepts and Double Pushout Approach. World Scientific, 1997.

[FG96] C. Fournet, G. Gonthier. The reflexive chemical abstract machine and the Join calcu-lus. InProceedings of POPL’96, 23rd Annual ACM SIGPLAN - SIGACT Symposium on Principles of Programming Languages. Pp. 372–385. ACM Press, 1996.

[NPW81] M. Nielsen, G. Plotkin, G. Winskel. Petri Nets, Event Structures and Domains, Part

1.Theoret. Comput. Sci.13:85–108, 1981.

Figure

Figure 1: A recollection of event structure semantics.
Figure 2: A DPO direct derivation.
Figure 4: A static production q.
Figure 5: The dynamics of DGGs
+6

References

Related documents

This paper outlines i) the literature drawn in conceptualizing the study, ii) the methodology that was followed in obtaining qualitative information from men and women farmers in

Appropriate zero factors for the general Fourier expansions are given at the axis and at innity in order to remove the numerical singularity at r = 0 and to satisfy all the

For this purpose, an experimental design was proposed to assess the effect of electrospinning process conditions including solution concentration, electric voltage and

The contract should be in writing and should include the purpose, goals, and objectives of supervision; the context in which supervision is provided; ethical and institutional

Phospholipid components contents ratio in the liver tissue to ones in the dorsal muscle in two- and three-year-old sterlet [unit: (liver phospholipids mg/g dry

Contraindicated in patients who are engaged in current opioid use (as indicated by self- report or a positive urine drug screen) or who are on buprenorphine or methadone

Depending on the treatment plan, a person may have an individual therapist, a group therapist, a substance abuse counselor, a psychiatrist, and a primary care provider; treatment

Regression models, associated R 2 values and mean times for each forwarder time element (extracting logs) at the Conventional and Fuel-adapted study sites... forwarder cycle time