11institutetext: LIG - CNRS and Université de Grenoble Alpes, France
11email: [email protected]
22institutetext: LJK - Université de Grenoble Alpes and CNRS, France
22email: [email protected]
Parallel Graph Rewriting with Overlapping Rules
Rachid Echahed
11
Aude Maignan
22
Abstract
We tackle the problem of simultaneous transformations of networks
represented as graphs. Roughly speaking, one may distinguish two kinds
of simultaneous or parallel rewrite relations over complex structures
such as graphs: (i) those which transform disjoint subgraphs in
parallel and hence can be simulated by successive mere sequential and
local transformations and (ii) those which transform overlapping
subgraphs simultaneously. In the latter situations, parallel
transformations cannot be simulated in general by means of successive
local rewrite steps. We investigate this last problem in the
framework of overlapping graph transformation systems. As parallel
transformation of a graph does not produce a graph in general, we
propose first some sufficient conditions that ensure the closure of
graphs by parallel rewrite relations. Then we mainly introduce and
discuss two parallel rewrite relations over graphs. One relation is
functional and thus deterministic, the other one is not functional for
which we propose sufficient conditions which ensure its confluence.
0.1 Introduction
Graph structures are fundamental tools that help modeling complex
systems. In this paper, we are interested in the evolution of such structures
whenever the dynamics is described by means of systems of rewrite
rules.
Rewriting techniques are being investigated for different
structures such as strings [4], trees [1] or
graphs [20].
Roughly speaking, a rewrite rule can be
defined as a pair l→r where the left-hand and the right-hand
sides are of the same structure. A rewrite system, consisting of a set
of rewrite rules, induces a rewrite relation (→) over the
considered structures. The rewrite relation corresponds to a
sequential application of the rules, that is to say, a structure G
rewrites into a structure G′ if there exits a rule l→r such
that l occurs in G. Then G′ is obtained from G by replacing
l by r.
Besides this classical rewrite relation, one may think of a parallel
rewrite relation which rewrites a structure G into a structure G′
by firing, simultaneously, some rules whose left-hand sides
occur in G. Simultaneous or parallel rewriting of a structure G
into G′ can be used as a means to speed up the computations
performed by rewrite systems and, in such a case, parallel rewriting can
be simulated by successive sequential rewrite steps. However, there are situations where
parallel rewrite steps cannot be simulated by sequential steps as in
formal grammars [11], cellular automata (CA)
[23] or L-systems [19].
This latter problem is of
interest in this paper in the case where structures are graphs.
Graph rewriting is a very active area where one may distinguish
two main stream approaches, namely (i) the algorithmic approaches
where transformations are defined by means of the actual actions one
has to perform in order to transform a graph, and (ii) the algebraic
approaches where graph transformations are defined in an abstract
level using tools borrowed from category theory such as pushouts,
pullbacks etc. [20].
In this paper, we
introduce a new class of graph rewrite systems following an algorithmic
approach where rewrite rules may overlap. That is to say, in the
process of graph transformation, it may happen that some occurrences
of left-hand sides of different rules can share parts of the graph to
be rewritten. This overlapping of the left-hand sides, which can be
very appealing in some cases, turns out to
be a source of difficulty to define rigorously the notion of parallel
rewrite steps. In order to deal with such a difficulty we follow the
rewriting modulo approach (see, e.g. [16]) where a
rewrite step can be composed with an equivalence relation. Another
complication comes from the fact that a graph can be reduced in parallel in
a structure which is not always a graph but rather a structure we call
pregraph. Thus, we propose sufficient conditions
under which graphs are closed under parallel rewriting. The rewrite
systems we obtain generalize some known models of computation such as
CA, L-systems and more generally substitution systems
[23].
As a simple example illustrating this work, we may
refer to mesh refinement [5] and adaptative
mesh refinement (AMR) which constitute a very usefull technique in
physics [3, 17], astrophysics [12, 6] or in biology
[18].
The paper is organized as follows. The next section introduces the
notions of pregraphs and graphs in addition to some preliminary results
linking pregraphs to graphs. In Section 0.3, a class of rewrite
systems, called environment sensitive rewrite systems is
introduced together with a parallel rewrite
relation. We show that graphs are not closed under such
rewrite relation and propose sufficient conditions under which the
outcome of a rewrite step is always a graph. Then, in
Section 0.4, we define two particular parallel rewrite relations, one
performs full parallel rewrite steps whereas the second relation uses the
possible symmetries that may occur in the rules and considers only
matches up to automorphisms of the left-hand
sides.
Section 0.5 illustrates our framework through some
examples.
Concluding
remarks and related work are given in Section 0.6.
0.2 Pregraphs and Graphs
In this section we first fix some notations and give preliminary
definitions and properties.
2A denotes the power set of A. A⊎B stands for the
disjoint union of two sets A and B.
In the following, we introduce the notion of (attributed)
pregraphs, which denotes a class of structures we use to define
parallel graph transformations. Elements of a pregraph may be
attributed via a function λ which assigns, to elements of a
pregraph, attributes in some sets which underly a considered
attributes’ structure A. For instance A may be a
Σ-algebra [21] or merely a set.
Definition 1** (Pregraph).**
A pregraph H is a tuple H=(NH,PH,PNH,PPH,AH,λH)
such that :
NH* is a finite set of nodes and PH is a finite set of ports,*
PNH* is a relation PNH⊆PH×NH,*
PPH* is a symmetric binary relation on ports, PPH⊆PH×PH,*
AH* is a structure of attributes,*
λH* is a function λH:PH⊎NH→2AH such that ∀x∈NH⊎PH,card(λH(x)) is finite.*
An element (p,n) in PNH means that port p is associated
to node n.
An element (p1,p2) in PPH means that port p is
linked to port p2.
In a pregraph, a port can be associated (resp. linked) to several
nodes (resp. ports).
Example 1**.**
Figure 1 shows an example of a pregraph where
the node attributes are natural numbers and Figure 2 shows an example where attributes could be expressions such as 2x+y.
In Figure 3,
node attributes are variables ranging over N. The
introduction of variables as attributes allows one to model node neighborhood-sensitive dynamics at the rewriting rule
level as it will be illustrated in Section 5.
Below we introduce the definition of graphs used in this paper. In
order to encode classical graph edges between nodes, restrictions over
port associations are introduced.
Intuitively, an edge e between two nodes n1 and n2 will be
encoded as two semi-edges (n1,p1) and (n2,p2) with
p1 and p2 being ports which are linked via an association (p1,p2).
Definition 2** (Graph).**
A graph, G, is a pregraph G=(N,P,PN,PP,A,λ)
such that :
PN* is a relation ⊆P×N which associates
at most one node
to every port111The relation PN could be seen as a partial
function PN:P→N which
associates to a given port p, a node n, PN(p)=n ; thus building a semi-edge “port-node”.. That is to say, ∀p∈P,∀n1,n2∈N,((p,n1)∈PNand(p,n2)∈PN)⟹n1=n2.*
PP* is a symmetric binary relation222The relation
PP could also be seen as an injective (partial) function from ports to
ports such that ∀p∈P,PP(p)=p and
∀p1,p2∈P,PP(p1)=p2 iff PP(p2)=p1. on ports, PP⊆P×P, such that ∀p1,p2,p3∈P,((p1,p2)∈PP and
(p1,p3)∈PP)⟹p2=p3 and ∀p∈P,(p,p)∈PP.*
The main idea of our proposal is based on the use of equivalence
relations over nodes and ports (merging certain nodes and ports under
some conditions) in order to perform parallel graph rewriting in
presence of overlapping rules. Thus, to a given pregraph H, we
associate two equivalence relations on ports, ≡P, and on
nodes, ≡N, as defined below.
Definition 3** (≡P, ≡N).**
Let H=(NH,PH,PNH,PPH,AH,λH) be a
pregraph. We define two relations ≡P and
≡N respectively on ports (PH) and nodes (NH) of H as follows:
≡P* is defined as (PPH∙PPH)∗*
≡N* is defined as (PNH−∙≡P∙PN)∗*
where ∙ denotes relation composition, - the converse of a
relation and ∗ the reflexive-transitive closure of a relation.
We write [n] (respectively, [p]) the equivalence class of
node n (respectively, port p).
Roughly speaking, relation ≡P is the closure of the first part of condition (ii)
in Definition 2. The base case says that if two ports
p1 and p2 are linked to a same port p, then p1 and p2
are considered to be equivalent.
≡N is almost the closure of condition (i)
in Definition 2. That is, two nodes n1 and n2,
which are associated to a same port (or two equivalent ports),
are considered as equivalent nodes.
Proposition 1**.**
Let H=(NH,PH,PNH,PPH,AH,λH) be a
pregraph. The relations ≡P
and ≡N are equivalence relations.
Proof.
The reflexivity and transitivity of ≡P and ≡N follow
directly from their respective definitions.
The symmetry of PPH implies directly the symmetry of ≡P and ≡N.
∎
Remark 1**.**
The relations ≡P and
≡N
can be computed incrementally as follows:
Base cases:
≡0P={(x,x)∣x∈PH} and
≡0N={(x,x)∣x∈NH}
Inductive steps:
Rule I*: if q,q′∈PH such that, q≡iPq′, (q,p1)∈PPH and (q′,p2)∈PPH
then p1≡i+1Pp2.
*
Rule II*: if p1∈PH, p2∈PH,
(p1,n1)∈PNH, (p2,n2)∈PNH and p1≡iPp2
then n1≡i+1Nn2. *
Rule III*: If n1≡iNn′ and n′≡iNn2 then n1≡i+1Nn2.*
Proposition 2**.**
The limit of the series (≡iP)i≥0 is ≡P.
Proof.
Since the set of ports is finite then the limit of the series is reached within a finite number of steps.
⇒ : Let p1,p2∈PH, such that p1≡kPp2 for some k,
let us prove by induction on k, that (p1,p2)∈(PP∙PP)k.
case k=0 : p1≡0Pp2 thus p1=p2 and (p1,p2)∈(PP∙PP)0.
Induction step, case k=k′+1 : Let us assume p1≡k′+1Pp2. In this case, from rule I, there exist q,q′∈PH such that, q≡k′Pq′, (q,p1)∈PPH and (q′,p2)∈PPH. q≡k′Pq′ implies by induction hypothesis that (q,q′)∈(PP∙PP)k′.
Thus (p1,p2)∈(PP∙PP)k′+1.
Therefore for all k, p1≡kPp2 implies (p1,p2)∈(PP∙PP)k, and thus, p1≡Pp2.
⇐
Let p1≡Pp2. By definition of ≡P, there exists a
natural number k such that (p1,p2)∈(PP∙PP)k. It
is then straightforward that
p1≡kPp2.
∎
Likewise, we can easily show the following proposition regarding
relation ≡N.
Proposition 3**.**
The limit of the series (≡iN)i≥0 is ≡N.
Proof.
Since the sets of nodes and ports are finite then the limit of the
series is reached within a finite number of steps.
⇒ : Let n1,n2∈NH, such that n1≡kNn2 for some k ,
let us prove by induction on k, that (n1,n2)∈≡N.
case k=0 : obvious.
Induction step, case k=k′+1 : Let us assume n1≡k′+1Nn2. We distinguish two sub-cases according to the
used rules, i.e. Rule II or Rule III.
According to Rule III, there exists a node n′ such that n1≡k′Nn′ and n′≡k′Nn2. From the induction hypothesis, we have n1≡k′Nn′⟹n1≡Nn′ and n′≡k′Nn2⟹n′≡Nn2. Then by transitivity of ≡N we have
n1≡Nn2.
According to Rule II, there exist two ports p1 and p2 in
PH such that
(p1,n1)∈PNH, (p2,n2)∈PNH and p1≡k′Pp2.
From Proposition 2, p1≡k′Pp2⟹p1≡Pp2, and thus, there exists an index i
such that (p1,p2)∈(PPH∙PPH)i. Since (p1,n1)∈PNH and (p2,n2)∈PNH we conclude that (n1,n2)∈(PNH−∙≡P∙PNH)
⇐
Let n1≡Nn2. Then by definition of ≡N there exists
a natural number k such that (n1,n2)∈(PNH−∙≡P∙PNH)k.
This means that there is a chain of connections consisting of tuples of
the form (mi,pi).pi≡Ppi′.(pi′,mi+1) for i∈{0,...,k}
such that m0=n1 and mk=n2.
From rule III, it is easy to deduce the existence of k′, such that n1≡k′Nn2.
∎
The equivalence relations ≡P
and ≡N are used to introduce the notion of quotient pregraph as defined below.
Definition 4** (Quotient Pregraph).**
Let H=(NH,PH,PNH,PPH,AH,λH) be a pregraph and
≡P and ≡N two equivalence relations over ports and
nodes respectively.
We write H the pregraph H=(NH,PH,PNH,PPH,AH,λH)
where
NH={[n]∣n∈NH},
PH={[p]∣p∈PH},
PNH={([p],[n])∣(p,n)∈PNH},
PPH={([p],[q])∣(p,q)∈PPH},
AH=AH
and
λH([x])=∪x′∈[x]λH(x′) where [x]∈NH⊎PH
Example 2**.**
*Let H=(NH,PH,PNH,PPH,AH,λH) be a pregraph as
depicted on the left of Figure 4, with
NH={n1,n2,n3,n4}, PH={p1,p2,p3,p4,p5,p6},
PNH={(p1,n1),(p5,n1),
(p2,n2),(p6,n2),(p4,n3),(p3,n4)},
PPH={(p1,p2),(p1,p4),(p2,p3),(p3,p4),(p5,p6)},
AH=N, λNH(n1)=λNH(n4)={1}, λNH(n2)=λNH(n3)={2}, ∀i∈{1,...,6},λPH(pi)=∅,*
We obtain H=(NH,PH,PNH,PPH,AH,λH), as
depicted on the right of Figure 4, with
NH={[n1],[n2]}* with [n1]={n1,n4}, [n2]={n2,n3},*
PH={[p1],[p2],[p5],[p6]}* with [p1]={p1,p3}, [p2]={p2,p4}, [p5]={p5}, [p6]={p6},*
PNH={([p1],[n1]),([p5],[n1]),([p2],[n2]),([p6],[n2])},
PPH={([p1],[p2]),([p5],[p6])},
AH=AH**
λNH([n1])={1}, λNH([n2])={2}, λPH([p1])=λPH([p2])=λPH([p5])=λPH([p6])=∅.
Example 3**.**
Figure 5 illustrates two computations of quotient pregraphs.
Remark 2**.**
If H is a graph, H and H are isomorphic. Indeed,
in a graph, a port can be associated (resp. linked) to at most one
node (resp. one port).
The following definition introduces some vocabulary and notations.
Definition 5** (Path, Loop).**
A path πH(p1,pk) between two (possibly the same) nodes
p1 and pk in a pregraph H is a sequence of ports of H
written πH(p1,pk)=(p1,p2,…,pk) such that
{(pi,pi+1)∣i=1,2,…,k−1}⊆PPH and k∈N with k>0.
The length of a path πH(p1,pk)=(p1,p2,…,pk)
is ♯(πH(p1,pk))=k−1.
An even path (resp. odd path) is a path such that its length is even (resp. odd).
A loop is a closed path, i.e., a path πH=(p1,p2,…,pk)
such that p1=pk. An even loop (resp. odd loop) is an even closed
path (resp. odd closed path).
From the definitions above, one can show the following statements.
Proposition 4**.**
Let H=(NH,PH,PNH,PPH,AH,λH) be a pregraph.
Let q,q′ be two ports in PH. q≡Pq′ iff there
exists an even path between q and q′ in H.
Proof.
If q≡Pq′ then, by definition,
(q,q′)∈(PPH∙PPH)∗ hence there exists an even path
between q and q′.
Conversely, if there exists an even path between q and q′ in H
then (q,q′)∈(PPH∙PPH)∗ and thus q≡Pq′.
∎
Proposition 5**.**
Let H=(NH,PH,PNH,PPH,AH,λH) be a
pregraph. H is a graph iff
H has no odd loop.
Proof.
Let H=(NH,PH,PNH,PPH,AH,,λH).
The relations PNH and PPH are functional by construction.
In order to show that H is indeed a graph,
It remains to prove that PPH is not anti-reflexive iff
there is an odd loop in H.
Assume that PPH is not anti-reflexive. Then, there exists
q∈PH such that ([q],[q])∈PPH.
Thus, either (q,q)∈PPH which constitute an odd loop of
length one or there exists a port q′, different from q, such
that (q,q′)∈PPH and q′≡Pq. In this last case, from
Proposition4, q′≡Pq implies the existence of
an even path from q′ to q. Then adding the link (q,q′) to this
path builds a loop from q to q in H of odd length.
Assume there is an odd loop containing a port q
in H. Then either the loop is of the form (q,q) and thus
(q,q)∈PPH and in this case
([q],[q])∈PPH, or there exists a port q′
different from q such that the loop is of the form
(q,q′,…,q). In this last case, (q,q′)∈PPH and the
path πH(q′,q) is even. Thus, [q]=[q′] which
implies that ([q],[q])∈PPH.
∎
Below, we define the notion of homomorphisms of
pregraphs and graphs. This notion assumes the existence of
homomorphisms over attributes [7].
Definition 6** (Pregraph and Graph Homomorphism).**
Let l=(Nl,Pl,PNl,PPl,Al,λl) and
g=(Ng,Pg,PNg,PPg,Ag,λg) be two pregraphs.
Let a:Al→Ag be a homomorphism
over attributes.
A
pregraph homomorphism, ha:l→g, between l and g,
built over attribute homomorphism a,
is defined by two functions hNa:Nl→Ng and
hPa:Pl→Pg such that
(i) ∀(p1,n1)∈PNl, (hPa(p1),hNa(n1))∈PNg,
(ii) ∀(p1,p2)∈PPl, (hPa(p1),hPa(p2))∈PPg,
(iii)
∀n1∈Nl,a(λl(n1))⊆λg(hNa(n1))
and (iv)
∀p1∈Pl,a(λl(p1))⊆λg(hPa(p1)).
*A graph homomorphism is a pregraph homomorphism between two graphs.
*
Notation: Let E be a set of attributes, we
denote by a(E) the set a(E)={a(e)∣e∈E}.
Proposition 6**.**
Let H and H′ be two
isomorphic pregraphs. Then H and H′ are isomorphic.
Proof.
Let ha:H→H′ be a pregraph isomorphism.
We define ha:H→H′ as follows: for all ports
p,p′ in H, nodes n in H, hNa([n])=[hNa(n)], hPa([p])=[hPa(p)], ha([p],[n])=([hPa(p)],[hNa(n)]), ha([p],[p′])=([hPa(p)],[hPa(p′)]).
ha is clearly a pregraph
isomorphism between H and H′.
h is well defined as illustrated
in the following three items.
We show that for all
ports p1,p2 in H,
p1≡HPp2 iff hPa(p1)≡H′PhPa(p2) :
hPa(p1)≡H′phPa(p2) iff there exists a path πH′(hPa(p1),hPa(p2))=(q1,q2,…qk−1,qk) such that q1=hPa(p1), qk=hPa(p2) and
♯πH′(hPa(p1),hPa(p2)) is even (see, Proposition 4).
It is equivalent to say that (p1,(hPa)−1(q2),…,(hPa)−1(qk−1),p2) is an even path of H because h is an isomorphism.
We conclude that p1≡Hpp2.
For all nodes n1,n2 in H, we show that n1≡Hnn2 iff
hNa(n1)≡H′nhNa(n2).
By definition, hNa(n1)≡H′nhNa(n2) iff (a) hNa(n1)=hNa(n2) or (b) there exists q,q′∈PH′, q≡H′pq′, (q,hNa(n1))∈PNH′ and (q′,hNa(n2))∈PNH′
or (c) there exists n′′∈NH′, hNa(n1)≡H′nn′′ and hNa(n2)≡H′nn′′.
ha is an isomorphism thus (a) is equivalent to n1=n2 and (b) is equivalent to there exists (hPa)−1(q),(hPa)−1(q′)∈PH, (hPa)−1(q)≡H′p(hPa)−1(q′), ((hPa)−1(q),n1)∈PNH and ((hPa)−1(q′),n2)∈PNH.
The cases (a) and (b) are straight foward.
Let us focus our attention on the case (c) :
hNa(n1)≡H′nhNa(n2) such that it exists n′′∈NH′ and q,q′∈PH′ which verify the condition {(q,n′′),(q,h(n1)),(q′,n′′),(q′,hNa(n2))}⊂PNH′. This is
equivalent to : (hNa)−1(n′′)∈NH and (hPa)−1(q),(hPa)−1(q′)∈PH which verify the condition
[TABLE]
and in that case
n1≡HNn2. Moreover because ≡N is transitive we obtain that (c)
is equivalent to : there exists (hNa)−1(n′′)∈NH, n1≡Hn(hNa)−1(n′′) and n2≡Hn(hNa)−1(n′′).
Thus, n1≡Hnn2.
The pregraph homorphism of H→H′ and H→H′ are
built over the same attribute homomorphism a, thus by construction
the points (iii) and (iv) of the previous definition
imply
∪ni∈[n]a(λH(ni))⊂∪ni∈[n]λH′(hNa(ni)) and
∪pi∈[p]a(λH(pi))⊂∪pi∈[p]λH′(hPa(pi))
thus
a(λH([n]))⊂λH′(hNa([n])) and
a(λH([p]))⊂λH′(hPa([p]))
and ha is a pregraph homomorphism from H to H′.
∎
We end this section by defining an equivalence relation over
pregraphs.
Definition 7** (Pregraph equivalence).**
Let G1 and G2 be two pregraphs. We say that G1 and G2 are
equivalent and write G1≡G2 iff the quotient pregraphs
G1 and G2 are isomorphic.
The relation ≡ over pregraphs is obviously an equivalence relation.
0.3 Graph Rewrite Systems
In this section, we define the considered rewrite systems and provide
sufficient conditions ensuring the closure of graph structures under
the defined rewriting process.
Definition 8** (Rewrite Rule, Rewrite System, Variant).**
A rewrite rule is a pair l→r where l and r are
graphs over the same sets of attributes. A rewrite system R is a set
of rules. A variant of a rule l→r is a rule l′→r′ where nodes, ports as well as the variables of the
attributes are renamed with fresh names.
Let l′→r′ be a variant of a rule l→r. Then
there is a renaming mapping ha, built over an attribute renaming
a:Al→Al′, and consisting of two maps
hNa and hPa over nodes and ports respectively :
hNa:Nl∪Nr→Nl′∪Nr′
and
hPa:Pl∪Pr→Pl′∪Pr′
such that, the elements in Nl′ and Pr′ are
new and the restrictions of ha to l→l′ (respectively
r→r′) are graph isomorphisms.
In general, parts of a left-hand side of a rule remain unchanged in
the rewriting process. This feature is taken into account in the
definition below which refines the above notion of rules by
decomposing the left-hand sides into an environmental part,
intended to stay unchanged, and a cut part which is
intended to be removed. As for the right-hand sides, they are
partitioned into a new part consisting of added items and an
environmental part (a subpart of the left-hand side)
which is used to
specify how the new part is connected to the environment.
Definition 9** (Environment Sensitive Rewrite Rule, Environment Sensitive Rewrite System).**
An environment sensitive rewrite rule is a rewrite rule (ESRR for short) l→r
where l and r are
graphs over the same attributes A
such that:
-
l=(Nl,Pl,PNl,PPl,A,λl)*
where*
Nl=Nlcut⊎* Nlenv,Pl=Plcut⊎Plenv,PNl=PNlcut⊎PNlenv,PPl=PPlcut⊎PPlenvand λl=λlcut⊎333Here, the function
λl is considered as a set of pairs (x,λl(x)), i.e. the graph of λl. λlenv
with some additional constraints :*
on PNl :*
∀(p,n)∈PNl,(n∈Nlcut or p∈Plcut)⇒(p,n)∈PNlcut.*
on PPl :*
∀(p,p′)∈PPl,p∈Plcut⇒(p,p′)∈PPlcut.*
on λl :*
∀n∈Nlcut,(n,λl(n))∈λlcut and
∀p∈Plcut,(p,λl(p))∈λlcut.*
-
r=(Nr,Pr,PNr,PPr,A,λr)* where*
Nr=Nrnew⊎Nrenv,Pr=Prnew⊎Prenv,PNr=PNrnew⊎PNrenv,PPr=PPrnew⊎PPrenv,λr=λrnew⊎λrenv*
such that Nrenv⊆Nlenv,
Prenv⊆Plenv, Nrnew∩Nlenv=∅ and
Prnew∩Plenv=∅
with some additional constraints :*
on PNr :*
∀(p,n)∈PNr,(p,n)∈PNrenv iff (p∈Prenv and n∈Nrenv and (p,n)∈PNlenv).*
on PPr :*
∀(p,p′)∈PPr,(p,p′)∈PPrenv iff (p∈Prenv and p′∈Prenv and (p,p′)∈PPlenv).*
on λr :*
∀n∈Nrenv,(∃y,(n,y)∈λrenv) iff (λrenv(n)=λlenv(n)) ; *
∀y∈Prenv,(∃y,(p,y)∈λrenv)* iff (λrenv(p)=λlenv(p)).*
An environment sensitive rewrite system (ESRS for short) is a set of environment sensitive
rewrite rules.
Roughly speaking,
constraints (1),
(2) and (3) ensure that if an item (node or port) is to be removed
(belonging to a “cut” component) then links involving that item
should be removed too as well as its attributes (constraint
(3)). Constraints (4) and (5) ensure that links, considered as new
(belonging to “new” components), of a given right-hand side of a
rule, should not appear in the left-hand side. Constraint (6) ensures
that an item (node or port) is newly attributed in the right-hand side
iff it is a new item or it was assigned by λlcut in the
left-hand side.
Proposition 7**.**
Let l→r be a an ESRR such that
l=(Nl=Nlcut⊎Nlenv,Pl=Plcut⊎Plenv,PNl=PNlcut⊎PNlenv,PPl=PPlcut⊎PPlenv,A,λl=λlcut⊎λlenv)
and
r=(Nr=Nrnew⊎Nrenv,Pr=Prnew⊎Prenv,PNr=PNrnew⊎PNrenv,PPr=PPrnew⊎PPrenv,A,λr=λrnew⊎λrenv).
Then the following properties hold:
For all (p,n)∈PNr, (p,n)∈PNrnew iff
p∈Prnew or n∈Nrnew or (p∈Prenv and n∈Nrenv and (p,n)∈PNlenv)
For all (p,p′)∈PPr, (p,p′)∈PPrnew iff p∈Prnew or p′∈Prnew or
(p∈Prenv and p′∈Prenv
and (p,p′)∈PPlenv(p))
For all x∈Nr∪Pr, (x,λr(x))∈λrnew iff x∈Nrnew∪Prnew or (x,λl(x))∈λlcut
Example 4**.**
*Let us consider a rule RT:l→r which specifies a way to
transform a triangle into four triangle graphs.
Figure 6 depicts the rule. Black parts should be understood
as members of the cut component of the left-hand side, yellow
items are in the environment parts. The red items are new in the
right-hand side. More precisely, lenv consists of
Nlenv={α,β,γ},
Plenv={α1,α2,β1,β2,γ1,γ2},
PNlenv={(α1,α),(α2,α),(β1,β),(β2,β), (γ1,γ),(γ2,γ)}, and
PPlenv=∅. The cut component of the left-hand side
consists of three port-port connections and their corresponding
symmetric connections which will not be written
: PPlcut={(α2,β1),(β2,γ1),(γ2,α1)}.
The environment component in the right-hand side allows to reconnect
the newly introduced items.
renv consists of the ports
Prenv={α1,α2,β1,β2,γ1,γ2}.
rnew consists of Nrnew={U,V,W}, Prnew={u1,u2,u3,u4,v1,v2,v3,v4,w1,w2,w3,w4},
PNrnew={(u1,U),(u2,U),(u3,U),(u4,U),(v1,V),(v2,V),(v3,V),(v4,V),(w1,W),(w2,W),(w3,W),(w4,W)} and PPrnew={(α1,w2),(α2,u1),(β1,u2),(β2,v1),(γ1,v2),(γ2,w1),(u3,w3),(u4,v4),(w4,v3)}. The sets of attributes are empty in this example.*
Remark 3**.**
From the definition of an environment sensitive rule, the environment
components renv=(Nrenv,Prenv,PNrenv,PPrenv,A,λrenv) and
lenv=(Nlenv,Plenv,PNlenv,PPlenv,A,λlenv) are graphs.
However, since PPlcut may include ports in
Plenv and PNlcut may include nodes in
Nlenv or ports in Plenv,
the cut component lcut=(Nlcut,Plcut,PNlcut,PPlcut,A,λlcut) is in
general neither a graph nor a pregraph.
For the same reasons rnew=(Nrnew,Prnew,PNrnew,PPrnew,A,λrnew) is in
general neither a graph nor a pregraph.
Finding an occurrence of a left-hand side of a rule within a graph to be
transformed consists in finding a match. This notion is
defined below.
Definition 10** (Match).**
Let l and g be two graphs. A match ma:l→g is defined
as an injective graph homomorphism. a:Al→Ag being an injective homomorphism over attributes.
Example 5**.**
Figure 7 gives a graph l and a graph g.
Because of ports attributes, only two matches, m1id and
m2id can be defined from l to g:
m1id* : m1id(α)=E;m1id(β)=B; m1id(γ)=C; m1id(α1)=e1;m1id(α2)=e2;m1id(β1)=b1;m1id(β2)=b2; m1id(γ1)=c1; m1id(γ2)=c2.*
m2id* : m2id(α)=C;m2id(β)=D; m2id(γ)=F; m2id(α1)=c3;m2id(α2)=c4;m2id(β1)=d1;m2id(β2)=d2; m2id(γ1)=f1; m2id(γ2)=f2.*
Notice that the occurrences in g of m1id(l) and m2id(l) overlap on node C.
Definition 11** (Rewrite Step).**
Let l→r be a rule, g a graph and
ma:l→g a match.
Let l=(Nl=Nlcut⊎Nlenv,Pl=Plcut⊎Plenv,PNl=PNlcut⊎PNlenv,PPl=PPlcut⊎PPlenv,A,λl=λlcut⊎λlenv)
and
r=(Nr=Nrnew⊎Nrenv,Pr=Prnew⊎Prenv,PNr=PNrnew⊎PNrenv,PPr=PPrnew⊎PPrenv,A,λr=λrnew⊎λrenv).
A graph g rewrites to g′ using a match ma, written g→g′ or
g→l→r,mag′ with g′ being a pregraph defined as follows:
g′=(Ng′,Pg′,PNg′,PPg′,Ag′,λg′) such
that
Ng′=(Ng−Nma(l)cut)⊎Nrnew**
Pg′=(Pg−Pma(l)cut)⊎Prnew**
PNg′=(PNg−PNma(l)cut)⊎PNma(r)new**
PPg′=(PPg−PPma(l)cut)⊎PPma(r)new**
Ag′=Ag* and λg′=(λg−λma(l)cut)⊎λma(r)new*
Notation: Let p,p′ be ports and n be a node, in notation ma(r)
above, ma(p,p′)=(ma(p),ma(p′)), ma(p,n)=(ma(p),ma(n)), ma(p)=p if p∈Prnew and ma(n)=n if n∈Nrnew.
It is easy to see that graphs are not closed under the rewrite
relation defined above. That is to say, when a graph g rewrites
into g′, g′ is a pregraph. To ensure that g′ is a graph we
provide the following conditions.
Theorem 1**.**
Let l→r be an environment sensitive rewrite rule, g a graph and
ma:l→g a match.
Let g→l→r,mag′.
g′ is a graph iff the two following constraints are verified :
-
If p∈Plenv, (p,q)∈PPrnew for some
port q and there is no q′ such that (p,q′)∈PPlcut,
then
there is no q′′∈Pg such that (ma(p),q′′)∈PPg.
2. 2.
If p∈Plenv , (p,n)∈PNrnew and there is no n′ such that (p,n′)∈PNlcut, then
there is no n′′∈Ng such that (ma(p),n′′)∈PNg.
Proof.
(⇐) Let p be a port of g′.
If the constraints 1. and 2. are verified then
If p∈g′−ma(r), p has the same connections as in g. Since g is a graph, p is connected to at most one port and one node.
If p∈ma(renv), thanks to constraints 1. and 2. p has
at most one connection to a node and one connection to a port in g′.
If p∈Prnew. Since r is a graph, p has
at most one connection to a node and one connection to a port in g′.
Thus, g′ is a graph.
(⇒)
It is easy to show, by contrapositive, that in case one of the constraints (1 and 2) is not verified, a
counter example can be exhibited.
∎
Matches which fulfill the above two conditions are called well behaved matches.
Example 6**.**
Figure 8 (a) gives an example of toy rule.
Figure 8 (b) is a graph H such that
the match m1id as defined below is a well behaved match, whereas the match
m2id is not a well behaved match.
m1id:m1id(α)=A,m1id(β)=B,m1id(α1)=a1,m1id(β1)=b1
and
m2id:m2id(α)=C,m2id(β)=B,m2id(α1)=c1,m2id(β1)=b1.
The application of the toy rule on nodes B and C and the ports
b1 and c1 (according to match m2id) leads to a pregraph which is not a graph.
In order to define the notion of parallel rewrite step, we have to
restrict a bit the class of the considered rewrite systems. Indeed,
let l1→r1 and l2→r2 be two ESRR.
Applying these two rules in parallel on a graph g is possible
only if there is “no conflict” while firing the two rules
simultaneously. A conflict may occur if some element of the
environment of r1env is part of l2cut and vice versa.
To ensure conflict free rewriting, we introduce the notion of
conflict free ESRS.
Let us first define the notion of compatible rules.
Definition 12** (compatible rules).**
Two ESRR’s
l1→r1 and l2→r2 are said to be compatible
iff for all graphs g and matches m1a1:l1→g and m2a2:l2→g, (i) no element of m1a1(r1env) is in m2a2(l2cut) and
(ii) no element of m2a2(r2env) is in m1a1(l1cut).
Conditions (i) and (ii) ensure that the constructions defined by
m1a1(r1) (respectively by m2a2(r2)) can actually be performed ;
i.e, no element used in m1a1(r1) (respectively by m2a2(r2)) is
missing because of its inclusion in m2a2(l2cut) (respectively in
m1a1(l1cut)).
For instance, the reader can easily verify that two variants of the rule
are not compatible.
Verifying that two given rules are compatible is decidable and can be
checked on a finite number, less than max(size(l1),size(l2)), of graphs where the size of a graph stands for its number of
nodes and ports.
Proposition 8**.**
The problem of the verification
of compatibility of two rules is decidable.
Proof.
Let ρ1=l1→r1 and ρ2=l2→r2 be two rules.
Assume that ρ1 and ρ2 are not compatible. Then there
exists a graph G such that:
there exists a match m1a1:l1→G
there exists a match m2a2:l2→G
w.l.o.g, we assume that there exists an element, say e, in
m1a1(r1env) which belongs also to m2a2(l2cut).
Graph G can be built as follows:
Let d be a graph such that there
exist two injective homomorphisms h1:d→m1a1(l1) and
h2:d→m2a2(l2) such that G is obtained as a pushout of h1
and h2. That is to say, there exist two injective homomorphisms h1′:m1a1(l1)→G and h2′:m2a2(l2)→G such that
h1′(h1(d))=h2′(h2(d)). We consider subgraphs d which
contain at least h1−1((m1a1)−1(e)) which is equal to
h2−1((m2a2)−1(e)). Notice that elements of graph d
could be attributed by empty sets.
Therefore, to check whether two rules ρ1=l1→r1 and
ρ2=l2→r2 are compatible, one has to check whether there
exist a subgraph d and two injective homomorphisms
h:d→l1 and h′:d→l2 such that d contains an item, e,
such that h(e)∈l1cut and h′(e)∈r2env (h(e)∈rlenv and h′(e)∈l2cut) . Since homomorphisms h and
h′ are injective, the size (number of
nodes and ports) of d is less than max(size(l1),size(l2)).
Obviously, d, h and h′ exist iff the two rules are not
compatible.
Indeed the graph G′ obtained as a pushout of homomorphisms h and
h′ contains at least one item which can be matched either by
lienv (and remains in rienv) and ljcut with (i,j)∈{(1,2),(2,1)}.
Since the set of possible d’s is finite (up to isomorphism),
verifying whether two rules are compatible is decidable.
∎
Definition 13**.**
A conflict free environment sensitive graph
rewrite system is an ESRS consisting of pairwise compatible rules.
Definition 14** (parallel rewrite step).**
Let R be a conflict free environment sensitive graph
rewrite system R={Li→Ri∣i=1…n}. Let G be a graph. Let I be a set of
variants of rules in R, I={li→ri∣i=1…k} and M a set of matches M={miai:li→G∣i=1…k}. We say that
graph G rewrites into a pregraph G′ using the rules in I and matches in
M, written G⇒I,MG′, G⇒MG′ or simply G⇒G′ if G′ is obtained following the two steps below:
First step:* A pregraph H=(NH,PH,PNH,PPH,AH,λH) is computed using the different matches and rules as follows:*
NH=(NG−∪i=1kNmiai(li)cut)⊎∪i=1kNrinew**
PH=(PG−∪i=1kPmiai(li)cut)⊎∪i=1kPrinew**
PNH=(PNG−∪i=1kPNmiai(li)cut)⊎∪i=1kPNmiai(ri)new**
PPH=(PPG−∪i=1kPPmiai(li)cut)⊎∪i=1kPPmiai(ri)new**
AH=AG* and λH=(λG−∪i=1kλmiai(li)cut)∪∪i=1nλmiai(ri)new*
second step*: G′=H*
Notice that the rewrite step G⇒G′ is a rewrite
modulo step [16] of the form G→H≡H.
Example 7**.**
Let us consider the graph g depicted below and the following two
matches, m1 and m2,
of the rule RT depicted in Figure 6.
m1* : m1(α)=E;m1(β)=B; m1(γ)=C; m1(α1)=e1;m1(α2)=e2;m1(β1)=b1;m1(β2)=b2; m1(γ1)=c1; m1(γ2)=c2.
The isomorphism of the port-node and port-port connections are easily deduced.*
m2* : m2(α)=B;m2(β)=D; m2(γ)=C; m2(α1)=b2;m2(α2)=b3;m2(β1)=d2;m2(β2)=d1; m2(γ1)=c3; m2(γ2)=c1.*
The two matches overlap.
Figure 9 shows the different steps of the application of two
matches of the rule defined in Figure 6. The pregraph, H, in the
middle is obtained after the first step of Definition 14.
Its quotient pregraph, G′, is the graph on the right. G′ has been
obtained by merging the nodes S and Y and the ports s1 and
y1 as well as ports s2 and y2. These mergings are depicted by
the quotient sets [S],[s1] and [s2]. For sake of readability,
the brackets have been omitted for quotient sets reduced to one
element.
As a quotient pregraph is not necessarily a
graph (see Figure 5), the above definition of parallel rewrite
step does not warranty, in general, the production of graphs only.
Hence, we propose hereafter a sufficient condition, which could be
verified syntactically, that ensures that the outcome of a parallel
rewrite step is still a graph.
Theorem 2**.**
Let R be a conflict free environment sensitive graph
rewrite system R={Li→Ri∣i=1…n}. Let G be a graph. Let I be a set of
variants of rules in R, I={li→ri∣i=1…k} and M a set of matches M={miai:li→G∣i=1…k}. Let G′ be the pregraph such that G⇒I,MG′.
If ∀p,p′∈PLienv, (p,p′)∈/PPRinew,
then G′ is a graph.
Proof.
We have to prove that H does not contain odd loops. Because of the previous constraint, it is enough to prove that
all ports of H are not parts of a loop.
If p∈∪i=1nPRinew, it is a new port contained in the graph Ri thus p has at most one connection port-port.
If p∈∪i=1nPmiai(Ri)env, p
belongs to the graph G and the only new port-port connections
where p is involved are those of ∪i=1nPRinew.
Else, if p∈G/∪i=1nPRinew⊎∪i=1nPmiai(Ri)env,
p belongs to the non modified part of the graph. Its connections
are unchanged and thus p has at most one port-port connection.
Finally, p belongs to a path which is not a loop and H=G′ is a graph.
∎
0.4 Two Parallel Rewrite Relations
The set of matches, M, in Definition 14 is not
constrained and thus the induced parallel rewrite relation is too
nondeterministic since at each step one may choose several
sets of matches leading to different rewrite outcomes. In this
section, we are rather interested in two confluent parallel rewrite
relations which are realistic and can be good candidates for
implementations.
The first one performs all possible reductions (up to node and port
renaming) whereas the second relation is more involved
and performs reductions up to left-hand sides’
automorphisms.
0.4.1 Full Parallel Rewrite Relation
We start by a technical definition of an equivalence relation, ≈, over matches.
Definition 15** (≈).**
Let L→R be a rule and G a graph. Let l1→r1 and
l2→r2 be two variants of the rule L→R. We denote by
h1a1 (respect. h2a2) the (node, port and attribute) renaming mapping such
that the restriction of h1a1 (respectively, h2a2) to
L→l1 (respectively L→l2) is a graph
isomorphism.
Let m1b1:l1→G and m2b2:l2→G be two matches. We say that
m1b1 and m2b2 are equivalent and write m1b1≈m2b2 iff for all elements x (in PL, NL,
PPL or PNL) of L,
m1b1(h1a1(x))=m2b2(h2a2(x)) and for all x in
AL, b1(a1(x))=b2(a2(x)) .
The relation ≈ is clearly an equivalence
relation. Intuitively, two matches m1b1:l1→G and
m2b2:l2→G are equivalent, m1b1≈m2b2, whenever (i) l1
and l2 are left-hand sides of two variants of a same rule, say
L→R, and (ii) m1b1 and m2b2 coincide on each element x of
L.
Definition 16** (full parallel matches).**
*Let R be a graph rewrite system and G a graph.
Let MR(G)={miai:li→G∣miai\mboxisamatchandli→ri\mboxisavariantofaruleinR}. A set, M, of full parallel matches, with
respect to a graph rewrite system R and a graph G, is a
maximal set such that
(i) M⊂MR(G) and
(ii) ∀m1a1,m2a2∈M,m1a1≈m2a2.
*
A set of full parallel matches M is not unique because any rule in R may have infinitely many
variants. However the number of non equivalent matches could be easily proven to be finite.
Proposition 9**.**
Let M be a set of full parallel matches with
respect to a graph rewrite system R and a graph G. Then M is finite.
Proof.
We assume that G has a finite number of nodes, ports and attributes and R
has a finite number of rules.
Let li→ri be a rule in
R. Let us assume now that nodes and ports of the left-hand side
li are attributed with the empty set. In this case, matching li
with subgraphs in G remains to find a (non attributed) graph
homomorphism between li and G. Therefore, in this case,
the number of possible matches of the
left-hand side li in graph G is at most
(nki)×ki! where n=card(NG)+card(PG) and ki=card(Nli)+card(Pli).
Thus card(M) is bounded by Π1≤i≤card(R)(nki)×ki! which is finite since n and the
ki’s are finite.
Let us consider now the case where li is attributed (that is to
say, there exists at leat a node or port, say x, such that λli(x)=∅). Let ma:li→G be a match. m is a
non-attributed graph homomorphism and a:Ali→AG is
an attribute homomorphism which corresponds to a match over attributes in
the case where attributes in li contain variables. We assume that
the matching problem over attributes is finitary. Thus for every m
there is a finite number, say Cm, of possible matchings over
attributes a. Let li′ be the graph obtained from li by
removing all attributes (or equivalently said, by setting the
attribute function λli′ to the empty set.
Let Ci=max(Cm∣m\mboxisanon−attributedgraphhomomorphismm:li′→G). Ci exists
since we assume that the matching problem is finitary.
Then
card(M) is bounded by Π1≤i≤card(R)(nki)×ki!×Ci which is finite since n, the
ki’s and the Ci’s are finite.
∎
Definition 17** (full parallel rewriting).**
Let R be an ESRS and G a graph. Let M be a set of
full parallel matches with respect to R and G. We define the
full parallel rewrite relation and write
G⇉MG′ or simply G⇉G′, as the parallel rewrite step G⇒MG′.
Proposition 10**.**
Let R be an ESRS. The rewrite relation ⇉ is
deterministic. That is to say, for all graphs g,
(g⇉g1andg⇉g2) implies that g1 and g2 are
isomorphic.
Proof.
The proof is quite direct. Let M1 and
M2 be two different sets of full parallel matches such that
g⇉M1g1 and g⇉M2g2. By definition of sets
of full parallel matches, for all matches mb∈M1 there exists a match m′b′∈M2 such
that mb≈m′b′. Since M1 and M2 are finite (see
Proposition 9), there exists a natural number k such
that M1={m1b1,m2b2,…,mkbk} and
M2={m1′b1′,m2′b2′,…,mk′bk′} such that for all
i∈{1,…,k}, mibi≈mi′bi′. Therefore, for every i
such that 1≤i≤k, there exist a rule Li→Ri in
R and two variants of it li→ri and li′→ri′
together with two renaming mappings hiai:Li→li and
hi′ai′:Li→li′ such that for all elements x∈Li,
mibi(hiai(x))=mi′bi′(hi′ai′(x)).
By Definitions 14 and 17, graphs g1
and g2 are quotient pregraphs of two pregraphs, respectively
H1 and H2, obtained after the
first step of parallel rewrite steps. The sets of nodes
and ports of pregraphs H1 and H2 are defined as follows
NH1=(Ng−∪i=1kNmibi(li)cut)⊎∪i=1kNrinew
NH2=(Ng−∪i=1kNm′ibi′(l′i)cut)⊎∪i=1kNr′inew
PH1=(Pg−∪i=1kPmibi(li)cut)⊎∪i=1kPrinew
PH2=(Pg∪i=1kPm′ibi′(l′i)cut)⊎∪i=1kPr′inew
λH1=(λg−∪i=1kλmibi(li)cut)⊎∪i=1kλrinew
λH2=(λg−∪i=1kλm′ib′i(li)cut)⊎∪i=1kλrinew
Now, We define a map fc:H1→H2 by means of three maps on nodes, ports and attributes
fNc:NH1→NH2,
fPc:PH1→PH2 and
c:AH1→AH2 as follows
[TABLE]
[TABLE]
and c(x)={bi′∘ai′∘ai−1∘bi−1(x)xif ∃i∈{1,…,k},∃e∈(NH1∪PH1),(e,x)∈λrinewotherwise
fc is clearly a pregraph isomorphism between H1 and H2. As
g1 and g2 are obtained as quotient pregraphs of H1 and H2
respectively, we conclude by using
Proposition 6, that g1 and g2 are isomorphic.
∎
Example 8**.**
**
Let us consider the rule RT defined in Figure 6 and the
subgraph s depicted on the side. The reader can verify
that there are six different matches, m1…m6, between the
left-hand side of RT and graph s.
These matches are sketched below. Variants of
RT have been omitted for sake of readability.
m1* : m1(α)=E;m1(β)=B; m1(γ)=C; m1(α1)=e1;m1(α2)=e2;m1(β1)=b1;m1(β2)=b2; m1(γ1)=c1; m1(γ2)=c2.*
m2* : m2(α)=E;m2(β)=C; m2(γ)=B; m2(α1)=e2;m2(α2)=e1;m2(β1)=c2;m2(β2)=c1; m2(γ1)=b2; m2(γ2)=b1.*
m3* : m3(α)=B;m3(β)=E; m3(γ)=C; m3(α1)=b2;m3(α2)=b1;m3(β1)=e2;m3(β2)=e1; m3(γ1)=c2; m3(γ2)=c1.*
m4* : m4(α)=B;m4(β)=C; m4(γ)=E; m4(α1)=b1;m4(α2)=b2;m4(β1)=c1;m4(β2)=c2; m3(γ1)=e1; m4(γ2)=e2.*
m5* : m5(α)=C;m5(β)=B; m5(γ)=E; m5(α1)=c2;m5(α2)=c1;m5(β1)=b2;m5(β2)=b1; m5(γ1)=e2; m5(γ2)=e1.*
m6* : m5(α)=C;m5(β)=E; m5(γ)=B; m5(α1)=c1;m5(α2)=c2;m5(β1)=e1;m5(β2)=e2; m5(γ1)=b1; m5(γ2)=b2.*
Here, the homomorphisms over attributes are always the identity, that
is why they have been omitted.
Thanks to the six matches and the rule RT, the reader may
check that the subgraph s can be rewritten, by using six different
variants of rule RT, into a pregraph containing 3×6 new
nodes and 12×6 new ports. The quotient pregraph has only 3
new nodes but has 42 new ports. Each pair of new nodes has 6
connections.
This example shows that the full parallel rewriting has to be used carefully since it may produce non intended results due to overmatching the same subgraphs. To overcome this issue, one may use attributes in order to lower the possible matches.
We call such attributes distinguishing attributes.
In order to consider only one match of the subgraph s considered in
Example 8 by the rule RT, one option is to apply
full parallel rewrite relation with
distinguishing attributes on the subgraph depicted in Figure 10 (a) and
rule RT with distinguishing attributes given in
Figure 10 (b),
leading to a pregraph whose
quotient is a graph with 3 new nodes and 12 new ports.
This graph is the expected one.
Another way to mitigate the problems of overmatching subgraphs, in
addition to the use of distinguishing attributes, consists in taking
advantage of the symmetries that appear in the graphs of rewrite
rules. This leads us to define a new rewrite relation which gets rid
of multiple matches of the same left-hand-side of a fixed
rule. We call this relation parallel up to automorphisms and is defined
below.
0.4.2 Parallel Rewrite Relation up to Automorphisms
Let us consider a graph g which rewrites into g1 and g2 using
an ESRR l→r. This means that there exist two matches
μiβi:l→g with i∈{1,2} such that
g⇒l→r,μiβigi. One may wonder
whether g1 and g2 are the same (up to isomorphism) whenever
matches μ1β1 and μ2β2 are linked by means of an
automorphism of l. That is to say, when there exists an automorphism
ha:l→l with μ1β1=μ2β2∘ha.
Intuitively, matches μ1β1 and μ2β2 could be considered
as the same up to a permutation of nodes. We show below that g1 and
g2 are actually isomorphic but under some syntactic condition we
call symmetry condition.
Notation: Let g be a graph with attributes in A. We write
H(g) to denote the set of automorphisms of g, i.e. H(g)
is the set of isomorphisms ha:g→g, with a being an
isomorphism on the attributes of g, a:A→A.
Proposition 11**.**
Let l→r be an ESRR. let
l1→r1 and l2→r2 be two variants of the rule
l→r. Let v1c1, v1′c1, v2c2, v2′c2
be the isomorphisms reflecting the variant status of these two rules
with v1c1:l→l1, v1′c1:r→r1,
v2c2:l→l2 and v2′c2:r→r2 such that
li=vici(l), ri=vi′ci(r) and
vici(rienv)=vi′ci(rienv) for i∈{1,2}.
Let g be a graph and g1′ and g2′ be two pregraphs. Let
g⇒l1→r1,m1b1g1′ and
g⇒l2→r2,m2b2g2′ be two rewrite
steps such that there exist two automorphisms ha:l→l
and h′a:r→r
such that (i) with m1b1=m2b2∘v2c2∘ha∘(v1c1)−1 and (ii) for all elements x of renv, h′a(x)=ha(x).
Then, g1′ and g2′ are isomorphic.
Sketch.
The sketch of the proof is depicted in Figure 11. The
attributes structures used in the rule l→r (respectively,
l1→r1 and l2→r2) are denoted A (respectively,
A1 and A2) whereas the attibutes structure of the transfomed
graph g is denoted B.
From the hypotheses, we can easily infer the exitence of two
isomorphisms hvcv:l1→l2 and hv′cv:r1→r2 such that
hvcv=v2c2∘ha∘(v1c1)−1 and
hv′cv=v2′cv∘h′a∘(v1′c1)−1.
And we have cv=c2∘a∘c1−1.
Let g⇒l1→r1,m1b1g1′ and
g⇒l2→r2,m2b2g2′
such that m1b1(l1)=m2b2(l2).
By definition of a rewrite step, there exist a pregraph g1 (respect.
a pregraph g2) and an injective
homomorphism m1′b1:r1→g1 (respect. m2′b2:r2→g2)
such that g1′=g1 (respect. g2′=g2). Moreover,
since, by definition, renv is included in lenv for any ESRR l→r, we have m1′b1(r1env)=m1b1(r1env)
(respect. m2′b2(r2env)=m2b2(r2env)), where mi′bi, for i∈{1,2}, are defined as follows:
for n\in{\cal N}_{r_{i}},{m^{\prime}}^{b_{i}}_{i}(n)=\left\{\begin{array}[]{l}m^{b_{i}}_{i}(n)\;if\;n\in{\cal N}_{r_{i}}^{env}\\
n\;otherwise(n\in{\cal N}_{r_{i}}^{new})\end{array}\right.
for p\in{\cal P}_{r_{i}},{m^{\prime}}^{b_{i}}_{i}(p)=\left\{\begin{array}[]{l}m^{b_{i}}_{i}(p)\;if\;p\in{\cal P}_{r_{i}}^{env}\\
p\;otherwise(p\in{\cal P}_{r_{i}}^{new})\end{array}\right.
Now, let us define the isomorphism h′′d:g1→g2 with d(x)= if x∈b1(A1) then b2∘cv∘b1−1(x) else x.
Let us consider x
such that x is an element of renv (port or node).
We have m1b1(v1c1(x))=m2b2(v2c2(ha(x))) is an element of g.
Moreover m1′b1(v1′c1(x))∈g1 and m2′b2(v2′c2(h′a(x))∈g2.
Let us denote y=m1b1(v1c1(x)).
By construction m1′b1(v1′c1(x))=m1b1(v1c1(x))=y because x∈renv.
From the hypothesis we have ha(x)=h′a(x). Thus
m2′b2(v2′c2(h′a(x))=m2′b2(v2′c2(ha(x)) and then we have
m2′b2(v2′c2(h′a(x))=m2b2(v2c2(ha(x))=y.
Then,
for all elements z of
the non-modified part of g which is g−m1b1(v1c1(l)) (z can be a port or a node if y is not a node) such that (z,y)∈g,
we have that (z,y)∈g1 and (z,y)∈g2 and h′′d=Idd on g1−m1′b1(v1′c1(r)).
Finally the definition of h′′d is :
For y\in{\cal N}_{g_{1}}\cup{\cal P}_{g_{1}},h^{\prime\prime d}(y)=\left\{\begin{array}[]{l}m_{2}^{\prime b_{2}}(h_{v}^{\prime c_{v}}((m_{1}^{\prime b_{1}})^{-1}(y)))\;if\;y\in m_{1}^{\prime b_{1}}(r_{1})\\
y\;otherwise\end{array}\right.
For all types of existing connections (y,z) of g1 where y and
z in Ng1∪Pg1, h′′d(y,z)=(h′′d(y),h′′d(z)) is
in g2. By construction, the homomorphism conditions on attributes
are fulfilled by h′′d. Thus, h′′d:g1→g2 is a pregraph homomorphism.
In addition, h′′d is bijective by construction.
From h′′d and
Proposition 6, we infer the
isomorphism h(3)d:g1′→g2′.
∎
Definition 18** (Symmetry Condition).**
An ESRR l→r verifies the
symmetry condition iff
∀ha∈H(l),∃h′a∈H(r),\mboxsuchthat∀x∈renv,ha(x)=h′a(x)
The reader can check that the rule RT verifies the symmetry condition.
Definition 19** (Matches up to automorphism, ∼l).**
Let l→r be an ESRR satisfying the symmetry condition.
Let l1→r1 and l2→r2 be two different variants of
the rule l→r. Let v1c1:l→l1 and v2c2:l→l2 be the isomorphisms that reflect the variant status
of l1 and l2 of l. Let m1b1:l1→g and m2b2:l2→g be two matches such that m1b1(l1)=m2b2(l2). We
say that matches m1b1 and m2b2 are equal up to (l-)automorphism and
write m1b1∼lm2b2
iff
there exists an automorphism ha:l→l such that m1b1=m2b2∘v2c2∘ha∘v1c1−1.
Definition 20** (Rewriting up to automorphisms).**
Let R be a conflict free environment sensitive graph
rewrite system whose rules satisfy the symmetry
condition and g a graph. Let
M(R,g)auto={miai:li→g∣li\mboxistheleft−handsideofavariantofa\mboxrulel→r\mboxinR\mboxandmiai\mboxisamatchuptoautomorphism}.
We define the rewrite relation ⇉auto which rewrites graph g by
considering only matches up to automorphisms. I.e., the set of matches M of Definition 14 is
M(R,g)auto.
Remark 4**.**
For all two matches m1b1 and m2b2 in M(R,G)auto, m1b1∼lm2b2. This means that the choice of matchings in
M(R,G)auto are not unique. From every equivalence class of a
match w.r.t. the equivalence relation ∼l, only one
representative is considered. Therefore, one may wonder if the relation ⇉auto is
confluent. The answer is positive, that is to say, whatever the match
representatives are chosen (up to automorphism), the relation ⇉auto
rewrites a given graph to a same pregraph up to isomorphism.
Theorem 3**.**
Let R be a conflict free environment sensitive graph
rewrite system whose rules satisfy the symmetry
condition. Then ⇉auto is deterministic. That is, for all graphs g,
(g⇉autog1′ and g⇉autog2′) implies that g1′ and g2′
are isomorphic.
Sketch.
Let M1 (resp. M2) be the set of matches used in the rewrite step
g⇉autog1′ (resp. g⇉autog2′). Let us assume that M1=M2.
By definition of sets M1 and M2, for all matches mibi:li→g
in M1, there exits a match mi′bi′:li′→g in M2 such that li and
li′ are the left-hand sides of two variants li→ri and li′→ri′ of a rule l→r in
R such that mibi(li)=mi′bi′(li′). That is to say, there exist four isomorphisms reflecting the
variant status of these two rules, say vici:l→li,
vi′ci:r→ri, widi:l→li′ and wi′di:r→ri′ such that
li=vici(l), ri=vi′ci(r), li′=widi(l), ri′=wi′di(r),
∀x∈rienv,vici(x)=vi′ci(x) and
∀x∈ri′env,widi(x)=wi′di(x).
From the hypotheses, there exist two automorphisms hiai:li→li
and hi′ai:ri→ri and two isomorphisms hviei:li→li′
and hv′iei:ri→ri′ such that
hviei=widi∘hiai∘(vici)−1 and
hv′iei=wi′ei∘hi′ai∘(vi′ci)−1.
By following the same reasoning as in Proposition 11, we
can build h′′f:g1→g2 defined as follows, where μiti:ri→g1 and μi′ti:ri′→g2 are induced by definition of
rewrite steps (μiti and μi′ti play the same role, for every two
rules, as m1′b1 and m2′b2 in the proof of Proposition 11).
for n\in{\cal N}_{g_{1}},h^{\prime\prime f}(n)=\left\{\begin{array}[]{l}\mu_{i}^{\prime t_{i}}({h^{\prime}_{v}}_{i}^{e_{i}}((\mu_{i}^{t_{i}})^{-1}(n)))\;if\;n\in\mu_{i}^{t_{i}}(r_{i})\\
n\;otherwise\end{array}\right.
for p\in{\cal P}_{g_{1}},h^{\prime\prime f}(p)=\left\{\begin{array}[]{l}\mu_{i}^{\prime t_{i}}({h^{\prime}_{v}}_{i}^{e_{i}}((\mu_{i}^{t_{i}})^{-1}(p)))\;if\;p\in\mu_{i}^{t_{i}}(r_{i})\\
p\;otherwise\end{array}\right.
for (p,n)∈Ng1,h′′f(p,n)=(h′′f(p),h′′f(n))
for (p,p′)∈Ng1,h′′f(p,p′)=(h′′f(p),h′′f(p′))
Clearly h′′f is an isomorphism between pregraphs g1 and g2. Therefore, by
Proposition 6, g1′ (which equals g1) is isomorphic to
g2′ (which equal g2).
∎
0.5 Examples
We illustrate the proposed framework through three examples borrowed
from different fields. We particularly provide simple confluent rewrite systems encoding cellular automata, the koch snowflake and the mesh refinement.
0.5.1 Cellular automata (CA)
A cellular automaton is based on a fixed grid composed of cells.
Each cell computes its new state synchronously. At instant
t+1, the value of a state k, denoted xk(t+1) may depend
on the valuations at instant t of
the state k itself, xk(t), and the states xn(t) such
that n is a neighbor of k. Such a formula is of the following
shape, where f is a given function and ν(k) is the set of the
neighbors of cell k: xk(t+1)=f(xk(t),xn(t),n∈ν(k))
In the case of a graph g, the neighbors of a cell (node) k,
ν(k), is defined by :
l∈ν(k) iff ∃p1,∃p2,(p1,k)∈PNg∧(p2,l)∈PNg∧(p1,p2)∈PPg.
Usually, the grid is oriented such that any cell of ν(k) has a unique relative position with respect to the cell k.
This orientation is easily modeled by distinguishing attributes on ports.
For instance, one can consider Moore’s neighborhood [9] on a 2-dimensional grid. This neighborhood of radius 1 is composed of 8 neighbors. The distinguishing attributes on ports belong to the set A={e,w,n,s,ne,se,nw,sw}
which defines the 8 directions where e = east, w = west, n = north, s =
south etc.
The grid is defined by a graph
g=(Ng,Pg,PNg,PPg,Ag,λg) such that :
Ng={mi,j}i∈I,j∈J, where intervals I and
J are defined as I=[−N,N]∩Z and J=[−N′,N′]∩Z for some natural numbers N and N′.
Pg={ei,j,wi,j,si,j,ni,j,nei,j,nwi,j,
sei,j,swi,j∣ i∈I,j∈J},
PNg={(ei,j,mi,j),(wi,j,mi,j),(si,j,mi,j),(ni,j,mi,j),(nei,j,mi,j),(nwi,j,mi,j),(sei,j,mi,j),
(swi,j,mi,j)∣i∈I,j∈J},
PPg={(ei,j,wi,j+1),(wi,j,ei,j−1),(ni,j,
si−1,j),(si,j,ni+1,j),(nei,j,swi−1,j+1),
(sei,j,nwi+1,j+1),(nwi,j,sei−1,j−1),(swi,j,
nei+1,j−1)∣ i∈I,j∈J},
∀i∈I,∀j∈J, λg(mi,j)⊆Ag,
∀i∈I,∀j∈J, λg(ei,j)={e}, λg(wi,j)={w},λg(si,j)={s}, λg(ni,j)={n}, λg(nei,j)={ne, λg(nwi,j)={nw}, λg(sei,j)={se}, λg(swi,j)={sw}.
The attributes of the nodes correspond to states of the cells. They
belong to a set A. To implement the dynamics of the
automaton one needs only one rewrite rule {ρ=l→r} which
corresponds to the function f. The rule does not modify the
structure of the grid but modifies the attributes of nodes. Thus a
left-hand side has a structure of a star with one central node (see Figure 12), for
which the rule at hand expresses its dynamics, surrounded by its
neighbors. Nodes, ports and edges of the left-hand side belong to the
environment part of the rule. Only the attribute of the central node
belongs to the cut part since this attribute is modified by the rule. In the left-hand-side, the attributes of
nodes are variables to which values are assigned during the matches.
The right-hand-side is reduced to a single node named i. Its
attribute corresponds to the new part of the right-hand side.
Figure 12 illustrates such rules by implementing the well
known game of life. It is defined using
Moore’s neighborhood and the dynamics of the game is defined on a
graph g such that attributes of nodes are in {0,1} and
xi(t+1)=((∑l∈ν(i)xl(t))=?=3)+((xi(t)=?=1)
×(∑l∈σ(i)xl(t))=?=2))
where (x=?=y)\Leftrightarrow\left\{\begin{array}[]{l}1\;if\;x=y\\
0\;otherwise\end{array}\right.
The neighborhood of a node i and its dynamics verify the symmetry
condition, thus there is no need to define attributes on ports.
The rewriting relation ⇉auto is applied
on the rewrite system R={ρ=l→r} reduced to
one rule depicted in Figure 12. More precisely the graphs of
the rule as defined as follows:
l=(Nl,Pl,PNl,PPl,Al,λl) with
Nl=Nlenv={i,a,b,c,d,e,f,g,h},
Pl=Plenv={i1,i2,i3,i4,i5,i6,i7,i8,
a1,b1,c1,d1,e1,f1,g1,h1},
PNl=PNlenv={(a1,a),(b1,b),(c1,c),(d1,d),
(e1,e),(f1,f),(g1,g),(h1,h),(i1,i)(i2,i),(i3,i),
(i4,i),(i5,i),(i6,i),(i7,i),(i8,i)},
PPl=PPlenv={(i1,a1)(i2,b1),(i3,c1),(i4,d1),
(i5,e1),(i6,f1),(i7,g1),(i8,h1)}.
Al={0,1,xi}∪{yq∣q∈{a,b,c,d,e,f,g,h}} and λl=λlenv∪λlcut with
λlcut:{i}→Al such that λlcut(i)={xi}
; and
λlenv:{a,b,c,d,e,f,g,h}→Al such that
λlenv(q)={yq}
r=(Nr,Pr,PNr,PPr,Ar,λr) with
Nr=Nrenv={i},
Pr=∅, PNr=∅, PPr=∅.
Ar=Al
Moreover, on nodes, λr=λrnew (λrenv being
empty) with
λrnew:{i}→Attr and λrnew(i)={((ya+yb+yc+yd+ye+yf+yg+yh)=?=3)+((xi=?=1)×((ya+yb+yc+yd+ye+yf+yg+yh)=?=2))}.
In the classical formulation of cellular automata, a cell contains one and only one value.
The model we propose can deal with cells with one or several values.
For instance, the initial state of the game of life can be a grid containing {0}’s except for 4 cells describing a square (see Figure 13(a)).
In this configuration one cell have 2 values which means, on the example, that the cell is dead or alive or we don’t have any information on the state of the cell.
The behavior of all possible trajectories is computed in parallel and
the fixed point is reached.
The initial state Figure 14(a) yields Figure 14(b) as a fixed point. Here we observe that the indeterminacy concerns at most 4 cells
over time.
0.5.2 The Koch snowflake
The well-known Koch snowflake is based on segment divisions (variants exist on surfaces, both can be modeled by our formalism).
Each segment is recursively divided into three segments of equal length as described in the following picture :
Let us consider the following triangle g as an initial state.
g=(Ng,Pg,PNg,PPg,Ag,λg) with
Ng={1,2,3} , Pg={p1,q1,p2,q2,p3,q3}, PNg={(p1,1),(q1,1),(p2,2),(q2,2),(p3,3),(q3,3)} , PPg={(p1,q2),(p2,q3),(p3,q1)}.
\lambda_{g}(1)=\left(\begin{array}[]{c}-1\\
0\end{array}\right), \lambda_{g}(2)=\left(\begin{array}[]{c}0\\
\sqrt{2}\end{array}\right), \lambda_{g}(3)=\left(\begin{array}[]{c}1\\
0\end{array}\right), λg(p1)=λg(p2)=λg(p3)={−}, λg(q1)=λg(q2)=λg(q3)={+}.
The attributes of ports are distinguishing attributes. The attributes
of nodes are the R2 positions of the
nodes. Every node got one attribute in R2, thus by abuse of
notation, we get rid of the set notation of attributes and use a
functional one. The implementation of both relations ⇉ and ⇉auto using the rule depicted in Figure 15 provide the expected pictures of flakes as in Figures 16.
Let us denote
\lambda_{l}(a)=\left(\begin{array}[]{c}x_{a}\\
y_{a}\end{array}\right)
and
\lambda_{l}(b)=\left(\begin{array}[]{c}x_{b}\\
y_{b}\end{array}\right).
In this example, the attributes of nodes i,j and
k are defined as follows:
λr(i)=32λl(a)+31 \lambda_{l}(b)=\left(\begin{array}[]{c}\frac{2}{3}x_{a}+\frac{1}{3}x_{b}\\
\frac{2}{3}y_{a}+\frac{1}{3}y_{b}\end{array}\right),
\lambda_{r}(j)=\frac{1}{2}(\lambda_{l}(a)+\lambda_{l}(b))+\frac{\sqrt{3}}{6}(\lambda_{l}(a)^{T}+\lambda_{l}(b)^{T})=\left(\begin{array}[]{c}\frac{1}{2}(x_{a}+x_{b})+\frac{\sqrt{3}}{6}(y_{a}-y_{b})\\
\frac{1}{2}(y_{a}+y_{b})+\frac{\sqrt{3}}{6}(-x_{a}+x_{b})\end{array}\right), and \lambda_{r}(k)=\frac{1}{3}\lambda_{l}(a)+\frac{2}{3}\lambda_{l}(b)=\left(\begin{array}[]{c}\frac{1}{3}x_{a}+\frac{2}{3}x_{b}\\
\frac{1}{3}y_{a}+\frac{2}{3}y_{b}\end{array}\right)
0.5.3 Mesh refinement
Mesh refinement consists in creating iteratively new partitions of the considered space.
The initial mesh g we consider is depicted
Figure 18. Distinguishing attributes are given on
ports. Attributes on nodes are omitted but we can easily consider
coordinates.
Triangle refinements are given in Figure 17. The three
rules verify the symmetry condition and we apply the ⇉auto relation on g to
obtain the graph g′ described in Figure 18.
Iteratively, the rewrite system can be applied again on g′ and so forth.
0.6 Conclusion and Related Work
Parallel rewriting technique is a tough issue when it has to deal with
overlapping reducible expressions. In this paper, we have proposed a
framework, based on the notion of rewriting modulo, to deal with graph transformation where parallel reductions may
overlap some parts of the transformed graph. In general, these
transformations do no lead to graphs but to a structure we call
pregraphs. We proposed sufficient conditions which ensure that graphs are
closed under parallel transformations. We also defined two parallel
transformations: (i) one that fires all possible rules in parallel
(full parallel) and (ii) a second rewrite relation which takes
advantage of the possible symmetries that may occur in the rules by
reducing the possible number of matches that one has to consider. The
two proposed parallel rewrite relations are confluent (up to
isomorphisms).
Our proposal subsumes some existing formalisms where simultaneous
transformations are required such as cellular automata
[23] or (extensions of) L-systems
[19]. Indeed, one can easily write graph rewriting
systems which define classical cellular automata, with possibly
evolving structures (grids) and where the content of a cell, say C,
may depend on cells not necessary adjacent to C. As for L-systems,
they could be seen as formal (context sensitive) grammars which fire
their productions in parallel over a string. Our approach here
generalizes L-systems at least in two directions: first by considering
graphs instead of strings and second by considering overlapping graph
rewrite rules instead of context sensitive (or often context free)
rewrite rules. Some graph transformation approaches could also be
considered as extension of L-systems such as star-grammars
[15] or hyperedge replacement [10]. These
approaches do not consider overlapping matches but act as context free
grammars. However, in [8] parallel graph grammars with
overlapping matches have been considered. In that work, overlapping
subgraphs remain unchanged after reductions, contrary to our framework
which does not require such restrictions. The idea behind parallel
graph grammars has been lifted to general replacement systems in
[22]. Amalgamation, see e.g.[13], aims at
investigating how the parallel application of two rules can be
decomposed into a common part followed by the remainder of the two
considered parallel rules. Amalgamation does not consider full
parallel rewriting as investigated in this paper.
Another approach based on complex transformation has been introduced
in [14]. This approach can handle overlapping matches but
requires from the user to specify the transformation of these common
parts. This requires to provide detailed rules. For instance, the two
first cases of the triangle mesh refinement example requires about
sixteen rules including local transformations and inclusions, instead
of two rules in our framework.
The strength of our approach lies in using an equivalence relation on
the resulting pregraph. This equivalence plays an important role in
making graphs closed under rewriting. Other relations may also be
candidate to equate pregraphs into graphs. we plan to investigate such
kind of relations in order to widen the class of rewrite systems that
may be applied in parallel on graph structures in presence of
overlaps. We also plan to investigate other issues such as stochastic
rewriting and conditional rewriting which would be a plus in modeling some
natural phenomena. Analysis of the proposed systems remains to be
investigated further.