{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture9.6

# Lecture9.6 - DPL-9 Semantics DPL-9 Semantics Denotational...

This preview shows pages 1–3. Sign up to view the full content.

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 specifications (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 final states). For each syntactic category we will define 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 Function : 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 Functions: D [[ 0 ]] = 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 Functions: A [[ a ]] = { "a" } A [[ b ]] = { "b" } R [[ A ]] = A [[ A ]] R [[ 0 ]] = {} 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 0 = {""} 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 infinite object. This seems to require an infinite description, or, presented differently, introduces an opportunity for exploiting fixed points . We will see more about the use of fixed points when we look at while programs.

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

View Full Document
2 11/14/06 Materials Copyright N. Ramsey & al. 7 DPL-9: Semantics Statement-based Languages .
This is the end of the preview. Sign up to access the rest of the document.
• Fall '09
• Giam
• denotational semantics, Operational Semantics, Formal semantics of programming languages, Axiomatic semantics, stm stm stm stm

{[ snackBarMessage ]}