Evaluation does not add or remove a global variable such that , - - PowerPoint PPT Presentation

evaluation does not add or remove a global variable
SMART_READER_LITE
LIVE PREVIEW

Evaluation does not add or remove a global variable such that , - - PowerPoint PPT Presentation

Evaluation does not add or remove a global variable such that , and For any e , , , , v , h e h v ; ; ; i + ; ; ; i ; we can prove dom = dom Evaluation doesnt


slide-1
SLIDE 1

Evaluation does not add or remove a global variable

For any e,

, , , v, ′, and ′ such that he ;
  • ;
; i + hv ; ′ ; ; ′ i;

we can prove

dom
  • =
dom ′

“Evaluation doesn’t change the global domain”

slide-2
SLIDE 2

Assume the existence of a derivation

Could terminate in any rule! Base case:

hLITERAL (v );
  • ;
; i + hv ;
  • ;
; i

Both sides identical!

dom
  • =
dom
slide-3
SLIDE 3

Holds for formal-parameter lookup

Another base case: x

2 dom
  • hVAR
(x );
  • ;
; i + h(x );
  • ;
; i

Both sides identical!

dom
  • =
dom
slide-4
SLIDE 4

Inductive case: good sub-derivation

Assignment to formal parameter x

2 dom
  • D
he ;
  • ;
; i + hv ; ′ ; ; ′ i hSET (x ;e );
  • ;
; i + hv ; ′ ; ; ′ fx 7! v gi

By induction hypothesis on

D, dom
  • =
dom ′

Both sides have same domain!

slide-5
SLIDE 5

Inductive case: good sub-derivation

True conditional

D1 he1 ;
  • ;
; i + hv1 ; ′ ; ; ′ i

v1

6= 0 D2 he2 ; ′ ; ; ′ i + hv2 ; ′′ ; ; ′′ i hIF (e1 ;e2 ;e3 );
  • ;
; i + hv2 ; ′′ ; ; ′′ i

By induction hypothesis on

D1, dom
  • =
dom ′

By induction hypothesis on

D2, dom ′ = dom ′′

Therefore, both sides have same domain:

dom
  • =
dom ′′
slide-6
SLIDE 6

The only interesting case: assign to global

x

= 2 dom
  • x
2 dom
  • D
he ;
  • ;
; i + hv ; ′ ; ; ′ i hSET (x ;e );
  • ;
; i + hv ; ′ fx 7! v g; ; ′ i

Do both sides have same domain?

  • Does
dom
  • =
dom (′ fx 7! v g) ?

By induction hypothesis on

D, dom
  • =
dom ′

And

dom (′ fx 7! v g) = dom ′ [ fx g = dom
  • [
fx g

But x

2 dom ! So dom
  • [
fx g = dom
slide-7
SLIDE 7

And now: Scheme!

slide-8
SLIDE 8

Examples of S-Expression operators

(cons ’a ’()) also written ’(a) (cons ’b ’(a)) equals ’(b a) (cons ’c ’(b a)) equals ’(c b a) (null? ’(c b a)) equals #f (cdr ’(c b a) equals ’(b a) (car ’(c b a) equals ’c

slide-9
SLIDE 9