CS601 2010 January FV - Exam-09-10
CS601 2010 January FV - Exam-09-10
Question #2 (8 Points)
A. Write a well founded formulae that specify the following argument, If here is an
error, identify the type of error. (2 Points)
“If your patient is breathing, she is alive. Your patient is not breathing.
Therefore, your patient is not alive.”
-------------------------------------
B. Show whether the predicates in the following page are a tautology or not in the
given interpretations: (3 Points)
1/4
α α = +/2* √-1
I. α rational numbers and irrational numbers
II. rational numbers, α imaginary numbers
III. α and are real variables in a programming language.
-----------------------------------------
C. Rewrite each of these statement so that negation are applied exclusively to
predicate. (3 Points)
Pre:{True}
S:[
1 J := 0;
2 m1 := 0;
3 m2 := 1;
4 m3 := 7;
5 m1 := m1 + m3;
6 m2 := m2 + m3;
7 m3 := m3 + m2;
]
Post: { m1 = j m2 = j + 1 m3 = 8 + j}
--------------------------------------------
B. Prove the correctness of the following program segment, (verification schemas
and proof): State the initial values that would make <Pre> S <post> a valid predicate.
(5 Points)
--------------------------------------------------------------------------------------------
Question 4: (15 points)
Pre:{ N >0}
1 i := 1;
2 k := N-1;
{INV(I,k,a)}
3 while i ≤ k do
begin
4 if (a[i] < 5)
5 then a[ i] := 5
6 i := i +1
{INV(I,k,a)}
end
1. 1: I:=1;
2. 2: while( I <= p) do
3. begin
4. 3: if (a[I] = x)
5. 4: then I :=p+1;
6. 5: I := I +1;
7. end;
8. 6: if (I = p+1) then
9. begin
10. 7: p := p+1;
11. 8: a[p] := x;
12. end;
13. Exit
4/4