pdfs.semanticscholar.org€¦ · chapter 7 describing systems of processes by means of high-level...

50
Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl f¨ ur Programmiersprachen, Universit¨ at Erlangen-N¨ urnberg, Martensstr. 3, D-91058 Erlangen Electronic Mail: [email protected] Graphs and graph transformations are natural means to describe systems of pro- cesses. Graphs represent structure of the system, and graph rewriting rules model dynamic behaviour. In this chapter, we illustrate the technique by describing Petri nets, statecharts, parallel logic programming, and systems of processes. Whereas description of Petri nets is based on usual graphs, statecharts lead us to hierarchical graphs, and parallel logic programming needs jungles. Finally, we combine different approaches to describe systems of processes. Topological structure is represented by a hypergraph. Local states and communication channels correspond to nodes that are labelled with parts of a global jungle playing the role of a shared data structure. The formal model takes advantage of comma-category approach allow- ing to change both the structure of graph and the contents of nodes consistently and to treat different graph structures as well as different labelling mechanisms in a uniform way. Handbook of Graph Grammars and Computing by Graph Transformations, Volume 3: Concurrency (Eds.: H. Ehrig, H-J. Kreowski, U. Montanari, G. Rozenberg), pp. 401-450 1

Upload: others

Post on 08-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

Chapter 7

DESCRIBING SYSTEMS OF

PROCESSES BY MEANS OF

HIGH-LEVEL REPLACEMENT

H.J. SCHNEIDER

Lehrstuhl fur Programmiersprachen,Universitat Erlangen-Nurnberg, Martensstr. 3,

D-91058 ErlangenElectronic Mail: [email protected]

Graphs and graph transformations are natural means to describe systems of pro-cesses. Graphs represent structure of the system, and graph rewriting rules modeldynamic behaviour. In this chapter, we illustrate the technique by describing Petrinets, statecharts, parallel logic programming, and systems of processes. Whereasdescription of Petri nets is based on usual graphs, statecharts lead us to hierarchicalgraphs, and parallel logic programming needs jungles. Finally, we combine differentapproaches to describe systems of processes. Topological structure is representedby a hypergraph. Local states and communication channels correspond to nodesthat are labelled with parts of a global jungle playing the role of a shared datastructure. The formal model takes advantage of comma-category approach allow-ing to change both the structure of graph and the contents of nodes consistentlyand to treat different graph structures as well as different labelling mechanisms ina uniform way.

Handbook of Graph Grammars and Computing by Graph Transformations,Volume 3: Concurrency (Eds.: H. Ehrig, H-J. Kreowski, U. Montanari,G. Rozenberg), pp. 401-450

1

Page 2: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

Contents

7 Describing Systems of Processes by Means of High-Level Re-placement 1

7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

7.2 Basic Notions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

7.3 Comma Category Approach . . . . . . . . . . . . . . . . . . . . 9

7.4 Graphs and Labelled Graphs . . . . . . . . . . . . . . . . . . . 12

7.5 Petri Nets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

7.6 Statecharts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

7.7 Parallel Logic Programming . . . . . . . . . . . . . . . . . . . . 25

7.8 Systems of Processes . . . . . . . . . . . . . . . . . . . . . . . . 31

7.9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

Appendix A: Full example . . . . . . . . . . . . . . . . . . . . . . . . 43

Appendix B: List of Categories and Functors . . . . . . . . . . . . . 50

Page 3: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.1. INTRODUCTION 3

7.1 Introduction

Graphs are a suggestive means to represent systems of processes. In fact, thisgreatly contributed to the success of Petri nets. Graphs represent the states ofthe system, and graph rewriting rules describe its dynamic behaviour. Graphtransformation systems, especially, offer a very convenient way to model dy-namic systems the topological structure of which is changed by creating ordeleting processes and channels. Looking at the literature, we see that nearly allmodels of concurrent systems have been already described using graph trans-formations. Typical examples are Petri nets [26], statecharts [28], data basesystems [30], relational structures [13], logic programming [5], term rewriting[18], high-level replacement systems [11], actors [24], and generative communi-cation [37]. Most approaches to specification methods based on graph transfor-mation need additional attribution techniques to close the gap between struc-tural aspects and calculation of values. Schied [34] has integrated attributesinto categorical framework: An attributed graph is a pair consisting of a graphand an algebra. Lowe et al. [27] have further developed this concept and appliedit to single-pushout approach.Concerning systems of processes, we follow a slightly different line. We combinegraph transformation with jungle rewriting. The topological structure of thesystem may change dynamically, i.e., processes and communication channelsmay be created or destroyed; these changes of structure are described by graphtransformations. The local states are given by sets of terms that are part ofa global jungle; changes of states correspond to jungle rewriting. This modelwas initiated by looking for a uniform description of different communicationmechanisms. On the one hand, it allows processes both to share data struc-tures and to compute compound data structures cooperatively. On the otherhand, it is possible to describe message passing. This is a matter of choosinga suitable category used to label communication nodes. Although our exam-ple must be small, it makes clear that the concept is suggestive and close towhat practitioners expect. Formally, the model is a modification of Schied’scomma category approach [34]. It may be regarded as a uniform mechanismto model both different graph structures (graphs, hypergraphs with or with-out distinguishing between source nodes and target nodes, bipartite graphs,etc.) and different labelling mechanisms (label preserving, partially ordered,hierarchical graphs). It seems that comma category approach is a nice tech-nique to improve modularity and reusability of results in the field of graphtransformation systems.The chapter starts with summarizing some of the basic concepts of double-pushout approach. In Sect. 7.2, derivability and parallel independence are in-

Page 4: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

4 DESCRIBING SYSTEMS OF PROCESSES BY . . .

troduced without any reference to graphs, i.e., we assume an arbitrary re-placement system. (For more information, the reader is referred to the firstvolume of this handbook [6].) Parallel-independence theorem, that is basicto discuss asynchronous behaviour of process systems, is usually proved forHLR1-categories, although some categories of interest do not fit into this class.A closer look at the proof shows that we do not need all pushouts, but onlythe pushouts of morphisms closely related to given morphisms the pushouts ofwhich exist by the assumption.

In literature, we find a large variety of graphs and of labelling mechanisms.Each author proves that his or her version satisfies the properties needed inthe case in point. In Sect. 7.3, we structure these results by showing that it issufficient to prove interesting properties only for some basic categories, sincethe comma-category technique is a general means to lift these properties frombasic categories to composed ones if some functors are (co-)continuous. Espe-cially, HLR1-property can be lifted. As before, a closer look at the proof showsthat we may also lift parts of HLR1-property: E.g., we need not assume the basecategory to be cocomplete; nevertheless, we may lift at least relations betweenthe existing pushouts. (Of course, the resulting category is not cocomplete.)Categories that are relevant to realistic applications are often complicated.Most of the functors to compose them, however, are sufficiently simple suchthat proving properties of those categories can be reduced to considering thebase categories separately, thus modularizing complicated proofs.

Then, we illustrate comma-category technique by defining different types ofgraphs, and we recapitulate Schied’s proposal how to unify treatment of differ-ent labelling mechanisms (Sect. 7.4). We introduce a new aspect into Schiedstechnique by proposing a two-step labelling allowing us to use different la-belling mechanisms for nodes and edges or even for different classes of nodes.Since two-step labelling may be iterated, it is possible to distinguish an arbitraynumber of node classes which each need another type of labelling. The benefitwe get from our approach is that labelling of each node class can be discussedseparately instead of having to take into consideration different mechanisms atthe same time. Of course, the results are the same as we had proved them forevery case separately and from scratch.

Four sections constitute the main part of this chapter presenting different mod-els of process systems. Sect. 7.5 describes Petri nets by graph transformations.Translation is easily comprehensible, but even this simple example results in alabelling category that is not cocomplete and does not satisfy HLR1-property.Nevertheless, discussing parallel independence makes sense, as it is well-knownfrom Petri-net theory, and we get it by lifting existing pushouts from the

Page 5: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.2. BASIC NOTIONS 5

labelling category to the category of Petri nets. Whereas usual graphs aresufficient to model Petri nets, statecharts (Sect. 7.6) are based on hierarchi-cal graphs. In literature, statecharts are assumed to have a static structure.An advantage of describing them by graph transformation is the possibilityto introduce changing the structure. Thus the approach yields a generaliza-tion of traditional statecharts. Transition to parallel logic programming leadsus to consider jungles (Sect. 7.7) and we have to have a very detailed lookto what happens with respect to labelling to ensure that the parallel inde-pendence theorem holds. Up to this point, we use comma-category approachto clarify relationship between known results. In Sect. 7.8, however, we pro-pose a new concept combining graph transformation with jungle rewriting todescribe systems of processes. This is a further step towards integrating struc-tural transformation and operations on labels often modelled by attributedtransformation rules.

For reason of space, we can illustrate the concepts only by small examples,but these are sufficient to give enough insight into the technique as well asinto the gap between a smooth theory and real world examples. For instance,category of jungles does not satisfy HLR1-conditions since not all colimits exist.Nevertheless, parallel independence theorem holds even in this category sincethe constructions we need exist because of concrete assumptions.

7.2 Basic Notions

We use the categorical graph-transformation approach based on two pushoutsas we have developed it in 1973 [9] and as it is outlined, e.g., by Ehrig [10] andby Corradini et al. [6]:

Definition 7.2.1 (Derivability [9])A production is a pair of morphisms p = (Bl pl

←− Kpr

−→ Br) in an arbitrarycategory. If p is a production, Gr is said to be derivable from Gl via p : Gl p

=⇒Gr (with redex gl : Bl → Gl) if and only if there exist a context object C anda morphism g : K → C such that in the following diagram both squares arepushouts:

KBlpl

� Brpr

-

Gl

gl

?C

g

?Gr

gr

?

pl�

pr-

PO PO

Page 6: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

6 DESCRIBING SYSTEMS OF PROCESSES BY . . .

The advantage of this definition is that it does not refer to specific kinds ofgraphs or even to graphs at all. Still more, we do not assume the category tohave all pushouts; to apply a production p, we only need that both pushoutsexist for some g. We find relevant examples of categories that are not cocom-plete in discussing Petri-nets (Sect. 7.5) and jungles (Sect. 7.7).

Studying the behaviour of systems of processes, we are interested in some prop-erties of derivation sequences that reflect asynchronous behaviour. Corradiniet al. [6] and Ehrig [10] summarize typical results characterizing parallel andsequential independence or amalgamating parallel productions. If two produc-tions are applicable to a given graph G, the result may depend on the orderof application, or even the second production is no longer applicable after thefirst has been applied. Of course there is no problem if the left-hand sides ofboth productions are mapped into disjoint parts of G. But this is too strong:

Definition 7.2.2 (Parallel independence [10])Two derivation steps

K1Bl1

pl1� Br

1pr1-

G

gl1

?C1

g1

?H1

gr1

?

pl1

�pr1

-

PO PO

K2Bl2

pl2� Br

2pr2-

G

gl2

?C2

g2

?H2

gr2

?

pl2

�pr2

-

PO PO

are called parallel independent if and only if there exist morphisms α1 : Bl1 →

C2 and α2 : Bl2 → C1 with gl

1 = pl2 · α1 and gl

2 = pl1 · α2.

This characterization can be interpreted as follows: If we apply p1 first, weare able to apply p2 subsequently by embedding its left-hand side into H1

(instead of G) by morphism pl1 · α2. Ehrig and Kreowski [12] have shown that

in the special case of sets, the result does not depend on the order of applyingthe productions if we consider only injective morphisms. The proof can becarried out without leaving the categorical framework if we assume a categorysatisfying the HLR1-property:

Definition 7.2.3 (HLR1-condition [14])A category with a distinguished class M of morphisms is called HLR1-categoryif the following conditions hold:

(a) If f ∈ M and g is any morphism, then pushout diagram qf = pg existsand p ∈M .

(b) If p, q ∈M , then pullback diagram qf = pg exists and f, g ∈M .

Page 7: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.2. BASIC NOTIONS 7

(c) Category has coproducts compatible with M , i.e., if f, g ∈M , then f+g ∈M .

(d) If in

· ·f - ·f ′-

g

?

g′

?

g′′

?· ·p - ·p′ -

(1) (2)

(1 + 2) is a pushout, (2) is a pullback, and f ′, g, g′, g′′, p′ ∈ M , then (1)and (2) are pushouts separately.

The last HLR1-condition fills a gap left by the double-pushout lemma thatholds in any category:

Lemma 7.2.4 (Double-pushout lemma [21, p. 147])If in the commutative diagram

· ·f - ·f ′-

g

?

g′

?

g′′

?· ·p - ·p′ -

(1) (2)

(1) and (2) are pushout diagrams, then (1+2) is a pushout diagram, too. Con-versely, if (1+2) as well as (1) are pushout diagrams, then (2) is.

Typical examples of HLR1-categories are Set and Graph together with injec-tions as M . Ehrig et al. [14] give a list of categories satisfying HLR1-condition.As we have already mentioned, some categories of interest, e.g., category ofjungles, do not satisfy these conditions. Nevertheless, we give the general for-mulation here:

Theorem 7.2.5 (Parallel independence theorem [10])If in a category that satisfies HLR1-condition, two derivation steps G =⇒p1 H1

and G =⇒p2 H2 with pl1, p

r1, p

l2, p

r2 ∈ M are parallel independent then there

exists a (unique) G′ such that we have H1 =⇒p2 G′ and H2 =⇒p1 G′.

This means that parallel independent derivations steps may be interchangedwithout affecting the result. The proof is straight-forward and is repeated herein order that we can see to what extent the result may be valid for categoriesthat are not HLR1.

Page 8: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

8 DESCRIBING SYSTEMS OF PROCESSES BY . . .

K1Bl1

pl1� Br

1pr1 -

G

gl1

?C1

g1

?H1

gr1

?

pl1

�pr1

-

(a)

(1) (2)

K2Bl2

pl2� Br

2pr2 -

G

gl2

?C2

g2

?H2

gr2

?

pl2

�pr2

-

(3) (4)

K1Bl1

pl1� Br

1pr1 -

C2

α1

?C0

?

H1

?

� C ′2

-

��

@@

@RG?

C1

?� -

(b)

(5) (8)

(7) (11)

K2Bl2

pl2� Br

2pr2 -

C1

α2

?C0

?

H2

?

� C ′1

-

��

@@

@RG?

C2

?� -

(6) (9)

(7) (12)

K1Bl1

pl1� Br

1pr1 -

C2

α1

?C0

?� C ′

2-

��

@@

@RH2

?C ′

1

?� G′-

(c)

(5) (8)

(12) (10)

K2Bl2

pl2� Br

2pr2 -

C1

α2

?C0

?� C ′

1-

��

G′

@@

@RH1

?C ′

2

?� -

(6) (9)

(11) (10)

K2 Bl2

pl2-

C2

?

C1

α2

?K1

-

Bl1

pl1

?G

pl1

?α1

-pl2

-

(d) K2 Bl2

pl2-

C0

?C1

α2

?K1

- -

Bl1

pl1

?C2

?G

pl1

?α1

-pl2

-

(5) (7)

(6)

Figure 7.1: Proof of parallel independence theorem

Page 9: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.3. COMMA CATEGORY APPROACH 9

ProofWe start from two derivation steps (Figure 7.1a) and construct a suitable C0

that is common to both derivation steps (Figure 7.1b). If it can be choosensuch that squares (5), (6), and (7) are pushout diagrams, the following stepsare simple: On the right-hand sides of both derivation steps, we construct (8)and (9) as pushout diagrams. From double-pushout lemma, we get that (2)and (4) may be subdivided such that (11) and (12) are pushouts, too. Now,we let unchanged the upper part of both diagrams, but we transpose (11) and(12) from right-hand side of one derivation step to left-hand side of the other(Figure 7.1c). Now, p1 is applied to H2 and p2 is applied to H1. Constructingpushout (10) yields the desired result. The steps we have discussed in detail donot depend on special properties of HLR1-categories. These are needed onlyto construct C0. Figure 7.1d shows how (1) and (3) overlap. We construct C0

as the pullback object of pl1 and pl

2. Therefore, K1 → C0 and K2 → C0 areuniquely determined and Definition 7.2.3(d) yields that (5), (6), and (7) arepushouts. utIn categories that do not have all pushouts, it may be of interest to note thatconstructing (8) and (9) uses same gluing graphs K1 and K2 as the givenderivation steps do; furthermore, gluing graph of (10), i.e., C0, is stronglyrelated to existing pushouts. Therefore, we have some chance that parallelindependence also holds in categories that allow pushout construction only forspecial gluing objects.

7.3 Comma Category Approach

As we have already mentioned in the introduction, we use comma categories[16,33] as a means to modularize proofs and to reuse parts of them.

Definition 7.3.1 (Comma category [33])Let A,B, C be categories and let L : A → C and R : B → C be two functors.Then, the comma category (L,R) is defined as follows:

(a) The objects of (L,R) are of the form (a, b, c) with a ∈ ObjA, b ∈ ObjBand c : L(a)→ R(b) being a morphism of C.

(b) A morphism s : (a, b, c) → (a′, b′, c′) of (L,R) is a pair of morphismsf = (fl : a → a′, fr : b → b′) with fl ∈ MorA, fr ∈ MorB such that thefollowing diagram commutes:

Page 10: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

10 DESCRIBING SYSTEMS OF PROCESSES BY . . .

L(a) R(b)c -

L(a′) R(b′)c′

-

L(fl)?

R(fr)?

=

(c) Composition and identities are defined componentwise.

Since we have Mor(L,R) = MorA×MorB, every commutative diagram qf = pgin (L,R) induces commutative diagrams qlfl = plgl in A and qrfr = prgr in B.As a consequence, pushouts, pullbacks, etc. in (L,R) may be projected on thecomponent categories, but the converse does not always hold:

Lemma 7.3.2 (Colimits in a comma category [33])Let L : A → C and R : B → C be two functors. The comma category (L,R) iscocomplete if A and B are cocomplete and L is cocontinuous.

Proof outlineAs the well-known construction of pushouts in category Graph shows, pushoutof f , g in a comma category can be obtained in two steps: First, we constructpushout diagrams of the projections fl, gl and fr, gr in A and B, respectively.They exist because of cocompleteness of these categories. Then, we put togetherthe results and get morphisms (fl, fr) and (gl, gr) in (L,R) by the universalproperty in C. (Cocontinuous functors preserve colimits.) Proving universalproperty in (L,R) can also be reduced to universal property in C. Same argu-ment holds for all colimits. The interested reader can find functional programsto construct (co-)limits and to lift them to comma categories in [33]. utThe dual lemma states that (L,R) is complete if A and B are complete and ifR is continuous.

Unfortunately, not all the categories we need in the main part of this chapterare cocomplete. Some of them do not have even all pushouts. A closer lookto the proof we have just sketched, however, shows that we may lift someproperties which are of importance to discussing parallelism. For example,HLR1-property may be lifted to (L,R):

Theorem 7.3.3 (Lifting HLR1-categories)If A and B satisfy HLR1-condition, L is cocontinuous, and R is continuous,then comma category (L,R) is an HLR1-category.

Page 11: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.3. COMMA CATEGORY APPROACH 11

a bf -

c

g

?d

g′

?p -

d′

k

AAAAAAAU

h

HH

HH

HH

HHj

al blfl -

cl

gl

?dl

g′l?pl-

d′l

kl

AAAAAAAU

hl

HH

HH

HHHj

ul

@@

@R

ar brfr-

cr

gr

?dr

g′r?pr-

d′r

kr

AAAAAAAU

hr

HH

HH

HHHj

ur

@@

@R

(1) (1l) (1r)

Figure 7.2: Diagrams to illustrate proof of Theorem 7.3.3

Proof outlineBy way of example, we show how to prove one part of property (d) in Definition7.2.3. We consider the diagram given there. As we have already mentioned, wecan project it from category (L,R) on categories A and B by indexing mor-phisms with l and r, respectively, and all the prerequisites also hold in thesecategories. Therefore, projections of the left-hand square (1) are pushouts inA as well as in B since both categories are HLR1 by assumption. To prove uni-versal property in (L,R), we consider the first diagram in Figure 7.2 assumingtwo morphisms h and k with hg = kf . The other diagrams are the projectionson A and B, where we get unique ul and ur, respectively. It remains to showthat (ul, ur) is a morphism in (L,R), i.e., satisfies condition (b) of Definition7.3.1. But this is straight-forward. Projections of second and third diagramon C may be connected by morphisms cc : L(cl) → R(cr), bc : L(bl) → R(br),and d′c : L(d′l) → R(d′r) and dc : L(dl) → R(dr) follows from pushout in A.Since h and k are morphisms in (L,R), this results in some commutative di-agrams that may be put together yielding a large commutative diagram in Cfrom L(al) to R(d′r): R(kr)bc L(fl) = dc L(hl) L(gl). Taking advantage of thefact that L(pl) · L(gl) = L(g′l) · L(fl) is a pushout because L is cocontinous, weget R(ur)dc = d′c L(ul); thus, (ul, ur) is a morphism. If (ul, ur) were not uniquein (L,R), we would have either two ul or two ur or both contrary to pushoutproperty in A and B. utThis theorem illustrates the benefit we gain from constructing the categorieswe need as comma categories based on simpler categories since it immedi-ately transfers known results concerning parallelism and concurrency [6] to thecomma categories if they hold for the base categories. In the following sections,we show that many of the categories used in literature can be constructed insuch a way. Unfortunately, some of them are not cocomplete. Nevertheless, we

Page 12: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

12 DESCRIBING SYSTEMS OF PROCESSES BY . . .

have no cause to worry about this: The proof we have just sketched does notassume the categories involved to have all pushouts. Therefore, it is sufficientto know that parallel independence holds with respect to the base categories:

Corollary 7.3.4 (Lifting parallel independence)If A and B have all pushouts necessary to prove parallel-independence theorem,L is cocontinuous, and R is continuous, then parallel-independence holds incomma category (L,R).

7.4 Graphs and Labelled Graphs

Now, we illustrate these benefits by applying comma category technique bothto unify the treatment of different kinds of graphs (usual graphs, hypergraphs,bipartite graphs, etc.) and to deal with different types of labelling in the sameway. Of course, the results are the same as we had proved them for each caseseparately and from scratch.

Definition 7.4.1 (Graphs)Let Id : Set → Set be the identity functor, X : Set → Set the diagonal functordefined by X(S) := S×S and X(f)(a, b) := (f(a), f(b)). Then, comma categoryGraph = (Id,X) is the category of graphs.

This means that a graph is a triple G = (E, V, c) with c : E → V × V , whereE is the set of edges, V is the set of nodes, c is a function connecting eachedge with a source and a target node. A graph morphism is pair (gE : E1 →E2, gV : V1 → V2) with

Id(E1) X(V1)c1 -

Id(E2) X(V2)c2-

Id(gE)?

X(gV )?

=

E1 V1 × V1c1 -

E2 V2 × V2c2-

gE

?(gV , gV )

?

=

Computations may be described by hypergraphs the edges of which correspondto operations or predicates [5,18,35]. The nodes an edge visits denote param-eters and results. In this case, it makes sense to distinguish between sourcenodes (parameters) and target nodes (results), but we do not in all cases:

Page 13: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.4. GRAPHS AND LABELLED GRAPHS 13

Definition 7.4.2 (Hypergraphs)(a) Let Q : Set → Set be the functor defined bya Q(S) := S+ and Q(f)(w) :=

f+(w). Then, comma category Hgraph = (Id,Q) is called the category ofhypergraphs.

(b) Let C : Set → Set be the functor defined by C(S) := S∗ × S+ andC(f)(w,w′) := (f∗(w), f+(w′)). Then, comma category SThgraph =(Id,C) is called the category of hypergraphs with sources and targets.

Hence, a hypergraph with sources and targets is a triple H = (E, V, c) withc : E → V ∗ × V +, and a hypergraph morphism is pair (ge : E1 → E2, gV :V1 → V2) with

Id(E1) C(V1)c1 -

Id(E2) C(V2)c2-

Id(gE)?

C(gV )?

=

E1 V ∗1 × V +

1c1 -

E2 V ∗2 × V +

2c2-

gE

?(g∗V , g+

V )?

=

Although in theory of parallel algorithms, it is of interest to make use of con-current write operations, we exclude this here and assume that every operandis the result of a uniquely determined operation:

Definition 7.4.3 (Computational graphs)We define category Cgraph of computational graphs to be the full subcategoryof SThgraph the objects (E, V, c) of which satisfy

(∀v ∈ V )(card{e ∈ E | v occurs in t(e)} ≤ 1)

with t being the second component of c, i.e., c(e) = (s(e), t(e)).

Similarly, we may define bipartite graphs, which we later need to describe Petrinets.

There is a rich variety of mechanisms to label graphs. On the one hand, wecan distinguish between labelling only nodes, only edges or both nodes andedges. On the other hand, we can use a simple labelling alphabet assumingthat morphisms preserve labels or we may impose a structure on the alphabetrequiring morphisms to be compatible with this structure [30] or we may evenuse graphs as labels again [36]. It is a nice effect that comma category approachalso unifies different labelling mechanisms:

af∗ is defined by f∗(ε) = ε and f∗(aw) = f(a)f∗(w) for all a ∈ S, w ∈ S∗. f+ isrestriction of f∗ to S+.

Page 14: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

14 DESCRIBING SYSTEMS OF PROCESSES BY . . .

Definition 7.4.4 (Selecting functors [34])Let G be any category of graphs and WE ,WV ,WEV : G → Set selecting func-tors defined as follows:b

WE((E, V, c)) := E WE((fE , fV )) := fE

WV ((E, V, c)) := V WV ((fE , fV )) := fV

WEV ((E, V, c)) := E + V WEV ((fE , fV )) := fE + fV

Consider a category L of labels and a functor F : L → Set . Then, (WE ,F) yieldsthe category of edge-labelled F-graphs, (WV ,F) yields the category of node-labelled F-graphs, and (WEV ,F) yields the category of node- and edge-labelledF-graphs.

In the following, W denotes one of the functors WE ,WV ,WEV . The domain ofW defines the kind of graphs we consider, i.e., usual graphs, hypergraphs, bi-partite graphs, etc. The codomain defines the component to be labelled (edgesand/or nodes). In detail, an F-graph is a triple (G, L, m), where G = (E, V, c)is a graph, L ∈ ObjL is an object of the labelling category and m is a labellingfunction. If we choose, e.g., (WV ,F), then m assigns an element of F(L) to eachnode, and we get the following diagram:

WV (G1) F(L1)m1 -

WV (G2) F(L2)m2-

WV ((fE , fV ))?

F(r)?

=

V1 F(L1)m1 -

V2 F(L2)m2-

fV

?F(r)?

=

Choosing L and F, we are able to handle different kinds of labelling within thesame framework. The simplest case is that nodes and/or edges of a graph arelabelled with elements of a given set M :

Definition 7.4.5 (Labelled graphs)Let 1 be the category consisting of one object • and one morphism id•. Con-sider functor M : 1 → Set defined by M(•) := M and M(id•) := idM . Then,LgraphM = (W,M) is the category of M -labelled graphs.

Choosing W = WV : Graph → Set , we get the usual definition of node-labelledgraphs:

b+ denotes coproduct (disjoint union).

Page 15: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.4. GRAPHS AND LABELLED GRAPHS 15

WV (G1) M(•)m1 -

WV (G2) M(•)m2-

WV ((fE , fV ))?

M(id•)?

=

V1

M

m1PPPPPq

V2

m2�����1fV

?

=

If we use WEV , we get a problem since Definition 7.4.4 yields objects withm : E + V → L. In practice, however, we often have to label edges with el-ements of a set LE and nodes with elements of a set LV different from LE .Other functions are not allowed contrary to our definition of WEV that leadsto the first of the following diagrams, but we need the second and third:

E1 + V1

LE + LV

m1PPPq

E2 + V2

m2���1fE + fV

?

=

V1

LV

m1VPPPPPq

V2

m2V�����1fV

?

=

E1

LE

m1EPPPPPq

E2

m2E�����1fE

?

=

We solve this problem by introducing a two-step comma-category construc-tion. Without loss of generality, we start with labelling edges using WE

and FE : LE → Set . Objects of (WE ,FE) are of the form (G, LE ,mE) =((E, V, c), LE ,mE) and morphisms are of the form ((fE , fV ), fLE). Then, weuse a modified WV to label nodes:

Definition 7.4.6 (Two-step labelling)Let FE : LE → Set and FV : LV → Set be two labelling functors. WithW′

V : (WE ,FE)→ Set defined by

W′V (G, LE ,mE) = WV (G)

W′V (f, fLE) = WV (f)

we get comma category (W′V , FV ) and denote it by (WE ,WV , FE , FV ).

The objects of this category are of the form (((E, V, c), LE ,mE), LV ,mV ) andmorphisms are arranged as (((fE , fV ), fLE), fLV ). On the other hand, Def-inition 7.4.4 results in a category (WEV , FE + FV ) consisting of objects ofthe form ((E, V, c), (LE , LV ),m). Of course, there is a close relationship: Two-step construction yields a category that is isomorphic to a subcategory of(WEV , FE + FV ) restricting morphisms to be of the form mE + mV . This

Page 16: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

16 DESCRIBING SYSTEMS OF PROCESSES BY . . .

means that we can embed it by the following functor i:

i(((E, V, c), LE ,mE), LV ,mV ) = ((E, V, c), LE + LV ,mE + mV )i(((fE , fV ), fLE), fLV ) = ((fE , fV ), fLE + fLV )

Here, we have used indices E and V ; nevertheless, definition allows to treatcases with two or more disjoint sets of nodes analogously, as we do in the nextsection.

7.5 Petri Nets

Petri nets are a widely accepted tool for discussing both the spatial structure ofa concurrent system and its temporal behaviour that can be made transparentby the well-known token game. They are based on bipartite graphs:

Definition 7.5.1 (Bipartite graphs)Let B : Set × Set → Set be the functor defined byc B(S, T ) := S × T + T × Sand

B(f, g)(u, v) :={

(f(u), g(v)) if u ∈ S, v ∈ T(g(u), f(v)) if u ∈ T, v ∈ S

Then, comma category Bgraph = (Id,B) is the category of bipartite graphs.

From this, a bipartite graph is a graph (E,S+T, c) with c : E → S×T +T×S.A morphism is a triple (ge : E1 → E2, gS : S1 → S2, gT : T1 → T2):

E1 S1 × T1 + T1 × S1c1 -

E2 S2 × T2 + T2 × S2c2-

gE

?B(gS , gT )

?

=

More precisely, morphisms of Bgraph are pairs the second component is a pairagain: (ge : E1 → E2, (gS : S1 → S2, gT : T1 → T2)). They map places toplaces and transitions to transitions.

Figure 7.3 shows a simple producer/consumer system. Places are labelled witha token (•) or they are not labelled (◦). Firing a transition means changing

cThe product of two categories A×B is a category the object set of which is ObjA×ObjB .The morphisms are constructed component by component.

Page 17: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.5. PETRI NETS 17

t1

s1 :•����

s2 :◦����t2 s3 :•�����

��� @@@R

���@

@@I

- - t3

����

s4 :◦����@

@@Rt4

���

s5 :•����@@@I

Figure 7.3: A condition/event net

s3 :•����s5 :•����

t3

s4 :◦����AAU

���

?

pl

←−

s3 :x����s5 :y����

s4 :z����pr

−→

s3 :◦����s5 :◦����

t3

s4 :•����AAU

���

?

Figure 7.4: Example of a Petri net production

labels. Therefore, usually labelled graphs are not suited since morphisms ofLgraph do not allow relabelling. Kreowski has solved the problem by repre-senting the tokens on a place as a bundle of new nodes and new edges [26]. Theidea depicted in Figure 7.4 uses a structured alphabet and modifies definitiongiven by Parisi-Presicce et al. [30]:

Definition 7.5.2 (Partially ordered labelling)(a) Let (D,v) be a partial order. A function h : D → D is nondecreasing if

and only if it satisfies d v h(d) for all d ∈ D. Category POD has (D,v)as object and all nondecreasing functions h : D → D as morphisms wherecomposition and identities are given by the underlying set functions.

(b) Consider forgetful functor D : POD → Set defined by D((D,v)) := D andD(h) := h Then, category of PO-labelled graphs is the comma categoryPOgraph = (W,D)

Page 18: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

18 DESCRIBING SYSTEMS OF PROCESSES BY . . .

Let D be a set of atoms and variables and v such that x is a variable or x = yif x v y holds, i.e., a variable may be replaced by another variable or by anatom, whereas atoms must not be replaced:

V D((D,v))m -

V ′ D((D,v))m′

-

fV

?

D(h)?

=

V Dm -

V ′ Dm′

-

fV

?h

?

=

Our definition differs from Parisi-Presicce’s in that it requires all occurrencesof a variable to be replaced by the same atom or variable. In the case ofa condition/event net, however, this makes no problems since we may usedifferent variables to label different places. We allow variables to be replaceeither by • or by ◦. To make the labelling category cocomplete, we may add anelement > indicating forbidden “nets”. The production of Figure 7.4 describesfiring transition t3.

Definition 7.5.3 (Category of condition/event nets)(a) We use a partial order (D,v) with v v • and v v ◦ for all variables v

and • v >, ◦ v >. D : POD → Set is as above.(b) Let TL be a set of transition labels. Then, we consider functor PT : 1→Set defined by PT (•) := TL and PT (id•) := idTL.

(c) Let WV S : Bgraph → Set and WV T : Bgraph → Set be the functorsselecting places and transitions of a bipartite graph, respectively. Then,we define the category of Petri nets to be the two-step comma categoryPnet = (WV S ,WV T ,D,PT ).

In detail, we get the following diagrams:

S + T D + TLmS + mT-

S′ + T ′ D + TLm′

S + m′T

-

fS + fT

?h + idTL

?

S DmS -

S′ Dm′

S

-

fS

?h

?

T

TL

mTPPPPPq

T ′ m′T�����1

fT

?

= = =

This means that morphisms do not change transition labels. Therefore, theproduction of Figure 7.4 can be applied only to transition t3. This transitionnode, however, is not included in the gluing graph between the left-hand sideand the right-hand side of the production. Therefore, the gluing condition [6,p. 171] ensures that all places adjacent to the transition are mentioned in the

Page 19: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.5. PETRI NETS 19

satisfied

{p1, p2, p3, p4, p5}

��

��

��*

� �{f1, f2, f3, f4, f5}-

� � hungry

HH

HH

HHj-

{}

��

��

���� �HHH

HHHY

Figure 7.5: Dining philosophers

vl1 :{p1}

hungry

@@R

� �

vl3 :{}?� �

vl2 :{f1, f2}�

� � vr1 :{}

hungry

@@R

� �

vr3 :{p1}

?� �

vr2 :{}

��

� �pl

←− pr

−→

v1 :{}� �

v3 :{}� �v2 :{}

� �

Figure 7.6: p1 is hungry

production. It is easy to prove that firing sequences correspond to derivationsif we restrict applicability of productions to injective redices.

We now consider place-transition nets the places of which are labelled withsets of distinguishable tokens. Figure 7.5 shows the well-known example ofdining philosophers. All the philosophers pi are thinking and all the forksfj are available. In general, we assume a base set S. Multisets M over Sare sets consisting of elements of S where multiple occurrences are allowed.M1 ⊆ M2 if and only if each element e is in M2 at least as many times as inM1. Let M(S) be the set of multisets over S. Of course, multiset inclusion is anondecreasing function and can be used to define a partially ordered labelling.In the production of Figure 7.6, however, all gluing nodes have the same labelwhereas the image nodes have different labels. We use a trick due to Hess andMayoh [22] and extend the labels by adding indices from an index set I. Wedefine h : I ×M(S)→ I ×M(S) to be nondecreasing if the second componentis, i.e., h(i,m) = (h1(i,m), h2(i,m)) ⇒ m ⊆ h2(i,m). In Figure 7.6, we mayuse node identifiers vi, etc., as indices.

Page 20: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

20 DESCRIBING SYSTEMS OF PROCESSES BY . . .

Definition 7.5.4 (Multiset-labelled graphs)We consider the category POI

M(S) the object of which is I ×M(S) and themorphisms of which are the nondecreasing functions. Furthermore, let ML :POI

M(S) → Set be the forgetful functor. Then, the category of multiset-labelledgraphs is comma categoryMgraph = (W,ML).

If two nodes are labelled with same index and same multiset, then the imagenodes must have same label. If either the indices or the multisets are different,then the image nodes may (but need not!) have different labels. Mgraph iscocomplete. Proof is a special case of the proof given in [36]. In that paper, weconsider graphs instead of multisets and graph morphisms instead of nonde-creasing functions. A multiset, however, may be seen as a discrete graph thenode labels of which are the elements of the multiset; nondecreasing functionscorrespond to injective graph morphisms. Parallel independence theorem isalso treated there.

Definition 7.5.5 (Category of place/transition nets)Let WV S : Bgraph → Set and WV T : Bgraph → Set be the functors selectingplaces and transitions of a bipartite graph, respectively. Then, we define thecategory of place/transition nets to be the two-step comma category PTnet =(WV S ,WV T ,PS ,PT ) where PS : POI

M(S) → Set is the functor defined byPS(I ×M(S)) = I ×M(S), PS(h) = h, and PT is as in Definition 7.5.3.

If we restrict redices to morphisms the underlying graph morphisms of whichare injective, we get a 1-1-correspondence between derivations and firing se-quences. It is straight-forward to show that a transition is activated under acertain marking if and only if the corresponding production is applicable andthat notion of concurrency coincides with parallel independence:

Lemma 7.5.6 (Derivations and firing sequences)Given a marking, two occurrences of productions are parallel independent ifand only if the corresponding transitions are concurrent.

The interested reader can find a more detailed discussion of relationship be-tween Petri-net theory and graph transformations in [4]. Especially, Corradinidiscusses computation-based semantics of Petri nets. Please note that tran-sitions may be deleted when translating a Petri net into the graph-grammarframework; this shows that Petri-net computations essentially correspond torewriting discrete graphs.

Page 21: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.6. STATECHARTS 21

Sys

Snd

?

Se

?

6

Wait

Re-

?

Wa

Rcv

?

Int

?

I1-

iH?

I2

�I3

6

?

6

Ac

Figure 7.7: Example of a statechart [28]

7.6 Statecharts

Statecharts is a visual formalism that offers facilities for hierarchically structur-ing states [20]. Maggiolo-Schettini and Peron have defined semantics of state-charts by graph rewriting [28]. Here, we restrict discussion to simulating controlflow. We consider an example, a system consisting of a sender and a receiver(Figure 7.7). The sender Snd communicates a message to the environment;then, it waits (Wa) for an acknowledgment from the receiver Rcv and repeats(Re) the message if it is not acknowledged. The receiver performs some inter-nal activities (Int) until a message is available. When this happens, it maycontinue local activity or it may service communication request sending ac-knowledgment and then resume its internal activity at the stage at which ithas been interrupted.

States are depicted as boxes, transitions are represented by arrows. Dashedlines between two or more subgraphs indicate that the subgraphs describeparallel processes. Usually, each arrow is labelled with a pair defining the eventthat causes the transition to take place and an action, i.e., a set of events tobe broadcast. We omit these labels for the moment. When a transition is

Page 22: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

22 DESCRIBING SYSTEMS OF PROCESSES BY . . .

performed, control is transferred to the state the arrow points to. If it containsa state graph again, this subgraph is entered and the successor state is its initialstate by default (usually characterized by an arrow stub) or it is determined byhistory node (H) if one exists. If the successor state contains parallel processes,this applies to all the subprocesses, simultaneously.

Figure 7.8 shows some of the productions describing control flow in the ex-ample of Figure 7.7. We introduce a special node (C) to indicate the statethat control has reached. Production (a) presents start situation; control hasreached the outermost node of our example and is transferred to both sub-processes. Since control node is explicitly set to point to initial states of thesubprocesses, description by graph transformation does not need the arrowstubs. The next production transfers control to the internal activity of receiverby substituting control node for history node, thus resuming internal activity.Replacing H-node by C-node is not changing the label of a node, but remov-ing one node from the graph and inserting another one, i.e., this node is nota gluing node. (c) describes a local transition within Int. The last productionresponds to receiving a message; control node within Int becomes history nodeand control is transferred to Ac. To describe what happens, we need not depictcomplete state graphs or subgraphs. It is sufficient to include those nodes thatare changed or that are used to describe changing a connection.d Furthermore,it is not necessary to mention the outermost nodes on the left-hand and on theright-hand sides of the productions.

Now, it becomes clear that graph transformation approach does not explicitlyneed edge labels. Events that cause a transition to take place are put intonodes that are mentioned on the left-hand side of one or more productions,thus allowing them to be applied. Messages to be broadcast are generated bysuitable right-hand sides.

Of course, we may describe control flow by productions that do not depend onthe concrete example. Figure 7.8(c) can be seen as a production applicable toall transitions. In this case, we have to replace node labels by variables in theproductions and to use nondecreasing functions as morphisms (cf. Definition7.5.2). Case discrimination between resuming an activity via history node andrestarting it at initial node can be implemented by introducing a special node(I) pointing to the initial state at the beginning. It is then used as an alternativeto H.

How to model Statecharts in comma category approach? We borrow Pratt’sconcept of hierarchical graphs [32]. We restrict discussion to node labelling.

dWe have omitted the gluing graphs that are trivial in the cases we consider here. Moreprecisely, all nodes but those labelled with C, H, msg are gluing nodes.

Page 23: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.6. STATECHARTS 23

(a) iC?

Snd

Se

Rcv

Int

::=

Snd iC?

Se

Rcv iC?

Int

(b) iC?

Int iH?

I2

::=

Int iC?

I2

(c) iC?

I2- I3

::=

iC?

I2- I3

(d)Int iC

?

I2

?

6

Ac

msg

::=

Int iH?

I2

?

6

Ac iC�

Figure 7.8: Some productions describing control flow in Statecharts example

Even if it would be necessary to label edges, too, this can be done separatelybecause of Definition 7.4.6. We start from LgraphM with M being a set ofidentifiers; furthermore, we assume a set of primitive actions P . In Figure 7.7,Se, Re, Wa, Ac, I1, I2, and I3 are primitive actions, Snd, Rcv, Wait, Int, and

Page 24: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

24 DESCRIBING SYSTEMS OF PROCESSES BY . . .

Sys are identifiers. To simplify the diagram, we have not explicitly assignedidentifiers to nodes that contain a primitive action, although this is necessary todefine a Statecharts diagram to be a function σ : M → ObjLgraphM

+P ′. Thisfunction assigns either a primitive action or a labelled graph to an identifier,thus implicitly to the nodes labelled with this identifier. Please note that this isa two-level definition: First, we define labelled graphs; then, we assign primitiveor compound actions to the nodes. (Of course, different nodes may contain thesame action.) We consider the right-hand part of Figure 7.7: It is a graphconsisting of two nodes, the first of which is labelled with Int, the second withan identifier not mentioned in the figure. σ assigns a graph to Int and theprimitive action Ac to the unkown identifier. A discrete graph consisting oftwo nodes labelled with Snd and Rcv, respectively, is assigned to Sys.

Now, we sum up this discussion formally assuming a sufficiently large set I ofidentifiers we may take subsets M from.

Definition 7.6.1 (Statecharts)(a) Let I be a set of identifiers and ST I the category the only object of which

is the set of I-labelled graphs and morphisms of which are the mappingsassigning a G′ to G such that there is a label preserving injection G 7→ G′

in LgraphI .(b) Furthermore, let be P a set of primitive actions, P ′ = P ∪ {C,H}, POI

the category with subsets of I as objects and inclusions as morphisms.(c) We consider I : POI → Set with I(M) = M and I(M ⊆M ′) being natural

injection from M into M ′ and St : ST I + 1→ Set defined by

St(G) = G St(•) = P ′

St(f) = f St(id•) = idP ′

Then, category of statecharts is comma category Stcharts = (I,St).

We have to make a short remark on POI . There exists at most one mor-phism between two objects; thus, each morphism is both an epimorphism anda monomorphism, but not necessarily an isomorphism. Trivially, POI is co-complete and I is cocontinous.

Together with definition of comma category, definition of statecharts yields thefollowing diagram reflecting our previous considerations:

Page 25: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.7. PARALLEL LOGIC PROGRAMMING 25

M ObjLgraphI+P ′σ -

M ′ ObjLgraphI+P ′

σ′-

⊆?

f + idP ′

?=

This means that a statechart consists of a (finite) set M ⊆ I of identifierstogether with a function σ assigning graphs or primitive actions to them. Mor-phisms preserve identifiers as well as primitive actions; they map graphs intoother graphs preserving identifiers on this level, too, because we use LgraphI .Please note that f is not a graph morphism, but a mapping between sets ofgraphs. As a consequence of this, a morphism of Stcharts can not map twonodes labelled with the same graph to nodes labelled with different graphs.We have not yet seen an example that needs this; if, however, such a situationoccurs, we may use additional indices as we have done in Definition 7.5.4.

We have to take into consideration one more point: We need some top-levelnodes. A usual statechart has exactly one top-level node surrounding one ormore graphs. In productions, we may have more than one top-level node (cf.Figure 7.8(d)). Without loss of generality, we can define that all identifiers ofM that do not occur as labels in the graphs of σ[M ] indicate top-level nodes.Contrary to Harel’s original definition, our version allows recursion. Therefore,outermost identifier may also occur inside of a graph. In this case, we doublethe node using different identifiers, thus distinguishing top-level node frominside node.

7.7 Parallel Logic Programming

On the level of expression evaluation, term rewriting [25] is a typical techniquerelated both to graph rewriting [1] and to parallelism. Two main lines werefollowed to represent terms by graphs: directed acyclic graphs and jungles, i.e.,hypergraphs satisfying some additional requirements [18]. These approachesare equivalent [5], but the jungle approach is more suited to be extended todescribe logic programming and may also be used to describe systems of pro-cesses in the next section.

We assume a fixed signature Σ = (S, Op, τ) where S is a set of sorts, Op is aset of function symbols (operations) and τ : Op → S∗ × S assigns a type toeach function symbol describing the sorts of the parameters and of the result.e

eFor simplicity, we forbid overloading.

Page 26: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

26 DESCRIBING SYSTEMS OF PROCESSES BY . . .

(a)

f

•t1

6

s1�� •

s2@@R

u

t16

v

t16

(b)

f

•t1

6

s1�� •

s2@@R

x

t16

g

•t1

6

s1��

s2

?

h

t16

•s1

?s2@@R

a

t16

y

t16

Figure 7.9: Jungles and term graphs

Furthermore, let X =⋃

s∈S Xs be a sorted set of variables. We extend τ byτ(x) := s⇔ x ∈ Xs.

Definition 7.7.1 (Categories of jungles)Let C be the category consisting of C = Op + X as object and morphisms ofthe form idOp +h with h : X → Op + X and let TE : C → Set be the forgetfulfunctor. Furthermore, we define a functor TV : 1 → Set by TV (•) = S andTV (id•) = idS . With WE ,WV : Cgraph → Set , we construct two-step commacategory (WE ,WV ,TE ,TV ) and define the category of jungles TgraphΣ,X tobe the full subcategory the objects of which satisfy

(a) (m∗V (s(e)),mV (t(e))) = τ(mE(e))

(b) (∀x ∈ X)(mE(e) = x ∧mE(e′) = x⇒ e = e′)

with s, t as in Definition 7.4.3 and mE ,mV as in 7.4.5.

The nodes of a jungle are labelled with sorts, whereas an edge represents eitheran operation or a variable. Definition results in that jungle morphisms preservefunction symbols and sorts, whereas a variable may be replaced by anothervariable or by a function symbol:

E1 Op + Xm1E -

E2 Op + Xm2E-

fE

?idOp +h

?=

V1

S

m1VPPPPPq

V2

m2V�����1fV

?

=

Page 27: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.7. PARALLEL LOGIC PROGRAMMING 27

Additional requirements define a subcategory ensuring a close relationship be-tween jungles and terms. First, we require that the nodes an edge visits describefunctionality of the operation corresponding to it: source nodes indicate thetypes of the parameters and the target node is labelled with result type. Thesecond condition ensures that all variables occur at most once in the jungle.Please note that the underlying category of graphs is Cgraph, i.e., each valuerepresented by a node is either the result of an unambiguously defined opera-tion or it is a variable.

Lemma 7.7.2 (Correspondence between jungles and terms [18])Each node v in a jungle represents a term ϑ(v) recursively defined by ϑ(v) =mE(e)ϑ∗(s(e)) where e is the unique hyperedge with t1(e) = v.

Each jungle, therefore, represents a set of terms, e.g., the jungle of Figure7.9(b) describes the set {f(x, h(a, y)), g(h(a, y), y)}. f, g, h, a, x, y are hyper-edges visiting the nodes as indicated by the numbered arrows where si pointsto i-th argument and t1 is directed to result. The nodes are labelled with aunique sort denoted by •-symbol. Conversely, a single term can be representedby many non-isomorphic jungles, since identical subterms may either coincidewith one another or not. This ambiguity does not affect derivability; the inter-ested reader is referred to [18]. Here, we rest content with the fact that we canconstruct a jungle from a set of terms straight-forwardly.

Every jungle morphism f : J1 → J2 induces a substition θf defined by

(∀e | mE(e) ∈ X)(θf (mE(e)) = ϑ(fV (t1(e))))

In the example of Figure 7.9, we have a morphism from jungle (a) to jungle(b). The induced substitution is given by u 7→ x and v 7→ h(a, y). Since junglemorphisms are allowed to replace variables by operation symbols, but not anoperation symbol by another one, TΣ,X is not cocomplete. With respect to gen-erative power of graph transformation systems, however, it suffices to considerproductions with discrete K [10]. Restricting discussion to these productions,we get a close relationship to term rewriting, whereas the situation is morecompicated if we do not assume this:

Theorem 7.7.3 (Existence of pushouts [5])Let K be a discrete hypergraph with nodes v1, v2, . . . , vk and p : K → B andg : K → C hypergraph morphisms. The pushout of p, g exists if and only if

(ϑ(p(v1)), ϑ(p(v2)), . . . , ϑ(p(vk))) and (ϑ(g(v1)), ϑ(g(v2)), . . . , ϑ(g(vk)))

have a most general unifier.

Page 28: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

28 DESCRIBING SYSTEMS OF PROCESSES BY . . .

mode qsort(in_list?, out_list^),part(pivot?, in_list?, left^, right^),concat(left?, right?, out_list^).

qsort(cons(h,t), s) :- part(h, t, l, r),qsort(l, ls), qsort(r, rs),concat(ls, cons(h,rs), s).

qsort(nil, nil).part(u, cons(v,t),cons(v,l),r) :- v<u: part(u,t,l,r).part(u, cons(v,t),l,cons(v,r)) :- u=<v: part(u,t,l,r).part(u, nil, nil, nil).concat(cons(h,t), r, cons(h,rt)) :- concat(t, r, ct).concat(nil, r, r).

Figure 7.10: Parlog version of quicksort [3]

Since this theorem takes into consideration only the terms related to nodesthat are images of gluing graph, it is easy to see that Theorem 7.2.5 still holds.

Lemma 7.7.4In category of jungles TgraphΣ,X , parallel independence theorem holds.

Proof outlinePushout (8) and (9) in Figure 7.1(b) exist because gluing graphs are the sameas in the given derivation steps and C0 is between Ki and Ci for i = 1, 2.This results in existence of matching substitutions from the terms representedby C0 to the terms of Ci that can be used to extend the unifiers that existbecause of the pushout diagrams (2) and (4). (Please note that we may choosevariable names in Br

i and Ci disjointly without loss of generality.) Similarconsiderations show that (8+10) and (9+10) exist, therefore, (10) from doublepushout lemma. utNow, we extend the jungle approach to describe logic programs. We demon-strate the technique by considering an extract from a parallel version of quicksort written in Parlog (Figure 7.10). In addition to constructs that are com-mon practice in logic programming, Parlog introduces mode declarationsconstraining unification. An argument annotated with a question mark signi-fies that a nonvariable term appearing in that argument position in the head ofa clause can only be used for input matching, whereas circumflex annotationmeans that a nonvariable term can only be used for output matching against avariable argument. In the first clause of the example, l and r are used as output

Page 29: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.7. PARALLEL LOGIC PROGRAMMING 29

qsort

1l : list

s1���

2l : list

t2@@@R

1 : list

2 : list

part

list

s2���

elmt

s1

?list

t4@@@R

list

t3H

HH

HHj

cons

s26

s1�

���

1r : list

t3?

qsort

s16

list

t2?

qsort

s16

list

t2?

cons

s1

6

s2�

���

list

t3?

concat

s26

s1

2r : listt3 -

pl

←− pr

−→

Figure 7.11: Production corresponding to first rule of Ex. 7.10

qsort

1l : list

s1���

2l : list

t2@@@R

1 : list

2 : list nil

1r : list

t16

nil

2r : list

t16pl

←− pr

−→

Figure 7.12: Production corresponding to second rule of Ex. 7.10

arguments of part and as input to qsort. Mode declarations of Parlog area means to establish communication channels between predicates. Therefore,we may treat predicates similar to operations and represent them by hyper-edges. A new situation arises from the fact that predicates in a logic programare not restricted to having exactly one result argument. E.g., part has twooutput arguments and there may be predicates that only compare some inputarguments. Therefore, we modify definition of jungles by assuming weaker τ :

Definition 7.7.5 (Category of enriched jungles)We assume a signature Σ with τ : Op → S∗ × S∗ and construct two-step

Page 30: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

30 DESCRIBING SYSTEMS OF PROCESSES BY . . .

comma-category (WE ,WV ,TE ,TV ) as in Definition 7.7.1. PLgraphΣ,X is thefull subcategory the objects of which satisfy:

(a) (m∗V (s(e)),m∗

V (t(e))) = τ(mE(e))(b) (∀x ∈ X)(mE(e) = x ∧mE(e′) = x⇒ e = e′).

Following Corradini et al. [5], we translate clauses into an equivalent canonicalform introducing a set of variables not occurring in the clause, replacing non-variable arguments in the head by these variables, and unifying them on theright-hand side with the original arguments:

qsort(u, s) :- u=cons(h,t), part(h, t, l, r),qsort(l, ls), qsort(r, rs),concat(ls, cons(h,rs), s).

qsort(u, s) :- u=nil, s=nil.

A clause in canonical form can obviously be represented by an enriched jungleproduction of a special form:

Definition 7.7.6 (Contextfree productions [5])A production p = (Bl pl

←− Kpr

−→ Br) in PLgraphΣ,X is called contextfree ifand only if

(a) Bl consists of a single hyperedge connected to m distinct nodes,(b) K is a discrete graph of m nodes,(c) pl is a bijection on nodes.

Figure 7.11 shows contextfree production corresponding to the first clause ofExample 7.10. It is applied to a jungle representing a non-empty list (Figure7.13). On the right-hand side, part can be replaced in the next step providingone of the qsort-hyperedges with the first element of its parameter list. There-fore, replacing this qsort and further recursive calls of part may be performedin parallel.

Lemma 7.7.7 (Existence of pushout complements)If we have a contextfree production in PLgraph and a redex Bl → G, then thepushout complement exists and is unique.

This lemma is an immediate consequence of the definition, but the problem ofnon-existing pushout-complements on the left-hand side of a derivation step isonly shifted to the righ-hand side: Production of Figure 7.12 is not applicableto left-hand graph of Figure 7.13 since the right-hand pushout does not exist.(nil can not be unified with cons.)

Although representation is slightly different from [5], we get the same result:

Page 31: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.8. SYSTEMS OF PROCESSES 31

qsort

1 : list

s1��

2 : list

t2@@R

r

t16

cons

t36

elmt

s1

?list

s2@@R

a

t1 6

cons

t36

elmt

s1

?list

s2@@R

b

t1 6

nil

t16

part

list

s2�

����elmt

s1�

�list

t4@

@Rlist

t3HH

HHj

cons

t3�

���*

elmt

s1

?list

s2@@R

b

t1 6

nil

t16

cons

s26 s1�

��

1 : list

t3?

a

t1@

@I

qsort

s16

list

t2?

qsort

s16

list

t2?

cons

s1

6

s2����*

list

t3@

@R

concat

s2

@@I

s1

����������

2 : listt3�

Figure 7.13: Example of a derivation step in logic program

Theorem 7.7.8 (Logic programs and graph transformation)A logic program, i.e., a set of definite clauses, can be represented by a graphtransformation system consisting of contextfree productions in PLgraph suchthat derivations correspond to computations and vice versa.

One of the advantages of considering contextfree productions is that thereexists a well-elaborated theory of contextfree hyperedge replacement [8,17].

The concept we followed here enriches jungles by adding hyperedges represent-ing logic predicates. We may see this hypergraph in some sense as a bipartiteone: Some hyperedges are used to construct terms, some others correspond toprocesses. In the next section, we distinguish between these two roles hyper-edges may play.

7.8 Systems of Processes

To describe systems of processes, we use an actor-like style. The basic elementsof an actor system are actors and messages. Actors are active objects whichprocess messages. Processing a message may result in changing the state ofthe actor, creating new actors, and sending messages to other actors. First,

Page 32: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

32 DESCRIBING SYSTEMS OF PROCESSES BY . . .

1l : Q(cons(x, y))

msort

δ?

� �

2l : Q(⊥)

ρ?� �

1 : Q(cons(x, y))� �

2 : Q(⊥)� �

1r : Q(cons(x, y))

δ?

� �split

ρleft��

ρright@@R

Q(⊥)

msort

δ?

� � Q(⊥)

msort

δ?

� �

Q(⊥)

ρ?� � Q(⊥)

ρ?� �

mergeδleft

@@R δright

��

2r : Q(⊥)

ρ?� �

pl

←− pr

−→

Figure 7.14: Extract from merge sort: Sorting a nonempty list

Janssens and Rozenberg have translated this concept into the graph-grammarframework [23,24]: Actors and messages that are present at a given moment arerepresented by nodes. Each message has a unique destination actor indicatedby an edge from the message to the destination. An actor can send messagesto other actors it is acquainted with; special edges define these acquaintances.

We use a slightly different approach describing the state of a system of processesby a hypergraph [35]. As Castellani, Degano, and Montanari have proposed[2,7], processes (actors) correspond to hyperedges labelled with the actor’sname, whereas communication is implemented by nodes. (Lateron, we intro-duce additional state nodes.) These communication nodes implicitly describeacquaintances: If two actors visit the same node, they are acquainted with oneanother. At every moment, such a node may or may not contain messages.This is a matter of labelling and will be discussed later. This communicationconcept looks quite symmetrical; hypergraph approach, however, allows us todistinguish between source nodes and target nodes of an edge. If we want tointerprete acquaintances asymmetrically, i.e., in accordance with definition ofactor systems, we may define that an actor “knows” only those actors whichit is connected to by a target node.

Page 33: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.8. SYSTEMS OF PROCESSES 33

1l : Q(cons(e, u))

split

δ?

� �

2l : Q(l)

ρleft ���� � 3l : Q(r)

ρright@@@R� �

1 : u� �2 : Q(l)

� �3 : Q(r)

� �pl

←− pr

−→

1r : Q(u)

split1

δ?

� �

2r : Q(appd(l, e))

ρleft ���� �3r : Q(r)

ρright@@@R� �

Figure 7.15: Merge sort: First element is sent to the left-hand side

We illustrate the concept by first looking at an example. We choose an extractof merge sort.f In Figure 7.14, an actor msort creates four new actors (split,merge, and two new instantiations of msort) and defines acquaintances, i.e.,communication channels. Furthermore, it forwards the message it has got andmakes the sender of this message acquainted with actor split causing the senderto direct further messages to split, immediately. Moreover, it forwards theacquaintance with the actor to receive the sorted list to actor merge making itresponsible of reporting the result. Finally, this production causes actor msortto be terminated and to be replaced by the system of actors defined on theright-hand side of the production.

In figures, we depict hyperedges (actors) by rectangles and communicationnodes by ovals. For mnemonic reasons, we do not indicate the order in whichthe nodes are visited by numbers, but we use expressive “indices”: δ-arrowsdenote communication nodes the process reads from and ρ-arrows determineoutput nodes. If the process is connected to more than one node of the samekind, we distinguish them by additional indices, e.g., δleft and δright. (Likewise,direction of arrows indicates data flow to the reader and is of no importanceto the formal model.) To define a 1-1-relationship between the figures and theformal model, it is sufficient to associate a fixed order of indices with eachnonterminal hyperedge label, e.g., (δ, ρleft, ρright) with split.

In this first example, gluing nodes preserve labels. Thus, we have no problems.In the next example (Figure 7.15), labels of gluing nodes change, and we haveto ask for suitable labels in the gluing graph. Gluing nodes on hypergraphlevel and gluing nodes on jungle level, however, are different things. It is notnecessary to label nodes of the gluing graph in a detailed way. For example,we may omit Q without changing the result, but this will become clear when

fMerge sort is not a good example for parallel processes because of the bottlenecks, butit is small enough to be used here.

Page 34: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

34 DESCRIBING SYSTEMS OF PROCESSES BY . . .

1l : Q(cons(x, s))

merge

δleft

@@@R

� � 2l : Q(s′)

δright

���

� �

3l : Q(s′′)

ρ?� �

1 : s� �2 : s′

� �3 : s′′

� �pl

←− pr

−→

1r : Q(s)

merge1

δleft

@@@R

� � 2r : Q(s′)

δright

���

� �

4r : L(x)

λ ���

3r : Q(s′′)

ρ@@@R� �

Figure 7.16: Merge sort: Take first element from left-hand queue

1l : Q(s)

merge1

δleft

@@@R

� � 2l : Q(cons(y, s′))

δright

���

� �

4l : L(x)

λ ���

3l : Q(s′′)

ρ@@@R� �

pl

←− pr

−→

1r : Q(s)

merge3

δleft

@@@R

� � 2r : Q(s′)

δright

���

� �

4r : L(x), R(y)

λ ���

3r : Q(s′′)

ρ@@@R� �

1 : s� �2 : s′

� �4 : x

3 : s′′� �

Figure 7.17: Merge sort: Take next element from right-hand queue

discussing jungle level.

In Figure 7.15, actor split is replaced by actor split1 without changing thestructure of the system. The names of the actors are used here in the senseof nonterminal symbols in formal language theory. The meaning is that theactor changes its state. (We may also say that it changes its computationalbehaviour.) As long as a finite number of states is involved, this works. Thestate of an actor, however, is often described by local variables that differentvalues may be assigned to. Figure 7.16 and Figure 7.17 give examples. Todescribe local states, we use another kind of nodes, the state nodes, depicted bydashed rectangles in the figures. Each actor hyperedge visits exactly one suchnode characterized by a λ-arrow. If there are no local variables with definedvalues, we omit state node in the figure for reason of clarity. Furthermore, wedo not consider local computations changing only the contents of a state node[18,31].

Page 35: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.8. SYSTEMS OF PROCESSES 35

Specification Σ = Σelmt+

nil : → list⊥ : → list appd(⊥, e) = cons(e,⊥)cons : elmt× list → list appd(cons(e′, l), e) = cons(e′, appd(l, e))appd : list× elmt → list close(⊥) = nilclose : list → list close(cons(e′, l)) = cons(e′, close(l))L,R : elmt → locQ : list → msg

Figure 7.18: Specifying communication behaviour and states

Now, we are ready to define the structure of process systems:

Definition 7.8.1 (Category of process structures)We consider functor P : Set ×Set → Set defined by P(VC , VS) := V +

C ×VS andP(fC , fS) := (f+

C , fS). Then, we define the category Pgraph of process struc-tures to be the subcategory of (IdHgraph ,P) restricting morphisms to injections.

VC and VS denote the set of communication nodes and the set of state nodes,respectively. Morphisms ensure that state nodes are mapped onto state nodesand communication nodes onto communication nodes:

Id(E1) P(V1C , V1S)c1-

Id(E2) P(V2C , V2S)c2-

Id(fE)?

P(fV C , fV S)?

=

E1 V +1C × V1S

c1 -

E2 V +2C × V2Sc2

-

fE

?(f+

V C , fV S)?

=

Please note that this definition does not use hypergraphs with sources and tar-gets although this would make sense in order to distinguish between communi-cation nodes an actor reads from and other nodes it writes into. (Hypergraphsare allowed to visit a node twice using it both as input node and output node.)If we are interested in doing so, we have to replace P(VC , VS) := V +

C × VS byP(VC , VS) := V ∗

C ×V ∗C ×VS , etc. (This would make the formalism less readable

without showing more insight.)

We now switch over to discussing node labels. Communication nodes as well asstate nodes are labelled with terms. In general, we may use different signaturesfor communication nodes and state nodes and then apply two-step comma-category trick; for reason of space, however, we here use only one signature

Page 36: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

36 DESCRIBING SYSTEMS OF PROCESSES BY . . .

putting together all the operations we need in our example. In Figure 7.18,we specify an asynchronous communication mechanism queuing messages atdifferent entries. In addition to the usual operations on lists, we introduce ⊥and close. Whereas nil means that last element of the list has been processedand connection may be closed, ⊥ indicates that the queue is empty for themoment, but not yet finished. Operation close terminates a list such that nomore elements may be appended. Q defines a term to be a message. L and Rare used in local states to characterize elements read from the left-hand andright-hand side, respectively.

The signature we use to define labels of communication nodes determines thetype of communication. In the present example, we have specified an asyn-chronous communication processing messages according to FIFO strategy. Ifwe want to model synchronous communication, e.g., Ada’s Rendez-vous con-cept [35], we use a signature providing only elements, not queues. On the otherhand, we may specify a bag; then we get a communication of Linda style [15].

In general, a node is labelled with a set of terms; node 4r in Figure 7.17 is anexample of a node labelled with more than one term. But we can not label nodesof a production with arbitrary terms independently, since we want variables tobe consistently replaced in all node labels such that we can “send” expressionsto new nodes and unify terms by identifying the nodes they are the labels of, aswe have done, e.g., in Figure 7.16 and Figure 7.17. (This is strongly related toattributed grammars, but we can not go into the details here.) Therefore, weconsider the labels to be defined by a jungle which we regard as a global datastructure. This concept also meets our graph transformation point of view.Furthermore, the case of a set of terms is included, since a subjungle is notnecessarily connected.

A jungle J is called a subjungle of J if EJ ⊆ EJ , VJ ⊆ VJ . (Since J is a jungle,at least the nodes visited by edges of EJ must be in VJ .) Let S(J) be the setof all subjungles of J . If j : J1 → J2 is a jungle morphism, jS : S(J1)→ S(J2)denotes induced mapping.

Definition 7.8.2 (Category of process states)We consider a set N of (nonterminal) symbols and two labelling functors PSE :1→ Set and PSV : TgraphΣ,X → Set defined by

PSE(•) = N PSE(id•) = idN

PSV (J) = S(J) PSV (j) = jS

Then, two-step comma category (WE ,WV ,PSE ,PSV ) with selecting functorsWE ,WV : Pgraph → Set is the category ProcStates of process states.

Page 37: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.8. SYSTEMS OF PROCESSES 37

This definition means that we have the following diagrams the first of whichmay be interpreted as an abbreviation:

E1 + V1 N + S(J1)m1E + m1V -

E2 + V2 N + S(J2)m2E + m2V

-

gE + gV

?idN +jS?

=

E1

N

m1EHHHj

E2

m2E���*gE

?

=

V1 S(J1)m1V -

V2 S(J2)m2V-

gV

?jS?

=

Remark:As in Definition 7.5.4, we may add a set I of indices to allow nodes with thesame label to be mapped to nodes with different labels as long as the originallabel may be mapped to all the image labels. utA process state consists of a hypergraph, a jungle and two mappings assigninga symbol to each hyperedge and a subjungle to each node. A process statemorphism is determined by a hypergraph morphism together with a junglemorphism. At this point, we gain benefit from Corollary 7.3.4 since it followsfrom our considerations in Section 7.7 that parallel independence theorem holdsfor jungles although this category is not cocomplete.

If we want to embed, e.g., left-hand side of the production in Figure 7.16 into ahost graph, the image of node 1l must be labelled with a jungle which in somesense “contains” Q(cons(x, s)). The jungle represented by this term must bea subjungle of the host label, i.e., host label must contain hyperedges labelledwith Q and cons, whereas x and s may be replaced by other terms. Introduc-ing function symbol Q ensures that label of 1l is mapped to the outermostoccurrence of cons in the label of image node, i.e., x is unified with the firstelement of the message queue.

In Figure 7.16, variable x is not mentioned in the labels of gluing graph, al-though its value must be transferred to derived graph. But it is a gluing nodeof the jungle production. Figure 7.19 shows what happens on jungle level. Todistinguish gluing nodes in the hypergraph from those in the jungle, we useletters to identify the nodes of the jungles. a, al, and ar denote the jungle nodes

Page 38: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

38 DESCRIBING SYSTEMS OF PROCESSES BY . . .

1l:

Q(con

s(x,s))

merge

δle

ft

@@@R

��

2l:

Q(s ′)

δrig

ht

��� �

3l:

Q(s ′′)

ρ?

��

1:s

��

2:s ′

��

3:s ′′

��

pl

←−

pr

−→

1r

:Q

(s)merge1

δle

ft

@@@R

��

2r

:Q

(s ′)

δrig

ht

��� �

4r

:L

(x) λ�

��3

r:Q

(s ′′)

ρ@

@@R�

Q

s1?

(1l,m

sg)t2

6

cons

listt3

6

al:

elmt

s1?

bl:

list

s2

HH

HHj

Q

cl:

list

s1?

(2l,m

sg)t2

6

Q

dl:

list

s1?

(3l,m

sg)t2

6

L

(4r,loc)

t2

6

ar

:elm

t

s1?

Q

(1r,m

sg)t2

6

br

:list

s1?

Q

(2r,m

sg)t2

6

cr

:list

s1?

Q

(3r,m

sg)t2

6

dr

:list

s1?

pl

←−

a:elm

t

b:(1

,list)

c:(2

,list)

d:(3

,list)

pr

−→

Fig

ure

7.1

9:P

roductio

nofFig

ure

7.1

6to

geth

erw

ithits

asso

ciated

jungle

pro

ductio

n

Page 39: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.9. CONCLUSION 39

visited by hyperedge labelled with variable x in the gluing graph, the left-handside, and the right-hand side, respectively. Analogously, b corresponds to s, etc.In Figure 7.16, mnemonic notation 1l : Q(cons(x, s)) means that node 1l of thehypergraph is labelled with subjungle consisting of hyperedges Q and cons andthe nodes visited by these edges. In Figure 7.19, we have added graph-nodeidentifiers to indicate the jungle node the label of the graph node starts fromusing the correspondence defined in Lemma 7.7.2, e.g., (1l,msg) means thatthis is the node the label of graph node 1l starts from.

As we have already mentioned, edge labels are used like nonterminal symbolsand implicitly determine the computational behaviour of actors since appli-cability of productions depends on them. A more systematic solution maycombine the contents of state nodes with labelling of hyperedges, but formulasbecome more complicated. Furthermore, two-level comma-category construc-tion allows to subdivide the set of state nodes or the set of communicationnodes again in order to use different signatures.

As we have already mentioned, a disadvantage of mergesort example is itsbasically sequential nature. It would be of interest to consider a system of pro-cesses that cooperate in constructing the result, especially, parallel algorithmson graphs seem to be a fruitful area.

7.9 Conclusion

In this chapter, we have studied some aspects of applying the double-pushoutapproach to simulate systems of processes. We discussed Petri nets as a repre-sentative of static process structure with synchronous communication, whereasparallel logic programming and process systems communicating via channelslead to dynamic process structure and asynchronous communication. Discus-sion of statecharts has shown that a description using fundamental methodscan easily suggest interesting extensions, for example, extending statecharts toallow recursion. We could show that very different models can be consideredas instances of a generic concept. This unified view is a main advantage ofcomma-category approach.

Further research can follow two lines. On the one hand, we can start fromwell-understood models such as Petri nets and then investigate notions typi-cal of this model with respect to a more general framework in order to applythem to other models. On the other hand, it may be of interest to transferresults already discussed in the context of double-pushout approach to differ-ent models of process systems. Distributed graph transformation [38,39] wouldbe a promising topic, as well as amalgamating derivation steps may result in

Page 40: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

40 DESCRIBING SYSTEMS OF PROCESSES BY . . .

an appropriate graph-transformation description of massively parallel systems.Another line of research concerning distributed systems, which started from[2,7] as we did, considers a kind of graph rewriting based on context-free pro-ductions that are combined by means of synchronization mechanisms [29], i.e.,graph rewriting is first considered locally, and then global evolution of the sys-tem is defined. It would be a fruitful task to compare both approaches and tolook for properties common to them. This is left to a longer report.

Acknowledgment The author likes to thank Ingrid Fischer, Mark Minas,and Georg Schied for helpful comments on previous stages of this research.

References

1. H.P. Barendregt et al., Term graph reduction, Lecture Notes in ComputerScience 259 (1987), pp. 141-158

2. I. Castellani/U. Montanari, Graph grammars for distributed systems,Lecture Notes in Computer Science 153 (1983), pp. 20-38

3. K. Clark/S. Gregory, Parlog – Parallel programming in logic, ACMTransactions on Programming Languages and Systems 8, 1 (1986), pp. 1-49

4. A. Corradini, Concurrent computing – From Petri nets to graph gram-mars, Electronic Notes in Theoretical Computer Science 2 (1995), pp.245-259

5. A. Corradini/U. Montanari/F. Rossi/H. Ehrig/M. Lowe, Graph gram-mars and logic programming, Lecture Notes in Computer Science 532(1991), pp. 221-237

6. A. Corradini/U. Montanari/F. Rossi/H. Ehrig/R. Heckel/M. Lowe, Al-gebraic approaches to graph transformation - Part I: Basic concepts anddouble pushout approach, in: Handbook of Graph Grammars and Com-puting by Graph Transformation, vol. 1 (Ed.: G. Rozenberg), World Sci-entific, 1997, pp. 163-245

7. P. Degano/U. Montanari, A model for distributed systems based ongraph rewriting, Journal of Association for Computing Machinery 34,2 (1987), pp. 411-449

8. F. Drewes/H.J. Kreowski/A. Habel, Hyperedge replacement grammars,in: Handbook of Graph Grammars and Computing by Graph Transforma-tion, vol. 1 (Ed.: G. Rozenberg), World Scientific, 1997, pp. 95-162

9. H. Ehrig/M. Pfender/H.J. Schneider, Graph-grammars – An algebraicapproach, Proceedings of the Conference on Switching and AutomataTheory 1973, pp. 167-180

Page 41: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.9. CONCLUSION 41

10. H. Ehrig, Introduction to the algebraic theory of graph grammars (asurvey), Lecture Notes in Computer Science 73 (1979), pp. 1-69

11. H. Ehrig/A. Habel/H.J. Kreowski/F. Parisi-Presicce, Parallelism andconcurrency in high-level replacement systems, Mathematical Structuresin Computer Science 1 (1991), pp. 361-404

12. H. Ehrig/H.J. Kreowski, Pushout properties – an analysis of gluing con-structions, Mathematische Nachrichten 91 (1979), pp. 135-149

13. H. Ehrig/H.J. Kreowski/A. Maggiolo-Schettini/B.K. Rosen/J. Winkows-ki, Transformation of structures – an algebraic approach, MathematicalSystems Theory 14 (1981), pp. 305-334

14. H. Ehrig/H.J. Kreowski/G. Taentzer, Canonical derivations for high-levelreplacement systems, Lecture Notes in Computer Science 776 (1994),pp. 153-169

15. D. Gelernter, Generative communication in Linda, ACM Transactionson Programming Languages and Systems 7 (1985), pp. 80-112

16. J.A. Goguen/R.M. Burstall, Some fundamental algebraic tools for thesemantics of computation – Part 1: Comma categories, Colimits, Signa-tures and Theories, Theoretical Computer Science 31 (1984), pp. 175-209

17. A. Habel, Hyperedge replacement – Grammars and Languages, Ph.D.Thesis, University of Bremen, 1989, and Lecture Notes in Computer Sci-ence 643, 1992

18. A. Habel/H.J. Kreowski/D. Plump, Jungle evaluation, Lecture Notes inComputer Science 332 (1988), pp. 92-112, and Fundamenta InformaticaeXV (1991), pp. 37-60

19. A. Habel/R. Heckel/G. Taentzer, Graph grammars with negative appli-cation conditions, Fundamenta Informaticae XVII (1996)

20. D. Harel, Statecharts: A visual formalism for complex systems, Scienceof Computer Programming 8 (1987), pp. 231-274

21. H. Herrlich/G. Strecker, Category Theory – An Introduction, Allyn &Bacon, 1973

22. L. Hess/B.H. Mayoh, Graphics and their grammars, Lecture Notes inComputer Science 291 (1987), pp. 232-249

23. D. Janssens/G. Rozenberg, Basic notions of actor grammars – A graphgrammar model for actor computation, Lecture Notes in Computer Sci-ence 291 (1987), pp. 280-298

24. D. Janssens/G. Rozenberg, Actor grammars, Mathematical Systems The-ory 22 (1989), pp. 75-107

25. J.W. Klop, Term rewriting systems, in: Handbook of Logic in ComputerScience, vol. 2 (Eds.: S. Abramsky et al.), Oxford University Press, 1992,pp. 1-116

Page 42: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

42 DESCRIBING SYSTEMS OF PROCESSES BY . . .

26. H.J. Kreowski, A comparison between Petri-nets and graph grammars,Lecture Notes in Computer Science 100 (1981), pp. 306-317

27. M. Lowe/M. Korff/A. Wagner: An algebraic framework for the trans-formation of attributed graphs, in: Term Graph Rewriting – Theory andPractice (Eds.: M.R. Sleep et al.), Wiley, 1993, pp. 185-199

28. A. Maggiolo-Schettini/A. Peron, Semantics of full statecharts based ongraph rewriting, Lecture Notes in Computer Science 776 (1994), pp. 265-279

29. U. Montanari/F. Rossi, Graph rewriting and constraint solving for mod-elling distributed systems with synchronization, Lecture Notes in Com-puter Science 1061 (1996), pp. 12-27

30. F. Parisi-Presicce/H. Ehrig/U. Montanari, Graph rewriting with unifi-cation and composition, Lecture Notes in Computer Science 291 (1987),pp. 496-514

31. D. Plump, Evaluation of functional expressions by hypergraph rewriting,Ph.D. Thesis, Computer Science Dept., University of Bremen, 1993

32. T.W. Pratt, A hierarchical graph model of the semantics of programs,Proceedings AFIPS 1969 Spring Joint Computer Conference, vol. 34,pp. 813-825, Afips Press, Montvale, NJ., 1969

33. D.E. Rydeheard/R.M. Burstall, Computational Category Theory, Pren-tice-Hall, 1988

34. G. Schied, Uber Graphgrammatiken, eine Spezifikationsmethode fur Pro-grammiersprachen und verteilte Regelsysteme, Ph.D. Thesis, ComputerScience Dept., University of Erlangen, 1992

35. H.J. Schneider, Describing distributed systems by categorical graphgrammars, Lecture Notes in Computer Science 411 (1990), pp. 121-135

36. H.J. Schneider, On categorical graph grammars integrating structuraltransformations and operations on labels, Theoretical Computer Science109 (1993), pp. 257-274

37. H.J. Schneider, Graph grammars as a tool to define the behaviour ofprocess systems - From Petri nets to Linda, Preprints of 5th InternationalWorkshop on Graph Grammars (Williamsburg, VA., 1994)

38. G. Taentzer, Parallel and Distributed Graph Transformation, Ph.D. The-sis, Computer Science Dept., Technical University of Berlin, 1996

39. G. Taentzer/ M. Koch/I. Fischer/V. Volle, Distributed graph transforma-tion with application to visual design of distributed systems, in: Handbookof Graph Grammars and Computing by Graph Transformation, vol. 3(Ed.: G. Rozenberg), World Scientific, 1999

Page 43: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.9. CONCLUSION 43

Appendix A: Full example

In this appendix, we present the mergesort example in more detail. Processmsort takes an unsorted list as input and splits it into two sublists. Then,these sublists are sorted recursively. Finally, the sorted sublists are merged(Fig. 7.20). This process terminates if input becomes empty:

1l : Q(nil)

msort

δ?

� �

2l : Q(s)

ρ?� � 2 : s

� � 2r : Q(close(s))� �

pl

←− pr

−→

Please note that there is no production applicable to hyperedge msort if inputis ⊥, i.e., it is empty for the moment, but it has not reached the end.

Next, we consider process split. We distinguish between two states split andsplit1. In state split, the first element of input is sent to the left-hand side,and state is changed to split1 (Fig. 7.21(a)). Then, the second element is sentto the right-hand side and the system returns to the first state (Fig. 7.21(b)).If there is no more element to be sent to the left-hand side, process split

terminates:

1l : Q(nil)

split

δ?

� �

2l : Q(l)

ρleft ���� � 3l : Q(r)

ρright@@@R� �

2 : l� �3 : r

� �pl

←− pr

−→ 2r : Q(close(l))� �3r : Q(close(r))

� �An analogous production describes termination if the process is in state split1when the end of the input is reached. None of these productions is applicableas long as δ-node is labelled with ⊥, i.e., splitting process is waiting for thenext element.

The second major activity is merging. In initial state, it takes an element fromleft-hand queue, whereas in state merge1, it waits for an element from right-

Page 44: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

44 DESCRIBING SYSTEMS OF PROCESSES BY . . .

1l : Q(cons(x, y))

msort

δ?

� �

2l : Q(⊥)

ρ?� �

1 : Q(cons(x, y))� �

2 : Q(⊥)� �

1r : Q(cons(x, y))

δ?

� �split

ρleft ���

ρright@@@R

Q(⊥)

msort

δ?

� � Q(⊥)

msort

δ?

� �

Q(⊥)

ρ?� � Q(⊥)

ρ?� �

merge

δleft

@@@R

δright

���

2r : Q(⊥)

ρ?� �

pl

←− pr

−→

Figure 7.20: Production starting mergesort

hand queue (Fig. 7.22). Contrary to sequential solution, we have to take intoconsideration the situation that in state merge, the left-hand queue is empty forthe moment. In this case, we are allowed to start with reading from right-handqueue (Fig. 7.23).

As soon as there are two elements available, they may be compared and thesmaller one is written into output queue. The production of Fig. 7.24(a) is to beapplied if element coming from right-hand queue is smaller, i.e., y ≤ x; other-wise, production of Fig. 7.24(b) is to be used. At this point, we have productionswith application conditions. This is a well-known situation in specifying sys-tems of processes (guarded commands) and discussed in graph-transformationframework by Habel, Heckel, and Taentzer [19]. Nevertheless, guarded com-mands may be integrated into the categorical framework as we have shown in[35].

Finally, we need some productions to finish process merge after one of the

Page 45: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.9. CONCLUSION 45(a

)1l

:Q(c

ons(

e,u))

split

δ?

� �

2l:Q

(l)

ρle

ft�

� ��

� 3l

:Q(r

)

ρrig

ht

@@ @R �

1:u�

� 2

:l� �

3:r�

� p

l

←−

pr

−→

1r:Q

(u)

split

1

δ?

� �

2r:Q

(appd(l

,e))

ρle

ft�

� ��

� 3r:Q

(r)

ρrig

ht

@@ @R �

(b)

1l:Q

(con

s(e,

u))

split

1

δ?

� �

2l:Q

(l)

ρle

ft�

� ��

� 3l

:Q(r

)

ρrig

ht

@@ @R �

1:u�

� 2

:l� �

3:r�

� p

l

←−

pr

−→

1r:Q

(u)

split

δ?

� �

2r:Q

(l)

ρle

ft�

� ��

� 3r:Q

(appd(r

,e))

ρrig

ht

@@ @R

� �

Fig

ure

7.2

1:P

roduct

ions

that

des

crib

esp

litt

ing

Page 46: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

46 DESCRIBING SYSTEMS OF PROCESSES BY . . .

1l:

Q(con

s(x,s))

merge

δle

ft

@@@R

��

2l:

Q(s ′)

δrig

ht

��� �

3l:

Q(s ′′)

ρ?

��

1:s

��

2:s ′

��

3:s ′′

��

pl

←−

pr

−→

1r

:Q

(s)merge1

δle

ft

@@@R

��

2r

:Q

(s ′)

δrig

ht

��� �

4r

:L

(x) λ�

��3

r:Q

(s ′′)

ρ@

@@R�

�1

l:Q

(s)

merge1

δle

ft

@@@R

��

2l:

Q(con

s(y,s ′))

δrig

ht

���

��

4l:

L(x) λ

���

3l:

Q(s ′′)

ρ@

@@R�

�p

l

←−

pr

−→

1r

:Q

(s)merge3

δle

ft

@@@R

��

2r

:Q

(s ′)

δrig

ht

��� �

4r

:L

(x),R(y)

λ�

��3

r:Q

(s ′′)

ρ@

@@R�

1:s

��

2:s ′

��

4:x

3:s ′′

��

Fig

ure

7.2

2:M

ergin

gsta

rtsat

left-hand

side

Page 47: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.9. CONCLUSION 471l

:Q(s

)

mer

ge

δ lef

t

@@ @R

� � 2l

:Q(c

ons(

y,s′ )

)

δ rig

ht

�� ��

3l:Q

(s′′)

ρ?

� �

1:s�

� 2

:s′

� �

3:s

′′�

� p

l

←−

pr

−→

1r:Q

(s) m

erge

2

δ lef

t

@@ @R

� �

2r:Q

(s′ )

δ rig

ht

�� ��

4r:R

(y)λ�

� �3r

:Q(s′′)

ρ@

@ @R � �

1l:Q

(con

s(x,s

))

mer

ge2

δ lef

t

@@ @R

� � 2l

:Q(s′ )

δ rig

ht

�� �

� �

4l:R

(y)λ�

� �3l

:Q(s′′)

ρ@

@ @R � � p

l

←−

pr

−→

1r:Q

(s) m

erge

3

δ lef

t

@@ @R

� �

2r:Q

(s′ )

δ rig

ht

�� ��

4r:L

(x),

R(y

)

λ�

� �3r

:Q(s′′)

ρ@

@ @R � �

1:s�

� 2

:s′

� �

4:x

3:s

′′�

� Fig

ure

7.2

3:M

ergin

gst

art

sat

right-

hand

side

Page 48: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

48 DESCRIBING SYSTEMS OF PROCESSES BY . . .

(a)y≤

x1

r:Q

(s)merge3

δle

ft

@@@R

��

2r

:Q

(s ′)

δrig

ht

��� �

4l:

L(x),R

(y)

λ�

��3

r:Q

(s ′′)

ρ@

@@R�

�p

l

←−

pr

−→

1r

:Q

(s)merge1

δle

ft

@@@R

��

2r

:Q

(s ′)

δrig

ht

��� �

4r

:L

(x) λ�

��3

r:Q

(appd(s ′′,y))

ρ@

@@R�

1:s

��

2:s ′

��

4:x

3:s ′′

��

(b)y

>x

1r

:Q

(s)merge3

δle

ft

@@@R

��

2r

:Q

(s ′)

δrig

ht

��� �

4l:

L(x),R

(y)

λ�

��3

r:Q

(s ′′)

ρ@

@@R�

�p

l

←−

pr

−→

1r

:Q

(s)merge2

δle

ft

@@@R

��

2r

:Q

(s ′)

δrig

ht

��� �

4r

:R

(y) λ�

��3

r:Q

(appd(s ′′,x))

ρ@

@@R�

1:s

��

2:s ′

��

4:y

3:s ′′

��

Fig

ure

7.2

4:C

om

parin

gin

com

ing

elemen

ts

Page 49: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

7.9. CONCLUSION 49(a

)1l

:Q(s

)

mer

ge1

δ lef

t

@@ @R

� �

2l:Q

(nil)

δ rig

ht

�� ��

L(x

)

λ�

� �3l

:Q(s′′)

ρ@

@ @R � � p

l

←−

pr

−→

1r:Q

(s)

copy

δ lef

t

?

� �

3r:Q

(appd(s′′,x

))

ρ ?�

1:s�

� 3

:s′′

� �

(b)

1l:Q

(nil) m

erge

2

δ lef

t

@@ @R

� �

2l:Q

(s)

δ rig

ht

�� �

� �

R(y

)

λ�

� �3l

:Q(s′′)

ρ@

@ @R � � p

l

←−

pr

−→

2r:Q

(s)

copy

δ lef

t

?

� �

3r:Q

(appd(s′′,y

))

ρ ?�

2:s

′�

� 3

:s′′

� �

Fig

ure

7.2

5:M

ergin

g:O

ne

ofth

ein

com

ing

list

has

bec

om

eem

pty

Page 50: pdfs.semanticscholar.org€¦ · Chapter 7 DESCRIBING SYSTEMS OF PROCESSES BY MEANS OF HIGH-LEVEL REPLACEMENT H.J. SCHNEIDER Lehrstuhl fur¨ Programmiersprachen, Universit¨at Erlangen-Nurnb¨

50 DESCRIBING SYSTEMS OF PROCESSES BY . . .

incoming queues has become empty (Fig. 7.25). We omit two further produc-tions doing the same in state merge on the left-hand side (of course, withoutthe λ-node). Productions describing copy are trivial.

Appendix B: List of Categories and Functors

Category Definition

1 Def. 7.4.5Bgraph Def. 7.5.1C Def. 7.7.1Cgraph Def. 7.4.3Graph Def. 7.4.1Hgraph Def. 7.4.2LgraphM Def. 7.4.5Mgraph Def. 7.5.4Pgraph Def. 7.8.1Pnet Def. 7.5.3PLgraphΣ,X Def. 7.7.5POD Def. 7.5.2POI

M(S) Def. 7.5.4POgraph Def. 7.5.2ProcStates Def. 7.8.2PTnet Def. 7.5.5ST I Def. 7.6.1Stcharts Def. 7.6.1SThgraph Def. 7.4.2TgraphΣ,X Def. 7.7.1

Functor Definition

B Def. 7.5.1C Def. 7.4.2D Def. 7.5.2I Def. 7.6.1Id Def. 7.4.1M Def. 7.4.5ML Def. 7.5.4P Def. 7.8.1PS Def. 7.5.5PT Def. 7.5.3PSE Def. 7.8.2PSV Def. 7.8.2Q Def. 7.4.2St Def. 7.6.1TE Def. 7.7.1TV Def. 7.7.1W Def. 7.4.4WE Def. 7.4.4WEV Def. 7.4.4WV Def. 7.4.4WV S Def. 7.4.4WV T Def. 7.4.4X Def. 7.4.1