Title: From Graph Rewriting to Logic Programming
1From Graph Rewriting to Logic Programming
Ivan Lanese Dipartimento di Informatica Università
di Pisa
joint work with
Ugo Montanari
2Outline
- 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
3Motivation
- We propose to use
- Graphs as a natural way to model systems
- Synchronized hyperedge replacement to model
synchronization, reconfiguration and computation
4A very general framework
- Synchronized hyperedge replacement can be used to
model - Network structures and reconfigurations
- Software architectures
- Process-calculi (?-calculus, Ambient calculus, )
5A 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
6Edge Replacement Systems
- Productions A context free production rewrites a
single edge labeled by L into an arbitrary graph
R. (Notation L ? R)
L
R
H
3
3
4
4
2
2
1
1
7Edge Replacement Systems
- Productions A context free production rewrites a
single edge labeled by L into an arbitrary graph
R. (Notation L ? R)
Rewritings of different edges can be executed
concurrently
8Synchronized 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
9Synchronized 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
10Adding 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
11Example
12Logic Programming
13Synchronized 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
14The Ring-Star Example, I
15The Ring-Star Example, II
16A 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
17The In transition
18Productions for the In transition
19The In transition
20The reconfiguration
21Ambients 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.
22Adding 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
23Back 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
24Conclusions 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
25A Notation For Graphs
26Transitions as Judgements
Formalization of synchronized rewriting as
judgements
?
? G1 ?? ?, D G2
?
?
? ? ? (A x N ) (x, a , y) ? ? if ?(x)
(a , y)
o
D is the set of new names that are used in
synchronization D z ? x. ?(x) (a , y), z
? ?, z ?set(y)
27Transitions as Judgements
Formalization of synchronized rewriting as
judgements
Free names can i) be added to productions and
ii) merged Identity productions are always
available
- Transitions
- are generated from the productions by
applying the transition rules - of the chosen synchronization mechanism
28From Synchronized Graph Rewriting to LP
PROLOG metainterpreter for synchronous execution