Download presentation

Presentation is loading. Please wait.

Published byColleen Malone Modified over 2 years ago

1
Winter 2004/5Pls – expresssion-lang – Catriel Beeri22 Informal Analysis Goal: prove the semantics is deterministic Stages: Values --- we know they have no transitions Minimal non-values --- consider the axioms General composite expressions --- consider the propagation rules

2
Winter 2004/5Pls – expresssion-lang – Catriel Beeri23 “Minimal” non-value expressions Reducible expression (redex): provided it has a transition (condition?) (always has a transition) by (op-apply): 3+4 7 by (if_) : if true 3 4 3 Both are reductions Claim: there is a a unique transition from a redex. (both ) Q: Why “minimal”?

3
Winter 2004/5Pls – expresssion-lang – Catriel Beeri24 Intuition: The rules of define paths in a composite expression E; each descends to a “minimal” non- value sub-expression F A path defined by the rules: a selection path The sub-expression at its end: a selected sub-expression If F is a redex, has a transition F F’, E has a transition E {F’/F}E (replacement) Arbitrary composite expressions

4
Winter 2004/5Pls – expresssion-lang – Catriel Beeri25 Examples applic tuple applic +tuple 3545 (eval-rand) (eval-tuple) (2,1) (op-apply)

5
Winter 2004/5Pls – expresssion-lang – Catriel Beeri26 applic tuple applic +tuple 3545 (eval-rand) (eval-tuple) (2,2) (op-apply)

6
Winter 2004/5Pls – expresssion-lang – Catriel Beeri27 For , an expression may have several selected sub- expressions, several transitions But, for d, there is a unique selected sub- expression, hence at most one transition How do argue this is the case?

7
Winter 2004/5Pls – expresssion-lang – Catriel Beeri28 Consider application E1 E2 E1 is not a value: – (op-apply), (eval-rand) cannot be used. – (eval-rator) can be used, if E1 has a transition E1 is a value, E2 is not: –(op-apply), (eval-rator) cannot be used (why?) –(eval-rand) can be used, if E2 has a transition Both E1 E2 are values: –(eval-rator),(eval-rand) cannot be used, –Possibly (op-apply) can be used

8
Winter 2004/5Pls – expresssion-lang – Catriel Beeri29 This “shows” that for d : For each composite expression E, there is at most one transition The binary relation d is functional (a partial function) This transition semantics is deterministic

9
Winter 2004/5Pls – expresssion-lang – Catriel Beeri30 Natural (evaluation) Semantics Transition semantics deals with one step Natural semantics deals with a complete computation EV transition Natural:

10
Winter 2004/5Pls – expresssion-lang – Catriel Beeri31 Natural semantics rules (nat-int)(nat-bool) (nat-op) (nat-applic-op)(nat-tuple)(nat-if-true)(nat-if-false) if defined

11
Winter 2004/5Pls – expresssion-lang – Catriel Beeri32 A proof tree in natural semantics Q: What is the difference in shape of trees between transition and natural?

12
Winter 2004/5Pls – expresssion-lang – Catriel Beeri33 A (faulty) proof tree in natural semantics: (what is missing?)

13
Winter 2004/5Pls – expresssion-lang – Catriel Beeri34 Properties of natural semantics For each value V, For each E, if then E’ is a value (The value variables in the rules are not needed!) For each E, there is at most one proof tree, hence at most one value (main idea of proof: For each expression category, except if, a unique rule.) Natural semantics is a functional relation --- it defines a partial function

14
Winter 2004/5Pls – expresssion-lang – Catriel Beeri35 On run-time errors High level pl’s do not allow run-time errors to occur w/o taking notice: prevent, detect and treat A semantics should specify explicitly both what are errors, error handling

15
Winter 2004/5Pls – expresssion-lang – Catriel Beeri36 A computation from E may get stuck in a non-value final expression 3/0, true + 2, if 3 4 5, 2 3 We shall: Determine the forms of error expressions Introduce terminology Add rules that specify error treatment to all specs

16
Winter 2004/5Pls – expresssion-lang – Catriel Beeri37 Candidate for a reduction: a expression of the forms For both, proper rules certainly do not apply If there is no transition: a run-time error 4/0, 4 2, false + 3, + (2, 3, 4) (All, except the first, are run-time type errors) Candidate for a reduction: either a redex or a run-time error Claim: there is a at most one transition from a candidate for a reduction (for both , d).

17
Winter 2004/5Pls – expresssion-lang – Catriel Beeri38 The run-time errors: 3/0, 2+false, + (2,3,4) 2 4 if 5 4 6

18
Winter 2004/5Pls – expresssion-lang – Catriel Beeri39 For each composite expression: each selected sub-expression is a candidate for a reduction Def: E contains an error: a selected sub-expression is a run-time error E is an error: ( a stuck expression) all its selected sub-expressions are run-time errors Discuss differences between , d on these concepts

19
Winter 2004/5Pls – expresssion-lang – Catriel Beeri40 Error treatment --- error rules We add a special “constant” ER (not a regular expression/value) We add error rules to specify error handling An expression may transform in one step to ER iff It is a run-time error (error axioms) It contains an error (error propagation rules) Def: Exval - extended values: Val {ER} extended expressions: Exp {ER}

20
Winter 2004/5Pls – expresssion-lang – Catriel Beeri41 Need to change assumption about built-in: For each built-in operation o, is a total function from Val to Exval (returns a value or ER) Takes care of

21
Winter 2004/5Pls – expresssion-lang – Catriel Beeri42 Some error rules: For other constructs –left to you For d -- left for you The new set of rules Is there a change in selected sub-expressions? Can rules be improved upon by using v instead of e?

22
Winter 2004/5Pls – expresssion-lang – Catriel Beeri43 Example: ER applic tuple applic 35 45 seq (error-rand) (error-tuple) (2,1) (apply- error)

23
Winter 2004/5Pls – expresssion-lang – Catriel Beeri44 Rules for natural semantics: The other constructs – left to you The new set:

24
Winter 2004/5Pls – expresssion-lang – Catriel Beeri45 Additional properties for semantics with error rules: Soundness: an expression cannot evaluate to both a value and ER Completeness/Progress: If E is not in Exval, then E evaluates to some XV in Exval (progress --- evaluation does not get stuck) Determinism implies soundness (we argue that is deterministic, as before) Completeness: Argue that a candidate for a reduction is never stuck, extend to all expressions

Similar presentations

OK

Catriel Beeri Pls/Winter 2004/05 types 65 A type-checking algorithm The task: (since we start with empty H, why is the goal not just E?) The rule set.

Catriel Beeri Pls/Winter 2004/05 types 65 A type-checking algorithm The task: (since we start with empty H, why is the goal not just E?) The rule set.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on solar air conditioning Download ppt on subject and predicate Mp ppt online application form Slideshare ppt on leadership Ppt on computer languages wiki Download ppt on effects of global warming Ppt on number system for class 9 free download Ppt on event handling in javascript code Ppt on online banking project in java Download ppt on mind controlled robotic arms for education