Coalgebraic Weak Bisimulation from Recursive Equations over

Transcription

Coalgebraic Weak Bisimulation from Recursive Equations over
Coalgebraic Weak Bisimulation from
Recursive Equations over Monads
Sergey Goncharov, Dirk Pattinson
Oberseminar, 10. Dezember 2014
FAU Erlangen-Nürnberg, Informatik 8
A Ridiculously Simple Example
Interaction of a computer scientist (CS) and a coffee machine (CM):
CS = coin.coffee.pub.CS
CM = coin.(coffee.CM + tea.CM)
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
2
A Ridiculously Simple Example
Interaction of a computer scientist (CS) and a coffee machine (CM):
CS = coin.coffee.pub.CS
CM = coin.(coffee.CM + tea.CM)
System S = (CS | CM)\coin\coffee satisfies the equation:
S = τ.τ.pub.S.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
3
A Ridiculously Simple Example
System S = (CS | CM)\coin\coffee satisfies the equation:
S = τ.τ.pub.S.
We could formalize that the computer scientist is productive as
νγ. hτihτihpubiγ.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
4
A Ridiculously Simple Example
We could formalize that the computer scientist is productive as
νγ. hτihτihpubiγ.
Or, better: νγ. hhpubiiγ where
hhaiiφ = hhiihhaiihhiiφ
hhiiφ = µγ. (φ ∨ hτi]γ)
[[a]]φ = [[ ]][[a]][[ ]]φ
[[ ]]φ = νγ. (φ ∧ [τ]γ).
However, this trick does not work with probabilistic systems.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
5
Strong Bisimulation, Coalgebraically
a
Given an LTS (X, −
→), R is a strong bisimulation (equivalence) if
x
R
y
x
and
a
y
a
x0
Oberseminar, 10. Dezember 2014
8 |
R
x0
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
6
Strong Bisimulation, Coalgebraically
a
Given an LTS (X, −
→), R is a strong bisimulation (equivalence) if
x
R
y
a
x
a
x0
|
Sergey Goncharov, Dirk Pattinson
y
a
y0
R
Oberseminar, 10. Dezember 2014
8 |
and
R
a
x0
|
R
FAU Erlangen-Nürnberg, Informatik
y0
7
Strong Bisimulation, Coalgebraically
a
Given an LTS (X, −
→), R is a strong bisimulation (equivalence) if
x
R
y
a
x
a
x0
and
y
a
y0
R
R
a
x0
R
y0
Coalgebraic approach:
• replace LTS with a coalgebra, i.e. a map f : X → FX with
FX = P(X × A)
• identify equivalences E on X with projections π : X → (X × X)/E
• then R is recovered a the kernel of some F-coalgebra morphism
g : Z → FZ. Thus we obtain kernel bisimulation
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
8
Kernel Bisimulation
Kernel bisimulation is a robust device:
• works uniformly for a diversity of systems: automata, probabilistic,
stohastic, graded, etc.
• has a proof-theoretic characterization — coinduction
• has a modal characterization — coalgebraic modal logic
• has a relational characterization — Aczel-Mendler(-style) bisimulation
(under weak pullback preservation).
• yeilds final semantics, as the unique morphism to final coalgebra νF.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
9
Kernel Bisimulation
Kernel bisimulation is a robust device:
• works uniformly for a diversity of systems: automata, probabilistic,
stohastic, graded, etc.
• has a proof-theoretic characterization — coinduction
• has a modal characterization — coalgebraic modal logic
• has a relational characterization — Aczel-Mendler(-style) bisimulation
(under weak pullback preservation).
• yeilds final semantics, as the unique morphism to final coalgebra νF.
But, in concurrency strong bisimulation is only an auxiliary notion.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
10
Weak Bisimulation: Why?
Rule for paralell composition:
a
P−
→ P0
a
Q−
→ Q0
τ
P | Q −−→ P 0 | Q 0
Hence R is a weak bisimulation if
x
y
R
x
∗
τ
y
τ
x
τ∗
x0
•
a
R
R
y0
x
τ∗
y0
Oberseminar, 10. Dezember 2014
8 |
R
y
τ∗
R
Sergey Goncharov, Dirk Pattinson
y0
|
y0
•
τ
x0
|
a
a
•
R
y
•
a
x0
R
τ∗
τ∗
R
x0
FAU Erlangen-Nürnberg, Informatik
11
Weak Bisimulation: Why?
Internal action
Rule for paralell composition:
a
P−
→ P0
a
Q−
→ Q0
τ
P | Q −−→ P 0 | Q 0
Hence R is a weak bisimulation if
x
y
R
x
∗
τ
y
τ
x
τ∗
x0
•
a
R
R
y0
x
τ∗
y0
Oberseminar, 10. Dezember 2014
8 |
R
y
τ∗
R
Sergey Goncharov, Dirk Pattinson
y0
|
y0
•
τ
x0
|
a
a
•
R
y
•
a
x0
R
τ∗
τ∗
R
x0
FAU Erlangen-Nürnberg, Informatik
12
Delay Bisimulation
Alternatively, R is a delay bisimulation if
x
y
R
x
∗
τ
R
y0
Oberseminar, 10. Dezember 2014
8 |
y
y0
|
y
•
τ∗
R
Sergey Goncharov, Dirk Pattinson
R
τ∗
R
x
|
x
R
a
x0
y
x0
•
a
τ∗
R
a
a
x0
R
FAU Erlangen-Nürnberg, Informatik
y0
13
Weak Transitions and Partial Observations
a
a
Milner’s weak transition construction: From (X, −
→) switch to (X, =
⇒)
where
a
=
⇒
τ
=
⇒
is
is
τ ∗
a
τ ∗
(a 6= τ)
→
− −
→→
−
τ ∗
→
−
a
a
Weak bisimulation for (X, −
→) is strong bisimulation for (X, =
⇒).
a
τ
The observable =
⇒ is constructed out of partial observables →
− and
a
−
→. This can be understood a coalgebra B → 2 × BA, equivelently
o:B→2
(acceptance)
−/− : B × A → B
(evolution)
We call B an observation pattern.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
14
Observation Patterns
Any observation pattern is a subcoalgebra of the final coalgebra
∼ P(A∗)
νγ. (2 × γA) =
E.g. for weak bisimulation B = {0/ , τ∗, τ∗aτ∗},
o(s) = 1 ⇐⇒ s = τ∗
0/ /a = 0/
τ∗aτ∗/τ = τ∗aτ∗
/
τ∗ / a = 0
/ (a 6= b)
τ∗aτ∗/b = 0
τ∗/τ = τ∗
τ∗aτ∗/a = τ∗
Analogously,
• B = {0/ , τ∗, τ∗a} for delay bisimulation
• B = {0/ , {}, {a}} for strong bisimulation
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
15
Probabilistic Weak Bisimulation: The Problem
Milner’s construction fails at probabilistic systems.
τ(0.5)
a(0.5)
b(0.5)
s2
s1
a(0.5)
b(1.0)
s4
s3
s5
a
• The probability of weak transition s1 =
⇒ s2 is not
0.5 + 0.52 + · · · = 1.
• R = ∆ ∪ {hs2, s4i, hs3, s5i} is a weak bisimulation.
Moral: point-to-set transitions are irreducible to point-to-point ones.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
16
Probabilistic Weak Bisimulation: The Solution
Let P∗(x, Λ, S) be the total probability of the move from x ∈ X to
S ⊆ X via Λ ⊆ A∗.
Definition [BaierHermanns97]. R ⊆ X × X is a probabilistic
bisimulation equivalence if xRy implies
P∗(x, τ∗aτ∗, S) = P∗(y, τ∗aτ∗, S)
(a 6= τ)
P∗(x, τ∗, S) = P∗(y, τ∗, S)
for any R-equivalence class S.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
17
How to Calculate Total Probabilities?
Approach from [BaierHermanns97]:
• Consider a set-algebra of path-cones generated by finite paths.
• Complete it to a σ-algebra.
• Extend probabilistic measure using a Caratheodory-style theorem.
Our approach: Solve recursive system
P∗(x, Λ, S) = 1
∗
P (x, Λ, S) =
X
(x ∈ S and ∈ Λ)
P(x, a, y) · P∗(y, Λ/a, S)
a,y
Equivalently,
X
1 if x ∈ S and ∈ Λ
P (x, Λ, S) =
t
P(x, a, y) · P∗(y, Λ/a, S)
0 otherwise
a,y
∗
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
18
From Total Probabilities to Total Multiplicities
a
a
For graded systems, P −
→ Q + Q is not the same as P −
→ Q.
a(n)
Hence, one uses weighted transitions P −−→ Q.
Following the ideas from [CorradiniNicolaEtAl99] “total multiplicities”
M∗(x, Λ, S) must mesure the degree of nondeterminism.
Surprisingly, the same formula is suitable for M∗:
X
if x ∈ S and ∈ Λ
t
M(x, a, y) · M∗(y, Λ/a, S)
otherwise
a,y
1
M ( x, Λ , S ) =
0
∗
τ
E.g.
s1
a
Oberseminar, 10. Dezember 2014
8 |
s2
|
M∗(s1, τ∗aτ∗, {s1, s2}) = 1
M∗(s2, τ∗bτ∗, {s2, s3}) = ∞
b
Sergey Goncharov, Dirk Pattinson
s3
|
FAU Erlangen-Nürnberg, Informatik
19
The General Case
LTS, graded and probabilistic systems are coalgebras of type
f : X → T(X × A)
where T is a completely ordered monad
(≈ T is a monad + TX is a ω-cpo with ⊥).
Main Definition:
fhB(x)(b) =
η(h(x))
⊥
if o(b)
otherwise
⊕
do hy, ai ← f (x); fhB(y)(b/a)
Then R ⊆ X × X is a B-⊕-bisimulation equivalence on f if R ⊆ ker fπB
where π is the projection X → R/X.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
20
The General Case
continuous operation T2 → T
LTS, graded and probabilistic systems are coalgebras of type
observation pattern
f : X → T(X × A)
where T is a completely ordered monad
(≈ T is a monad + TX is a ω-cpo with ⊥).
Main Definition:
B
fh (x)(b) =
η(h(x))
⊥
if o(b)
otherwise
⊕
do hy, ai ← f (x); fhB(y)(b/a)
Then R ⊆ X × X is a B-⊕-bisimulation equivalence on f if R ⊆ ker fπB
where π is the projection X → R/X.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
21
Probability and Nondeterminism
The mixture of probability and nondeterminsm is modelled by
(simple) Segala systems.
The corresponding monad is a monad of convex sets of valuations
[Jacobs08,Brengos13].
Our definition unravels as follows (and agrees with [Segala94]):
τ
x=
⇒ δx
a
x=
⇒ζ
iff
∃ξ ∈ f (x). ζ ∈

X

y∈ X


b
a
ξ(y, a) · θy + ξ(y, τ) · θy ∀y. y =
⇒ θby

τ
where =
⇒ ∈ X × B × [0, ∞)X.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
22
Killing τ with a Dagger?
Recall that a complete Elgot monad is a monad with an operator ---†:
f ∈ Hom(A, T(B + A))
f † ∈ Hom(A, TB))
7→
(satisfying suitable laws)
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
23
Killing τ with a Dagger?
Recall that a complete Elgot monad is a monad with an operator ---†:
f ∈ Hom(A, T(B + A))
f † ∈ Hom(A, TB))
7→
(satisfying suitable laws)
Roughly, this allows as to solve excursive equations like
f (x) = do z ← toss; case z of inl ? 7→ p; inr ? 7→ f (q),
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
24
Killing τ with a Dagger?
Recall that a complete Elgot monad is a monad with an operator ---†:
f ∈ Hom(A, T(B + A))
f † ∈ Hom(A, TB))
7→
(satisfying suitable laws)
Roughly, this allows as to solve excursive equations like
f (x) = do z ← toss; case z of inl ? 7→ p; inr ? 7→ f (q),
equivalently,
f (x) = p ⊕ f (q),
with algebraic ⊕.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
25
Killing τ with a Dagger?
Recall that a complete Elgot monad is a monad with an operator ---†:
f ∈ Hom(A, T(B + A))
f † ∈ Hom(A, TB))
7→
(satisfying suitable laws)
Roughly, this allows as to solve excursive equations like
f (x) = do z ← toss; case z of inl ? 7→ p; inr ? 7→ f (q),
equivalently,
f (x) = p ⊕ f (q),
with algebraic ⊕. However, t is generally not algebraic, e.g. for
probabilistic systems:
do x ← (p t q); r 6= (do x ← p; r ) t (do x ← q; r ).
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
26
Algebraic Operations
An operation ⊕ : T2 → T is algebraic if it distributes over sequential
composition
do x ← p ⊕ q; r = (do x ← p; r ) ⊕ (do x ← q; r ).
Examples: set union is algebraic for LTS and Segala systems.
Nonexample: join for probabilistic and weighted systems.
algebraicity ⇒ continuity
Theorem: If ⊕ is algebraic then E is a B-bisimulation equivalence for
f iff E is a strong bisimulation for fidB.
Bottom line: Weak transition construction works for LTS and Segala
system, but not for probabilistic and graded systems!
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
27
A (Somewhat) Alternative Approach
The approach from [Tomasz Brengos, Marino Miculan, Marco Peressotti,
Behavioural equivalences for coalgebras with unobservable moves]:
∼ X × Aτ )
• Start from f : X → T(FX + X) (e.g. with FX + X =
where F distributes over T via some δ : FT → TF;
∼ 1);
• Equip T(FX + X) with a monad structure (assuming that T 0/ =
• Solve recursive equation g = h t g · f in the Kleisli category of
M = T(F + Id) where h : X → Y is the weak bisimulation in question
(assuming that T is ωCpo-enriched and has t).
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
28
A (Somewhat) Alternative Approach
∼ A+1
Aτ =
The approach from [Tomasz Brengos, Marino Miculan, Marco Peressotti,
Behavioural equivalences for coalgebras with unobservable moves]:
∼ X × Aτ )
• Start from f : X → T(FX + X) (e.g. with FX + X =
where F distributes over T via some δ : FT → TF;
∼ 1);
• Equip T(FX + X) with a monad structure (assuming that T 0/ =
• Solve recursive equation g = h t g · f in the Kleisli category of
M = T(F + Id) where h : X → Y is the weak bisimulation in question
(assuming that T is ωCpo-enriched and has t).
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
29
A (Somewhat) Alternative Approach
∼ A+1
Aτ =
The approach from [Tomasz Brengos, Marino Miculan, Marco Peressotti,
Behavioural equivalences for coalgebras with unobservable moves]:
∼ X × Aτ )
• Start from f : X → T(FX + X) (e.g. with FX + X =
where F distributes over T via some δ : FT → TF;
∼ 1);
• Equip T(FX + X) with a monad structure (assuming that T 0/ =
• Solve recursive equation g = h t g · f in the Kleisli category of
M = T(F + Id) where h : X → Y is the weak bisimulation in question
(assuming that T is ωCpo-enriched and has t).
Pro: Slick main definition, higher generality.
Con: Geared to the idea of saturation (i.e. aggregation of transitions
into τ∗aτ∗-sequences) — not observation; e.g. not suitable for delay
bisimulation.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
30
Further Generalization
• Let f : X → TFX be a coalgebra (e.g. FX = X × A);
• Let G a functor distributing over T (e.g. GX = X × B);
• Let, additionally, ∂ : GF → TG and σ : G → T be two natural
transformations (e.g. ∂(x, a, b) = η(x, b/a), σ(x, b) = η(x, o(b))).
In particular, G lifts to CT and ∂, σ lift to ∂ : GF → G and σ : G → Id.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
31
Further Generalization
• Let f : X → TFX be a coalgebra (e.g. FX = X × A);
• Let G a functor distributing over T (e.g. GX = X × B);
• Let, additionally, ∂ : GF → TG and σ : G → T be two natural
transformations (e.g. ∂(x, a, b) = η(x, b/a), σ(x, b) = η(x, o(b))).
In particular, G lifts to CT and ∂, σ lift to ∂ : GF → G and σ : G → Id.
id ×δ
hσ,Gf i
id ×∂∗
g : GX −−−→ TX × GTFX −−→ TX × TGFX −−−→ TX × TGX
For any h : X → Y let f∂h,σ : GX → TX be the least solution of
f∂h,σ = Th ⊕ (f∂h,σ)∗ · g
and R ⊆ X × X is a ∂-σ-⊕-bisimulation equivalence if R ⊆ ker f∂π,σ
with canonical π : X → R/X.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
32
Further Generalization
Let f : X → TFX, ∂ : GF → TG and σ : G → T.
In particular, G lifts to CT and ∂, σ lift to ∂ : GF → G and σ : G → Id.
id ×δ
hσ,Gf i
id ×∂∗
g : GX −−−→ TX × GTFX −−→ TX × TGFX −−−→ TX × TGX
For any h : X → Y let f∂h,σ : GX → TX be the least solution of
f∂h,σ = Th ⊕ (f∂h,σ)∗ · g
and R ⊆ X × X is a ∂-σ-⊕-bisimulation equivalence if R ⊆ ker f∂π,σ
with canonical π : X → R/X.
• This covers the previous treatment with FX = X × A, GX = X × B;
• It also covers trace equivalence with FX = X × A + 1, B = A∗,
∂(inl(x, a), s) = η(x, s/a), σ(inr ?, ) = ⊥, σ(inr ?, s) = η(x) (s 6= ).
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
33
Weak Bisimulation from Strong Bisumulation
Unless ⊕ is algebraic w/b does not reduce to s/b of the same type.
But it can (always?) reduce to a s/b of a different type!
Theorem: Assume
b an injective monad morphism,
• κ : T → T,
b , a lifting of ⊕ : T2 → T along κ.
• an algebraic operation ⊕
Then E is a B-⊕-equivalence on (X, f ) iff E is a strong equivalence
on (X, (κf )idB ).
c
Example: κ : T → (Id → T1) →
− T1 is a monad morphism to a
c
submonad of continuation monad (→
− denotes the function space of
continuous functions); κ is an injection e.g. for TX = X → [0, ∞].
Hence, weak bisimulation for probabilistic system is expressible as
strong bisimulation of systems of type T → (Id ×A → T1) →c T1.
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
34
Further Work
• Elaborate the generalization from T(X × A) to TFX
• Coalgebraic modal logic with weak modalities [[a]], hhaii
• Generic algorithms for checking weak bisimulation
• Further variants of weak bisimulation, e.g. branching bisimulation
Oberseminar, 10. Dezember 2014
8 |
|
Sergey Goncharov, Dirk Pattinson
|
FAU Erlangen-Nürnberg, Informatik
35