School of Technology 1 Z: Operations on Schemas David Lightfoot based on work of Andrew Simpson.

Slides:



Advertisements
Similar presentations
Formal Methods in Software Engineering
Advertisements

Relational Database Design Via ER Modelling
If R = {(x,y)| y = 3x + 2}, then R -1 = (1) x = 3y + 2 (2) y = (x – 2)/3 (3) {(x,y)| y = 3x + 2} (4) {(x,y)| y = (x – 2)/3} (5) {(x,y)| y – 2 = 3x} (6)
CS 501: Software Engineering Fall 2000 Lecture 10 Formal Specification.
The Z Specification Language
Winter 2007SEG2101 Chapter 41 Chapter 4 SDL – Structure and Behavior.
1 CS 501 Spring 2003 CS 501: Software Engineering Lecture 12 Requirements IV.
Software Testing and Quality Assurance
Schema Operators. State We can use the language of schemas to describe the state of a system, and operations upon it. Different aspects of the state --
1 Z Schemas Chapter 7 Formal Specification using Z Example of Z specification Document.
1 CS 501 Spring 2005 CS 501: Software Engineering Lecture 10 Requirements 4.
Promotion. Promotion is a structuring technique that may be used whenever the state of a system contains multiple, indexed instances of the same component.
The Schema Calculus. Schemas A notation specifying both system states and operations One way: S = [ declarations | predicate ] Means: The state components.
Schema Operators. State We can use the language of schemas to describe the state of a system, and operations upon it. Different aspects of the state --
An Introduction to formal methods using Z An aircraft example
Software Engineering Principles and C++ Classes
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
1 Z Schemas Chapter 6 Formal Specification using Z.
13 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
10 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 10 Slide 1 Formal Specification.
22 March 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
©Ian Sommerville 2000Software Engineering, 6th edition. Chapter 9 Slide 1 Formal Specification l Techniques for the unambiguous specification of software.
Software Engineering Chapter 8 Fall Analysis Extension of use cases, use cases are converted into a more formal description of the system.Extension.
Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.
Chapter 9 Designing Databases Modern Systems Analysis and Design Sixth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
A Z Approach in Validating ORA-SS Data Models Scott Uk-Jin Lee Jing Sun Gillian Dobbie Yuan Fang Li.
1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II.
Model-Based Specification CIS 376 Bruce R. Maxim UM-Dearborn.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean.
17 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
Course: Software Engineering ©Alessandra RussoUnit 2: States and Operations, slide number 1 States and Operations This unit aims to:  Define: State schemas.
7 Systems Analysis and Design in a Changing World, Fifth Edition.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
1 Relational Algebra Chapter 4, Sections 4.1 – 4.2.
Thinking Mathematically
Notes on: Is Proof More Cost- Effective Than Testing? by Steve King, Jonathan Hammond, Rob Chapman, Andy Pryor Prepared by Stephen M. Thebaut, Ph.D. University.
Software Engineering 2 -Prakash Shrestha.
1 Abstract Model Specification. 2 Explicitly describes behavior in terms of a model using well-defined types (viz. set, sequences, relations, functions)
1 Requirements Specification and Verification Using Z A. Rasoolzadegan July, 2009 AUT CEIT.
Z-Notation. Abstract Model Specification Explicitly describes behavior in terms of a model using well-defined types (sets, sequences, relations, functions)
The Z Specification Language Based on J. M. Spivey. An Introduction to Z and formal specifications, Software Engineering Journal, 4(1):40-50, January,
Chapter 1 Propositional Logic
Truth Table to Statement Form
Relational Database Design by ER- and EER-to- Relational Mapping
Chapter 8 Advanced Interaction Modeling
Thinking Mathematically
Chapter 7: Entity-Relationship Model
A Survey of Object Orientation in Z
(State) Model-Based Approaches II Software Specification Lecture 36
B (The language of B-Method )
Relational Algebra Chapter 4, Part A
Applications of Propositional Logic
Module 8 – Database Design Using the E-R Model
X-STANDARD MATHEMATICS ONE MARK QUESTIONS
CHAPTER 12 Retail Merchandising Individual Series Event
Relational Algebra Chapter 4, Sections 4.1 – 4.2
Function Notation “f of x” Input = x Output = f(x) = y.
CS 220: Discrete Structures and their Applications
Chapter 1 Introduction(1.1)
1-7 Function Notation Aim: To write functions using function notation.
Department of Computer Science
Design Yaodong Bi.
SECTION 4: OO METHODOLOGIES
Chapter 6b: Database Design Using the E-R Model
CS 501: Software Engineering Fall 1999
Presentation transcript:

School of Technology 1 Z: Operations on Schemas David Lightfoot based on work of Andrew Simpson

2 School of Technology Reference Using Z: Specification, Refinement, and Proof, Jim Woodcock and Jim Davies, Prentice-Hall, 1996 (Chapter 11)

3 School of Technology Agenda Operation schemas Input and output Initialisation schemas Schema disjunction Schema conjunction Schema negation

4 School of Technology The schema language The schema language is used to structure and compose mathematical descriptions of systems It collates pieces of information, encapsulates them, and names them for re-use It is the second component of the Z notation; the first is the mathematical language

5 School of Technology Change of state To describe the effect of an operation, we consider two copies of the state schema: one describing the state before, the other describing the state afterwards An operation schema describes the relationship between the two states The inclusion of two copies of the state ensures that the constraint part of the state schema (the state invariant) is preserved

6 School of Technology Operation schemas An operation schema includes two copies of the corresponding state schema:  Operation  ®State   …  We use the undecorated state to represent the state before the operation and the primed state to represent the state afterwards

7 School of Technology Example  Purchase 0  ®BoxOffice ®…  ®s?  seating \ dom sold ®sold = sold  {s?  c?} ®seating = seating 

8 School of Technology Input and output An operation may involve inputs and outputs These are declared in the normal way, although there is a convention regarding their names: the name of an input must end in a question mark ? the name of an output must end in an exclamation mark !

9 School of Technology Example  Operation  ®State ®i?: I ®o!: O  ®… 

10 School of Technology Example  Purchase 0  ®BoxOffice ®s?: Seat ®c?: Customer  ®s?  seating \ dom sold ®sold = sold  {s?  c?} ®seating = seating 

11 School of Technology  (Delta) and  (Xi) There is another convention regarding operation schemas: if a schema describes an operation upon a state described by S, we include  S (‘delta S’)in its declaration (in place of S and S) if, in addition, the operation leaves the state unchanged we include  S (in place of  S)

12 School of Technology Example  Purchase 0  ®  BoxOffice ®s?: Seat ®c?: Customer  ®s?  seating \ dom sold ®sold = sold  {s?  c?} ®seating = seating 

13 School of Technology Example An operation that leaves the state of the box office unchanged:  QueryAvailability  ®  BoxOffice ®available!:   ®available! = # (seating \ dom sold) 

14 School of Technology Initialisation An initialisation is a special operation for which the before state is unimportant Such an operation can be modelled by an operation schema that contains only a decorated copy of the state:  StateInit  ®State  ®… 

15 School of Technology Question How might we complete the following?  BoxOfficeInit  ®BoxOffice ®allocation?:  Seat  ®… 

16 School of Technology BoxOfficeInit  BoxOfficeInit  ®BoxOffice ®allocation?:  Seat  ®seating = allocation? ®sold =  

17 School of Technology Schema disjunction If S and T are two schemas then their disjunction, S  T is also a schema in which the declaration is a merging of the two declarations in which the constraint is a disjunction (‘oring’) of the two constraints

18 School of Technology Schema conjunction If S and T are two schemas then their conjunction, S  T is also a schema in which the declaration is a merging of the two declarations in which the constraint is a disjunction (‘anding’) of the two constraints

19 School of Technology Schema negation If S is a schema then its negation,  S is also a schema in which the declaration the same as that of S in which the constraint is the negation (‘noting’) of the constraint of S

20 School of Technology Examples  S  ®a: A ®b: B  ®P   T  ®b: B ®c: C  ®Q  S  T is equivalent to:  ®a: A ®b: B ®c: C  ®P  Q  S  T is equivalent to:  ®a: A ®b: B ®c: C  ®P  Q 

21 School of Technology Examples  S  ®a: A ®b: B  ®P   S is equivalent to:  ®a: A ®b: B  ®  P 

22 School of Technology Example If we define:  NotAvailable  ®  BoxOffice ® s?: Seat  ®s?  seating \ dom sold  then the schema disjunction Purchase 0  NotAvailable describes a total operation

23 School of Technology Constructing operations Although disjunction is the obvious operator for constructing operation schemas, conjunction can also be useful Response ::= okay | sorry  Success  ®r!: Response  ®r! = okay   Failure  ®r!: Response  ®r! = sorry 

24 School of Technology Total operation The operation of purchasing a seat may be described by: Purchase  (Purchase 0  Success)  (NotAvailable  Failure)

25 School of Technology Question How might we complete the following operation?  ReturnTicket 0  ®  BoxOffice ®s?: Seat ®c?: Customer  ®… 

26 School of Technology ReturnTicket 0  ReturnTicket 0  ®  BoxOffice ®s?: Seat ®c?: Customer  ®s?  c?  sold ®sold = sold \ {s?  c?} ®seating = seating 

27 School of Technology Question How might we complete the following operation?  ReturnNotPossible  ®  BoxOffice ®s?: Seat ®c?: Customer  ®… 

28 School of Technology ReturnNotPossible  ReturnNotPossible  ®  BoxOffice ®s?: Seat ®c?: Customer  ®s?  c?  sold 

29 School of Technology Summary We may use operation schemas to describe the effect of operations on the state of our system The inclusion of  S in an operation schema denotes that the operation will change the state of S The inclusion of  S indicates that the operation is concerned with the state of S, but will leave it unchanged Operation schemas may have input and output An initialisation schema describes the state of our system at the beginning of its life Disjunction and conjunction may be used to combine operation schemas