Introduction To Z
Introduction To Z
Mathematical Notation
Mathematical requirements can be specified formally.
Example: requirements from a mathematical package:
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 <
1 CS 501 Spring 2005
Formal Specification Using Diagrams
Example: Pascal number syntax
unsigned integer
digit
unsigned number +
unsigned integer . digit E unsigned integer
<sign> ::= + | -
intrt: N N
a : N•
intrt(a) * intrt(a) < a < (intrt(a) + 1) * (intrt(a) + 1)
Select field
Beam
Patients Fields Setup Ready
on
Stop
(lock on)
Select patient
Schema:
• The basic unit of formal specification.
• Enables complex system to be specified as
subsystems
• Describes admissible states and operations of a
system.
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.
ran m
X dom m m y Y
x
m:X Y
domain: dom m = { x X : y Y x y}
range: ran m = { y Y : x X x y}
Name
Library
stock : Copy Book finite
Declaration subset
issued : Copy Reader
part
shelved : F Copy
readers: F Reader
LibDB
stock : Copy Book
readers: F Reader
LibLoans
issued : Copy Reader
shelved : F Copy
r : Reader • #(issued {r})< maxloans
shelved dom issued = Ø
Library
LibDB
LibLoans
dom stock = shelved dom issued
ran issued readers
Issue
stock, stock' : Copy Book
issued, issued' : Copy Reader
shelved, shelved': F Copy
readers, readers' : F Reader
c?: Copy; r? :Reader
Issue
[See previous slide]
Issue
Library
Library'
c? : Copy; r? : Reader
c? shelved; r? readers
#(issued {r?}) < maxloans
issued' = issued {c? r?}
stock' = stock; readers' = readers
Issue
Library
c? : Copy; r? : Reader
c? shelved; r? readers
#(issued {r?}) < maxloans
issued' = issued {c? r?}
stock' = stock; readers' = readers
Schema inclusion
Schema decoration
Schema disjunction:
^ AddKnownTitle AddNewTitle
AddCopy =
Schema conjunction:
^ EnterNewCopy AddCopyAdmin
AddCopy =
Schema negation
Schema composition
27 CS 501 Spring 2005
Z in Practice