Presentation is loading. Please wait.

Presentation is loading. Please wait.

(State) Model-Based Approaches II Software Specification Lecture 36

Similar presentations


Presentation on theme: "(State) Model-Based Approaches II Software Specification Lecture 36"— Presentation transcript:

1 (State) Model-Based Approaches II Software Specification Lecture 36
Prepared by Stephen M. Thebaut, Ph.D. University of Florida

2 Specification using “Z”
Z is a mature and expressive notation for model-based specification. It combines formal and informal descriptions and incorporates graphical highlighting. The basic building blocks of Z-based specifications are schemas. Schemas identify state variables and define constraints and operations in terms of those variables. Software Engineering, 5th Edition. Chapter 11

3 Software Engineering, 5th Edition. Chapter 11
Schemas Schemas are comprised of three parts: name, signature, and predicate. The signature declares (state) entities introduced in a schema and their type. Signature declarations are given in the form identifier: type. The predicate defines logical relationships between entities in the declaration. Z is based on the predicate calculus + typed sets. Software Engineering, 5th Edition. Chapter 11

4 Graphical Layout of a Schema
Schema Name Signature Predicate Software Engineering, 5th Edition. Chapter 11

5 Software Engineering, 5th Edition. Chapter 11
Schemas (cont’d) Schemas describe state entities or operations on state entities. To describe state entities, declared variables comprise the entities while predicates specify their invariant properties. To describe operations, declarations consist of initial and final state variables, inputs, and outputs, while predicates specify the relations among them. Software Engineering, 5th Edition. Chapter 11

6 Software Engineering, 5th Edition. Chapter 11
Example 1 Specification of a generic container entity: Container contents: N capacity: N contents  capacity modeled as natural numbers invariant property Software Engineering, 5th Edition. Chapter 11

7 Software Engineering, 5th Edition. Chapter 11
Example 1 (cont’d) Specification of a generic indicator entity: Indicator light: {off, on} reading: N danger_level: N light = on  reading  danger_level Software Engineering, 5th Edition. Chapter 11

8 Software Engineering, 5th Edition. Chapter 11
Example 1 (cont’d) Specification of a storage tank entity: Storage_tank Container Indicator reading = contents capacity = 500 danger_level = 50 Predicates on separate lines are separated by an implicit “AND”. Software Engineering, 5th Edition. Chapter 11

9 Software Engineering, 5th Edition. Chapter 11
Example 1 (cont’d) Expanded specification of a storage tank entity: Storage_tank contents: N capacity: N light: {off, on} reading: N danger_level: N contents  capacity light = on  reading  danger_level reading = contents capacity = 500 danger_level = 50 Software Engineering, 5th Edition. Chapter 11

10 Software Engineering, 5th Edition. Chapter 11
Example 1 (cont’d) Specification of a nominal storage tank fill operation: Fill-OK  Storage-tank amount?: N contents + amount?  capacity contents’ = contents + amount? “dash” indicates the value of contents AFTER the operation “?” indicates that amount is an INPUT. “Delta” indicates that values of one or more variables will be changed. Software Engineering, 5th Edition. Chapter 11

11 Software Engineering, 5th Edition. Chapter 11
Example 1 (cont’d) Specification of an exceptional storage tank fill operation: OverFill  Storage-tank amount?: N r!: seq CHAR capacity < contents + amount? r! = “Insufficient tank capacity – Fill cancelled” “Xi” indicates that NO variables will be changed by the operation. “!” indicates that r is an OUTPUT. Software Engineering, 5th Edition. Chapter 11

12 Software Engineering, 5th Edition. Chapter 11
Example 1 (cont’d) Complete specification of the storage tank fill operation: Fill Fill-OK V OverFill Software Engineering, 5th Edition. Chapter 11

13 G Kontoya and I. Sommerville 1998
Example 2 Specification of a simple Library system: Library stock:  Book onLoan: Book  Borrower dom onLoan  stock “Powerset Book”: the set of sets of books set of books held by library books on loan are a subset of existing stock set of (book, borrower) pairs Each book on loan is mapped to a borrower. Note use of typed sets. G Kontoya and I. Sommerville 1998

14 G Kontoya and I. Sommerville 1998
Example 2 (cont’d) Specification of the borrow operation: Borrow  Library book?: Book reader?: Borrower book?  stock book?  dom onLoan onLoan’ = onLoan  {(book?, reader?)} stock’ = stock G Kontoya and I. Sommerville 1998

15 G Kontoya and I. Sommerville 1998
Example 2 (cont’d) Operation for adding a new book to current stock: New  Library book?: Book stock’ = stock  {book?} onLoan’ = onLoan G Kontoya and I. Sommerville 1998

16 G Kontoya and I. Sommerville 1998
Example 2 (cont’d) Operation for returning a book to the library: Return  Library book?: Book book?  dom onLoan dom onLoan’ = dom onLoan  book? stock’ = stock “Overriding” operator G Kontoya and I. Sommerville 1998

17 Software Engineering, 5th Edition. Chapter 11
Exercise 4 Modify the storage tank specification by adding a fill warning light which indicates when the tank is close to capacity. This should be switched on when the contents are some high percentage of the capacity. Software Engineering, 5th Edition. Chapter 11

18 Software Engineering, 5th Edition. Chapter 11
Key Points Model-based specification relies on a state model of the system using mathematical entities such as the predicate calculus and typed sets. Functions / operations may be specified by defining their effect on system state. Software Engineering, 5th Edition. Chapter 11

19 Software Engineering, 5th Edition. Chapter 11
Key Points (cont’d) It is normal to specify functions / operations incrementally and then combine the fragments to produce a complete specification. Z specifications are comprised of a number of schemas that introduce typed names and define predicates over those names. They are distinguished from surrounding text by graphical highlighting. Software Engineering, 5th Edition. Chapter 11

20 Software Engineering, 5th Edition. Chapter 11
Key Points (cont’d) Schemas are building blocks which may be combined and used in other schemas. The effect of including schema A in schema B is that schema B inherits the names and predicates of schema A. Software Engineering, 5th Edition. Chapter 11

21 (State) Model-Based Approaches II Software Specification Lecture 36
Prepared by Stephen M. Thebaut, Ph.D. University of Florida


Download ppt "(State) Model-Based Approaches II Software Specification Lecture 36"

Similar presentations


Ads by Google