MT131 Tutorial - 1 Logic 3
MT131 Tutorial - 1 Logic 3
MT131 Tutorial - 1 Logic 3
Discrete Mathematics
01/31/22
Course goals
• Mathematical reasoning
– Logic, Inference, proof
• Combinatorial analysis
– Count, Probability
• Discrete structures
– Sets, Functions, Relations, Graphs
Course Contents
Logic
Sets, Functions and Matrices
Number Theory and Cryptography
Counting
Discrete Probability
Relations
Graphs
1. The Foundations: Logic
01/31/22
Logic
• Mathematical Logic is a tool for working with
compound statements
• Logic is the study of correct reasoning
• Use of logic
– In mathematics:
to prove theorems
– In computer science:
to prove that programs do what they are
supposed to do
Propositional Logic
• Propositional logic: It deals with propositions.
• Predicate logic: It deals with predicates.
p (q r)
¬p ¬q
(p q) (¬r s)
• “If this lecture ever ends, then the sun will rise
tomorrow.” True or False?
• “If Tuesday is a day of the week, then I am a
penguin.” True or False?
• “If 1 + 1 = 6, then Trump is the president of
USA.” True or False?
Different Ways of Expressing
pq
if p, then q p implies q
if p, q p only if q
q unless ¬p q when p
q if p
q whenever p p is sufficient for q
q follows from p q is necessary for p
a necessary condition for p is q
a sufficient condition for q is p
Example
• If Maria learns discrete mathematics, then she will find
a good job (if p, then q)
– Maria will find a good job if she learns discrete
mathematics (q if p)
– Maria will find a good job when she learns discrete
mathematics (q when p)
– For Maria to get a good job, it is sufficient for her to
learn discrete mathematics (sufficient condition for q
is p)
– Maria will find a good job unless she does not learn
discrete mathematics (q unless not p)
Example: Truth Table of
(p q) (p q)
p q q p q p q (p q) (p q)
F F T T F F
F T F F F T
T F T T F F
T T F T T T
Important Logical Equivalence
p q is logically equivalent to p q
p q p q pq
F F T T
F T T T
T F F F
T T T T
Converse, Inverse, Contrapositive
Operator Precedence
() 1
2
, , 3
, 4
Left to Right 5
Example: Truth Table of
p q r
p q r r pq p q r
F F F T F T
F F T F F T
F T F T T T
F T T F T F
T F F T T T
T F T F T F
T T F T T T
T T T F T F
Logic and Bit Operations
• Find the bitwise AND, bitwise OR, and bitwise
XOR of the bit strings 0110110110 and
1100011101.
0110110110
Truth value Bit
1100011101 F 0
__________ T 1
Bitwise AND 0100010100
Bitwise OR 1110111111
Bitwise XOR 1010101011
Propositional Equivalence,
Tautologies and Contradictions
p q pq ppq
F F F T
F T T T
T F T T
T T T T
Equivalence Laws
• Distributive: p (q r) (p q) (p r)
p (q r) (p q) (p r)
• De Morgan’s:
(p q) p q
(p q) p q
• Trivial tautology/contradiction:
Augustus
p p T , p p F De Morgan
(1806-1871)
Implications / Biconditional Rules
• p q p q
(p q) (p q) p q
• p q q p (contrapositive)
• p q (p q) (q p)
(p q) p q
Proving Equivalence via Truth Tables
( (p q) q)
( (p q) q) Equivalence
( (p q) q) De Morgan
( (p q) q) Equivalence
(p q q) De Morgan
(p T) Trivial Tautology
(T) Domination
F Contradiction
Predicates and Quantifiers
Predicates: “x is greater than 3” has two parts
First part: x , is a variable.
Second part: “is greater than 3”, is a predicate.
“x is greater than 3” can be denoted by the
propositional function P(x).
P(x): x > 3, let x = 4, then P(4) is true,
let x = 1, then P(1) is false.
Example: If R(x, y, z) : x + y = z then
R(1, 2, 3), 1 + 2 = 3, is true.
Examples of Propositional Functions
• x P(x, 2):
P(1, 2) P(2, 2) P(3, 2)
• y P(3, y):
P(3, 1) P(3, 2) P(3, 3)
Negations
x P(x) ≡ x P(x)
x Q(x) ≡ x Q(x)
Examples:
- P(x, y), x and y are free variables.
- x P(x, y), x is bound and y is free.
- “P(x), where x = 3” is another way to bind x.
- x (x + y = 1), x is bound and y is free.