SolHW2f07 - HW2F07 CS336 1. Prove wp ( S 1 ; S 2 ,R 1 R 2 )...

Info iconThis preview shows pages 1–3. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: HW2F07 CS336 1. Prove wp ( S 1 ; S 2 ,R 1 R 2 ) = wp ( S 1 ; S 2 ,R 1 ) wp ( S 1 ; S 2 ,R 2 ) given S 1 and S 2 both satisfy the Distributivity of Conjunction. Solution: wp ( S 1 ; S 2 ,R 1 R 2 ) = < wp > wp ( S 1 ,wp ( S 2 ,R 1 R 2 )) = < S 2 satisfies the Distributivity of Conjunction > wp ( S 1 ,wp ( S 2 ,R 1 ) wp ( S 2 ,R 2 )) = < S 1 satisfies the Distributivity of Conjunction > wp ( S 1 ,wp ( S 2 ,R 1 )) wp ( S 1 ,wp ( S 2 ,R 2 )) = < wp > wp ( S 1 ; S 2 ,R 1 ) wp ( S 1 ; S 2 ,R 2 ) 2. Prove wp ( S 1 ; S 2 ,R ) wp ( S 1 ; S 2 , R ) = F Solution: wp ( S 1 ; S 2 ,R ) wp ( S 1 ; S 2 , R ) = < Distributivity of Conjunction > wp ( S 1 ; S 2 ,R R )) = < contradiction > wp ( S 1 ; S 2 ,F )) = < Law of Excluded Miracle > F 3. ( Extra * ) Give an example to show that wp ( S ,R ) wp ( S , R ) = T is not true for all R . Solution: wp ( S ,R ) wp ( S , R ) < instantiation > wp ( abort ,R ) wp ( abort , R ) < wp > F F < -simplification > F 4. ( Extra * ) Consider the command make-true with a constant predicate transformer wp ( make- true ,R ) = T for all predicates R . Why isnt make-true a valid command? Solution: 1 Let R be the constant F . Then we have wp ( make- true ,R ) < instantiation > wp ( make- true ,F ) < excluded miracle > F Therefore make-true is not valid. 5. ( Extra ) Find the weakest precondition for the following: a. wp ( j,s := 0 , 0 ,s = ( k | k < j : b [ k ])) Solution: wp ( j,s := 0 , 0 ,s = ( k | k < j : b [ k ])) < wp > 0 = ( k | k < 0 : b [ k ])) < empty range > 0 = 0 < identity > T b. wp ( j,s := j + 1 ,s + b [ j ] ,s = ( k | k < j : b [ k ])) Solution: wp ( j,s := j + 1 ,s + b [ j ] ,s = (...
View Full Document

This note was uploaded on 09/20/2008 for the course CS 336 taught by Professor Myers during the Spring '08 term at University of Texas at Austin.

Page1 / 7

SolHW2f07 - HW2F07 CS336 1. Prove wp ( S 1 ; S 2 ,R 1 R 2 )...

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

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