Docsity

ECS 240 Homework Assignment 2 - Proving Statements about Boolean Commands and Functions - , Assignments of Programming Languages

Toggle sidebar
bg1
ECS 240: Homework Assignment 2
(Due: Tuesday, May 5, 2009)
April 21, 2009
(Exercise 1) Prove the following statement. For any boolean command band any initial state σsuch
that σ(x) is even, if [[ while bdo x:= x+ 2 ]]σ=σ0and if σ06=⊥then σ0(x) is even. Unlike in previous
assignment, this time you should use denotational semantics for the proof.
(Exercise 2) Monotonicity and continuity
1. Show that any strict function (f(⊥) = ⊥) on a flat domain is both monotone and continuous.
2. Show that on finite domains, monotonicity implies continuity (i.e., any monotonic function fon a finite
domain Dis also continuous).
3. Give an example function fthat is monotonic, but not continuous.
(Exercise 3) Recall that we obtained the least fixed point of a continuous function F:D→Dby starting
with ⊥=F0(⊥) and repeatedly applying Fto the result. Let’s explore what happens if we do not start
with ⊥but with some other element x∈D.
1. What is a necessary and sufficient condition for the sequence Fi(x) to be a chain, that is xvF(x)v
F2(x)v · · · ?
2. Prove that if the condition above holds then FiFi(x) is a fixed-point and furthermore it is the least
of all fixed-points that are wthan x.
3. Find a necessary and sufficient condition for the FiFi(x) to be the overall least-fixed point.
(Exercise 4) We obtained a recursive equation for the semantics of the while statement in IMP. Then
we argued that the equation admits too many solutions and we made the informal observation that all of
the solutions disagree only on inputs for which the while does not terminate. Now we’ll explore this issue
formally.
Consider a flat domain Dand Fa continuous function (F∈(D−→ D)−→ (D−→ D)). We’ll refer to
the least-fixed point of Fas LFP(F). Recall that we defined the semantics of while to be just such a least
fixed point for some function F. Prove or disprove both implications in the following statement for some
arbitrary continuous function f: (D−→ D):
f=F(f) iff ∀x∈D.LFP(F)(x) = ⊥or f(x) = LFP(F)(x)
1

Partial preview of the text

Download ECS 240 Homework Assignment 2 - Proving Statements about Boolean Commands and Functions - and more Assignments Programming Languages in PDF only on Docsity!

ECS 240: Homework Assignment 2

(Due: Tuesday, May 5, 2009)

April 21, 2009

(Exercise 1) Prove the following statement. For any boolean command b and any initial state σ such that σ(x) is even, if [[ while b do x := x + 2 ]]σ = σ′^ and if σ′^6 = ⊥ then σ′(x) is even. Unlike in previous assignment, this time you should use denotational semantics for the proof.

(Exercise 2) Monotonicity and continuity

  1. Show that any strict function (f (⊥) = ⊥) on a flat domain is both monotone and continuous.
  2. Show that on finite domains, monotonicity implies continuity (i.e., any monotonic function f on a finite domain D is also continuous).
  3. Give an example function f that is monotonic, but not continuous.

(Exercise 3) Recall that we obtained the least fixed point of a continuous function F : D → D by starting with ⊥ = F 0 (⊥) and repeatedly applying F to the result. Let’s explore what happens if we do not start with ⊥ but with some other element x ∈ D.

  1. What is a necessary and sufficient condition for the sequence F i(x) to be a chain, that is x v F (x) v F 2 (x) v · · ·?
  2. Prove that if the condition above holds then

i F^

i(x) is a fixed-point and furthermore it is the least of all fixed-points that are w than x.

  1. Find a necessary and sufficient condition for the

i F^

i(x) to be the overall least-fixed point.

(Exercise 4) We obtained a recursive equation for the semantics of the while statement in IMP. Then we argued that the equation admits too many solutions and we made the informal observation that all of the solutions disagree only on inputs for which the while does not terminate. Now we’ll explore this issue formally. Consider a flat domain D and F a continuous function (F ∈ (D −→ D) −→ (D −→ D)). We’ll refer to the least-fixed point of F as LFP(F ). Recall that we defined the semantics of while to be just such a least fixed point for some function F. Prove or disprove both implications in the following statement for some arbitrary continuous function f : (D −→ D):

f = F (f ) iff ∀x ∈ D.LFP(F )(x) = ⊥ or f (x) = LFP(F )(x)