Docsity

CS 536: Science of Programming - Homework 6 - Prof. James T. Sasaki, Assignments of Computer Science

Toggle sidebar
bg1
CS 536: Science of Programming — HW 6 due Tue May 5
Total Correctness; Arrays; Parallel Programs; Interference
Dr. Jim Sasaki, CS Dept, Illinois Institute of Chicago
Problem 1 (20 points)
Give a full total correctness proof outline for a program {n!! 0} S {x!=!n!/1!} {x!=!n!} where the
invariant is obtained by replacing the constant 1 with a variable.
Problem 2 (20 points)
Find a reasonably simple precondition p for the program below; give a full proof outline that
uses your"p.
{p} a[n]!:=!0; a[m]!:=!x {a[n]!=!0}
Problem 3 (20 points)
Draw an evaluation graph for the following configuration. [Solve this for the general case,
symbolically.] Is the program disjoint parallel? [Hint: Is “disjoint parallel” a syntactic or se-
mantic property?]
<![!e!:=!3 || if b then d!:=!2 else e!:=!4 fi!], "[b!:=!true]!>
Problem 4 (20 points)
Give a full proof outline for {n!>!0} [u!:=!n!|| v!:=!n+1!|| w!:=!n+2] {0!<!u!<!v!<!w} using the disjoint
parallelism rule for parallel disjoint programs with disjoint conditions.
Problem 5 (20 points)
List the interference freedom checks for the following two standard proof outlines. Below, as-
sume S#, S$, and S% are atomic.
•{q#} S# {q$}
•{p#} S$; {inv p$} while B do {p&} S% od {p%}
CS 536: Science of Programming Spring’09 HW 6
Ill. Inst. Tech. CS 1 of 1

Partial preview of the text

Download CS 536: Science of Programming - Homework 6 - Prof. James T. Sasaki and more Assignments Computer Science in PDF only on Docsity!

CS 536: Science of Programming — HW 6 due Tue May 5

Total Correctness; Arrays; Parallel Programs; Interference

Dr. Jim Sasaki, CS Dept, Illinois Institute of Chicago Problem 1 (20 points) Give a full total correctness proof outline for a program { n !! 0} S { x !=! n !/1!} { x !=! n !} where the invariant is obtained by replacing the constant 1 with a variable. Problem 2 (20 points) Find a reasonably simple precondition p for the program below; give a full proof outline that uses your" p. { p } a [ n ]!:=!0; a [ m ]!:=! x { a [ n ]!=!0} Problem 3 (20 points) Draw an evaluation graph for the following configuration. [Solve this for the general case, symbolically.] Is the program disjoint parallel? [Hint: Is “disjoint parallel” a syntactic or se- mantic property?]

**_Problem 4 (20 points)_** Give a full proof outline for { _n_ !>!0} [ _u_ !:=! _n_ !|| _v_ !:=! _n_ +1!|| _w_ !:=! _n_ +2] {0!
  • { q #}^ S #^ { q $}
  • { p #}^ S $; { inv^ p $}^ while^ B^ do^ { p &}^ S %^ od^ { p %} CS 536: Science of Programming Spring’09 HW 6 Ill. Inst. Tech. CS 1 of 1