View
217
Download
0
Tags:
Embed Size (px)
Citation preview
1
Ivan LaneseDipartimento di Informatica
Università di Pisa
Ugo Montanari
From Graph Rewriting to Logic Programming
joint work with
2
Outline
Graph rewriting as a metamodel
Graphical presentation of systems
Synchronized hyperedge replacement (SHR)
SHR with name mobility
Translation into logic programming
Ambients in SHR
Modelling local names
Conclusions
3
Motivation
We propose to use:
Graphs as a natural way to model systems
Synchronized hyperedge replacement to model synchronization, reconfiguration and computation
4
A very general framework
Synchronized hyperedge replacement can be used to model:
Network structures and reconfigurations
Software architectures
Process-calculi (-calculus, Ambient calculus, …)
5
A Strategy in Two Steps
Local graph transformations: – Modular description of the system– Easy to implement in a distributed environment
Global constraint solving:– Allows complex synchronizations and rewritings
6
Edge Replacement Systems
Productions: A context free production rewrites a single edge labeled by L into an arbitrary graph R. (Notation: L R)
L
1
2 3 4
R
1
2 3 4H
7
Edge Replacement Systems
Productions: A context free production rewrites a single edge labeled by L into an arbitrary graph R. (Notation: L R)
R
R’
1
2 3 4
1
2
3
Rewritings of different edges can be executed concurrently
L
L’
1
2 3 4
1
2
3
H
8
Synchronized Hyperedge Replacement
Synchronized rewriting: Actions are associated to nodes in
productions. A rewriting is allowed if its actions satisfy the
synchronization requirements associated to nodes
How many edges synchronize depends
on the synchronization policy
Synchronized rewriting propagates synchronization
all over the graph
9
Synchronized Hyperedge Replacement
Hoare Synchronization: All adjacent edges must produce the same action on the shared node
Milner Synchronization: Only two of the adjacent edges synchronize by matching their complementary actions
aa a
3 3
B1 A1
B2 A2
Hoare synchronization
10
Adding Mobility
Synchronized rewriting with name mobility
– Allow declaration of new nodes in productions
– Add to an action in a node a tuple of names that it wants to
communicate
– The names of synchronized actions are pairwise matched and the
corresponding nodes merged
a<x> a<y>
(x) (y)
B1 A1
a<x> = a<y>
B2 A2
a<x> a<y>
x= y
11
Example
b)
x CBrother
C
C
C
C
C
C
CC CBrother Brother
(4)(3)(2)(1)
Star Rec.S
S
SS
(5)
x
Initial Graph
C
Brother:
C
C
C
C S
Star Reconfiguration:
(w)
r(w)
r(w)
12
Logic Programming
13
Synchronized Logic Programs
Goals have no functional symbols: goal-graphs
Synchronized clauses
– bodies are goal-graphs
– heads are A(t1,…,tn) where ti is either a variable or
a single function symbol applied to variables
Syncronized execution
14
The Ring-Star Example, I
y
C
x
y
C
z
C
x
x, y C(x,y){(x,y
x, y z.C(x,z) | C(z,y)
y
C
x
y
S
xr < w >
r < w >
(w)
x, y C(x,y){(x,r,<w>), (y,r,<w>)}
x, y S(w,y)
15
The Ring-Star Example, II
x C
C
C
C
C
C
C
CC C
S
S
SS
16
A challenging example: Ambient calculus
SHR as a semantic framework for Ambient
calculus
Ambients naturally form trees
Connectors to simulate Milner synchronization
Computations formed by activity steps and
reconfiguration steps
17
The In transition
a) n[in m.P | Q] | m[ R ]b) m[n[P | Q] | R]
18
Productions for the In transition
19
The In transition
20
The reconfiguration
21
Ambients in logic programming
The starting goal:
nil(v), c3(x,y,v), n(w,x), c3(w,a,b), nil(b), c3(p,q,a), in_m.P(p), Q(q),m(c,y), c3(c,r,d), nil(d), R(r)
The final result:
nil(v2), m(k2,v2), c3(k2,c2,d2), nil(d2), c3(h2,r2,c2), R(r2), n(w1,h2), c3(w1,a1,b1), nil(b1), c3(p1,q1,a1), P(p1), Q(q1)
Easy to execute with a meta-interpreter.
22
Adding restriction
Graphs can be extended with a restriction operator
Transitions on hidden nodes are not seen from
the outside
The transmission of an hidden name can
provoke an extrusion
The SHR rules can be extended to deal with the
restriction operator
23
Back to logic programming
Logic programming with restriction:
An extension of logic programming with the restriction
operator
Allows a uniform treatment of restriction to goal
variables and of anonymous variables
Introduce a step-by-step semantics of name visibility
The synchronized version is in correpondence with
SHR
24
Conclusions and Future Work
Graph rewriting as a general model An useful semantic framework for process-calculi Useful connections between SHR and logic
programming:– Implementations of SHR systems
– Logic programming with restriction
General synchronizations for graph rewriting
25
x,y z, w. C(x,w) | C(w,y) | C (y,z) | C(z,x)
A Notation For Graphs
Ring Example
w z
26
: (A x N* ) (x, a , y) if (x) = (a , y)
Transitions as Judgements
Formalization of synchronized rewriting as judgementsTransitions
G1 , G2
is the set of new names that are used in synchronization
= {z | x. (x) = (a , y), z , z set(y)}
o
27
Transitions as Judgements
Formalization of synchronized rewriting as judgements
Derivations
0 G0 1 G1 … n Gn
12 n
x1,…,xn L(x1,…,xn) x1,…,xn , G
Productions
Free names can: i) be added to productions; and ii) mergedIdentity productions are always available
Transitions are generated from the productions by applying the transition rules of the chosen synchronization mechanism
28
From Synchronized Graph Rewriting to LP
PROLOG metainterpreter for synchronous execution