View
217
Download
0
Tags:
Embed Size (px)
Citation preview
Tiling Transactions in Rewriting
LogicRoberto Bruni (Pisa/Illinois)José Meseguer (Illinois)Ugo Montanari (Pisa)
WRLA 2002 Pisa, Italia, 19-21 Sept. 2002
Research supported by• IST-2001-32747 Project AGILE• Italian MIUR Project COMETA• ONR Grant N00014-02-1-0715• CNR Fellowship on Information Sciences and
Technologies
Outline
• Transactions• Zero-Safe Nets (shortly)• A Word on Adjunctions & Coreflections• Zero-Safe Nets as Tiles• Tiling Transactions• Example: Minimal Communication Tree• Conclusions & Future Work
“Mission”
Fully General Notion of Concurrent Transaction
– Graphical Representation– Formal Specification– Refined and Abstract view
• Refinement morphism
– (Distributed Commit)
Transactions: one, no one, one hundred
thousands• In databases:
– a transaction groups actions into a single logical unit which terminates either with a commit or with an abort
• the commit operation permanently applies all the changes to the database, making them visible
• the abort operation cancels all the changes, as they were never executed
– ACID: Atomic, Consistent, Isolated, Durable
• Several variants: – transactions with checkpoints, hierarchical,
timed, long-lived, nested, with compensation
Distributed Transactions
• In “global computing” applications:– data integration and process cooperation
is required across sites and organizations– different platforms, policies, data formats
• Multi-way transactions:– distributed processes start local
transactions, then– they interact by exchanging information
and joining their transactions– they must agree on commit/abort
Theory, Pragmatics & Ethics
• What are the abstract models?– Mathematical description– How do they relate to concrete model?– How to define formal abstraction/refinement
techniques?
• TM Servers can be overloaded– A dedicated machine is necessary (e.g. .NET)– Distribution is important
• When two or more organizations participate in the same transaction, which TM should take control?– Mediator trusted sites– Inter-corporation agreement
Zero-Safe Nets
stable places
zero places
transitions
tokens
Zero-Safe Nets
stable places
zero places
transitions
tokens
copy
Example: Multicasting I
2
Interacting Processes
Administrator
buffer
new send
receive
Disconnected Processes
connect
Parallel composition
receive
receive
Horizontal Composition *
copyreceive
receive
Transaction
copyreceive
receive
send
Example: Multicasting II
Interacting Processes
Administrator
new
1-to-1
Disconnected Processes
connect
2
2
Abstract Net
1-to-2
3
3
1-to-n
n+1
n+1
… …
Main Features of ZS Nets• Graphical Presentation• Formal Theory
– Horizontal states in S
– Vertical states in Z (observations) – Horizontal composition as coordination
• parallel composition on (horizontal) states• sequential composition on observations
• Abstraction / Refinement– Refinement morphism– Abstraction via coreflection
• Concurrent Transactions & Distributed Interpreter• “Portability” under “Orthogonal” Flavors of Nets:
– coloured, reconfigurable, dynamic, probabilistic, timed, with read and inhibitor arcs, with priorities,…
Objects & Messages
• Object & Messages as Places in Coloured Nets
• Rewrites as Transitions• Partitioning stable/zero used to model
participation in transactions (for objects) and transactional messages
• Example: A Day at WRLA2002– Objects: participants, overhead projector,
beamer, microphone, …– Messages: words, gestures, …– Transitions: speaking, moving, changing slides, …– Transactions: presentations, intervals, …– (TM: chair-men, organizers, …)
A Constructive View of Adjunctions
A
B
A Constructive View of Adjunctions
A
B
F
F(A)
A Constructive View of Adjunctions
A
B
F
F(A)
b
What is the best approximation of b?
A Constructive View of Adjunctions
A
B
F
F(A)
b
What is the best approximation of b?
A Constructive View of Adjunctions
A
B
F
F(A)
b
What is the best approximation of b?
Adjunctions: Formally
b
BA
For any bB
Adjunctions: Formally
F(Gb) b
B
Gb
A
We want to find a GbA with approximationb: F(Gb)b Bwhich is universal
b
Adjunctions: Formally
F(Gb) b
B
Gb
A
i.e., any other approximation (via aA)g: F(a)b Bfactorizes uniquely through b
b
F(a)g
a
Adjunctions: Formally
F(Gb) b
B
Gb
A
i.e., ! ĝ: aGb A such thatg = F (ĝ) ; gb
= {b}bB is called the counit
b
F(a)g
a
ĝ F(ĝ)
Duality
A
B
F
F(A)
Duality
A
B
F
F(A)
G
G(B)
Duality
A
B
F
F(A)
G
G(B)
F(Gb’) b’
F(Gb) b
Gb’
Gb
b’
b
Duality
A
B
F
F(A)
G
G(B)
F(Gb’) b’
F(Gb) b
Gb’
Gb
h
b’
b
Duality
A
B
F
F(A)
G
G(B)
F(Gb’) b’
F(Gb)
Gb’
Gb
b ; h
b’
b ; h
Duality
A
B
F
F(A)
G
G(B)
F(GF(a))
F(a)aidF(a)
F(a) F(a)F(a)F(a)
idF(a)
GF(a)
a = idF(a) is called the unit
Adjunctions: Properties
• Left Adjoints (e.g. F) preserve Colimits• Right Adjoints (e.g. G) preserve Limits• (Co)Limits are the categorical way of
expressing operations Adjunctions are Compositional
Interpretations• Typical Scenario:
– B has more structure than A– G is the obvious forgetful functor– F is the best way of adding the extra structure to A
Building Transactions I
ZPetri
HCatZPetri
objects: ZS netsarrows: graph homomorphisms, preserving place partitioning &disjoint image property for zero places
objects: ZS nets whose transitions possess ,*, idarrows: “disjoint” graph homomorphisms, preserving place partitioning and alloperations on transitions
forgets ,*, idZ
Building Transactions II
• Given NZPetri, take Z(N):– arrows from uS to vS are the
concurrent transactions of N– Prime arrows are the basic transactions
of N• from uS to vS
• non decomposable in parallel– e.g., in the multicast example, each basic
transaction contains at most one “sender”
Coreflection
A
B
F
F(A)
G
G(B)
when a: aG(F(a)) isa natural iso
Coreflection
B
A
when a: aG(F(a)) isa natural iso, thenA can be seen as asubcategory of B,with F the inclusion
Coreflection
B
A
when a: aG(F(a)) isa natural iso, thenA can be seen as asubcategory of B,with F the inclusion
• Typical Scenario:– B category of operational models– A category of abstract models– G(b) is the same as b when observed from
A
Abstract Net via Coreflection
ZSN
Petri
objects: ZS netsarrows: refinement morphisms
• A refinement morphism R: N1 N2 – is a zero-safe net morphism R’: N1 Z(N2)– that maps transitions of N1
• either to prime arrows of Z(N2)• or to transitions of N2
AZ
AZ maps ZS nets to their abstract counterpartsthe counit maps transitions to the transactions they represent
N
AZ(N)
N
From Nets to Computads
• Can we generalize the ZS approach?– Meta-theory for transactions
• formal models• fully general notion refinement / abstraction
– Extension of the distributed commit algorithm
• Petri Nets: based on multiset rewriting• Zero-Safe Nets: bidimensional multiset
rewriting– horizontal composition computes transactions– vertical composition builds computations on the
abstract net
• RL & TL seem to be the natural candidates
RL & 2-Computads• Main Ingredients of Rewriting Logic:
– Signature of system configurations– Structural axioms E– Rewrite rules over [t]E
• Categorically (in the initial model):– States form a cartesian category L,E –the Lawvere
Theory associated with (,E)• underlined natural number as objects• substitutions as arrows• composition = substitution application
– Proof terms form a cartesian 2-category
• 2-Computad– Monoidal category of configurations C– Rewrite rules over the arrows of C
Nets as 2-Computads
• S seen as monoidal category– unique object 0– uS seen as an arrow u:00– sequential composition = tensor
product• u;v = uv
• Transitions as rewrites– pre-set = source– post-set = target
RL & TL
• In (Unconditional) RL:– Rewrites : f(x)g(x) can be applied
• in any context C[.]: C[(x)]: C[f(x)] C[g(x)] • with any argument p(y): (p(y)): f(p(y)) g(p(y))
– Horizontal composition is total
• In TL:– Rewrites are coordinated via observations
– applicable in context if C accept the effect of
– applicable with argument p if it provides the trigger
– Horizontal composition is partial
pf
g
C
p f
g
C
TL & D-Computads• Main Ingredients of Tile Logic:
– (H,EH): system configurations
– (V,EV): Observations
– Tiles: : [p]EH [q]EH
• D-Computad– Monoidal category of configurations H– Monoidal category of observations V– Tiles over the arrows of H and C
[u]EV
[v]EV
ZS Nets as D-Computads• S , Z seen as monoidal categories
– unique object 0– uS seen as a configuration u:00– aZ seen as an observation a:00– (SZ) = S Z – sequential composition = tensor product
• u;v = uv• a;b = ab
• Transitions as tiles– stable pre-set = initial configuration (north)– stable post-set = final configuration (south)– zero pre-set = trigger (west)– zero post-set = effect (east)
Tiling Transactions I
ZComp
HCatZComp
objects: D-Computadsarrows: disjoint D-Computads morphisms (on observations: injective on objects, faithful on arrows)
objects: D-Computads whose tiles possess ,*, idarrows: disjoint D-Computad morphisms, preserving all operations on tiles
forgets ,*, idD
Tiling Transactions II
• Given DZComp, take D(D):– cells with indentities as trigger and effect
are the concurrent transactions of D– Elementary cells are the basic
transactions of D• trigger is an identity• effect is an identity• minimal
– non decomposable in parallel– non decomposable sequentially– without unnecessary idle configurations
Tiling Transactions III
ZComp
HCatZComp
forgets ,*, idD
ZPetri
HCatZPetri
D recovers Z
Abstraction via Coreflection I
Rcomp
2Comp
objects: D-Computadsarrows: refinement morphisms
• A refinement morphism M: D1 D2
– is a disjoint D-Computad morphism M’: D1 D(D2)
– that maps tiles of D1
• either to elementary elements of D(D2)
• or to tiles of D2
Ad
Ad maps D-Computads to their abstract 2-Computadsthe counit maps rewrite rules to the transactions they represent
D
Ad(D)
D
Abstraction via Coreflection II
Rcomp
2Comp
Ad
Petri
ZSN
Ad recovers AZ
Example: CCS-like PCP ::= 0 | .P | P|P
P
act
.P
id lpar
P|Q
id
P’|Q
rpar
P|Q
id
P|Q’
com
P|Q
id
P’|Q’
action prefix is frozen
Example: a Tile Transaction
0
act
a.0
aid
a.0
rpar
_|_
aida
_|_
_|_
P1
lpar
_|_
aaid
_|_
_|_
P2
com
_|_
idaa
_|__|_
0
act
a.0
aid
a.0
(X1|a.0)|(a.0|X2)
(X1|0)|(0|X2)
id
id
idid
id
id
id
idid
id
Abstract Communications
_|_
_|_ _|_
_|__|_
P3P2
_|_ _|_
P4 P5 P6 P7 P8P1
Abstract Communications
_|_
_|_ _|_
_|__|_
P3P2
_|_ _|_
P4 P5 P6 P7 P8P1
Abstract Communications
_|_
_|_ _|_
_|__|_
P3P2
_|_ _|_
P4 P5 P6 P7 P8P1
Abstract Communications
_|_
_|_ _|_
_|__|_
P3P2
_|_ _|_
P4 P5 P6 P7 P8P1
Abstract Communications
_|_
_|_ _|_
_|__|_
P3P2
_|_ _|_
P4 P5 P6 P7 P8P1
Abstract Communications
_|_
_|_ _|_
_|_X1
a.X2
X4 _|_
X3 a.X5 X6
Each time, we want toconsider just themost general “context”,which is essential to the interaction
(X1|(a.X2|X3))|(X4|(a.X5|X6))
(X1|(X2|X3))|(X4|(X5|X6))
Abstract Communications
_|_
_|_ _|_
_|_X1
a.X2
X4
X3
a.X5
(X1|(a.X2|X3))|(X4|a.X5)
(X1|(X2|X3))|(X4|X5)
OK
Abstract Communications
_|_
_|_ _|_
a.X2X1 _|_
(X1|a.X2)|(X3|(X4|a.X5))
(X1|X2)|(X3|(X4|X5))
OK
X4 a.X5
X3
Abstract Communications
_|_
_|_ _|_
a.X2X1 _|_ a.X5
(X1|a.X2)|((X3|X4)|a.X5)
(X1|X2)|((X3|X4)|X5)
NO!
X3 X4
Abstract Communications
_|_
_|_ _|_
a.X2X1 _|_ a.X4
Concurrent rewrites
b.Y1 b.Y2
Conclusions & Future Work
• We have fully generalized the ZS approach– Refinement morphisms between Tiles– Abstract Rewrite Theory (aka 2-
computad)– “Compositional” specification of
transactions• To investigate:
– Connection with conditional RL
Tiling Transactions in RL
a paper by Roberto Bruni José Meseguer Ugo Montanari
a WRLA presentation by Roberto Bruni
Research supported byIST-2001-32747 Project AGILEItalian MIUR Project COMETAONR Grant N00014-02-1-0715CNR Fellowship on Inf. Sci. and Techn.
Electronic watercolor by Roberto Bruni