Monday, March 3, 2014 COMP2130 MIDTERM Solutions

Monday, March 3, 2014
COMP2130 MIDTERM Solutions
Instructions
1) Put your name and number on the answer papers.
2) The test is 50 minutes. There are 11 questions worth a total of 41 marks
3) No aids allowed, including phones and calculators. These devices must not be one your person or desk,
whether on or off.
4) For full marks give full answers, although you need not give the authorities in proofs except if you are using
a previous theorem. Just say previous theorem or give the name of the theorem if it has a name.
5) Hand in rough work. Do not rip booklets apart.
Q1) [3] Define statement, premise and critical row in the truth table of an argument.
A statement is a sentence that is true or false.[1]
A premise is a statement in an argument that is not the conclusion.[1]
A critical row in the truth table of an argument is ta row in which all the premises are true.[1]
Q2) [1] Put the following in order of precedence from high to low. , , , , ~.
High
~
^
  [1]
Q3) [5]Show that “~(pq)” and “p ^ ~q” are logically equivalent using truth statements. Be sure to have a
concluding statement that tells me what in the truth tables make these two things logically equivalent.
1
2
p
~p
q
~q
pq ~(pq)
p ^ ~q
T
F
T
F
T
F
F
T
F
F
T
F[1]
T[1]
T [1]
F
T
T
F
T
F
F
F
T
F
T
T
F
F
|____________|
[1]
These columns are the same so 1) and 2) are logically equivalent. [1]
Q4) [3] Simplify (pq)  (p ^ ~q).
(p~q)  (p ^ ~q)  p  (q  ~q)
pt
p
[1]
[1]
[1]
Q5) [3] Use the valid argument forms that we took in class to deduce the conclusion from the premises.
1) ~r
2) p  q
3) ~r  ~q
 p  ~q
3) ~r ~q
1) ~r
4)  ~q
[1]
2) p  q
4) ~q
5) p
[1]
4) ~q
5) p
 p  ~q
[1]
Q)6 [2] Write the negation for “xD such that y  E, x+y≥1.
xD, y E such that x+y < 1.
[1]
[1]
Q7) [3] Put each statement into logic form and then rearrange the new statements into the proper order and
state the final conclusion. You may use the contrapositive form.
Sorry, I messed this question all up. I got the “only if” wrong so the second part of the question does not work
like it is suppose to.
1) People who brush their teeth look good.
2) No one who is going to a party ever fails to brush their teeth.
3) You will be popular only if you look good.
1) If you brush your teeth then you will look good. [1]
2) If you are going to a party then you will brush your teeth, [1]
3) If you are popular then you will look good.[1]
Q8) [3] Simplify -4.5, -3 mod 5, |x| if x< 0.
-5, 2 (mod 5), -x
Q9) [4] Prove from first Principals (i.e. you are not allowed to use other theorems or lemmas) that if d|a and d|b
then d|(a-b) where d,a,b Z.
Since d|a then dt = a where tZ. Since d|b then st = b where s Z. [1]So
a-b = dt-ds {subst}
= d(t-s). {algebra}[1]
Since t, s Z, then (t-s) Z {closure}.[1] Since (t-s )Z and since a-b = d(t-s), then d|(a-b) by the definition of
divides.[1]
Q10) [6] Prove that there are an infinite number of primes.
Assume (iotgac) that there are only a finite number of primes, namely p1,…,pn.[1] Now consider P= p1*…*pn
and Q=P+1.[1] From the previous lemma,[.5] we know that any number is divisible by some prime,[.5] say pj.
Now pj|Q and pj|P so pj|Q-P{by a previous lemma}[1] or pj|1. This means pj=1 [1]which contradicts that a
prime is greater than 1.[1]
So our assumption is wrong and there are an infinite number of primes.
Q11) [5] Find the inverse of 17 (mod 20) using the extended Euclidean Algorithm.
20 = 1(17) + 3
17 = 5(3)+2
3 = 1(2)+1
2 = 2(1) + 0 [2]
i
-1
0
1
2
qi
xi
1
1
5
-1
1
6
2
-7
[2]
So 17-1 -7 (mod 20)
 13 (mod 20.[1]
So the inverse of 17 modulo 20 is 13.
Bonus Question [1] You are on the island of Knaves and Knights. Knaves always lie. Knights always tell the
truth. But on this island they will only answer one question and then answer it with a one word answer. You
are at a fork in the road. One fork takes you to the cannibals. The other fork takes you to a four star hotel
which you prefer to the cannibals. You know that all natives know which fork takes you to which destination.
Luckily, there is a native before you. You don’t know whether he is a Knave or a Knight. What question do
you ask him so that you can get to the four star hotel?
If I were here yesterday and had asked you “Is this the fork to the four star hotel” would you have said yes?
[1]