
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The solutions to homework xi for a fall 2004 computer science course. Students are required to prove the hoare while normal form theorem, provide axiomatic proofs of partial correctness for three wren program fragments using integer variables, and compute the square root and binary logarithm. Essential for students studying formal verification and programming theory.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

22C:185 — Fall 2004 Homework XI
1. [15 points] Prove the Hoare while normal form theorem (i.e., provide a construction to replace if – then – with sequential execution and while – do –), and justify its correctness. 2 (repeated from Homework X). [25 points] Provide an axiomatic proof of partial correctness for the Wren program fragment using integer variables: {true} if A=B or A=-B then if A>B then C:= A else C:= B-A+1 end if else if AB>0 then C:= AB else C:= 1-AB end if end if {C>0) 3. [25 points] Provide an axiomatic proof of partial correctness for the Wren program fragment with pre/post-conditions below (computing the “square root”), using integer variables: {N≥1} R:= 0; while RR < N do R:= R+1 end while {(R-1)^2 < N ≤ R^2 ) 4. [25 points] Provide an axiomatic proof of partial correctness for the Wren program fragment with pre/post-conditions below (computing the “binary logarithm”), using integer variables: {N>0} P:= 0; M:= 1; while M < N do P:= P+1; M:= 2*M end while {2P-1< N Ÿ 2 P≥N}