UpSTAIRS with Sequence Diagrams

UpSTAIRS with Sequence Diagrams
Øystein Haugen,
Ragnhild Kobro Runde, Ketil Stølen
University of Oslo and SINTEF ICT,
Norway
FMCO 2005 / UpSTAIRS with Sequence Diagrams
Ragnhild Kobro Runde
S
T
•
•
•
•
•
A
I
R
S
Overview
Interactions and trace semantics
Interactions as example runs
Underspecification and nondeterminism
Refinement
Data and guards
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 2
Ragnhild Kobro Runde
S
T
A
I
R
S
Background: UML interactions
Lifeline
(instance)
sd S
A
B
Message
x
Send-event (!x)
y
Receiveevent (?x)
• Partial ordering of events:
- The send event is ordered before the corresponding receive event.
- Events on the same lifeline are ordered from the top and downwards.
• S specifies the two traces:
- < !x, ?x, !y, ?y >
- < !x, !y, ?x, ?y >
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 3
Ragnhild Kobro Runde
S
T
A
I
R
S
Alternatives
sd S
A
B
x
y
alt
z
• S specifies the four traces:
-
< !x, ?x, !y, ?y >
< !x, !y, ?x, ?y >
< !x, ?x, !z, ?z >
< !x, !z, ?x, ?z >
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 4
First alternative
Second alternative
Ragnhild Kobro Runde
S
T
A
I
R
S
Example: Network communication
sd Comm
A:sender
S:network
m
B:receiver
m
• Interactions = example runs!
- Specifies a set of positive and/or negative behaviours.
Positive
Inconclusive
Negative
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 5
Ragnhild Kobro Runde
S
T
A
I
R
S
Negative behaviour
sd Comm
A:sender
S:network
m
neg
B:receiver
m
m
Positive:
<!mAS,?mAS,!mSB,?mSB>
Negative:
<!mAS,?mAS ,!mSB,?mSB,!mSB,?mSB>
<!mAS,?mAS ,!mSB,!mSB,?mSB,?mSB>
• Formally:
(p1,n1) > (p2,n2) =
~
>
(p1 ~ p2, (p1 > n2)U(n1 >
~ p2)U(n1 >
~ n2) )
~
• Note:
- Inconclusive + positive/negative = inconclusive
- Positive + negative = negative
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 6
Ragnhild Kobro Runde
S
T
•
•
•
•
•
A
I
R
S
Overview
Interactions and trace semantics
Interactions as example runs
Underspecification and nondeterminism
Refinement
Data and guards
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 7
Ragnhild Kobro Runde
S
T
A
I
R
S
Underspecification and non-determinism
• Underspecification: Several alternative
behaviours are considered equivalent (serve the
same purpose).
• Inherent non-determinism: Alternative behaviours
that must all be possible for the implementation.
• These two should be described differently!
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 8
Ragnhild Kobro Runde
S
T
A
I
R
S
STAIRS
Positive
Positive
Inconclusive
Positive
Negative
Inconclusive
Inconclusive
Negative
Negative
xalt
Positive
Positive
Inconclusive
Positive
Negative
Inconclusive
Inconclusive
Negative
Negative
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 9
Ragnhild Kobro Runde
S
T
A
I
R
S
alt vs xalt
• Assume
[[ d1 ]] = (p1,n1)
[[ d2 ]] = (p2,n2)
• alt specifies potential behaviour:
P1 U P2
[[ d1 alt d2 ]]
= [[ d1 ]] + [[ d2 ]]
I
= (p1 U p2, n1 U n2)
N1 U N2
• xalt specifies mandatory behaviour:
[[ d1 xalt d2 ]]
P1
= [[ d1 ]] U [[ d2 ]]
I1
= (p1,n1) U (p2,n2)
N1
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 10
P2
I2
N2
Ragnhild Kobro Runde
S
T
A
I
R
S
Example: Network communication
cs C
A:sender
S:network
B:receiver
cs S
N1:N
G:N
N3:N
N2:N
N4:N
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 11
Ragnhild Kobro Runde
S
T
A
I
R
S
alt vs xalt
S:network
sd S_Comm
A:sender
G:N
N1:N
N2:N
N3:N
N4:N
B:receiver
m
xalt
m
m
m
alt
m
m
m
m
A->G->N1->B
A->G->N2->N3->B
A->G->N2->N4->B
Everything else
Everything else
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 12
Ragnhild Kobro Runde
S
T
•
•
•
•
•
A
I
R
S
Overview
Interactions and trace semantics
Interactions as example runs
Underspecification and nondeterminism
Refinement
Data and guards
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 13
Ragnhild Kobro Runde
S
T
A
I
R
S
Refinement in STAIRS
Positive
Supplementing
Inconclusive
Narrowing
Negative
• An interaction obligation o'=(p',n') is a refinement of an
interaction obligation o=(p,n) iff
- n  n'
- p  p'Un'
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 14
Ragnhild Kobro Runde
S
T
A
I
R
S
Adding new obligations
sd S_Comm
A:sender
G:N
N1:N
N2:N
N3:N
N4:N
B:receiver
Mobile:N
m
xalt
m
m
m
alt
m
m
m
m
NEW
opt
m
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 16
m
Ragnhild Kobro Runde
S
T
A
I
R
S
Supplementing
sd S_Comm
A:sender
assert
G:N
N1:N
N2:N
N3:N
N4:N
B:receiver
m
xalt
m
m
m
alt
m
m
m
m
A->G->N1->B
A->G->N2->N3->B
A->G->N2->N4->B
Everything else
Everything else
Everything else
Everything else
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 17
Ragnhild Kobro Runde
S
T
•
•
•
•
•
A
I
R
S
Overview
Interactions and trace semantics
Interactions as example runs
Underspecification and nondeterminism
Refinement
Data and guards
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 18
Ragnhild Kobro Runde
S
T
A
I
R
S
Including data
• Two special events:
- write (for assignments)
- check (for constraints)
• A state is a total function
σ  Var → Val
• For an expression expr, expr(σ) denotes its value
in σ.
• Assignment:
[[assign(var,expr)]] =
( {<write(σ, σ')> | σ'(var) = expr(σ)} , Ø}
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 19
Ragnhild Kobro Runde
S
T
A
I
R
S
Constraints
sd constraint
A
B
{ avar = 0 }
m
{ avar > 0 }
[[constr(c)]] =
( {<check(σ)>|c(σ)} , {<check(σ)>|¬c(σ)} )
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 20
Ragnhild Kobro Runde
S
T
A
I
R
S
Guards
sd guards
A
alt
B
[ avar = 0 ]
x
[ avar >= 0 ]
y
• A special kind of constraint
• May be overlapping
• Need not be exhaustive
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 21
Ragnhild Kobro Runde
S
T
A
I
R
S
Definition of guarded xalt
• Assume:
[[ d1 ]] = (p1,n1)
[[ d2 ]] = (p2,n2)
• Guarded xalt:
[[ g1->d1 xalt g2->d2]] =
[[ constr(g1) seq d1 ]] U [[ constr(g2) seq d2 ]]
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 22
Ragnhild Kobro Runde
S
T
A
I
R
S
Definition of guarded xalt
• Assume:
[[ d1 ]] = (p1,n1)
[[ d2 ]] = (p2,n2)
• Guarded xalt:
[[ g1->d1 xalt g2->d2]] =
( {<check(σ)> >
~ p1 | g1(σ)},
{<check(σ)> >
p1
|
¬g1(σ)}
U
~
{<check(σ)> > n1 | g1(σ) v ¬g1(σ)} )
~
U
( {<check(σ)> >
~ p2 | g2(σ)},
{<check(σ)> >
~ p2 | ¬g2(σ)} U
{<check(σ)> >
~ n2 | g2(σ) v ¬g2(σ)} )
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 23
Ragnhild Kobro Runde
S
T
A
I
R
S
sd S_Comm
A:sender
assert
G:N
N1:N
N2:N
N3:N
N4:N
B:receiver
m
xalt
m
m
m
alt
m
m
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 24
m
m
Ragnhild Kobro Runde
S
T
A
I
R
S
Narrowing by using guards
sd S_Comm
A:sender
G:N
N1:N
N2:N
N3:N
N4:N
B:receiver
m
assert
xalt
[N1 capacity ok]
m
m
[N2 capacity ok]
m
alt
A->G->[N1 ok]->N1->B
A->G->[N1 not ok]->N1->B
A->G->[N2 ok]->N2->...
A->G->[N2 not ok]->N2->...
A->G->[N1 not ok]->N1->B
A->G->[N2 not ok]->N2->...
Everything else
Everything else
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 25
Ragnhild Kobro Runde
S
T
A
I
R
S
Narrowing by using guards
sd S_Comm
A:sender
G:N
N1:N
N2:N
N3:N
N4:N
B:receiver
m
assert
xalt
[N2 capacity ok]
m
alt
[N3 capacity ok]
m
m
[N4 capacity ok]
m
m
A->G->[N2 ok]->N2->[N3 ok]->N3->B
A->G->[N2 ok]->N2->[N4 ok]->N4->B
A->G->[N2 ok]->N2->[N3 not ok and N4 not ok]
A->G->[N2 ok]->N2->[N3 not ok]->N3->B
A->G->[N2 ok]->N2->[N4 not ok]->N4->B
A->G->[N2 not ok]->N2->[N3 ok/not ok]->N3->B
A->G->[N2 not ok]->N2->[N4 ok/not ok]->N4->B
A->G->[N2 ok]->N2->[N3 not ok]->N3->B
A->G->[N2 ok]->N2->[N4 not ok]->N4->B
Everything else
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 26
Ragnhild Kobro Runde
S
T
A
I
R
S
Summary
• Interactions are partial specifications:
- Distinguish between positive and inconclusive traces.
• Distinguish between underspecification (alt) and
inherent non-determinism (xalt).
• Refinement also of partial interactions.
- Supplementing
- Narrowing
• Introducing guards should be a valid refinement
step.
- Traces with a false guards should be negative.
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 29
Ragnhild Kobro Runde
S
T
A
I
R
S
Literature on STAIRS
• Øystein Haugen, Ketil Stølen:
STAIRS – Steps to analyze interactions with refinement
semantics (UML'2003, LNCS 2863).
- Distinguishes between mandatory and potential behaviour
• Øystein Haugen, Knut Eilif Husa, Ragnhild Kobro Runde,
Ketil Stølen:
STAIRS towards formal design with sequence diagrams
(SOSYM, Online First, 2005).
- Denotational trace semantics for interactions
- Formalizes the refinement relations in STAIRS
• Øystein Haugen, Knut Eilif Husa, Ragnhild Kobro Runde,
Ketil Stølen: Why timed sequence diagrams require threeevent semantics (Dagstuhl post-proc., LNCS 3466).
Extended version as research report 309.
- Extends STAIRS with time and three-event semantics
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 30
Ragnhild Kobro Runde
S
T
A
I
R
S
Literature on STAIRS
• Ragnhild Kobro Runde, Øystein Haugen, Ketil Stølen:
Refining UML interactions with explicit and implicit
nondeterminism (Nordic Journal of Computing, to appear).
- Extends STAIRS with data and guards
- More on mandatory vs potential behaviour
• Ragnhild Kobro Runde, Øystein Haugen, Ketil Stølen:
How to transform UML neg into a useful construct
(NIK'2005, to appear).
- Investigates various formal definitions for negation
• Atle Refsdal, Knut Eilif Husa, Ketil Stølen:
Specification and refinement of soft real-time
requirements using sequence diagrams (FORMATS'05).
- Extends STAIRS with probabilistic alternatives
FMCO 2005 / UpSTAIRS with Sequence Diagrams / Slide 31
Ragnhild Kobro Runde
http://heim.ifi.uio.no/~ragnhilk/stairs/
Thank you!
FMCO 2005 / UpSTAIRS with Sequence Diagrams
Ragnhild Kobro Runde