1 / 10

Principles of programming languages 5 : Answers for exercises

Principles of programming languages 5 : Answers for exercises. Isao Sasano. Department of Information Science and Engineering. Exercise 1. Evaluate an arithmetic expression ( (4 + Y) * (5 + Z) ) under the state  = { (X, 3), (Y, 20), (Z, 13) }. An answer.

Download Presentation

Principles of programming languages 5 : Answers for exercises

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Principles of programming languages5: Answers for exercises Isao Sasano Department of Information Science and Engineering

  2. Exercise 1 Evaluate an arithmetic expression ((4 + Y) * (5 + Z)) under the state= { (X, 3), (Y, 20), (Z, 13) } .

  3. An answer Evaluate an arithmetic expression ((4 + Y) * (5 + Z)) in the state= { (X, 3), (Y, 20), (Z, 13) }. < 4, >  4 < Y, >  20 < 5, >  5 < Z, >  13 < (4 + Y), >  24 < (5 + Z), >  18 < ((4 + Y) * (5 + Z)), >  432

  4. Exercise 2 Let= { (X, 10), (Y, 20), (Z, 30) }. Write down all the elements of [ 40 / X ] in the set notation.

  5. An answer Let= { (X, 10), (Y, 20), (Z, 30) }. Write down all the elements of [ 40 / X ] in the set notation. [ 40 / X ]= { (X, 40), (Y, 20), (Z, 30) }

  6. Exercise 3 Derive the state after executing the statement X = (Y + 2); Y = (Y + 3); in the state = { (X, 10), (Y, 20), (Z, 30) }.

  7. An answer Derive the state after executing the statement X = (Y + 2); Y = (Y + 3); in the state = { (X, 10), (Y, 20), (Z, 30) }. < Y,  >  20 < 2,  >  2 < (Y + 2),  >  22<(Y + 3);,  [ 22 / X ] >  23 < X = (Y + 2);  >   [ 22 / X ] <Y = (Y + 3);  [ 22 / X ]>  ( [ 22 / X ]) [23 / Y] < X = Y + 2; Y = Y + 3;, > (  [ 22 / X ] ) [ 23 / Y ] <Y, σ [22/X]>  20 <3, σ [22/X]>  3 { (X, 22), (Y, 23), (Z, 30) }

  8. Exercise 4 Derive the state after executing the statement while ( Y ) { Y = (Y – 20); } in the state = { (X, 10), (Y, 40), (Z, 30) }.

  9. An answer Derive the state after executing the statement while ( Y ) { Y = (Y – 20); } in the state = { (X, 10), (Y, 40), (Z, 30) }.

  10. An answer An answer is given in another filedue to the lack of space.

More Related