01 Logic
01 Logic
Discrete Mathematics
Lecturer: Quang-Thai Ho
Logic
• Crucial for mathematical reasoning
• Important for program design
• Used for designing electronic circuitry
Is this a proposition? no
P P
true (T) false (F)
false (F) true (T)
Conjunction (AND)
Binary Operator, Symbol:
P Q P Q
T T T
T F F
F T F
F F F
Disjunction (OR)
• Binary Operator, Symbol:
P Q P Q
T T T
T F T
F T T
F F F
Exclusive Or (XOR)
• Binary Operator, Symbol:
P Q PQ
T T F
T F T
F T T
F F F
Implication (if - then)
Binary Operator, Symbol: →
P Q P→Q
T T T
T F F
F T T
F F T
Biconditional (if and only if)
Binary Operator, Symbol:
P Q PQ
T T T
T F F
F T F
F F T
Statements and Operators
Statements and operators can be combined in any way to
form new statements.
P Q P Q (P)(Q)
T T F F F
T F F T T
F T T F T
F F T T T
Statements and Operations
Statements and operators can be combined in any way to
form new statements.
P Q PQ (PQ) (P)(Q)
T T T F F
T F F T T
F T F T T
F F F T T
Exercises
• Construct a truth table for the proposition ¬P (Q R )
• To take discrete mathematics, you must have taken calculus or a
course in computer science.
• When you buy a new car from Acme Motor Company, you get $2000
back in cash or a 2% car loan.
• School is closed if more than 2 feet of snow falls or if the wind chill is
below -100.
Exercises
• Construct a truth table for the proposition ¬P (Q R )
P Q R ¬P QR ¬P (Q R)
0 0 0 1 0 1
Exercises
To take discrete mathematics, you must have taken
calculus or a course in computer science.
• P: School is closed
• Q: 2 feet of snow falls
• R: wind chill is below -100
QR→P
Precedence among operators:
, , , →,
Equivalent Statements
The statements (PQ) and (P) (Q) are logically equivalent, since they have the
same truth table, or put it in another way, (PQ) (P) (Q) is always true.
T T F F T
T F T T T
F T T T T
F F T T T
Tautologies and Contradictions
• A tautology is a statement that is always true.
• Examples:
• R(R)
• (PQ) (P)( Q)
• A contradiction is a statement that is always false.
• Examples:
• R(R)
• ((P Q) (P) (Q))
• The negation of any tautology is a contradiction, and the negation of any
contradiction is a tautology.
Equivalence
Is it true? yes
Examples
Not all roses are red
x (Rose(x) → Red(x))
x (Rose(x) Red(x))
Nobody is perfect
x (Person(x) Perfect(x))
x (Person(x) → Perfect(x))
Nested Quantifier
p pq
q p Disjunctive
_____ Conjunction
_____ syllogism
pq q (resolution)
Arguments
Example:
“If 101 is divisible by 3, then 1012 is divisible by 9. 101 is divisible by 3.
Consequently, 1012 is divisible by 9.”
Another example:
“If it rains today, then we will not have a barbeque today. If we do not
have a barbeque today, then we will have a barbeque tomorrow.
Therefore, if it rains today, then we will have a barbeque tomorrow.”
This is a valid argument: If its hypotheses are true, then its conclusion
is also true.
Arguments
Another example:
i: “Gary is intelligent.”
a: “Gary is a good actor.”
c: “Gary can count from 1 to 10.”
Arguments
i: “Gary is intelligent.”
a: “Gary is a good actor.”
c: “Gary can count from 1 to 10.”
Step 1: c Hypothesis
Step 2: i→ c Hypothesis
Step 3: i Modus tollens Steps 1 & 2
Step 4: ai Hypothesis
Step 5: a Disjunctive Syllogism
Steps 3 & 4
Conclusion: a (“Gary is a good actor.”)
Arguments
x P(x) Existential
______________________
P(c) for some element c U instantiation
Example:
x P(x)
__________ Universal
P(c) if c U instantiation
Proving Theorems
Direct proof:
An implication p → q can be proved by showing that if p is true, then q
is also true.
Example: Give a direct proof of the theorem
“If n is odd, then n2 is odd.”
Idea: Assume that the hypothesis of this implication is true (n is odd).
Then use rules of inference and known theorems of math to show that
q must also be true (n2 is odd).
Proving Theorems
n is odd.
Indirect proof:
An implication p → q is equivalent to its contra-positive q → p.
Therefore, we can prove p → q by showing that whenever q is false,
then p is also false.
Example: Give an indirect proof of the theorem
“If 3n + 2 is odd, then n is odd.”
Idea: Assume that the conclusion of this implication is false (n is even).
Then use rules of inference and known theorems to show that p must
also be false (3n + 2 is even).
Proving Theorems
n is even.
Then n = 2k, where k is an integer.
It follows that 3n + 2 = 3(2k) + 2
= 6k + 2
= 2(3k + 1)
Therefore, 3n + 2 is even.
We have shown that the contrapositive of the implication is true, so the
implication itself is also true (If 3n + 2 is odd, then n is odd).
Proving Theorems
Hypotheses:
1. Anyone performs well is either intelligent or a good actor.
x (P(x) → I(x) A(x))
2. If someone is intelligent, then he/she can count from 1 to 10.
x (I(x) → C(x) )
3. Gary performs well.
P(G)
4. Gary can only count from 1 to 3.
C(G)
Conclusion: not everyone is both intelligent and a good actor
x(I(x) A(x))
Another Example on Proof
Direct proof:
Step 1: x (P(x) → I(x) A(x)) Hypothesis
Step 2: P(G) → I(G) A(G) Univ. Inst. Step 1
Step 3: P(G) Hypothesis
Step 4: I(G) A(G) Modus ponens Steps 2 & 3
Step 5: x (I(x) → C(x)) Hypothesis
Step 6: I(G) → C(G) Univ. inst. Step5
Step 7: C(G) Hypothesis
Step 8: I(G) Modus tollens Steps 6 & 7
Step 9: I(G) A(G) Addition Step 8
Step 10: (I(G) A(G)) Equivalence Step 9
Step 11: x(I(x) A(x)) Exist. general. Step 10
Step 12: x (I(x) A(x)) Equivalence Step 11
Conclusion: x (I(x) A(x)), not everyone is both intelligent and a good actor.
Summary, Section 1.5
• Terminology (axiom, theorem, conjecture, argument, etc.)
• Rules of inference (Tables 1 and 2)
• Valid argument (hypotheses and conclusion)
• Construction of valid argument using rules of inference
• For each rule used, write down and the statements involved in the proof
• Direct and indirect proofs
• Other proof methods (e.g., induction, pigeon hole) will be introduced in later
chapters
Exercise 1
Without constructing a truth table, use equivalent laws. Check if the
propositional expression G is an implication of F.
a) F = P ∧ (Q ∨ R) G = (P ∧ Q) ∨ R
b) F = P → Q ∧ Q → R G=P→ Q→R
c) F = P ∧ Q G = (¬P → Q) ∨ (P → ¬Q)
Exercise 2
Without constructing a truth table, use equivalent laws. Prove that the
following propositional expressions are true.
a) P → (¬P → P)
b) P → ((Q → (P ∧ Q)))
c) ¬(P ∨ ¬Q) → ¬P
d) ((P → Q) ∧ (Q → R)) → (P → R)
Exercise 3
Without constructing a truth table, use equivalent laws. Prove the
following logical equivalences.
a) P ∨ Q ∧ ¬(¬P ∧ Q) ⇔ P
b) ¬ ¬((P ∨ Q ∧ R)) ∨ ¬Q) ⇔ Q ∧ R
c) P ∨ Q ∧ P ∨ ¬Q ∨Q ⇔ P∨Q
d) ¬ (P ∨ Q) ∨ ¬P ∧ Q ∨ ¬Q ⇔ ¬ (P ∧ Q)
e) (P → Q) ∧ (¬Q ∧ (R ∨ ¬Q)) ⇔ ¬ (Q ∨ P)
Exercise 4
Without constructing a truth table, use equivalent laws. Prove the
following logical equivalences.
a) P ∨ (P ∧ P ∨ Q ) ⇔ P
b) P ∨ Q ∨ ¬P ∧ ¬Q ∧ R ⇔ P∨Q∨R
c) ¬P ∨ ¬Q → P ∧ Q ∧ R ⇔ P∧Q
d) P ∧ ((¬Q → (R ∧ R)) ∨ ¬(Q ∨ R ∧ S ∨ R ∧ ¬S ) ⇔ P
e) (P ∨ Q ∨ R) ∧ (P ∨ S ∨ ¬Q) ∧ (P ∨ ¬S ∨ R) ⇔ P ∨ (R ∧ S ∨ ¬Q )
Exercise 5
Without constructing a truth table, use equivalent laws. Prove the following
logical equivalences.
a) (p → r) ∧ (q → r) ⇔ (p ∨ q) → r
b) p → q ∨ p → r ⇔ p → q ∨ r
c) ¬ p ∨ q ∨ ¬p ∨ q ∧ ¬q ⇔ p → q ∧ ¬q ∧ r ∨ ¬q
d) ¬ ¬ r ∨ q ∧ q ∨ ¬p ⇔ ¬p ∨ ¬q → p ∧ q ∧ r
e) p ∨ ((p ∧ q) ∨ (p ∧ ¬r)) ⇔ p ∧ ((¬q → r) ∨ ¬(q ∨ (r ∧ s) ∨ (r ∧ ¬s)))
Exercise 6
Given 2 predicates P(x) Q(x) determined as follows:
𝑃 𝑥 = 𝑥≤3
Q(x) = {x + 1 is odd}
If space is the set of integers, determine the truth values of the following
statements:
a) P(1) f) P 3 ∧ Q 4
b) Q(1) g) P 4
c) ¬P(3) h) ¬(P(−4) ∨ Q(−3))
d) Q(6) i) ¬P (−4) ∧ ¬Q (−3)
e) P 7 ∧ Q 7
Exercise 7
a) No one is perfect
b) Not all of you are perfect
c) All your friends are perfect.
d) One of your friends is perfect.
e) Everyone is your friend and is perfect.
f) Not everyone is your friend or someone is not perfect.
Exercise 8
Given 𝐿(𝑥, 𝑦) : "x loves y", with the space of 𝑥 and y being the set of people in the
world. Use logical expression a to translate the following sentences:
a) Everyone loves Jerry.
b) Everyone loves someone.
c) There is a person that everyone loves.
d) No one loves everyone.
e) There is someone Lydia doesn't love.
f) There is a person that no one loves.
g) There is exactly one person that everyone loves.
h) There are exactly two people Lynn loves.
i) Everyone loves themself.
j) There is someone who loves no one but himself.
Q&A
Questions and Answer
Thank you for your attention