csc501-ln005

csc501-ln005 - Arithmetic Expression Summary for n I ( n ,...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Arithmetic Expression Summary for n I ( n , ) 7 eval ( n ) for x Loc ( x , ) 7 ( x ) ( a , ) 7 k ( a 1 , ) 7 k 1 where k = k + k 1 ( a + a 1 , ) 7 k ( a , ) 7 k ( a 1 , ) 7 k 1 where k = k k 1 ( a a 1 , ) 7 k ( a , ) 7 k ( a 1 , ) 7 k 1 where k = k k 1 ( a a 1 , ) 7 k ( a , ) 7 k (( a ) , ) 7 k with k , k , k 1 I , a , a , a 1 Aexp , and . Expression Equivalence Our notion of semantic value for expressions leads to a natural equivalence relation between arithmetic expressions: a a 1 iff , n I . ( a , ) 7 n ( a 1 , ) 7 n , where a , 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 reexive, symmetric, and transitive.) Expression Equivalence Problem: Let a 2 3 and a 1 3 + 3, show that a a 1 . Expression Equivalence Proof : We need to show that (2 3 , ) 7 k and (3 + 3 , ) 7 k for all states and some k I . Let be any state, then (2 , ) 7 2 (3 , ) 7 3 (2 3 , ) 7 6 and (3 , ) 7 3 (3 , ) 7 3 (3 + 3 , ) 7 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. 2 Expression Equivalence Problem: Show that the + operator is commutative. Expression Equivalence...
View Full Document

Page1 / 18

csc501-ln005 - Arithmetic Expression Summary for n I ( n ,...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online