CS 641 meeting -*- Outline -*- * Specifications (Cohen's chapter 4) Note Hesselink uses a different notation, so no need to emphasize. Skip over 4.1 (it's obvious) ** what is programming? (omit) ----------------------- EQUATION WITH UNKNOWN SPECIFIED consider x*x + b*x + c = 0 could solve for x, b, or c! x: x*x + b*x + c = 0 means solve for x in... ----------------------- ----------------------- WHAT IS PROGRAMMING? Programming is solving the equation: S: {Q} S {R} ----------------------- where Q and R are pre- and postconditions this points out that you have to tell what you want. Similarly in specification, have to say what you can change (what the program vars are) ** writing specifications We specify a program by stating a pre- and postcondition, as well what variables a program can modify *** notation ----------------------- TOTAL CORRECTNESS HOARE TRIPLE {Q} S {R} =def= Q ==> wp.S.R ----------------------- The Hoare triple means if Q holds, then execution of S always terminates in a state satisfying R The weakest precondition is an in Dijkstra's paper (see section 5.2) ** form of specification ------------------- FORM OF SPECIFICATION example: var a,b,z: int {a >= 0 /\ b >= 0} ; z: z = a*b ------------------- this says that a,b,z are integers, and the statement S desired must satisfy {a >= 0 /\ b >= 0} S {z = a*b} but only z may be modified ---------------------- SYNTAX OF SPECIFICATIONS ::= [ ; ] ... ; : ::= var : [ ] ::= [ , ] ... ::= |