evaluation does not add or remove a global variable
play

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


  1. 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 doesn’t change the global domain”

  2. Assume the existence of a derivation Could terminate in any rule! Base case: h LITERAL ( v h v ) ; � ; �; � i + ; � ; �; � i Both sides identical! dom � = dom �

  3. Holds for formal-parameter lookup Another base case: x 2 dom � h VAR ( x ) ; h � ( x ) ; � ; �; � i + � ; �; � i Both sides identical! dom � = dom �

  4. Inductive case: good sub-derivation Assignment to formal parameter D � ′ � ′ x h e h v 2 dom � ; � ; �; � i + ; ; �; i � ′ � ′ h SET ( x ; e h v f x 7! v ) ; � ; �; � i + ; ; �; gi � ′ By induction hypothesis on D , dom � = dom Both sides have same domain!

  5. Inductive case: good sub-derivation True conditional D 1 D 2 � ′ � ′ � ′ � ′ � ′′ � ′′ 6 = 0 h e 1 h v 1 v 1 h e 2 h v 2 ; � ; �; � i + ; ; �; i ; ; �; i + ; ; �; i � ′′ � ′′ h IF ( e 1 ; e 2 ; e 3 h v 2 ) ; � ; �; � i + ; ; �; i � ′ By induction hypothesis on D 1 , dom � = dom � ′ � ′′ By induction hypothesis on D 2 , dom = dom Therefore, both sides have same domain: � ′′ dom � = dom

  6. The only interesting case: assign to global D � ′ � ′ x x h e h v 2 = dom � 2 dom � ; � ; �; � i + ; ; �; i � ′ � ′ h SET ( x ; e h v f x 7! v ) ; � ; �; � i + ; g ; �; i Do both sides have same domain? ( � ′ • Does g ) ? f x 7! v dom � = dom � ′ By induction hypothesis on D , dom � = dom ( � ′ � ′ And f x 7! v f x g f x g dom g ) = dom [ = dom � [ But x � ! So f x g 2 dom dom � [ = dom �

  7. And now: Scheme!

  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

Recommend


More recommend