{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

csc501-ln006

# csc501-ln006 - Program Evaluation Compute the semantic...

This preview shows pages 1–5. Sign up to view the full content.

Program Evaluation Compute the semantic value of the program x := 2; y := 3. Assume the initial state σ 0 . We want to compute the value σ Σ where ( x := 2; y := 3 , σ 0 ) σ From our evaluation rules we have, (2 , σ 0 ) 2 ( x := 2 , σ 0 ) σ 0 [2 / x ] (3 , σ 0 [2 / x ]) 3 ( y := 3 , σ 0 [2 / x ]) ( σ 0 [2 / x ])[3 / y ] ( x := 2; y := 3 , σ 0 ) ( σ 0 [2 / x ])[3 / y ] We have σ = ( σ 0 [2 / x ])[3 / y ]. What is the value for σ ( y ) and σ ( x )? How about σ ( z ), z Loc ?

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

View Full Document
Program Evaluation Compute the semantic value of the program x := 1; y := x + 1. Assume the initial state σ 0 . We want to compute the value σ Σ where ( x := 1; y := x + 1 , σ 0 ) σ From our evaluation rules we have, (1 , σ 0 ) 1 ( x := 1 , σ 0 ) σ 0 [1 / x ] ( x , σ 0 [1 / x ]) 1 (1 , σ 0 [1 / x ]) 1 ( x + 1 , σ 0 [1 / x ]) 2 ( y := x + 1 , σ 0 [1 / x ]) ( σ 0 [1 / x ])[2 / y ] ( x := 1; y := x + 1 , σ 0 ) ( σ 0 [1 / x ])[2 / y ] We have σ = ( σ 0 [1 / x ])[2 / y ].
Program Evaluation Compute the semantic value of the program x := 2; x := 4. Assume the initial state σ 0 . We want to compute the value σ Σ where ( x := 2; x := 4 , σ 0 ) σ From our evaluation rules we have, (2 , σ 0 ) 2 ( x := 2 , σ 0 ) σ 0 [2 / x ] (4 , σ 0 [2 / x ]) 4 ( x := 4 , σ 0 [2 / x ]) σ 0 [4 / x ] ( x := 2; x := 4 , σ 0 ) σ 0 [4 / x ] We have σ = σ 0 [4 / x ]. What is the value for σ ( y ) and σ ( x )? How about σ ( z ), z Loc ?

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

View Full Document
Program Evaluation Compute the semantic value of the program x := 1; if x = 1 then x := 2 else x := 3 end . Assume the initial state σ 0 . We want to compute the value σ Σ where ( x := 1; if x = 1 then x := 2 else x := 3 end , σ 0 ) σ From our evaluation rules we have, (1 , σ 0 ) 1 ( x := 1 , σ 0 ) σ 0 [1 / x ] ( x , σ 0 [1 / x ]) 1 (1 , σ 0
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern