19.02.2015 Views

Semantics and Verification of UML Activity Diagrams for Workflow ...

Semantics and Verification of UML Activity Diagrams for Workflow ...

Semantics and Verification of UML Activity Diagrams for Workflow ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

✬<br />

✩<br />

<strong>Semantics</strong> <strong>and</strong> <strong>Verification</strong> <strong>of</strong><br />

<strong>UML</strong> <strong>Activity</strong> <strong>Diagrams</strong> <strong>for</strong><br />

<strong>Workflow</strong> Modelling<br />

Rik Eshuis<br />

CRP Henri Tudor|LIASIT<br />

rik.eshuis@tudor.lu<br />

www.cs.utwente.nl/∼eshuis<br />

January 6, 2003<br />

✫<br />

1<br />


✬<br />

✩<br />

Example <strong>UML</strong> activity diagram<br />

questionnaire<br />

received<br />

Process<br />

questionnaire<br />

Register<br />

Send<br />

questionnaire<br />

Evaluate<br />

WAIT−1<br />

[else]<br />

after(2 weeks)<br />

WAIT−2<br />

WAIT−4<br />

Archive<br />

WAIT−3<br />

[in(WAIT−2)]<br />

[processing required]<br />

Process<br />

complaint<br />

Check<br />

Processing<br />

[ok]<br />

[else]<br />

✫<br />

2<br />


✬<br />

✩<br />

<strong>Workflow</strong> models<br />

• no or little support <strong>for</strong> analysis <strong>of</strong> functional requirements<br />

• no st<strong>and</strong>ard notation<br />

<strong>UML</strong> activity diagrams<br />

• useful <strong>for</strong> specifying workflow models, but:<br />

• currently no <strong>for</strong>mal semantics<br />

• OMG semantics <strong>of</strong> <strong>UML</strong> activity diagrams is not intended <strong>for</strong><br />

workflow modelling<br />

✫<br />

3<br />


✬<br />

✩<br />

Goal<br />

• define <strong>for</strong>mal execution semantics <strong>for</strong> <strong>UML</strong> activity diagrams<br />

• intended <strong>for</strong> workflow modelling<br />

• use <strong>for</strong>mal semantics to verify functional requirements<br />

using model checking<br />

✫<br />

4<br />


✬<br />

✩<br />

Contents<br />

• Background: workflow modelling <strong>and</strong> activity diagram syntax<br />

• <strong>Semantics</strong><br />

• <strong>Verification</strong><br />

✫<br />

5<br />


✬<br />

✩<br />

<strong>Workflow</strong><br />

• =operational business processes.<br />

• Managed by workflow management system.<br />

• Often specified by bubble-<strong>and</strong>-arrow notations.<br />

• Petri nets have been proposed as <strong>for</strong>mal counterpart <strong>of</strong> this.<br />

• <strong>UML</strong> activity diagrams are a good alternative, once given a<br />

<strong>for</strong>mal semantics.<br />

✫<br />

6<br />


✬<br />

Environment <strong>of</strong> WF system<br />

✩<br />

<strong>Workflow</strong> Specification<br />

Database Specification<br />

<strong>Workflow</strong><br />

Management System<br />

(WFMS)<br />

Database<br />

Management System<br />

(DBMS)<br />

WFMS + Wf spec = WFS<br />

DBMS + DB spec = DBS<br />

<strong>Workflow</strong> System<br />

(WFS)<br />

local variables<br />

Database System<br />

(DBS)<br />

activity<br />

terminates<br />

enable<br />

activity<br />

Create, Read,<br />

Update, Delete<br />

Application s<strong>of</strong>tware<br />

✫<br />

User<br />

7<br />


✬<br />

✩<br />

Architecture <strong>of</strong> WF system<br />

event<br />

<strong>Workflow</strong> System<br />

event<br />

Queue<br />

event<br />

time<br />

Clock Manager Clock<br />

time<br />

Router<br />

enable new activity<br />

begin transaction<br />

end transaction<br />

control data<br />

✫<br />

8<br />


✬<br />

Syntax <strong>of</strong> <strong>UML</strong> activity diagrams<br />

✩<br />

Points to initial state<br />

Final state<br />

<strong>Activity</strong><br />

state<br />

Wait<br />

state<br />

Takes time<br />

Non−interruptable<br />

Finishes with termination event<br />

May change case attributes<br />

Takes time<br />

Interruptable<br />

Finished by event:<br />

external, condition change, temporal.<br />

Case attributes not changed:<br />

[g]<br />

[else]<br />

XOR split<br />

XOR join<br />

AND split<br />

AND join<br />

✫<br />

9<br />


✬<br />

✩<br />

<strong>Semantics</strong><br />

Requirements on <strong>for</strong>mal execution semantics<br />

• accurate, i.e. match workflow behaviour<br />

• analysable, i.e. “small” finite state space<br />

General assumptions <strong>for</strong> semantics<br />

• workflow model prescribes behaviour <strong>of</strong> WFS<br />

• WFS is reactive system<br />

• WFS coordinates activities, but does not per<strong>for</strong>m them<br />

✫<br />

10<br />


✬<br />

Existing execution semantics<br />

✩<br />

e[c]/a<br />

Statechart<br />

Petri net<br />

• Reactive step semantics <strong>of</strong> statecharts:<br />

– state = waiting <strong>for</strong> event<br />

– transition = responding to event (ECA rule)<br />

• Token-game semantics <strong>of</strong> Petri nets:<br />

– State (marking) = allocation <strong>of</strong> resources to places<br />

– Transition = (exclusive) use <strong>of</strong> resources<br />

• In a Petri net:<br />

– Enabled transitions need not be taken,<br />

– Behaviour is active rather than reactive.<br />

✫<br />

11<br />


✬<br />

✩<br />

Two semantics<br />

We take the statechart semantics as starting point.<br />

Requirements-level<br />

WFS is black box<br />

WFS reacts immediately to input<br />

events<br />

WFS routes instantaneously<br />

WFS processes events in parallel<br />

Implementation-level<br />

WFS is white box<br />

Requirements-level satisfies perfect synchrony:<br />

time(event occurrence) = time(system reaction)<br />

WFS does not react immediately<br />

to input events<br />

WFS does not route instantaneously<br />

WFS processes events one by<br />

one<br />

✫<br />

12<br />


✬<br />

<strong>Semantics</strong>: Kripke structure (Clocked<br />

Transition System)<br />

✩<br />

(Var,→,σ 0 ) with<br />

• Var set <strong>of</strong> variables<br />

• σ → σ ′ transition relation, with σ a valuation <strong>of</strong> Var<br />

• σ 0 initial state<br />

State <strong>of</strong> Kripke structure represents state <strong>of</strong> WFS. It consists <strong>of</strong>:<br />

• Configuration: bag <strong>of</strong> active activity diagram nodes.<br />

• Set <strong>of</strong> current event occurrences.<br />

• Valuation <strong>of</strong> case variables.<br />

• Current values <strong>of</strong> timers.<br />

✫<br />

13<br />


✬<br />

✩<br />

Step semantics<br />

• Step = maximal, consistent, non-interfering bag <strong>of</strong> enabled<br />

hyperedges.<br />

• Step is taken in response to some event occurrences.<br />

• Both semantics use step semantics but in a different way.<br />

✫<br />

14<br />


✬<br />

✩<br />

Requirements-level semantics<br />

• All input events are processed at the same time<br />

• Events generated in a step are responded to in next step.<br />

• Maximal sequence <strong>of</strong> steps (superstep) is taken.<br />

• In requirements-level semantics, supersteps do not take time.<br />

⇒ while superstep is taken, no external events can occur!<br />

STATEMATE semantics <strong>of</strong> statecharts<br />

✫<br />

15<br />


✬<br />

✩<br />

Implementation-level semantics<br />

• Imp.level semantics processes events one by one (single event<br />

processing)<br />

• Events generated in a step are responded to in some later step.<br />

• In implemenation-level semantics, steps take time.<br />

⇒ while step is taken, external event can occur!<br />

⇒ need a queue to store events.<br />

<strong>UML</strong> semantics <strong>of</strong> statecharts (state machines)<br />

✫<br />

16<br />


✬<br />

✩<br />

Example run in req.-level semantics<br />

Receive order<br />

{Receive<br />

order}<br />

{Check stock,<br />

Check customer}<br />

Check stock<br />

{Make pro−<br />

duction plan,<br />

Check customer}<br />

Check customer<br />

terminates terminates terminates<br />

{Make pro−<br />

duction plan,<br />

Send bill}<br />

initial<br />

state<br />

state 1 state 2<br />

state 3<br />

state 4<br />

insufficient stock<br />

customer ok<br />

being updated<br />

customer ok<br />

being updated<br />

✫<br />

17<br />


✬<br />

Example run in imp.-level semantics<br />

✩<br />

Receive order<br />

terminates<br />

Check stock<br />

terminates<br />

initial<br />

state<br />

{Receive<br />

order}<br />

{routing}<br />

{Check stock,<br />

Check customer}<br />

state 1 state 2<br />

state 3<br />

{routing,<br />

Check customer},<br />

state 4<br />

...<br />

insufficient stock<br />

customer ok<br />

being updated<br />

customer ok<br />

being updated<br />

Check customer<br />

terminates<br />

...<br />

{routing,<br />

Check customer},<br />

state 4<br />

{routing}<br />

state 5<br />

{Make pro−<br />

duction plan,<br />

routing}<br />

state 6<br />

{Make pro−<br />

duction plan,<br />

Send bill}<br />

state 7<br />

✫<br />

customer ok<br />

being updated<br />

✪<br />

18


✬<br />

✩<br />

Comparing requirements-level <strong>and</strong><br />

implementation-level semantics<br />

• Req.-level semantics is easier to analyse than imp.-level<br />

semantics<br />

• Imp.-level semantics is more accurate than req.-level semantics<br />

But <strong>for</strong> certain requirements r, activity diagrams a:<br />

r is satisfied by a under req.-level semantics<br />

⇔<br />

r is satisfied by a under imp.-level semantics<br />

✫<br />

19<br />


✬<br />

✩<br />

Comparing req.-level <strong>and</strong> imp.-level<br />

semantics (2)<br />

In order to make this work, we had to<br />

• Rule out “ambiguous” activity diagrams<br />

• Put restrictions on imp.level semantics (e.g. FIFO queue)<br />

• Put restrictions on requirements (no next time, restricted until<br />

operator)<br />

✫<br />

20<br />


✬<br />

✩<br />

Example ambiguous activity diagram<br />

Configuration = [WAIT-1,WAIT-4]<br />

Input events: e <strong>and</strong> f.<br />

e1:e<br />

WAIT−2<br />

WAIT−1<br />

e2:f<br />

WAIT−3<br />

e3:e<br />

WAIT−5<br />

WAIT−4<br />

e4:f<br />

WAIT−6<br />

✫<br />

21<br />


✬<br />

✩<br />

Another ambiguous activity diagram<br />

Configuration = [A,WAIT-2]<br />

Input events: e <strong>and</strong> termination event <strong>of</strong> A.<br />

A<br />

e1:<br />

WAIT−1<br />

WAIT−2<br />

e2:e[in(A)]<br />

WAIT−3<br />

e3:e[!in(A)]<br />

WAIT−4<br />

✫<br />

22<br />


✬<br />

✩<br />

Restricted logic<br />

CTL* with restrictions:<br />

• no events (in ILS named events can have extra effects)<br />

• no next time (X)<br />

• restricted until (lhs is not a state <strong>for</strong>mula)<br />

✫<br />

23<br />


✬<br />

✩<br />

In ILS, named events can have extra effects<br />

Configuration = [A]<br />

Input events: e <strong>and</strong> termination event <strong>of</strong> A.<br />

e<br />

A WAIT−1 WAIT−2<br />

✫<br />

24<br />


✬<br />

Intermezzo: statecharts vs. Petri nets<br />

✩<br />

(a)<br />

Produce<br />

partial order<br />

Take partial order<br />

from stock<br />

Send partial<br />

shipment<br />

(b)<br />

Produce<br />

partial order<br />

Take partial order<br />

from stock<br />

Send partial<br />

shipment<br />

(c)<br />

Produce<br />

partial order<br />

Take partial order<br />

from stock<br />

Send partial<br />

shipment<br />

Send partial<br />

shipment<br />

✫<br />

25<br />


✬<br />

✩<br />

Intermezzo: statecharts vs. Petri nets<br />

But: statecharts cannot express every <strong>for</strong>m <strong>of</strong> concurrency due to<br />

constraints on AND/OR hierachy.<br />

A<br />

B<br />

A<br />

B<br />

WAIT−1<br />

WAIT−2<br />

C<br />

D<br />

E<br />

WAIT−3<br />

WAIT−4<br />

WAIT−5<br />

✫<br />

26<br />


✬<br />

✩<br />

Intermezzo: statecharts vs. Petri nets<br />

So: statechart - hierarchy = Petri net ?<br />

No!<br />

Hypergraph<br />

(Petri net,<br />

activity diagram)<br />

Hierarchical<br />

hypergraph<br />

(statechart)<br />

Petri net theory<br />

we<br />

Statemate,<br />

<strong>UML</strong><br />

Token game<br />

semantics<br />

Step semantics<br />

✫<br />

27<br />


✬<br />

<strong>Verification</strong> tool<br />

✩<br />

Toolkit <strong>for</strong> Conceptual Modeling (TCM) contains about 20 graph<br />

editors, including editors <strong>for</strong> <strong>UML</strong> diagrams. See<br />

www.cs.utwente.nl/∼tcm<br />

<strong>Workflow</strong> modeller<br />

Formal requirement<br />

Formal activity diagram<br />

Path in activity diagram<br />

TCM TCM TCM<br />

Temporal Logic Formula<br />

Transition system<br />

Run<br />

Model checker<br />

✫<br />

28<br />


✬<br />

✩<br />

Example<br />

<strong>Workflow</strong> <strong>of</strong> a production company<br />

[insufficient stock]<br />

Receive<br />

order<br />

Make produc−<br />

tion plan<br />

[insufficient<br />

stock]<br />

Check<br />

stock<br />

[else]<br />

Check<br />

customer<br />

[else]<br />

WAIT<br />

WAIT<br />

[customer ok]<br />

[else]<br />

[customer ok]<br />

Send bill<br />

[else]<br />

Fill order<br />

Notify<br />

customer<br />

WAIT<br />

Produce<br />

payment<br />

received<br />

[else]<br />

WAIT<br />

WAIT<br />

H<strong>and</strong>le<br />

payment<br />

[payment<br />

ok]<br />

Ship<br />

order<br />

✫<br />

29<br />


✬<br />

✩<br />

Desired properties<br />

P1 FGfinal. True<br />

P2 Fin(Make production plan) ⇔ Fin(Produce). False<br />

P3 F(in(Produce) ∨ in(Fill order)) ⇔ Fin(Send bill). True<br />

Checked with NuSMV fair<br />

30<br />

✫<br />


✬<br />

✩<br />

Counter-example <strong>of</strong> P2 highlighted by TCM<br />

Make produc−<br />

tion plan<br />

[insufficient stock]<br />

WAIT<br />

Receive<br />

order<br />

Check stock<br />

Check<br />

customer<br />

[else]<br />

WAIT<br />

[else]<br />

If the customer check fails, the workflow stops whereas Make<br />

production plan may already have been executed. Repair:<br />

P2’ (F customer ok) ⇒<br />

Fin(Make production plan) ⇔ Fin(Produce). True<br />

✫<br />

31<br />


✬<br />

Reducing the state space<br />

✩<br />

• We do not allow unbounded state nodes (nodes with<br />

unbounded number <strong>of</strong> instances)<br />

A<br />

B<br />

A<br />

B<br />

C<br />

• We ‘abstract’ from data: Use basic guard expressions such as<br />

x>cthat are logically independent from each other. (Every<br />

basic guard expression is a boolean.)<br />

• Replace dense time by discrete time. Preserves untimed<br />

reachability properties.<br />

✫<br />

32<br />


✬<br />

Strong fairness<br />

✩<br />

• We assume that loops in an activity diagram are eventually<br />

exited. We specify this using strong fairness constraints.<br />

s1 s2 s3<br />

p,!q !p, q !p, !q<br />

strong fairness constraint (p,q)<br />

• This is an assumption on environment!<br />

• NuSMV has been extended with an algorithm by Kesten,<br />

Pnueli <strong>and</strong> Raviv that evaluates properties only on strongly<br />

fair runs. (now included in NuSMV 2.1)<br />

✫<br />

33<br />


✬<br />

✩<br />

Fighting the state space explosion<br />

• Although state space is now finite, it is still too large to be<br />

verified efficiently.<br />

• Solution: slice activity diagrams, depending upon property<br />

being verified.<br />

• Four reduction rules (e.g. remove irrelevant nodes, variables)<br />

✫<br />

34<br />


✬<br />

✩<br />

Removing irrelevant nodes <strong>of</strong> example<br />

[insufficient stock]<br />

[insufficient<br />

stock]<br />

[customer ok]<br />

[else]<br />

Check<br />

stock<br />

[else]<br />

WAIT<br />

WAIT<br />

[else]<br />

WAIT<br />

WAIT<br />

Ship<br />

order<br />

Check<br />

customer<br />

[customer ok]<br />

[else]<br />

[payment<br />

ok]<br />

[else]<br />

H<strong>and</strong>le<br />

payment<br />

Property: FGfinal<br />

✫<br />

35<br />


✬<br />

✩<br />

Conclusion<br />

• WF graphs need a reactive (step) execution semantics.<br />

• Models with a Petri net-like syntax can have a statechart-like<br />

semantics.<br />

• Requirements-level semantics, even though inaccurate, is useful<br />

<strong>for</strong> analysis.<br />

• WF graph can be used as pretty front-end <strong>for</strong> model checkers.<br />

• Tool allows verification <strong>of</strong> large workflow models that have<br />

event-driven behaviour, real-time, data, <strong>and</strong> loops.<br />

✫<br />

36<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!