s09_t10_Lecture21

s09_t10_Lecture21 - UNIVERSITY OF WATERLOO School of...

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

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

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
Proof of 1: A > B
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
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 Right Arrow Icon
Ask a homework question - tutors are online