Assignment 3

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

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

View Full Document Right Arrow Icon
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,
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
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

This note was uploaded on 05/04/2011 for the course CS 536 taught by Professor Cs536 during the Spring '08 term at Illinois Tech.

Page1 / 2

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

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

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