{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

SolHW2f07

# SolHW2f07 - HW2F07 CS336 1 Prove wp(S1 S2 R1 R2 = wp(S1 S2...

This preview shows pages 1–3. Sign up to view the full content.

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 isn’t make-true a valid command? Solution: 1

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

View Full Document
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 | 0 k < j : b [ k ])) Solution: wp (“ j, s := 0 , 0“ , s = (Σ k | 0 k < j : b [ k ])) < wp > 0 = (Σ k | 0 k < 0 : b [ k ])) < empty range > 0 = 0 < identity > T b. wp (“ j, s := j + 1 , s + b [ j ]“ , s = (Σ k | 0 k < j : b [ k ])) Solution: wp (“ j, s := j + 1 , s + b [ j ]“ , s = (Σ k | 0 k < j : b [ k ])) < wp > s + b [ j ] = (Σ k | 0 k < j + 1 : b [ k ])) < split term > s + b [ j ] = (Σ k | 0 k < j : b [ k ]) + b [ j ] < arith > s = (Σ k | 0 k < j : b [ k ]) 6. Formalize the following English specifications.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 7

SolHW2f07 - HW2F07 CS336 1 Prove wp(S1 S2 R1 R2 = wp(S1 S2...

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

View Full Document
Ask a homework question - tutors are online