1 / 10

Denotational vs Operational Approaches

Denotational vs Operational Approaches. COS 441 Princeton University Fall 2004. Operational Semantics.

evers
Télécharger la présentation

Denotational vs Operational Approaches

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 | (e1 e2) 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 e1 and e2 are contextually equivalent (e1ctxt e2) when 8 k. (k,e1) C* (¢,v) iff (k,e2) 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

More Related