Lecture9.6 - 1 11/14/06 Materials Copyright N. Ramsey...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 11/14/06 Materials Copyright N. Ramsey & al. 1 DPL-9: Semantics Formal Semantics: three approaches. Operational Semantics reasons about executions of programs on abstract machines (program text execution) Axiomatic Semantics reasons about properties of programs: it attempts to relate programs to speciFcations (program text axioms and rules of some logic) Denotational Semantics reasons about meanings (= denotations) of programs. Mathematical models of programming languages (program text mathematical model). 11/14/06 Materials Copyright N. Ramsey & al. 2 DPL-9: Semantics Denotational Semantics We are interested in the effect of executing a program (effect = association between initial states and Fnal states). or each syntactic category we will deFne a semantic function , a function that maps a syntactic construct to a mathematical object (often, itself, a function) that describes the effect of executing the construct. 11/14/06 Materials Copyright N. Ramsey & al. 3 DPL-9: Semantics Denotational Semantics Compositional (build up meaning of a large program fragment as a function of the meanings of smaller fragments) Map to meaning Concrete Semantics translates to a simpler language. Use meaning in simpler language Semantic Domain : A (structured) set of meanings Syntactic Domain : Parts of abstract syntax that you would expect to have the same semantic domain (i.e., type) Valuation unction : Compositional map from syntactic domain to semantic domain - this will be syntax-directed. 11/14/06 Materials Copyright N. Ramsey & al. 4 DPL-9: Semantics Denotational Semantics: Example - Binary Numerals Syntax: B ::= BD | D D ::= 0 | 1 Syntactic Domains: B Binary-numeral D Binary-digit Semantic Domains: { zero , one }, N = { zero , one , two , } Valuation unctions: D [[ ]] = zero D [[ 1 ]] = one B [[ D ]] = D [[ D ]] B [[ BD ]] = (( B [[ B ]] times two ) plus D [[ D ]] ) 11/14/06 Materials Copyright N. Ramsey & al. 5 DPL-9: Semantics Denotational Semantics: Example - Regular Expressions Syntax: R ::= A | 0 | R R | R | R | R* A ::= a | b | Syntactic Domains: A alphabet R regular expressions Semantic Domains: Languages ( = sets of strings) Valuation unctions: A [[ a ]] = { "a" } A [[ b ]] = { "b" } R [[ A ]] = A [[ A ]] R [[ ]] = {} R [[ R 1 R 2 ]] = {concat(s 1 , s 2 ) | s 1 R [[ R 1 ]] , s 2 R [[ R 2 ]]} R [[ R 1 | R 2 ]] = R [[ R 1 ]] R [[ R 2 ]] R [[ R* ]] = {""} R [[ R R* ]] 11/14/06 Materials Copyright N. Ramsey & al. 6 DPL-9: Semantics Denotational Semantics: Example - Regular Expressions What is wrong with: R [[ R* ]] = {""} R [[ R R* ]]? The behavior of the valuation function is not compositional: the right- hand-side uses the full left-hand-side. A "better" way of restating it is: Let L = {""} L n +1 = { concat( s 1 , s 2 )| s 1 L n , s 2 R [[ R ]] } then R [[ R* ]] = {0 i } L i Unfortunately, we are stuck with trying to describe an inFnite object.Unfortunately, we are stuck with trying to describe an inFnite object....
View Full Document

This note was uploaded on 02/13/2012 for the course CS 91.531 taught by Professor Giam during the Fall '09 term at UMass Lowell.

Page1 / 15

Lecture9.6 - 1 11/14/06 Materials Copyright N. Ramsey...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online