Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 501: Software Engineering Fall 1999

Similar presentations


Presentation on theme: "CS 501: Software Engineering Fall 1999"— Presentation transcript:

1 CS 501: Software Engineering Fall 1999
Lecture 7 Formal Specification I

2 Administration Assignment 2: Instructions for submitting Assignment 2
Ownership of software in projects: Students are owners of work that is carried out in projects (except patents) Importance of clarity at beginning of projects

3 Example from Lecture 6 Edit Unit 4

4 Example from Lecture 6 Edit Unit 4

5 Formal Specification Why?
 Precise standard to define and validate software. Why not?  May be time consuming  Methods not suitable for all applications

6 Formal Specification 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

7 Mathematical Specification
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 = 21 Bk-1 = k ... 21 The numerical accuracy must be such that, for all k, BkBk-1 - I < 

8 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

9 Formal Specification Using Diagrams
unsigned integer digit unsigned number + unsigned integer . digit E unsigned integer -

10 Two Rules  Formal specification does not guarantee correctness
 Formal specification does not prescribe the implementation

11 Example: Specification
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)

12 Example: Algorithm (2n - 1) = n2

13 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;

14 Finite State Machine A broadly used method of formal specification:
 Event driven systems (e.g., games)  User interfaces  Protocol specification etc., etc., ...

15 Finite State Machine Example: Therapy control console
[informal description]

16 State Transition Diagram
Select field Enter Enter (ok) Start Beam on Patients Fields Setup Ready Stop (interlock) Select patient

17 State Transition Table
Select Patient Select Field Enter ok Start Stop interlock Patients Fields Fields Patients Setup Setup Patients Fields Ready Beam on Ready Patients Fields Setup Beam on Ready Setup

18 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

19 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 }

20 Reading Before next Tuesday, read and be ready to discuss:
Sommerville: Chapter11, pages 171 to 206.


Download ppt "CS 501: Software Engineering Fall 1999"

Similar presentations


Ads by Google