csc501-ln005 - Arithmetic Expression Summary(n...

Info icon This preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Arithmetic Expression Summary for n I ( n , σ ) eval ( n ) for x Loc ( x , σ ) σ ( x ) ( a 0 , σ ) k 0 ( a 1 , σ ) k 1 where k = k 0 + k 1 ( a 0 + a 1 , σ ) k ( a 0 , σ ) k 0 ( a 1 , σ ) k 1 where k = k 0 k 1 ( a 0 a 1 , σ ) k ( a 0 , σ ) k 0 ( a 1 , σ ) k 1 where k = k 0 × k 1 ( a 0 a 1 , σ ) k ( a , σ ) k (( a ) , σ ) k with k , k 0 , k 1 I , a , a 0 , a 1 Aexp , and σ Σ.
Image of page 1

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

View Full Document Right Arrow Icon
Expression Equivalence Our notion of semantic value for expressions leads to a natural equivalence relation between arithmetic expressions: a 0 a 1 iff σ Σ , n I . ( a 0 , σ ) n ( a 1 , σ ) n , where a 0 , a 1 Aexp . Two expressions are equivalent if and only if they evaluate to the same semantic value in all possible states. (You should convince yourself that this is indeed an equivalence relation, i.e., check that the relation is reflexive, symmetric, and transitive.)
Image of page 2
Expression Equivalence Problem: Let a 0 2 3 and a 1 3 + 3, show that a 0 a 1 .
Image of page 3

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

View Full Document Right Arrow Icon
Expression Equivalence Proof : We need to show that (2 3 , σ ) k and (3 + 3 , σ ) k for all states σ Σ and some k I . Let σ Σ be any state, then (2 , σ ) 2 (3 , σ ) 3 (2 3 , σ ) 6 and (3 , σ ) 3 (3 , σ ) 3 (3 + 3 , σ ) 6 which shows that regardless of the state, the two expressions will always produce the same semantics value, namely the integer 6. This concludes the proof.
Image of page 4
Expression Equivalence Problem: Show that the + operator is commutative.
Image of page 5

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

View Full Document Right Arrow Icon
Expression Equivalence Proof: We need to show that a 0 + a 1 a 1 + a 0
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern