Formal Methods continued Formal Methods Modifying a Formal

  • Slides: 10
Download presentation
Formal Methods (continued) Formal Methods: Modifying a Formal Specification 1

Formal Methods (continued) Formal Methods: Modifying a Formal Specification 1

Propositional Logic Formal methods: Allow us to "prove" properties of the system under development

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. 2

Additional Z Notation 3

Additional Z Notation 3

Z Sequence Notation 4

Z Sequence Notation 4

Z example revisited (1) Example (from Pressman, Software Engineering, A Practitioner’s Approach): “Block Handler”

Z example revisited (1) Example (from Pressman, Software Engineering, A Practitioner’s Approach): “Block Handler” Unused (free) blocks 2 5 7 8 10 11 12 13469 2 Used blocks 5 8 11 7 Blocks released to queue when files deleted Queued for entry into Unused 5

Z example revisited (2) Z specification: -------Block. Handler-----------used, free: BLOCKS Block. Queue: seq P

Z example revisited (2) Z specification: -------Block. Handler-----------used, free: BLOCKS Block. Queue: seq P BLOCKS -----------------------used free = All. Blocks i: dom Block. Queue i used i, j : dom Block. Queue. i j Block. Queue i Block. Queue j = 6

Z example revisited (3) -----Remove. Block------------- Block. Handler --------------------------#Block. Queue > 0, used’ =

Z example revisited (3) -----Remove. Block------------- Block. Handler --------------------------#Block. Queue > 0, used’ = used head Block. Queue free’ = free head Block. Queue’ = tail Block. Queue -------------------------------Add. Block--------------- Block. Handler Ablocks? : BLOCKS --------------------------Ablocks? used, used’ = used free’ = free Block. Queue’ = Block. Queue ^ (Ablocks? ) --------------------------- 7

Modifying the example Examples: 1. Change Block. Queue to Block. Stack: 2. Output size

Modifying the example Examples: 1. Change Block. Queue to Block. Stack: 2. Output size of Block. Queue in Add. Block or Remove. Block 3. Make Block. Queue part of “free” instead of “used” 8

Modifying the example 9

Modifying the example 9

Formal methods in project (exercise) Class exercise: --Describe a priority queue in Z notation

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? 10