

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Dr. Ferucio Laurent¸iu T¸ IPLEA Visiting Professor School of Computer Science University of Central Florida CSB # Orlando, FL 32816- Tel: (407) 823- E-mail: [email protected]
COP 5021 (Program Analysis) Spring 2006
Let S be the while program
y := 1; while ¬(x = 1) do (y := y ∗ x; x := x − 1)
under the interpretation D = N and I 0 (∗) = ∗, I 0 (−) = − and I 0 (n) = n, for all n ≥ 0). Let γ 6 = ⊥. Then,
φI (S)(γ) = φI (while ¬(x = 1) do (y := y ∗ x; x := x − 1))(φI (y := 1)(γ)) = φI (while ¬(x = 1) do (y := y ∗ x; x := x − 1))(γ[y/I 0 (1)]) = φI (while ¬(x = 1) do (y := y ∗ x; x := x − 1))(γ[y/1]) = μ(F )(γ[y/1]),
where F (f )(γ′) is given by
for any f ∈ [Γ⊥→Γ⊥] and γ′^ ∈ Γ⊥. Then,
Let f 0 = ⊥(Γ⊥→Γ⊥) be the least element of [Γ⊥→Γ⊥], i.e., the function given by f 0 (γ′) = ⊥, for all γ′^ ∈ Γ⊥.
We know that μ(F ) = sup({F n(f 0 )|n ≥ 0 }). We compute the elements of this chain:
F (f 0 )(γ′) =
⊥, if γ′(x) 6 = 1 γ′, if γ′(x) = 1
F 2 (f 0 )(γ′) =
⊥, if γ′(x) 6 = 1 and γ′(x) 6 = 2 γ′[y/γ′(y) ∗ 2][x/1], if γ′(x) = 2 γ′, if γ′(x) = 1
=
⊥, if γ′(x) 6 = 1 and γ′(x) 6 = 2 γ′[y/γ′(y) ∗ 2][x/1], if γ′(x) = 2 γ′[y/γ′(y) ∗ 1][x/1], if γ′(x) = 1
for any γ′. By mathematical induction we get:
F n(f 0 )(γ′) =
⊥, if γ′(x) < 1 or γ′(x) > n γ′[y/γ′(y) ∗ j ∗ · · · ∗ 2 ∗ 1][x/1], if γ′(x) = j and 1 ≤ j ≤ n,
for any γ′^ and n ≥ 1. Then,
μ(F )(γ′) =
⊥, if γ′(x) < 1 γ′[y/γ′(y) ∗ n ∗ · · · ∗ 2 ∗ 1][x/1], if γ′(x) = n ≥ 1 ,
for any γ′. Substituting γ′^ by γ[y/1] we get
μ(F )(γ[y/1]) =
⊥, if γ(x) < 1 γ[y/ 1 ∗ n ∗ · · · ∗ 2 ∗ 1][x/1], if γ(x) = n ≥ 1 ,
for any γ 6 = ⊥. Then, the semantics is:
M(S)(γ) =
γ[y/ 1 ∗ n ∗ · · · ∗ 2 ∗ 1][x/1], if γ(x) = n ≥ 1 undefined, if γ(x) < 1 ,
for any γ. For instance, if γ(x) = 5, then M(S)(γ) = 1 ∗ 5 ∗ 4 ∗ 3 ∗ 2 ∗ 1.