Lecture 3
Lecture 3
TABLE 4 The Truth Table for TABLE 5 The Truth Table for
the Exclusive Or of Two the Conditional Statement
Propositions. p → q.
p q p⊕q p q p→q
T T F T T T
T F T T F F
F T T F T T
F F F F F T
DEFINITION 4 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.
The truth table for the exclusive or of two propositions is displayed in Table 4.
DEFINITION 5 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).
If the politician is elected, voters would expect this politician to lower taxes. Furthermore, if the
politician is not elected, then voters will not have any expectation that this person will lower
taxes, although the person may have sufficient influence to cause those in power to lower taxes.
It is only when the politician is elected but does not lower taxes that voters can say that the
politician has broken the campaign pledge. This last scenario corresponds to the case when p
is true but q is false in p → q.
Similarly, consider a statement that a professor might make:
“If you get 100% on the final, then you will get an A.”
If you manage to get a 100% on the final, then you would expect to receive an A. If you do not
get 100% you may or may not receive an A depending on other factors. However, if you do get
100%, but the professor does not give you an A, you will feel cheated.
Of the various ways to express the conditional statement p → q, the two that seem to cause
the most confusion are “p only if q” and “q unless ¬p.” Consequently, we will provide some
guidance for clearing up this confusion.
To remember that “p only if q” expresses the same thing as “if p, then q,” note that “p only
if q” says that p cannot be true when q is not true. That is, the statement is false if p is true,
but q is false. When p is false, q may be either true or false, because the statement says nothing
about the truth value of q. Be careful not to use “q only if p” to express p → q because this is
incorrect. To see this, note that the true values of “q only if p” and p → q are different when
p and q have different truth values.
You might have trouble
understanding how To remember that “q unless ¬p” expresses the same conditional statement as “if p, then
“unless” is used in q,” note that “q unless ¬p” means that if ¬p is false, then q must be true. That is, the statement
conditional statements “q unless ¬p” is false when p is true but q is false, but it is true otherwise. Consequently,
unless you read this “q unless ¬p” and p → q always have the same truth value.
paragraph carefully.
We illustrate the translation between conditional statements and English statements in Ex-
ample 7.
EXAMPLE 7 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: From the definition of conditional statements, we see that when p is the statement
“Maria learns discrete mathematics” and q is the statement “Maria will find a good job,” p → q
represents the statement
“If Maria learns discrete mathematics, then she will find a good job.”
There are many other ways to express this conditional statement in English. Among the most
natural of these are:
“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.”
and
“Maria will find a good job unless she does not learn discrete mathematics.”
▲
Note that the way we have defined conditional statements is more general than the meaning
attached to such statements in the English language. For instance, the conditional statement in
Example 7 and the statement
“If it is sunny, then we will go to the beach.”
are statements used in normal language where there is a relationship between the hypothesis
and the conclusion. Further, the first of these statements is true unless Maria learns discrete
mathematics, but she does not get a good job, and the second is true unless it is indeed sunny,
but we do not go to the beach. On the other hand, the statement
8 1 / The Foundations: Logic and Proofs
is true from the definition of a conditional statement, because its conclusion is true. (The truth
value of the hypothesis does not matter then.) The conditional statement
is true if Juan does not have a smartphone, even though 2 + 3 = 6 is false. We would not use
these last two conditional statements in natural language (except perhaps in sarcasm), because
there is no relationship between the hypothesis and the conclusion in either statement. In math-
ematical reasoning, we consider conditional statements of a more general sort than we use in
English. The mathematical concept of a conditional statement is independent of a cause-and-
effect relationship between hypothesis and conclusion. Our definition of a conditional statement
specifies its truth values; it is not based on English usage. Propositional language is an artificial
language; we only parallel English usage to make it easy to use and remember.
The if-then construction used in many programming languages is different from that used
in logic. Most programming languages contain statements such as if p then S, where p is a
proposition and S is a program segment (one or more statements to be executed). When execution
of a program encounters such a statement, S is executed if p is true, but S is not executed if p
is false, as illustrated in Example 8.
if 2 + 2 = 4 then x := x + 1
if x = 0 before this statement is encountered? (The symbol := stands for assignment. The
statement x := x + 1 means the assignment of the value of x + 1 to x.)
▲
CONVERSE, CONTRAPOSITIVE, AND INVERSE We can form some new conditional
statements starting with a conditional statement p → q. In particular, there are three related
conditional statements that occur so often that they have special names. The proposition q → p
is called the converse of p → q. The contrapositive of p → q is the proposition ¬q → ¬p.
The proposition ¬p → ¬q is called the inverse of p → q. We will see that of these three
conditional statements formed from p → q, only the contrapositive always has the same truth
value as p → q.
We first show that the contrapositive, ¬q → ¬p, of a conditional statement p → q always
has the same truth value as p → q. To see this, note that the contrapositive is false only when
¬p is false and ¬q is true, that is, only when p is true and q is false. We now show that neither
the converse, q → p, nor the inverse, ¬p → ¬q, has the same truth value as p → q for all
possible truth values of p and q. Note that when p is true and q is false, the original conditional
statement is false, but the converse and the inverse are both true.
Remember that the
contrapositive, but neither When two compound propositions always have the same truth value we call them equiv-
the converse or inverse, of alent, so that a conditional statement and its contrapositive are equivalent. The converse and
a conditional statement is the inverse of a conditional statement are also equivalent, as the reader can verify, but neither is
equivalent to it. equivalent to the original conditional statement. (We will study equivalent propositions in Sec-
tion 1.3.) Take note that one of the most common logical errors is to assume that the converse
or the inverse of a conditional statement is equivalent to this conditional statement.
We illustrate the use of conditional statements in Example 9.
1.1 Propositional Logic 9
EXAMPLE 9 What are the contrapositive, the converse, and the inverse of the conditional statement
“The home team wins whenever it is raining?”
Solution: Because “q whenever p” is one of the ways to express the conditional statement
p → q, the original statement can be rewritten as
“If it is raining, then the home team wins.”
Consequently, the contrapositive of this conditional statement is
“If the home team does not win, then it is not raining.”
The converse is
“If the home team wins, then it is raining.”
The inverse is
“If it is not raining, then the home team does not win.”
▲
Only the contrapositive is equivalent to the original statement.
The truth table for p ↔ q is shown in Table 6. Note that the statement p ↔ q is true when both
the conditional statements p → q and q → p are true and is false otherwise. That is why we use
the words “if and only if” to express this logical connective and why it is symbolically written
by combining the symbols → and ←. There are some other common ways to express p ↔ q:
“p is necessary and sufficient for q”
“if p then q, and conversely”
“p iff q.”
The last way of expressing the biconditional statement p ↔ q uses the abbreviation “iff” for
“if and only if.” Note that p ↔ q has exactly the same truth value as (p → q) ∧ (q → p).
T T T
T F F
F T F
F F T
10 1 / The Foundations: Logic and Proofs
EXAMPLE 10 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.”
This statement is true if p and q are either both true or both false, that is, if you buy a ticket and
can take the flight or if you do not buy a ticket and you cannot take the flight. It is false when
p and q have opposite truth values, that is, when you do not buy a ticket, but you can take the
flight (such as when you get a free trip) and when you buy a ticket but you cannot take the flight
▲
(such as when the airline bumps you).
IMPLICIT USE OF BICONDITIONALS You should be aware that biconditionals are not
always explicit in natural language. In particular, the “if and only if” construction used in
biconditionals is rarely used in common language. Instead, biconditionals are often expressed
using an “if, then” or an “only if” construction. The other part of the “if and only if” is implicit.
That is, the converse is implied, but not stated. For example, consider the statement in English
“If you finish your meal, then you can have dessert.” What is really meant is “You can have
dessert if and only if you finish your meal.” This last statement is logically equivalent to the
two statements “If you finish your meal, then you can have dessert” and “You can have dessert
only if you finish your meal.” Because of this imprecision in natural language, we need to
make an assumption whether a conditional statement in natural language implicitly includes its
converse. Because precision is essential in mathematics and in logic, we will always distinguish
between the conditional statement p → q and the biconditional statement p ↔ q.
(p ∨ ¬q) → (p ∧ q).
Solution: Because this truth table involves two propositional variables p and q, there are four
rows in this truth table, one for each of the pairs of truth values TT, TF, FT, and FF. The first
two columns are used for the truth values of p and q, respectively. In the third column we find
the truth value of ¬q, needed to find the truth value of p ∨ ¬q, found in the fourth column. The
fifth column gives the truth value of p ∧ q. Finally, the truth value of (p ∨ ¬q) → (p ∧ q) is
▲
found in the last column. The resulting truth table is shown in Table 7.
T T F T T T
T F T T F F
F T F F F T
F F T T F F
1.1 Propositional Logic 11
JOHN WILDER TUKEY (1915–2000) Tukey, born in New Bedford, Massachusetts, was an only child. His
parents, both teachers, decided home schooling would best develop his potential. His formal education began
at Brown University, where he studied mathematics and chemistry. He received a master’s degree in chemistry
from Brown and continued his studies at Princeton University, changing his field of study from chemistry to
mathematics. He received his Ph.D. from Princeton in 1939 for work in topology, when he was appointed an
instructor in mathematics at Princeton. With the start of World War II, he joined the Fire Control Research Office,
where he began working in statistics. Tukey found statistical research to his liking and impressed several leading
statisticians with his skills. In 1945, at the conclusion of the war, Tukey returned to the mathematics department
at Princeton as a professor of statistics, and he also took a position at AT&T Bell Laboratories. Tukey founded
the Statistics Department at Princeton in 1966 and was its first chairman. Tukey made significant contributions to many areas of
statistics, including the analysis of variance, the estimation of spectra of time series, inferences about the values of a set of parameters
from a single experiment, and the philosophy of statistics. However, he is best known for his invention, with J. W. Cooley, of the fast
Fourier transform. In addition to his contributions to statistics, Tukey was noted as a skilled wordsmith; he is credited with coining
the terms bit and software.
Tukey contributed his insight and expertise by serving on the President’s Science Advisory Committee. He chaired several
important committees dealing with the environment, education, and chemicals and health. He also served on committees working
on nuclear disarmament. Tukey received many awards, including the National Medal of Science.
HISTORICAL NOTE There were several other suggested words for a binary digit, including binit and bigit, that never were widely
accepted. The adoption of the word bit may be due to its meaning as a common English word. For an account of Tukey’s coining
of the word bit, see the April 1984 issue of Annals of the History of Computing.
12 1 / The Foundations: Logic and Proofs
0 0 0 0 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 0
Information is often represented using bit strings, which are lists of zeros and ones. When
this is done, operations on the bit strings can be used to manipulate this information.
DEFINITION 7 A bit string is a sequence of zero or more bits. The length of this string is the number of bits
in the string.
▲
EXAMPLE 12 101010011 is a bit string of length nine.
We can extend bit operations to bit strings. We define the bitwise OR, bitwise AND, and
bitwise XOR of two strings of the same length to be the strings that have as their bits the OR,
AND, and XOR of the corresponding bits in the two strings, respectively. We use the symbols
∨, ∧, and ⊕ to represent the bitwise OR, bitwise AND, and bitwise XOR operations, respectively.
We illustrate bitwise operations on bit strings with Example 13.
EXAMPLE 13 Find the bitwise OR, bitwise AND, and bitwise XOR of the bit strings 01 1011 0110 and
11 0001 1101. (Here, and throughout this book, bit strings will be split into blocks of four
bits to make them easier to read.)
Solution: The bitwise OR, bitwise AND, and bitwise XOR of these strings are obtained by taking
the OR, AND, and XOR of the corresponding bits, respectively. This gives us
01 1011 0110
11 0001 1101
11 1011 1111 bitwise OR
01 0001 0100 bitwise AND
10 1010 1011 bitwise XOR
▲
Exercises
5. What is the negation of each of these propositions? 10. Let p and q be the propositions “The election is decided”
a) Steve has more than 100 GB free disk space on his and “The votes have been counted,” respectively. Express
laptop. each of these compound propositions as an English sen-
b) Zach blocks e-mails and texts from Jennifer. tence.
c) 7 · 11 · 13 = 999. a) ¬p b) p ∨ q
d) Diane rode her bicycle 100 miles on Sunday. c) ¬p ∧ q d) q → p
6. Suppose that Smartphone A has 256 MB RAM and 32 GB e) ¬q → ¬p f ) ¬p → ¬q
ROM, and the resolution of its camera is 8 MP; Smart- g) p ↔ q h) ¬q ∨ (¬p ∧ q)
phone B has 288 MB RAM and 64 GB ROM, and the 11. Let p and q be the propositions
resolution of its camera is 4 MP; and Smartphone C has p : It is below freezing.
128 MB RAM and 32 GB ROM, and the resolution of q : It is snowing.
its camera is 5 MP. Determine the truth value of each of
Write these propositions using p and q and logical con-
these propositions.
nectives (including negations).
a) Smartphone B has the most RAM of these three smart-
a) It is below freezing and snowing.
phones.
b) It is below freezing but not snowing.
b) Smartphone C has more ROM or a higher resolution
c) It is not below freezing and it is not snowing.
camera than Smartphone B.
d) It is either snowing or below freezing (or both).
c) Smartphone B has more RAM, more ROM, and a
e) If it is below freezing, it is also snowing.
higher resolution camera than Smartphone A.
f ) Either it is below freezing or it is snowing, but it is
d) If Smartphone B has more RAM and more ROM than
not snowing if it is below freezing.
Smartphone C, then it also has a higher resolution
g) That it is below freezing is necessary and sufficient
camera.
e) Smartphone A has more RAM than Smartphone B if for it to be snowing.
and only if Smartphone B has more RAM than Smart- 12. Let p, q, and r be the propositions
phone A. p : You have the flu.
7. Suppose that during the most recent fiscal year, the an- q : You miss the final examination.
nual revenue of Acme Computer was 138 billion dollars r : You pass the course.
and its net profit was 8 billion dollars, the annual revenue Express each of these propositions as an English sen-
of Nadir Software was 87 billion dollars and its net profit tence.
was 5 billion dollars, and the annual revenue of Quixote a) p → q b) ¬q ↔ r
Media was 111 billion dollars and its net profit was c) q → ¬r d) p ∨ q ∨ r
13 billion dollars. Determine the truth value of each of e) (p → ¬r) ∨ (q → ¬r)
these propositions for the most recent fiscal year. f ) (p ∧ q) ∨ (¬q ∧ r)
a) Quixote Media had the largest annual revenue. 13. Let p and q be the propositions
b) Nadir Software had the lowest net profit and Acme p : You drive over 65 miles per hour.
Computer had the largest annual revenue. q : You get a speeding ticket.
c) Acme Computer had the largest net profit or Quixote
Write these propositions using p and q and logical con-
Media had the largest net profit.
d) If Quixote Media had the smallest net profit, then nectives (including negations).
Acme Computer had the largest annual revenue. a) You do not drive over 65 miles per hour.
e) Nadir Software had the smallest net profit if and only b) You drive over 65 miles per hour, but you do not get
if Acme Computer had the largest annual revenue. a speeding ticket.
8. Let p and q be the propositions c) You will get a speeding ticket if you drive over
65 miles per hour.
p : I bought a lottery ticket this week. d) If you do not drive over 65 miles per hour, then you
q : I won the million dollar jackpot. will not get a speeding ticket.
Express each of these propositions as an English sen- e) Driving over 65 miles per hour is sufficient for getting
tence. a speeding ticket.
a) ¬p b) p ∨ q c) p → q f ) You get a speeding ticket, but you do not drive over
d) p ∧ q e) p ↔ q f ) ¬p → ¬q 65 miles per hour.
g) ¬p ∧ ¬q h) ¬p ∨ (p ∧ q) g) Whenever you get a speeding ticket, you are driving
9. Let p and q be the propositions “Swimming at the New over 65 miles per hour.
Jersey shore is allowed” and “Sharks have been spotted 14. Let p, q, and r be the propositions
near the shore,” respectively. Express each of these com- p : You get an A on the final exam.
pound propositions as an English sentence. q : You do every exercise in this book.
a) ¬q b) p ∧ q c) ¬p ∨ q r : You get an A in this class.
d) p → ¬q e) ¬q → p f ) ¬p → ¬q Write these propositions using p, q, and r and logical
g) p ↔ ¬q h) ¬p ∧ (p ∨ ¬q) connectives (including negations).
14 1 / The Foundations: Logic and Proofs
a) You get an A in this class, but you do not do every a) Coffee or tea comes with dinner.
exercise in this book. b) A password must have at least three digits or be at
b) You get an A on the final, you do every exercise in this least eight characters long.
book, and you get an A in this class. c) The prerequisite for the course is a course in number
c) To get an A in this class, it is necessary for you to get theory or a course in cryptography.
an A on the final. d) You can pay using U.S. dollars or euros.
d) You get an A on the final, but you don’t do every ex-
20. For each of these sentences, determine whether an in-
ercise in this book; nevertheless, you get an A in this
clusive or, or an exclusive or, is intended. Explain your
class.
answer.
e) Getting an A on the final and doing every exercise in
this book is sufficient for getting an A in this class. a) Experience with C++ or Java is required.
f ) You will get an A in this class if and only if you either b) Lunch includes soup or salad.
do every exercise in this book or you get an A on the c) To enter the country you need a passport or a voter
final. registration card.
15. Let p, q, and r be the propositions d) Publish or perish.
p : Grizzly bears have been seen in the area. 21. For each of these sentences, state what the sentence means
q : Hiking is safe on the trail. if the logical connective or is an inclusive or (that is, a dis-
r : Berries are ripe along the trail. junction) versus an exclusive or. Which of these meanings
Write these propositions using p, q, and r and logical of or do you think is intended?
connectives (including negations). a) To take discrete mathematics, you must have taken
a) Berries are ripe along the trail, but grizzly bears have calculus or a course in computer science.
not been seen in the area. b) When you buy a new car from Acme Motor Company,
b) Grizzly bears have not been seen in the area and hik- you get $2000 back in cash or a 2% car loan.
ing on the trail is safe, but berries are ripe along the c) Dinner for two includes two items from column A or
trail. three items from column B.
c) If berries are ripe along the trail, hiking is safe if and d) School is closed if more than 2 feet of snow falls or if
only if grizzly bears have not been seen in the area. the wind chill is below −100.
d) It is not safe to hike on the trail, but grizzly bears have 22. Write each of these statements in the form “if p, then q”
not been seen in the area and the berries along the trail in English. [Hint: Refer to the list of common ways to ex-
are ripe. press conditional statements provided in this section.]
e) For hiking on the trail to be safe, it is necessary but not a) It is necessary to wash the boss’s car to get promoted.
sufficient that berries not be ripe along the trail and b) Winds from the south imply a spring thaw.
for grizzly bears not to have been seen in the area.
c) A sufficient condition for the warranty to be good is
f ) Hiking is not safe on the trail whenever grizzly bears
that you bought the computer less than a year ago.
have been seen in the area and berries are ripe along
d) Willy gets caught whenever he cheats.
the trail.
e) You can access the website only if you pay a subscrip-
16. Determine whether these biconditionals are true or
tion fee.
false.
f ) Getting elected follows from knowing the right peo-
a) 2 + 2 = 4 if and only if 1 + 1 = 2. ple.
b) 1 + 1 = 2 if and only if 2 + 3 = 4.
g) Carol gets seasick whenever she is on a boat.
c) 1 + 1 = 3 if and only if monkeys can fly.
d) 0 > 1 if and only if 2 > 1. 23. Write each of these statements in the form “if p, then q”
in English. [Hint: Refer to the list of common ways to
17. Determine whether each of these conditional statements
express conditional statements.]
is true or false.
a) It snows whenever the wind blows from the northeast.
a) If 1 + 1 = 2, then 2 + 2 = 5.
b) If 1 + 1 = 3, then 2 + 2 = 4. b) The apple trees will bloom if it stays warm for a week.
c) If 1 + 1 = 3, then 2 + 2 = 5. c) That the Pistons win the championship implies that
d) If monkeys can fly, then 1 + 1 = 3. they beat the Lakers.
18. Determine whether each of these conditional statements d) It is necessary to walk 8 miles to get to the top of
is true or false. Long’s Peak.
e) To get tenure as a professor, it is sufficient to be world-
a) If 1 + 1 = 3, then unicorns exist.
famous.
b) If 1 + 1 = 3, then dogs can fly.
c) If 1 + 1 = 2, then dogs can fly. f ) If you drive more than 400 miles, you will need to buy
d) If 2 + 2 = 4, then 1 + 2 = 3. gasoline.
g) Your guarantee is good only if you bought your CD
19. For each of these sentences, determine whether an in-
player less than 90 days ago.
clusive or, or an exclusive or, is intended. Explain your
answer. h) Jan will go swimming unless the water is too cold.
1.1 Propositional Logic 15
40. Explain, without using a truth table, why (p ∨ ¬q) ∧ because Fred is happy most of the time, and the truth value
(q ∨ ¬r) ∧ (r ∨ ¬p) is true when p, q, and r have the 0.4 can be assigned to the statement “John is happy,” because
same truth value and it is false otherwise. John is happy slightly less than half the time. Use these truth
41. Explain, without using a truth table, why (p ∨ q ∨ r) ∧ values to solve Exercises 45–47.
(¬p ∨ ¬q ∨ ¬r) is true when at least one of p, q, and r 45. The truth value of the negation of a proposition in fuzzy
is true and at least one is false, but is false when all three logic is 1 minus the truth value of the proposition. What
variables have the same truth value. are the truth values of the statements “Fred is not happy”
42. What is the value of x after each of these statements is and “John is not happy?”
encountered in a computer program, if x = 1 before the 46. The truth value of the conjunction of two propositions in
statement is reached? fuzzy logic is the minimum of the truth values of the two
a) if x + 2 = 3 then x := x + 1 propositions. What are the truth values of the statements
b) if (x + 1 = 3) OR (2x + 2 = 3) then x := x + 1 “Fred and John are happy” and “Neither Fred nor John is
c) if (2x + 3 = 5) AND (3x + 4 = 7) then x := x + 1 happy?”
d) if (x + 1 = 2) XOR (x + 2 = 3) then x := x + 1 47. The truth value of the disjunction of two propositions in
e) if x < 2 then x := x + 1 fuzzy logic is the maximum of the truth values of the two
43. Find the bitwise OR, bitwise AND, and bitwise XOR of propositions. What are the truth values of the statements
each of these pairs of bit strings. “Fred is happy, or John is happy” and “Fred is not happy,
a) 101 1110, 010 0001 or John is not happy?”
b) 1111 0000, 1010 1010 ∗ 48. Is the assertion “This statement is false” a proposition?
c) 00 0111 0001, 10 0100 1000 ∗ 49. The nth statement in a list of 100 statements is “Exactly
d) 11 1111 1111, 00 0000 0000 n of the statements in this list are false.”
44. Evaluate each of these expressions. a) What conclusions can you draw from these state-
a) 1 1000 ∧ (0 1011 ∨ 1 1011) ments?
b) (0 1111 ∧ 1 0101) ∨ 0 1000 b) Answer part (a) if the nth statement is “At least n of
c) (0 1010 ⊕ 1 1011) ⊕ 0 1000 the statements in this list are false.”
d) (1 1011 ∨ 0 1010) ∧ (1 0001 ∨ 1 1011) c) Answer part (b) assuming that the list contains 99
Fuzzy logic is used in artificial intelligence. In fuzzy logic, a statements.
proposition has a truth value that is a number between 0 and 1, 50. An ancient Sicilian legend says that the barber in a remote
inclusive. A proposition with a truth value of 0 is false and one town who can be reached only by traveling a dangerous
with a truth value of 1 is true. Truth values that are between 0 mountain road shaves those people, and only those peo-
and 1 indicate varying degrees of truth. For instance, the truth ple, who do not shave themselves. Can there be such a
value 0.8 can be assigned to the statement “Fred is happy,” barber?