FORMAL METHODS FINAL EXAM - New
FORMAL METHODS FINAL EXAM - New
PROGRAMME: CS , SE
YEAR OF STUDY: II
EXAMINATION INSTRUCTIONS
1. (a) Using truth tables, prove whether the following are tautologies, contradications or a
contingent.Give reason for your answer.
i. ∼ (P ∨ (P ∧ Q)) ∨ P (5 marks)
ii. ((P → Q) → P ) → P (5 marks)
(b) Let f:A → B and g : B → C be functions. Prove that if (g ◦ f ) is injective, then f is
injective. (5 marks).
(c) For each of the following, state whether its true or false giving reason for your answer.
A, B and C are sets.
i. If |A| = 3 and |B | = 4, then |AUB | = 7. (5 marks)
ii. if |A| = 3,|B | = |C | = 5,|A ∩ B | = 2, |B ∩ C | = 3 and |A ∩ C | = |A ∩ B ∩ C | = 1,
then |A ∪ B ∪ C | = 8. (5 marks)
(d) Let f : Z → Z by f (x ) = x 2 + 1 and g : Z → Z by g(x ) = 2x − 3. What is:-
i. (g ◦ f )(4)? (5 marks)
ii. (f ◦ g)(2)? (5 marks)
(e) Translate each of the following statements into the language of sentential logic. Use
the first letter of the capitalised word(s).
i. It is RAINING or OVERCAST, but in any case it is not SUNNY. (1 mark)
ii. I will SUCCEED only if I WORK hard and take RISKS. (1 marks)
iii. It is not RAINING, but it is still too WET to play (1 marks)
iv. If neither JAY nor KAY is home this weekend, we will go to the BEACH;otherwise,
we will STAY home. (1 marks)
v. Either Jones is a FOOL or he is DISHONEST (1 marks)
1
SECTION B:(60 Marks)
2. (a) Prove whether the following sequents are valid or not without using truth tables
(P ∨ Q) ∧ R
i. (P ∧ R) ∨ (Q ∧ R) (5 marks)
(P ∧ Q) → R
ii. [(P → Q) → R] → [(P → Q) → R] (5 marks)
(b) Construct a formal derivation of the conclusion for each of the following arguments.
i. ∀ x [(Fx ∨ Gx ) → Hx ]; ∀ x [Hx → (Jx ∧ Hx )] / Fa → Ka (5 marks)
ii. ∀ x (Fx → Gx ); ∼ ∃ x (Gx ∧ Hx )/ ∀(Fx →∼ Hx ) (5 marks)
3. (a) Using the suggested abbreviations (the capitalized words), translate each of the fol-
lowing into the language of predicate logic.
2
4. (a) Use diagrams to state whether each of the following functions is injective or surjective.
i. f (x ) = |x − 2| (5 marks).
ii. g(x ) = x 2 − 2 (5 marks).
(b) Let f : A → B be a function where A and B are finite sets and |A|=|B |. Prove that f
is injective if and only if it is surjective. (5 marks).
(c) Find the inverse of f(x)= - 31 x + 1 (5 marks)
5. (a) Given a queue which is a sequence of 10 integers. In a z schema we declare the queue
as q=seq Z. Define a predicate in the same schema to represent the fact that the
queue can only hold 10 integers. Note: Don’t draw the schema. (5 marks).
(b) Given a system which records peoples birthdays, and is able to issue a reminder when
the day comes round. Define a state space schema for this system. (5 marks).
(c) In a Z specification of a system which will keep track of students who have handed in
Assignments, there are clearly four sets involved...
i. STUDENT (all students)
ii. Class (all the students in the class)
iii. HandedIn (all the students in the class who have handed in their assignment)
iv. NotHandedIn (all the students in the class who have not handed in their assign-
ment)
Write a z schema to model handing in of a student assignment. (10 marks).
6. (a) Given that set A={1,2,3,4,5} and set B ={4,5,6,7}. Compute the following.
i. |P(A ∪ B )| (4 marks)
ii. A∆B (3 marks)
iii. A x B (2 marks)
iv. |(A − B ) ∪ (B − A)| (3 marks)
v. (B x A)∪A (3 marks)
(b) Using Sets A and B in a) above, prove (or disprove) that |A∆B )|= |A|+|B |- |A ∩ B |
(5 marks).