Unit 3 - Reasoning Using Logic
Unit 3 - Reasoning Using Logic
Overview
• Basic Notations and Operators
CSIT113 • Reasoning using Logic
Problem Solving • Apply basic to solve logic puzzle
UNIT 3
REASONING USING LOGIC
1 2
1
3 4
12/24/2021
5 6
P Q PɅQ
T T T P Q P∨Q
T F F T T T
F T F T F T
F F F F T T
F F F
• And is true only if both P and Q are true • Or is true as long as at least one of P or Q is true
7 8
12/24/2021
Properties of logical Or
Equivalence (≡) • Commutative: p ∨ q ≡ q ∨ p
• The Equivalence operator combines two propositions, P and Q. • Associative: p ∨ ( q ∨ r) ≡ (p ∨ q) ∨ r
• Idempotent: p ∨ p ≡ p
• Has neutral element false: p ∨ false ≡ p
P Q P≡Q
T T T • Distributes over boolean equality:
T F F p ∨ ( q ≡ r) ≡ ((p ∨ q) ≡ (p ∨ r))
F T F
All the equivalence relations can be proved by constructing a truth table, e.g. The
F F T
following truth table shows the first relation:
p q p∨q q∨p
T T T T Since for each case, the values
• Equivalence is true if P and Q have the same truth value of p∨q and q∨p are identical.
T F T T
F T T T Hence,
F F F F p∨q ≡q∨p
9 10
11 12
12/24/2021
3 , • De Morgan’s laws
~(p ∨ q) ≡ ~p Ʌ ~q
~(p Ʌ q) ≡ ~p ∨ ~q
Compound statements in brackets must be evaluated first: from
inner to outer. Then, evaluate . Next, evaluate and . Last, • We can show all of these with truth tables.
last, evaluate and .
13
14
Q
Simplifying Logic
Testing propositions using Truth table • We can express all possible logical operators in terms of just two operators:
• We can use truth tables to test propositions to determine whether they • Not and And
are theorems. • Not and Or
• E.g. P (Q P) • P ∨ Q ≡ ~(~P Ʌ ~Q)
P Q QP P (Q P) P Q PQ ~P ~Q ~P Ʌ ~Q ~(~P Ʌ ~Q)
T T T T T T T F F F T
T F T T T F T F T F T
F T F T F T T T F F T
F F T T F F F T T T F
• Because the last column is all true, P (Q P) is a theorem • As the columns for P ∨ Q and ~(~P Ʌ ~Q) have identical values, hence, P ∨
Q ≡ ~(~P Ʌ ~Q)
15 16
12/24/2021
Q Q
Even simpler Nor
• ~P ≡ P nor P
• The two operators Nor and Nand make life even easier… • P Ʌ Q ≡ ~P nor ~Q
≡ (P nor P) nor (Q nor Q)
P Q P nor Q P Q P nand Q
T T F T T F
• P ∨ Q ≡ ~(P nor Q)
T F F T F T ≡ (P nor Q) nor (P nor Q)
F T F F T T
F F T F F T
17 18
19 20
12/24/2021
21 22
23 24
12/24/2021
25 26
27 28
12/24/2021
Since A ≡ (A ≡ G), it can only be the first case or third case. Hence, G is
true and A can be true or false
29 30
Knights and Knaves Logic Puzzle: Problem 2 Knights and Knaves Logic Puzzle: Problem 3
• A will answer “yes” if he is a knight and so is B or if he is a knave and • There are three natives, A, B and C.
so is B.
• A says “B and C are of the same type”.
• In other words: • What can we conclude about the number of knights present?
• A’s answer ≡ (A ≡ B)
• B’s answer ≡ (B ≡ A)
• Using the symmetry property:
• (A ≡ B) ≡ (B ≡ A)
• So B’s answer will be the same as A’s.
31 32
12/24/2021
or F F T F T
F F F F F
• A is a knave and one of B and C is a knight
• From the truth table, we conclude that the four possible cases are the 4 rows that have
• There is an odd number of knights. the value “T” for A ≡ (B ≡ C) (indicated by “”).
• And, each of above-mentioned row has odd number of knights. Hence, we can
conclude that there are odd number of knights.
33 34
Knights and Knaves Logic Puzzle: Problem 4 Knights and Knaves Logic Puzzle: Problem 4
• There are three natives, A, B and C. • Let Q be the unknown question we must ask C, with truth value Q.
• A says “B and C are of the same type”. • Let A, B and C denote the propositions A, B, C is a knight.
• What question can we ask C to find out if A is telling the truth? • The response we want is A so:
• (C ≡ Q) ≡ A
• Which we regroup to give:
• Q ≡ ( C ≡ A)
• But A ≡ (B ≡ C) so substituting for A we get:
• Q ≡ (C ≡ (B ≡ C) )
• Which simplifies (after rearrangement) to:
• Q≡B
• In other words, the question is “Is B a knight?”.
35 36
12/24/2021
37 38
39 40
12/24/2021
Knights and Knaves Logic Puzzle: Problem 7 Knights and Knaves Logic Puzzle: Problem 7
• Following the same rules as before:
• You come to a fork in the road. • (A ≡ Q) ≡ L
• There is a restaurant down one of the two branches. • Which we can rearrange as:
• There is a native at the fork. • Q ≡ (A ≡ L)
• What question do you ask to find out if the restaurant lies down the left fork?
• So our question is “Is the truth value of the statement ‘you are a knight’ the
same as the truth value of ‘the restaurant lies down the left fork’?”
• Our question can be rephrased as “Is it the case that the statement that the
left fork leads to the restaurant is equivalent to your being a knight?”
41 42
T T T T
T F F F
F T F T
F F T F
43