2 Propositional Logic
2 Propositional Logic
Introduction to Logic
• The study of reasoning
• Focuses on the relationship among
statements as opposed to the content of any
particular statement.
• Example:
All cats have 4 legs
Yordana is a cat
Therefore, Yordana has 4 legs
2
Introduction to Logic
• Must follow rules and techniques to get
valid conclusion/argument
• Example of logical fallacy:
All cats have four legs
My dog has four legs
Therefore, my dog is a cat.
3
Introduction to Logic
• Must follow rules and techniques to get
valid conclusion/argument
• Example of logical fallacy:
All cats have four legs
My dog has four legs
Therefore, my dog is a cat.
Fallacy!!!
4
Why we learn Logic?
• The way of reasoning is the root of
computer science
• Applications include:
– Automated reasoning in artificial
intelligence
– Logic gates in computer hardware
– specification and verification in software
engineering
– Semantics and logic in programming
5
Topics in Logic
• Propositional logic
• Predicate logic
• Proof
6
Propositional Logic
Statement / Proposition
• Statement/Proposition : a sentence that is
either TRUE or FALSE, but not both.
(a declarative sentence)
• Examples:
✔ I can run.
✔ I can fly while eating
✔2 > 1
✔1 > 2
✔ Birds can fly and elephants can swim.
✔ University of Malaya is in Malaysia.
8
These are not propositions:
✗
Where is University of Malaya?
✗
Who has taken my pillow?
✗
Please show me your ticket.
✗
Buy me a dozen of eggs when you
come home.
9
Exercise
• Is 3 greater than 2?
• I need a pencil.
• Buy me a pencil.
• If I have a pencil, I can draw.
• 1+1 = 3
• When elephants swim, they uses their wings
as paddles and breath with gills.
• I win the jackpot!
• This sentence is not a proposition.
10
What is Propositional Logic?
• The area of logic that
deals with
propositions
• First developed
systematically by the
Greek philosopher
Aristotle more than
2300 years ago.
11
Symbolize Statement
• We can use variables (a, b, c, P, Q, R,
…) to represent propositions.
• Examples:
p: I can run.
q: 1+1 =3
A: Apples in Malaysia are imported
B: Bicycles have windscreens
C: Canada is in Asia
12
Negation, ¬
• Negation of p, denoted ¬p, is the
proposition:
not p
• Example:
p : Bicycles have windscreens
¬p : Bicycles do not have windscreens
13
Negation, ¬
• Negation of p, denoted ¬p, is the
proposition:
not p
• Example:
p : Bicycles have windscreens
¬p : Bicycles do not have windscreens
• Or, in English, we can use “It is not the case
that p” to express a negation.
• Notations: ¬p , ~p , !p , p' or p.
14
Truth value and truth table
• A proposition has a truth value – it is
TRUE or FALSE.
• Example:
p: 2 is an even number T
¬p: 2 is not an even number F
15
Truth value and truth table
• A proposition has a truth value – it is
TRUE or FALSE.
• Example:
p: 2 is an even number T
¬p: 2 is not an even number F
• Truth table
p ¬p
T F
F T 16
Exercise
State the negations of the following
prepositions:
• Q : Birds can swim
• R : 3+5 = 8
• S : 2+5 < 0
17
AND, ⋀
• We can combine propositions with
AND (conjunction).
• Example:
p: 2+2=4
q: birds can swim.
• “p AND q”, or “p ⋀ q” is
2+2=4 and birds can swim.
18
Truth Table of AND
P Q P⋀Q
T T T
T F F
F T F
F F F
19
Truth Table of AND
P Q P⋀Q
T T T
T F F
F T F
F F F
NOTE : TRUE only when both P and Q are TRUE.
20
Exercise
Symbolize the following sentences.
Use AND and negation operators if
needed.
• Vincent Van Gogh is a famous painter
and I have one of his painting.
• Vivaldi played guitar or Michael
Jackson played Tik Tok.
• BTS sings dangdut but P Ramli did not
sing K-POP.
21
Exercise
If p is TRUE, q is FALSE, r: “5>3”, s:
“Durians growth in Malaysia” and t:
“Sundays come after Mondays”.
Find the truth values of:
• ¬p ⋀ ( r ⋀ s)
• q ⋀ ¬ (t ⋀ r)
• ¬p ⋀ ¬( s ⋀ r ⋀ ¬t )
23
OR, ⋁
• We also can combine propositions with
OR (disjunction).
• Example:
p: 10 is odd number
q: 10 is greater then 5.
• “p OR q”, or “p ⋁ q” is
10 is odd number or 10 is greater then
5.
24
Truth Table of OR
P Q P⋁Q
T T T
T F T
F T T
F F F
25
Truth Table of OR
P Q P⋁Q
T T T
T F T
F T T
F F F
Note : FALSE only when both P and Q are FALSE.
26
Operator precedence
• In propositions involve multiple
operators, order of evaluation:
Negation >> AND >> OR.
27
Operator precedence
• In propositions involve multiple
operators, order of evaluation:
Negation >> AND >> OR.
• Example:
¬ TRUE ⋀ ¬ TRUE ⋁ TRUE
28
Operator precedence
• In propositions involve multiple
operators, order of evaluation:
Negation >> AND >> OR.
• Example:
¬ TRUE ⋀ ¬ TRUE ⋁ TRUE
= FALSE ⋀ FALSE ⋁ TRUE
29
Operator precedence
• In propositions involve multiple
operators, order of evaluation:
Negation >> AND >> OR.
• Example:
¬ TRUE ⋀ ¬ TRUE ⋁ TRUE
= FALSE ⋀ FALSE ⋁ TRUE
= FALSE ⋁ TRUE
= TRUE
30
Conditional Proposition
• The propositions in the form
if p then q
are conditional propositions that denote as :
p → q.
• Example:
If the apple is red,
then it is delicious.
• p: the apple is red (antecedent)
• q: the apple is delicious (consequent)
33
Truth Table of Conditional
Proposition
Given: If the apple is red, then it is delicious.
p q p→q
The apple is red,
T T T it is delicious
T F
F T
F F
34
Truth Table of Conditional
Proposition
Given: If the apple is red, then it is delicious.
p q p→q
The apple is red,
T T T it is delicious
The apple is red,
T F F but not delicious! No
way!
F T
F F
35
Truth Table of Conditional
Proposition
Given: If the apple is red, then it is delicious.
p q p→q
The apple is red,
T T T it is delicious
The apple is red,
T F F but not delicious! No
way!
36
Some ways to express
conditional propositions
• if p, then q
• if p, q
• p is sufficient for q
• q if p
• q when p
• a necessary condition for p is q
• q unless ¬p
37
Exercise
Construct truth tables for the following
propositions:
• p⋀q→r
• p ⋁ q → ¬r
• p→(q→r)
38
Biconditional Proposition
• Bidirectional Propositions – in the form:
p if and only if q
• Example : Integer x is divisible by 2 if
and only if x is an even number.
• Denote as : p↔q
• Can be written as p iff q
39
Truth Table of
Biconditional Proposition
p q p↔q
T T T
T F F
F T F
F F T
41
Exercise
Restate each proposition in the form of a
conditional or biconditional proposition:
• Mary will be a good student if she studies
hard.
• When you sing, my ears hurt.
• I sing if and only if you dance.
• John takes Calculus II if and only if he
has passed his Calculus I.
• If John go, I go , but If John is going to
absent, I will follow. 42
Converse, Inverse,
Contrapositive
• The converse of the conditional proposition
p→q is the proposition q→p
• The inverse of the conditional proposition
p→q is the proposition ~p →~q
• The contrapositive of the conditional
proposition p→q is the proposition ~q→~p
43
Converse, Inverse,
Contrapositive
• The converse of the conditional proposition
p→q is the proposition q→p
• The inverse of the conditional proposition
p→q is the proposition ~p →~q
• The contrapositive of the conditional
proposition p→q is the proposition ~q→~p
45
Example of Tautology
p V ~(pΛq)
T T T F T
T F F T T
F T F T T
F F F T T
46
Example of Contradiction
(pΛq) Λ ~(pVq)
(pΛq) Λ
p q (pΛq) ~(pVq)
~(pVq)
T T T F F
T F F F F
F T F F F
F F F T F
47
Logical Equivalent
• Assume A and B are two propositions,
A=………
B=……
• A and B are “logically equivalent”, or
AÛB
iff A and B have the same truth values.
• 2 ways to determine logical equivalent:
– Truth Table
– Laws of Logic 48
Truth Table
• 2 propositions are logical equivalent if
they same truth values
• Example: show that p→q and ~pVq
are logically equivalent
49
Example
• Example: show that p→q and q→p
are not logically equivalent
p q p→ q q→ p
F T T F
F F T T
50
Laws of Logic
51
Laws of Logic
p → q ≡ ¬p ∨ q Law of Implication
52
Example
¬( p∨(¬ p∧q))
=¬(( p∨¬ p)∧( p∨q)) Distributive law
( p∧q)→( p∨q)
=¬( p∧q)∨( p∨q) Implication law
=T ∨T =T Negation law 54
Deductive Reasoning
55
Deductive Reasoning
• Consider the following sequence of
propositions.
a)We are looking for a man either in black or yellow shirt
b)The man with black shirt is wearing jeans.
c)The man we are looking for is not wearing jeans
56
Deductive Reasoning
• Consider the following sequence of
propositions.
a)We are looking for a man either in black or yellow shirt
b)The man with black shirt is wearing jeans.
c)The man we are looking for is not wearing jeans
58
Deductive Reasoning
The following is an argument.
62
Rules of Inference
• A proof uses the hypotheses, axioms,
definitions, and so on to reach a
conclusion. Each step of the proof
involves drawing intermediate
conclusions.
p→q
p
---------
∴q
65
Rules of Inference
Modus Example
Ponens
If this object is made of copper,
p→q it will conduct electricity.
p This object is made of copper.
---------
∴q Therefore, it will conduct
electricity
66
Rules of Inference
Modus Example
Tollens
p→q
~q
---------
∴ ~p
67
Rules of Inference
Modus Example
Tollens
p /\ q
---------
∴p
∴q
69
Rules of Inference
Conjunction Example
elimination
2 is a prime number, but
p /\ q it is even
---------
∴p 2 is a prime number
∴q 2 is an even number
70
Rules of Inference
Disjunction Example
introduction
p
---------
∴pVq
71
Rules of Inference
Disjunction Example
introduction
Socrates is a man.
p
--------- So, either “Socrates is a man”
or “ice is cold”
∴pVq
So, either “Socrates is a man”
or “ice is hot”
72
Rules of Inference
Disjunctive Example
Syllogism
pVq
~p
---------
∴q
73
Rules of Inference
Disjunctive Example
Syllogism
Mr Bean is handsome or
pVq funny
~p
--------- Mr bean is not handsome
∴q
Mr Bean is funny
74
Rules of Inference
Hypothetical Example
Syllogism
p→q
q→r
---------
∴p→r
75
Rules of Inference
Hypothetical Example
Syllogism
If it rains, we will not have a
p→q picnic.
76
Rules of Inference
Dilemma Example
pVq
p→r
q→s
---------
∴rVs
77
Rules of Inference
Dilemma Example
78
There are some common
fallacy
Affirming the consequent
p→q
q
---------
∴p
79
There are some common
fallacy
Affirming the consequent
80
There are some common
fallacy
Denying the antecedent
p→q
~p
---------
∴ ~q
81
There are some common
fallacy
Denying the antecedent
82
Exercise
• Fishing is a popular sport or reading
poetry is wildly popular in Malaysia.
Reading poetry is not wildly popular in
Malaysia. Therefore, fishing is a
popular sport.
• If birds can fly or swim, then they can
find food. Birds can fly. Tigers can find
food. Therefore, birds and tigers can
find food.
83