School of Computing and Mathematics, University of Huddersfield CHA2545: WEEK 4 LECTURE: DENOTIONAL...
-
Upload
caren-stokes -
Category
Documents
-
view
212 -
download
0
Transcript of School of Computing and Mathematics, University of Huddersfield CHA2545: WEEK 4 LECTURE: DENOTIONAL...
School of Computing and Mathematics, University of Huddersfield
CHA2545: WEEK 4
LECTURE:
DENOTIONAL SEMANTICS OF A SIMPLE LANGUAGE
TUTORIAL:
Do exercises given out
DURING THE WEEK:
Go through ARJ’s supporting WEB notes (from main web page).
School of Computing and Mathematics, University of Huddersfield
The Four Parts of a Semantic Definition:
Syntactic domains Abstract Syntax Semantic Domains Meaning Functions
Example syntax domains (see handout)
Nml, Ide, Exp, Cmd
School of Computing and Mathematics, University of Huddersfield
DENOTATIONS
The semantics of the various syntactic structures of a language is defined via meaning functions which take the syntactic structure as a parameter and returns its denotation.
A “denotation” is a mathematical representation of the meaning of a construct - its an object belonging to a SEMANTIC DOMAIN.
School of Computing and Mathematics, University of Huddersfield
SEMANTIC DOMAINS - Examples
Simple Semantic Domains -
T - truth values
N - natural numbers
Z - integers
Complex Domains
are made up by combining Simple Domains with operators such as +, x, ->
School of Computing and Mathematics, University of Huddersfield
COMPLEX DOMAINS - Examples Disjoint Union Domain of all integers and truth
values
Z + T Cross Product Domain of all pairs of integers
Z x Z Function Domain consisting of all functions
from integers to truth values
Z -> Z
and pairs of integers to integers
(Z x Z) -> Z
School of Computing and Mathematics, University of Huddersfield
COMPLEX DOMAINS - Another Example
All “expressible” values in a simple programming language with truth values and natural numbers:
E = N + T + {error}
School of Computing and Mathematics, University of Huddersfield
The STORE
The simplest way to represent the STATE of program execution is by a STORE - representing the values stored at any point in the execution of a program.
The store is represented by a function domain
S = [ Ide -> E ] + {error}
We usually let ‘s’ be a typical store or state.
School of Computing and Mathematics, University of Huddersfield
Commands
Commands change the program state
The domain of commands is therefore the functions between states, i.e.
S -> S
School of Computing and Mathematics, University of Huddersfield
Semantic Function: Emeans
Emeans takes a syntactically well formed expression, and gives it a denotation in terms of a
function between stores and expressible values
so
Emeans : Exp -> S -> E
The definition of Emeans depends on the syntactic subclass to which it is applied.
School of Computing and Mathematics, University of Huddersfield
Semantic Function: Cmeans
Cmeans takes a syntactically well formed command, and gives it a denotation in terms of a
function between stores and stores
so
Cmeans : Cmd -> S -> S
The definition of Cmeans depends on the syntactic subclass to which it is applied
School of Computing and Mathematics, University of Huddersfield
The Problem with Recursive Functions - what do they mean?
Cmeans[[while B do C]] =
s.(Emeans[[B]]s ->
Cmeans[[while B do C]](Cmeans[[C]]s), s)
OR:
Cmeans[[while B do C]] = f where
f = s.(Emeans[[B]]s -> f(Cmeans[[C]]s), s)
School of Computing and Mathematics, University of Huddersfield
Recursive Functions - The Fixpoint Equation
Given:
f = s.(Emeans[[B]]s -> f(Cmeans[[C]]s), s)
Then:
H = f.s.(Emeans[[B]]s -> f(Cmeans[[C]]s), s)
Hf = (f.s.(Emeans[[B]]s -> f(Cmeans[[C]]s), s)) f
= s.(Emeans[[B]]s -> f(Cmeans[[C]]s), s)
= f
SO WE HAVE Hf = f - the fixpoint equation!!