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 satisﬁes its speciﬁcation. ( | ?? | ) 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

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.

## This note was uploaded on 01/19/2010 for the course CS 246 taught by Professor Wormer during the Spring '08 term at Waterloo.

### 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