Act04_Semantics_of_pgms_and_triples

Act04_Semantics_of_pgms_and_triples - CS 536 Activities:...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 536 Activities: Program Semantics; Correctness Triples Activity 4.1: Program Semantics A. Why? The meaning of a program is that it transforms states. B. Outcomes At the end of this activity you should: Be able to calculate the meaning of a program in a state. C. Questions 1. Let S ! be x := x+1; y := x*y and S # be y := x*y; x := x+1 . Let ! be a state with ! ( x ) = c and ! ( y ) = d . What are M ( S ! , ! ) and M ( S # , ! )? M ( S ! , ! ) " x = c+1 # y = ( c+1 ) d M ( S # , ! ) " x = c+1 # y = c d 2. Let $ $ " x = 0 # y = 1 , let S be the statement x := x+1; y := y+y , and de ne $ ! = M ( S , $ $ ), $ # = M ( S , $ ! ), $ % = M ( S , $ # ), and so on. Calculate the states $ ! , $ # , and $ % . $ ! " x = 1 # y = 2 $ # " x = 2 # y = 4 $ % " x = 3 # y = 8 3. For the states of the previous problem, in general, if $ k ( x ) = c ! and $ k ( y ) = c # , what does $ k +1 look like? M ( S , $ k ) = M ( x := x+1; y := y+y , $ k ) = M ( y := y+y, M ( x := x+1 , $ k )) = M ( y := y+y , { $ k [ x ! d ! ]}) where d ! is the value of c ! +1 = { $ k [ x ! d ! ][ y ! d # ]} where d # is the value of 2 c # . For Questions 4 6, use the $ $ of Question 2: $ $ " x = 0 # y = 1 ....
View Full Document

This note was uploaded on 04/17/2011 for the course CS 536 taught by Professor Cs536 during the Fall '08 term at Illinois Tech.

Page1 / 3

Act04_Semantics_of_pgms_and_triples - CS 536 Activities:...

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