Act09_Loops_Termination

# Act09_Loops_Termination - Illinois Institute of Technology...

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

Loops and Termination CS 536, Mon Nov 1, 2010 Version 1.1, Nov 28: Colored solutions red; cleaned up Activity 9.2 Question 2. Activity 9.1: Expanding Proof Outlines for Loops A. Why? Loops are ubiquitous, so it’s useful to see examples of proving them correct. B. Outcomes At the end of this activity you should: Be able to expand partial proof outlines for simple loops. C. Questions 1. Give a fully expanded proof outline for the following program (the down-going summation loop): { n 0 } j := n; s := n; { inv 0 j n s = sum(j, n) } while j 0 do s := s+j-1; j := j-1 od { s = sum(0, n) } Expanded outline: { n 0 } j := n; { n 0 j = n } s := n; { n 0 j = n s = n } { inv 0 j n s = sum(j, n) } while j 0 do {0 j n s = sum(j, n) j 0} {0 j-1 n s+j-1 = sum(j-1, n)} s := s+j-1; {0 j-1 n s = sum(j-1, n)} j := j-1 {0 j n s = sum(j, n)} od { s = sum(0, n) } Illinois Institute of Technology Activities for Lecture 9 CS 536: Science of Programming - 1 of 3 - © James Sasaki, 2010

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

View Full Document
2. Give a fully expanded proof outline for the alternate binsearch (version 2) loop body.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

Act09_Loops_Termination - Illinois Institute of Technology...

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

View Full Document
Ask a homework question - tutors are online