2 - Logic (Part 1)
2 - Logic (Part 1)
LOGIC
Logic is a very useful topic in computer science. It is applied in proving programs
correct; databases [where you study about relational algebra and relational calculus];
and Artificial Intelligence, which is about reasoning, etc.
LOGIC
PROPOSITIONAL LOGIC
Lec 1-2
PREDICATE LOGIC
Lec 3-4
LOGICAL INFERENCE
Lec 5
RESOLUTION PRINCIPLE
Lec 6
METHODS OF PROOF
Lec 7
NORMAL FORMS
Lec 8
Non-Propositions
None of the following statements is a proposition:
(a) X + Y > 4
It is true or false depending on the value you assign to the variables X and Y so;
it does not have a unique truth value.
(b) X = 3
You cannot associate a unique truth value to this statement.
Propositional Variable
A propositional variable such as P, Q, R… denotes an arbitrary proposition with
unspecified truth value. Just as a value, 4 can be assigned to an algebraic variable 𝑥,
you can assign a truth value to the proposition P, Q or R, …
Propositional variables can be connected with logical connectives.
Logical Connectives
These following are logical connectives; AND, OR, NOT.
P and Q
P or Q
Not P
EXAMPLE. Consider the following propositions:
P: John is 6” tall.
Q: There are 4 cows in the barn.
From these, the compound statements follow:
P and Q: John is 6” tall and there are cows in the barn.
[This statement will be true when both P and Q are true i.e., P is true and Q is
true.]
P or Q: John is 6” tall or there are 4 cows in the barn.
[This compound statement is true when either P or Q or both is true. This is
called an Inclusive OR.]
The following are truth tables for the logical connectives:
i. AND denoted by ˄
P Q P˄Q
F F F
F T F
T F F
T T T
P Q P˄Q
0 0 0
0 1 0
1 0 0
1 1 1
This is the truth table for AND
ii. OR denoted by ˅
P Q P˅Q
0 0 0
0 1 1
1 0 1
1 1 1
Whereas...
Kayode is home or Kayode is out.
In this case, only one proposition can be true so, you use an Exclusive Or.
Either Kayode is home or Kayode is out.
Note: you have to be careful because sometimes they are used in an ambiguous
manner. So, when you want to transcribe an English sentence to a logical statement or
vice-versa, you have to be wary of which OR is involved.
v. Implications denoted as ⇒
P implies Q written as P⇒Q
In some books, it’s written as P ⊃ Q or P→Q
P is called the premise, hypothesis or antecedent.
Q is called the conclusion or consequence.
Truth table for P ⇒ Q is given below:
P Q P⇒Q
0 0 1
0 1 1
1 0 0
1 1 1
This truth table is based on Greek logic; Indian logic does not permit a premise and
conclusion not to be related.
There is a possible confusion about the implication’s truth table that you need to be
clear about: The antecedent and conclusion may not be related.
EXAMPLE: If the moon is made of cheese, then earth is not round.
In the example above, the compound statement is true because it is of the form F ⇒ F.
In the [Greek] truth table, you must give a truth value to the antecedent and conclusion
even though they are not related.
Conditions for an Implication to true:
i. When the premise and conclusion are both false
ii. When the conclusion is true
iii. When the premise and conclusion are both true
Conditions for an implication to be false:
i. When the premise is true and the conclusion is false
However, P ⇒ Q is same as ¬Q ⇒ ¬P
You will find this contrapositive situation very useful. For instance, …
EXAMPLE (showing a contrapositive statement):
“A prime number is not a perfect number” can be written as
“If 𝑥 is a prime number, then it is not a perfect number.” or
“A perfect number is not a prime number.”
Solution:
i. (Q ˄ ¬P) ⇒ P
P Q ¬P Q ˄ ¬P (Q ˄ ¬P) ⇒ P
0 0 1 0 1
0 1 1 1 0
1 0 0 0 1
1 1 0 0 1
Consequence Premise
ii. [(P ˄ Q) ˅ ¬R] ⇔ P
Tautology
A tautology is a propositional form whose truth value is true for all possible values of its
propositional variables.
EXAMPLE: P ˅ ¬P
This statement is always true. If P is false, ¬P will true, which makes the whole
expression true. Likewise, if P is false, ¬P will be true hence, the whole expression is
true [by disjunction]. Such a statement is called a tautology.
Contingency
This is a propositional form, which is neither a tautology nor a contradiction.
EXAMPLE: The truth table for these statements
[(P ˄ Q) ˅ ¬R] ⇔ P
(Q ˄ ¬P) ⇒ P
Shows that each proposition is a possibility or a condition because in some cases, they
are true and in some other, they are false.
Logical Identities
P ⇔P˅P Idempotence of ˅
P ⇔P˄P Idempotence of ˄
(P ˅ Q) ⇔ (Q ˅ P) Commutativity of ˅
(P ˄ Q) ⇔ (Q ˄ P) Commutativity of ˄
[(P ˅ Q) ˅ R] ⇔ [P ˅ (Q ˅ R)] Associativity of ˅
[(P ˄ Q) ˄ R] ⇔ [P ˄ (Q ˄ R)] Associativity of ˄
¬(P ˅ Q) ⇔ (¬P ˄ ¬Q) De Morgan’s law
¬(P ˄ Q) ⇔ (¬P ˅ ¬Q) De Morgan’s law
[P ˄ (Q ˅ R)] ⇔ [(P ˄ Q) ˅ (P ˄ R)] Distribution of ˄ over ˅
[P ˅ (Q ˄ R)] ⇔ [(P ˅ Q) ˄ (P ˅ R)] Distribution of ˅ over ˄
(P ˅ 1) ⇔ 1
(P ˄ 1) ⇔ P
(P ˅ 0) ⇔ P
(P ˄ 0) ⇔ 0
(P ˅ ¬P) ⇔ 1 Tautology
(P ˄ ¬P) ⇔ 0 Absurdity
P ⇔ ¬(¬P) Double negation
(P ⇒ Q) ⇔ (¬P ˅ Q) Implication
(P ⇔ Q) ⇔ [(P ⇒ Q) ˄ [(Q ⇒ P)] Equivalence
[(P ˄ Q) ⇒ R] ⇔ [(P ⇒ (Q ⇒ R)] Exportation
(P ⇒ Q) ⇔ (¬Q ⇒ ¬P) Contrapositive
LECTURE 2
Recap
We considered the following and their associated truth tables:
• propositions P and Q
• logical operations P ˄ Q and P ˅ Q
• unary operation ¬P
• exclusive operator P ⊕ Q
• implication P ⇒ Q
• equivalence P ⇔ Q
• converse of P ⇒ Q is Q ⇒ P
Note:
Is not always necessary to have 2k rows for the truth table. For example: to show that a
propositional form is a contingency, it is enough to show on one row that the resultant
expression takes a value of 1; and on another row that the resultant expression takes a
value of 0. Without writing all the 2k rows, this sufficiently shows that the statement is a
contingency because some assignments take the value of 1 and the others, 0.
EXAMPLE: In order to show that implication is not associative, consider the truth table
for (P ⇒ Q) ⇒ R and P ⇒ (Q ⇒ R).
Solution:
P Q R P ⇒ Q Q⇒R (P ⇒ Q) ⇒ R P ⇒ (Q ⇒ R)
0 0 0 1 1 0 1
0 0 1 1 1 1 1
0 1 0 1 0 0 1
0 1 1 1 1 1 1
1 0 0 0 1 1 1
1 0 1 0 1 1 1
1 1 0 1 0 0 0
1 1 1 1 1 1 1
EXAMPLE: Show on a truth table that this implication (P ⇒ Q) ⇔ (¬P ˅ Q) is true. Tell
what it is.
P Q P⇒Q ¬P ¬P ˅ Q (P ⇒ Q) ⇔ (¬P ˅ Q)
0 0 1 1 1 1
0 1 1 1 1 1
1 0 0 0 0 1
1 1 1 0 1 1
EXAMPLE: Show on a truth table that the propositions below are equivalent.
(P ⇔ Q) ⇔ [(P ⇒ Q) ˄ (Q ⇒ P)]
Solution:
P Q P⇔Q P⇒Q Q⇒P (P ⇔ Q) ⇔ [(P ⇒ Q) ˄ (Q ⇒ P)]
0 0 1 1 1 1
0 1 1 1 1 1
1 0 0 0 0 1
1 1 1 0 1 1
Solution:
P Q P⇒Q ¬Q ¬P ¬Q ⇒ ¬P
0 0 1 1 1 1
0 1 1 0 1 1
1 0 0 1 0 0
1 1 1 0 0 1
“If I don’t get wet, then I have not fallen into the lake.”
These rules or logical identities can be used to simplify logical expressions or well-
formed formulae of propositional logic.
We will use the aforementioned logical identities or rules to simplify expressions in the
following examples.
(a) Q ⇔ (R ˄ ¬P)
Solution:
I will go to town if and only if I have time and it is not snowing.
(b) R ˄ Q
Solution:
I have time and I will go to town.
(c) (Q ⇒R) ˄ (R ⇒ Q)
Solution:
I will go to town only if I have time and if I have time I will go to town.
There are tautologies that involve implications – these are called rules of inference. We
shall consider them later.
For Simplification (P ˄ Q) ⇒ P
From (P ˄ Q), you can conclude P because (P ˄ Q) will be true only when P is
true and Q is true.
EXERCISE 1
A certain country is inhabited only by people who either always tell the truth or always
tell lies and who will respond to questions only with a “yes” or a “no”. A tourist comes to
a fork in the road, where one branch leads to the capital and the other does not. There
is no sign indicating which branch to take, but there is an inhabitant, Mr Zee, standing at
the fork. What single yes/no question should the tourist ask him in order to determine
which branch to take?
Solution:
Left Right
Inhabi
tant
The tourist has to ask a single yes/no question such that if the inhabitant answers yes,
he must go left; ‘no’, he must go right.
But the tourist does not know if Mr Zee, the inhabitant is a truth teller or a liar. So, there
are four possibilities: The left road may lead to the capital or the right road may lead to
the capital; and the inhabitant may be a truth teller or a liar. These possibilities are
represented below:
Left Right
Truth Teller (TT) Yes Yes
Liar No No
If the answer is ‘yes’, the tourist will take the left road.
If the answer is ‘no’, the tourist will take the right road.
But the liar always lies.
So, the correct answer the tourist should expect from a truth teller and liar is
respectively given below:
Left Right
Truthful Yes No
Liar No Yes
“Is it true that you are a truth teller and the left road leads to the
capital or you are a liar and the right road leads to a capital?”
“If I ask you whether the left road leads to the capital, you will say
‘yes’, won’t you?”
“If I ask the other kind of person whether the left road leads to the
capital, he will say ‘yes’, won’t he?”
EXERCISE 2
Five persons A, B, C, D, E, are in a compartment in a train. A, C and E are men and B
and D are women. The train passes through a tunnel and when it emerges, it is found
that E is murdered. An emergency enquiry is held where A, B, C and D make the
following statements:
A: I am an innocent; B was talking to E when the train was passing through
the tunnel.
B: I am innocent; I was not talking to E when the train was passing through
the tunnel.
C: I am innocent; D committed the murder.
D: I am innocent; one of the men committed the murder.
Four of these eight statements are true and four are false. Assuming only one person
committed the murder, who did it?
Hint:
• Remember that A and C are men while B and D are women
• Each person has made two statements
• Four of the statement are true while the other four are false
• Assume four statements to be true and four false
• Assuming only one person committed the murder, who did?
• From the eight statements, how do you know who committed the murder?
• A, B, C and D say “I am innocent”.
But only one person committed the murder so out of A, B, C and D, three persons must
be saying the truth and one person must be lying
So, there are eight statements and each person makes statement 1 and statement 2 –
represented below:
A: 1 2
B: 1 2
C: 1 2
D: 1 2
3–T 3–F
1–F 1–T
Out of the remaining four statements, 3 will be false and 1 must be true.
Examining the second statements of A and B
A: B was talking to E when the train was passing through the tunnel
B: B was not talking to E when the train was passing through the tunnel.
It can be observed that one statement is a negation of the other.
So, either of them may be false and the other true.
A 2 T
One of them is true and the other false
B 2 F
In that case,
A 1, C 1, D 1, B 2 are true while the remaining (4)
statements are false. This satisfies the condition.
EXERCISE 3
You are in the catacombs, there are two guards by a fork in the tunnel and you have
been told that one always lies and the other never does. What question would you ask
any of them in order to get the right direction?
Solution:
The question you can ask is:
“Which way would the other guard tell me to go?”
LECTURE 3
EXERCISE 4
A tourist is enjoying an afternoon refreshment in a local pub in England when the
bartender says to him: “Do you see those three men over there? One is Mr. X, who
always tells the truth, another is Mr. Y, who always lies, and the third is Mr Z, who
sometimes tells the truth and sometimes lies. (That is, Mr. Z answers ‘yes’ or ‘no’ at
random without regard to the question.) You may ask them three yes or no questions,
always indicating which man should answer. If, after asking these three questions, you
correctly identify Mr. X, Mr. Y, and Mr. Z, they will buy you a drink.” What yes/no
questions should the thirsty tourist ask?
Hint:
The waiter then introduces the three men to the tourist and tells him that one is Mr X…
X Truth Teller
Y Liar
Z Unpredictable (Sometimes tells lies or truth )
The tourist should ask three questions that indicate who will answer. Also, the questions
should be asked in such a way that the next question is determined by the answer to
the preceding question.
If the yes/no question is correct,
X will answer ‘yes’;
Y will answer ‘no’;
Z will randomly say ‘yes’ or ‘no’, without any consideration.
The first question is important – it should be asked in such a way that Mr Z is eliminated
because it is easier to deal with a person that always tells the truth or always tells lies
than someone that is unpredictable. Therefore, you have to discover who Mr Z is and
eliminate him.
After eliminating Mr Z, the second and the third questions can be asked.
Alternatively
This puzzle is similar to Exercise 3 except for the addition of the random option.
The best you can do is to spend two questions working out who Mr Z is, then ask one
question, like the ones in Exercise 3, in order to identify the truth teller and the liar. i.e.
Figuring out who is Mr Z the unpredictable:
I ask X: “I give you two statements – is exactly one of them true? The
statements are
1. Do you always speak the truth?
2. Does Y tell truth and lie randomly?”
If Mr X answers YES it can have three possible cases.
a) X tells the truth always – that is the only true statement so
Mr Y is a liar
b) X answers my question randomly.
c) X is a liar so both statements are false therefore, Mr Y is not
a random person.
Here, the common thing is that Y is not a random / unpredictable
person.
Similarly, if Mr X answers NO, there are three possible cases:
(a) X lies always – that is the only truth statement so Mr Y is
the liar.
(b) X answers the question randomly.
(c) X tells the truth always so both statements are false
therefore Mr Y is not random
So, with one question exhausted, we can identify Mr Z as a
random person while Mr Y is not random.
Next thing is to go to that person, Mr Y, who is not random and ask him a
truism, which is a universal truth like “Does Sunday come before
Monday?” A YES or NO will confirm that Mr Y is a truth teller or a liar
respectively.
Suppose we ascertain the fact that Mr Y is a truth teller, we then go on to
ask him “Does Mr X always lie?”
So, we immediately know the status of X and Z based on the
answer.
The same analysis can be done in any case and the tourist will recognize X, Y and Z
and enjoy his drink.
EXERCISE 5
Brown, Jones and Smith are suspected of income tax evasion. They testify under oath
as follows:
Brown: Jones is guilty and Smith is innocent
Jones: If Brown is guilty, then so is Smith.
Smith: I am innocent but at least one of the others is guilty.
(a) Assuming everybody told the truth, who is/are innocent or guilty?
(b) Assuming the innocent told the truth and the guilty lied, who is/are
innocent/guilty?
Hint:
We have to translate these statements into logical notations before solving the problem.
The first part is easy…
Solution
(a) Assuming everybody told the truth…
From the first statement, we can infer that
• Jones is guilty and Smith is Innocent. JG ˄ SI
• If Brown is guilty, then so is Smith. BG ⇒ SG
The contrapositive is ‘If Smith is not guilty, Brown is not guilty.
¬SG ⇒ ¬BG
(b) Assuming the innocent told the truth and the guilty lied…
From the statements, the logical interpretations follow
• Brown: JG ˄ SI
• Jones: BG ⇒ SG or ¬SG ⇒ ¬BG
• Smith: SI ˄ (JG ⊕ BG) or SI ˄ (JI ⊕ BI)
If Jones lies, the implication ¬SG ⇒ BG holds so, we can conclude that:
Brown is guilty, Jones is guilty and Smith is innocent.
First, let us consider Brown – From Smith’s statement, there are two possibilities:
Brown is innocent or guilty – If he is innocent, he must be telling the truth
Brown
Innocent Guilty
B I B G G G G
J G J I I G G
S I S I G I G
✓
Considering the first guilty possibility G-I-I from the table, Jones is innocent so he is
telling the truth. Recall his statement BG ⇒ SG or ¬SG ⇒ ¬BG. This makes this
possibility to be ruled out.
The next possibility G-I-G looks correct based on Jones’ statement and his innocent
status.
Considering the possibility G-G-I
If Brown is guilty, his statement (JG ˄ SI) should be incorrect. So, the negation
¬ (JG ˄ SI) = (JI ˄ SG) should be the truth
Also, considering the possibility GGG
In this case Jones says that BG ⇒ SG This corresponds to his actual statement
but it is not supposed to be so since Jones is guilty and cannot tell the truth.
Therefore, the correct answer is
Brown is guilty, Jones is innocent and Smith is guilty.
¬B ˄ J ˄ ¬S or BG ˄ JI ˄ SG
RECAP
We have discussed propositions, the logical connectors ˄, ˅, ⇒, and ⇔; unary operators
¬; identities of logical connectors; identities of logical expressions; simplification of
logical expressions; tautology, contradictions and contingency; and how to use logic to
solve problems.
PREDICATES AND QUANTIFIERS
Earlier, we have seen that a statement like 𝑥 > 3, 𝑥 + 𝑦 = 7 are assertions and not
propositions because the truth value of the statements will depend on the value
assigned to the individual variables 𝑥 and 𝑦.
In English language, we have statements like the following:
She is tall and fair.
X was born in city Y in the year Z.
He was born in city Y in the year Z.
Here, we do not know who the pronouns she / he refers to. Such statements are called
predicates. The value assigned to them determines the truth value of the statement.
Predicates are usually expressed in the form of P(x, y, z).
Forms of Predicates
The table below shows the general forms of predicates.
Predicate form Description
P(x) Unary predicate has an individual variable
Q(x, y) Binary predicate
P(x1, x2,…,xn) n-ary predicate or n-place predicate
The values of the variables are chosen from the Universe of Set also known as
Underlying Universe or Universe of Discourse. In the previous example, M(x, y) – the
value of x and y are gotten from the set of human beings. Also, for Sum(x, y, z) and the
programming example, 𝑥, y and z can take values from the set of real numbers, integers
or non-negative integers – In such cases, you have to specify the underlying universe
because a statement which is true for real numbers may not always be true for integers.
Similarly, for the predicate “𝑥 was born in y in the year z”:
𝑥 takes values from the set of human beings;
y takes values from the set of years; and
z takes values from the set of cities.
Here, 𝑥 is bound while y and z are free variables so, it is a binary predicate. These free
variables can still be bound using quantifiers or by assigning values to them. For
instance, if
𝑦 = 2, we will have
𝑥P(𝑥, 2, 𝑧). This is now a u-nary predicate.
Furthermore,
𝑧𝑥P(𝑥, 𝑦, 𝑧) is now a proposition, which takes true or false
values when the underlying universe is specified.
¬P(2) ˄ P(3))
Now, if U = N = {0, 1, 2, 3, … }
𝑥P(𝑥) P(0) ˄ P(2) ˄ P(3) ˄ … Infinite conjunction
𝑥P(𝑥) P(0) ˅ P(1) ˅ P(2) ˅… Infinite disjunction
Note:
Be mindful of the scope of the quantifiers: Take note of the variable it is meant to bind.
I.e.
If in addition to the individual variables 𝑥1 , 𝑥n , 𝑥3 ,… 𝑥n of a predicate P(𝑥1 , 𝑥n , 𝑥3 ,… 𝑥n ),
there is an additional variable y and you make the following statement:
yP(𝑥1 , 𝑥n , 𝑥3 ,… 𝑥n ), such that y ≠ 𝑥1 , 𝑥n , 𝑥3 ,… or 𝑥n
Binding with 𝑦 will not affect P(𝑥1 , 𝑥n , 𝑥3 ,… 𝑥n ) because the scope
of the predicate does not involve 𝑦.
In the same vein,
𝑦P(𝑥1 , 𝑥n , 𝑥3 ,… 𝑥n ) is equivalent to P(𝑥1 , 𝑥n , 𝑥3 ,… 𝑥n )
(b) 𝑥𝑦P(𝑥, 𝑦)
It is read as “There exists 𝑥 such that for all values of 𝑦, P(𝑥, 𝑦) is true.”
Here, the variable 𝑥 is bound by the existential quantifier while 𝑦 is bound
by the universal quantifier.
Also, the value of 𝑥 is fixed and independent of the value of 𝑦.
(c) 𝑦𝑥P(𝑥, 𝑦)
“For any 𝑦, there exists 𝑥 such that P(𝑥, 𝑦) is true.
Here, the value of 𝑥 depends on the value of 𝑦.
EXAMPLE: To show how changing the order of quantifiers affects the meaning of a
statement.
(a) 𝑥𝑦[𝑥 is married to 𝑦]. This is true because it asserts that for any x, there is a
person 𝑦 to whom 𝑥 is married to". However,
(b) 𝑦𝑥[𝑥 is married to 𝑦]. This is false because it asserts that there is some
person in the universe who is married to everyone.
(c) 𝑥𝑦[𝑥 + 𝑦 = 0] “For all 𝑥, there exists a y such that 𝑥 + 𝑦 = 0” is true because
for any value of 𝑥, there is a value y such that y = -𝑥, which makes the
proposition 𝑥 + 𝑦 = 0 true.
(d) 𝑦𝑥[𝑥 + 𝑦 = 0] states that “There exists a y such that for all 𝑥, 𝑥 + 𝑦 = 0”.
This assertion means that the value of y can be chosen independently of the
value of 𝑥. Since no 𝑦 exists, which yields zero when added to an arbitrary
integer, this proposition is false. (To make this statement true, you have
to interchange the quantifiers.)
(e) 𝑥𝑦!𝑧[𝑥 + 𝑦 = 𝑧] asserts that for every pair of integers 𝑥 and 𝑦, there is a
unique integer 𝑧, which equals their sum. This assertion is true.
(Interchanging the last two quantifiers results in the next proposition:)
(f) 𝑥!𝑧𝑦[𝑥 + 𝑦 = 𝑧] asserts that for every 𝑥, a unique 𝑧 can be chosen such
that no matter what y is added to 𝑥, 𝑥 + 𝑦 = 𝑧. This proposition is false.
(i) 𝑦! 𝑥[𝑥. 𝑦 = 0] is false because at 𝑦 = 0, any value of 𝑥 will yield zero whereas
the statement implies that it should be a unique value of 𝑥.
Similarly,
(j) 𝑦! 𝑥[𝑥 + 𝑦 < 0] is false because for any value of 𝑦, there are many values of 𝑥
for which the sum of 𝑥 and 𝑦 is negative.
EXAMPLE: To show that interchanging the position of the same type of quantifiers does
not alter the meaning of a statement.
Consider the set of natural numbers as the underlying universe i.e.
𝐔=𝐍
𝑥𝑦P(𝑥, 𝑦) can be expanded as
[𝑦P(0, 𝑦)] ˄ [𝑦P(1, 𝑦)] ˄ [𝑦P(2, 𝑦)] ˄… which can be represented as
[P(0, 0) ˄ P(0, 1) ˄ P(0, 2),…]
˄ [P(1, 0) ˄ P(1, 1) ˄ P(1, 2),…]
˄ [P(2, 0) ˄ P(2, 1) ˄ P(2, 2),…]
˄…
Recall that the operator, ˄, is commutative and associative so, the order in which P(0,
0), P(0, 1),… occur can be interchanged in a conjunction.
Interchanging the order results in;
[P(0, 0) ˄ P(1, 0) ˄ P(2, 0),…]
˄ [P(0, 1) ˄ P(1, 1) ˄ P(2, 1),…]
˄ [P(0, 2) ˄ P(1, 2) ˄ P(2, 2),…]
˄…
Which represents
[𝑥P(𝑥, 0)] ˄ [𝑥P(𝑥, 1)] ˄ [𝑥P(𝑥, 2)] ˄ …
Grouping this altogether results in:
𝑥𝑦P(𝑥, 𝑦)
QED
The same argument can be used for the quantifier, , except that disjunction, ˅ will be
used in this case. ˅ is commutative and associative so,
𝑥𝑦 ⇔ 𝑦𝑥
Note:
In algebra, when we write
𝑥 + 𝑦 = 𝑦 + 𝑥 and
𝑥 + (𝑦 + 𝑧) = (𝑥 + 𝑦) + 𝑧
we implicitly are writing
𝑥𝑦[𝑥 + 𝑦 = 𝑦 + 𝑥] and
𝑥𝑦𝑧[𝑥 + (𝑦 + 𝑧) = (𝑥 + 𝑦) + 𝑧] respectively.
Scope of 𝑦
Scope of 𝑥
The rows with “n.a” are not applicable because when xP(x) is true, 𝑥P(𝑥)cannot be
false.
The columns for 𝑥P(𝑥) ⇒ 𝑥Q(𝑥) and 𝑥P(𝑥) ⇒ 𝑥Q(𝑥)) are not identical but one
implies the other.
For an implication, the antecedent can be false wand the consequence true so,
𝑥P(𝑥) ⇒ 𝑥Q(𝑥) implies 𝑥P(𝑥) ⇒ 𝑥Q(𝑥).
3. 𝑥¬P(𝑥) ⇔ ¬𝑥P(𝑥)
4. 𝑥P(𝑥) ⇒ P(𝑥)
5. 𝑥¬P(𝑥) ⇔ ¬𝑥P(𝑥)
6. [𝑥P(𝑥) ˄ Q] ⇔ 𝑥[P(𝑥) ˄ Q]
This means that if Q does not involve 𝑥, whether 𝑥 is inside or outside
the bracket is immaterial.
7. [𝑥P(𝑥) ˅ Q] ⇔ 𝑥[P(𝑥) ˅ Q]
If Q does not involve 𝑥, whether 𝑥 is inside or outside the bracket is
immaterial.
c
near c
at the value c with the vertical value k, within a short interval near c, the function can
only tale values which are nearer to k. The graphical representation of this limit is
represented above.
i. In logical notation, this limit is written as
∈∈>0 δ x[|x - c| < δ ⇒ |f(x) – k| < ∈]
c
This means that if you take some interval near c, the difference between f(x) and k will
be more than ∈.
EXAMPLE: Translate each of the following sentences into logical notations, firstly,
using no existential symbols and secondly, using no universal quantifier.
1. Not all cars have carburetors.
2. No dogs are intelligent
3. Some numbers are not real
Solution:
1. Not all cars have carburetors
Let Car(𝑥): 𝑥 is a car
Carbu(𝑥): 𝑥 has carburetor
(a) ¬𝑥(Car(𝑥) ⇒ Carbu(𝑥))
Hint:
Generally, 𝑥 goes with ⇒ in the bracket while x goes with ˄ in the bracket.
• WFF of predicate logic is valid if it is true for all universes and all interpretations
of predicate variables. For instance, the expression
𝑥P(𝑥) ⇒ 𝑥P(𝑥) is always true. It is a valid statement.
• If some WFF is true for some universe and some interpretation, it is said to be
satisfiable.
• If the WFF is not true for any universe or any interpretation, it is daid to be
unsatisfiable.
Valid corresponds to tautology in propositional logic.
Satisfiable corresponds to contingency…
Unsatisfiable corresponds to contradiction…
LOGICAL INFERENCE
There are several systems such as arithmetic systems where U = I. Also, there are
rules and axioms. Example of axioms are commutative law, associative law, etc. You
can use these axioms and rules of inference to deduce the truth statement about a
system.
In other words, for any system, there are axioms and rules of inferences – combining
these two in use, you derive truth statements, called theorems.
Theorems are derived from axioms by making use of rules of inference.
Axiom
Rules of inference
arrive at
Conclusion
Known as
Theorem
Starting with wrong axioms or applying rules of inference in a wrong manner can result
in a wrong proof.
Proof is the derivation of theorem from axioms with the use of rules of inference.
Deduction Rules - Rules of Inference Related to the Language Propositions
P . P ⇒ (P ˅ Q) Addition
P ˅ Q
P (P ˄ Q) ⇒ (P ˄ Q) Conjunction
.Q .
P ˄ Q
Mostly, we will be using Modus ponens and Modus tollens in our arguments.
Proving the Correctness of an Argument
EXAMPLE: (This argument below may look silly. However, given the premises and
conclusion, is the argument correct?)
• If horses fly or cows eat grass, then the mosquito is the national bird. If the
mosquito is the national bird, then peanut butter tastes good on hot dogs. But
peanut butter tastes terrible on hot dogs. Therefore, cows don’t eat grass.
Solution:
Horses fly: H
Cows eat grass: G
Mosquito is a national bird: M
Peanut butter tastes good on hot dogs: P
If horses fly or cows eat grass, the mosquito is the national bird:
(H ˅ G) ⇒ M
If the mosquito is the national bird, then peanut butter tastes good on hot dogs;
M⇒P
1. (H ˅ G) ⇒ M
2. M ⇒ P
3. ¬P .
¬G
EXAMPLE: Using the correct logical inferences, does this conclusion ¬G arrive from
the three premises?
Proof:
Using hypothetical syllogism on 1 and 2 i.e.
1 & 2 Hypothetical syllogism 4 (H ˅ G) ⇒ P
6 Simplification ¬G
From the first row we can see that the truth value for all the premises and conclusion
are true, therefore, the argument is valid.
QED
EXAMPLE: Prove that the statement below is a valid argument.
• It is not the case that IBM or Xerox will take over the copier market. If RCA
returns to the computer market, then IBM will take over the copier market hence
RCA will not return to the computer market.
Solution:
IBM will take over the copier market: I
Xerox will take over the copier market: X
RCA will return to the computer market: R
It is not the case that IBM or Xerox will take over the copier market:
¬ (I ˅ X)
If RCA returns to the computer market, then IBM will take over the copier market:
R⇒I
hence RCA will not return to the computer market:
¬R
1. ¬ (I ˅ X)
2. R ⇒ I
¬R
Assuming these two premises are correct can you derive the conclusion from them?
Proof:
1 De Morgan’s law 3 (¬I ˄ ¬X)
3 Simplification 4 ¬I
2 & 4 Modus tollens 5 ¬R
1. ¬ (I ˅ X)
2. R ⇒ I
¬R
I X R (I ˅ X) ¬(I ˅ X) R⇒I ¬R
0 0 0 0 1 1 1
0 0 1 0 1 0 0
0 1 0 1 0 1 1
1 0 0 1 0 1 1
0 1 1 1 0 0 0
1 0 1 1 0 1 0
1 1 0 1 0 1 1
1 1 1 1 0 1 0
From the first row we can see that the truth value for all the premises and conclusion
are true, therefore, the argument is valid.
QED
T CS E S ¬E CS ˅ E T ⇒ (CS ˅ E) S ⇒ ¬E T˄S
0 0 0 0 1 0 1 1 0
0 0 0 1 1 0 1 1 0
0 0 1 0 0 1 1 1 0
0 1 0 1 1 1 1 1 0
1 0 0 0 1 0 0 1 0
0 0 1 1 0 1 1 0 0
0 1 0 1 1 1 1 1 0
0 1 1 0 0 1 1 1 0
1 1 0 0 1 1 1 1 0
1 0 1 0 0 1 1 1 0
1 0 0 1 1 0 0 1 1
0 1 1 1 0 1 1 0 0
1 1 1 0 0 1 1 1 0
1 1 0 1 1 1 1 1 1
1 0 1 1 0 1 1 0 1
1 1 1 1 0 1 1 0 1
From the first row we can see that the truth value for all the premises and conclusion
are true, therefore, the argument is valid.
QED
Note:
This is the sort of proof you give, to show that an argument is correct or not.
If an argument is not correct/valid, you must give a counter example. In other words,
with the existing premises and conclusion of an argument, which you want to prove
incorrect, you must give truth values to the assertion involved such that the premises
become true and the conclusion false – This is called a fallacy.
Fallacies
EXAMPLE: “If the bottler committed the murder, he will be very nervous”
OR
“The bottler is nervous, so he committed the murder”
Is this argument correct?
Answer: No, it isn’t because he can be nervous by just seeing the police even
without haven committed the murder.
This is a fallacy of affirming the consequence.
2. Universal Instantiation:
From 𝑥P(𝑥)
P(c) c is an arbitrary element of U
3. Existential Generalization:
If you have P(c) . for some c ∈ U, i.e. it is not an arbitrary element
𝑥P(𝑥)
4. Existential Instantiation:
From 𝑥P(𝑥)
P(c) c is a particular element of the universe.
In this case all, two statements are actually true but whether the conclusion actually
follows from them is what we want to prove.
In logical notation:
𝑥(T(𝑥) ˄ C(𝑥)
𝑥(C 𝑥) ˄ P(𝑥) .
𝑥(T(𝑥) ˄ P(𝑥)
You can easily see that the conclusion does not follow from the premises, based on the
rules of inference so, it is necessary to give a counter example as given below:
Proof:
T C P
From the nonempty intersections in the Venn diagram, we can see that some trig
functions are continuous and some continuous functions are periodic, respectively.
However, it does not necessarily imply that T and P intersect i.e. the intersection of T
and P can be empty. Therefore, from this argument, you cannot conclude that some
trigonometric functions are periodic. QED
Note:
You can use a Venn diagram to check for the correctness of an argument after which
you give the proper logical argument for it.
Solution:
Let B(𝑥): 𝑥 is a baby
Il(𝑥): 𝑥 is illogical
D(𝑥): 𝑥 is despised
M(𝑥): 𝑥 can manage a crocodile
Representing these premises on a Venn diagram:
B Il D M
l
From the Venn diagram, we can see that B and M are disjoint therefore, the argument is
correct.
1 𝑥(B(𝑥) ⇒ Il(𝑥))
2 𝑥(Il(𝑥) ⇒ D(𝑥))
3 ¬𝑥(M(𝑥) ˄ D(𝑥))
4 𝑥(B(𝑥) ⇒ ¬M(𝑥))
Proof:
Rewriting 3: 3 ¬𝑥(M(𝑥) ˄ D(𝑥))
𝑥¬(M(𝑥) ˄ D(𝑥)) Applying De Morgan’s law:
𝑥(¬M(𝑥) ˅ ¬D(𝑥)) By commutativity of ˅:
𝑥(¬D(𝑥) ˅ ¬M(𝑥)) By implication:
4 𝑥(D(𝑥) ⇒ ¬M(𝑥))
Solution:
Let L(𝑥): 𝑥 is a living thing
P(𝑥): 𝑥 is a plant
A(𝑥): 𝑥 is an animal
H(𝑥): 𝑥 has a heart
d: David’s dog
Representing these premises / statements in logical notation:
1 𝑥[L(x) ⇒ (P(𝑥) ˅ A(𝑥))]
2 L(d) ˄ ¬P(d)
3 𝑥(A(𝑥) ⇒ H(𝑥))
H(d)
(Note: Here, we can instantiate/replace 𝑥 with any value from the set of living things.
Also, statements 1 and 3 have universal quantifiers while statement 2 has no quantifier.)
Proof:
From 1 Universal instantiation 4 L(d) ⇒ (P(d) ˅ A(d))
2 Simplification 5 L(d)
6 ¬P(d)
3 Universal instantiation 7 A(d) ⇒ H(d)
4&5 Modus ponens 8 P(d) ˅ A(d)
8&6 Disjunctive syllogism 9 A(d)
7&9 Modus ponens H(d)
QED
The argument is valid since we arrived at the conclusion from the premises.
(b) All clear explanations are satisfactory.
Some excuses are unsatisfactory.
Hence, some excuses are not clear explanations.
Solution:
Let C(𝑥): Clear explanation
S(𝑥): Satisfactory explanation
¬S(𝑥): Unsatisfactory explanation
E(𝑥): Excuses
EXERCISE:
The following propositions involve predicate that define sets. Use the properties to
conclude relationships between these sets. Use Venn diagrams to check for the validity
of the arguments.
(a) Some scientists are not engineers. Some astronauts are not engineer. Hence,
some scientists are not astronauts.
(b) All astronauts are scientists. Some astronauts are not engineers. Hence, some
engineers are not scientists.
Solution (a):
If the Venn diagram satisfies the premises and not the conclusion, then the argument
cannot be correct.
S E
Some scientists are not
engineers
Solution (b): S E
A From this we cannot conclude that
some scientists are not astronauts
Normal Forms
We have seen how to prove or disprove the correctness of an argument using rules of
inference. Such rules of inference are very useful in the logic programming language,
PROLOG, which uses what is known as a resolution principle.
For this, we have to write a premise in a proper form, which is called a class form. In
order to know what a class form is, we have to see some normal forms of propositional
expression, WFF, or propositional logic.
Two types of normal forms:
(i) Conjunctive normal form, CNF
(ii) Disjunctive normal for, DNF
Definitions:
(a) A variable or negation of a variable is called a literal.
E.g. P, ¬P are literals.
Product of sums
CNF and Dare used to write arguments in a different form – This is called Resolution
Principle, which is used in PROLOG, the logic programming language.
Summary:
We have seen what rules of inference are; and how to use the rules to prove the validity
or invalidity of arguments. We’ve also discussed DNF and CNF; and seen how to bring
a WFF of a propositional logic to CNF or DNF. In the next section, we shall see how to
use the Resolution Principle to prove the correctness or incorrectness of an argument.
Definitions:
A variable or negation of a variable is a literal.
A disjunction of literals is called the sum.
A conjunction of literals is called the product.
A clause is [also] a disjunction of literals.
What is a resolution?
A clause is a disjunction of literals.
For any two clauses C1 and C2, if there is a literal L1 in C1 that is complementary to a
literal L2 in C2, then delete L1 and L2 from C1 and C2, respectively, and construct the
disjunction of the remaining clauses. The constructed clause is a resolvent of C1 and C2.
EXAMPLE: Suppose you have two clauses
P ˅ Q ˅ ¬R and
¬P ˅ ¬S ˅ T ˅ U.
Since you have P in the first clause and ¬P in the second clause; P and ¬P
complement each other so, delete both of them - After this deletion, what is left is the
resolvent of the two clauses:
Q ˅ ¬R ˅ ¬S ˅ T ˅ U
Theorem:
Given the two clauses C1 and C2, a resolvent C of C1 and C2 is a logical consequence
of C1 and C2.
(This theorem is seen in the examples above)
Proof of the Theorem:
There is a clause C1, which has a literal L and the remaining clauses are noted by C’1
i.e. C1 L ˅ C’1
and you have another clause C2 which contains ¬L and the remaining clauses denoted
by C’2
i.e. C’2 L ˅ C’2
So, we have
C1 L ˅ C’1
C2 ¬L ˅ C’2
Now let’s show that C’1 ˅ C’2 is the logical consequence of the original clauses C1 and
C2:
Remember that C’1 and C’2 are sums, having ˅ as the logical connector.
If the premises are true, the conclusion must be true. To shoe this:
C1 L ˅ C’1
C2 ¬L ˅ C’2
Either L is true or
¬L is true, which is equivalent to saying that
L is false
So, L is either true or false.
If L is true in C2, ¬L is definitely false therefore, C’2 must be true for C2 to be true;
Now, if C’2 is true, the whole resolvent clause
C C’1 ˅ C’2
is true because of disjunction.
QED
Resolution Principle
Given a set S of clauses, a (resolution or) deduction of C from S is a finite sequence C1,
C2, … Ck of clauses such that each C is either a clause in S or a resolvent of clauses
preceding C; and Ck = C. A deduction of [ ] from S is called a refutation or a proof of S.
[ ] is an empty class.
Hint:
If you want to derive a conclusion from a collection of some set of clauses
S = C1, …,
C2, …,
.
.
.,
try to use the resolution principle to resolve some of them in order to get more clauses.
Finally, consequent upon the resolution, when you are left with the result you want to
conclude, take a negation of that conclusion and arrive at an array of an empty class [ ].
If this works out correctly, the argument is correct otherwise, it is not correct.
Solution:
Today is Tuesday: T
I have a test in Computer Sc. CS
I have a test in Econ E
My Econ professor is sick S
2&4 7 ¬E
6&7 8 CS
5&8 []
From the proof/refutation, the argument is correct.
Note:
The resolution principle is much easier than deduction principle and it can be
automated. The resolution principle is used in PROLOG.
Rewriting the argument, splitting the conjunction and negating the conclusion:
1 ¬I
2 ¬X
3 ¬R ˅ I
4 R
PROLOG
PROLOG is used in artificial intelligence.
Rules and Facts
Facts are written as
female(Mary) ← the fact that Mary is a female
likes(Mary, books) ← the fact that Mary likes books
likes(Mary, chocolates) ← the fact that Mary likes chocolates
Actually, you give the system a lot of facts; and you have some rules. With the
combination of these facts and rules / syntax. The illustration below shows how the
system will reply when asked a question:
If you ask
?female(Mary) ←Question: Is Mary a female
Yes ← Answer: yes
?female(John)
No
If you ask same question again, it will show the second answer, depending on
the implementation of the language.
?likes(Mary, X)
X = chocolates
This interpreted as
When do you say 𝑥 is the brother of 𝑦? it is when x is a male and also x
and 𝑦 have the same mother and father.
Head
Horn Clause is a distinction of literals where at most, one literal is non-negative. All of
them will be negated except one or at most, one will not be negated
P ˅¬P ˅¬Q ˅¬R ˅¬S
Headed Horn Clause is a horn clause that has one literal that is not negated. For
instance: A single fact, likes(Mary, books) is a headed horn clause, with one literal.
Headless Horn Clause is horn clause with all its literals negated.
which means
“If 𝑥 is a male and parents of 𝑥 are M and F and parent of 𝑦 are M and F
then 𝑥 is the brother of 𝑦.”
EXAMPLE: We will write the statement below, firstly, in the IF THEN manner and also
in the PROLOG manner and see how both syntaxes correspond with each other.
Solution:
In IF THEN syntax:
IF 𝑥 us a female and s is a sister to 𝑧 and 𝑧 is a parent of 𝑦 THEN 𝑥 is the
aunt of 𝑦.
Rewriting in logical notation:
𝑥𝑦𝑧[((female(𝑥) ˄ sister(𝑥, 𝑧) ˄ parent(𝑧, 𝑦)) ⇒ aunt(𝑥, 𝑦)]
Facts female(Mary)
sister(Mary, John)
parent(John, Joseph)
: aunt(Mary Joseph) ←goal
In logical notation:
(female(Mary) ˄ sister(Mary, John) ˄ parent(John, Joseph)) ⇒ aunty(Mary, Joseph)
In clause form
¬(female(Mary) ˄ sister(Mary, John) ˄ parent(John, Joseph)) ˅ aunty(Mary, Joseph)
Hint:
You have the general rule, which you instantiate to yield the headed clause. You also
have the fact, which is also a headed horn clause but with a negated goal i.e. the goal
returned is a headless horn clause. At the end you need to have one headless hrn
clause as the goal.
Backward Chaining is starting from the conclusion to verify that it can be derived from
the facts and rules.
Forward Chaining: You start from the axioms and try to use the rules of inference to
derive the conclusion.
In PROLOG, the backward chaining method is used.