Denotational Semantics G54FOP: Lecture 15 • the Relation Between Operational and Denotational Semantics and Domain Theory I Denotational Semantics

Denotational Semantics G54FOP: Lecture 15 • the Relation Between Operational and Denotational Semantics and Domain Theory I Denotational Semantics

This Lecture • Introduction to Denotational Semantics G54FOP: Lecture 15 • The relation between Operational and Denotational Semantics and Domain Theory I Denotational Semantics Henrik Nilsson University of Nottingham, UK G54FOP: Lecture 15 – p.1/16 G54FOP: Lecture 15 – p.2/16 Denotational Semantics (1) Denotational Semantics (2) Operational Semantics (review): Denotational Semantics: • The meaning of a term is the term it • Idea: Semantic function maps (abstract) (ultimately) reduces to, if any: syntax directly to meaning in a semantic - Stuck terms domain. - Infinite reduction sequences • Domains consist of appropriate semantic • No inherent meaning (structure) beyond objects (Booleans, numbers, functions, ...) syntax of terms. and have structure; in particular, an information ordering. • Focus on behaviour; important aspects of semantics (such as non-termination) • The semantic functions are total; in particular, emerges from the behaviour. even a diverging computation is mapped to an element in the semantic domain. G54FOP: Lecture 15 – p.3/16 G54FOP: Lecture 15 – p.4/16 Denotational Semantics (3) Compositionality (1) Example: • It is usually required that a denotational [[(1+2) * 3]] = 9 semantics is compositional: that the meaning of a program fragment is given in abstract syntax terms of the meaning of its parts. • Compositionality ensures that meaning/denotation - the semantics is well-defined (here, semantic domain is Z) - important meta-theoretical properties hold [[·]], or variations like E[[·]], C[[·]]: semantic functions [[ and ]]: Scott brackets or semantic brackets. G54FOP: Lecture 15 – p.5/16 G54FOP: Lecture 15 – p.6/16 Compositionality (2) Definition Example: Formally, a denotational semantics for a language L is given by a pair [[(1+2) * 3]] = [[1+2]] × [[3]] hD, [[·]]i abstract syntax where • D is the semantic domain subterms (abstract syntax) • [[·]] : L → D is the valuation function or semantic multiplication semantic function. Z Z Z (× : × → ) In simple cases D may be a set, but usually The meaning of the whole is given by composing more structure is required leading to domains as the meaning of the parts. defined in domain theory. G54FOP: Lecture 15 – p.7/16 G54FOP: Lecture 15 – p.8/16 Example: Simple Expr. Language (1) Example: Simple Expr. Language (2) Develop a denotational semantics hD, [[·]]i for E, e → expressions: picking N as the semantic domain for simplicity: | true constant true N | false constant false D = N | if e then e else e conditional [[·]] : e → | 0 constant zero However, as there are both Booleans and natural | succ e successor numbers in the object language, a more refined | pred e predecessor choice for the semantics at the meta level would have been N ⊎ B, the disjoint union of natural | iszero e zero test numbers and Booleans. (On whiteboard) G54FOP: Lecture 15 – p.9/16 G54FOP: Lecture 15 – p.10/16 Exercises (1) Exercises (2) 1. Find the denotation of 2. Consider the following language extension: if (iszero (succ 0)) then true else false e → expressions: . | not e logical negation | e && e logical conjunction | e + e addition | e - e subtraction | e * e multiplication Extend the denotational semantics accordingly. G54FOP: Lecture 15 – p.11/16 G54FOP: Lecture 15 – p.12/16 Operational and Denotational Sem. (1) Operational and Denotational Sem. (2) Given a language L, suppose we have: Closed terms t1,t2 ∈ L are semantically or • a big-step operational semantics denotationally equivalent iff ⇓⊆ L × V [[t1]] = [[t2]] where V ⊆ L is the set of values Assume D is ground (no functions; i.e., our closed terms are programs that output • a denotational semantics something “printable”). We adopt a function hD, [[·]]i · : D → V where [[·]] : L → D that maps a semantic value d ∈ D to its term How should these be related? representation v ∈ V . G54FOP: Lecture 15 – p.13/16 G54FOP: Lecture 15 – p.14/16 Operational and Denotational Sem. (3) Operational and Denotational Sem. (4) Assuming termination: Assuming termination: • Correctness of operational semantics w.r.t. • Computational adequacy of operational denotational semantics: semantics w.r.t. denotational semantics (or vice versa, depending on point of view): t ⇓ v ⇒ [[t]] = [[v]] t ⇓ v ⇔ [[t]] = [[v]] • Completeness of operational semantics w.r.t. denotational semantics: [[t]] = d ⇒ t ⇓ d G54FOP: Lecture 15 – p.15/16 G54FOP: Lecture 15 – p.16/16.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us