Graph Computation Models
Selected Revised Papers from GCM 2015
On Single-Pushout Rewriting of Partial Algebras
Michael Löwe and Marius Tempelmeier
21 pages
Guest Editors: Detlef Plump
Managing Editors: Tiziana Margaria, Julia Padberg, Gabriele Taentzer
On Single-Pushout Rewriting of Partial Algebras
Michael Löwe1and Marius Tempelmeier2
Fachhochschule für die Wirtschaft Hannover, Germany
Sennheiser electronic GmbH & Co. KG
Abstract: We introduce Single-Pushout Rewriting for arbitrary partial algebras. Thus, we give up the usual restriction to graph structures, which are algebraic cat-egories with unary operators only. By this generalisation, we obtain an integrated and straightforward treatment of graphical structures (objects) and attributes (data). We lose co-completeness of the underlying category. Therefore, a rule is no longer applicable at any match. We characterise the new application condition and make constructive use of it in some practical examples.
Keywords:Graph Transformation, Single Pushout Rewriting, Partial Algebras
1
Introduction
The current frameworks for the (algebraic) transformation of typed graphs are not completely satisfactory from the software engineering perspective. For example, it is hardly possible to spe-cify and handle associations with “at-most-one”-multiplicity, since most frameworks are based on some (adhesive) categories of graphs which allow multiple edges between the same pair of vertices.1
Another example is the handling of attributes. The standard approaches to the transforma-tion of attributed graphs, compare for example [4,14], explicitly distinguish two parts, i. e. the structure part (objects and links) which can be changed by transformations and the base-type and -operation part (data) which is immutable. Typically, objects can be attributed with data via some special edges the source of which is in the structure part and the target of which is data. This set-up either leads to set-valued or immutable attribute structures. Both is not satisfactory from the software engineering point of view.2
Another problem in current frameworks for attributed graphs is the infiniteness of rules stip-ulated by the infiniteness of the term algebra which is typically used in the rules. Even if the algebra for the objects which are subject to transformation is finite (for example integers modulo some maximum), the term algebra tends to contain infinitely many terms.
All these problems are more or less caused by the usage of total algebras. In this paper, we use partial algebras instead as the underlying category for single-pushout rewriting. In partial al-gebras, operation definitions can be changed without deleting and adding an object (edge). Thus,
1Typically, some negative application conditions [8] are employed to handle these requirements making the
frame-work more complicated.
we get a straightforward model for “at-most-one” associations. We also give up the distinction between structure and data, i. e. we allow arbitrary signatures which are able to integrate both parts. We lose co-completeness of the base category and import some application conditions into single-pushout rewriting. But we gain a seamless integration of structure and data. Finally, partial term algebras in the rules help to keep rules finite.
The paper is a short version of [17] and an extended version of [15]. Section2introduces our concept of partial algebra. We show explicitly the similarities between partial algebras and hy-pergraphs. Section3provides sufficient and necessary conditions for the existence of pushouts in categories of partial algebras and partial morphisms. It contains our main results. Section4 defines the new single-pushout approach and compares it to the sesqui-pushout approach [3]. Section5demonstrates by some examples that the application conditions in the introduced re-writing approach are useful in many situations. Finally, Section6 discusses related work and provides some conclusions.
2
Graphs and Partial Algebras
In this section, we introduce the basic notions and constructions for partial algebras. We use a rather unusual approach in order to emphasise the close connection of categories of par-tial algebras to categories of hypergraphs. We employ a kind of objectification for parpar-tial mappings. A partial map f :A→ B is not just a subset of A×B satisfying the uniqueness condition (∗) (a,b1),(a,b2)∈ f implies b1=b2.Instead, a partial map f :A→B is a triple (f,df : f→A,cf : f →B)consisting of a set f ofmap entriestogether with twototalmapsdf : f →Aandcf : f →Bwhich provide the argument and the return value for every entry
respect-ively. The uniqueness condition(∗)above translates to∀e1,e2∈f :df(e1) =df(e2) =⇒e1=e2 in this set-up.
A signature Σ= (S,O) consists of a set of sorts S and a domain- and co-domain-indexed family of operationsO= (Ow,v)w,v∈S∗.3 Agraph Gwrt. a signature consists of a carrier setGs
(of vertices) for every sort s∈S and a set of hyperedges
fG,dGf :fG→Gw,cGf : fG→Gv
for every operation f ∈Ow,v and w,v∈S∗ where the total mappings dGf and c G
f provide the
“arguments” and “return values”.4 Agraph morphism h:G→Hbetween two graphsGandH wrt. the same signatureΣ= (S,O)consists of a family of vertex mappingsh= (hs:Gs→Hs)s∈S
and a family of edge mappingshO=hOf :fG→ fH
f∈Osuch that, for all operations f ∈Ow,v
and for all edgese∈fG, we have:5
dHf hOf(e)=hw dGf(e) andcHf hOf(e)=hv cGf(e).
3 Note that we generalise the usual notion of signature which allows single sorts as co-domain specification for
operations only. Operations inOw,εwill be interpreted as predicates, operations inOw,vwith|v|>1 will be interpreted
as operations which deliver several results simultaneously. 4Forw∈S∗and a family(G
s)s∈Sof sets,Gwis recursively defined by (i)Gε={∗}, (ii)Gw=Gsifw=s∈Sand
(iii)Gw=Gv×Guifw=vu.
5Given a sort-indexed family of mappings(f
s:Gs→Hs)s∈S, fw:Gw→Hwis recursively defined for everyw∈S∗
by (i)fε={(∗,∗)}, (ii)fw=f
The category of all graphs and graph morphisms wrt. a signature Σ is denoted by GΣ in the following.6 GΣ is complete and co-complete. All limits and co-limits can be constructed component-wise on the underlying sets. The pullback for a co-span B→m A←n C is given by the partial product B×(m,n)C with the two projection morphisms πBB×C:B×(m,n)C→B and
πCB×C:B×(m,n)C→C:
∀s∈S: B×(m,n)C
s = {(x,y)::ms(x) =ns(y)}
∀f ∈Ow,v: f(B×(m,n)C) =
(x,y)::mOf(x) =nOf(y)
∀f ∈Ow,v:d
(B×(m,n)C)
f ::= (x,y)7→d B
f(x)||wdCf(y)
∀f ∈Ow,v:c(
B×(m,n)C)
f ::= (x,y)7→c B
f(x)|| v
cCf(y),
where the operator||w:Bw×Cw→(B×C)w
transforms pairs ofw-tuples intow-tuples of pairs: x1, . . . ,x|w|
, y1, . . . ,y|w|
7→ (x1,y1), . . . x|w|,y|w|
. A graphG∈GΣ=(S,O) is apartial
al-gebra, if it satisfies for all f ∈O:
∀e1,e2∈ fG:dGf(e1) =dGf(e2) =⇒ e1=e2. (1)
The full sub-category ofGΣconsisting of all partial algebras7is denoted byAΣin the follow-ing. In a partial algebraA, operations f ∈Oε,v with|v|>0 are interpreted as (partial)constants,
i. e. fA :Aε →Av is a partial map from the standard one-element setAε ={∗}into Av.
Sym-metrically, operations p∈Ow,ε with|w|>0 are interpreted aspredicates, sincep
A:Aw→ {∗}
is a partial map into the standard one-element set, i. e. it determines a subset onAwonly, namely the part ofAw where it is defined. Finally for operations f ∈Oε,ε, there are only two possible
interpretations inA, namely fA=/0 (false) or fA={(∗,∗)}(true). Thus fAis just a boolean flag. Due to formulae (1) being a set of Horn-axioms,AΣ is an epireflective sub-category ofGΣ, i. e. there is a reflection that maps a graphG∈GΣ to a pair GA ∈AΣ,ηG:G→GA
such that any graph morphismh:G→AwithA∈AΣhas a unique extensionh∗:GA →Awithh∗◦ηG=h.
Since epireflective subcategories are closed wrt. products and sub-objects defined by regular monomorphisms (equalisers), the limits inAΣ coincide with the limits constructed inGΣ. AΣ has also all co-limits, since epireflections preserve co-limits. In general, however, the co-limits inAΣdo not coincide with the co-limits constructed inGΣ. The reflection provides the necessary correction. If, for example,(b:A→B,c:A→C)is a span inAΣ and(c∗:B→D,b∗:C→D) is its pushout constructed inGΣ, ηD◦c∗:B→DA,ηD◦b∗:C→DA
is the pushout inAΣ. Besides being complete and co-complete, the most important property ofAΣ for the rest of the paper is the existence of right adjoints to all inverse image functors. If we fix an algebra A∈AΣ,AΣ↓MAdenotes thecategory of all (weak) sub-algebrasofA. The objects inAΣ↓MA
6 The identities inG
Σ are given by families of identity mappings, and composition of morphisms is provided by
component-wise composition of the underlying mappings. 7Note that the interpretation of an operationf∈O
w,vin a partial algebraAis a partial map: Due to condition (1), the
assignment
fA,dAf :fA→Aw,cAf:fA→Av
7→ndAf(e),cAf(e)
::e∈fA
o
provides a partial map fromAwtoAv.
are all monomorphismsm:MAand a morphism inAΣ↓MAfromm:MAton:NAis a (mono)morphismh:MNinAΣ such thatn◦h=m.8 For anAΣ-morphismg:A→B, the inverse image functor g∗:AΣ↓MB→AΣ↓MAmaps an objectm:M→B∈AΣ↓MBtoπ
A×M A : A×(g,m)M→A and a morphism h:(m:M→B)→(n:N→B) to the uniquely determined
morphismg∗(h):A×(g,m)M→A×(g,n)N such thatπAA×N◦g∗(h) =πAA×M andπNA×N◦g∗(h) = h◦πMA×M.
Proposition 1 In a category AΣ of partial algebras, every inverse image functor g∗:AΣ↓M B→AΣ↓MA has a right adjoint called g∗:AΣ↓MA→AΣ↓MB.
Proof. Given a sub-algebram:MA, we construct the sub-algebrag∗(M)⊆Band the inclu-sion morphismg∗(m):g∗(M),→Bas follows:
∀s∈S:g∗(M)s =
b∈Bs::∀a∈g−1s (b)∃x∈M:ms(x) =a and
∀f∈Ow,v:fg∗(M) =
n
e∈ fB::∀ea∈ gOf
−1
(e)∃ex∈M:mOf(ex) =ea
o
,
such thatdgf∗(M) =dBf
|fg∗(M) andc g∗(M)
f =c B
f|fg∗(M) for every operation.
The co-unitεm:g∗(g∗(m:MA))→(m:MA)can be defined on every element(a,b)∈ A×(g,g∗(m))g∗(M)byεm(a,b) =csuch thatm(c) =a. Note thatεmis completely defined, since,
by definition ofg∗(m),amust have a pre-image wrt.mfor every pair(a,b)∈A×(g,g∗(m))g∗(M). It is uniquely defined, sincemis monic. By definition ofεm,m◦εm=g∗(g∗(m)) =πAA×(g,g∗(m))g∗(M)
which means thatεmis a morphism inAΣ↓MA.
Now, let an objectx:XB∈AΣ↓MBand a morphismk:g∗(x)→m∈A
Σ↓MA, i. e.m◦k=
πAA×(g,x)X be given. We construct k∗ :x →g∗(m) by e 7→x(e) for every e ∈X. The map-pings of k∗ are completely defined: (i) if x(e)∈/ g(A), x(e)∈g∗(M) because g−1(x(e)) = /0, and, otherwise, the existence of k with m◦k =π
A×(g,x)X
A enforces that every g-pre-image of x(e) has a pre-image under m. By definition, g∗(m)◦k∗ =x. By definition of the inverse image functor, g∗(k∗) : A×(g,x)X→ A×(g,g∗(m))g∗(M) maps (a,e) to (a,k∗(e)). Thus,
ε(g∗(k∗)(a,e)) =ε(a,k∗(e)) =cwithm(c) =aandk(a,e) =c0withm(c0) =π
A×(g,x)X
A (a,e) =a.
Sincemis monic,c=c0. The morphismk∗is uniquely determined, sinceg∗(M)⊆Bandg∗(m) is monic.
Corollary 1 If g is monic, the co-units of g∗are isomorphisms.
For every algebraA, the categoryAΣ↓MAof all (weak) sub-algebras ofAhas two important sub-categories, namely AΣ↓FA and AΣ↓CA, i. e. the category of all full respectively closed sub-algebras of A. A morphism m:M→A is full, if for every e∈ fA, f ∈Ow,v, and w,v∈ S∗ with dAf(e) =mw(x) and cAf(e) =mv(y) for some (x,y)∈Mw×Mv there is e0 ∈ fM with e=m(e0); it is closed, if for every e∈ fA, f ∈Ow,v, and w,v∈S∗ with dAf(e) =mw(x) for x∈Mwthere ise0∈ fMwithe=m(e0).9 By definition,AΣ↓CA⊆AΣ↓FA⊆AΣ↓MAfor every
8Note that every sub-graph ofAis a sub-algebra ofA, since all monomorphisms inG
Σare regular and epireflective
sub-categories are closed wrt. regular sub-objects.
A∈AΣ. The three different sorts of sub-algebras induce three factorisation systems in every category of partial algebras, namely factorisations in (i) closed epimorphisms10 and arbitrary monomorphisms, (ii) morphisms with surjective vertex mappings and full monomorphisms, and (iii) arbitrary epimorphisms and closed monomorphisms.
Since pullbacks preserve full and closed monomorphisms11, we obtain restrictionsg∗F:AΣ↓F B→AΣ↓FAandg∗
C:AΣ↓CB→AΣ↓CAof the inverse image functorg∗:AΣ↓MB→AΣ↓MAfor every morphismg:A→B.
Proposition 2 In a categoryAΣof partial algebras, every inverse image functor g∗F:AΣ↓FB→
AΣ↓FA has a right adjoint called gF∗:AΣ↓FA→AΣ↓FB. If g is monic, the co-units of gF∗ are isomorphisms.
Proof. We show thatg∗:AΣ↓MA→AΣ↓MBmaps full monomorphisms to full monomorphisms. Letm:MAbe full,e∈ fBwith f ∈Ow,v, andw,v∈S∗such that (i)dBf(e) =g∗(m)
w
(x)and (ii)cBf(e) =g∗(m)v(y). Ifg(e0) =e, properties (i) and (ii) together with the construction ofg∗in the proof of Proposition1implydAf(e0) =mw(x0)andcAf(e0) =mv(y0)for some(x0,y0)∈Mw×Mv. Since mis full, e0=mOf(e00). Thus, every e0 with g(e0) =e has a pre-image under mOf which implies thatehas a pre-image underg∗(m)Of.
The inverse image functors between closed sub-algebras do not possess right adjoints in gen-eral as the following examples illustrate:
Example1 (Missing right adjoint) Consider the signatureΣ2= S2,O2
with
S2 = {s}andO2w,v=
(
{f} w=ss,v=s
/0 otherwise ,the three algebras
A ::= As={2}, fA=/0,
B ::= Bs={0,1,2}, fB= {fB},dBf(f B) = (
0,1),cBf(fB) =2, M ::= Ms=/0,fM=/0,
the morphismg:A→B::=27→2, and the closed monomorphismm:MA::=/0. There are
seven closed sub-algebras ofB, namelyBitself and six algebras⊆x:Bx→B,x∈ {1,2,3,4,5,6}
with completely undefined f and carriersB1s =/0,B2s ={0},Bs3={1},B4s ={2},B5s ={0,2},
andB6s ={1,2}for sorts.12 None of these algebras can be the right adjoint object form:Bitself
and casesx∈ {4,5,6}are excluded since there is no object inMwhere the object(2,2)in the
partial productA×(g,⊆x)Bx can be mapped to. The casesx∈ {1,2,3}provide an empty partial
product of⊆xwithg. Thus, there is the empty morphism from
πA:A×(g,⊆x)Bx→Atomwhich
can play the role of the co-unit. But there is no morphism from⊆2 to⊆1 or⊆3 and there is
no morphisms from⊆3 to⊆2. Thus, havingO
w,v6= /0 for|w| ≥2 and|v| ≥1in the signature
prevents the existence of right adjoints in some cases.
10A morphismh:A→Bis closed, if its image inBis a closed sub-algebra ofB.
11 Pullbacks preserve all monomorphisms in a classN, if the underlying category has an epi-mono-factorisation
system(E,N).
Also constants, i. e. operations inOε,vwith|v| ≥1, are harmful. A simple example provides
the signatureΣ0= S0,O0
with
S0 = {s}andO0w,v=
(
{f} w=ε,v=s
/0 otherwise ,the three algebras
A ::= As={f,0}, fA= {fA},dAf(f A
) =∗,cAf(fA) = f B ::= Bs={f},fB= {fB},dBf(f
B
) =∗,cBf(fB) =f M ::= Ms={f,}, fM= {fM},dMf (fM) =∗,cMf (fM) = f
the morphismg:A→B::= f 7→ f,07→ f, and the closed monomorphismm:MA::= f 7→
f. There is only one closed sub-algebra of B, namely B itself. But idB cannot be the right
adjoint object form, since there is no mapε: πA:A×(g,idB)B
→m. The problematic object in
A×(g,id
B)Bis(0,f)theA-projection of which provides0which has no pre-image underm.
Definition 1(Graph Structure) Agraph structureΓ= (S,(Ow,v)w,v∈S∗)is a signature with unary
operations only, i. e.Ow,v=/0 ifv=6 ε and|w| 6=1.13
Proposition 3 For a graph structureΓ, the inclusion functor⊆:AΓ↓CA→AΓ↓FA has a right adjoint.
Proof. (Sketch) Given a graph structureΓ= (S,O)and a full sub-algebra (m:MA)∈AΓ, construct the following family of carriers:
Ms0={x∈Ms :: fA(x)∈ M0 v
for allv∈S∗andf∈Os,v}
s∈S.
LetM0 be the largest full sub-algebra ofAcontained in(Ms0)s∈S. SinceM
0⊆M, we can use this
inclusion as the required co-unit. It is easy to see, that M0 is a closed sub-algebra of A. And, by construction, any other closed sub-algebra ofAthe carriers of which are contained inMis a sub-algebra ofM0.
Corollary 2 Given a graph structureΓ, every inverse image functor g∗C:AΓ↓CB→AΓ↓CA has a right adjoint called gC∗ :AΓ↓CA→AΓ↓CB. If g is monic, the co-units of gC∗ are isomorphisms.
3
Partial Morphisms on Partial Algebras
In order to obtain frameworks for single-pushout rewriting, we proceed from the category of partial algebras withtotalmorphisms to the categories of partial algebras andpartialmorphisms. In this section, we investigate the conditions under which pushouts can be constructed in these categories.
13Note that this notion of graph structure is a straightforward extension of the one in [12] to signatures with predicate
3.1 Pushouts in Arbitrary Categories of Partial Morphisms
LetC be a category andS a sub-class of its monomorphisms such that
(C1) C has a factorisation system(E,S)for a class of (epi)morphismsE,
(C2) S contains all isomorphisms and is closed wrt. composition and prefix14,
(C3) C has pullbacks alongS-morphisms which preserveS-morphisms15.
AconcreteS-partial morphismis a span of C-morphisms(p:K P,q:K→Q) such that p∈S. Two concrete S-partial morphisms (p1,q1) and (p2,q2) are equivalent and denote the same abstract S-partial morphism if there is an isomorphismisuch that p1◦i=p2 and q1◦i=q2; in this case we write(p1,q1)≡(p2,q2)and[(p,q)]≡ for the class of spans that are equivalent to(p,q). Thecategory of S-partial morphisms CS overC has the same objects asC and abstractS-partial morphisms as arrows. The identity idCAS for an objectAis defined
by idCAS = [(idA,idA)]≡and composition ofS-partial morphisms[(p:KP,q:K→Q)]≡and [(r:JQ,s:J→R)]≡is given by
[(r,s)]≡◦CS[(p,q)]≡=
(p◦Cr0:MP,s◦Cq0:M→R)
≡
where(M,r0:MK,q0:M→J)is an arbitrarily chosen pullback ofqandr.
Note that there is the faithful embedding functorι :C →CS defined by identity on objects and(f :A→B)7→[idA:AA,f:A→B]≡on morphisms. We call[d:A0A,f :A0→B]≡a totalmorphism, ifdis an isomorphism, and, by a slight abuse of notation, write[d,f]∈C. From now on, we mean the abstractS-partial morphism[f,g]≡if we write(f :BA,g:B→C).
The single-pushout approach defines direct derivations by a single pushout in a category of partial morphisms. There is a general result for the existence of pushouts in a categoryCS of partial morphisms based on the notionsfinalS-tripleandS-hereditary pushoutin the underly-ing categoryC of total morphisms.
Definition 2(Final S-triple) AS-triplefor a pair((l,r),(p,q))of morphisms inCS with common domain is given by a collection p,p∗,r,l,l∗,q of C-morphisms such that p∗, p, l∗, l are in S and (i)(r,p) is pullback of (r,p∗), (ii)(q,l) is pullback of (q,l∗), and (iii) l◦ p= p◦l. A S-triple p,p∗,r,l,l∗,q for ((l,r),(p,q)) is final, if, for any other S-triple p0,p0 ∗,r0,l0,l0 ∗,q0, there is a unique collection(u1,u2,u3)of (S-)morphisms such that(iv) p◦ u1=p0,(v) l◦u1=l0,(vi) p∗◦u2= p0 ∗,(vii) u2◦r0=r◦u1,(viii) l∗◦u3=l0 ∗, and(ix) u3◦q0= q◦u1, compare left part of Fig.1.
In [13], a sufficient condition for the existence of finalS-triples is shown.
Proposition 4 A categoryCS of partial morphisms has all finalS-triples, if (i)the inverse image functor g∗S :AΣ↓SB→AΣ↓SA has a right adjoint for each morphism g:A→B and (ii)everyS-chain(mi:Ai+1Ai)i∈N0 has a limit(li:A
∗
Ai)i∈N0.
16
14Closure ofS wrt. composition and prefix means that, giveng∈S,g◦f∈S⇔f∈S. 15I. e.g0∈S, if(f0,g0)is pullback in f◦g0=g◦f0andg∈S.
L K R A0 C0
P D P∗ B0 D0
D0 P0 A C
Q K∗ B D
K0
l r qi
pi
i0 p0
i i1 p
q l
q p
r
p∗
q0i
i2 i3
p0
r0
q0 l0
u1
p0∗
u2
q p
p0 l∗
q0 l0∗
u3
Figure 1: Final Triple and Hereditary Pushout
Definition 3(S-Hereditary pushout) A pushout(q0,p0) of(p,q) inC isS-hereditaryif for each commutative cube as in the right part of Figure1, which has pullback squares(pi,i0)and (qi,i0) of(i2,p) and(i1,q)resp. as back faces such thati1 andi2 are inS, in the top square, (q0i,p0i)is pushout of(pi,qi), if and only if, in the front faces,(p0i,i1)and(q0i,i2)are pullbacks of (i3,p0)and(i3,q0)resp. andi3is inS.17
Note that(q0i,p0i)is hereditary pushout of(pi,qi)in Figure1, if(q0,p0)is hereditary pushout
of(p,q).
Proposition 5(Pushout inCS) A given span of partial morphisms(l:KL,r:K→R)and (p:PL,q:P→Q) has a pushout((l∗,r∗),(p∗,q∗))inCS, if and only if there is(i) a fi-nal S-triplel :D→P, p:D→ K, r:D→P∗, q:D→K∗, p∗:P∗→R, l∗ :K∗→ Q for ((l,r),(p,q))and(ii)aS-hereditary pushout(r∗:K∗→H,q∗:P∗→H)for(q,r)inC, com-pare sub-diagrams (1) – (3) and (4) resp. in Figure2.
L K R
P D P∗
Q K∗ H
(1)
l r
(2)
p
q l
q p
r p∗
q∗
(3)
l∗ r∗
(4)
Figure 2: Pushout inCS
The proof can be found in [16]. A version of the proof that does not presuppose a choice of pullbacks that is compatible with pullback composition and decomposition is contained in [17].
3.2 Pushouts of Partial Morphisms on Partial Algebras
With the results of Section2, we can construct categories with three different types of partial morphisms over partial algebras, namelyAΣM,AΣF, and AΓC where M is the class of all, F the class of all full, C the class of all closed monomorphisms,Σis an arbitrary signature, andΓis
a graph structure. The general results about pushouts of partial morphisms carry over to these categories as follows:
Proposition 6(Final triple) InAΣM,AΣF, andAΓC, every pair((l,r),(p,q))of partial morph-isms with common domain has a final triple.
Proof. We use the condition of Proposition4. The existence of right adjoints to inverse image functors is given by Propositions1and2as well as Corollary2. Limits ofS-chains exist, since
AΣhas all limits.
Corollary 3(Pushout) Partial morphisms (l:KL,r:K→R) and(p:PL,q:P→Q) have a pushout inAΣM,AΣF, andAΓC, if and only if the pushout of(q,r)isM-,F-, orC-hereditary respectively, where l:D→P, p:D→K, r:D→P∗, q:D→K∗, p∗:P∗→R, l∗:K∗→Q is a finalM-,F-, orC-triple of((l,r),(p,q)), see Figure2.
Proof. Direct consequence of Proposition5and Proposition6.
Thus, the existence of pushouts inAΣM,AΣF, orAΓConly depends on the involvedAΣ-pushout being M-, F-, or C-hereditary, resp. We start with the analysis of M-hereditary pushouts inAΣ.
Proposition 7(Sufficient condition for M-hereditariness) If a pushout inAΣis also pushout in
GΣ, then it isM-hereditary inAΣ.
Proof. Let a commutative cube as in the right part of Fig.1inAΣ be given such that the back faces are pullbacks. Then this is also a situation inGΣand the back faces are also pullbacks in
GΣ, sinceAΣis an epireflection ofGΣ.
Let the front faces be pullbacks inAΣ andi3be a monomorphism. Then the front faces are also pullbacks inGΣ. Since all pushouts inGΣare hereditary,D0together withp0iandq0iis pushout
inGΣ. Since (i)AΣis closed wrt. sub-algebras, (ii)Dis inAΣ, and (iii)i3is monic,D0is also in
AΣand its reflectorηD0 is an isomorphism.18 Thus,D0together withp0 i andq
0
i is pushout inAΣ. Let(D0,q0i,p0i)be pushout of(pi,qi)inAΣ. Construct(D00,q00i,p00i)as pushout of(pi,qi)inGΣ. We obtain the epic reflectorηD00 :D00D0 with p0i=ηD00◦p00i andq0i=ηD00◦q00i. SinceD00 is
pushout, we also geti03:D00Dwithi03◦p00i =p0◦i1andi03◦q00i =q0◦i2. Sincei3◦ηD00◦p00 i = i3◦p0i=p0◦i1=i30 ◦p00i andi3◦ηD00◦q00
i =i3◦q0i=q0◦i2=i03◦q00i, we can concludei3◦ηD00=i0
3. Since all pushouts inGΣ are hereditary, i03 is monic implying thatηD00 is monic as well. Thus,
ηD00 is an isomorphism andD0is also the pushout inGΣ. This immediately provides monici3and
pullbacks in the front faces of the cube in the right part of Fig.1.
But not all pushouts inAΣare M-hereditary. Here is a typical example:
18Note that morphisms inG
a cL99fC
b dL99 fD
a cL99fC
bL99fB dL99 fD qi=q pi
i0=idA
p0i=p0 i1=idC q0is=q0s
i2s=idBs i3=idD q p
p0 q0
Figure 3: Simple Non-Hereditary Pushout inAΣ
Example2 Consider the signatureΣc= (Sc,Oc)with
Sc = {s}andOcw,v=
(
{f} w=ε,v=s
/0 otherwise,
the three algebras
A ::= As={a},fA=/0,
B ::= Bs={b},fB= {fB},dBf(f B
) =∗,cBf(fB) =b, C ::= Cs={c},fC= {fC},dCf(f
C) =∗,cC f(f
C) =c
,
and the two morphismsp:A→B::=a7→bandq:A→C::=a7→c. The pushout of(p,q)in
AP
Σc consists of the algebra
D::=Ds={d}, fD= {fD},dDf(f D
) =∗,cDf(fD) =d
and the two morphisms
p0:C→D ::= c7→d,fC7→ fD q0:B→D ::= b7→d,fB7→ fD.
This pushout is depicted in the bottom of Fig.3and is notM-hereditary. We construct the
follow-ing cube of morphisms, compare Fig.3:A0=A,i0=idA,B0is defined byB0s=Bsand fB
0 =/0,i2
mapsbinB0stobinBs,C0=C,i1=idC,qi=q, andpimapsatob. Note that(i0,qi)is pullback
of(q,i1)and(i0,pi) is pullback of(p,i2). Constructing(D0 =D,p0i= p0,q0i ::=b7→d) as the
pushout of(p0,q0), we obtaini3=idD. But(i2,q0i)is not pullback of(q0,i3):B×(q0,i3)D0contains
a defined constant for f, sincei3(fD) =q0(fB), andB0does not.
Note that theAΣ-pushout of the morphisms pandqin Example2does not coincide with the pushout ofpandqconstructed in the larger categoryGΣ. The pushout inGΣis the graph
G ::= Gs={g},fG= {fCG,f G B},d
G f(f
G C) =d
G f(f
G B) =∗,c
G f(f
G C) =c
G f(f
G B) =g
together with the morphisms
p00:C→G ::= c7→g,fC7→ fCG q00:B→G ::= b7→g,fB7→ fBG.
The partial algebra Dis the epireflection of the graphGand the reflector ηG:G→Dmaps
as follows: g7→d, fCG7→ fD, and fBG7→ fD. The identificationηG(fCG) =ηG(fBG) = fDof the
reflector provided the possibility to construct the commutative cube in Example2that disproves M-hereditariness of the pushout of(p,q). The following proposition shows that this construction of a counterexample is always possible if the pushouts inAΣandGΣare different.
As a prerequisite, we need the following construction.
Definition 4(Vertex- and hyperedge-generated sub-span) Let a signatureΣ= (S,O)and anAΣ -spanB←−p A−→q Cbe given. Fors∈S, let≡sp,q⊆(Bs]Cs)×(Bs]Cs)denote the equivalence
generated by{(ps(z),qs(z))::z∈As} and, for f ∈O, let≡ p,q f ⊆ f
B]fC
× fB]fC denote the equivalence generated by{(pO
f(z),q O
f(z))::z∈ f A}.
For a vertex e∈Bs, the sub-algebrasBe⊆B,Ce ⊆C, andAe⊆A are defined byBes =Bs∩ [e]≡p,q
s ,C e
s =Cs∩[e]≡sp,q,A e
s={a∈As::ps(a)∈[e]≡sp,q},B e
s0 =Cse0 =Ase0 = /0 for alls06=s, and fB= fC= fA=/0 for all f∈O.
For a hyperedgee∈ fB with dBf(e) = (d1, . . . ,dn)andcBf(e) = (c1, . . . ,cm), the sub-algebras Be ⊆B, Ce ⊆C, andAe ⊆A are defined by Bes =S
x∈e↔Bxs, Cse =Sx∈e↔Csx, Aes =Sx∈e↔Axs, fBe=fB∩[e]≡p,q
f , f
Ce=fC∩[e]
≡pf,q, fA
e
={n∈ fA::pOf(n)∈[e]≡p,q
f }, and f
0Be=f0Ce= f0Ae=/0
for all f06=f ∈Owheree↔={d1, . . . ,dn,c1, . . . ,cm}.
Proposition 8(Necessary condition for M-hereditariness) If a pushout inAΣ isM-hereditary, it is also pushout inGΣ.
Proof. Let(p:A→B,q:A→C)be a span of morphisms inAΣ, let(E,q
00:B→E,p00:C→
E) be its pushout in GΣ, and let(q0:B→D,p0:C→D) be its pushout in AΣ. SinceAΣ is epireflective sub-category ofGΣ, we know thatD=EA,q0 =ηE◦q00 and p0=ηE◦p00 where
ηE :E→EA is the reflector for the graphE. SupposeDandE are not isomorphic, then there
arex,y∈E such thatx6=yandηE(x) =ηE(y) =z. Since p00andq00are jointly epic inGΣ, both xandyhave pre-images underp00and/orq00. Letx00,y00∈B]Cbe these pre-images and suppose, without loss of generality,x00∈B.
We construct a cube as in Fig.1(right part) using the construction of Definition4forx00: Let B0=Bx00,C0=Cx00, andA0=Ax00,i0:A0 A,i1:C0C, andi2:B0Bbe the sub-algebra inclusions, and let p0 =p|A0 andq0 =q|A0. By construction,(pi,i0) and(qi,i0) are pullbacks.
Sincex6=y, we have[x00]≡p,q 6= [y00]≡p,q and can conclude thaty00has neither a pre-image under
i1nor underi2. Construct theAΣ-pushout(p0i:C0→D0,q0i:B0→D0)of(q0,p0)which provides
the morphisms i03 :D0→E andi3=ηE◦i03:D0 →D making the whole cube commute. By
construction,z=ηE(x) =ηE◦q00(x00) =ηE◦q00◦i2(x00) =ηE◦i03◦q0i(x00) =i3◦q0i(x00). Thus,z
has a pre-image underi3andz=q0(y00)orz=p0(y00). Sincey00has neither a pre-image underi1 nor underi2, one of the front faces of the constructed cube fails to be a pullback.
Now, we investigate F-hereditary pushouts inAΣ. In Example2, the morphismi2 is not full, compare Figure3. If monomorphisms are restricted to full ones, the situation in Figure3cannot occur. This observation leads to the following characterisation of F-hereditary pushouts inAΣ.
Theorem 2 A pushout(q0,p0)of(p,q)inAΣ isF-hereditary, iff (q0s,p0s)is pushout of(ps,qs) in the category of sets and mappings for all sorts s∈Σ.
Proof. “⇐”: Let a commutative cube as in the right part of Fig.1inAΣbe given such that the back faces are pullbacks. Let the top be pushout in AΣ. Then, for every sort s, the pushout
Es,q00i s:B0s→Es,p00i s:C0s→Es
of(pi s,qi s)provides epicus:Es→D0s. Since all pushouts
of mappings are hereditary, we obtain monic i03s:Es→Dswith i3s◦us=i03s. Thus,usis monic
and epic which implies, for all sortss,(D0s,p0i s,q0i s)is pushout,i3sis monic, and(p0i s,i1s)as
well as(q0i s,i2s)are pullbacks. Thati3is full, follows from p0 andq0being jointly epic andi1 andi2being full. Given d∈ fDwithd=i3(d0) andd=p0(c), there isc0∈ fC
0
withi1(c0) =c and p0i(c) =d0, since i1 is full. Therefore(p0i,i1) is pullback. An analog argument provides that(q0i,i2)is pullback. Vice versa, ifi3is full monomorphism and(p0i,i1)as well as(q
0
i,i2)are
pullbacks, they are pullbacks for each sort mapping. This implies that(p0i s,q0i s)is pushout for every sorts. It remains to show thatp0iandq0i are jointly epic on hyperedges. But this is a direct consequence of p0andq0being jointly epic andi1andi2being full.
“⇒”: We repeat the argument in the proof of Proposition8: Let there be a sorts, such that the pushout(Es,q00s :Bs→Es,p00s :Cs→Es)is different from(Ds,q0s,p0s). Then there arex6=ysuch
thatus(x) =z=us(y)for the unique morphismus:Es→Dswithus◦q00s =q0sandus◦p00s =p0s.
Without loss of generality, assume y has a pre-image y00 under p00 and/or q00 andx=q00s(x00). Consider again the sub-span of(p,q)induced byx00: LetA0,B0, andC0 be thefullsub-algebras ofA, B, andC induced by Ax00, Bx00, andCx00 respectively, let pi = p|A0 and qi =q|A0, and let i0 :A
0
A, i1:C
0
C, and i2:B
0
B be the inclusions. We obtain pullbacks(i0,p0) and (i0,q0). Constructing the pushout(q0i,p
0
i)of(pi,qi),z has a pre-image underi3. We also know z=q0(y00)orz=p0(y00). By construction,y00has neither a pre-image underi1nor underi2. Thus, either(i2,q0i)or(i1,p0i)is no pullback.
The analysis of C-hereditary pushouts inAΓfor a graph structureΓis more complicated than the analysis of M- and F-hereditary pushouts as the following example demonstrates.
Example3 (C-hereditary pushout) Consider the span(p:A→B,q:A→C)inAΓ where the
underlying graph structureΓC= SC,OC
is defined by
SC = {s} andOCw,v=
(
{f} w=s,v=s
/0 otherwise,
the three algebrasA,B, andCare given by
A ::= As={a1;1,a1;3,a3;1}, fA= /0,
and the two morphismspandqmap as follows:
ps:As→Bs ::= a1;17→b1,a1;37→b1,a3;17→b3 qs:As→Cs ::= a1;17→c1,a1;37→c3,a3;17→c1.
The pushout of(p,q)inAΓconsists of the algebra
D::=Ds={d2;2,d1,3;1,3}, fD::=d2;27→d1,3;1,3,d1,3;1,37→d2;2
and the two morphisms
p0:C→D ::= c17→d1,3;1,3,c27→d2;2,c37→d1,3;1,3
q0:B→D ::= b17→d1,3;1,3,b27→d2;2,b37→d1,3;1,3.
This pushout inAΓ does not induce a pushout in the category of sets and maps for the sorts,
sincep0s(c2) =d2;2=q0s(b2)withoutb2≡p,qc2. Nevertheless, it isC-hereditary, since the only
possible sub-spans of(p,q)in a commutative cube as in Figure1(right part) with pullbacks in the
back faces and closed monomorphismsi1andi2are(/0,/0)and(p,q)itself. Having, for example
c2 inC0 requires alsoc3∈C0. This impliesb1,b2,b3∈B0due to p(a1;3) =b1andq(a1;3) =c3.
Now, p(a3;1) =b3andq(a3;1) =c1requiresc1∈C0. Thus, having one of the elements ofBand
Cin the sub-span requires having all of the elements in the sub-span. This is due to the cyclic
structure established by fB, fC, and the mapping ofa1;3anda3;1by pandq.
Definition 5(Hierarchical span) Given a graph structureΓ= (S,O)and a span(p:A→B,q:
A→C)inAΓ, itsreachability relationR on the disjoint unionU
s∈SBs]Us∈SCsof the carriers
ofBandCis defined byxRyif(i) x≡sp,qyfor some sorts,(ii)(z1, . . . ,zn) = fB]C(x)for some f ∈Os,v, n≥1, andy=zi for 1≤i≤n, or(iii) xRz andzRy.19 A span(p,q) ishierarchical,
ifxRyandyRximpliesx≡p,qy. R(x)denotes the elements reachable fromx, i. e. R(x) ={z∈
U
s∈SBs]Us∈SCs::xRz}
Theorem 3 A pushout (q0 :B→ D,p0 :C→D) of a hierarchical span (p,q) in AΓ is C -hereditary, iff(q0s,p0s)is pushout of(ps,qs)for all sorts s∈Σ.
Proof. (Sketch) For the “⇐”-part, we can repeat the arguments in the “⇐”-part of the proof for Theorem2substituting fullness by closedness. The “⇒”-part also follows the outline given by the “⇒”-part of the proof for Theorem2. Havingx6=y∈Esandus(x) =us(y)where(Es,p00s : Cs→Es,q00s:Bs→Es)is the pushout of(qs,ps)andus:Es→Dsthe mediating map withus◦p00s= p0sandus◦q00s =q0s, we know for the pre-imagesx00ofxandy00ofyunder p00and/orq00that either x00is not reachable fromy00 ory00 is not reachable fromx00. Without loss of generality, suppose the second case and construct B0 as the full sub-algebra ofBinduced by B∩R(x00),C0 as the full sub-algebra ofC induced byC∩R(x00), and A0 as the full sub-algebra of A induced by {a∈A::p(a)∈R(x00)}. Leti0:A0→A,i1:C0→C, andi2:B0→Bbe the corresponding closed inclusions and pi=p|A0 andqi=q|A0. Since we know thaty00neither has a pre-image underi1
nor underi2, either(i1,p0i)or(i2,q
0
i)is not a pullback. 19 fB]C:B
L K R
G K∗ t@m
m
l
mhli
r
mhti
(1)
lhmi rhmi
(2)
Figure 4: Single- versus Sesqui-Pushout Transformation
Definition 6(Hierarchical graph structure) A graph structureΓ= (S,O)is hierarchical, if the
reflexive/transitive closure of the relation on S defined by ss0 if there is f ∈Os,vs0u with v,u∈S∗is a partial order.
Corollary 4 For a hierarchical graph structureΓ, a pushout(q0,p0)of a span(p,q)inAΓ is C-hereditary, iff(q0s,p0s)is pushout of(ps,qs)for all sorts s∈Σ.
4
Rewriting of Partial Algebras: Some Theory
In this section, we introduce single-pushout rewriting in the categories of partial algebras. For a rich theory, we restrict transformations to those that produce total co-matches. All definitions and propositions in the following presuppose an arbitrary underlying categoryAΣM,AΣF, andAΓC for a signatureΣor hierarchical graph structureΓ.20
Definition 7 (Rule and transformation) A transformation rule t is a partial morphism t = (l:KL,r:K→R). There is adirect transformationof ahost graph Gto the result graph t@mwith a rulet:L→Rif there aretotalmorphismsm:L→Gandmhti:R→t@mas well as a partialmorphismthmi= (lhmi:K∗→G,rhmi:K∗→t@m):G→t@msuch that(thmi,mhti) is pushout of(t,m). In a direct transformation, mis calledmatch,mhtico-match, andthmitrace of the transformation.21
Since we restricted transformations to total co-matches, we obtain a close connection of our transformations to Sesqui-Pushout Rewritings in the sense of [3], which are composed of final pullback complements and pushouts.
Theorem 4(Single- and sesqui-pushout transformation) There is a transformation with rule t= (l:KL,r:KR), match m:L→G, (total) co-match mhti:R→t@m and trace thmi= (lhmi:K∗G,rhmi:K∗t@m), if and only if there is a total morphism mhli:K→K∗such that(i)(l,mhli)is pullback of(m,lhmi), (ii)lhmi=m∗(l), and (iii)(rhmi,mhti)is hereditary pushout of(r,mhli), compare (1) and (2) in Fig.4.
Proof. Direct consequence of the construction of final triples in [17] and the fact that the match and the co-match are total.
20 Note that the theory in this section is also valid inAC
Σ for arbitrary signatures, although existence of a direct
L1 K1 R1 L2 K2 R2
L01 K10 M K20 R02
G D1 t1@m1 D2 t2@m2
m1
e001
m1hl1i
e01 l1 r1
m1ht1i
e1
m2
e2
m2hl2i
e02
l2 r2
m2ht2i
e002
s01
l10 r10
s1 s s2
l20 r20
s02
l1hm1i r1hm1i l2hm2i r2hm2i
Figure 5: Hereditary Pushout and Final Pullback Complement
Thus, our set-up of single-pushout rewriting isSesqui-Pushout Rewriting at left-linear rules with the additional requirement that the involved pushout on the transformation’s right-hand side is hereditary. This close connection between Single-Pushout and Sesqui-Pushout Rewriting leads to a rich theory for Single-Pushout Rewriting with total co-matches in general and in the special case of partial algebra transformation. In this paper, we present the concurrency theorem. It is a good example to demonstrate how far the theory for Single-Pushout Rewriting of total algebras carries over to partial algebras and where the differences are. We additionally presuppose:
(C4) C has all finite co-limits and
(C5) For every morphismg∈S, all co-units ofg∗are isomorphisms.
Definition 8(Concurrent rule) Two transformationst1hm1i:G→t1@m1andt2hm2i:t1@m1→ t2@m2with rulest1:L1→R1andt2:L2→R2constitute aconcurrent rule t2hm2i ◦t1hm1i:G→ t2@m2, if the match of the first and the match of the second are “jointly epic”, i. e. the co-product morphisms{m1ht1i,m2}:R1+L2→t1@m1making the diagram commute is inE.22
Theorem 5 Given two transformations t1hm1i:G→t1@m1 and t2hm2i:t1@m1→t2@m2, there is a direct transformation with a concurrent rule t2hn2i ◦t1hn1i at a match n, such that (t2hn2i ◦t1hn1i)hni=t2hm2i ◦t1hm1i.
Proof. Consider Figure5. The first transformation uses rulet1= (l1:K1→L1,r1:K1→R1) at matchm1and produces tracet1hm1i= (l1hm1i,r1hm1i)and co-matchm1ht1iand the second uses rulet2= (l2:K2→L2,r2:K2→R2)at matchm2with tracet2hm2i= (l2hm2i,r2hm2i)and co-matchm2ht2i. Let(R1+L2,i1:R1→R1+L2,i2:L2→R1+L2)be the co-product ofR1and L2 and let {m1ht1i,m2}:R1+L2→t1@m1 be the unique morphism with {m1ht1i,m2} ◦i1= m1ht1iand{m1ht1i,m2} ◦i2=m2. Construct(e:R1+L2→M,s:Mt1@m1)as the(E,S) -factorisation of{m1ht1i,m2}and sete1=e◦i1ande2=e◦i2. Now,e1ande2are “jointly epic”.
Construct(s1,r01)as the pullback of(r1hm1i,s)and lete01 be the morphism making the dia-gram commute. Since pullbacks preserve morphisms inS,s1∈S. Now,(r01,e1)is hereditary pushout of(e01,r1), since (i)(r1hm1i,s◦e1)is hereditary pushout of(r1,m1hl1i),(ii)(e1,idR1)is
pullback of(m1ht1i,s), (iii)(e01,idK1)is pullback of(m1hl1i,s1), and (iv)(r1,idK1) is pullback
of(idR1,r1). Properties (ii) and (iii) are implied bysands1being monic. Construct(s
0 1,l
0 1)such that(l10,s1) is pullback of(l1hm1i,s01) and s01=l1hm1i∗(s1) and e001 as the morphism making the diagram commute. Since also(e01,idK1)is pullback of(m1hl1i,s1),(e
00
1,idL1)is pullback of
(m1,s01),(l1,idK1)is pullback of(idL1,l1), and final pullback complements are stable under
pull-backs, l01= e001∗(l1). Thus,(l10,r10) ande1 constitute a pushout of(l1,r1) ande001 inCS. This implies that(t1hm1i,s)is pushout of(l01,r01)ands01.
Construct(s2,l20) as the pullback of(l2hm2i,s)and let e02 be the morphism making the dia-gram commute such that s2 ∈S. Since also (e02,idK2) is pullback of (m2hl2i,s2), (e2,idL2)
is pullback of (m2,s), and(l2,idK2) is pullback of (idL2,l2), l
0
2= e2∗(l2). Finally, let (r02,e002) be the pushout of(r2,e02) ands
0
2the morphism making the diagram commute. Since the push-out(r2hm2i,m2ht2i) is hereditary,(e02,idK2)is pullback of(l
0
2,s2), and(idK2,r2) is pullback of
(idR2,r2), we conclude that(e
00
2,r20)is hereditary pushout of(e02,r2). Thus,(l20,r02)ande002 consti-tute a pushout of(l2,r2)ande2inCS, and(t2hm2i,s02)is pushout of(l
0 2,r
0
2)ands.
Since pushouts compose, we found the concurrent rulet2he2i ◦t1he001iand the matchs01 such that(t2he2i ◦t1he001i)hs01i=t2hm2i ◦t1hm1i.
The opposite of Theorem5, i. e. that every transformation with a concurrent rule at a match in
S can be decomposed into transformations with the component rules, is true in suitable categor-ies of total algebra whereallpushouts are hereditary. This is no longer the case in categories of partial algebras as the following example demonstrates.
Example 4 (Hidden “element”) Consider again the signature Σc of Example2, the category
AM
Σc, the partial algebras
A ::= As={a}, fA=/0 and B ::= Bs={b}, fB= {fB},dBf(f
B) =∗,
cBf(fB) =b,
and the total morphism p:A→B::=ps(a) =b. Instantiate the diagram in Fig.5byL1=L01=
K1=K10 =K2=K20 =R2=R02:=A, R1=L2 =M:=B, l1=l10 =e001 =e01=r2=r20 =e02=
e002 :=idA, e1=e2=idB, and r1=r01=l2=l20 :=p. These definitions result int2◦t1:L1→
R2= (idA,idA). Now letG=Bands01=p. Thent2◦t1is applicable ats01and produces the trace
t2◦t1hs01i= (idB,idB) and the co-matchs10 ht2◦t1i=p. Butt1 is not applicable at s01◦e
00 1=p,
since the transformation inGΣMresults in a pushout as in Figure3which is not hereditary inAΣM.
Thus, the fact that not all pushouts in categories of partial algebras are hereditary hinders transfer of some theoretical results from the total case to partial algebras. This disadvantage in theory pays off in practical applications as the examples in the next section will show.
5
Rewriting of Partial Algebras: Some Applications
Given a signatureΣ, rewriting inAΣM,AΣF, andAΓC differs in the possibilities for a rule’s
left-hand side to delete hyperedges23and the concrete application conditions stipulated by the fact
23InAM
Σ , arbitrary hyperedges (operation and/or predicate definitions) can be deleted without deleting any vertex,
that a transformation requires a hereditary pushout on its right-hand side. In this section, we consider examples inAΣMonly, since the application conditions can easily be checked.
Proposition 9 For rule t= (l,r)and match candidate m inAΣM, there is a morphism mhlisuch that(l,mhli)is pullback of(m∗(l),m), if and only if m isconflict-free, i. e. m(x) =m(y) and t defined for x implies that t is defined for y.24
Proof. Using the construction of the right adjoint in Proposition1, it is easy to check that the co-unit ofm∗forlis an isomorphism, iff this condition holds.
This result leads to the following procedure for rule application at a given match candidate:
Algorithm 1 Application of rule (l:K L,r :K →R) at match candidate m:L→G is performed in five steps:
1. Check the condition of Proposition9! Proceed, if valid, abort otherwise!
2. Construct(m∗(l):K∗→G)andlhmi:K→K∗, such that(lhmi,l)is pullback of(m,m∗(l))!
3. Construct the pushout(rhmi:K∗→H,mhti:R→H)ofrandlhmiinGΣ!
4. Check uniqueness condition (1) on page3forH!
5. Finish transformation if the check in4is positive, rollback otherwise!
sorts O, Int
opns i:O --> Int ( )
+:Int,Int --> Int
o i setset o
i o i
i' changechange o
i
i'
Figure 6: Setting and Changing an Attribute
The application condition in Algorithm1(4), can be usefully exploited in many practical ap-plications as a condition that prevents rule application. Our first example is a simple integer attributeithat can besetorchangedfor objects of typeO. Figure6shows the underlying signa-ture25and the two rules. Note that, due to the check in Algorithm1(4), theset-rule can only be applied in a situation where thei-attribute ofohas not been set yet. If there is an old value, the
change-rule must be applied.
sorts O
opns ≤:O,O ( )
o reflexivereflexive o
transitivetransitive
o
o
o o
o
o
Figure 7: Reflexive/Transitive Closure
domain or codomain), and, inAΓC, deletion of a hyperedge is only possible, if the domain vertex of this hyperedge is deleted as well.
24This condition is calledconflict-freenessin [12] and [3] as well.
The next example handles the reflexive and transitive closure of a relation on the setO. We just apply the two rulesreflexiveandtransitiveas long as there are matches. Note that the algorithm terminates, since the rulereflexivecannot add loops to objects that possess a loop already. This is again due to the application condition in Algorithm1(4). If all “abbreviations” are added, also the ruletransitiveis not applicable any more.
The next example in Figure8 shows a typical copying process, here for a structure that is built up by the partial dyadic operationt. The unary predicatermarks the root of the structure to be copied. The start and the three copy rules perform the actual copy process. And the operationckeeps track of already built copies. Again, the application condition of single pushout rewriting for partial algebras guarantees thatexactly onecopy is made. Note that this copy mechanism works for hierarchical and even cyclic structures.
sorts N ( )
opns t:N,N --> N ( )
c:N --> N ( )
r:N ( )
start
start
copycopy11
copy
copy11
copy
copy11
copy
copy22
copycopy11
copy
copy33
Figure 8: Copying
A situation as in the preceding example often occurs in the software engineering area of model transformation where objects in a source model must be mapped to objects in a target model. The transformation process starts with a completely undefined mapping and stops if the map-ping is sufficiently defined. Uniqueness of the mapmap-ping has to be guaranteed during the whole transformation process. This is a perfect application scenario for our new rewriting approach. As an example consider the mapping of (small) object-oriented models to relational database
MT = OO + DB +
opns to: Class --> Table ( ) to: Attribute --> Column ( ) to: Association --> Table ( )
Figure 9: Object-oriented Model, Relational Schema, and Inter-Model Mapping
(OO-part in Fig.9) consists of classes, (untyped) attributes, and binary associations. A relational schema (DB-part in Fig.9) comprises tables and columns. Columns can be marked as primary and/or foreign keys. The transformation signature is completed by the inter-model mapping in theMT-part in Figure9. It specifies that classes shall be mapped to tables, attributes to columns, and associations to (junction) tables. The three rules that implement this transformation process are depicted in Figure10. The condition in Algorithm1(4) guarantees that the process stops if everything is mapped.
Figure 10: Transformation of Classes, Attributes, and Associations
The mapping of classes, attributes, and associations is one-to-one (up to some implementation details). It becomes more intricate, if inheritance comes into play. Figure11shows the extended object-oriented model and two variantsMTI1 andMTI2for the extension of the mapping.
OOI = OO + opns super: Class --> Class ( ) MTI1= MT + OOI + opns to: Class, Class --> Table ( )
MTI2= MT + OOI + opns to: Class, Class --> ForeignKey ( )
Figure 11: Object-Orientation with Inheritance
The first variant can be used to realise the pattern calledSingle Table Inheritancein [6], which puts a complete inheritance hierarchy into one table. The corresponding transformation rule
singleis depicted in Figure12(left part).26 The second variant is appropriate for the pattern calledClass Table Inheritancein [6], which implements inheritance by a foreign key constraint on the primary key of the table for the sub-class referencing the primary key of the table for the super-class. The transformation rulejoinfor this pattern can be found in Figure12(right part).
Figure 12: Handling Inheritance
All examples in this section demonstrate that the built-in application condition in Single-Pushout Rewriting for Partial Algebras is useful to control termination in transformations.
6
Related Work and Conclusions
We have introduced single-pushout rewriting of arbitrary partial algebras. As usual, transform-ations are defined by a single pushout of partial morphisms. Thus, general composition and de-composition properties of pushouts can be exploited for a rich theory. The new approach is built on a category of partial morphisms thatdoes not have allpushouts. We provided a good char-acterisation of the situations which admit pushouts by hereditariness of underlying pushouts of total morphisms, compare Theorems1,2, and3. Informally, pushouts can be built if the applied rule does not try to define operations where they are defined already. This application condition can easily be checked in every concrete situation. By some examples, we showed the practical relevance of the application condition for system design and the termination of derivation se-quences. Within our approach, we do not have to distinguish between graph structures (objects and links) and data structures (base-types and -operations). We can easily model associations and attributes with at-most-one-multiplicity.
There are only a few articles in the literature that address rewriting of partial algebras, for example [2] and [1] for the double- and single-pushout approach resp. But both papers stay in the framework of signatures withunaryoperation symbols only and aim at an underlying category of partial morphisms that is co-complete. Aspects of partial algebras occur in all papers that are concerned with relabelling of nodes and edges, for example [9], or that invent mechanisms for exchanging the attribute value without deleting and adding an object, for example [7]. Most of these approaches avoid “real” partial algebras by completing them to total ones by some undefined-values. Thus, our approach is new, seems promising wrt. theoretical results, and shows some application potentials.
References
[1] Peter Burmeister, Miquel Monserrat, Francesc Rosselló, and Gabriel Valiente. Algebraic transformation of unary partial algebras II: single-pushout approach. Theor. Comput. Sci., 216(1-2):311–362, 1999.
[2] Peter Burmeister, Francesc Rosselló, Joan Torrens, and Gabriel Valiente. Algebraic trans-formation of unary partial algebras I: double-pushout approach.Theor. Comput. Sci., 184(1-2):145–193, 1997.
[3] Andrea Corradini, Tobias Heindel, Frank Hermann, and Barbara König. Sesqui-pushout re-writing. In Andrea Corradini, Hartmut Ehrig, Ugo Montanari, Leila Ribeiro, and Grzegorz Rozenberg, editors,ICGT, volume 4178 ofLecture Notes in Computer Science, pages 30– 45. Springer, 2006.
[5] Hartmut Ehrig, Gregor Engels, Hans-Jörg Kreowski, and Grzegorz Rozenberg, editors. Graph Transformations - 6th International Conference, ICGT 2012, Bremen, Germany, September 24-29, 2012. Proceedings, volume 7562 ofLecture Notes in Computer Science. Springer, 2012.
[6] Martin Fowler. Patterns of Enterprise Application Architecture. Addison-Wesley, 2003.
[7] Ulrike Golas. A general attribution concept for models in M-adhesive transformation sys-tems. In Ehrig et al. [5], pages 187–202.
[8] Annegret Habel, Reiko Heckel, and Gabriele Taentzer. Graph grammars with negative application conditions. Fundam. Inform., 26(3/4):287–313, 1996.
[9] Annegret Habel and Detlef Plump. M,n-adhesive transformation systems. In Ehrig et al. [5], pages 218–233.
[10] Tobias Heindel. Hereditary pushouts reconsidered. In Hartmut Ehrig, Arend Rensink, Grzegorz Rozenberg, and Andy Schürr, editors, ICGT, volume 6372 ofLecture Notes in Computer Science, pages 250–265. Springer, 2010.
[11] Richard Kennaway. Graph rewriting in some categories of partial morphisms. In Hartmut Ehrig, Hans-Jörg Kreowski, and Grzegorz Rozenberg, editors,Graph-Grammars and Their Application to Computer Science, volume 532 ofLecture Notes in Computer Science, pages 490–504. Springer, 1990.
[12] Michael Löwe. Algebraic approach to single-pushout graph transformation. Theor. Com-put. Sci., 109(1&2):181–224, 1993.
[13] Michael Löwe. A unifying framework for algebraic graph transformation. Technical Report 2012/03, FHDW-Hannover, 2012.
[14] Michael Löwe, Martin Korff, and Annika Wagner. An algebraic framework for the trans-formation of attributed graphs. In M. R. Sleep et al, editor,Term Graph Rewriting: Theory and Practice, pages 185 – 199. Wiley, 1993.
[15] Michael Löwe and Marius Tempelmeier. Single-pushout rewriting of partial algebras. In Detlef Plump, editor,Proceedings of the 6th International Workshop on Graph Computa-tion Models, L’Aquila, Italy, July 20, 2015, volume 1403 ofCEUR Workshop Proceedings, pages 82–96. CEUR-WS.org, 2015.
[16] Miquel Monserrat, Francesc Rossello, Joan Torrens, and Gabriel Valiente. Single pushout rewriting in categories of spans I: The general setting. Technical Report LSI-97-23-R, De-partment de Llenguatges i Sistemes Informtics, Universitat Politcnica de Catalunya, 1997.