001_chand_shakti_assingment_06

001_chand_shakti_assingment_06 - Option A Do not change...

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

View Full Document Right Arrow Icon
Option A Do not change grading policy CS 536: Science of Programming Spring 2010 Assignment #06                                                                          Shakti SG Chand Solution:- 1 1a. Construct and formally prove partial correctness of a deterministic sequential program by showing that your program is a refinement of the UNITY program. Program: P1 r:=0 ; old_r := -1; { ¥u: 0<= u< r: ¬com(u) ^ r>=0} while old_r ≠ r do; old_r:= r; r:= f1(r) r:= f2(r) r:= f3(r) r:= f4(r) end { ¥u: 0<= u< r: ¬com(u) ^ r>=0} Now we are Formally proving partial correctness : The state transformation that the program is going through is f1 – f2 – f3 – f4 – f1 ………and so on. This Sequence is a branch of the computation tree of the UNITY program. Since the UNITY program is partially correct, a branch in the tree is also partially correct. 1b. Prove partial correctness directly: Invariant: { ¥u: 0<= u< r: ¬com(u) ^ r>=0} Proof: a) Invariant before the loop- { ¥u: 0<= u< r: ¬com(u) ^ r>=0} Putting r=0 and old_r := -1 . Hence the set is empty and its true for an empty set b) { ¥u: 0<= u< r: ¬com(u) ^ r>=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
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

001_chand_shakti_assingment_06 - Option A Do not change...

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