This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full 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 maketrue with a constant predicate transformer wp ( make true ,R ) = T for all predicates R . Why isnt maketrue 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 maketrue 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.
 Spring '08
 Myers

Click to edit the document details