
























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Solutions to exercises related to functional verification, software testing, and verification. The exercises cover topics such as correctness tables, while loops, repeat until loops, and invariant status theorem. The solutions are prepared by dr. Stephen m. Thebaut from the university of florida.
Typology: Study notes
1 / 32
This page cannot be seen from the preview
Don't miss anything!

























Software Testing and Verification
Prepared by
Stephen M. Thebaut, Ph.D.
University of Florida
Given
= if x>=y then x,y := y,x f^1
= (x>y
x,y := y,x | true
f^2
= (x>y
x,y := y,x | x<y
f^
= (x
ā y
x,y := y,x)
āIdentityā function:
x,y := x,y
f^3
= (x
ā y
x,y := y,x)
Fill in the following ācorrectness tableā:
f^1 f^2
P f^3
C=CompleteS=SufficientN=Neither
Prove
f
P] where
f^ = (x=
x,y := 17,20 |
true
x,y := x,-x)
and
is:
if x= 17 then
y := x+ else
y := -x end_if_else
Complete correctness conditions for
f^ = [if
p
then
else
where
g
] and
h
] have been shown:
Prove:
p^
(f
g
Prove:
p^
(f
g
¬p
(f
h
Working correctness questions:^ ā When
p
is
true,
does
f equal
g
p
is
false,
does
f equal
h
f^ = (x=
x,y := 17,20 | true
x,y := x,-x)
if x=17 then
y := x+
elseelse
y := -x
end_if_else
By observation,
g
= x,y := x,x+3 h^ = x,y := x,-x
Therefore, by the Axiom of Replacement, it issufficient to show: f^ = (x=
x,y := 17,20 | true
x,y := x,-x)
= [if
p
then
(x,y := x,x+3)
else
(x,y := x,-x)
When
p
is
true
does
f equal
g
g^
h
(x=17) When
p
is
true
does
f equal
g
(x=17)
f =
(x,y := 17,20))
(x=17)
g^
= (x,y := x,x+3)
= (x,y := 17,20))
When
p
is
false
does
f equal h?
(xā 17)
(f
= (x,y := x,-x))
(xā 17)
h^
= (x,y := x,-x))
For program
below, where all variables are
integers, hypothesize a function
f for [
P] and
prove
f
while i<n do
t := t
āx
i := i+1i := i+ end_while
Hypothesized
f:
(i<n
i,t := n,tx
n-i
| iā„n
Alternative
f : (iā¤n
i,t := n,tx
n-i
| i>n
Does it make any difference which we use?
Complete correctness conditions for
f^ = [while
p
do
g
where
g
] has been shown:
Prove:Prove:
term
(f,P)
p^
(f
f o
g
p^
(f
n-i
n-i
p
Is loop termination guaranteed for anyargument of
f
(Show this using the Method of
Well-Founded Sets.)
Does (iā„n)
f
Does (i<n)
f
f o
g
(i<n)
f
n-i
(i<n)
f o
g
f o
(i<n)
f o
g
f o
What is
f when applied after
g
changes the
initial value of
i?
There are two cases to consider:
i=n-
i<n-
( Recall:
f
n-i
Does (i<n)
f
f o
g
(i<n)
f
n-i
(i<n)
f o
g
f o
case a:
(i=n-1)
f o
g
o
o
o
o
n-i
n-i
For program
below, where all variables
are integers, hypothesize a function
r
for
] and prove
r
repeat:repeat:
x := xā1y := y+ until x=
For program
below, where all variables
are integers, hypothesize a function
r
for
] and prove
r
repeat:repeat:
x := xā1y := y+ until x=
Hypothesized
r:
(x>
x,y := 0,y+2x)