The feasibility of a formalism is based essentially on the way in which ... 1 This work is partly supported by the ESPRIT-Working Group #7183 \Computing by.
URL: http://www.elsevier.nl/locate/entcs/volume2.html
10 pages
Concurrent Derivations as Single Pushout Graph Grammar Processes Martin Kor and Leila Ribeiro 1 Department of Computer Science Technical University of Berlin D-10587 Berlin, Germany
Abstract
Algebraic graph transformations visually support intuition, have a strong theoretical basis, and provide a formal, implementation independent basis for the description of discretely evolving computational systems and their formal and tractable analysis. Graph grammar models of concurrent systems (petri nets, actor systems) have inspired corresponding semantics developments. Recently this led to the introduction of partial orders of concurrent derivations (concurrent computations). A concurrent derivation (CDer) abstracts from the (sequential) order of rule applications in the sequential derivation and thus can be considered as a concurrent process. Complementary, a morphism between two concurrent derivations expresses that the rst is a computational approximation of the second. In this paper we newly introduce non-deterministic concurrent derivations (CTrees) as classes of concurrently equivalent sequential derivation trees. Due to the fact that also in nite computations are represented by CTrees, the category of all CTrees of a given graph grammar has a nal object (the concurrent counterpart of the whole sequential tree of the given grammar) which is approximated by all other CTrees. We show that (syntactical) morphisms between two graph grammars induce corresponding adjunction between the corresponding (semantic) categories of CDers and CTrees respectively.
The feasibility of a formalism is based essentially on the way in which syntax and semantics are related. Approaches to integrate both syntax and semantics into a uniform framework are therefore particularly attractive and theoretically rich. Two prominent examples for this are Petri net processes [1,10] and term algebras in algebraic speci cations [5]. In this paper we contribute to this aim by showing that the semantics of a graph grammar can be described by one graph grammar representing all possible computations that this grammar can perform. Moreover, there is a (semantical) adjunction induced by (syntactical) morphisms. The investigations in this paper follow the single pushout (SPO) approach in [9]. Originally this was formulated for diernt classes of categories with parThis work is partly supported by the ESPRIT-Working Group #7183 \Computing by Graph Transformations (COMPUGRAPH) II" and by a CNPq-grant for Leila Ribeiro. 1
c
1995 Elsevier Science B. V.
Korff and Ribeiro tial morphisms. Here we review it w.r.t. dierent classes of graph-interpreted or typed graphs [6]. We then present the semantical categories of concurrent derivations and concurrent derivation trees respectively and establish a relation between syntax and semantics of graph grammars.
1 Graphs, Grammars, and Sequential Derivations In the algebraic approach, graphs and graph morphisms are internally structured components of a suitable category. When partial rather than total graph morphisms are considered, commutativity as the internal compatibility of morphism components is replaced by a so-called weak commutativity. Weak commutativity is based on a certain factorization property (span representation) of partial morphisms (see [6]). For a (partial) function f : A ! B , let f ? : A dom(f ) and f ! : dom(f ) ! B be its domain inclusion and the domain restriction (span). The inverse of f is denoted by (f )? . Given functions a : A ! A0, f : A ! B , b : B ! B 0 and f 0 : A0 ! B 0, we write f 0 a b f and say that the diagram commutes weakly if f 0 a f ? = b f !. De nition 1.1 A graph G = (VG ; EG ; sG; tG) consists of a set of vertices VG , a set of edges EG , and total functions sG; tG : EG ! VG called source and target operations respectively. A (partial) graph morphism g : G ! H between graphs G and H is a tuple g = (gV ; gE ) consisting of two partial functions gV : VG ! VH and gE : EG ! EH which are weakly homomorph, i.e. 1
2
VG g V VH tH tG _ _ EG gE EH
VG gV VH sH sG _ _ EG gE EH
/
/
O
O
O
/
O
/
Fig. 1. Weak Commutativity Requirement
g is called inclusion, total, injective, or surjective if all components are inclusions, total, injective, or surjective respectively. Let G (GT) denote the category of all graphs and partial (total) graph morphisms. In the following de nition, the internal structure of a `higher-order graph' is formulated w.r.t. to the category G rather than SetP. This becomes possible by carrying over the notion of weakly commuting diagrams from SetP to G. Analogously to functions, there are inverse graph morphism and spans: the inverse of g : A ! B , denoted by (g)? , is de ned componentwise and again a graph morphism i g is injective. The span of g consists of the graph morphisms g? : A dom(g) and g! : dom(g) ! B ; note that g = g! (g?)? . 3
1
1
2 3
Note this non-standard formulation is equivalent to the one given in [9] This can be seen as a generalized comma category construction.
2
Korff and Ribeiro
De nition 1.2 A graph-interpreted graph (GiG) GT is a triple GT = (G; iG ; T ) where iG : G ! T is a total graph morphism, called the interpretation of G in T . A GiG morphism gt : G1T ! G2T between GiGs G1T = 1
(G1; iG
G2T
2
(G2; iG
2
1
; T 1) and = ; T 2) is a pair of partial graph morphisms g : G1 ! G2 and t : T 1 ! T 2 such that t iG iG g. gt is called inclusion, total, injective, or surjective if all components are inclusions, total, injective, or surjective respectively. The category of all GiGs and partial (total) GiGmorphisms is denoted by G2 (G2T). 1
2
'&
1
T1
%$
t
'& /
%$
O
O
iG1 !
T2
2
G1
"#
iG1
! /
f
G2
"#
Fig. 2. Graph-Interpreted Graph Morphism f t : G1T
1
! G2T
2
Let G2(T) (G2(T)T) denote the restriction of G2 (G2T) where all GiGs and GiG-morphisms are interpreted into a xed G-graph T and its identity. Remark 1.3 This process of constructing `higher-order' graphs can be iterT T 3 3 2 3 ated, Let G , G , G (T), and G (T) be the categories obtained when in the preceeding de nition the category G is replaced by G2. This means that a G3 -graph is a GiG-morphism (a G2 -interpreted-G2-graph) and a G3-morphism is a weakly commuting pair of GiG-morphisms. Theorem 1.4 (Cocompleteness) All the categories de ned above are cocomplete and colimits are preserved by the corresponding inclusion functors from categories of partial to categories of total morphisms. These results are due to the fact that these can be considered as generalized graph structure (GGS) categories ([6]). In the rest of the paper, we will formulate the de nitions w.r.t. a category C that can be any of the categories above, unless stated otherwise. For a set X , let X 1 denote the countable sequences over X . The length of s 2 X 1 is denoted by jsj 2 IN [ f!g. s may be considered as a partial function s : IN ! X with domain dom(s) = fi 2 IN ji jsjg. Function application is denoted by si. De nition 1.5 A C-rule is an injective morphism which is consuming, i.e. not total, by default. A C-graph grammar GG = (IN; P ) consists of an input graph IN and a set of rules P . GG is called nite if IN and P are nite. A G2-grammar morphism between a G2(T1)-grammar GG1 = (IN 1T ; P 1T ) t ; fP ) consistand a G2(T2)-grammar GG2 = (IN 2T ; P 2T ) is a pair f t = (fIN t = (fIN ; t) : IN 1T ! IN 2T and a total function ing of a G2-morphism fIN T T fP : P 1 ! P 2 s.t. , for all rt1TT 2 P 1T , there is a G2t-isomorphism g = (gL ; gR) s.t. gLt : LTr ! LfP r and gRt : RTr ! RfPT r are G2morphisms. 4
1
2
2
1
1
2
1
1 1
4
(
1)
( 1)
2
1
1 1
`By default' ensures that `inverse rules' may also be considered as rules.
3
(
1)
( 1)
1
Korff and Ribeiro Let GraGra be the category of all G2(T)-grammars and all G2-grammar morphisms. Remark 1.6 Again, the de nition of GiG-grammar morphisms is parametric in the sense that may also be read w.r.t. G3 rather than G2. A sequential derivation describes (a sequential observation of) a possible computation of a given graph grammar. A tree of derivation steps, called (sequential) derivation tree additionally captures a set of observations. De nition 1.7 Given a rule r : L ! R, a match m : L ! IN of r in a graph IN is a total morphism. A derivation step d of a graph IN d , called r m input of d, with rule rd at match md is a pushout IN ! OUT R of md and rd. It is denoted by INd[rd : mdiOUTd , brie y INd[diOUTd . OUT , r and m are called output graph, co-rule and co-match resp. rd
Ld
md
_
/
Rd
md
INd
rd /
OU Td
Fig. 3. Derivation Step
The set of all derivation steps using rules in GG is denoted by StepsGG . The set of sequential derivations w.r.t. GG is de ned by SDerGG = f 2 Steps1GG j = or 6= , IN = IN and OUTi = INi+1 for all 1 i < jjg. If is nite we de ne the output graph as OUT = OUTjj . Graph elements related by morphism may intuitively be considered the same. Certain rule applications become equivalent then in the sense that their order is irrelevant. Such independent rule applications may then be considered as speci c interleavings of actually parallel activities. The corresponding formal notion of parallel independence expresses the fact that two derivations that do not overlap in items that are to be deleted by one of them. Using this notion, we can de ne a dependency relation between rules of a graph grammar. Let r1T and r2T be rules of a G2(T)-grammar GG. Then the dependency relation GG associated to GG expresses the fact that if r1T GG r2T then there may be a sequential derivation of GG in which a step using rule r2T is dependent of a step using rule r1T . The existence of such a derivation depends on the initial graph of the grammar GG and of the ways of rule application. De nition 1.8 Given a graph grammar GG = (IN T ; P ) w.r.t. G2(T) (G3(T)). Two derivation steps s1 = (G[r1 : m1iH 1) and s2 = (G[r2 : m2iH 2) are parallel independent if r1 m2 and r2 m1 are total. Otherwise they are parallel dependent. Let r1T ; r2T 2 P , s1 = (T [(r1)? : iR iH 1) and s2 = (T [r2 : iL iH 2) be derivation steps of GG. Then r1T r2T i s2 is parallel dependent of s1. The 4 1
1
2
Korff and Ribeiro R1 m1
H1
L1 AA
r1 o
AA m1 AA AA
r 1 o
L2
G
r2
m2 }}}} }} }}
/
R2 m2
H2
~
r 2 /
Fig. 4. Parallel Independence
dependency relation of GG, denoted by GG , is the re exive and transitive closure of .
2 Concurrent Derivations and Derivation Trees Only recently true concurrency semantics for algebraic graph grammars have been proposed in [2] and [7]. Both approaches provide partial orders of (concurrently) equivalent sequential derivations. Two sequential derivations are considered equivalent only if they are isomorphic (renamed) or their constituting derivation steps show a dierent interleaving (order). In [7] such classes have explicitly been represented by so-called concurrent derivations. The basic idea of a concurrent derivation is to glue all the intermediate graphs occurring in a sequential derivation without losing the participating rules and their matches. This gluing leads to a so-called core graph which is categorically obtained from a colimit construction. The input graph and the rules of derivation steps of the sequential derivation can be thus considered as interpreted in terms of the core graph. A concurrent derivation then consists of the interpreted input graph and the set of interpreted rules from the participating derivation steps, called actions. De nition 2.1 Let GG be a G2(T)-grammar. (i) Given a step s 2 StepsGG , we de ne the step-core of s as core(s) = (IO; in; out) constructed as follows: (a) Construct pushout (1) of Ls rs rs dom(rs ) ! Rs; (b) This leads to a factorization of rs = (aRs)? aLs. Thus we can decompose s (the derivation step) into the pushouts (2) and (3) As (aRs)? is injective, the pushout morphism (out)? is also injective and can be inverted, giving raise to the morphism out. ?
!
1
1
rs
LS _
ms
INs
y
1
dom(rs )L k
ss ss ss ?
K
rs LL LL rs L aRqsqqqqq1q Rs q q qqqqq q aRs ?1 m !
&
L 111_
m
1
/
LLL LL L
aLs
(2)
%
(1)
LR
ms
x
8
(
)
rs
(3)
out ?q1qqq1OUTs qqqq qqqq out q
/
LLL LL s L
in
%
(
IO
s
x
)
8
/
R1 D
ioR r
in
%
IO1 OO
t
L2. _ _ _ _r _ _ _ R 2 2
/
D 1 D 1 1 1 D 1 D 1 1 D 1 1 1 1 _ _ 1 _ _ _ _ _ _ _ 1 1 JJ 1 hh JJ 11 hhh JJ 1 hhh h h hhh 1 1
ioL
IN 1
r
_ _ 1_ _ _
m
OUT "
/
out
OO OO OO OO OO 1 OO OO O
. . z . 2 z . z . . z . z 2 . 2 _ _ _ _ _. _ _ _ _ . = 2 VVV . 2 VVV rr . VVV . rrr V V r VV 2 2
m
|
ioL r
IN
in
ioR /
IO2
*
p pp pp pp p p pp 2 pp pp p p
x
m 2
OUT 2
out
c
c
'
z
C
w
Fig. 5. Step-Core and Core Structure
(ii) Given a sequential derivation 2 SDerGG , let inout() = (core(i)i2dom ) be the diagram containing all cores of steps of . Then the colimit Core() = 5 (
)
Korff and Ribeiro (C; cini; ci; couti)i2dom is called the core structure of . Each colimit morphism ci is called core morphism and the colimit graph C is called core graph. (iii) the concurrent derivation K = (IN C ; AC ) w.r.t. , written ; K, is de ned as follows: IN C is the G3-graph cin idT : IN T ! C T , rjC C AC is a set of rules in G3(C) given by AC = fLCj ! Rj j j 2 dom()g. For C r each a = (LC ! RC ) 2 AC we de ne preKa = iL, raK = r, postKa = iR called pre-condition, rule and post-condition of a respectively. The sets of all concurrent derivations obtainable from SDerGG is denoted by CDerGG . The length of a concurrent derivation K is de ned by jKj = card(AC ). A concurrent derivation can be seen as a graph grammar: it consists of a start graph and of a set of actions that can be considered as rules in the category G3(CT). A concurrent derivation can be seen as a deterministic unfolding of a graph grammar, and the double-typing mechanism provides a unique way of relating a concurrent derivation and the grammar. If we consider a concurrent derivation as a graph grammar, we get an associated dependency relation that in this case have a special meaning. Using the notion of parallel independence one can check whether two consecutive steps within a derivation could have been applied in the opposite order (by nding a step that is \equivalent" to the second step and parallel independent of the rst step). However, it is not a trivial task to check whether two arbitrary steps in a sequential derivation are or not independent. Contrastingly, the construction of a concurrent derivation makes the (in)dependencies between steps explicit. It holds that two steps (actions) s1 and s2 of a concurrent derivation K are sequentially independent s1 K s2 if and only if there is a sequentialization in which s2 depends on s1. That means that in the case of concurrent derivations, the dependency relation describes a sequential order on steps, and this order is in fact a partial order. For a proof of the following proposition see [8]. Proposition 2.2 Given a graph grammar GG = (IN T ; P T ) w.r.t. G3(T), let 2 SDerGG and K = (IN C ; AC ) s.t. ; K. Then (a) K is a graph grammar w.r.t. G3 (T) and K is a well-founded partial order; (b) there is a canonical relationship between GG and K given by VC (IN C ) = IN T , A0 P , where A0 = fVC (a)ja 2 AC g, where VC : G2(CT ) ! G2(T) is a functor that forgets the type C . The partial order K associated to a concurrent derivation K describes the \concurrency potential" of this derivation: all steps that are not related (
)
1
5
6
If a concurrent derivation if nite, we could also add a third component to it, namely the output graph OUTK = OUT . 6 A sequentialization of a concurrent derivation K is a sequential derivation of K where the double-typing C T is reduced to T via a forgetful functor VC : G3 (CT ) ! G3 (T). 5
6
Korff and Ribeiro by K are considered independent and may thus occur in parallel. Concurrent derivations can thus be used as a basis for a concurrency semantics of graph grammars. Categories of derivations are obtained by complementing these sets of derivations with suitable morphisms representing the fact that one derivation is a pre x (an approximation) of a second. Categories of concurrent derivations are thin, i.e. they represent a partial order of computations. By identifying isomorphic derivations, we obtain a category of abstract computations representing a partial order of abstract computations. If we consider only nite computations, the category of abstract derivations was shown to be a nitary, prime algebraic partial order ([7]). By using a corresponding result in [11], this can equivalently be expressed by a prime event structure. For a proof of the well-de nedness of the following de nition we refer to [8]. De nition 2.3 let K and K0 be graph grammars w.r.t. G3(T). A concurrent derivation morphism f c : K ! K0 is a graph grammar morphism s.t. id c T fIN = (idIN ; cidT ), c is injective fP (r1C ) = r1C and for all a 2 AK0 ; b 2 AK, a K0 fP (b) ) a 2 fP (AK). Let GG = (IN; P ) be a G2(T)-graph grammar. The concurrency semantics CDerGG of GG is given by the category having as objects all concurrent derivations w.r.t. GG and all concurrent derivation morphisms between them as morphisms (it is a subcategory of GraGra2). The abstract concurrent semantics ACDerGG of GG is the quotient category of CDerGG consisting of isomorphism classes of objects and morphisms respectively. Theorem 2.4 Let g : GG ! GG0 be an injective G2-grammar morphism between nite G2-grammars with isomorphic input graphs. Then there is an adjunction between the deterministic semantics with left adjoint Tg : ACDerGG ! ACDerGG0 and right adjoint Cg : ACDerGG and ACDerGG0 . Proofsketch This adjunction is induced by an adjunction Tg ; Cg between the (non-abstract) deterministic semantics. The functor Tg : CDerGG ! CDerGG0 T ranslates each GG-derivation K1 into a GG0 -derivation K2 along g: the core graph of K2 is C 1T obtained from prolongating the core graph C 1T of K1 along the interpretation part of g. The rules of K2 are the rules assigned via gP ; Their pre- and post-conditions are given by some isomorphism and the pre- and postconditions of the corresponding rules in K1. The functor Cg : CDerGG0 ! CDerGG C uts each GG0-derivation K2 into a GG-derivation K1 along (g)? : The idea is to nd the greatest subset of all actions with rules having preimages under g and which are closed w.r.t. the sequential dependency relation between actions. In [8] it was shown that there is an essentially unique subderivation and a corresponding concurrent derivation morphism having the selected actions as its image. The interpretation of the core graph can then be adapted w.r.t. (g)? . Informally this means that 7
1
2
2
1
1
1
Note that prime event structures are not able to capture fairness considerations. Hence in [7] the partial order semantics has been preferred (it was possible to exclude certain unfair (in nite) derivations from the semantic domain). 7
7
Korff and Ribeiro
Cg cuts a concurrent derivations to the greatest subderivation which can be simulated by GG. Two concurrent derivations which do not have a common superderivation must contain activities which exclude each other, i.e. which are in con ict. Only one of these processes may actually occur. The corresponding choice is non-deterministic. Thus representing these two computations in a single object means to introduce non-deterministic processes into the semantics. One way to obtain them would have been to replay the construction of concurrent derivations for derivation trees rather than sequential derivations. Here we use a more ecological way based on a gluing construction of concurrent derivations. L 33ITITITTTT
raK
preKa
CK
inK
IN
R
4PPPP 4 PP 3 II TTTT 4 PP 3 4 II TT PP TT 3 4 I PP 3 4 TTT II PP TT 4 II PP TT4 T PP 4TT II 3 PP 4 TTT 3 I 4 PP 3 TT I 3 3 3 PP II TTT 4 4 PP TTT II 4 PP TT II 4 [[[[[ P T TT 4 [[[[[ I TT PPPP n 4 I [ [[ n TTT [ I n [ [ 4 [ n [ II [[[[[ TT PPP n 4 n [[[[[ TT PP II 4 [[[[[ TTT PP nn n 4 [ I [[[[[ n PP II4 [[[[[ TTT nn PP TT [[[[[ nn T [[ 6
/
postKa preGGY preGGZ postGGY postGGZ a a a a yK
y
zK
fKGGY
$
&
,
/
Y
z
(
*
-
/
Z
Fig. 6. Concurrent Derivation Tree
De nition 2.5 Given a G2(T)-grammar GG = (IN; P ) and a set of concurrent derivations D CDerGG we de ne
(i) a G3(Y)-grammar GGY = (IN Y ; AY ) with input graph IN Y = y and rules AY = f ( yK preKa ; raK; yK postKa ) j a 2 AK; K 2 D g y yK where (Y; IN ?! Y; C K ?! Y )K2D is the colimit of the (G2(T)-)diagram C inK (IN = IN K ?! Y )K2D , and 3 (ii) a G (Z)-grammar GGZ = (IN Z ; AZ ) with input graph IN Z = z and rules GGY GGY GGY g AZ = f ( z preGGY a ; ra ; z posta ) j a 2 A K z z where (Z; C K ?! Z; Y ?! Z )K2D is the colimit of the (G2(T)-)diagram fKY (C K ?! Y )K2D;fKY 2MorKY and MorKY = f f : K ! GGY j f is concurrent derivation morphism g. GGZ is called a concurrent derivation tree or a non-deterministic concurrent derivation of D. The subcategory of GraGra3 consisting of all concurrent derivation trees obtainable from GG and all concurrent derivation morphisms is denoted by CTreeGG. Let ACTreeGG be the quotient category consisting of isomorphism classes of objects (abstract non-deterministic concurrent derivations) and morphisms respectively. Theorem 2.6 The concurrent derivation tree obtained from the set of all concurrent derivations is nal in ACTree GG. 8 (
Korff and Ribeiro
Proo dea Based on the universal properties of colimit morphims this is ensured by the construction. (Note the category ACTreeGG is also thin). The (abstract) nal object is the possibly non-terminating computation which can intuitively be described as the concurrent equivalent of the full tree of sequential derivations. Theorem 2.7 Let g : GG ! GG0 be an injective G2-grammar morphism between nite G2-grammars with isomorphic input graphs. Then there is an adjunction between the deterministic semantics with left adjoint Tg : ACDerGG ! ACDerGG0 and right adjoint Cg : ACDerGG and ACDerGG0 . The proof generalizes the functors provided for Theorem 2.4.
3 Conclusion Concurrent derivations describe concurrent computations of a grammar, i.e. its processes. Morphisms model pre x relations,i.e. computational approximations between these. Thus the partial order of concurrent derivations (given by the category ACDer), de ned in [7], yields a suitable description of the concurrent behaviour of a graph grammar. A related approach following the DPO-approach based on sets of nite deterministic processes was presented in [3]. In this paper we showed that morphisms between graph grammars induce an adjunction between their corresponding semantical categories (partial orders), establishing a connection between syntax and process semantics of graph grammars. Moreover, we showed how the non-deterministic processes of a grammar can be obtained from deterministic ones. This construction gave raise to a process that describes all computations of a graph grammar and is itself a graph grammar. A relationship between this process and its originating grammar is canonically induced.
References [1] E. Best and R. Devillers, Sequential and concurrent behaviour in Petri net theory, Theoretical Computer Science 55 (1987), 87{136. [2] A. Corradini, H. Ehrig, M. Lowe, U. Montanari, and F. Rossi, An event structure semantics for safe graph grammars, To appear in Proc. of the IFIP Working Conference PROCOMET'94, 1994. [3] A. Corradini, U. Montanari, and F. Rossi, Graph processes, Submitted to a special issue of Fundamentae Informatica, 1994. [4] H. Ehrig, Introduction to the algebraic theory of graph grammars, 1st Graph Grammar Workshop, LNCS 73, Springer, 1979, pp. 1{69. [5] H. Ehrig and B. Mahr, Fundamentals of algebraic speci cations 1, EACTSMonographs in Theoretical Computer Science, vol. 6, Springer, Berlin, 1985.
9
Korff and Ribeiro [6] M. Kor, Single pushout transformations of generalized graph structures, Tech. Report RP 220, Federal University of Rio Grande do Sul, Brazil, 1993. [7] M. Kor, True concurrency semantics for single pushout graph transformaitons with applications to actor systems, To appear in Information Systems { Corretness and Reusability IS-CORE'94, World Scienti c Publishing, 1994. [8] M. Kor, Generalized graph structure grammars and their application to concurrent object-oriented systems, In preparation, 1995. [9] M. Lowe, Algebraic approach to single-pushout graph transformation, Theoretical Computer Science 109 (1993), 181{224. [10] J. Meseguer, U. Montanari, and V. Sassone, On the model of computation of place/transition Petri nets, ATPN'94, Springer, 1994, LNCS 815, pp. 16{38. [11] G. Winskel, An introduction to event structures, Linear Time, Branching Time and Partial Order in Logics and Models for Concurrency, Springer Verlag, 1989, pp. 364{397.
10