Presentation is loading. Please wait.

Presentation is loading. Please wait.

Denotational vs Operational Approaches COS 441 Princeton University Fall 2004.

Similar presentations


Presentation on theme: "Denotational vs Operational Approaches COS 441 Princeton University Fall 2004."— Presentation transcript:

1 Denotational vs Operational Approaches COS 441 Princeton University Fall 2004

2 Operational Semantics It is the purpose of these notes to develop a simple and direct method for specifying the semantics of programming languages. Very little is required in the way of mathematical background all that will be involved is “symbol-pushing” of one kind or another … A Structural Approach to Operational Semantics - Gordon Ploktin

3 Limitations of Op. Sem. What does it mean for two functions to be “equal”? Same syntax? Always reduce to the same value given same inputs? One-to-one relationship between their reductions?

4 Strengths of DS Every functions has a precise meaning two functions are equal if they are semantically equal Completely hides details of how the functions compute values Treats all non-terminating functions as equivalents

5 What’s Hard About DS DS deals simply with non-looping functions When we introduce non-terminating functions naïve interpretation of functions as sets is no longer valid Must introduce new theory of domains to account for technicalities

6 Contextual Equivalence Op. Sem. has one natural equivalence on functions that gets at the essences of the natural equivalences Contexts for -calculus e ::= x | x.e | (e 1 e 2 ) v ::= x.e C ::= [] | (C e) | (v C)

7 Contexts and Stacks Contexts are just a reformulation of the control stack (v ([] e)) is ( ¤ e) B (v ¤ ) B ² We say e 1 and e 2 are contextually equivalent (e 1  ctxt e 2 ) when 8 k. (k,e 1 )  C * ( ¢,v) iff (k,e 2 )  C * ( ¢,v) Intuitively swapping one expression for the other doesn’t change the result of any possible evaluation under any context

8 Op Sem vs DS Op has simple mathematical foundations –Requires sophisticated statements to get at program equality –With enough cleverness DS theorems can be restated in terms of Op Sem definitions DS has simple notions of program equivalence –Requires requires sophisticated mathematical foundations

9 When to use DS For languages that do not admit non- terminating computations DS approach is simple to use Consider our DS for pictures –Elementary ideas with simple notion of equality What would a Op Sem. for pictures look like?

10 When to use Op Sem When dealing with non-terminating computations and don’t care so much about a rich theory of equalities –e.g. type safety When you care about how the computation takes place –Sketching out details of implementation for things like exceptions and the like


Download ppt "Denotational vs Operational Approaches COS 441 Princeton University Fall 2004."

Similar presentations


Ads by Google