1 cs 501 spring 2002 cs 501: software engineering lecture 10 techniques for requirements definition...
TRANSCRIPT
![Page 1: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/1.jpg)
1 CS 501 Spring 2002
CS 501: Software Engineering
Lecture 10
Techniques for Requirements Definition and Specification II
![Page 2: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/2.jpg)
2 CS 501 Spring 2002
Administration
![Page 3: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/3.jpg)
3 CS 501 Spring 2002
Formal Specification
Why?
Precise standard to define and validate software.
Why not?
May be time consuming
Methods are not suitable for all applications
![Page 4: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/4.jpg)
4 CS 501 Spring 2002
Formal Specification using Mathematical Notation
Example:
B1, B2, ... Bk is a sequence of m x m matrices
1, 2, ... k is a sequence of m x m elementary matrices
B1-1 = 1
B2-1 = 21
Bk-1 = k ... 21
The numerical accuracy must be such that, for all k,
BkBk-1 - I <
![Page 5: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/5.jpg)
5 CS 501 Spring 2002
Formal Specification Using Diagrams
digitunsigned integer
digit. E
+
-
unsigned integerunsigned integer
unsigned number
Pascal number syntax
![Page 6: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/6.jpg)
6 CS 501 Spring 2002
Formal Specification of Programming Languages
<unsigned number> ::= <unsigned integer> | <unsigned real>
<unsigned integer> ::= <digit> {<digit>}
<unsigned real> ::= <unsigned integer> . <digit> {<digit>} | <unsigned integer> . <digit> {<digit>} E <scale factor> | <unsigned integer> E <scale factor>
<scale factor> ::= <unsigned integer> | <sign> <unsigned integer>
<sign> ::= + | -
Pascal number syntax
![Page 7: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/7.jpg)
7 CS 501 Spring 2002
Formal Specification using Z ("Zed")
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
![Page 8: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/8.jpg)
8 CS 501 Spring 2002
Two Rules
Formal specification does not guarantee correctness
Formal specification does not prescribe the implementation
![Page 9: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/9.jpg)
9 CS 501 Spring 2002
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
![Page 10: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/10.jpg)
10 CS 501 Spring 2002
Example: Algorithm
1 + 3 + 5 + ... (2n - 1) = n2
Static specification does not describe the design of the system.
A possible algorithm uses the mathematical identity:
![Page 11: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/11.jpg)
11 CS 501 Spring 2002
Example: Program
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;}
![Page 12: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/12.jpg)
12 CS 501 Spring 2002
Formal Specification Using Finite State Machine
A broadly used method of formal specification:
Event driven systems (e.g., games)
User interfaces
Protocol specification
etc., etc., ...
![Page 13: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/13.jpg)
13 CS 501 Spring 2002
Finite State Machine
Example:
Therapy control console
[informal description]
![Page 14: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/14.jpg)
14 CS 501 Spring 2002
State Transition Diagram
Patients Fields Setup ReadyBeam
on
Enter Enter Start
Stop
Select field
Select patient(interlock)
(ok)
![Page 15: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/15.jpg)
15 CS 501 Spring 2002
State Transition Table
SelectPatient
SelectField
Enter ok Start Stop interlock
Patients
Fields
Setup
Ready
Beamon
Fields
Fields
Fields
Patients
Patients
Patients
Setup
Setup
Setup
Ready
Beamon
Ready
![Page 16: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/16.jpg)
16 CS 501 Spring 2002
Z Specification
STATE ::= patients | fields | setup | ready | beam_on
EVENT ::= select_patient | select_field | enter | start | stop | ok | interlock
FSM == (STATE X EVENT) STATE
no_change, transitions, control : FSM
Continued on next slide
![Page 17: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/17.jpg)
17 CS 501 Spring 2002
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, ok) ready,
(ready, select_patient) patients, (ready, select_field) fields, (ready, start) beam_on, (ready, interlock) setup,
(beam_on, stop) ready, (beam_on, interlock) setup }
![Page 18: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/18.jpg)
18 CS 501 Spring 2002
Schemas
Schema:
Enables complex system to be specifed as subsystems
The basic unit of formal specification.
Describes admissible states and operations of a system.
![Page 19: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/19.jpg)
19 CS 501 Spring 2002
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.
![Page 20: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/20.jpg)
20 CS 501 Spring 2002
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.
![Page 21: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/21.jpg)
21 CS 501 Spring 2002
LibSys
Level of Detail:
Assume given sets:
Copy, Book, Reader
Global constant:
maxloans
![Page 22: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/22.jpg)
22 CS 501 Spring 2002
Domain and Range
dom mX Yx
ran my
m : X Y
dom m = { x X : y Y x y}
ran m = { y Y : x X x y}
m
domain:
range:
![Page 23: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/23.jpg)
23 CS 501 Spring 2002
LibSys: Schema for Abstract States
Library
stock : Copy Bookissued : Copy Readershelved : F Copyreaders: F Reader
shelved dom issued = dom stockshelved dom issued = Øran issued readersr : readers • #(issued {r}) maxloans<
![Page 24: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/24.jpg)
24 CS 501 Spring 2002
Schema Inclusion
LibDB
stock : Copy Bookreaders: F Reader
LibLoansissued : Copy Readershelved : F Copy
r : Reader • #(issued {r}) maxloansshelved dom issued = Ø
<
![Page 25: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/25.jpg)
25 CS 501 Spring 2002
Schema Inclusion (continued)
Library
LibDBLibLoans
dom stock = shelved dom issuedran issued readers
![Page 26: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/26.jpg)
26 CS 501 Spring 2002
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!
![Page 27: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/27.jpg)
27 CS 501 Spring 2002
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
![Page 28: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/28.jpg)
28 CS 501 Spring 2002
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
![Page 29: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/29.jpg)
29 CS 501 Spring 2002
Operation: Issue a Book (continued)
[See previous slide]
Issue
shelved dom issued = dom stockshelved' dom issued' = dom stock'shelved dom issued = Ø; shelved' dom issued' = Øran issued readers; ran issued' readers'r : readers #(issued {r}) maxloansr : readers' #(issued' {r}) maxloansc? shelved; r? readers; #(issued {r?}) < maxloansissued' = issued {c? r?}stock' = stock; readers' = readers
<<
![Page 30: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/30.jpg)
30 CS 501 Spring 2002
Schema Decoration
Issue
LibraryLibrary'c? : Copy; r? : Reader
c? shelved; r? readers#(issued {r?}) < maxloansissued' = issued {c? r?}stock' = stock; readers' = readers
![Page 31: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/31.jpg)
31 CS 501 Spring 2002
Schema Decoration
Issue
Libraryc? : Copy; r? : Reader
c? shelved; r? readers#(issued {r?}) < maxloansissued' = issued {c? r?}stock' = stock; readers' = readers
![Page 32: 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 10 Techniques for Requirements Definition and Specification II](https://reader035.vdocument.in/reader035/viewer/2022062304/56649e915503460f94b975b7/html5/thumbnails/32.jpg)
32 CS 501 Spring 2002
The Schema Calculus
Schema inclusion
Schema decoration
Schema disjunction:
AddCopy AddKnownTitle AddNewTitle
Schema conjunction:
AddCopy EnterNewCopy AddCopyAdmin
Schema negation
Schema composition
=̂
=̂