An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory...

48
An introduction to the wire calculus Pawel Sobocinski Southampton, 06/05/09

Transcript of An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory...

Page 1: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

An introduction to the wire calculus

Pawel Sobocinski

Southampton, 06/05/09

Page 2: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Process algebra• R. Milner (CCS, pi, ...)

• syntax-directed SOS

• bisimilarity as extensional congruence

• R.F.C. Walters (Span(Graph), ...)

• operations of monoidal categories ⤳ formal graphical representation

• internal state & dynamics important

• Wire calculus combines these features

Page 3: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Motivating example: 3 party synch

F0 F0F1

Page 4: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Motivating example: 3 party synch

F0 F0F1

(0set0)F0

0−→0

F0

(0set1)F0

1−→0

F1

(0Refl)F0

ι−→ι

F0

(1set1)F1

1−→1

F1

(1set0)F1

0−→1

F0

(1Refl)F1

ι−→ι

F1

ι

=no signal

Page 5: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Motivating example: 3 party synch

F0 F0F1

(0set0)F0

0−→0

F0

(0set1)F0

1−→0

F1

(0Refl)F0

ι−→ι

F0

(1set1)F1

1−→1

F1

(1set0)F1

0−→1

F0

(1Refl)F1

ι−→ι

F1

ι

=no signal

d ; I ⊗ (F0 ; F1 ; F0) ; e

Page 6: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Motivating example: 3 party synch

F0 F0F1

(0set0)F0

0−→0

F0

(0set1)F0

1−→0

F1

(0Refl)F0

ι−→ι

F0

(1set1)F1

1−→1

F1

(1set0)F1

0−→1

F0

(1Refl)F1

ι−→ι

F1

ι

=no signal

d ; I ⊗ (F0 ; F1 ; F0) ; e

coordination

Page 7: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Motivating example: 3 party synch

F0 F0F1

(0set0)F0

0−→0

F0

(0set1)F0

1−→0

F1

(0Refl)F0

ι−→ι

F0

(1set1)F1

1−→1

F1

(1set0)F1

0−→1

F0

(1Refl)F1

ι−→ι

F1

ι

=no signal

d ; I ⊗ (F0 ; F1 ; F0) ; e

coordination

dynamics

Page 8: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Plan of talk

• Coordination aspects

• Dynamic aspects

• Example - Petri nets

• Buffers & asynchrony

Page 9: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Components

• Let Σ be a set of signals

• for a -transition is a labelled transition of the form

• A -component is a reflexive & transitive LTS of -transitions with chosen node

• graphically:{ }k l...

...P

k, l ∈ N (k, l)

P�a−→�b

Q, #(�a) = k, #(�b) = l

(k, l)(k, l) P

Page 10: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Simulation & bisimulation

• Q. When are two components and indistinguishable by an external observer?

• Simulation: Relation s.t. if and

• Bisimulation: A simulation such that is also a simulation

• A. There exists a bisimulation that contains

R

S (v, w) ∈ S

v �a−→�b v� then ∃w�. w �a−→�b w� and (v�, w�) ∈ S

P Q

R−1

R(P,Q)

Page 11: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Reflexive & transitive LTSs: Iota rules

P�ι−→�ι R R

�a−→�b Q(ιL)

P�a−→�b Q

(Refl)P

�ι−→�ι P

P�a−→�b R R

�ι−→�ι Q(ιR)

P�a−→�b Q

consequence: “weak” and “strong” bisimilarities coincide

F0 F1

F0 F0F1

reason: avoid unwantedsynchronisation

on “common clock”

Page 12: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Wire constants• another name for one state components

• will give wire calculus expressions later

Picture SemanticsSymbol

I : (1, 1)

(d)d−→aa d

(e)e

aa−→ e

d : (0, 2)

e : (2, 0)

(Id)I

a−→a I

Page 13: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Connecting wires & components

Γ � P : (k, n) Γ � Q : (n, l)

Γ � P ;Q : (k, l)

Γ � P : (k, l) Γ � Q : (m, n)

Γ � P⊗Q : (km, ln)

......

......

P

Q

k l

nm...

......P Q

k ln

P�a−→�c Q R

�c−→�b S(Cut)

P ;Ra−→b Q;S

P�a−→�b Q R

�c−→�d S(Ten)

P⊗R�a�c−→�b�d

Q⊗S

Page 14: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Some simple bisimilarities(P ; Q) ; R ∼ P ; (Q ; R)

∀P : (m,n), P ; (�

n I) ∼ P ∼ (�

m I) ; P

......P...

...P......P ∼ ∼

(P ⊗R) ; (Q⊗ S) ∼ (P ; Q)⊗ (R ; S)(P ⊗Q)⊗R ∼ P ⊗ (Q⊗R)

......

...P Q

......

...R S

wire calculus terms up to ~ are arrows of monoidal cat.

∼ ∼

(η ⊗ I) ; (I ⊗ �) ∼ I ∼ (I ⊗ η) ; (�⊗ I)

Page 15: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Congruence theorem

P ⊗Q ∼ P � ⊗Q Q⊗ P ∼ Q⊗ P �

P ; R ∼ P � ; R S ; P ∼ S ; P �

then:

P, P � : (k, l) Q : (m, n) R : (l, l�) S : (k�, k)

P ∼ P �

......P ∼ ...

...P �

......P

......Q

......P �

......Q

∼...

...Q

......P

......Q

......P �

......R... P ...

...R... P �∼ ......

... PS ......

... P �S∼

Page 16: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Dynamics

syntax-directed SOS, so:

F0 F0F1d ; I ⊗ (F0 ; F1 ; F0) ; e

Page 17: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Dynamics

syntax-directed SOS, so:

F0 F0F1d ; I ⊗ (F0 ; F1 ; F0) ; e

y = 1z = 0Y = 0

F0x−→z X F1

z−→y Y(Cut)

F0;F1x−→y X;Y

Page 18: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Dynamics

syntax-directed SOS, so:

F0 F0F1d ; I ⊗ (F0 ; F1 ; F0) ; e

y = 1z = 0Y = 0

F0x−→z X F1

z−→y Y(Cut)

F0;F1x−→y X;Y

F0x−→0 X F1

0−→1 F0(Cut)

F0;F1x−→1 X;F0

Page 19: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Dynamics

syntax-directed SOS, so:

F0 F0F1d ; I ⊗ (F0 ; F1 ; F0) ; e

y = 1z = 0Y = 0

F0x−→z X F1

z−→y Y(Cut)

F0;F1x−→y X;Y

F0x−→0 X F1

0−→1 F0(Cut)

F0;F1x−→1 X;F0

F0;F1x−→1 X;F0 F0

1−→0 F1(Cut)

F0;F1;F0x−→0 X;F0;F1

Page 20: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Dynamics

syntax-directed SOS, so:

F0 F0F1d ; I ⊗ (F0 ; F1 ; F0) ; e

y = 1z = 0Y = 0

F0x−→z X F1

z−→y Y(Cut)

F0;F1x−→y X;Y

F0x−→0 X F1

0−→1 F0(Cut)

F0;F1x−→1 X;F0

F0;F1x−→1 X;F0 F0

1−→0 F1(Cut)

F0;F1;F0x−→0 X;F0;F1

(⊗)I⊗(F0;F1;F0)

wx−−→w0 I⊗(X;F0;F1)

Page 21: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Dynamics

syntax-directed SOS, so:

F0 F0F1d ; I ⊗ (F0 ; F1 ; F0) ; e

y = 1z = 0Y = 0

F0x−→z X F1

z−→y Y(Cut)

F0;F1x−→y X;Y

F0x−→0 X F1

0−→1 F0(Cut)

F0;F1x−→1 X;F0

F0;F1x−→1 X;F0 F0

1−→0 F1(Cut)

F0;F1;F0x−→0 X;F0;F1

(⊗)I⊗(F0;F1;F0)

wx−−→w0 I⊗(X;F0;F1)

(Cut)(I⊗(F0;F1;F0));e

0x−→ I⊗(X;F0;F1);e

Page 22: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Dynamics

syntax-directed SOS, so:

F0 F0F1d ; I ⊗ (F0 ; F1 ; F0) ; e

y = 1z = 0Y = 0

F0x−→z X F1

z−→y Y(Cut)

F0;F1x−→y X;Y

F0x−→0 X F1

0−→1 F0(Cut)

F0;F1x−→1 X;F0

F0;F1x−→1 X;F0 F0

1−→0 F1(Cut)

F0;F1;F0x−→0 X;F0;F1

(⊗)I⊗(F0;F1;F0)

wx−−→w0 I⊗(X;F0;F1)

(Cut)(I⊗(F0;F1;F0));e

0x−→ I⊗(X;F0;F1);e

(Cut)d;(I⊗(F0;F1;F0));e−→ d;I⊗(F0;F0;F1);e

Page 23: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Flip flops - another example

Using reflexivity, a step of the system is one of:1. step of the upper component2. step of the lower component3. concurrent step (“true” concurrency!)

F0 F1

F0 F0F1

(d⊗ d) ; (I ⊗ F0 ⊗ I ⊗ F0) ; (I ⊗ F1 ⊗ I ⊗ F1) ; (e⊗ I ⊗ F0) ; e

Page 24: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Plan of talk

• Coordination aspects

• Dynamics aspects

• Example - Petri nets

• Buffers & asynchrony

Page 25: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Prefix

• like input prefix in value-passing CCS

• simple pattern matching

uv [ϕ]:(k, l) Γ � P : (k, l)

Γ � uv [ϕ]P : (k, l)x - set of signal variables

u, v ∈ x∗ #u = k #v = l vars in and are bound in .u v P

uv [ϕ] : (k, l)

- set of constraints on varsϕ

Page 26: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Prefix, ctd.

01P x

y [x = 0, y = 1]Pdef=

Useful abbreviations:

x�=ax Y

def= xx [x �= a]P

�ϕ|σ(Pref)

uv [ϕ]P

u|σ−−→v|σP |σ

- function that satisfies .

σ : x→ Σ� ϕ|σϕ

Page 27: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

RecursionP [µY. P/Y ]

a−→b Q(Rec)

µY. Pa−→b Q

Γ,Y � P : (k, l)

Γ � µY. P : (k, l)

• standard

Examples - basic wiresI

def= µY. xxY

(d)d−→aa d

(e)e

aa−→ e

(Id)I

a−→a I

ddef= µY. xxY

edef= µY. xxY

Page 28: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Choice

• Similar to CSP choice

Γ � P : (k, l) Γ � Q : (k, l)

Γ � P+Q : (k, l)

P�a−→�b Q ( �ab �=�ι)

(+L)P+R

�a−→�b Q

P�a−→�b Q ( �ab �=�ι)

(+R)R+P

�a−→�b Q

P�ι−→�ι Q R

�ι−→�ι S(+ι)

P+R�ι−→�ι Q+S

Page 29: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Example - flip flops

(0set0)F0

0−→0

F0

(0set1)F0

1−→0

F1

(0Refl)F0

ι−→ι

F0

(1set1)F1

1−→1

F1

(1set0)F1

0−→1

F0

(1Refl)F1

ι−→ι

F1

F0def= µY. 0

0Y + 10µZ. ( 1

1Z + 01Y )

F1def= µZ. 1

1Z + 01µY. ( 0

0Y + 10Z)

Page 30: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Bisimilarity & dynamics

then:

P, Q, R : (k, l)

P ∼ Q

uv [ϕ]P ∼ u

v [ϕ]Q

P + R ∼ Q + R

R + P ∼ R + Q

Page 31: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Summary

P�ι−→�ι R R

�a−→�b Q(ιL)

P�a−→�b Q

(Refl)P

�ι−→�ι P

P�a−→�b R R

�ι−→�ι Q(ιR)

P�a−→�b Q

P�a−→�c Q R

�c−→�b S(Cut)

P ;Ra−→b Q;S

P�a−→�b Q R

�c−→�d S(Ten)

P⊗R�a�c−→�b�d

Q⊗S

P [µY. P/Y ]a−→b Q

(Rec)µY. P

a−→b Q

P�ι−→�ι Q R

�ι−→�ι S(+ι)

P+R�a−→�b Q+S

P�a−→�b Q ( �ab �=�ι)

(+L)P+R

�a−→�b Q

P�a−→�b Q ( �ab �=�ι)

(+R)R+P

�a−→�b Q

�ϕ|σ(Pref)

uv [ϕ]P

u|σ−−→v|σP |σ

P ::= x | Y | P ; P | P ⊗ P | uv [ϕ]P | P + P | µY. P

Page 32: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Plan of talk

• Coordination aspects

• Dynamics aspects

• Example - Petri nets

• Buffers & asynchrony

Page 33: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Example 2 - Petri nets

• to handle Petri nets, we will need to build up our library of wire constants

• this time, we will express them using the operators for dynamics

• we also provide SOS characterisations

Page 34: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Petri net conditions

� def= µY. •ι

ι•Y �• def= ι

•�

�•�

• will be modelled using the following (1,1) terms:

• events will be modelled by appropriate wiring

Page 35: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Events• possibly have several pre/post conditions

• need diagonals and codiagonals

∆def= µY. x

xxY(∆)

∆a−→aa ∆

∆def= µY. xxx Y

(

)∆aa−→a

⊥⊥⊥ def= µY. xY

��� def= µY. xY(���)

���−→a ���

(⊥⊥⊥)⊥⊥⊥

a−→ ⊥⊥⊥

Page 36: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Bisimulations

Page 37: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Example

��

�•

Page 38: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Conditions• possibly have several in/out events

• need linear diagonals and codiagonals

(ΛL)Λ

a−→aι Λ

(VL)V

aι−→a V

Λdef= µY. x

xιY + xιxY

Vdef= µY. xι

x Y + ιxx Y

(↓↓↓)↓↓↓

ι−→ ↓↓↓

(↑↑↑)↑↑↑−→ι ↑↑↑

↓↓↓ : (1, 0) def= µY. Y

↑↑↑ : (0, 1) def= µY. Y

Page 39: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Bisimulations

Page 40: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Example

Page 41: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Full abstraction

Me−→M � �M� −→ �M ��

�M� −→ P

∃M �. �M �� = P & (M � = M ∨ ∃e1, . . . , em.e1−→ · · · em−−→ M �)

Page 42: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Plan of talk

• Coordination aspects

• Dynamics aspects

• Example - Petri nets

• Buffers & asynchrony

Page 43: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Interleaving parallel operator

• commutative & associative

X | Ydef= Λ ; (X ⊗ Y ) ; V

X

Y

X

Y

“CCS-like” parallelFeedback

nb: associativity holds, but is not trivial to prove

Consequence of construction:preserves bisimilarity

fb(P )def= (d⊗V);(I⊗P );(e⊗Λ)

P

Page 44: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Buffers & Queues• Unordered unbounded output buffer

def=B1

def= xι

ιx0

B def= µY.B1 | YB

B1

B

• Queue

C[X]ι−→ι C[X]

σ∈Σ

C[X]σ−→ι C[X+σ] C[X+σ]

ι−→σ C[X]

Q def= µY. xι (Y ; ι

xI)

Page 45: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Lemma

• (cf. Selinger 1997)

B ; B ∼ B

Q ; Q ∼ Q

Q ; B ∼ B

Page 46: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Asynchronous comm.

• Can be modelled by putting an output buffer on a wire

• Different kinds of asynchrony can be studied (queues vs buffers)

• Asynchronous and synchronous communication can co-exist in the same system

Page 47: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Related work (lots!)• Milner - CCS

• Gadducci Montanari - Tile systems

• Laneve Montanari - Connectors

• R.F.C. Walters et. al. - Span(Graph)

• Interaction categories (Abramsky)

• SOS Formats

• Coordination languages, glue operators (Siafikis, Bliudze), REO

Page 48: An introduction to the wire calculusps1a06/talks/Southampton.pdf · Conclusions • category theory for the process algebraist! • formal graphical notation • “weak” bisimulation

Conclusions• category theory for the process algebraist!

• formal graphical notation

• “weak” bisimulation does not exist -- there is only one kind of bisimilarity

• combining dynamics & coordination allows dynamic changes to wiring

• model systems with several communication paradigms