1 Statecharts for the many: Algebraic State Transition Diagrams Marc Frappier GRIL – Groupe de recherche en ingénierie du logiciel.

Slides:



Advertisements
Similar presentations
State Charts Mehran Najafi. Reactive Systems A reactive, event-driven, object is one whose behavior is best characterized by its response to events dispatched.
Advertisements

Modeling Main issues: What do we want to build How do we write this down.
Component Oriented Programming 1 Chapter 2 Theory of Components.
Marc Geilen, Eindhoven University of Technology, Information and Communication Systems 1 Object-Oriented Modelling and Specification.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
CS 290C: Formal Models for Web Software Lecture 4: Implementing and Verifying Statecharts Specifications Using the Spin Model Checker Instructor: Tevfik.
Modeling Main issues: What do we want to build How do we write this down ©2008 John Wiley & Sons Ltd. vliet.
Technische universiteit eindhoven 25 September 2002www.ics.ele.tue.nl/~btheelen1 Using the SHE Method for UML-based Performance Modelling B.D. Theelen.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 8 Slide 1 System modeling 2.
ISBN Chapter 3 Describing Syntax and Semantics.
5/24/2015CPSC , CPSC , Lecture 71 Software Engineering, CPSC , CPSC , Lecture 7.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 8 Slide 1 System models.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Software Development Software Life Cycle UML Diagrams.
CS 425/625 Software Engineering System Models
Essentials of state and activity diagram Lecture 24.
System behaviors: state machine diagrams
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 8 Slide 1 System models.
Nov 2002 R. McFadyen1 Statechart Diagrams - Ch 29 Example: Suppose we have a class Copy, representing copies of books. We can consider two states:
Describing Syntax and Semantics
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
Basic Concepts The Unified Modeling Language (UML) SYSC System Analysis and Design.
Lecture 4 Finite State Machine CS6133 Software Specification and Verification.
Systems Analysis and Design in a Changing World, Fifth Edition
程建群 博士(Dr. Jason Cheng) 年03月
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 7 Slide 1 System models l Abstract descriptions of systems whose requirements are being.
Chapter 4 System Models A description of the various models that can be used to specify software systems.
System models Abstract descriptions of systems whose requirements are being analysed Abstract descriptions of systems whose requirements are being analysed.
AToM 3 : A Tool for Multi- Formalism and Meta-Modelling Juan de Lara (1,2) Hans Vangheluwe (2) (1) ETS Informática Universidad Autónoma de Madrid Madrid,
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
©Ian Sommerville 1995/2000 (Modified by Spiros Mancoridis 1999) Software Engineering, 6th edition. Chapter 7 Slide 1 System models l Abstract descriptions.
SDS Foil no 1 Process Algebra Process Algebra – calculating with behaviours.
Grammars CPSC 5135.
Chapter 7 System models.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
System models l Abstract descriptions of systems whose requirements are being analysed.
Modified by Juan M. Gomez Software Engineering, 6th edition. Chapter 7 Slide 1 Chapter 7 System Models.
Sommerville 2004,Mejia-Alvarez 2009Software Engineering, 7th edition. Chapter 8 Slide 1 System models.
UML-1 3. Capturing Requirements and Use Case Model.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
Software Engineering Lecture 10 UML vs. ERD.
Requirements Engineering Methods for Requirements Engineering Lecture-30.
1 Qualitative Reasoning of Distributed Object Design Nima Kaveh & Wolfgang Emmerich Software Systems Engineering Dept. Computer Science University College.
Sept Tracing Status Update - Sept Montreal - Timothy Lethbridge Trace-Directed Modelling Status Update Timothy C. Lethbridge University.
Internet Security CSCE 813 Communicating Sequential Processes.
1 Kyung Hee University Diagram Editor : Design View Spring 2001.
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
Introduction to UML CS A470. What is UML? Unified Modeling Language –OMG Standard, Object Management Group –Based on work from Booch, Rumbaugh, Jacobson.
OMT Modeling 1. Object Model : presented by the object model and the data dictionary. 2. Dynamic Model: presented by the state diagrams and event flow.
CS3773 Software Engineering Lecture 06 UML State Machines.
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
1/33 Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
Chapter 3: Introducing the UML
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 6: Restaurant.
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
1 SWE Introduction to Software Engineering Lecture 14 – System Modeling.
Class Diagrams Revisited. Parameterized Classes Parameterized Classes - are used to represent relationships between templates.
March 2007ACS-3913 R. McFadyen1 UML Statechart Diagram A UML Statechart Diagram describes states for an object how/why an objects’ state changes A Statechart.
Internet Security CSCE 813 Communicating Sequential Processes.
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation
Evolution of UML.
Main issues: • What do we want to build • How do we write this down
Advanced state modeling
State Machine Diagrams
Abstract descriptions of systems whose requirements are being analysed
Chapter 20 Object-Oriented Analysis and Design
Advanced state modeling
Object Life Cycles: FSMs
Presentation transcript:

1 Statecharts for the many: Algebraic State Transition Diagrams Marc Frappier GRIL – Groupe de recherche en ingénierie du logiciel

2 Plan Statecharts and information system specifications Statecharts and information system specifications ASTD : Algebraic State Transition Diagrams ASTD : Algebraic State Transition Diagrams Semantics of ASTD Semantics of ASTD Conclusion Conclusion

3 Statecharts graphical notation graphical notation hierarchy + orthogonality hierarchy + orthogonality hierarchical states hierarchical states AND states (parallel) AND states (parallel) OR states (choice) OR states (choice) nice for single instance behaviour nice for single instance behaviour parameterized states in Harel’s seminal paper (SCP 87) parameterized states in Harel’s seminal paper (SCP 87) “never” implemented or formalised “never” implemented or formalised

4 A library in statecharts

5 Problems only describes behaviour of a single book only describes behaviour of a single book how to deal with several books? how to deal with several books? put n copies of book in parallel put n copies of book in parallel not defined in statecharts or UML not defined in statecharts or UML available in ROSE RT, but it is not quite what we want here available in ROSE RT, but it is not quite what we want here can discard an unreturned book can discard an unreturned book could add a guard to discard could add a guard to discard unnecessary complexity unnecessary complexity could make discard a transition from an inner state of loan could make discard a transition from an inner state of loan introduce coupling between book and loan introduce coupling between book and loan

6 Potential solutions book knows about the structure of loan book knows about the structure of loan makes loan less reusable makes loan less reusable makes maintenance more difficult makes maintenance more difficult

7 Adding members

8 Problems a member can borrow several books in parallel a member can borrow several books in parallel can’t “easily” express that in statecharts or UML can’t “easily” express that in statecharts or UML State explosion State explosion two calls to loan two calls to loan one in member, one in book one in member, one in book they both get the lend event they both get the lend event OK if only one member OK if only one member KO if we have several members trying to borrow the same book KO if we have several members trying to borrow the same book could remove loan from member could remove loan from member must add guard to Unregister to check for completed loan must add guard to Unregister to check for completed loan loose visual ordering constraint loose visual ordering constraint

9 Potential solutions remove loan from member remove loan from member loose visual ordering constraint between member and loan loose visual ordering constraint between member and loan replaced by a guard replaced by a guard need state variable need state variable

10 The single instance view: A weakness of statecharts both statecharts and UML state machines are designed to represent a single instance both statecharts and UML state machines are designed to represent a single instance eg, controller, object of a class, etc eg, controller, object of a class, etc they offer no convenient means to express relationships between multiple instances they offer no convenient means to express relationships between multiple instances in practice, designers only describe the single instance behaviour in practice, designers only describe the single instance behaviour leave it to the implementer to figure out the multiple instance case leave it to the implementer to figure out the multiple instance case

11 A solution: Process algebra CCS, CSP, ACP, LOTOS, EB 3,... CCS, CSP, ACP, LOTOS, EB 3,... algebra algebra operators to combine process expressions operators to combine process expressions sequence, choice, interleave, synchronisation, guard,... sequence, choice, interleave, synchronisation, guard,... quantification quantification operators are the essence of abstraction operators are the essence of abstraction combine small units to build large units combine small units to build large units operators foster abstraction by masking internal details operators foster abstraction by masking internal details

12 A Process expression for books book(b : BookId ) = Acquire(b,_) loan( _, b)  Discard(b) Sequential composition Kleene closure matches any value

13 A process expression for loans loan(mId:Member, IDbId:BookID ) = nbLoans(mId) < maxNbLoans(mId)  Lend(mId, bId) Renew(bId)  Return(bId) guard

14 A process expression for members member(m : MemberId ) = Register(m, _, _) (  b : BookId : loan( m, b)  ) Unregister(m) interleave quantification over all books

15 Interleave quantification  x : {1,2,3} : P(x) = P(1)  P(2)  P(3)

16 Main process expression main = (  b : BookId : book(b)  )  (  m : MemberId : member(m)  ) Synchronisation over common actions

17 Synchronisation over common actions a(1) b(1) c(1)  |x : T : a(x) b(x) c(2) = a(1) b(1) STOP quantified choice

18 ASTD Algebraic State Transition Diagrams Algebraic State Transition Diagrams ASTD = statecharts + process algebra ASTD = statecharts + process algebra graphical notation graphical notation power of abstraction power of abstraction statecharts become elementary process expressions statecharts become elementary process expressions combine them using operators combine them using operators formal semantics formal semantics operational semantics operational semantics

19 ASTD Operators : sequence  : sequence | : choice | : choice |x : quantified choice |x : quantified choice : Kleene closure  : Kleene closure : guard  : guard |[ A ]| : parallel composition with synchronisation on A |[ A ]| : parallel composition with synchronisation on A interleave, parallel composition  interleave,  parallel composition  x, |[ ]| x : quantified version ASTD call : allows recursive calls ASTD call : allows recursive calls

20 A book ASTD final state operators applied from left to right initial state final transition: can trigger only if its source is in a final state

21 Closure applied to an ASTD  means execute the ASTD an arbitrary number of times, including 0 when the ASTD is in a final state, it can start again from its initial state example traces are empty trace e1,e2,e2,...,e1,e1,e2,...

22 The closure ASTD type  denotes the type constructor for a closure body is an ASTD (of any type) ( , body )

23 The closure state type  ০ is the closure state type constructor started? is a boolean value that indicates if its component has started its first iteration s is the state of its component (  ০,started?, s )

24 States of a closure initial state initial state is the initial state of its component is the initial state of its component final states final states its initial state its initial state final states of its component final states of its component function that defines the initial state of an ASTD closure ASTDclosure initial state function that determines if a state is final

25 Final state an ASTD does not terminate when its current state is final an ASTD does not terminate when its current state is final a final state simply enables transitions of another ASTD within a a final state simply enables transitions of another ASTD within a closure closure sequence sequence

26 A member ASTD

27 A loan ASTD

28 The main ASTD n-ary operator operands of ||

29 Power of abstraction suppose you have two statecharts, a and b suppose you have two statecharts, a and b you want to compose them as follows you want to compose them as follows execute a an arbitrary number of times execute a an arbitrary number of times then execute b an arbitrary number of times then execute b an arbitrary number of times then start over again, an arbitrary number of times then start over again, an arbitrary number of times can’t do it in statecharts without peeking into a and b ’s structure with guards can’t do it in statecharts without peeking into a and b ’s structure with guards introduce a dependency between the compound and the components introduce a dependency between the compound and the components

30 Power of abstraction sequential composition

31 The sequence ASTD type  denotes the sequence ASTD type constructor left and right are ASTDs ( , left, right)

32 The sequence state type  ০ denotes the sequence state type constructor side denotes the current side of the sequence left right s denotes the state of the side component (  ০, side, s)

33 State transitions (  ০, left, 1) (  ০, left, 2) (  ০, right, 4)

34 State transitions (  ০, left, 1) (  ০, left, 2)

35 State transitions (  ০, left, (  ০,  started, 1)) (  ০, right, (  ০,started, 4)) (  ০, right, ( ,started, 4))

36 Initial and final states of a sequence ASTD

37 Operational semantics first used by Milner for CCS first used by Milner for CCS transitions transitions ASTD a can execute  from state s and move to state s’ ASTD a can execute  from state s and move to state s’

38 Operational semantics transitions defined by a set of inference rules transitions defined by a set of inference rules rules for each operator rules for each operator allows non-determinism allows non-determinism if several transitions can fire from s, then one is nondeterministically chosen if several transitions can fire from s, then one is nondeterministically chosen no priority no priority

39 Inference rules first rules deals with environment, noted ([ ]), to manage variables introduced by first rules deals with environment, noted ([ ]), to manage variables introduced by quantifications quantifications process parameters process parameters

40 Automaton inference rules execute an automaton transition similar to traditional  of an automaton execute a transition of the component

41 Closure inference rules execute from the initial state of the component execute the component when started

42 Sequence inference rules execute on left execute on right when left is final execute the right component

43 Choice: initial and final states Choice state (| ০, side, s )

44 Choice inference rules execute the first component from its initial state execute the second component from its initial state execute the first component when it has been selected execute the second component when it has been selected

45 Choice example (| ০, ,  ) e1 e2 e3 e4 (| ০, fst, 2 ) (| ০, fst, 3 ) (| ০, snd, 5 ) (| ০, snd, 6 )

46 Integration with the business class diagram bookmember Register Unregister Lend Renew Return Acquire Discard ListBook loan bookId title memberId name nbLoans maxNbLoans date 1 * borrower

47 State variables the system trace is the only state variable the system trace is the only state variable entity attributes are functions on this trace entity attributes are functions on this trace attributes can be used anywhere in ASTDs attributes can be used anywhere in ASTDs guard, quantification sets,... guard, quantification sets,... nbLoans(mId : MemberId) = Register(mId, _ ) : 0, Register(mId, _ ) : 0, Lend(mId, _) : 1 + nbLoans(mId), Lend(mId, _) : 1 + nbLoans(mId), Return(bId) : if borrower(bId) = mId Return(bId) : if borrower(bId) = mId then nbLoans(mId) - 1, then nbLoans(mId) - 1, Unregister(mId, _ ) :  ; Unregister(mId, _ ) :  ;

48 Conclusion process algebra operators can improve the expressiveness of statecharts process algebra operators can improve the expressiveness of statecharts complete, precise models of information systems complete, precise models of information systems not just single instance scenarios, but also multiple instance scenarios not just single instance scenarios, but also multiple instance scenarios future work future work tools for animation tools for animation model checking model checking code generation code generation