A First Course in Logic: Solutions To Exercises: Mark V. Lawson October 18, 2017
A First Course in Logic: Solutions To Exercises: Mark V. Lawson October 18, 2017
SOLUTIONS TO EXERCISES
Mark V. Lawson
Introductory exercises
1. (a) C was a knight. The key point is the following. If you ask a knight
what he is he will say he is a knigh whereas if you ask a knave
what he is he is obliged to lie and so also say that he is a knight.
Thus no one on this island can say they are a knave. This means
that B is lying and so is a knave. Hence C was correct in saying
that B lies and so C was a knight.
(b) A is a knave, B a knight and C a knave. If all three were knaves
then C would be telling the truth which would contradict the fact
that he is a self-proclaimed knave. Therefore C is a knave and
there is either one knight or there are two knights. Suppose that
there were exactly two knights. Then these would have to be A
and B. But they contradict each other. It follows that exactly one
of them is a knight. Hence A is knave and B is a knight.
2. Sam drinks water and Mary owns the aardvark. The following table
shows all the information you should have deduced.
1 2 3 4 5
House Yellow Blue Red White Green
Pet Fox Horse Snails Dog Aardvark
Name Sam Tina Sarah Charles Mary
Drink Water Tea Milk Orange juice Coffee
Car Bentley Chevy Oldsmobile Lotus Porsche
You should check that the above solution is consistent with all the
information you have been given.
To solve the problem, a reasonable starting point is the following table.
1 2 3 4 5
House
Pet
Name
Drink
Car
3
Using clues (h), (i) and (n), we can make the following entries in the
table.
1 2 3 4 5
House Blue
Pet
Name Sam
Drink Milk
Car
There are a number of different routes from here. I shall just give some
examples of how you can reason. Clue (a) tells us that Sarah lives in
the red house. Now she cannot live in the first house, because Sam
lives there, and she cannot live in the second house because that is
blue. We are therefore left with the following which summarizes all the
possibilities so far.
1 2 3 4 5
House Yellow? White? Green? Blue Red? Red? Red?
Pet
Name Sam Sarah? Sarah? Sarah?
Drink Milk
Car
Clue (b) tells us that Charles owns the dog. It follows that Sam cannot
own the dog. We are therefore left with the following possibilities.
1 2 3 4 5
House Yellow? White? Green? Blue Red? Red? Red?
Pet Fox? Horse? Snails? Aardvark?
Name Sam Sarah? Sarah? Sarah?
Drink Milk
Car
4. This difficult question is taken from the famous book: Gödel, Escher,
Bach. The answer to the question is no. The key is to focus on the
number of Is in a string which we call the I-count. Rule-I does not
change the I-count. Rule-II doubles the I-count. Rule-III reduces the
I-count by 3. Rule-IV does not change the I-count. We begin with
a string whose I-count is 1 and our goal is to obtain a string whose
I-count is 0. The problem reduces to showing that applying the above
rules to a string whose I-count is 1 never results in a string whose I-
count is 0. This amounts to showing that if 3 does not divide n then 3
does not divide 2n, and if 3 does not divide n then 3 does not divide
n − 3.
8 1 3 4 2 9 7 6 5
4 6 2 5 7 1 8 3 9
7 9 5 3 6 8 1 4 2
2 4 7 1 5 3 9 8 6
5 3 9 8 4 6 2 1 7
6 8 1 2 9 7 4 5 3
9 7 8 6 1 5 3 2 4
1 2 6 7 3 4 5 9 8
3 5 4 9 8 2 6 7 1
6. This is called the Collatz problem or the 3x+1 problem. Nobody has yet
found a proof. It is therefore conceivable that there is a number where
the process described in the question does not terminate. I included
this question to show that unsolved problems are not limited to what
you might regard as advanced mathematics. Bear in mind that the
question can be rephrased as asking whether a very simple program
prints the output 1 for any allowable input.
5
Exercises 1.1
1.
(a) T .
(b) F .
(c) T .
(d) F .
(e) T .
(f) T .
(g) F .
(h) T .
(i) T .
(j) T .
You would falsify this statement if you could find a card that had a
vowel on one side but did not have an even number on the other. Thus,
clearly, I need to turn over the first card to check that it has an even
number on the other side. The next two cards play no role. Now look
at the last card. If it had a vowel on the other side then it would falsify
the statement. So, I need to turn that card over as well. Thus I only
need turn over two cards.
It is possible to answer the question using just PL though it really needs
the notion of logical equivalence described in Section 1.4. Observe that
the truth tables for p → q and ¬q → ¬p are the same. Thus these wff
have the same meaning. The first wff immediately tells us to turn over
the first card. The second wff says that ‘a card had an odd number
on one side → it has a consonant on the other’. Thus we need to turn
over the fourth card to check that it does show a consonant.
This question has its origins in the psychology of reasoning. Read the
wikipedia article if you want to know more. What is interesting is that
6
Beer 25 Cola 16
My guess is that you immediately saw that you had to check the age
of the guy buying beer and the 16 year old to check that they were
not trying to buy booze. But the logical structure of this problem is
identical to the one originally posed.
7
Exercises 1.2
1.
(a)
∨ →
¬ q q p
(b)
p →
→ →
q r → →
p q p r
(c)
8
→ ¬
p ¬ p
(d)
p ¬
(e)
→ →
p → ∧ r
q r p q
9
Exercises 1.3
1.
(a) This is satisfiable with only one truth assignment p = T and q = F
leading to an F .
(b) This is satisfiable with only one truth assignment p = T and q = F
leading to an F .
(c) This is satisfiable with the satisfying truth assignments being p =
T, q = T, r = T and p = T, q = T, r = F and p = F, q = F, r = F .
2.
(a) This is not a tautology.
(b) This is a tautology.
(c) This is a tautology.
(d) This is not a tautology.
(e) This is a tautology.
3. There are potentially many different solutions to this question.
Column wff
1 (p ∨ ¬p) ∧ (q ∨ ¬q)
2 p∨q
3 p ∨ ¬q
4 p
5 p→q
6 q
7 p↔q
8 p∧q
9 ¬(p ∧ q)
10 p⊕q
11 ¬q
12 ¬(p → q)
13 ¬p
14 ¬p ∧ q
15 ¬(p ∨ q)
16 (p ∧ ¬p) ∧ q
10
Exercises 1.4
2. (a) p ∨ ¬p is a tautology.
(b) p ∧ ¬p is a contradiction.
(c) Clear.
(d) Clear.
(e) Clear.
(f) Clear.
(g) If p is true then p → f is false. If p is false then p → f is true. It
follows that p → f ≡ ¬p.
(h) If p is true than t → p is true. If p is false then t → p is false. It
follows that t → p ≡ p.
(a)
(p → q) ∧ (p ∨ q) ≡ (¬p ∨ q) ∧ (p ∨ q) since x → y ≡ ¬x ∨ y
≡ (¬p ∧ p) ∨ q by distributivity
≡ F ∨ q since ¬p ∧ p is a contradiction
≡ q.
11
(b)
(p → r) ∨ (q → r) ≡ (¬p ∨ r) ∨ (¬q ∨ r) since x → y ≡ ¬x ∨ y
≡ ¬p ∨ r ∨ ¬q ∨ r by associativity
≡ ¬p ∨ ¬q ∨ r ∨ r by commutativity
≡ ¬p ∨ ¬q ∨ r by idempotence
≡ ¬(p ∧ q) ∨ r by De Morgan
≡ (p ∧ q) → r since x → y ≡ ¬x ∨ y.
(c)
(p → q) ∨ (p → r) ≡ (¬p ∨ q) ∨ (¬p ∨ r) since x → y ≡ ¬x ∨ y
≡ ¬p ∨ ¬p ∨ q ∨ r by associativity and commutativity
≡ ¬p ∨ q ∨ r by idempotence
≡ p → (q ∨ r) since x → y ≡ ¬x ∨ y.
Exercises 1.5
(p ⊕ q) ∧ (r ⊕ s) ∧ (t ⊕ u) ∧ (v ⊕ w) ∧ (p ⊕ r) ∧ (q ⊕ s)
∧ (t ⊕ v) ∧ (u ⊕ w) ∧ (p ⊕ t) ∧ (r ⊕ v) ⊕ (q ⊕ u) ∧ (s ⊕ w).
(f) This
V9 is similar to what we did in the above two parts. Put C =
j=1 Cj where
9
^
Cj = xor(p1,j,k , . . . , p9,j,k ).
k=1
(i) We now consider when P is true. Suppose that you come up with a
potential solution to this Sudoku. This means that for each cell cij
you enter a digit k. This assigns the value true to the atom pi,j,k .
Once you have done this for every cell, all the remaining atoms are
assigned the value false. Thus a potential solution to the puzzle
leads to a truth assignment to all 729 atoms. With respect to
this truth assignment, P is either true or false. It will be false if
any one of the constraints is violated. If none of the constraints
is violated, then your potential solution is correct. Thus a correct
solution to the puzzle leads to a truth assignment to the atoms
that satisfies P .
Now suppose that you have found a truth assignment that satisfies
P . If Pi,j,k is true then put digit k in cell cij . I claim that because
of the way that P is defined, this will lead to every empty cell
being assigned a digit. This is because if P is true then E is
true and so each cell contains exactly one digit. Thus the truth
assignment leads to a potential solution to the puzzle. But since
P is true all constraints are satisfied and so the Sudoku has, in
fact, been solved.
3. Define A to be the conjunction of the following wff.
• Initial state: q(0) = 1.
15
• Input constraints:
Exercises 1.6
1.
¬p p nand p p nor p
p ∧ q (p nand q) nand (p nand q) (p nor p) nor (q nor q)
p ∨ q (p nand p) nand (q nand q) (p nor q) nor (p nor q)
p→q p nand (q nand q) ((p nor p) nor q) nor ((p nor p) nor q)
x y nand nand ¬y ¬x
T T F F F F
T F T F T F
F T T F F T
F F T T T T
Exercises 1.7
1. (a) p ∧ ¬q ∧ r.
(b) (p ∧ q ∧ ¬r) ∨ (p ∧ ¬q ∧ ¬r).
(c) (p ∧ q ∧ r) ∨ (p ∧ ¬q ∧ r) ∨ (¬p ∧ q ∧ r) ∨ (¬p ∧ ¬q ∧ r).
18
Exercises 1.8
1. (a)
(p → q) → p ≡ (¬p ∨ q) → p
≡ ¬(¬p ∨ q) ∨ p
≡ (¬¬p ∧ ¬q) ∨ p
≡ (p ∧ ¬q) ∨ p NNF and DNF.
(b)
(c)
3. (a)
p q r A
T T T T
T T F F
T F T T
T F F F
F T T T
F T F F
F F T T
F F F F
4. (a)
(d)
A ≡ ((p ∧ q) → r) ∧ (¬(p ∧ q) → r)
≡ (¬(p ∧ q) ∨ r) ∧ (¬¬(p ∧ q) ∨ r)
≡ (¬(p ∧ q) ∧ (p ∧ q)) ∨ r
≡ r.
p q r s u
T T T F F
Exercises 1.9
1. (a) A says that you should 2-colour the graph so that adjacent vertices
have different colours.
(b) It is a contradiction.
(c) It is impossible to 2-colour this graph in this way.