csc501-ln005

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

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

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 σ Σ.

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

View Full Document
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 reﬂexive, symmetric, and transitive.)
Expression Equivalence Problem: Let a 0 2 3 and a 1 3 + 3, show that a 0 a 1 .

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

View Full Document
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.
Expression Equivalence Problem: Show that the + operator is commutative.

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

View Full Document
Expression Equivalence Proof: We need to show that a 0 + a 1 a 1 + a 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