[CSUSB]
>> [CNS]
>> [Comp Sci Dept]
>> [R J Botting]
>> [CSci620]
>>
04
[Source]
Some books and papers use a simpler definition of domain than Scott and Strachey did. This omits the top (over-defined) element but keeps the bot element. I wrote some notes on this some years ago and put them on the web [ math_24_Domains.html ] in the mathematical part of my web site.
Domain
A domain is always more than a normal "set".
A domain is created by
| Elements | defining a set of elements in it, |
| Top, bottom | identifying (or adding) the top and bot of the domain. |
| Order | defining an order that we interpret as "is less defined than". |
For example the domain N of numbers in the book is defined by
| Elements | All the integers including negatives and zero. |
| top... | The bot and top symbols. |
| Order | For all numbers n, bot is less defined than n and top is more defined than n. All numbers are equally defined: neither more or less defined than each other. |
| Elements | S |
| Top... | top, bot |
| Order | For all x in S, bot is less defined than x and x is less defined than top. |
Product Domains
Figure 3.4 in the book is correct. The example of B><V on page 42 is incorrect.
Given two domains A and B the product domain is defined by
| Elements | { (a,b). for each a:A and b:B } -- including (bot, x) for example. |
| - | bot := ( A.bot, B.bot ), top := (A.top, B.top). |
| Order | For a1,a2:A, b1,b2:B, (a1,b1) is less defined than (a2,b2) if and only if a1 is less defined than a2 and b1 is less defined than b2. |
Where the book uses a downward pointing arrow.... most people would use a simple subscript.
The test does not waste time distinguishing (A><B)><C from A><(B><C) because
in set theory and domain theory they are isomorphic (same thing in disguise).
It flattens them to (A><B><C).
Simple Power Domains
Taking products of a domain with itself gives us powers:
Given a couple of domains A and B the sum domain is defined as
| Elements | { (a,1). for a:A } | { (b,2). for b:B }. |
| " | (A.bot,1), (A.top, 1), (B.bot,2), and (B.top,2) are all in this domain. |
| - | Add new top and bot elements. |
| Order | For a1, a2: A, (a1,1) is less defined than (a2,1) if a1 is less defined than a2. |
| " | For b1, b2: B, (b1,2) is less defined than (b2,2) if b1 is less defined than b2. |
| " | (a,1) and (b,2) are not less or more defined than each other. |
| " | For all (x,i), bot is less defined than (x,i) and (x,i) is less defined than top. |
Infinite Sum Domains
Now we have powers and sums we can define
A function (or power domain) of two domains A and B can be defined by
| Elements | { f. for all a:A, one b:B ( f(a) = b ) }. |
| - | Add bot and top as functions than map every a:A in bot and top respectively. |
| Order | For f,g: A->B, f is less defined than g if for all a:A ( f(a) is less defined than g(a) ). |
Lists
These are defined using the above function. I'd call them string operations!
Operators on Domains
We now have an algebra of domains with product, sum, and powers/functions.
Injection and Projection on Sum Domains
The book defines some useful notations/ideas for sum domains.
The book defines projection (|)and injection (in) operators. These are just like up and down casting operations in an OO language like C++. Suppose we had a domain Number which was the sum of Int and Float domains:
A condition that make sure that an element is in a particular part of the sum: For x:D1+D2+....+D[i]+..., x E D[i]::x is in D[i].
Changing Functions
Functions are going to be used to model storage. We need there to be
able to change their values (change the value stored in a location).
The book uses a common notation f[b/a] for this.
| x | f(x) |
|---|---|
| a | b |
| else | f(x) |
. . . . . . . . . ( end of section Metalanguage) <<Contents | Index>>
Simple Semantic Equations
. . . . . . . . . ( end of section Denotational Semantics) <<Contents | Index>>
Questions
Notice we can not rely on the compiler or a vendor to define the meaning of a language. The result allows programs to suddenly start misbehaving as their meaning changes.
Trying to us ENglish in a standard has lead to langauges that are paradoxical ... the meanings contradict each other, or undefined -- we can not figure out what a staement or expressions means. Formal (mathematical and/or logical) methods have tended to provide clear answers to questions and early indicators of error in a language specification.
What is the a on line 5 of Page 44
It is an example of a character. It is an element
Similarly lines 3 and 4 show a member of I and of R (real).
So each line is a member of (I+ C* + R).
So, all three lines is a sequence in (I + C* + R)*
Can you give examples of D1->D2 on page 44.
A Function domain is used to model the behavior of storage.
Suppose we have a domain of variable names Var and a domain of values Val, then storage is modelled as
So if s:Var->(Bool+Int+FLoat) we might have
Another common example is modelling changes to State. Each change is a function mapping the past into the present:
Explain the notation on page 39.
The key notation is like this:
Lattice are a useful way of looking at many things and have been recently used in sofware engineering. Here is a pretty example [ Programming_Languages in logic_42_Properties_of_Relation ] that describes languages and how they are related.
On page 45 explain the notation
The notation
In the example given
I think the book's formula s[+(3,4)] is wrong.
. . . . . . . . . ( end of section Questions) <<Contents | Index>>
Examples
Using semantic equations to evaluate expressions. Page 41.
Semantic Equations
Net
Determining the meaning of 3*2+1. Note, in my notation on web
pages the steps in a proof are linked to the rules that were applied.
Net
DON'T try to figure it out! I chose a useless program with a well known unpredictable calculation.
Your task is to remove all control structures except while loops. NO ifs, do-whiles, GOTOs, switches, ... No (_?_:_) are allowed. Assignments, conditions, expressions, input and output are ok. Your version must produce precisely the same results as the original.
Be ready to show me your code and demonstrate it before the end of the laboratory today.
Next
Study chapter 3 on semantics pages 48 to 64 inclusive.
[ 05.html ]
. . . . . . . . . ( end of section CSCI620 Session 4) <<Contents | Index>>
Glossary