Presentation is loading. Please wait.

Presentation is loading. Please wait.

School of Computing and Mathematics, University of Huddersfield CHA2545: WEEK 4 LECTURE: DENOTIONAL SEMANTICS OF A SIMPLE LANGUAGE TUTORIAL: Do exercises.

Similar presentations


Presentation on theme: "School of Computing and Mathematics, University of Huddersfield CHA2545: WEEK 4 LECTURE: DENOTIONAL SEMANTICS OF A SIMPLE LANGUAGE TUTORIAL: Do exercises."— Presentation transcript:

1 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).

2 School of Computing and Mathematics, University of Huddersfield The Four Parts of a Semantic Definition: n Syntactic domains n Abstract Syntax n Semantic Domains n Meaning Functions Example syntax domains (see handout) Nml, Ide, Exp, Cmd

3 School of Computing and Mathematics, University of Huddersfield DENOTATIONS n 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. n A “denotation” is a mathematical representation of the meaning of a construct - its an object belonging to a SEMANTIC DOMAIN.

4 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, ->

5 School of Computing and Mathematics, University of Huddersfield COMPLEX DOMAINS - Examples n Disjoint Union Domain of all integers and truth values Z + T n Cross Product Domain of all pairs of integers Z x Z n Function Domain consisting of all functions from integers to truth values Z -> Z and pairs of integers to integers (Z x Z) -> Z

6 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}

7 School of Computing and Mathematics, University of Huddersfield The STORE n 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. n The store is represented by a function domain S = [ Ide -> E ] + {error} We usually let ‘s’ be a typical store or state.

8 School of Computing and Mathematics, University of Huddersfield Commands n Commands change the program state The domain of commands is therefore the functions between states, i.e. S -> S

9 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.

10 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

11 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)

12 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!!


Download ppt "School of Computing and Mathematics, University of Huddersfield CHA2545: WEEK 4 LECTURE: DENOTIONAL SEMANTICS OF A SIMPLE LANGUAGE TUTORIAL: Do exercises."

Similar presentations


Ads by Google