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 ) 7→ σ From our evaluation rules we have, (2 0 ) 7→ 2 ( x := 2 0 ) 7→ σ 0 [2 / x ] (3 0 [2 / x ]) 7→ 3 ( y := 3 0 [2 / x ]) 7→ ( σ 0 [2 / x ])[3 / y ] ( x := 2; y := 3 0 ) 7→ ( σ 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 ) 7→ σ From our evaluation rules we have, (1 0 ) 7→ 1 ( x := 1 0 ) 7→ σ 0 [1 / x ] ( x 0 [1 / x ]) 7→ 1 (1 0 [1 / x ]) 7→ 1 ( x +1 0 [1 / x ]) 7→ 2 ( y := x +1 0 [1 / x ]) 7→ ( σ 0 [1 / x ])[2 / y ] ( x := 1; y := x +1 0 ) 7→ ( σ 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 ) 7→ σ From our evaluation rules we have, (2 0 ) 7→ 2 ( x := 2 0 ) 7→ σ 0 [2 / x ] (4 0 [2 / x ]) 7→ 4 ( x := 4 0 [2 / x ]) 7→ σ 0 [4 / x ] ( x := 2; x := 4 0 ) 7→ σ 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
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/03/2011 for the course CSC 501 taught by Professor Staff during the Spring '09 term at Rhode Island.

### Page1 / 16

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

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online