The Foundations: Logic
and Proofs
Chapter 1, Part I: Propositional Logic
With Question/Answer Animations
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill Education.
Chapter Summary
Propositional Logic
The Language of Propositions
Applications
Logical Equivalences
Predicate Logic
The Language of Quantifiers
Logical Equivalences
Nested Quantifiers
Proofs
Rules of Inference
Proof Methods
Proof Strategy
Propositional Logic Summary
The Language of Propositions
Connectives
Truth Values
Truth Tables
Applications
Translating English Sentences
System Specifications
Logic Puzzles
Logic Circuits
Logical Equivalences
Important Equivalences
Showing Equivalence
Satisfiability
Propositional Logic
Section 1.1
Section Summary
Propositions
Connectives
Negation
Conjunction
Disjunction
Implication; contrapositive, inverse, converse
Biconditional
Truth Tables
Propositions
A proposition is a declarative sentence that is either true or false.
Examples of propositions:
a) The Moon is made of green cheese.
b) Trenton is the capital of New Jersey.
c) Toronto is the capital of Canada.
d) 1+0=1
e) 0+0=2
Examples that are not propositions.
a) Sit down!
b) What time is it?
c) x + 1 = 2
d) x + y = z
Propositional Logic
Constructing Propositions
Propositional Variables: p, q, r, s, …
The proposition that is always true is denoted by T and
the proposition that is always false is denoted by F.
Compound Propositions; constructed from logical
connectives and other propositions
Negation ¬
Conjunction ∧
Disjunction ∨
Implication →
Biconditional ↔
Compound Propositions: Negation
The negation of a proposition p is denoted by ¬p and
has this truth table:
p ¬p
T F
F T
Example: If p denotes “The earth is round.”, then ¬p
denotes “It is not the case that the earth is round,” or
more simply “The earth is not round.”
Conjunction
The conjunction of propositions p and q is denoted
by p ∧ q and has this truth table:
p q p∧q
T T T
T F F
F T F
F F F
Example: If p denotes “I am at home.” and q
denotes “It is raining.” then p ∧q denotes “I am at
home and it is raining.”
Disjunction
The disjunction of propositions p and q is denoted
by p ∨q and has this truth table:
p q p ∨q
T T T
T F T
F T T
F F F
Example: If p denotes “I am at home.” and q
denotes “It is raining.” then p ∨q denotes “I am at
home or it is raining.”
The Connective Or in English
In English “or” has two distinct meanings.
“Inclusive Or” - In the sentence “Students who have taken CS202 or
Math120 may take this class,” we assume that students need to have taken
one of the prerequisites, but may have taken both. This is the meaning of
disjunction. For p ∨q to be true, either one or both of p and q must be true.
“Exclusive Or” - When reading the sentence “Soup or salad comes with this
entrée,” we do not expect to be able to get both soup and salad. This is the
meaning of Exclusive Or (Xor). In p ⊕ q , one of p and q must be true, but
not both. The truth table for ⊕ is:
p q p ⊕q
T T F
T F T
F T T
F F F
Implication
If p and q are propositions, then p →q is a conditional statement or
implication which is read as “if p, then q ” and has this truth table:
p q p →q
T T T
T F F
F T T
F F T
Example: If p denotes “I am at home.” and q denotes “It is
raining.” then p →q denotes “If I am at home then it is raining.”
In p →q , p is the hypothesis (antecedent or premise) and q is
the conclusion (or consequence).
Understanding Implication
In p →q there does not need to be any connection
between the antecedent or the consequent. The
“meaning” of p →q depends only on the truth values of p
and q.
These implications are perfectly fine, but would not be
used in ordinary English.
“If the moon is made of green cheese, then I have more
money than Bill Gates. ”
“If the moon is made of green cheese then I’m on welfare.”
“If 1 + 1 = 3, then your grandma wears combat boots.”
Understanding Implication (cont)
One way to view the logical conditional is to think of an
obligation or contract.
“If I am elected, then I will lower taxes.”
“If you get 100% on the final, then you will get an A.”
If the politician is elected and does not lower taxes, then
the voters can say that he or she has broken the campaign
pledge. Something similar holds for the professor. This
corresponds to the case where p is true and q is false.
Implication or Conditional Statements
Example: “If I am elected, then I will lower taxes.”
Where p = I am elected and q = I will lower taxes, p → q
implication: The Truth Table for the
implication of Two
Propositions.
elected, lower taxes.
p q p → q
elected, not lower taxes.
T T T
not elected, lower taxes. T F not F
elected, not lower taxes. F T T
F F T
15
Implication or Conditional Statements
Example:
Let p be the statement “Maria learns discrete mathematics.” and q
the statement “Maria will find a good job.” Express the statement p
→ q as a statement in English.
Solution: Any of the following -
“If Maria learns discrete mathematics, then she will find a
good job.
“Maria will find a good job when she learns discrete
mathematics.”
“For Maria to get a good job, it is sufficient for her to learn
discrete mathematics.”
“To find a good job it is necessary for Maria to learn
discrete mathematics.”
16
Different Ways of Expressing p →q
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
Converse, Contra positive, and Inverse
From p →q we can form new conditional statements .
q →p is the converse of p →q
¬q → ¬ p is the contrapositive of p →q
¬ p → ¬ q is the inverse of p →q
Converse, Contra positive, and Inverse
Example: “ If today is Thursday, then I have a test
today”
Solution:
converse: If I have a test today then today is Thursday.
inverse: If Today is not Thursday then I do not have a test
today.
contrapositive: If I do not have a test today, then today is
not Thursday.
Converse, Contra positive, and Inverse
Example: Find the converse, inverse, and contrapositive
of “It raining is a sufficient condition for my not going
to town.” p= It is raining, q= I don’t go to town
Solution:
converse: If I don’t go to town, then it is raining.
inverse: If it is not raining, then I will go to town.
contra positive: If I go to town, then it is not raining.
Biconditional
If p and q are propositions, then we can form the biconditional
proposition p ↔q , read as “p if and only if q .” The biconditional
p ↔q denotes the proposition with this truth table:
p q p ↔q
T T T
T F F
F T F
F F T
If p denotes “I am at home.” and q denotes “It is raining.” then
p ↔q denotes “I am at home if and only if it is raining.”
Example:
Let p be the statement “You can take the flight”
and let q be the statement “You buy a ticket.”
Then p ↔ q is the statement
“You can take the flight if and only if you buy a
ticket.”
Implication:
If you buy a ticket you can take the flight.
If you don’t buy a ticket you cannot take the
flight.
Expressing the Biconditional
Some alternative ways “p if and only if q” is expressed
in English:
p is necessary and sufficient for q
if p then q , and conversely
p iff q
Truth Tables For Compound Propositions
Construction of a truth table:
Rows
Need a row for every possible combination of values for
the atomic propositions.
Columns
Need a column for the compound proposition (usually at
far right)
Need a column for the truth value of each expression that
occurs in the compound proposition as it is built up.
This includes the atomic propositions
Example Truth Table
Construct a truth table for
p q r r pq p q → r
T T T F T F
T T F T T T
T F T F T F
T F F T T T
F T T F T F
F T F T T T
F F T F F T
F F F T F T
Equivalent Propositions
Two propositions are equivalent if they always have
the same truth value.
Example: Show using a truth table that the
conditional is equivalent to the contrapositive.
Solution:
p q ¬p ¬q p →q ¬q → ¬ p
T T F F T T
T F F T F F
F T T F T T
F F T T T T
Using a Truth Table to Show Non-
Equivalence
Example: Show using truth tables that neither the
converse nor inverse of an implication are not
equivalent to the implication.
Solution:
p q ¬p ¬q p →q ¬ p →¬ q q→p
T T F F T T T
T F F T F T T
F T T F T F F
F F T T T T T
Problem
How many rows are there in a truth table with n
propositional variables?
Solution: 2n We will see how to do this in Chapter 6.
Note that this means that with n propositional
variables, we can construct 2n distinct (i.e., not
equivalent) propositions.
Precedence of Logical Operators
Operator Precedence
1
2
3
4
5
E.g. ¬p Λ q = (¬p ) Λ q
p Λ q ν r = (p Λ q ) ν r
p ν q Λ r = p ν (q Λ r)
Applications of
Propositional Logic
Section 1.2
Applications of Propositional Logic:
Summary
Translating English to Propositional Logic
System Specifications
Boolean Searching
Logic Puzzles
Logic Circuits
AI Diagnosis Method (Optional)
Translating English Sentences
Steps to convert an English sentence to a statement in
propositional logic
Identify atomic propositions and represent using
propositional variables.
Determine appropriate logical connectives
“If I go to Harry’s or to the country, I will not go
shopping.”
p: I go to Harry’s If p or q then not r.
q: I go to the country.
r: I will go shopping.
Example
Problem: Translate the following sentence into
propositional logic:
“You can access the Internet from campus only if you are
a computer science major or you are not a freshman.”
One Solution: Let a, c, and f represent respectively
“You can access the internet from campus,” “You are a
computer science major,” and “You are a freshman.”
a→ (c ∨ ¬ f )
System Specifications
System and Software engineers take requirements in
English and express them in a precise specification
language based on logic.
Example: Express in propositional logic:
“The automated reply cannot be sent when the file
system is full”
Solution: One possible solution: Let p denote “The
automated reply can be sent” and q denote “The file
system is full.”
q→ ¬ p
Consistent System Specifications
Definition: A list of propositions is consistent if it is possible
to assign truth values to the proposition variables so that each
proposition is true.
Exercise: Are these specifications consistent?
“The diagnostic message is stored in the buffer or it is retransmitted.”
“The diagnostic message is not stored in the buffer.”
“If the diagnostic message is stored in the buffer, then it is retransmitted.”
Solution: Let p denote “The diagnostic message is stored in the buffer.” Let q
denote “The diagnostic message is retransmitted” The specification can be
written as: p ∨ q, ¬p, p → q. When p is false and q is true all three statements
are true. So the specification is consistent.
What if “The diagnostic message is not retransmitted is added.”
Solution: Now we are adding ¬q and there is no satisfying assignment. So the
specification is not consistent.
Propositional
Equivalences
Section 1.3
Section Summary
Tautologies, Contradictions, and Contingencies.
Logical Equivalence
Important Logical Equivalences
Showing Logical Equivalence
Normal Forms (optional, covered in exercises in text)
Disjunctive Normal Form
Conjunctive Normal Form
Propositional Satisfiability
Sudoku Example
Tautologies, Contradictions, and
Contingencies
A tautology is a proposition which is always true.
Example: p ∨¬p
A contradiction is a proposition which is always false.
Example: p ∧¬p
A contingency is a proposition which is neither a
tautology nor a contradiction, such as p
P ¬p p ∨¬p p ∧¬p
T F T F
F T T F
Logically Equivalent
Two compound propositions p and q are logically equivalent if p↔q
is a tautology.
We write this as p⇔q or as p≡q where p and q are compound
propositions.
Two compound propositions p and q are equivalent if and only if the
columns in a truth table giving their truth values agree.
This truth table shows that ¬p ∨ q is equivalent to p → q.
p q ¬p ¬p ∨ q p→ q
T T F T T
T F F F F
F T T T T
F F T T T
De Morgan’s Laws
Augustus De Morgan
1806-1871
This truth table shows that De Morgan’s Second Law holds.
p q ¬p ¬q (p∨q) ¬(p∨q) ¬p∧¬q
T T F F T F F
T F F T T F F
F T T F T F F
F F T T F T T
Logical Equivalences
Equivalence Name
p ΛT≡p Identity Laws
p VF≡P
p VT≡T Domination Laws
p ɅF≡F
p Vp≡p Idempotent Laws
p Ʌp≡p
┐(┐p) ≡ p Double negation Law
p Vq≡q Vp Commutative Laws
p Ʌq≡q Ʌp
(p V q) V r ≡ p V (q V r) Associative Laws
(p Ʌ q) Ʌ r ≡ p Ʌ (q Ʌ r)
p V (q Ʌ r) ≡ (p V q ) Ʌ ( p V r) Distributive Laws
p Ʌ (q V r) ≡ (p Ʌ q) V (p Ʌ r)
┐( p Ʌ q) ≡ ┐p V ┐q De Morgan’s Laws
┐( p V q) ≡ ┐p Ʌ ┐q
41
Constructing New Logical Equivalences
We can show that two expressions are logically equivalent by
developing a series of logically equivalent statements.
To prove that we produce a series of equivalences
beginning with A and ending with B.
Keep in mind that whenever a proposition (represented by a
propositional variable) occurs in the equivalences listed
earlier, it may be replaced by an arbitrarily complex
compound proposition.
Equivalence Proofs
Example: Show that
is logically equivalent to
Solution:
Equivalence Proofs
Example: Show that
is a tautology.
Solution:
Constructing New Logical Equivalences
Example: Show that ¬(p → q ) and p Λ ¬q are logically equivalent.
Solution:
¬(p → q ) ≡ ¬(¬p ν q)
≡ ¬(¬p) Λ ¬q by the second De Morgan law
≡ p Λ ¬q by the double negation law
Example: Show that (p Λ q) → (p ν q) is a tautology.
Solution: To show that this statement is a tautology, we will use logical
equivalences to demonstrate that it is logically equivalent to T.
(p Λ q) → (p ν q) ≡ ¬(p Λ q) ν (p ν q)
≡ (¬ p ν ¬q) ν (p ν q) by the first De Morgan law
≡ (¬ p ν p) ν (¬ q ν q) by the associative and
commutative law for disjunction
≡ T ν T From tautology example
≡T
Note: The above examples can also be done using truth tables.
45
Problem 1: Let p : You drive over 65 miles/hour.
q : You get a speeding ticket.
Write the following propositions using logical connectives:
a) You will get a speeding ticket if you drive over 65 miles/hours. p → q
b) You get a speeding ticket, but you don’t drive over 65 miles/hours.
q Ʌ ┐p
Problem 2: For each of the following sentences, state what
the sentence means if the or is an inclusive or exclusive or.
Which of these meanings of or do you think is intended?
a) To take discrete mathematics, youormust have taken calculus or a
Inclusive
course in computer science.
b) exclusive
Dinner for two or two items from column A or three items for
includes
column B.
46
Some solutions of exercises
Problem 3: Construct the truth table for the following
compound statement: (p → q) Ʌ (┐ p → r)
p q r ┐p p→q=x ┐p→r= xɅy
y
T T T F T T T
T T F F T T T
T F T F F T F
T F F F F T F
F T T T T T T
F T F T T F F
F F T T T T T
F F F T T F F
47
Some solutions of exercises
Problem 4: Show that p ↔ q and (p Ʌ q) V (┐p Ʌ ┐q) are logically
equivalent.
(p ↔ q) (p→q)Ʌ (q→p) ; from the definition of p ↔ q
(┐p V q) Ʌ (┐q V p); from the definition of p →q
((┐p V q) Ʌ ┐q ) V ((┐p V q)Ʌ p) ; Distributive laws
((┐p Ʌ ┐q)V (q Ʌ┐q)) V ((┐p Ʌp)V(q Ʌ p));
Distributive laws
((┐p Ʌ ┐q) V F) V (F V (q Ʌ p)); As p Ʌ ┐p = F
(┐p Ʌ ┐q) V (q Ʌ p); Domination laws
(q Ʌ p) V (┐p Ʌ ┐q) ; commutative laws
(p Ʌ q) V (┐p Ʌ ┐q) ; commutative laws
48
Thank You
Study all the solved problem from your text book.
Try to solve related problems from exercise.
49