0% found this document useful (0 votes)
56 views21 pages

A First Course in Logic: Solutions To Exercises: Mark V. Lawson October 18, 2017

This document provides solutions to exercises from a logic textbook. It includes solutions to introductory exercises on puzzles involving knights and knaves. It also provides the solution to an exercise involving deducing information from clues about houses, pets, names, drinks and cars. Further solutions cover exercises involving logical connectives, determining if a statement is a tautology or satisfiable, and the Collatz problem.

Uploaded by

Invisible Bro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views21 pages

A First Course in Logic: Solutions To Exercises: Mark V. Lawson October 18, 2017

This document provides solutions to exercises from a logic textbook. It includes solutions to introductory exercises on puzzles involving knights and knaves. It also provides the solution to an exercise involving deducing information from clues about houses, pets, names, drinks and cars. Further solutions cover exercises involving logical connectives, determining if a statement is a tautology or satisfiable, and the Collatz problem.

Uploaded by

Invisible Bro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

A FIRST COURSE IN LOGIC:

SOLUTIONS TO EXERCISES

Mark V. Lawson

October 18, 2017


2

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

The reasoning now continues . . ..


3. There are two possible secret numbers consistent with the information
given: 2745 or 4725.
4

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.

5. Here is the completed puzzle taken from Solving sudoku by Michael


Mepham available at www.sudoku.org.uk/PDF/Solving_Sudoku.pdf.

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 .

2. The following statement is supposed to be true

‘a card has a vowel on one side → it has an even number on


the other side’.

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

if the same problem is couched in the language of social rules it becomes


a lot easier to solve. Here is an example. You have to be 18 or over to
buy alcohol in the UK. Below is some data about four people: on one
side is their age and on the other what they want to buy. Who do you
have to check?

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

1. To show that A ≡ B construct truth tables for A and B separately and


show that they are the same.

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.

3. Check that both (p ⊕ q) ⊕ r and p ⊕ (q ⊕ r) have the following truth


table.
p q r
T T T T
T T F F
T F T F
T F F T
F T T F
F T F T
F F T T
F F F F

4. It is important to lay out the solutions clearly with proper annotations.

(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.

5. (a) A(p, q, r, s) is true when exactly one of p, q, r, s is true.


(b) Define
n
! !
_ ^
A(p1 , . . . , pn ) = pi ∧ ¬(pk ∧ pl ) .
i=1 1≤k<l≤n

We claim that A(p1 , . . . , pn ) is true when exactly one of the pi is


true. Suppose first, that ps is true and all other atoms are false.
The first bracket is clearly true. Now look at the second bracket.
Then pk ∧ pl where k 6= l is either ps ∧ pl where l 6= s or pk ∧ pl
where k 6= l 6= s. Therefore, under the specific truth assignment
above, pk ∧ pl is always false and so the second bracket is true. It
follows that A(p1 , . . . , pn ) is true. Now suppose that A(p1 , . . . , pn )
is true. Then both brackets have to be true. It follows that at
least one pi is true. Suppose that at least two were true: ps and
pt where s < t. Then the second bracket would contain the wff
¬(ps ∧ pt ) which is false giving us a contradiction. It follows that
exactly one pi is true.
I will use the notation xor(p1 , . . . , pn ) instead of A(p1 , . . . , pn ).
12

6. By symmetry, it is enough to show that  A ↔ B implies that 


A∗ ↔ B ∗ . Let the atoms in A and B be p1 , . . . , pn . Suppose that
A∗ ↔ B ∗ is not a tautology. Then there is some assignment of truth
values to the atoms such that A∗ is true and B ∗ is false, or vice-versa.
Observe that ¬A∗ = A(¬p1 , . . . , ¬pn ) and ¬B ∗ = B(¬p1 , . . . , ¬pn ).
Thus A(¬p1 , . . . , ¬pn ) is false and B(¬p1 , . . . , ¬pn ) is true. Thus by
reversing the truth values assigned to p1 , . . . , pn it follows that A is
false and B is true but this contradicts the fact that A and B assume
the same truth values for the same truth assignments to the atoms.
13

Exercises 1.5

1. (a) The wff A is the following

(p ⊕ q) ∧ (r ⊕ s) ∧ (t ⊕ u) ∧ (v ⊕ w) ∧ (p ⊕ r) ∧ (q ⊕ s)
∧ (t ⊕ v) ∧ (u ⊕ w) ∧ (p ⊕ t) ∧ (r ⊕ v) ⊕ (q ⊕ u) ∧ (s ⊕ w).

(b) There are 28 = 256 rows of the truth table.


(c) 2.
(d) The atoms assigned the value T will tell us which numbers occur
in which cells.
(e) The rows of the truth table for A that have the output T are as
follows
p q r s t u v w
T F F T F T T F
F T T F T F F T
These two rows of the truth table correspond to the following two
solutions of the Sudoku.
1 2 2 1
2 1 1 2

2. (a) I = p1,2,1 ∧ p1,4,4 ∧ p1,5,2 ∧ . . . ∧ p9,8,7 . There are 29 atoms in all.


(b) Fix i and j. Then Eij = xor(pi,j,1 , . . . , pi,j,9 ).
W
(c) E = 1≤i,j≤9 Ei,j . Thus E is true when every cell contains exactly
one digit.
(d) Fix i and k. Then xor(pi,1,k , pi,2,k , . . . , pi,9,k ) is true when the digit
k occurs exactly once in row i. Thus
9
^
Ri = xor(pi,1,k , pi,2,k , . . . , pi,9,k )
k=1

is true when each digit occurs exactly once in row i.


(e) R = 9i=1 Ri is true when each row contains each digit exactly
V
once.
14

(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

(g) We look at block 5 where 4 ≤ i ≤ 6 and 4 ≤ j ≤ 6. Then


9
^
W5 = xor(p4,4,k , p4,5,k , p4,6,k , . . . , p6,6,k )
k=1

and W5 is true when each digit occurs exactly once in block 5. In


a similar way, we may define Wl to be true when each digit occurs
exactly once in block l.
(h) W = 9l=1 Wl .
V

(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:

((i(0) = a) ⊕ (i(0) = b)) ∧ ((i(1) = a) ⊕ (i(1) = b)).

• Unique state at each instant of time t = 0, t = 1 and t = 2:

xor ((q(0) = 1), (q(0) = 2))


∧ xor ((q(1) = 1), (q(1) = 2))
∧ xor ((q(2) = 1), (q(2) = 2)) .

• First set of possible state transitions:

(q(0) = 1) ∧ (i(0) = a) → (q(1) = 1)


∧ (q(0) = 1) ∧ (i(0) = b) → (q(1) = 2)
∧ (q(0) = 2) ∧ (i(0) = a) → (q(1) = 1)
∧ (q(0) = 2) ∧ (i(0) = b) → (q(1) = 2).

• Second set of possible state transitions:

(q(1) = 1) ∧ (i(1) = a) → (q(2) = 1)


∧ (q(1) = 1) ∧ (i(1) = b) → (q(2) = 2)
∧ (q(1) = 2) ∧ (i(1) = a) → (q(2) = 1)
∧ (q(1) = 2) ∧ (i(1) = b) → (q(2) = 2).

• Finally, there is the actual input string of length 2.

(i(0) = a) ∧ (i(1) = b).

We look at the circumstances under which A is true. ‘q(0) = 1’ is true


and so ‘q(0) = 2’ is false; ‘i(0) = a’ is true and so ‘i(0) = b’ is false. We
therefore deduce from the first set of state transitions that ‘q(1) = 1’ is
true and so ‘q(1) = 2’ is false. From the second set of state transitions
we deduce that ‘q(2) = 2’ is true and so ‘q(2) = 1’ is false.
16

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)

2. (a) We have that p → q ≡ ¬p ∨ q. It follows that p ∨ q ≡ ¬p → q.


Thus from ¬ and → we can construct ∨, but ∨ and ¬ together
are adequate, and so ¬ and → are adequate.
(b) Observe that p → f ≡ ¬p. Adequacy now follows from part (a).

3. (a) If T ∗ T = T we would never be able to construct negation using


∗.
(b) If F ∗ F = F we would never be able to construct negation using
∗.
(c) The possible truth tables for ∗ are as follows.

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

If we look at the third column, the value of x1 ∗ . . . ∗ xn will


either be xn or ¬xn . It will therefore be true for exactly half the
truth assignments. But there are plenty of wff which are not true
for exactly half the truth assignments. Therefore it cannot be
adequate on its own. A similar argument applies to the fourth
column.
17

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)

p → (q → p) ≡ ¬p ∨ ¬q ∨ p NNF and DNF.

(c)

(q ∧ ¬p) → p ≡ ¬(q ∧ ¬p) ∨ p


≡ (¬q ∨ ¬¬p) ∨ p
≡ ¬q ∨ p ∨ p
≡ ¬q ∨ p NNF and DNF.

(d) (p ∨ q) ∧ r is already in NNF and (p ∨ q) ∧ r ≡ (p ∧ r) ∨ (q ∧ r) is


in DNF.
(e) p → (q ∧ r) ≡ ¬p ∨ (q ∧ r) is in NNF and DNF.
(f) (p∨q)∧(r → s) ≡ (p∨q)∧(¬r∨s) is in NNF and (p∨q)∧(¬r∨s) ≡
(p ∧ ¬r) ∨ (p ∧ s) ∨ (q ∧ ¬r) ∨ (q ∧ s) is in DNF.

2. We use the calculations from Question 1 above.

(a) (p ∧ ¬q) ∨ p ≡ (p ∨ p) ∧ (¬q ∨ p) ≡ p ∧ (¬q ∨ p).


(b) (¬p ∨ ¬q ∨ p).
(c) (¬q ∨ p).
(d) (p ∨ q) ∧ (r).
(e) ¬p ∨ (q ∧ r) ≡ (¬q ∨ q) ∧ (¬p ∨ r).
(f) (p ∨ q) ∧ (¬r ∨ s).
19

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

(b) (p ∧ q ∧ r) ∨ (p ∧ ¬q ∧ r) ∨ (¬p ∧ q ∧ r) ∨ (¬p ∧ ¬q ∧ r).


(c)
p q r ¬A
T T T F
T T F T
T F T F
T F F T
F T T F
F T F T
F F T F
F F F T

(d) (p ∧ q ∧ ¬r) ∨ (p ∧ ¬q) ∧ ¬r) ∨ (¬p ∧ q ∧ ¬r) ∨ (¬p ∧ ¬q ∧ ¬r).


(e) (¬p ∨ ¬q ∨ r) ∧ (¬p ∨ q ∨ ¬r) ∧ (p ∨ ¬q ∨ r) ∧ (p ∨ q ∨ r).

4. (a)

((p ∧ q) → r) ∧ (¬(p ∧ q) → r) ≡ (¬(p ∧ q) ∨ r) ∧ (¬¬(p ∧ q) ∨ r)


≡ (¬p ∨ ¬q ∨ r) ∧ ((p ∧ q) ∨ r).

(b) (¬p ∧ p ∧ q) ∨ (¬p ∧ r) ∨ (¬q ∧ q ∧ p) ∨ (¬q ∧ r) ∨ (r ∧ p ∧ q) ∨ r.


(c) (¬p ∨ ¬q ∨ r) ∧ (p ∨ r) ∧ (q ∨ r).
20

(d)

A ≡ ((p ∧ q) → r) ∧ (¬(p ∧ q) → r)
≡ (¬(p ∧ q) ∨ r) ∧ (¬¬(p ∧ q) ∨ r)
≡ (¬(p ∧ q) ∧ (p ∧ q)) ∨ r
≡ r.

5. (¬p ∨ ((¬q ∨ r) ∧ (¬r ∨ q))) ∧ (p ∨ (q ∧ ¬r) ∨ (r ∧ ¬q)). This question


illustrates the fact that although we can write any wff in NNF, there
are good reasons for not always doing so.

6. (a) (q → p) ∧ (r → q). Satisfiable with all atoms taking the value F .


(b) ((q ∧ r) → p) ∧ ((s ∧ u) → f ) ∧ ((p ∧ q) → r) ∧ (t → p) ∧ (t → q).
Satisfiable with the following truth assignment

p q r s u
T T T F F

(c) (t → p) ∧ (t → q) ∧ ((p ∧ q) → f ) ∧ (p → r). Unsatisfiable


21

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.

You might also like