Professional Documents
Culture Documents
L9 Design Verification
L9 Design Verification
Design Verification
The approach is to
• assign algebraic symbols to the program variables
• restate the program as one or more equations using
these symbols
• analyze the behavior of the equations
begin
X := X + Y;
Y := X – Y;
X := X – Y;
end
# Instruction X Y
Initial values A B
1 X := X + Y A+B
2 Y := X - Y A
3 X := X - Y B
Final values B A
Assume nMax = 3.
20 minutes
3 if Input[Length] = ‘ ‘
4 Length := Length - 1
6 else State := 3
This is a defect.
3 if Input[Length-1] = ‘ ‘ true
4 Length := Length - 1 3
6 else State := 3
1 Length := length(Input)
State := 0
2 repeat ‘ AB ‘ 3 1
3 if Input[Length-1] = ‘ ‘ false
4 Length := Length - 1
6 else State := 3 3
1 Length := length(Input)
State := 0
2 repeat ‘ AB…’ 3 2
3 if Input[Length-1] = ‘ ‘ false
4 Length := Length - 1
6 else State := 3 3
while WhileTest
begin
LoopPart
end
f=1
i=1
while i != n {i not equal to n}
begin
i=i+1
f=f*i
end
i=0
j=n
while i != j
begin
k = (i + j) div 2
if a[k] < x
i=k
else
j=k
end
So
• if x > a[n-1] then the desired result is i = n
• if n = 0 then the desired result is i = 0