1 Formal Methods (continued) Formal Methods: Modifying a Formal Specification
2 Propositional Logic Formal methods: Allow us to "prove" properties of the system under development Here we will use the Z language to represent formal specifications Note: the example below is a specification, not a design. In the operations, for example, the specification describes the state of the system before and after the operation, it does not describe how the operation is to be carried out.
3 Additional Z Notation
4 Z Sequence Notation
5 Z example revisited (1) Example (from Pressman, Software Engineering, A Practitioner’s Approach): “Block Handler” Unused (free) blocks Queued for entry into Unused Blocks released to queue when files deleted Used blocks
6 Z example revisited (2) Z specification: BlockHandler used,free: BLOCKS BlockQueue: seq P BLOCKS used free = used free = AllBlocks i: dom BlockQueue. BlockQueue i used i,j : dom BlockQueue. i j BlockQueue i BlockQueue j =
7 Z example revisited (3) RemoveBlock BlockHandler #BlockQueue > 0, used’ = used \ head BlockQueue free’ = free head BlockQueue BlockQueue’ = tail BlockQueue AddBlock BlockHandler Ablocks? : BLOCKS Ablocks? used, used’ = used free’ = free BlockQueue’ = BlockQueue ^ (Ablocks?)
8 Modifying the example Examples: 1. Change BlockQueue to BlockStack: 2. Output size of BlockQueue in AddBlock or RemoveBlock 3. Make BlockQueue part of “free” instead of “used”
9 Modifying the example
10 Formal methods in project (exercise) Class exercise: --Describe a priority queue in Z notation --Are there operations you need which have not yet been defined in these slides on the Z notation?