Professional Documents
Culture Documents
Maarten de Rijke
mdr@wins.uva.nl
http://www.wins.uva.nl/ mdr/Teaching/index.html
January 28, 1998
Monotone functions 1
I 1
f X =N n X
I 2
f X = [ f27g
X
I 3
f X = \ f7 9 2898g
X ; ;
I 4
f X =f 2n Xj is primeg n
I 5
f X = f2 j 2 g
n n X
January 28, 1998
Monotone functions 2
are monotone:
I 0 F g = g
(
I 1 =
g 1 if g = g 2 16
, where g = g .2
F g
g 2 otherwise
(
I gs 6 0
if sx =
(F 0 g )s =
s 0
if sx =
v v
Lemma 4.30 Let (D; ) and (D 0; 0) be ccpo’s, and let f : D ! D
0
be a
monotone function. If Y is a chain in D , then
I f j 2 g is a chain in
f d d Y D
0
I F f j 2 g v (F ).
0
f d d Y
0
f Y
What if Y = ? 6 ;
Monotonicity is not enough
January 28, 1998 4
Monotone functions do preserve chains, but they do not preserve least upper
bounds on chains.
Consider f : P (N [ f g) ! P (N [ f g) defined by
a a
(
X if X is finite
f X =
X [f g
a if X is infinite
Then f is monotone, but least upepr bounds are not always preserved:
G G
0
f j 2 g=
fd d Y f ( Y )
does not always hold.
v v
Let (D; ) and (D 0; 0) be ccpo’s, and consider a (total) function f : D ! D
0
.
Then f is continuous if
I is monotone
f
I F f j 2 g = (F
0
fd d Y f Y )
v
Lemma Let (D; ) and (D 0; 0) be ccpo’s, and let f : D v ! Dand0
f : D
0 0 00
!
D be continuous functions. Then f
0
f : D ! 00
D is a continuous
function.
First: f f
0
is monotone.
G G
f j 2 f j 2 gg = ( f j 2 g)
00
f d
0 0
d
0
fd d Y f
0 0
fd d Y
Proof:
1. FIX f is well-defined
(
if sx = gs 6 0
Consider the function (F 0g )s =
s if sx = 0
First, F 0 is continuous! Second, determine the set F 0n f ? j 0g, where ? is
n
and 1 = if x = 0.
g s s s
Example: factorial program
January 28, 1998 9
where
(
(F g )s =
g s ( [y 7! ( y
s x)][x 7! (sx)
s 6
1]) if sx = 1
s if sx = 1
We need to ensure that
F is continuous.
Then the Fixed Point Theorem applies, and gives us the semantics for the
factorial program.
Example: factorial program
January 28, 1998 10
(F 0?) = undef
s
(
(F 1?) s =
undef if sx = 1 6
if sx = 1
8
s
2?)
>
< undef 6
if sx = 1 and sx = 26
(F = s[y 7! (sy 2][x 7! 1] if sx = 2
s
>
:s if sx = 1
(
if sx < 1 or sx > n
?
(F n )s =
undef
s[y7! (sy) 2 1][x 7!
1] if sx = j and 1 j
(
j n
undef if sx < 1
(FIX F )s =
s[y7! (sy) 2 1][x 7!
n 1] if sx = n and 1
j n
January 28, 1998
Denotational semantics 11
I Sds[[ := ]] = [ 7! A[[ ]] ]
x a s s x a s
I Sds[[skip]] = id
I Sds[[ 1 ; 2]] = Sds[[ 2]] Sds[[ 1]].
S S S S
Important tools
I Let f : D !
D be a continuous function on the ccpo (D; v) with least
?
element . Then
G
FIX f = f n ? j 0g
f n
undef otherwise
Well-definedness of Sds
January 28, 1998 13
S
The semantic equations for ds define a total function from Stm to
State ! State
, .
I 0 State ! State
Let g : , ,p: State ! ftt g and define
;
0
F g = cond(p; g; g ).
Then F is continuous.
I 0 State ! State
Let g : , , and define F g = g 0.
g
Then F is continuous.
January 28, 1998
Next Time 14
Material
I Equivalence
I Extensions
Reading material
Exercises