47
1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università di Pisa Dagstuhl Seminar #05081, 20-25 February 2005 To be published on a special issue of Theory and Practice of Logic Programming

1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

  • View
    224

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

1

Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming

joint work withUgo Montanari

Ivan LaneseDipartimento di Informatica Università di Pisa

Dagstuhl Seminar #05081, 20-25 February 2005

To be published on a special issue of Theory and Practice of Logic Programming

Page 2: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

2

Roadmap

Lot of background– Fusion Calculus– Synchronized Hyperedge Replacement– Logic programming

From Fusion Calculus to Hoare SHR From Hoare SHR to logic programming Conclusions

Page 3: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

3

Motivations

Many models proposed for global computing systems

Each model has its strengths and its weaknesses

Comparing different models– To understand the relationships among them– To devise new (hybrid) models

Cannot analyze all the models, naturally…

Page 4: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

4

Roadmap

Lot of background– Fusion Calculus– Synchronized Hyperedge Replacement– Logic programming

From Fusion Calculus to Hoare SHR From Hoare SHR to logic programming Conclusions

Page 5: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

5

Fusion Calculus

Process calculus that is an evolution of -calculus

Simpler and more symmetric but also more expressive

Introduces fusions of names

Page 6: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

6

Syntax for Fusion Calculus

Agents:

S::=i i.Pi

P::=0 | S | P1|P2 | (x)P | rec X. P | X

Processes are agents up to a standard structural

congruence

nameson relation eequivalenc:

||::

:actions Free

xuxu

Page 7: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

7

Reduction semantics

'

'',',

QQ

QPPPQP

)||)(()).(|).(|)(( QPRzQyuPxuRz

)|)(()).(|)(( PRzPRz

yxyx

of mgu and where ||||

of mgu where

Page 8: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

8

Synchronized Hyperedge Replacement

Follows the approach of graph transformation (Hyper)edges are systems connected through common

nodes Productions describe the evolution of single edges

– Local effect, easy to implement

Productions are synchronized via constraints on nodes– Global constraint solving algorithm to find allowed transitions– Productions applied indipendently– Allows to define complex transformations

Page 9: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

9

Hyperedge Replacement Systems

A production describes how the hyperedge L is transformed into the graph R

R

1

2 3 4

L

1

2 3 4 H H

Page 10: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

10

Hyperedge Replacement Systems

A production describes how the hyperedge L is transformed into the graph R

R

R’

1

2 3 4

1

2

3

Many concurrent rewritings are allowed

L

L’

1

2 3 4

1

2

3

H H

Page 11: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

11

Synchronizing productions

Productions associate actions to nodes A transition is allowed iff the synchronization

constraints imposed on actions are satisfied Many synchronization models are possible

(Hoare, Milner, ...)

Page 12: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

12

An example: Hoare SHR

Hoare synchronization: all the edges must perform the same action

Milner synchronization: pairs of edges do complementary actions

aB1 A1

B2 A2

3 3

aa a

Page 13: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

13

SHR with mobility

– Actions carry tuples of references to nodes (new or already

existent)

– References associated to synchronized actions are matched and

corresponding nodes are merged

We use name mobility

a<x>B1 A1

B2 A2

a<y>a<x>a<y>

(x) (y)x=y

Page 14: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

14

Very quickly… Syntax Semantics

Logic programming

nBBA ,...,1 nBB ,...,1

goal atomic

),...,(

)mgu(,...,

1

1

k

k

BBA

HAPBBH

goal econjunctiv

',', GFGG

FG

Page 15: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

15

Roadmap

Lot of background– Fusion Calculus– Synchronized Hyperedge Replacement– Logic programming

From Fusion Calculus to Hoare SHR From Hoare SHR to logic programming Conclusions

Page 16: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

16

From Fusion to HSHR

We separate the topological structure (graph) from the behaviour (productions)

We give a visual representation to processes– Processes translated into graphs– Sequential processes become hyperedges– Names become structures called amoeboids

Our approach deals only with closed processes

Page 17: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

17

Translation by example

We take agents in standard form– restrictions with inside parallel composition of

sequential agents We transform it into a linear agent + substitution

)),(.|),(.|),,()(( wzSuzwxuRxyuzyxQuxyzw

)),(.|),(.|),,()(( 2312332221111 wzSwzuxuRyxuzyxQuxyzw

Page 18: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

18

Translation by example

We translate the process into a graph– Each linear agent becomes an edge labelled with a

copy of the agent with standard names» Q(x1,y1,z1) becomes an edge labelled by Q(x1,x2,x3)

attached to x1,y1,z1

– σ transformed into amoeboids» Each amoeboid connects a group of names merged by σ

Page 19: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

19

Translation by example

)),(.|),(.|),,()(( 2312332221111 wzSwzuxuRyxuzyxQuxyzw

Q(x1,x2,x3)

x1x2x3.R(x4,x5)

x1x2x3.S(x4,x5)

x

uw

zy

x1

y1

z1

u1

x2

y2

u2

x3

u3

z2 z3

w2

w1

Page 20: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

20

Dynamics

We have actions for input and output prefixes Productions for process edges

– Correspond to executions of prefixes of normalized linear agents

– Prefixes modeled by corresponding SHR actions– RHS contains the translation of the resulting

sequential process– Fusions implemented by connecting nodes via

amoeboids

Page 21: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

21

A sample production

),(),(. 3232221221 xuRxuRyxu yxu

x1x2x3.R(x4,x5)

u1

x2

y2

u2

x3

R(x1,x2)

x2

y2

u2

x3

u1

out2x2y2

Page 22: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

22

What is an amoeboid?

Amoeboids must allow two complementary actions on the interface and create new amoeboids connecting corresponding names

Connected amoeboids are merged

Px

Qy

in x out yP Q

=

Page 23: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

23

Implementing amoeboids in HSHR

Amoeboids implemented as networks of edges with a particular structure– composed essentially by edges that act as routers– each internal node is shared by two edges– some technical conditions

Satisfy the desired properties but…– interleaving must be imposed from the outside– produce some garbage (disconnected from the

system)

Page 24: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

24

Correspondence theorem

Reductions of fusion processes correspond to (interleaving) HSHR transitions– up to garbage– up to equivalence of amoeboids that does not

change the behaviour The correspondence can be extended to

computations

Page 25: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

25

Translation by example

Q(x1,x2,x3)

x1x2x3.R(x4,x5)

x1x2x3.S(x4,x5)

x

uw

zy

out x2 y2

in z2 w1

Page 26: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

26

Translation by example

Q(x1,x2,x3)

R(x1,x2)

S(x1,x2)

x

uw

zy

)),(|),(|),,()(( yxSxuRxyxQuxy

Page 27: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

27

Summary : Fusion Calculus vs HSHR

Fusion Hoare SHR

Closed process Graph

Sequential process Hyperedge

Name Amoeboid

Prefix Action

Prefix execution Production

Reduction Transition

Page 28: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

28

Roadmap

Lot of background– Fusion Calculus– Synchronized Hyperedge Replacement– Logic programming

From Fusion Calculus to Hoare SHR From Hoare SHR to logic programming Conclusions

Page 29: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

29

From Hoare SHR to logic programming

Useful for implementation purposes

Logic programming as goal rewriting engine

Very similar syntax (with the textual representation for HSHR)

Logic programming allows for many execution strategies and

data structures we need some restrictions– limited function nesting

– synchronized execution

We define Synchronized Logic Programming (SLP)

Page 30: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

30

Synchronized Logic Programming

A transactional version of logic programming (in the zero-safe

nets style)

Safe states are goals without function symbols (goal-graphs)

Transactions are sequences of SLD steps

During a transaction each atom can be rewritten at most once

Transactions begin and end in safe states

Transactions are called big-steps

A computation is a sequence of big-steps

Page 31: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

31

Synchronized clauses

Clauses with syntactic restrictions

– bodies are goal-graphs

– heads are A(t1,…,tn) where ti is either a variable or

a single function symbol applied to variables

Page 32: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

32

HSHR vs logic programming

Graphs translated to goal-graphs– edges modeled by predicates applied to the attachment nodes

Productions are synchronized clauses

Transitions are matched by big-steps

Actions are implemented by function symbols– the constraint that all function symbols have to be removed corresponds

to the condition for Hoare synchronization

– names are the arguments of the function symbol

– we choose the first one to represent the new name for the node where

the interaction is performed (needed since substitutions are idempotent)

– fusions performed by unification

Page 33: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

33

Correspondence theorem

Correspondence between HSHR transitions

and big-steps

An injective (at each step) substitution keeps

track of the correspondence between HSHR

nodes and logic programming variables

Page 34: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

34

An example (simpler than Fusion…)

y

C

x

y

C

z

C

x

y

C

x

y

S

xr <w>

r <w>

(w)

C(x,y)←C(x,z),C(z,y)

C(r(x,w),r(y,w))←S(y,w)

Page 35: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

35

Dynamics

x C

C

C

C

C

C

C

CC C

S

S

SS

Page 36: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

36

Dynamics

x C

C

C

C

C

C

C

CC C

S

S

SS

Page 37: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

37

Summary : HSHR vs SLP

Hoare SHR SLP

Graph Goal

Hyperedge Atom

Node Variable

Parallel comp. AND comp.

Action Function sym.

Production Clause

Transition Big-step

Page 38: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

38

Roadmap

Lot of background– Fusion Calculus– Synchronized Hyperedge Replacement– Logic programming

From Fusion Calculus to Hoare SHR From Hoare SHR to logic programming Conclusions

Page 39: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

39

Conclusions

Many relations among the three models– similar underlying structure (e.g. parallel composition)

– name generations ability

– fusions

Distinctive features– Fusion: same structure for system and elementary actions,

interleaving semantics, Milner synchronization, restriction

– HSHR: distributed parallel computations, Hoare synchronization, synchronous execution

– SLP: Hoare synchronization, asynchronous execution engine

Page 40: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

40

Future work

Analyzing different name-handling mechanisms– In π calculus bound names are guarenteed distinct

– Useful for analyzing protocols (nonces, key generation)

Hybrid models– Different synchronizations for Fusion or logic programming

– Process calculi with unification (of terms)

– Logic programming with restriction

Logic programming for implementation purposes– For HSHR systems

– For Fusion Calculus

Page 41: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

41

End of talk

Page 42: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

42

x,y,w,z C(x,w) | C(w,y) | C (y,z) | C(z,x)

A textual notation for graphs

Ring Example

w z

Page 43: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

43

: (A x N* ) (x, a , y) if (x) = (a , y)

Transitions as judgements

Transitions

G1 ,, G2

is the set of new names that are used in synchronization

= {z | x. (x) = (a , y), z , z set(y)}

I contains new internal names

Page 44: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

44

Transitions as judgements

Computations

0 G0 1 G1 … n Gn

1 2 n

x1,…,xn L(x1,…,xn) x1,…,xn , , I G

Productions

Names can be merged (and new names can be added)Identity productions are always available

Transitions are generated from the productions by applying the transition rules for the chosen synchronization model

Page 45: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

45

Textual representation for productions

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)

Page 46: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

46

From SHR to SLP

Page 47: 1 Mapping Fusion and Synchronized Hyperedge Replacement into Logic Programming joint work with Ugo Montanari Ivan Lanese Dipartimento di Informatica Università

47

Structural congruence

Process: agent up to the following laws:– | and + are associative, commutative and with 0 as

unit -conversion– (x)0 = 0, (x)(y)P=(y)(x) P– P|(x)Q=(x)(P|Q) if x not free in P– rec X.P=P[rec X.P/X]