Checking Graph-Transformation Systems for Confluence Detlef Plump - - PowerPoint PPT Presentation
Checking Graph-Transformation Systems for Confluence Detlef Plump - - PowerPoint PPT Presentation
Checking Graph-Transformation Systems for Confluence Detlef Plump Hypergraphs E TOP TRUE 1 3 PUSH EMPTY? data stack bool 2 FALSE F POP Hypergraphs E TOP TRUE 1 3 PUSH EMPTY? data stack bool 2 FALSE F POP
Hypergraphs
data stack bool E F TOP PUSH
1 2 3
Λ POP EMPTY? TRUE FALSE
Hypergraphs
data stack bool E F TOP PUSH
1 2 3
Λ POP EMPTY? TRUE FALSE
◮ Signature Σ = ΣV, ΣE, Type: ΣE → P(Σ∗ V) where ΣV and
ΣE are sets of vertex labels and hyperedge labels
Hypergraphs
data stack bool E F TOP PUSH
1 2 3
Λ POP EMPTY? TRUE FALSE
◮ Signature Σ = ΣV, ΣE, Type: ΣE → P(Σ∗ V) where ΣV and
ΣE are sets of vertex labels and hyperedge labels
◮ Hypergraph
G = V, E, lV : V → ΣV, lE : E → ΣE, att: E → V∗ where V, E are finite sets of vertices and hyperedges, and l∗
V(att(e)) ∈ Type(lE(e)) for each hyperedge e
Hypergraphs
data stack bool E F TOP PUSH
1 2 3
Λ POP EMPTY? TRUE FALSE
◮ Signature Σ = ΣV, ΣE, Type: ΣE → P(Σ∗ V) where ΣV and
ΣE are sets of vertex labels and hyperedge labels
◮ Hypergraph
G = V, E, lV : V → ΣV, lE : E → ΣE, att: E → V∗ where V, E are finite sets of vertices and hyperedges, and l∗
V(att(e)) ∈ Type(lE(e)) for each hyperedge e ◮ Graph G: all hyperedges e satisfy |att(e)| = 2
Rules (injective case)
◮ Rule: L ⊇ K ⊆ R
2 1
⊇
2 1
⊆
2 1
Rules (injective case)
◮ Rule: L ⊇ K ⊆ R
2 1
⊇
2 1
⊆
2 1
◮ Intuition: remove L − K and add R − K
Rules (injective case)
◮ Rule: L ⊇ K ⊆ R
2 1
⊇
2 1
⊆
2 1
◮ Intuition: remove L − K and add R − K ◮ Short notation: L ⇒ R
2 1
⇒
2 1
Direct derivation G ⇒r,g H
Given r : L ⊇ K ⊆ R and injective morphism g : L → G
2 1
⊇
2 1
⊆
2 1
g ↓
2 1
Direct derivation G ⇒r,g H
Given r : L ⊇ K ⊆ R and injective morphism g : L → G
2 1
⊇
2 1
⊆
2 1
g ↓
2 1
- 1. Check dangling condition: nodes in g(L − K) are not incident
to edges outside g(L)
Direct derivation G ⇒r,g H
Given r : L ⊇ K ⊆ R and injective morphism g : L → G
2 1
⊇
2 1
⊆
2 1
g ↓
↓
2 1
⊇
1 2
- 1. Check dangling condition: nodes in g(L − K) are not incident
to edges outside g(L)
- 2. Remove g(L − K)
Direct derivation G ⇒r,g H
Given r : L ⊇ K ⊆ R and injective morphism g : L → G
2 1
⊇
2 1
⊆
2 1
g ↓
↓ ↓
2 1
⊇
1 2
⊆
1 2
- 1. Check dangling condition: nodes in g(L − K) are not incident
to edges outside g(L)
- 2. Remove g(L − K)
- 3. Add R − K
Hypergraph-transformation systems
Hypergraph-transformation system Σ, R
◮ Σ: signature ◮ R: set of rules over Σ
Graph-transformation system Σ, R
◮ for each label l ∈ ΣE and each w ∈ Type(l), |w| = 2
Example: reduction rules for control-flow graphs
seq:
1 2
⇒
2 1
while:
2 1
⇒
2 1
dec1:
2 1
⇒
2 1
dec2:
2 3 1
⇒
2 3 1
Confluence
A hypergraph-transformation system Σ, R is confluent if for all hypergraphs G, H1, H2 over Σ, H1 ⇐∗
R G ⇒∗ R H2 implies that
there is a hypergraph M such that H1 ⇒∗
R M ⇐∗ R H2.
G H1 H2 M
∗
⇐ =
R ∗
= ⇒
R ∗
= ⇒
R ∗
⇐ =
R
Confluence
A hypergraph-transformation system Σ, R is confluent if for all hypergraphs G, H1, H2 over Σ, H1 ⇐∗
R G ⇒∗ R H2 implies that
there is a hypergraph M such that H1 ⇒∗
R M ⇐∗ R H2.
G H1 H2 M
∗
⇐ =
R ∗
= ⇒
R ∗
= ⇒
R ∗
⇐ =
R
Note: Confluence implies that every hypergraph can be reduced to at most one irreducible hypergraph (up to isomorphism). The converse does not hold.
Local confluence
A hypergraph-transformation system Σ, R is locally confluent if for all hypergraphs G, H1, H2 over Σ, H1 ⇐R G ⇒R H2 implies that there is a hypergraph M such that H1 ⇒∗
R M ⇐∗ R H2.
G H1 H2 M ⇐ =
R
= ⇒
R ∗
= ⇒
R ∗
⇐ =
R
Local confluence does not imply confluence
Counterexample: R r1 : a ⇒ b r2 : a ⇒ c r3 : c ⇒ a r4 : c ⇒ d The system is locally confluent but not confluent: b ⇐
r1
a ⇒
r2
⇐
r3
c ⇒
r4
d
Termination and confluence
A hypergraph-transformation system Σ, R is terminating if there is no infinite sequence G0 ⇒R G1 ⇒R G2 ⇒R . . .
Theorem (Newman’s lemma)
A terminating hypergraph-transformation system is confluent if and only if it is locally confluent.
Critical pairs (for injective rules)
Direct derivations T1 ⇐r1,g1 S ⇒r2,g2 T2 are a critical pair if
- 1. S = g1(L1) ∪ g2(L2) and
- 2. the steps are not independent, that is, S ⇒r1,g1 T1 removes
an item in g2(L2) or S ⇒r2,g2 T2 removes an item in g1(L1). Also, if r1 = r2 then g1 = g2 must hold.
Critical pairs (for injective rules)
Direct derivations T1 ⇐r1,g1 S ⇒r2,g2 T2 are a critical pair if
- 1. S = g1(L1) ∪ g2(L2) and
- 2. the steps are not independent, that is, S ⇒r1,g1 T1 removes
an item in g2(L2) or S ⇒r2,g2 T2 removes an item in g1(L1). Also, if r1 = r2 then g1 = g2 must hold. Note: Hypergraph-transformation systems with finitely many rules possess only finitely many critical pairs (up to isomorphism).
Example: critical pairs of control-flow reduction rules (1)
w y z
⇐
seq w x y z
⇒
seq w x z x z
⇐
seq x y z
⇒
seq x y
Example: critical pairs of control-flow reduction rules (2)
w y z
⇐
while
⇒
seq x y w z z w
⇒
dec2
⇐
while x z w
Example: critical pairs of control-flow reduction rules (3)
w y v z
⇐
dec2 w x v y z
⇒
seq w x v z
Example: critical pairs of control-flow reduction rules (4)
w y v
⇐
dec2 w x v y
⇒
seq w x v w y v
⇐
dec2 w x v y
⇒
seq w x v
Joinability
Given a hypergraph-transformation system Σ, R, a critical pair T1 ⇐ S ⇒ T2 is joinable if there is a hypergraph U such that T1 ⇒∗
R U ⇐∗ R T2.
S T1 T2 U ⇐ = = ⇒
∗
= ⇒
R ∗
⇐ =
R
Joinability is insufficient
Joinability of all critical pairs does not guarantee local confluence:
r1 :
1 2
a ⇒
1 2
b r2 :
1 2
a ⇒
1 2
b
The only critical pair is joinable:
1 2
b ⇐
r1
1 2
a ⇒
r2
1 2
b
But Σ, {r1, r2} is not locally confluent:
1 2
b b ⇐
r1
1 2
a b ⇒
r2
1 2
b b
Strong joinability
For a critical pair Γ: T1 ⇐ S ⇒ T2, define Persist(Γ) = {v ∈ SV | S ⇒ T1 and S ⇒ T2 preserve v}. Given a hypergraph-transformation system Σ, R, a critical pair Γ: T1 ⇐ S ⇒ T2 is strongly joinable if there are a hypergraph U and derivations T1 ⇒∗
R U ⇐∗ R T2 such that for each
v ∈ Persist(Γ), trS⇒T1⇒∗U(v) and trS⇒T2⇒∗U(v) are defined and equal. Here trS⇒T1⇒∗U : S → U and trS⇒T2⇒∗U : S → U are partial morphisms that, informally, track the items in S through the derivations S ⇒ T1 ⇒∗ U and S ⇒ T2 ⇒∗ U.
Critical pair lemma
Theorem (Critical pair lemma [P 93])
A hypergraph-transformation system is locally confluent if all its critical pairs are strongly joinable.
Corollary
A terminating hypergraph-transformation system is confluent if all its critical pairs are strongly joinable.
Confluence does not imply strong joinability
The system r1 :
1 2
⇒
1 2
r2 :
1 2
⇒
1 2
is terminating and confluent but the critical pair
1 2
⇐
r1
1 2
⇒
r1
1 2
is not strongly joinable
Bad news: confluence is undecidable
Theorem ([P 93/05])
The following problem is undecidable in general: Instance: A terminating graph transformation system Σ, R where ΣV is a singleton and ΣE and R are finite. Question: Is Σ, R confluent?
Subhypergraphs G R and G ⊖
Let Σ, R be a hypergraph-transformation system and G a hypergraph over Σ.
◮ For e ∈ EG, the pair lE(e), l∗ V(attG(e)) is the profile of e. ◮ Prof(R) is the set of all hyperedge profiles occurring in R. ◮ VL(R) is the set of all vertex labels occurring in R.
Define subhypergraphs G R and G ⊖ of G as follows.
◮ G R consists of all hyperedges with profile in Prof(R) and all
nodes with label in VL(R).
◮ G ⊖ consists of all hyperedges in EG − Prof(R), all
attachment nodes of these hyperedges, and all nodes in VG − VL(R). Note that G = G R ∪ G ⊖, where G R and G ⊖ may share some attachment nodes of hyperedges in G ⊖.
Covering critical pairs
A cover for a critical pair Γ is a hypergraph C such that (1) PersistΓ ⊆ C, (2) C ⊖ = C, and (3) for every homomorphic image ˜ C of C, there is a unique surjective morphism C → ˜ C. Remarks:
- 1. (1) and (2) imply that each node in PersistΓ is incident to
some hyperedge in C.
- 2. Intuitively, C uniquely identifies the nodes in PersistΓ in that
for every image ˜ C of C, each node in PersistΓ corresponds to a unique node in ˜ C.
- 3. By (3), C does not possess nontrivial automorphisms.
Example: covers
Let Γ be a critical pair such that PersistΓ = {v1, . . . , vn} and lV(vi) = mi.
◮ If there is l ∈ ΣE such that m1 . . . mn ∈ Type(l) and
l, m1 . . . mn ∈ Prof(R), then the following is a cover for Γ: l
1
m1
. . . . . .
n
mn
◮ Alternatively, if there are distinct labels l1, . . . , ln−1 ∈ ΣE such
that for i = 1, . . . , n − 1, mimi+1 ∈ Type(li) and li, mimi+1 ∈ Prof(R), then the following is a graph cover for Γ: m1 m2 l1 l2
. . .
ln−1 mn
Coverable systems
A hypergraph-transformation system is coverable if for each of its critical pairs there exists a cover.
Theorem
A coverable hypergraph-transformation system is locally confluent if and only if all its critical pairs are strongly joinable. Consider now systems Σ, R in which ΣV, ΣE and R are finite.
Corollary
(1) Confluence is decidable for terminating coverable systems. (2) Confluence is decidable for terminating systems with universal signatures.
Decision procedure for confluence
Input: a terminating and coverable hypergraph-transformation system Σ, R and its set of critical pairs CP for all Γ: U1 ⇐r1,g1 S ⇒r2,g2 U2 in CP do {let C be a cover for Γ such that S ∩ C = PersistΓ}
- S := S ∪ C
{for i = 1, 2, let gi be the extension of gi to S} for i = 1 to 2 do construct a derivation S ⇒ri,b
gi
Ui ⇒∗
R Xi such that Xi is
irreducible end for ifX1 ∼ = X2 then return “non-confluent” end if end for return “confluent”
Example: extended critical pair
w y z
1 2
⇐
while
⇒
seq x y
1 2
w z
⇒
dec2
⇐
while x z
1 2
w z w
1 2