Formalising Concurrent UML State Machines Using Coloured Petri Nets - - PowerPoint PPT Presentation

formalising concurrent uml state machines using coloured
SMART_READER_LITE
LIVE PREVIEW

Formalising Concurrent UML State Machines Using Coloured Petri Nets - - PowerPoint PPT Presentation

KSE 2014 October 10th, 2014 Hanoi Formalising Concurrent UML State Machines Using Coloured Petri Nets tienne Andr, Mohamed Mahdi Benmoussa, Christine Choppy Universit Paris 13, Sorbonne Paris Cit, LIPN, CNRS, France Andr, Benmoussa,


slide-1
SLIDE 1

KSE 2014 October 10th, 2014 Hanoi

Formalising Concurrent UML State Machines Using Coloured Petri Nets

Étienne André, Mohamed Mahdi Benmoussa, Christine Choppy Université Paris 13, Sorbonne Paris Cité, LIPN, CNRS, France

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 1 / 21

slide-2
SLIDE 2

Introduction

Motivation: Complex Systems Safety

Need for early bug detection

Bugs discovered when final testing: expensive Need for a thorough modelling phase

Critical and complex systems that need verification Specification with UML state machines (SMDs) [OMG, 2011] Informal description of UML semantics No formal verification on UML state machines Solution: Provide a formalisation using coloured Petri nets

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 2 / 21

slide-3
SLIDE 3

Outline

Outline

1

Concepts (SMDs & CPNs)

2

Translation of Concurrent State Machines

3

Conclusion and Perspectives

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 3 / 21

slide-4
SLIDE 4

Concepts (SMDs & CPNs)

Outline

1

Concepts (SMDs & CPNs)

2

Translation of Concurrent State Machines

3

Conclusion and Perspectives

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 4 / 21

slide-5
SLIDE 5

Concepts (SMDs & CPNs) UML State Machines (SMDs)

UML Behavioural State Machines

Transition systems used to express the behaviour of dynamic systems Specified in [OMG, 2011] Widely used in the industry Semantics not formally expressed

Informal specification in [OMG, 2011] Not directly suitable for formal methods

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 5 / 21

slide-6
SLIDE 6

Concepts (SMDs & CPNs) UML State Machines (SMDs)

Example of a CD Player [Zhang and Liu, 2010]

Features

A hierarchy of simple and composite states Transitions (including inter-level) with events Entry (find track start) and do (play track) behaviours Global variables (present and track) History pseudostate (H)

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 6 / 21

slide-7
SLIDE 7

Concepts (SMDs & CPNs) UML State Machines (SMDs)

Example of a CD Player (cont.)

This example is simple

Few states, few events, few variables No exit behaviour

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 7 / 21

slide-8
SLIDE 8

Concepts (SMDs & CPNs) UML State Machines (SMDs)

Example of a CD Player (cont.)

This example is simple

Few states, few events, few variables No exit behaviour

And still. . . Can we ensure the following?

“When in PLAYING, there is a CD in the player” “When in PLAYING, the track number is always between 1 and trackCount”

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 7 / 21

slide-9
SLIDE 9

Concepts (SMDs & CPNs) UML State Machines (SMDs)

Example of a CD Player (cont.)

This example is simple

Few states, few events, few variables No exit behaviour

And still. . . Can we ensure the following?

“When in PLAYING, there is a CD in the player” “When in PLAYING, the track number is always between 1 and trackCount”

Not easy to guarantee! (So what about larger case studies. . . )

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 7 / 21

slide-10
SLIDE 10

Concepts (SMDs & CPNs) UML State Machines (SMDs)

Main Goal

We translate UML state machines to coloured Petri nets (CPNs) Set of considered constructs

Hierarchy of composite states

simple

  • rthogonal (with regions)

Inter-level transitions Entry, do, exit behaviours with global variables History pseudostates Concurrency (fork, join, synchronization)

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 8 / 21

slide-11
SLIDE 11

Concepts (SMDs & CPNs) UML State Machines (SMDs)

Main Goal

We translate UML state machines to coloured Petri nets (CPNs) Set of considered constructs

Hierarchy of composite states

simple

  • rthogonal (with regions)

Inter-level transitions Entry, do, exit behaviours with global variables History pseudostates Concurrency (fork, join, synchronization)

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 8 / 21

slide-12
SLIDE 12

Concepts (SMDs & CPNs) Coloured Petri Nets

Petri Nets [Petri, 1962]

A kind of automaton

Bipartite graph with places and transitions Tokens can be added to places

Represent data or control

A state (configuration) of the Petri net: a marking

Number of tokens in each place Evolves when firing transitions

Initial state: initial marking

Advantages of Petri nets

Detailed view of the process with an expressive graphical representation A formal semantics Powerful tools to simulate and verify the model w.r.t. various properties (reachability, boundedness, invariants, deadlock-freeness, etc.)

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 9 / 21

slide-13
SLIDE 13

Concepts (SMDs & CPNs) Coloured Petri Nets

Petri Nets: An Example

A DVD renting machine

Customer’s coins Earned coins DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 10 / 21

slide-14
SLIDE 14

Concepts (SMDs & CPNs) Coloured Petri Nets

Petri Nets: An Example

A DVD renting machine

Customer’s coins Earned coins DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 10 / 21

slide-15
SLIDE 15

Concepts (SMDs & CPNs) Coloured Petri Nets

Petri Nets: An Example

A DVD renting machine

Customer’s coins Earned coins DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 10 / 21

slide-16
SLIDE 16

Concepts (SMDs & CPNs) Coloured Petri Nets

Petri Nets: An Example

A DVD renting machine

Customer’s coins Earned coins DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 10 / 21

slide-17
SLIDE 17

Concepts (SMDs & CPNs) Coloured Petri Nets

Petri Nets: An Example

A DVD renting machine

Customer’s coins Earned coins DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 10 / 21

slide-18
SLIDE 18

Concepts (SMDs & CPNs) Coloured Petri Nets

Petri Nets: An Example

A DVD renting machine

Customer’s coins Earned coins DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 10 / 21

slide-19
SLIDE 19

Concepts (SMDs & CPNs) Coloured Petri Nets

Petri Nets: An Example

A DVD renting machine

Customer’s coins Earned coins DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 10 / 21

slide-20
SLIDE 20

Concepts (SMDs & CPNs) Coloured Petri Nets

Petri Nets: An Example

A DVD renting machine

Customer’s coins Earned coins DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 10 / 21

slide-21
SLIDE 21

Concepts (SMDs & CPNs) Coloured Petri Nets

Petri Nets: An Example

A DVD renting machine

Customer’s coins Earned coins DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 10 / 21

slide-22
SLIDE 22

Concepts (SMDs & CPNs) Coloured Petri Nets

Petri Nets: An Example

A DVD renting machine

Customer’s coins Earned coins DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 10 / 21

slide-23
SLIDE 23

Concepts (SMDs & CPNs) Coloured Petri Nets

Coloured Petri Nets [Jensen and Kristensen, 2009]

Extension of Petri nets with colours

Tokens and places have a type (“colour set”) Arcs are labelled with expressions Transitions can have a guard

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 11 / 21

slide-24
SLIDE 24

Concepts (SMDs & CPNs) Coloured Petri Nets

Coloured Petri Nets [Jensen and Kristensen, 2009]

Extension of Petri nets with colours

Tokens and places have a type (“colour set”) Arcs are labelled with expressions Transitions can have a guard

Example: A more complex version of the DVD renting machine

NAMExINT 1’(Alice, 30¤) ++ 1’(Bob, 20¤)

[m ≥ p]

INT 1’(0¤) FILMxINT 2’(Satan Tango, 12¤) ++ 1’(Rash¯

  • mon, 6¤)

++ 1’(Un retour, 10¤) FILMxINT

(c, m − p) (c, m) (f, p) (f, p) e + p e (f, p) (f, p)

Legend Customers Money earned DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 11 / 21

slide-25
SLIDE 25

Concepts (SMDs & CPNs) Coloured Petri Nets

Coloured Petri Nets [Jensen and Kristensen, 2009]

Extension of Petri nets with colours

Tokens and places have a type (“colour set”) Arcs are labelled with expressions Transitions can have a guard

Example: A more complex version of the DVD renting machine

NAMExINT 1’(Alice, 30¤) ++ 1’(Bob, 20¤)

[m ≥ p]

INT 1’(0¤) FILMxINT 2’(Satan Tango, 12¤) ++ 1’(Rash¯

  • mon, 6¤)

++ 1’(Un retour, 10¤) FILMxINT

(c, m − p) (c, m) (f, p) (f, p) e + p e (f, p) (f, p)

Legend Customers Money earned DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 11 / 21

slide-26
SLIDE 26

Concepts (SMDs & CPNs) Coloured Petri Nets

Coloured Petri Nets [Jensen and Kristensen, 2009]

Extension of Petri nets with colours

Tokens and places have a type (“colour set”) Arcs are labelled with expressions Transitions can have a guard

Example: A more complex version of the DVD renting machine

NAMExINT 1’(Alice, 24¤) ++ 1’(Bob, 20¤)

[m ≥ p]

INT 1’(6¤) FILMxINT 2’(Satan Tango, 12¤) ++ 1’(Un retour, 10¤) FILMxINT 1’(Rash¯

  • mon, 6¤)

(c, m − p) (c, m) (f, p) (f, p) e + p e (f, p) (f, p)

Legend Customers Money earned DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 11 / 21

slide-27
SLIDE 27

Concepts (SMDs & CPNs) Coloured Petri Nets

Coloured Petri Nets [Jensen and Kristensen, 2009]

Extension of Petri nets with colours

Tokens and places have a type (“colour set”) Arcs are labelled with expressions Transitions can have a guard

Example: A more complex version of the DVD renting machine

NAMExINT 1’(Alice, 24¤) ++ 1’(Bob, 20¤)

[m ≥ p]

INT 1’(6¤) FILMxINT 2’(Satan Tango, 12¤) ++ 1’(Un retour, 10¤) FILMxINT 1’(Rash¯

  • mon, 6¤)

(c, m − p) (c, m) (f, p) (f, p) e + p e (f, p) (f, p)

Legend Customers Money earned DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 11 / 21

slide-28
SLIDE 28

Concepts (SMDs & CPNs) Coloured Petri Nets

Coloured Petri Nets [Jensen and Kristensen, 2009]

Extension of Petri nets with colours

Tokens and places have a type (“colour set”) Arcs are labelled with expressions Transitions can have a guard

Example: A more complex version of the DVD renting machine

NAMExINT 1’(Alice, 24¤) ++ 1’(Bob, 8¤)

[m ≥ p]

INT 1’(18¤) FILMxINT 1’(Satan Tango, 12¤) ++ 1’(Un retour, 10¤) FILMxINT 1’(Rash¯

  • mon, 6¤)

++ 1’(Satan Tango, 12¤)

(c, m − p) (c, m) (f, p) (f, p) e + p e (f, p) (f, p)

Legend Customers Money earned DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 11 / 21

slide-29
SLIDE 29

Concepts (SMDs & CPNs) Coloured Petri Nets

Coloured Petri Nets [Jensen and Kristensen, 2009]

Extension of Petri nets with colours

Tokens and places have a type (“colour set”) Arcs are labelled with expressions Transitions can have a guard

Example: A more complex version of the DVD renting machine

NAMExINT 1’(Alice, 24¤) ++ 1’(Bob, 8¤)

[m ≥ p]

INT 1’(18¤) FILMxINT 1’(Satan Tango, 12¤) ++ 1’(Un retour, 10¤) FILMxINT 1’(Rash¯

  • mon, 6¤)

++ 1’(Satan Tango, 12¤)

(c, m − p) (c, m) (f, p) (f, p) e + p e (f, p) (f, p)

Legend Customers Money earned DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 11 / 21

slide-30
SLIDE 30

Concepts (SMDs & CPNs) Coloured Petri Nets

Coloured Petri Nets [Jensen and Kristensen, 2009]

Extension of Petri nets with colours

Tokens and places have a type (“colour set”) Arcs are labelled with expressions Transitions can have a guard

Example: A more complex version of the DVD renting machine

NAMExINT 1’(Alice, 24¤) ++ 1’(Bob, 8¤)

[m ≥ p]

INT 1’(18¤) FILMxINT 2’(Satan Tango, 12¤) ++ 1’(Un retour, 10¤) FILMxINT 1’(Rash¯

  • mon, 6¤)

(c, m − p) (c, m) (f, p) (f, p) e + p e (f, p) (f, p)

Legend Customers Money earned DVDs available DVDs on loan

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 11 / 21

slide-31
SLIDE 31

Concepts (SMDs & CPNs) Coloured Petri Nets

An Example of a CPN

(Partial) translation of the CD player

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 12 / 21

slide-32
SLIDE 32

Translation of Concurrent State Machines

General translation Scheme

Deeply revise & extend translation from SMDs to CPNs proposed in

[André, Choppy, Klai, 2012]

Tricky: ways to get a reasonable size for the CPN To allow to take into account concurrency, fork and join pseudo-states and orthogonal regions. Translation based on three algorithms :

Algorithm 1 for states and behaviours Algorithm 2 for transitions Algorithm 3 for history pseudo-states

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 13 / 21

slide-33
SLIDE 33

Translation of Concurrent State Machines

Algorithm 1 -Translation of States and Behaviours

Each simple, final, history (pseudo) state → one place Each behaviour (entry/exit/do) → place, transition & arc Hierarchical structure → tree of exit/entry behaviours (used later to connect transitions)

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 14 / 21

slide-34
SLIDE 34

Translation of Concurrent State Machines

Algorithm 2 - Translation of Transitions

Establishes connection between source and target of the transition Processing differs for simple or composite states (as source and/or target) Each UML transition is represented by a CPN transition Special processing for concurrent constructs Use guards mechanism to guide the tokens in the CPN

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 15 / 21

slide-35
SLIDE 35

Translation of Concurrent State Machines André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 16 / 21

slide-36
SLIDE 36

Translation of Concurrent State Machines

Example (followed)

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 17 / 21

slide-37
SLIDE 37

Translation of Concurrent State Machines

Algorithm 3 - History pseudo-states

Take into account shallow pseudo-states Each history is represented by a global variable that contains the last state visited in the region and place/transition Variable value updated for each transition fired within a composite state Achieved with Algorithm 3 (not represented in the paper for lack

  • f space)

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 18 / 21

slide-38
SLIDE 38

Conclusion and Perspectives

Outline

1

Concepts (SMDs & CPNs)

2

Translation of Concurrent State Machines

3

Conclusion and Perspectives

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 19 / 21

slide-39
SLIDE 39

Conclusion and Perspectives

Element Considered? Simple / composite states Yes Orthogonal regions Yes Initial / final (pseudo)states Yes Terminate pseudostate No (but trivially extensible) Shallow history states Identical to [André et al., 2012] Deep history states No (but trivially extensible) Submachine states No (but trivially extensible) Entry / exit points No (but probably easy) Entry / exit / do behaviours Yes Shared variables Yes External / local / internal transitions Yes Basic fork / joins Yes Implicit fork/joins No (but trivially extensible) Choices / merges No (but probably easy) Deferred events No Timing aspects No

Table: Summary of the syntactic aspects considered

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 20 / 21

slide-40
SLIDE 40

Conclusion and Perspectives

Conclusion and Perspectives

Extended set of syntactic elements (including hierarchy & concurrency) taken into account Developing a tool for implementation of the translation

Translation using Acceleo (model to text tool) to implement the translation (done) Home-made tool using Java with parsers to manage the input and the output (partially done)

Integration of timed events Take into account real time specifications Prove the formal equivalence between an SMD and its CPN translation

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 21 / 21

slide-41
SLIDE 41

Bibliography

Bibliography

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 22 / 21

slide-42
SLIDE 42

Bibliography

References I

André, É., Choppy, C., and Klai, K. (2012). Formalizing non-concurrent UML state machines using colored Petri nets. ACM SIGSOFT Software Engineering Notes, 37(4):1–8. UML&FM 2012. Jensen, K. and Kristensen, L. M. (2009). Coloured Petri Nets – Modelling and Validation of Concurrent Systems. Springer. Liu, S., Liu, Y., André, É., Choppy, C., Sun, J., Wadhwa, B., and Dong, J. S. (2013). A formal semantics for the complete syntax of UML state machines with communications. In iFM, volume 7940 of Lecture Notes in Computer Science, pages 331–346. Springer. OMG (2011). OMG unified modeling language (OMG UML) superstructure. version 2.4.1, 2011-08-06. Petri, C. A. (1962). Kommunikation mit Automaten. PhD thesis, Darmstadt University of Technology, Germany.

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 23 / 21

slide-43
SLIDE 43

Bibliography

References II

Zhang, S. and Liu, Y. (2010). An automatic approach to model checking UML state machines. In SSIRI (Companion), pages 1–6. IEEE Computer Society.

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 24 / 21

slide-44
SLIDE 44

Explanation

Additional explanation

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 25 / 21

slide-45
SLIDE 45

Explanation

Explanation for the 4 pictures in the beginning

Allusion to the Northeast blackout (USA, 2003) Computer bug Consequences: 11 fatalities, huge cost (Picture actually from the Sandy Hurricane, 2012) Allusion to any plane crash (Picture actually from the happy-ending US Airways Flight 1549, 2009) Allusion to the sinking of the Sleipner A offshore platform (Norway, 1991) No fatalities Computer bug: inaccurate finite element analysis modeling (Picture actually from the Deepwater Horizon Offshore Drilling Platform) Allusion to the MIM-104 Patriot Missile Failure (Iraq, 1991) 28 fatalities, hundreds of injured Computer bug: software error (clock drift) (Picture of an actual MIM-104 Patriot Missile, though not the one of 1991)

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 26 / 21

slide-46
SLIDE 46

Licensing

Licensing

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 27 / 21

slide-47
SLIDE 47

Licensing

Source of the graphics used

Title: Hurricane Sandy Blackout New York Skyline Author: David Shankbone Source: https://commons.wikimedia.org/wiki/File:Hurricane_Sandy_Blackout_New_York_Skyline.JPG License: CC BY 3.0 Title: Miracle on the Hudson Author: Janis Krums (cropped by Étienne André) Source: https://secure.flickr.com/photos/davidwatts1978/3199405401/ License: CC BY 2.0 Title: Deepwater Horizon Offshore Drilling Platform on Fire Author: ideum Source: https://secure.flickr.com/photos/ideum/4711481781/ License: CC BY-SA 2.0 Title: DA-SC-88-01663 Author: imcomkorea Source: https://secure.flickr.com/photos/imcomkorea/3017886760/ License: CC BY-NC-ND 2.0

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 28 / 21

slide-48
SLIDE 48

Licensing

License of this document

This presentation can be published, reused and modified under the terms of the license Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)

(L

A

T EX source available on demand)

Authors: Étienne André and Mohamed Mahdi Benmoussa https://creativecommons.org/licenses/by-sa/3.0/

André, Benmoussa, Choppy (Paris13) Formalising UML State Machines Oct 10th, 2014 29 / 21