Mathematical Logic &
Truth Table
FAC1002 – Programming I
Pusat Asasi Sains, Universiti Malaya
LOGIC & TRUTH TABLE
1. Statements
2. Conjunction
3. Disjunction
4. Negation
5. Propositions & Truth Table
6. Tautologies & Contradiction
7. Logical Equivalence
8. Conditional Statement
9. Biconditional Statement
10.Conditional / Converse / Inverse / Contrapositive
CONDITIONAL
p
T
T
F
F
q
T
F
T
F
p→q
Example 1:
Write the truth table values of conjunction for the given two statements
p: The robot is blue
q: The robot has an antenna
Solution:
Robot
p
q
p→q
CONDITIONAL
Remark:
(i) p is sufficient condition for q (syarat cukup).
(ii) q is necessary condition for p (syarat perlu).
The p → q TRUE; except the case that p is true and q is false
Example 2:
p = You are on time.
q = You are in class.
p → q = If you are on time, then you are not in class.
THEREFORE, the conditional statement is false
CONDITIONAL
p
q
p→q
p
q
~p
~p v q
T
T
T
F
T
F
T
T
T
F
F
F
T
F
F
T
T
F
T
T
T
F
F
T
F
F
T
T
≡
other conditional proposition
p→q
/ if p then q
conditional
statement
symbolic
Note
converse
if q then p
q→p
switch positions
inverse
if not p then not q
∼p→∼q
opposite
~q →~p
switch positions
and opposite
contrapositive if ~q then ~p
CONDITIONAL
conditional ≡ contrapositive
converse ≡ inverse
p
q
T
T
T
F
F
T
F
F
conditional
converse
inverse
contrapositive
p→q
q→p
~p→~q
~q→~p
CONDITIONAL
Example 3:
Form the conditional, converse, inverse and
contrapositive statements if given that
p = It rains.
Conditional
p→q
Converse
q→p
Inverse
~p→~q
Contrapositive ~q→~p
q = They cancel school.
BICONDITIONAL
Example 4:
p→q
If I study hard, then I will pass.
and
q→p
If I pass, then I studied hard.
p↔q
Both the p → q and
q → p statements
must be true to
produce a
biconditional
statement
BICONDITIONAL
Example 5:
Let p and q represent the following statement:
p: A person is a father.
q: A person is a male.
statement
(conditional)
p→q
(converse)
q→p
output
BICONDITIONAL
p↔q
Truth table :
p
T
q
T
T
F
F
F
T
F
p→q
q→p
p↔q
BICONDITIONAL
Example 6:
Let r and s represent the following statement:
r: A polygon is a triangle.
s: A polygon has exactly three sides.
r → s (conditional)
If a polygon is a triangle, then
it has exactly three sides.
s → r (converse)
If a polygon has exactly three sides, then
it is a triangle.
BICONDITIONAL
Example 6:
r ↔ s (biconditional)
s ↔ r (biconditional)
Exercises 1
(a) ~p
(b) ~q
(c) p^q
(d) p v q
(e) ~p^q
(f) ~p^~q
Solutions:
Exercises 2
(a) ~(p v q)
(c) p → q
Solutions:
(e) ~p→~q
(b) ~p ^ ~q
(d) p ↔ q
Exercises 3
Given that, p is “All men are human” and q is “Ali is human” and
r is “Ali is a man”. Express the compound propositions as a
sentence.
Solutions:
( ( r q) ۸ r ) p
That’s all for today.
Thank you!