CS336F104 - 9/6/10 1 CS336 Lecture 4 Weakest Preconditions...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 9/6/10 1 CS336 Lecture 4 Weakest Preconditions Goal Further understand wp How to prove an IF statement correct Why should we care? These are the techniques we will use to verify program then use these methods for developing programs via goal oriented programming. Hoares Triple {Q} S {R} S is the command sequence, the predicate Q is known as Ss pre condition , and R is known as its post condition . A program holds (is verified or proven correct) if we begin in any state satisfying Q,after we execute the commands, we end up in a state satisfying R in a finite amount of time. Our Approach wp(S,R) denotes the weakest (i.e. minimum) precondition necessary for the postcondition to be satisFed. We started with basic commands and look at the weakest precondition for these. Then we looked at how to deal with sequences of these commands. Skip The do-nothin g command (a place- holder): skip Defnition . wp ( skip , R) = R 9/6/10 2 Abort The fatal-error command: abort Defnition . wp ( abort , R) = F Assignment The Assignment command: := Defnition . That is, a textual substitution is made for x in R by replacing x with e. Sequential composition of commands ; Defnition . wp (S1 ; S2, R) = wp (S1, wp (S2,R)) The Alternative Command if B then S0 else S1 , is if B S0 B S1 fi wp(IF,R)= (B wp(S0,R)) ( B wp(S1,R)) Example If x<0 then x:=0 {T} if x<0 x:=0 x0 Skip fi { x0 } Our approach: show T wp(IF, x0 ) Example {T} if x<0 x:=0 x0 Skip fi { x0 } wp(IF,R)= ( x<0 wp( x:=0 , x0 )) ( x0 wp(Skip, x0 )) 9/6/10 3 Example wp (IF,R) = <def> ( x<0 wp( x:=0 , x0 )) ( x0 wp(Skip, x0 )) <wp := and skip > ( x<0 ) ( x0 x0 ) <arith; identity> ( x<0 T ) T < ; -simp > T Now since T T, Q wp(If,R) The Alternative Command The general form (known as IF ) : if B0 S0 B1 S1 B2 S2 . . . B n Sn fi General definition for WP of IF (assumes all guards are defined). wp( IF ,R) = ( i|1 i n: B i ) ( i| 1 i n: B i wp(S i ,R)) If we maintain our approach First, we would find the WP of IF and then show Q wp(IF,R) Or Q ( i|1 i n: B i ) ( i| 1 i n: B i wp(S i ,R)) If we maintain our approach...
View Full Document

This note was uploaded on 11/30/2010 for the course CS 336 taught by Professor Myers during the Fall '08 term at University of Texas at Austin.

Page1 / 7

CS336F104 - 9/6/10 1 CS336 Lecture 4 Weakest Preconditions...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online