{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

s09_t10_Lecture21

# s09_t10_Lecture21 - UNIVERSITY OF WATERLOO School of...

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

UNIVERSITY OF WATERLOO School of Computer Science CS245 Logic and Computation Spring 2009 FINAL TUTORIAL/LECTURE 21 1. Find a precondition, such that the following program satisfies its specification. ( | ?? | ) x = x + 1; y = y + 2; ( | x = y | ) ———————————————————– Annotated Program ( | x + 1 = y + 2 | ) x = x + 1; ( | x = y + 2 | ) y = y + 2; ( | x = y | ) 1

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

View Full Document
2. Verify that at the end of the following program M contains a value greater than or equal to both of A and B. if (A > B) { M = A; } else { M = B; } ———————————————————– Annotated Program ( | true | ) if (A > B) { ( | A > B | ) if-then-else ( | ( A A ) ( A B ) | ) implied (1) M = A; ( | ( M A ) ( M B ) | ) assignment } else { ( ( A > B ) | ) if-then-else ( | ( B A ) ( B B ) | ) implied (2) M = B; ( | ( M A ) ( M B ) | ) assignment } ( | ( M A ) ( M B ) | ) if-then-else 2
Proof of 1: A > B ( A A ) ( A B ) 1. ( A > B ) premise 2. ( A B ) 1 , algebra 3. ( A A ) algebra 4. ( A A ) ( A B ) 2 , 3 , I 5. (line 1) (line 4) 1 - 4 , I Proof of 2: ¬ ( A > B ) ( B A ) ( B B ) 1. ¬ ( A > B ) premise 2. ( B

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.

{[ snackBarMessage ]}

### Page1 / 6

s09_t10_Lecture21 - UNIVERSITY OF WATERLOO School of...

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

View Full Document
Ask a homework question - tutors are online