Propositional Logic
• Logic is the basis of all mathematical reasoning and of all automated
reasoning.
• Propositions: A proposition is a declarative sentence (that is, a sentence
that declares a fact) that is either true or false, but not both. A proposition
is a basic building blocks of logic.
• Eg:
• 1 + 1 = 2.
• Toronto is the capital of Canada.
• What time is it?
• x + 1 = 2.
• Propositional variables (or statement variables): Variables that
represent propositions. The conventional letters used for
propositional variables are p, q, r, s, . . . .
• If the proposition is true, it is denoted by T. If the proposition is false,
it is denoted by F.
• The area of logic that deals with propositions is called the
propositional calculus or propositional logic.
• Many mathematical statements are constructed by combining one or
more propositions. New propositions, called compound propositions,
are formed from existing propositions using logical operators.
1. Negation of p: Let p be a proposition. The negation of p, denoted by ¬𝑝
(also denoted by 𝑝) read as “not p”, is the statement “It is not the case
that p.”
• Eg: Find the negation of the proposition
Truth table
“Michael’s PC runs Linux”
𝑝 ¬𝑝
and express this in simple English.
T F
“It is not the case that Michael’s PC runs Linux.” F T
“Michael’s PC does not run Linux.”
Q. Find the negation of the proposition
“Vandana’s smartphone has at least 32GB of memory”
and express this in simple English.
“It is not the case that Vandana’s smartphone has at least 32GB of
memory.”
“Vandana’s smartphone does not have at least 32GB of memory”
“Vandana’s smartphone has less than 32GB of memory.”
2. Conjunction of p and q: Let p and q be propositions. The conjunction
of p and q, denoted by p ∧ q, is the proposition “p and q.” The
conjunction p ∧ q is true when both p and q are true and is false
otherwise.
Truth table
𝑝 𝒒 𝑝∧𝑞
T T T
T F F
F T F
F F F
3. Disjunction of p and q: Let p and q be propositions. The disjunction of p and q,
denoted by p ∨ q, is the proposition “p or q.” The disjunction p ∨ q is false when
both p and q are false and is true otherwise.
Truth table
𝑝 𝒒 𝑝∨𝑞 𝑝⊕𝑞
T T T F
T F T T
F T T T
F F F F
4. Exclusive or of p and q: Let p and q be propositions. The exclusive or of p and
q, denoted by p ⊕ q, is the proposition that is true when exactly one of p and q
is true and is false otherwise.
5. Conditional Statements: Let p and q be propositions. The conditional statement p →
q is the proposition “if p, then q.” The conditional statement p → q is false when p is true
and q is false, and true otherwise.
In the conditional statement p → q, p is called the hypothesis (or antecedent or premise) and
q is called the conclusion (or consequence). A conditional statement is also called an
implication.
• Note that the statement p → q is true when both p and q are true and when p is false (no
matter what truth value q has).
• “If you get 100% on the final, then you will get an A.”
Truth table Truth table
𝑝 𝒒 𝑝→𝑞 𝑝 𝒒 ¬𝒑 ¬𝒑 ∨ 𝒒 𝑝→𝑞
T T T T T F T T
T F F T F F F F
F T T F T T T T
F F T F F T T T
Expressing conditional statement:
1. “if p, then q” 2. “p implies q”
3. “if p, q” 4. “p only if q”
5. “p is sufficient for q” 6. “a sufficient condition for q is p”
7. “q if p” 8. “q whenever p”
9. “q when p” 10. “q is necessary for p”
11. “a necessary condition for p is q” 12. “q follows from p”
13. “q unless ¬p”
Q. 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.
p: Maria learns discrete mathematics.
q: Maria will find a good job.
“if p, then q”
“If Maria learns discrete mathematics, then she will find a good job.”
“q when p”
“Maria will find a good job when she learns discrete mathematics.”
“q unless ¬p”
“Maria will find a good job unless she does not learn discrete mathematics.”
CONVERSE, CONTRAPOSITIVE, AND INVERSE
CONVERSE: The converse of p → 𝑞 is the proposition q → 𝑝.
CONTRAPOSITIVE: The contrapositive of p → 𝑞 is the proposition ¬𝑞 → ¬𝑝.
INVERSE: The inverse of p → 𝑞 is the proposition ¬p → ¬𝑞.
Q. Find the truth table for converse, contrapositive and inverse:
p q Converse: Contrapositive: Inverse:
q→𝑝 ¬𝑞 → ¬𝑝 ¬p → ¬𝑞
T T
T F
F T
F F
Only the contrapositive always has the same truth value as p → q. When two
compound propositions always have the same truth value we call them
equivalent. A conditional statement and its contrapositive are equivalent.
Q. What are the contrapositive, the converse, and the inverse of the
conditional statement
“The home team wins whenever it is raining?”
“q whenever p”
q: The home team wins
p: It is raining.
“The home team wins whenever it is raining?”
“q whenever p”
q: The home team wins
p: It is raining.
Contrapositive ¬𝑞 → ¬𝑝 : “If the home team does not win, then it is
not raining.”
Converse q → 𝑝 : “If the home team wins, then it is raining.”
Inverse ¬p → ¬𝑞: “If it is not raining, then the home team does not
win.”
BICONDITIONALS: Let p and q be propositions. The biconditional statement
p ↔ q is the proposition “p if and only if q.” Biconditional statements are also
called bi-implications.
p ↔ q has exactly the same truth value as (p → q) ∧ (q → p).
Q. Find the truth table for p ↔ q
p q p→𝒒 𝑞→𝑝 p⟷𝑞
T T
T F
F T
F F
Q. 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?
Q. Construct the truth table of the compound proposition
(p ∨¬q) → (p ∧ q).
Precedence of Logical Operators
Operator Precedence
¬ 1
∧ 2
∨ 3
→ 4
↔ 5
Q. Let p, q, and r be the propositions
p :You have the flu.
q :You miss the final examination.
r :You pass the course.
Express each of these propositions as an English sentence.
a) p → q b) ¬q ↔ r
c) q →¬r d) p ∨ q ∨ r
e) (p →¬r) ∨ (q →¬r)
f ) (p ∧ q) ∨ (¬q ∧ r)
Sometimes in logic, the word “but” is used instead of “and”.
The sun is shining, but it is raining.
Expressing it using logical connective:
p: The sun is shining.
q: It’s raining
𝑝∧𝑞
Q. Let p, q, and r be the propositions
p : Grizzly bears have been seen in the area.
q : Hiking is safe on the trail.
r : Berries are ripe along the trail.
Write these propositions using p, q, and r and logical connectives (including
negations).
a) Berries are ripe along the trail, but grizzly bears have not been seen in the
area.
b) Grizzly bears have not been seen in the area and hiking on the trail is safe,
but berries are ripe along the trail.
c) If berries are ripe along the trail, hiking is safe if and only if grizzly bears
have not been seen in the area.
d) It is not safe to hike on the trail, but grizzly bears have not been seen in
the area and the berries along the trail are ripe.
e ) Hiking is not safe on the trail whenever grizzly bears have been seen in
the area and berries are ripe along the trail.
Q. Let p, q, and r be the propositions
p : Grizzly bears have been seen in the area.
q : Hiking is safe on the trail.
r : Berries are ripe along the trail.
Write these propositions using p, q, and r and logical connectives (including
negations).
a) Berries are ripe along the trail, but grizzly bears have not been seen in the
area.
b) Grizzly bears have not been seen in the area and hiking on the trail is safe,
but berries are ripe along the trail.
c) If berries are ripe along the trail, hiking is safe if and only if grizzly bears
have not been seen in the area.
d) It is not safe to hike on the trail, but grizzly bears have not been seen in
the area and the berries along the trail are ripe.
e ) Hiking is not safe on the trail whenever grizzly bears have been seen in
the area and berries are ripe along the trail.
p : Grizzly bears have been seen in the area.
q : Hiking is safe on the trail.
r : Berries are ripe along the trail.
Write these propositions using p, q, and r and logical connectives (including negations).
a) Berries are ripe along the trail, but grizzly bears have not been seen in the area.
𝑟 ∧ ¬𝑝
b) Grizzly bears have not been seen in the area and hiking on the trail is safe, but berries are ripe along the
trail.
¬𝑝 ∧ 𝑞 ∧ 𝑟
c) If berries are ripe along the trail, hiking is safe if and only if grizzly bears have not been seen in the area.
𝑟 → (𝑞 ↔ ¬𝑝)
d) It is not safe to hike on the trail, but grizzly bears have not been seen in the area and the berries along the
trail are ripe.
¬ 𝑞 ∧ ¬𝑝 ∧ 𝑟
e ) Hiking is not safe on the trail whenever grizzly bears have been seen in the area and berries are ripe along
the trail.
𝑝 ∧ 𝑟 → ¬𝑞
Q. Let p, q, and r be the propositions and:
but/nevertheless/however/even
p :You get an A on the final exam. so/inspite/yet/though/still/nonetheless/anyhow/an
q :You do every exercise in this book. yway
r :You get an A in this class.
Write these propositions using p, q, and r and logical connectives (including
negations).
a) You get an A in this class, but you do not do every exercise in this book.
b) You get an A on the final, you do every exercise in this book, and you get an A in this
class.
c) To get anA in this class, it is necessary for you to get an A on the final.
d) You get an A on the final, but you don’t do every exercise in this book; nevertheless,
you get an A in this class.
e) Getting an A on the final and doing every exercise in this book is sufficient for
getting an A in this class.
f ) You will get an A in this class if and only if you either do every exercise in this book
or you get an A on the final.
p :You get an A on the final exam.
q :You do every exercise in this book.
r :You get an A in this class.
Write these propositions using p, q, and r and logical connectives (including negations).
a) You get an A in this class, but you do not do every exercise in this book.
𝑝 ∧ ¬𝑞
b) You get an A on the final, you do every exercise in this book, and you get an A in this class.
𝑝∧𝑞∧𝑟
c) To get an A in this class, it is necessary for you to get an A on the final.
𝑟→𝑝
d) You get an A on the final, but you don’t do every exercise in this book; nevertheless, you get an A in this class.
𝑝 ∧ ¬𝑞 ∧ 𝑟
e) Getting an A on the final and doing every exercise in this book is sufficient for getting an A in this class.
𝑝∧𝑞 →𝑟
f ) You will get an A in this class if and only if you either do every exercise in this book or you get an A on the
final.
𝑟 ↔ (𝑞 ∨ 𝑟)
Q. Write each of these statements in the form “if p, then q”
a) It snows whenever the wind blows from the northeast.
b) The apple trees will bloom if it stays warm for a week.
c) That the Pistons win the championship implies that they beat the Lakers.
d) It is necessary to walk 8 miles to get to the top of Long’s Peak.
e) To get tenure as a professor, it is sufficient to be world famous.
f ) If you drive more than 400 miles, you will need to buy gasoline.
g) Your guarantee is good only if you bought your CD player less than 90 days
ago.
h) Jan will go swimming unless the water is too cold.
Write each of these statements in the form “if p, then q”
a) It snows whenever the wind blows from the northeast. 𝑞 𝑤ℎ𝑒𝑛𝑒𝑣𝑒𝑟 𝑝
If the wind blows from the northeast, then it snows
b) The apple trees will bloom if it stays warm for a week. 𝑞 𝑖𝑓 𝑝
If it stays warm for a week, then the apple trees will bloom
c) That the Pistons win the championship implies that they beat the Lakers. 𝑝 𝑖𝑚𝑝𝑙𝑖𝑒𝑠 𝑞
If the Pistons win the championship, then they beat the Lakers.
d) It is necessary to walk 8 miles to get to the top of Long’s Peak.
What is necessary to get to the top of Long’s Peak : to walk 8 miles (conclusion/consequence)
If you get to the top of Long’s Peak, then must have walked 8 miles.
e) To get tenure as a professor, it is sufficient to be world famous.
What is sufficient to get tenure as a professor: to be world famous (hypothesis/antecedent/premise)
If you are world famous, then you will get tenure as a professor.
f ) If you drive more than 400 miles, you will need to buy gasoline.
If you drive more than 400 miles, then you will need to buy gasoline.
g) Your guarantee is good only if you bought your CD player less than 90 days ago. 𝑝 𝑜𝑛𝑙𝑦 𝑖𝑓 𝑞
If your guarantee is good, then you have bought your CD player less than 90 days ago.
h) Jan will go swimming unless the water is too cold. 𝑞 𝑢𝑛𝑙𝑒𝑠𝑠 𝑛𝑜𝑡 𝑝
If the water is not too cold, then Jan will go swimming.
Translating English Sentences
• Translate the English sentences into expressions involving
propositional variables and logical connectives
• Once we have translated sentences from English into logical
expressions we can analyze these logical expressions to determine
their truth values, we can manipulate them, and we can use rules of
inference (will be taught later) to reason about them.
Q. Translated into a logical expression
“You can access the Internet from campus only if you are a computer
science major or you are not a freshman.”
• “You can access the Internet from campus”: a
• “You are a computer science major”: c
• “You are a freshman”: f
𝑎 → (𝑐 ∨ ¬𝑓)
Q. “You cannot ride the roller coaster if you are under 4 feet tall unless you are
older than 16 years old.”
r: You can ride the roller coaster.
u: you are under 4 feet tall.
o: you are older than 16 years old.
(𝑢 ∧ ¬𝑜) → ¬𝑟
Q. The automated reply cannot be sent when the file system is full
a: The automated reply can be sent.
f: The file system is full.
𝑓 → ¬𝑎
System specifications should be consistent, that is, they should not contain
conflicting requirements that could be used to derive a contradiction.
Q. Determine whether these system specifications are 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.”
p: The diagnostic message is stored in the buffer .
q: The diagnostic message is retransmitted.
𝑝∨𝑞
¬𝑝 p q 𝑝∨𝑞 ¬𝑝 𝑝→𝑞
𝑝→𝑞 T T T F T
T F T F F
F T T T T
F F F T T
Logic Puzzles: Puzzles that can be solved using logical reasoning are known as logic puzzles.
• An island that has two kinds of inhabitants, knights, who always tell the truth, and their opposites,
knaves, who always lie. You encounter two people A and B. What are A and B if A says “B is a
knight” and B says “The two of us are opposite types?”
• Let
• 𝑝 : A is a knight. and ¬𝑝: A is knave
• 𝑞: B is a knight. and¬𝑞: B is knave
Assume A is a knight.
If A is a knight, then he is telling the truth when he says that B is a knight.
However, if B is a knight, then B’s statement that A and B are of opposite types contradicts. We can
conclude that A is not a knight, that is, that p is false.
Assume A is a knave.
If A is a knave, then everything A says is false. A’s statement that B is a knight is a lie. Means that q is
false and B is also a knave. If B is a knave, then B’s statement that A and B are opposite types is a lie
which is consistent with both A and B being knaves.
• We can conclude that both A and B are knaves.
Logic Circuits
Q. Build a digital circuit that produces the output (p ∨¬r) ∧ (¬p ∨ (q
∨¬r)) when given input bits p, q, and r.
Propositional Equivalences
A compound proposition that is always true, no matter what the truth
values of the propositional variables that occur in it, is called a
tautology.
A compound proposition that is always false is called a contradiction.
A compound proposition that is neither a tautology nor a contradiction
is called a contingency.
• Logical Equivalences: Compound propositions that have the same
truth values in all possible cases are called logically equivalent. The
symbol ≡ or ⇔is used to denote logical equivalence.
• The compound propositions p and q are called logically equivalent if p
↔ q is a tautology.
• De Morgan laws:
1. ¬(p ∧ q) ≡ ¬p ∨¬q
2. ¬(p ∨ q) ≡ ¬p ∧¬q
Q. Show that ¬(p ∨ q) and ¬p ∧¬q are logically equivalent.
Q. Show that p ∨ (q ∧ r) and (p ∨ q) ∧ (p ∨ r) are logically equivalent.
Equivalence Name
p∧T≡p Identity laws
Logical Equivalences. p∨F≡p
p∨T≡T Domination laws
p∧F≡F
p∨p≡p Idempotent laws
p∧p≡p
¬(¬p) ≡ p Double negation law
p∨q≡q∨p Commutative laws
p∧q≡q∧p
(p ∨ q) ∨ r ≡ p ∨ (q ∨ r) Associative laws
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) Distributive laws
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
¬(p ∧ q) ≡ ¬p ∨¬q De Morgan’s laws
¬(p ∨ q) ≡ ¬p ∧¬q
p ∨ (p ∧ q) ≡ p Absorption laws
p ∧ (p ∨ q) ≡ p
p ∨¬p ≡ T Negation laws
p ∧¬p ≡ F
Logical Equivalences
Involving Conditional Statements.
• p → q ≡ ¬p ∨ q
• p → q ≡ ¬q →¬p
• p ∨ q ≡ ¬p → q
• p ∧ q ≡ ¬(p →¬q)
• ¬(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
Logical Equivalences Involving
Biconditional Statements.
• p ↔ q ≡ (p → q) ∧ (q → p)
• p ↔ q ≡ ¬p ↔¬q
• p ↔ q ≡ (p ∧ q) ∨ (¬p ∧¬q)
• ¬(p ↔ q) ≡ p ↔¬q