Assignment 3

# Assignment 3 - z>0 4 What do you need to show in order...

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

CS536 Science of Programming Assignment #3 Spring 2010 Due date Friday February 12 by midnight 1. Prove following (8 pts) a. {a b = x y *z } (y,z :=y-1,x*z) { a b = x y *z } b. {a b = x y *z ^even(y) ^y != 0 } (x,y := x*x,y/2) { a b = x y *z } 2.a (8 pts) { z* x y = a b ^ y ≠ 0 } if odd(y) then (y,z) := (y-1, z*x); else (x,y):= (x*x, y/2); { z* x y = a b } 2.b (4 pts) { a>0 ^ b>0 ^ GCD (a,b)=GCD(x,y) } if x>y the x:=x-y else y:=y-x; { a>0 ^ b>0 ^ GCD (a,b)=GCD(x,y) } 3. Compute: (4 pts each) a. WP (if x=0 then y:=1, y=2) b. WP (if false then x:=1 else x:=2, odd(x) ) c. WP (if x=0 then if y=0 then z:=0 else z=1 else if y=0 then z:=1 else z:=0,

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: z>0) 4. What do you need to show in order to prove the following: (4 pts each) a. {P} ( if B1then A;B; if B2 then [C;D] else E;F {R} b. {P} if B1 then if B2 then A {R} c. {P} If B1 then [A;B] else C;D {R} 5. Given the flowing program a. Find correctness assertions only (8 pts) {n>o} (i, a, b := 1,1,0) { } While i/=n do { } (i, a, b := i+1, a+b, a) { } End {a= Fibonacci (n) } b. prove initialization (2 pts) {n>o} (i, a, b := 1,1,0) { } c. prove body of the loop (2 pts) { } (i, a, b := i+1, a+b, a) { }...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern