1 CS 501 Spring 2005 CS 501: Software Engineering Lecture 10 Requirements 4.

Slides:



Advertisements
Similar presentations
© Fachgebiet Softwaretechnik, Heinz Nixdorf Institut, Universität Paderborn 2.4 The Z Notation [Reference: M. Spivey: The Z Notation, Prentice Hall]
Advertisements

Semantics Static semantics Dynamic semantics attribute grammars
Modular Programming With Functions
CS 501: Software Engineering Fall 2000 Lecture 10 Formal Specification.
Algorithms and Problem Solving
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 17 JavaScript.
ISBN Chapter 3 Describing Syntax and Semantics.
CS 355 – Programming Languages
1 CS 501 Spring 2008 CS 501: Software Engineering Lecture 10 Requirements 3.
1 CS 501 Spring 2003 CS 501: Software Engineering Lecture 12 Requirements IV.
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
1 CS 501 Spring 2006 CS 501: Software Engineering Lecture 10 Requirements 4.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
1 CS 501 Spring 2007 CS 501: Software Engineering Lecture 10 Requirements 4.
C SC 520 Principles of Programming Languages 1 C SC 520: Principles of Programming Languages Peter J. Downey Department of Computer Science Spring 2006.
CS /29/2004 (Recitation Objectives) and Computer Science and Objects and Algorithms.
Describing Syntax and Semantics
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
CS CS 5150 Software Engineering Lecture 10 Requirements 3.
CS CS 5150 Software Engineering Lecture 10 Requirements 3.
1 CS 501 Spring 2006 CS 501: Software Engineering Lecture 9 Requirements 3.
Introduction to C language
The Fundamentals: Algorithms, the Integers & Matrices.
CHAPTER 1 GC 101 Introduction to computers and programs.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Cheng/Dillon-Software Engineering: Formal Methods Model Checking.
Computer Architecture Computational Models Ola Flygt V ä xj ö University
Course: Software Engineering © Alessandra RussoUnit 1 - Introduction, slide Number 1 Unit 1: Introduction Course: C525 Software Engineering Lecturer: Alessandra.
Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.
A Z Approach in Validating ORA-SS Data Models Scott Uk-Jin Lee Jing Sun Gillian Dobbie Yuan Fang Li.
Formal Methods and Models
1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II.
Introduction to Formal Methods Based on Jeannette M. Wing. A Specifier's Introduction to Formal Methods. IEEE Computer, 23(9):8-24, September,
CS CS 5150 Software Engineering Lecture 10 Requirements 3.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 9 Techniques for Requirements Definition and Specification I.
1 Software Design Reference: Software Engineering, by Ian Sommerville, Ch. 12 & 13, 5 th edition and Ch. 10, 6 th edition.
Input, Output, and Processing
Chapter 1 Introduction to Computers and C++ Programming Goals: To introduce the fundamental hardware and software components of a computer system To introduce.
1 CMPT 275 Software Engineering Requirements Gathering Activity Janice Regan,
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Modeling Shari L. Pfleeger and Joanne M. Atlee, Software Engineering: Theory and Practice, 4 th edition, Prentice Hall, Hans Van Vliet, Software.
Term 2, 2011 Week 1. CONTENTS Problem-solving methodology Programming and scripting languages – Programming languages Programming languages – Scripting.
© 2005 Prentice Hall9-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
CPS120: Introduction to Computer Science Operations Lecture 9.
Requirements Engineering Methods for Requirements Engineering Lecture-30.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
Chapter 3 Part II Describing Syntax and Semantics.
ECSE Software Engineering 1I HO 4 © HY 2012 Lecture 4 Formal Methods A Library System Specification (Continued) From Specification to Design.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
1 CS 501 Spring 2004 CS 501: Software Engineering Lecture 9 Requirements 3.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
1 Specification A broad term that means definition Used at different stages of software development for different purposes Generally, a statement of agreement.
CS 5150 Software Engineering Lecture 9 Requirements 3.
1 CS 501 Spring 2003 CS 501: Software Engineering Lecture 11 Requirements III.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Requirements Specification
Chapter 9: Value-Returning Functions
Types for Programs and Proofs
Formal Techniques (CS340 © John C. Knight 2004)
CS148 Introduction to Programming II
Algorithm Discovery and Design
CS 501: Software Engineering Fall 1999
CS 501: Software Engineering Fall 1999
Presentation transcript:

1 CS 501 Spring 2005 CS 501: Software Engineering Lecture 10 Requirements 4

2 CS 501 Spring 2005 Course Administration Presentations, March 9-10 Read the instructions on the Assignments web page Reserve a time slot by sending to Time slots are listed on the home page of the web site. First-come-first- served.

3 CS 501 Spring 2005 Formal Specification Why? Precise standard to define and validate software. Why not? May be time consuming Methods are not suitable for all applications

4 CS 501 Spring 2005 Remember Formal specification does not prescribe the implementation With formal specification it is possible, at least theoretically, to generate code automatically from the specification, but this may not be the most effective way: Writing the generator may be a very large programming task. The resulting code may perform badly. Formal specification does not guarantee correctness If the specification is wrong, the system will be wrong.

5 CS 501 Spring 2005 Formal Specification using Mathematical Notation Mathematical requirements can be specified formally. Example: requirements from a mathematical package: B 1, B 2,... B k is a sequence of m x m matrices  1,  2,...  k is a sequence of m x m elementary matrices B 1 -1 =  1 B 2 -1 =  2  1 B k -1 =  k...  2  1 The numerical accuracy must be such that, for all k, B k B k -1 - I < 

6 CS 501 Spring 2005 Formal Specification Using Diagrams digit unsigned integer digit. E + - unsigned integer unsigned number Example: Pascal number syntax

7 CS 501 Spring 2005 Formal Specification of Programming Languages ::= | ::= { } ::=. { } |. { } E | E ::= | ::= + | - Example: Pascal number syntax

8 CS 501 Spring 2005 Formal Specification using Z ("Zed") Z is a specification language developed by the Programming Research Group at Oxford University around Z is used for describing and modeling computing systems. It is based on axiomatic set theory and first order predicate logic. Ben Potter, Jane Sinclair, David Till, An Introduction to Formal Specification and Z (Prentice Hall) 1991 Jonathan Jacky The Way of Z (Cambridge University Press) 1997

9 CS 501 Spring 2005 Informal: The function intrt(a) returns the largest integer whose square is less than or equal to a. Formal (Z): intrt: N N a : N intrt(a) * intrt(a) < a < (intrt(a) + 1) * (intrt(a) + 1) Example: Specification using Z

10 CS 501 Spring 2005 Example: Implementation of intrt (2n - 1) = n 2 Static specification does not describe the design of the system. A possible algorithm uses the mathematical identity:

11 CS 501 Spring 2005 Example: Program for intrt int intrt (int a) /* Calculate integer square root */ { int i, term, sum; term = 1; sum = 1; for (i = 0; sum <= a; i++) { term = term + 2; sum = sum + term; } return i; }

12 CS 501 Spring 2005 Formal Specification of Finite State Machine Using Z A finite state machine is a broadly used method of formal specification: Event driven systems (e.g., games) User interfaces Protocol specification etc., etc.,...

13 CS 501 Spring 2005 State Transition Diagram Patients Fields SetupReady Beam on Enter Start Stop Select field Select patient (lock on) (lock off)

14 CS 501 Spring 2005 State Transition Table Select Patient Select Field Enter lock off StartStop lock on Patients Fields Setup Ready Beam on Fields Patients Setup Ready Beam on Ready

15 CS 501 Spring 2005 Z Specification STATE ::= patients | fields | setup | ready | beam_on EVENT ::= select_patient | select_field | enter | start | stop | lock_off | lock_on FSM == (STATE X EVENT) STATE no_change, transitions, control : FSM Continued on next slide

16 CS 501 Spring 2005 Z Specification (continued) control = no_change transitions no_change = { s : STATE; e : EVENT (s, e) s } transitions = { (patients, enter) fields, (fields, select_patient) patients, (fields, enter) setup, (setup, select_patient) patients, (setup, select_field) fields, (setup, lock_off) ready, (ready, select_patient) patients, (ready, select_field) fields, (ready, start) beam_on, (ready, lock_on) setup, (beam_on, stop) ready, (beam_on, lock_on) setup }

17 CS 501 Spring 2005 Schemas Schema: The basic unit of formal specification. Enables complex system to be specified as subsystems Describes admissible states and operations of a system.

18 CS 501 Spring 2005 LibSys: An Example of Z Library system: Stock of books. Registered users. Each copy of a book has a unique identifier. Some books on loan; other books on shelves available for loan. Maximum number of books that any user may have on loan.

19 CS 501 Spring 2005 LibSys: Operations Issue a copy of a book to a reader. Reader returns a book. Add a copy to the stock. Remove a copy from the stock. Inquire which books are on loan to a reader. Inquire which readers has a particular copy of a book. Register a new reader. Cancel a reader's registration.

20 CS 501 Spring 2005 LibSys: Modeling Formal Specifications are models. As with all models, it is necessary to decide what should be included and what can be left out. Level of detail Assume given sets: Copy, Book, Reader Global constant: maxloans

21 CS 501 Spring 2005 Domain and Range dom mXY x ran m y m : X Y dom m = { x  X :  y  Y  x y} ran m = { y  Y :  x  X  x y} m domain: range:

22 CS 501 Spring 2005 LibSys: Schema for Abstract States Library stock : Copy Book issued : Copy Reader shelved : F Copy readers: F Reader shelved  dom issued = dom stock shelved  dom issued = Ø ran issued  readers  r : readers #(issued  {r}) maxloans < finite subset Name Declaration part Predicate

23 CS 501 Spring 2005 Schema Inclusion LibDB stock : Copy Book readers: F Reader LibLoans issued : Copy Reader shelved : F Copy  r : Reader #(issued  {r}) maxloans shelved  dom issued = Ø <

24 CS 501 Spring 2005 Schema Inclusion (continued) Library LibDB LibLoans dom stock = shelved  dom issued ran issued  readers

25 CS 501 Spring 2005 Schemas Describing Operations Naming conventions for objects: Before: plain variables, e.g., r After: with appended dash, e.g., r' Input: with appended ?, e.g., r? Output: with appended !, e.g., r!

26 CS 501 Spring 2005 Operation: Issue a Book Inputs: copy c?, reader r? Copy must be shelved initially: c?  shelved Reader must be registered: r?  readers Reader must have less than maximum number of books on loan: #(issued  {r?}) < maxloans Copy must be recorded as issued to the reader: issued' = issued  {c? r?} The stock and the set of registered readers are unchanged: stock' = stock; readers' = readers

27 CS 501 Spring 2005 Operation: Issue a Book stock, stock' : Copy Book issued, issued' : Copy Reader shelved, shelved': F Copy readers, readers' : F Reader c?: Copy; r? :Reader [See next slide] Issue

28 CS 501 Spring 2005 Operation: Issue a Book (continued) [See previous slide] Issue shelved  dom issued = dom stock shelved'  dom issued' = dom stock' shelved  dom issued = Ø; shelved'  dom issued' = Ø ran issued  readers; ran issued'  readers'  r : readers  #(issued  {r}) maxloans  r : readers'  #(issued'  {r}) maxloans c?  shelved; r?  readers; #(issued  {r?}) < maxloans issued' = issued  {c? r?} stock' = stock; readers' = readers < <

29 CS 501 Spring 2005 Schema Decoration Issue Library Library' c? : Copy; r? : Reader c?  shelved; r?  readers #(issued  {r?}) < maxloans issued' = issued  {c? r?} stock' = stock; readers' = readers

30 CS 501 Spring 2005 Schema Decoration Issue  Library c? : Copy; r? : Reader c?  shelved; r?  readers #(issued  {r?}) < maxloans issued' = issued  {c? r?} stock' = stock; readers' = readers

31 CS 501 Spring 2005 The Schema Calculus Schema inclusion Schema decoration Schema disjunction: AddCopy AddKnownTitle  AddNewTitle Schema conjunction: AddCopy EnterNewCopy  AddCopyAdmin Schema negation Schema composition = ^ = ^

32 CS 501 Spring 2005 Z in Practice In carefully monitored industrial use, Z has been shown to improve the timeliness and accuracy of software development, yet it is widely used in practice.  Complexity of notation makes communication with client difficult.  Few software developers are comfortable with the underlying axiomatic approach.  Heavy notation is awkward to manipulate with conventional tools, such as word processors.