Logic and Proofs: Foundations of Reasoning
Logic and Proofs: Foundations of Reasoning
1
CONTENT
1.1 Logic
1.1.1 Propositions
1.1.2 Fundamental Logical Operators
1.1.3 Implications
1.1.4 Precedence of Logical Operators
1.1.5 Logic and Bit Operations
3
1.1.1 Propositions
A proposition is a declarative statement that not
is either TRUE or FALSE both!
but not both.
Examples.
Washington, D.C. is the capital of the US TRUE
1+1=2 TRUE
2+2=3 FALSE
3+2
x+y=z
Exercise. Which of these sentences are propositions?
What are the truth values of those that are propositions?
a) Paris is the capital of France.
b) The sun rises in the west.
c) 2 + 3 = 5.
d) x + 7 = 10.
e) x2 + 1 >0.
f ) Answer this question.
g) Do not pass go.
h) What time is it?
1.1.2 Fundamental Logical Operators
Suppose p is a proposition. The negation of p is written
p and has meaning:
“It is not the case that p.”
p is read “NOT p”
p p
Truth table for negation: T F
F T
Conjunction: p q corresponds to English “and.”
Proposition p q is true when p and q are both true.
p q p→q
T T T
Truth table for implication:
T F F
F T T
F F T
Example. Determine whether each of these conditional
statements is true or false.
a) If 1 + 1 = 2, then 2 + 2 = 5.
b) If 1 + 1 = 3, then 2 + 2 = 4.
c) If 1 + 1 = 3, then 2 + 2 = 5.
d) If monkeys can fly, then 1 + 1 = 3.
e) If 1 + 1 = 3, then dogs can fly.
f) If 1 + 1 = 2, then dogs can fly.
g) If 2 + 2 = 4, then 1 + 2 = 3.
There are a number of ways to indicate or express an
implication in a mathematical statement:
p→q
“if p, then q” “p implies q”
“if p, q” “p only if q”
“p is sufficient for q” “q whenever p”
“q if p” “q is necessary for p”
“q when p” “q follows from p”
Ex. Let p and q be the propositions
p :You drive over 65 miles per hour.
q :You get a speeding ticket.
Write these propositions using p and q and logical connectives (including
negations).
a) You do not drive over 65 miles per hour.
b) You drive over 65 miles per hour, but you do not get a speeding ticket.
c) You will get a speeding ticket if you drive over 65 miles per hour.
d) If you do not drive over 65 miles per hour, then you will not get a
speeding ticket.
e) Driving over 65 miles per hour is sufficient for getting a speeding ticket.
f ) You get a speeding ticket, but you do not drive over 65 miles per hour.
g) Whenever you get a speeding ticket, you are driving over 65 miles per
hour.
The implication can be reduced to the other
fundamental logical operators.
Example. Consider the truth tables of p → q and p q
p q p→q p p q
T T T F T
T F F F F
F T T T T
F F T T T
pq
“p iff q.”
These propositions are logically equivalent.
▪Thus p → q p q
Contrapositive:
“If the home team does not win, then it is not raining.”
Converse:
“If the home team wins, then it is raining.”
Inverse is
“If it is not raining, then the home team does not win.”
1.1.4 Precedence of Logical Operators
➢ In a compound proposition with several logical operators,
we have to use parentheses ( ) to specify their order of
execution.
➢ However to reduce the number of parentheses used we
adopted the following precedence convention.
Operator Precedence
Ex. p q r means (p q) r 1
2
rather than p (q r)
3
p q → r means (p q) → r → 4
5
Example. Construct a truth table for the compound
propositions pq →r
p q r pq p q →r
F F F F T
F F T F T
F T F T F
F T T T T
T F F T F
T F T T T
T T F T F
T T T T T
◼Negation ppT
p p F
◼Commutativity pqqp
pqqp
◼Associativity (p q) r p (q r)
(p q) r p (q r)
◼Distributivity p (q r) (p q) (p r)
p (q r) (p q) (p r)
◼ DeMorgan’s (p q) p q
(p q) p q
◼ Absorption p (p q) p
p (p q) p
Proofs of some famous Equivalences
➢ Distributivity p (q r) (p q) (p r)
T T T T T T T T
T T F F T T T T
T F T F T T T T
T F F F T T T T
F T T T T T T T
F T F F F T F F
F F T F F F T F
F F F F F F F F
➢ DeMorgan’s (p q) p q
p q p q p q pq (p q)
T T F F F T F
T F F T F T F
F T T F F T F
F F T T T F T
➢ DeMorgan’s (p q) p q
Therefore
p q Double negation
➢ Show that [p (p → q)] → q is a tautology.
➢ We apply the Laws of Logic in each steps.
[p (p → q)] → q
[p (p q)] → q substitution for →
[(p p) (p q)] → q distributivity
[ F (p q)] → q negation
(p q) → q identity
(p q) q substitution for →
(p q) q DeMorgan’s
p (q q ) associativity
p T negation
T domination
The following logical equivalences involving
implications can be checked using the Laws of Logic
• p→qq→p
• (p → q) p q
• (p → q) ( p → r) p → (q r)
• (p → r) ( q → r) (p q) → r
• (p → q) ( p → r) p → (q r)
• (p → r) ( q → r) (p q) → r
➢ We also have logical equivalences involving
Biconditionals
p q (p → q) (q → p)
pqpq
p q (p q) ( p q)
(p q) p q
1.3.1 Predicates
1.3.2 Quantifiers
1.3.3 Negations
X+2=5 NO
12 > 4 YES
X>4 NO
Q(3,4) YES
Q(x,9) NO
x P(x)
Otherwise, it is false
Ex 11/53 Let P(x) be the statement “x =x2.” If the domain
consists of the integers, what are these truth values?
a) P(0) b) P(1) c) P(2)
d) P(−1) e) ∃xP(x) f ) ∀xP(x)
b) ∀x(C(x) ∧ F(x))
c) ∃x(C(x) → F(x))
d) ∃x(C(x) ∧ F(x))
a) ∀x(C(x) → F(x))
All comedians are funny
b) ∀x(C(x) ∧ F(x))
Every person is funny and a comedian.
c) ∃x(C(x) → F(x))
There exists a person such that if this person is a
comedian then this person is funny
d) ∃x(C(x) ∧ F(x))
There is a person who is a comedian and funny
Ex 9 /53 Let
P(x) = “x can speak Russian” and let
Q(x) =“x knows the computer language C++.”
Express each of these sentences in terms of P(x), Q(x),
quantifiers, and logical connectives. The domain for quantifiers
consists of all students at your school.
a) There is a student at your school who can speak Russian
and who knows C++.
b) There is a student at your school who can speak Russian
but who doesn’t know C++.
c) Every student at your school either can speak Russian or
knows C++.
d) No student at your school can speak Russian or knows
C++.
a) There is a student at your school who can speak Russian
and who knows C++.
∃x (P(x) ∧ Q(x))
¬∃x (P(x))
¬∀x(P(x))
∀x (F (x) → P (x))
∃x (F(x) ∧ P(x))
1.3.3 Negations
Another:
B(x) = “x is a hummingbird.”
L(x) = “x is a large bird.”
H(x) = “x lives on honey.”
R(x) = “x is richly colored.”
x (B(x) → R(x))
All hummingbirds are richly colored.
Reminder: in a
proposition, all
variables must be
bound.
Predicates - multiple quantifiers
To bind many variables, use many quantifiers.
1.4.1 Definitions
1.2.2 Rules of Inference
1.4.3 Fallacies
1.4.4 Rules of Inference and Quantifiers
1.4.5
1.4.1 Definition
An argument in propositional logic is a sequence of
propositions. All but the final proposition in the
argument are called premises and the final
proposition is called the conclusion.
Therefore,
▪ “you can log onto the network” conclusion
81
1.4.2. Rules of Inference
An argument form in propositional logic is a sequence of
compound propositions involving propositional
variables.
p
“if you have a current password,
then you can log onto the network” q
✓ “you have a current password”
Therefore,
“you can log onto the network”
p→q
p
q
82
Valid arguments in propositional logic
83
We can use a truth table to show that an argument form is
valid. By showing that whenever the premises are true,
the conclusion must also be true.
p→q
p
q
85
Instead of using a truth table to show that an argument form
is valid, we can use Rules of inference.
The tautology (p (p→q))→q is the basis of the rule of
inference called Modus Ponens ( or law of detachment-
mode that affirms)
p→q
p
q
The hypotheses are written in a column, followed by
horizontal bar, followed by the and the conclusion.
86
Terminology
➢A theorem is a statement that can be shown to be true.
87
A theorem is a statement that can be shown to be
true.
A proof is the means of doing so.
Axioms, postulates,
hypotheses, & previously
proven theorems
Rules of Inference
Proof
Modus Ponens
I am Luyen.
If I am Luyen, then I am a lecturer of
Mathematics.
I am a lecturer of Mathematics.
p Inference
tautology: Rule:
p→q
(p (p → q)) → q Modus
q Ponens
Modus Tollens
I am not a great actor.
If I am Thanh, then I am a great actor.
I am not Thanh!
q Inference
tautology:
p→q Rule:
(q (p → q)) → p Modus
p
Tollens
Addition
Inference
tautology:
p Rule:
p → (p q)
pq Addition
Conjunction
Inference
tautology:
p Rule:
q p q → (p q)
Conjuction
pq
Simplification
I am not a great actor and you are sleepy.
you are sleepy.
pq Inference
tautology: Rule:
q
((p q) q) → p Disjunctive
p Syllogism
Hypothetical Syllogism
If you are a CS major, then you must pass Math 2215.
If you passed Math 2215, then you are good in logic.
If you are a CS major, then you are good in logic.
p→q Inference
tautology: Rule:
q→r
((p → q) (q → r)) → (p → r) Hypothetical
p→r Syllogism
Rule of Inference Tautology Name
p p→pq Addition
pq
pq pq→p Simplification
p
p, q (p) (q) → p q Conjunction
pq
p, p → q p (p → q) → q Modus Ponens
q
q, p → q q (p → q) → p Modus Tollens
p
p → q, q → r (p → q) (q → r) Hypothetical
p→r → (p → r) Syllogism
p q, p (p q) p → q Disjunctive
q Syllogism
Ex 3/78. Which rule of inference is used in each argument
below?
a) Alice is a Math major. Therefore, Alice is either a Math
major or a CS major.
b) Jerry is a Math major and a CS major. Therefore, Jerry is a
Maths major.
c) If it is rainy, then the pool will be closed. It is rainy.
Therefore, the pool is closed.
d) If it snows today, the university will close. The university is
not closed today. Therefore, it did not snow today.
e) If I go swimming, then I will stay in the sun too long. If I
stay in the sun too long, then I will sunburn. Therefore, if I
go swimming, then I will sunburn.
f) I go swimming or eat an ice cream. I did not go swimming.
Therefore, I eat an ice cream.
Using Rules of Inference to Build Arguments
A formal proof of a conclusion C, given premises p1,
p2,…,pn consists of a sequence of steps, each of which
applies some inference rule to premises or to previously-
proven statements (as hypotheses) to yield a new true
statement (the conclusion).
99
Example.
Show that the hypotheses
“It is not sunny and it is cold (q).”
“we will swim (r) only if it is sunny (p),
“If we do not swim, then we will canoe (s).”
“If we canoe, then we will be home early (t).”
Leads to the conclusion
“We will be home early” t
p q , r → p, r →s, s → t
100
We can use the truth table
Premises p q , r → p, r →s, s → t
Conclusion t
Step Reason p q
1. p q Hypothesis r→p
2. p Simplification using (1) r →s
3. r → p Hypothesis s→t
4. r Modus Tollens using (2) (3) t
5. r →s Hypothesis
6. s Modus ponens using (4) (5)
7. s → t Hypothesis
8. t Modus ponens using (6) (7)
101
A little proof…
Here’s what you know:
Minh is a BM major or a CS major.
If Minh does not like discrete math, he is not a CS
major.
If Minh likes discrete math, he is smart.
BC
Minh is not a BM major.
D → C
Can you conclude Minh is smart? D→S
B
1. B C
2. D → C
3. D → S
4. B
I am Descartes
Affirming the
I’m Luyen
conclusion.
((p → q) q) → p
Fallacies:
Not at tautology.
If you don’t give me $10, I bite your ear.
I bite your ear!
You didn’t give me $10.
Affirming the
conclusion.
((p → q) q) → p
Fallacies:
Not at tautology.
If it rains then it is cloudy.
It does not rain.
It is not cloudy
Denying the
hypothesis.
((p → q) p) → q
Fallacies:
Not at tautology.
If it is a bicycle, then it has 2 wheels.
It is not a bicycle.
It doesn’t have 2 wheels.
((p → q) p) → q
Fallacies:
Not at tautology.
1.4.4. Rules of Inference for Quantified Statements
x P(x) Universal
__________
P(c) if cU instantiation
x P(x) Existential
______________________
instantiation
P(c) for some element cU
P(c) for some element cU Existential
____________________
x P(x) generalization
109
Rules of Inference for Quantified Statements
Example.
U(x): “x is an US student.”
G(x): “x is a genius.”
110
Rules of Inference for Quantified Statements
x P(x)
__________ Universal
P(c) if cU instantiation
111
Example
Anyone performs well is either intelligent or a good actor.
If someone is intelligent, then he/she can count
from 1 to 10.
Gary performs well.
Gary can only count from 1 to 3.
Therefore, not everyone is both intelligent and a good actor
P(x): x performs well
I(x): x is intelligent
A(x): x is a good actor
C(x): x can count from 1 to 10
112
Hypotheses:
Anyone performs well is either intelligent or a good actor.
x (P(x) → I(x) A(x))
If someone is intelligent, then he/she can count
from 1 to 10.
x (I(x) → C(x) )
Gary performs well.
P(G)
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))
113
The following steps are used in the argument:
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
114