2215 CH 1
2215 CH 1
p ~p
T F
F T
Truth Tables
• A truth table lists ALL possible values of a
(compound) proposition
– one column for each propositional variable
– one column for the compound proposition
– 2n rows for n propositional variables
Conjunction (AND)
• The conjunction AND is a logical operator
p: I am going to town.
q: It is raining.
p q: I am going to town and it is raining.
T F F
F T F
F F F
Disjunction (OR)
• Inclusive or - only one proposition needs to be
true for the disjunction to be true.
p: I am going to town.
q: It is raining.
p q: I am going to town or it is raining.
Truth table for (OR)
p q pq
T T T
T F T
F T T
F F F
Exclusive OR
• Only one of p and q are true (not both).
p: I am going to town.
q: It is raining.
p q: Either I am going to town or it is raining.
Truth table for (Exclusive OR)
p q pq
T T F
T F T
F T T
F F F
Conditional statements
• A conditional statement is also called an
implication or an if .. then statement.
• It has the form p q
p: I am going to town.
q: It is raining.
p q: If I am going to town, then it is raining.
• The implication is false only when p is true and
q is false!
Truth table for Conditional statements
p q pq
T T T
T F F
F T T
F F T
Implication - Equivalent Forms
• If p, then q
• p implies q
• If p, q
• q if p
• q whenever p
• p is a sufficient condition for q
• q is a necessary condition for p
• p only if q
Converse of an Implication
• Implication: p q
• Converse: qp
• Implication:
– If I am going to town, it is raining.
• Converse:
– If it is raining, then I am going to town.
Converse of an Implication
p q qp
T T T
F F T
Contrapositive of an Implication
• Implication: pq
• Contrapositive: q p
• Implication:
– If I am going to town, it is raining.
• Contrapositive:
– If it is not raining, then I am not going to town.
• The contrapositive has the same truth table as
the original implication.
Inverse of an Implication
• Implication: p q
• Inverse: p q
• Implication:
– If I am going to town, it is raining.
• Inverse:
– If I am not going to town, then it is not raining.
• The inverse of an implication has the same
truth table as the converse of that implication.
Biconditional
• “if and only if”, “iff”
• pq
• I am going to town if and only if it is raining.
• Both p and q must have the same truth value
for the assertion to be true.
Truth Table for (Biconditional)
p q pq
T T T
T F F
F T F
F F T
Truth Table Summary of Connectives
p q r pq ~r (p q) ~r
T T T T F F
T T F T T T
T F T T F F
T F F T T T
F T T T F F
F T F T T T
F F T F F T
F F F F T T
Precedence of Logical Operators
• Parentheses gets the highest precedence
• Then:
Operator Precedence
1
2
3
4
5
Precedence of Logical Operators
• Examples:
p q r means (p q) r, not p (q r)
p q r means (p q) r
Translating English Sentences
• To remove natural language ambiguity
• Helps in reasoning
• Examples:
– You can access the Internet from campus
only if you are a computer science major or
you are not a freshman.
– You cannot ride the roller coaster if you are
under 4 feet tall unless you are older than 16
years old.
Logic and Bit Operations
• Binary numbers use bits, or binary digits.
• Each bit can have one of two values:
1 (which represents TRUE)
0 (which represents FALSE)
• A variable whose value can be true or false is
called a Boolean variable. A Boolean variable’s
value can be represented using a single bit.
Logic and Bit Operations
• Computer bit operations are exactly the same as the logic
operations we have just studied. Here is the truth table
for the bit operations OR, AND, and XOR:
p p p p p p
T F T F
F T T F
Basic Terminology
p q p q (p q) p q p q
T T T F F F F
T F T F F T F
F T T F T F F
F F F T T T T
Show that: p q p q
p q p p q pq
T T F T T
T F F F F
F T T T T
F F T T T
Determining Logical Equivalence
pTp Identity
pFp
pTT Domination
pFF
ppp Idempotent
ppp
(p q) r p (q r) Associative
(p q) r p (q r)
p (q r) (p q) (p r) Distributive
p (q r) (p q) (p r)
(p q) p q De Morgan’s
(p q) p q
Important Equivalences
p (p q) p Absorption
p (p q) p
p p T Negation
p p F
Example
Show that (p q) and p q are logically
equivalent:
Q.E.D
Example
Show that (p (p q)) and p q are logically equivalent:
p q identity
Equivalences Involving Implications
p→q p q
p→q q → p
pq p → q
pq (p → q)
(p → q) p q
More Equivalences Involving
Implications
(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
Equivalences Involving Biconditionals
p↔q (p → q) (q → p)
p↔q p ↔ q
p↔q (p q) (p q)
(p ↔ q ) p ↔ q
Example
•Show that (p q) (p q) is a tautology.
(p q) (p q) (p q) (p q) p → q p q
P(x) : x > 3
What are the truth values of P(4) and P(2)?
Q(x,y) : x = y + 3
What are the truth values of Q(1, 2) and Q(3, 0)?
Quantifiers
x P(x)
“for all x, P(x)”
“for every x, P(x)”
• Example
U = {positive integers not exceeding 3} and P(x): x2 < 10
– What is the truth value of x P(x)?
P(1) P(2) P (3)
T T T
T
Existential Quantification
• P(x) is true for some x in the universe of
discourse
x P(x)
“for some x, P(x)”
“There exists an x such that P(x)”
“There is at least one x such that P(x)”
• Example
U = {positive integers not exceeding 4} and P(x): x2 < 10
– What is the truth value of x P(x)?
P(1) P(2) P(3) P(4)
T T T F
T
Binding Variables
• Bound variable: if a variable is quantified
• Free variable: Neither bound nor assigned a
specific value
– Example: x P(x), x Q(x,y)
• Scope of Quantifiers: Part of a logical
expression to which a quantifier is applied
– Example: x (P(x) Q(x)) x R(x)
Negation of Quantifiers
• Distributing a negation operator across a
quantifier changes a universal to an existential
and vice versa.
~x P(x) x ~P(x)
~ x P(x) x ~P(x)
Negation of Quantifiers
• Example:
Assume the domain of x is: {students in MTH 2215},
and P(x) : x has taken a course in calculus. Then
x P(x)
means “All students in MTH 2215 have taken a course
in calculus.”
The negation of this statement would be, “Not every
student in MTH 2215 has taken a course in calculus,” or
“There exists some student in MTH 2215 who has not
taken a course in calculus.” This would be:
x P(x)
Translating from English
• There are many ways to translate a given
sentence
• The goal is to produce a logical expression that is
simple and can be easily used in subsequent
reasoning
• Steps:
– Clearly identify the appropriate quantifier(s)
– Introduce variable(s) and predicate(s)
– Translate using quantifiers, predicates, and logical
operators
Example
“Every student in this class has studied calculus.”
• Solution 1
– Assume, U = {all students in MTH 2215}
– Rewrite the sentence: “For every student in the class,
that student has studied calculus.”
– Introduce a variable, x: “For every student x in the
class, x has studied calculus.”
– Replace “x has studied calculus” with: C(x)
– Since our domain is all students in MTH 2215, we
can now represent our sentence with: x C(x)
Example
• “Every student in this class has studied calculus.”
• Solution 2
– Assume, U = {all people}
– Rewrite the sentence: “For every person x, if x is a
student in the class, then x has studied calculus.”
– Replace “x is a student in the class” with: S(x)
– Replace “x has studied calculus” with: C(x)
– We can now represent our sentence with:
x S(x) C(x)
Example
Expressed in English:
“For all real numbers x, for all real numbers y,
x + y = y + x”
When we changed
x y (x + y = 0)
to
y x (x + y = 0)
we changed the meaning of the statement, and
ended up with a false one.
Obviously, if the quantifiers are of different types,
then order is important.
Translating statements with nested quantifiers
argument
H1
H2 H1, H2, … Hn the hypotheses (premises)
We use conjunction: H1 ^ H2 ^ H3…
Hn
C is the conclusion.
C
“” means “therefore” or “it follows that”
Validity of an Argument
• An argument is valid if
– whenever all hypotheses are true, the conclusion is
also true
• To prove that an argument is valid:
– Assume the hypotheses are true
– Use the rules of inference and logical equivalences
to determine that the conclusion is true
Some Rules of Inference
p
pq [p (p q)] q Modus ponens
------------------- mode that affirms
q
q
pq [ q (p q)] p Modus tollens
------------------- mode that denies
p
pq
qr [(p q) (q r)] (p r) Hypothetical
------------------- syllogism
pr
pq
p [(p q) p] q Disjunctive
------------------- syllogism
q
Some Rules of Inference
p
------------------- ppq Addition
pq
pq
------------------- pqp Simplification
p
p
q [(p) (q)] (p q) Conjunction
-------------------
pq
pq
p r [(p q) (p r)] (q r) Resolution
-------------------
qr
Example: Modus Ponens
from Latin: mode that affirms
p ( p ( p q )) q Modus Ponens
pq
q
• In other words:
If the hypothesis p is true
and the hypothesis (p q) is true
Then I can conclude q
Example: Modus Ponens
• p: “n is greater than 3”
• q: “n2 is greater than 9”
pq
qr Hypothetical syllogism
pr
____________________________________________
pq ( p q) p Simplification
p
pTp Identity
pFp
pTT Domination
pFF
ppp Idempotent
ppp
( p) p Double Negation
Recap 1.2: Important Equivalences
pqqp Commutative
pqqp
(p q) r p (q r) Associative
(p q) r p (q r)
p (q r) (p q) (p r) Distributive
p (q r) (p q) (p r)
(p q) p q De Morgan’s
(p q) p q
Recap 1.2: Important Equivalences
p (p q) p Absorption
p (p q) p
p p T Negation
p p F
Example
p q Hypothesis
p Simplification using previous step
r p Hypothesis
r Modus tollens using steps 2 and 3
r s Hypothesis
s Modus ponens using steps 4 and 5
s t Hypothesis
t Modus ponens using steps 6 and 7
Rules of Inference for Quantified Statements
xP(x)
therefore for at
least one specific c,
P(c) is true
Rules of Inference for Quantified Statements
In Universal Instantiation, we know that P(x) is true for all
values of x; therefore it must also be true of any
particular value of x, c.
In Universal Generalization, we know that P(c) is true for
any specific value of c; therefore it must be true for all
values, so x P(x).
In Existential Instantiation, we know that P(x) is true for at
least one specific value of x, c.
• In Universal Instantiation, we know that P(c) is true for
some particular value of c, so x P(x). Here c need not be
arbitrary but often is assumed to be.
Example
Show that the following argument is valid:
• Everyone in the Applied discrete
mathematics class has taken a CSE course.
• Marla is a student in the Applied discrete
mathematics class.
• Therefore, Marla has taken a CSE course.
Example:
Put into propositional form:
D(x) = x is in the Applied discrete mathematics class
C(x) = x has taken a CSE course
Represent hypotheses:
STEP JUSTIFICATION
x(D(x) C(x)) Premise
pq (( p q ) q ) p
q
p
pq (( p q ) p ) q
p
q
p 3n + 2 is odd ~p 3n + 2 is even
q n is odd ~q n is even
Proof complete!
Example (Cont)
Step Reason
a=b hypothesis
a2 = ab Multiply both sides by a
a2 – b2 = ab – b2 Subtract b2 from both sides
(a - b)(a + b) = b(a - b) Factor both sides
a+b=b Divide by (a – b)
2b = b Step 1, replace & simplify
2=1 Divide by b
Mistakes in proof
The problem here is in step 5, where we
divide both sides of the equation by (a – b).
Our original hypothesis was that a = b, so
dividing by (a – b) is dividing by zero,
which is undefined in our numbering
system.
Circular Reasoning
n2 is even hypothesis
n2 = 2k for some integer k Def. of even
Let n = 2j for some integer k ?
n is even Def. of even
• Proof by cases
• Exhaustive proof
• “Without loss of generality”
• Existence proof
• Uniqueness proof
Proof by Cases
• Break the premise of p q into an equivalent
disjunction of the form p1 p2 pn
• Then use the equivalence
[(p1p2pn) q] [(p1q)(p2 q) (pnq)]
• Each of the implications pi q is a case.
• You must
– Convince the reader that the cases are inclusive (i.e.,
they exhaust all possibilities)
– Establish all implications
Example
• Prove that if n is an integer, then n2 n