Lecture 4
Lecture 4
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?
often ambiguous. Translating sentences into compound statements (and other types of logical
expressions, which we will introduce later in this chapter) removes the ambiguity. Note that
this may involve making a set of reasonable assumptions based on the intended meaning of the
sentence. Moreover, 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 (which are discussed in Section 1.6) to reason about
them.
To illustrate the process of translating an English sentence into a logical expression, consider
Examples 1 and 2.
EXAMPLE 1 How can this English sentence be 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.”
Solution: There are many ways to translate this sentence into a logical expression. Although it is
possible to represent the sentence by a single propositional variable, such as p, this would not be
useful when analyzing its meaning or reasoning with it. Instead, we will use propositional vari-
ables to represent each sentence part and determine the appropriate logical connectives between
them. In particular, we let a, c, and f represent “You can access the Internet from campus,”
“You are a computer science major,” and “You are a freshman,” respectively. Noting that “only
if” is one way a conditional statement can be expressed, this sentence can be represented as
a → (c ∨ ¬f ).
▲
EXAMPLE 2 How can this English sentence be translated into a logical expression?
“You cannot ride the roller coaster if you are under 4 feet tall unless you are older than 16
years old.”
Solution: Let q, r, and s represent “You can ride the roller coaster,” “You are under 4 feet tall,”
and “You are older than 16 years old,” respectively. Then the sentence can be translated to
(r ∧ ¬s) → ¬q.
Of course, there are other ways to represent the original sentence as a logical expression,
▲
but the one we have used should meet our needs.
System Specifications
Translating sentences in natural language (such as English) into logical expressions is an essential
part of specifying both hardware and software systems. System and software engineers take
requirements in natural language and produce precise and unambiguous specifications that can
be used as the basis for system development. Example 3 shows how compound propositions
can be used in this process.
EXAMPLE 3 Express the specification “The automated reply cannot be sent when the file system is full”
using logical connectives.
Solution: One way to translate this is to let p denote “The automated reply can be sent” and
q denote “The file system is full.” Then ¬p represents “It is not the case that the automated
18 1 / The Foundations: Logic and Proofs
reply can be sent,” which can also be expressed as “The automated reply cannot be sent.”
Consequently, our specification can be represented by the conditional statement q → ¬p.
▲
System specifications should be consistent, that is, they should not contain conflicting
requirements that could be used to derive a contradiction. When specifications are not consistent,
there would be no way to develop a system that satisfies all specifications.
Solution: To determine whether these specifications are consistent, we first express them using
logical expressions. Let p denote “The diagnostic message is stored in the buffer” and let q
denote “The diagnostic message is retransmitted.” The specifications can then be written as
p ∨ q, ¬p, and p → q. An assignment of truth values that makes all three specifications true
must have p false to make ¬p true. Because we want p ∨ q to be true but p must be false,
q must be true. Because p → q is true when p is false and q is true, we conclude that these
specifications are consistent, because they are all true when p is false and q is true. We could
come to the same conclusion by use of a truth table to examine the four possible assignments
of truth values to p and q.
▲
EXAMPLE 5 Do the system specifications in Example 4 remain consistent if the specification “The diagnostic
message is not retransmitted” is added?
Solution: By the reasoning in Example 4, the three specifications from that example are true
only in the case when p is false and q is true. However, this new specification is ¬q, which is
false when q is true. Consequently, these four specifications are inconsistent.
▲
Boolean Searches
Logical connectives are used extensively in searches of large collections of information, such
as indexes of Web pages. Because these searches employ techniques from propositional logic,
they are called Boolean searches.
In Boolean searches, the connective AND is used to match records that contain both of
two search terms, the connective OR is used to match one or both of two search terms, and the
connective NOT (sometimes written as AND NOT ) is used to exclude a particular search term.
Careful planning of how logical connectives are used is often required when Boolean searches
are used to locate information of potential interest. Example 6 illustrates how Boolean searches
are carried out.
EXAMPLE 6 Web Page Searching Most Web search engines support Boolean searching techniques, which
usually can help find Web pages about particular subjects. For instance, using Boolean searching
to find Web pages about universities in New Mexico, we can look for pages matching NEW
AND MEXICO AND UNIVERSITIES. The results of this search will include those pages that
contain the three words NEW, MEXICO, and UNIVERSITIES. This will include all of the
pages of interest, together with others such as a page about new universities in Mexico. (Note
that in Google, and many other search engines, the word “AND” is not needed, although it is
understood, because all search terms are included by default. These search engines also support
the use of quotation marks to search for specific phrases. So, it may be more effective to search
for pages matching “New Mexico” AND UNIVERSITIES.)
1.2 Applications of Propositional Logic 19
Next, to find pages that deal with universities in New Mexico or Arizona, we can search
for pages matching (NEW AND MEXICO OR ARIZONA) AND UNIVERSITIES. (Note: Here
the AND operator takes precedence over the OR operator. Also, in Google, the terms used for
this search would be NEW MEXICO OR ARIZONA.) The results of this search will include
all pages that contain the word UNIVERSITIES and either both the words NEW and MEXICO
or the word ARIZONA. Again, pages besides those of interest will be listed. Finally, to find
Web pages that deal with universities in Mexico (and not New Mexico), we might first look
for pages matching MEXICO AND UNIVERSITIES, but because the results of this search will
include pages about universities in New Mexico, as well as universities in Mexico, it might be
better to search for pages matching (MEXICO AND UNIVERSITIES) NOT NEW. The results
of this search include pages that contain both the words MEXICO and UNIVERSITIES but
do not contain the word NEW. (In Google, and many other search engines, the word “NOT” is
replaced by the symbol “-”. In Google, the terms used for this last search would be MEXICO
▲
UNIVERSITIES -NEW.)
Logic Puzzles
Puzzles that can be solved using logical reasoning are known as logic puzzles. Solving logic
puzzles is an excellent way to practice working with the rules of logic. Also, computer programs
designed to carry out logical reasoning often use well-known logic puzzles to illustrate their
capabilities. Many people enjoy solving logic puzzles, published in periodicals, books, and on
the Web, as a recreational activity.
We will discuss two logic puzzles here. We begin with a puzzle originally posed by Raymond
Smullyan, a master of logic puzzles, who has published more than a dozen books containing
challenging puzzles that involve logical reasoning. In Section 1.3 we will also discuss the
extremely popular logic puzzle Sudoku.
EXAMPLE 7 In [Sm78] Smullyan posed many puzzles about 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?”
Solution: Let p and q be the statements that A is a knight and B is a knight, respectively, so that
¬p and ¬q are the statements that A is a knave and B is a knave, respectively.
We first consider the possibility that A is a knight; this is the statement that p is true. If A is
a knight, then he is telling the truth when he says that B is a knight, so that q is true, and A and B
are the same type. However, if B is a knight, then B’s statement that A and B are of opposite
types, the statement (p ∧ ¬q) ∨ (¬p ∧ q), would have to be true, which it is not, because A
and B are both knights. Consequently, we can conclude that A is not a knight, that is, that p is
false.
If A is a knave, then because everything a knave says is false, A’s statement that B is
a knight, that is, that q is true, is a lie. This means that q is false and B is also a knave.
Furthermore, 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.
We pose more of Smullyan’s puzzles about knights and knaves in Exercises 19–23. In
Exercises 24–31 we introduce related puzzles where we have three types of people, knights and
knaves as in this puzzle together with spies who can lie.
Next, we pose a puzzle known as the muddy children puzzle for the case of two children.
20 1 / The Foundations: Logic and Proofs
EXAMPLE 8 A father tells his two children, a boy and a girl, to play in their backyard without getting dirty.
However, while playing, both children get mud on their foreheads. When the children stop
playing, the father says “At least one of you has a muddy forehead,” and then asks the children
to answer “Yes” or “No” to the question: “Do you know whether you have a muddy forehead?”
The father asks this question twice. What will the children answer each time this question is
asked, assuming that a child can see whether his or her sibling has a muddy forehead, but cannot
see his or her own forehead? Assume that both children are honest and that the children answer
each question simultaneously.
Solution: Let s be the statement that the son has a muddy forehead and let d be the statement that
the daughter has a muddy forehead. When the father says that at least one of the two children
has a muddy forehead, he is stating that the disjunction s ∨ d is true. Both children will answer
“No” the first time the question is asked because each sees mud on the other child’s forehead.
That is, the son knows that d is true, but does not know whether s is true, and the daughter
knows that s is true, but does not know whether d is true.
After the son has answered “No” to the first question, the daughter can determine that d
must be true. This follows because when the first question is asked, the son knows that s ∨ d is
true, but cannot determine whether s is true. Using this information, the daughter can conclude
that d must be true, for if d were false, the son could have reasoned that because s ∨ d is true,
then s must be true, and he would have answered “Yes” to the first question. The son can reason
in a similar way to determine that s must be true. It follows that both children answer “Yes” the
▲
second time the question is asked.
Logic Circuits
Propositional logic can be applied to the design of computer hardware. This was first observed
in 1938 by Claude Shannon in his MIT master’s thesis. In Chapter 12 we will study this topic
in depth. (See that chapter for a biography of Shannon.) We give a brief introduction to this
application here.
A logic circuit (or digital circuit) receives input signals p1 , p2 , . . . , pn , each a bit [either
0 (off) or 1 (on)], and produces output signals s1 , s2 , . . . , sn , each a bit. In this section we will
In Chapter 12 we design restrict our attention to logic circuits with a single output signal; in general, digital circuits may
some useful circuits. have multiple outputs.
RAYMOND SMULLYAN (BORN 1919) Raymond Smullyan dropped out of high school. He wanted to study
what he was really interested in and not standard high school material. After jumping from one university to
the next, he earned an undergraduate degree in mathematics at the University of Chicago in 1955. He paid
his college expenses by performing magic tricks at parties and clubs. He obtained a Ph.D. in logic in 1959 at
Princeton, studying under Alonzo Church. After graduating from Princeton, he taught mathematics and logic at
Dartmouth College, Princeton University, Yeshiva University, and the City University of New York. He joined
the philosophy department at Indiana University in 1981 where he is now an emeritus professor.
Smullyan has written many books on recreational logic and mathematics, including Satan, Cantor, and
Infinity; What Is the Name of This Book?; The Lady or the Tiger?; Alice in Puzzleland; To Mock a Mockingbird;
Forever Undecided; and The Riddle of Scheherazade: Amazing Logic Puzzles, Ancient and Modern. Because his logic puzzles are
challenging, entertaining, and thought-provoking, he is considered to be a modern-day Lewis Carroll. Smullyan has also written
several books about the application of deductive logic to chess, three collections of philosophical essays and aphorisms, and several
advanced books on mathematical logic and set theory. He is particularly interested in self-reference and has worked on extending
some of Gödel’s results that show that it is impossible to write a computer program that can solve all mathematical problems. He is
also particularly interested in explaining ideas from mathematical logic to the public.
Smullyan is a talented musician and often plays piano with his wife, who is a concert-level pianist. Making telescopes is one
of his hobbies. He is also interested in optics and stereo photography. He states “I’ve never had a conflict between teaching and
research as some people do because when I’m teaching, I’m doing research.” Smullyan is the subject of a documentary short film
entitled This Film Needs No Title.
1.2 Applications of Propositional Logic 21
¬p p p∨q p p∧q
p
q q
p p ∧ ¬q
q (p ∧ ¬q) ∨ ¬r
¬q
r
¬r
Complicated digital circuits can be constructed from three basic circuits, called gates, shown
in Figure 1. The inverter, or NOT gate, takes an input bit p, and produces as output ¬p. The
OR gate takes two input signals p and q, each a bit, and produces as output the signal p ∨ q.
Finally, the AND gate takes two input signals p and q, each a bit, and produces as output the
signal p ∧ q. We use combinations of these three basic gates to build more complicated circuits,
such as that shown in Figure 2.
Given a circuit built from the basic logic gates and the inputs to the circuit, we determine
the output by tracing through the circuit, as Example 9 shows.
Solution: In Figure 2 we display the output of each logic gate in the circuit. We see that the AND
gate takes input of p and ¬q, the output of the inverter with input q, and produces p ∧ ¬q.
Next, we note that the OR gate takes input p ∧ ¬q and ¬r, the output of the inverter with
input r, and produces the final output (p ∧ ¬q) ∨ ¬r.
▲
Suppose that we have a formula for the output of a digital circuit in terms of negations,
disjunctions, and conjunctions. Then, we can systematically build a digital circuit with the
desired output, as illustrated in Example 10.
EXAMPLE 10 Build a digital circuit that produces the output (p ∨ ¬r) ∧ (¬p ∨ (q ∨ ¬r)) when given input
bits p, q, and r.
Solution: To construct the desired circuit, we build separate circuits for p ∨ ¬r and for ¬p ∨
(q ∨ ¬r) and combine them using an AND gate. To construct a circuit for p ∨ ¬r, we use an
inverter to produce ¬r from the input r. Then, we use an OR gate to combine p and ¬r. To
build a circuit for ¬p ∨ (q ∨ ¬r), we first use an inverter to obtain ¬r. Then we use an OR gate
with inputs q and ¬r to obtain q ∨ ¬r. Finally, we use another inverter and an OR gate to get
¬p ∨ (q ∨ ¬r) from the inputs p and q ∨ ¬r.
To complete the construction, we employ a final AND gate, with inputs p ∨ ¬r and ¬p ∨
(q ∨ ¬r). The resulting circuit is displayed in Figure 3.
▲
We will study logic circuits in great detail in Chapter 12 in the context of Boolean algebra,
and with different notation.
22 1 / The Foundations: Logic and Proofs
p p ∨ ¬r
r
¬r (p ∨ ¬r) ∧ (¬p ∨ (q ∨ ¬r))
¬p
p
q ¬p ∨ (q ∨ ¬r)
r q ∨ ¬r
¬r
Exercises
In Exercises 1–6, translate the given statement into proposi- “You have a 64-bit processor,” g1 : “Your processor runs
tional logic using the propositions provided. at 1 GHz or faster,” g2 : “Your processor runs at 2 GHz or
1. You cannot edit a protected Wikipedia entry unless you faster,” r1 : “Your processor has at least 1 GB RAM,” r2 :
are an administrator. Express your answer in terms of e: “Your processor has at least 2 GB RAM,” h16 : “You have
“You can edit a protected Wikipedia entry” and a: “You at least 16 GB free hard disk space,” and h32 : “You have
are an administrator.” at least 32 GB free hard disk space.”
2. You can see the movie only if you are over 18 years old 7. Express these system specifications using the proposi-
or you have the permission of a parent. Express your an- tions p “The message is scanned for viruses” and q “The
swer in terms of m: “You can see the movie,” e: “You are message was sent from an unknown system” together
over 18 years old,” and p: “You have the permission of a with logical connectives (including negations).
parent.” a) “The message is scanned for viruses whenever the
3. You can graduate only if you have completed the require- message was sent from an unknown system.”
ments of your major and you do not owe money to the
b) “The message was sent from an unknown system but
university and you do not have an overdue library book.
it was not scanned for viruses.”
Express your answer in terms of g: “You can graduate,”
m: “You owe money to the university,” r: “You have com- c) “It is necessary to scan the message for viruses when-
pleted the requirements of your major,” and b: “You have ever it was sent from an unknown system.”
an overdue library book.” d) “When a message is not sent from an unknown system
4. To use the wireless network in the airport you must pay it is not scanned for viruses.”
the daily fee unless you are a subscriber to the service. 8. Express these system specifications using the proposi-
Express your answer in terms of w: “You can use the wire- tions p “The user enters a valid password,” q “Access is
less network in the airport,” d: “You pay the daily fee,” granted,” and r “The user has paid the subscription fee”
and s: “You are a subscriber to the service.” and logical connectives (including negations).
5. You are eligible to be President of the U.S.A. only if you a) “The user has paid the subscription fee, but does not
are at least 35 years old, were born in the U.S.A, or at the enter a valid password.”
time of your birth both of your parents were citizens, and b) “Access is granted whenever the user has paid the
you have lived at least 14 years in the country. Express subscription fee and enters a valid password.”
your answer in terms of e: “You are eligible to be Pres-
ident of the U.S.A.,” a: “You are at least 35 years old,” c) “Access is denied if the user has not paid the subscrip-
b: “You were born in the U.S.A,” p: “At the time of your tion fee.”
birth, both of your parents where citizens,” and r: “You d) “If the user has not entered a valid password but has
have lived at least 14 years in the U.S.A.” paid the subscription fee, then access is granted.”
6. You can upgrade your operating system only if you have 9. Are these system specifications consistent? “The system
a 32-bit processor running at 1 GHz or faster, at least is in multiuser state if and only if it is operating normally.
1 GB RAM, and 16 GB free hard disk space, or a 64- If the system is operating normally, the kernel is func-
bit processor running at 2 GHz or faster, at least 2 GB tioning. The kernel is not functioning or the system is
RAM, and at least 32 GB free hard disk space. Express in interrupt mode. If the system is not in multiuser state,
you answer in terms of u: “You can upgrade your oper- then it is in interrupt mode. The system is not in interrupt
ating system,” b32 : “You have a 32-bit processor,” b64 : mode.”
P1: 1/1 P2: 1/2 QC: 1/1 T1: 2
CH01-7T Rosen-2311T MHIA017-Rosen-v5.cls May 13, 2011 15:27
10. Are these system specifications consistent? “Whenever become unhappy if Samir is there, Samir will attend only
the system software is being upgraded, users cannot ac- if Kanti will be there, and Kanti will not attend unless Jas-
cess the file system. If users can access the file system, mine also does. Which combinations of these three friends
then they can save new files. If users cannot save new can you invite so as not to make someone unhappy?
files, then the system software is not being upgraded.” Exercises 19–23 relate to inhabitants of the island of knights
11. Are these system specifications consistent? “The router and knaves created by Smullyan, where knights always tell
can send packets to the edge system only if it supports the the truth and knaves always lie. You encounter two people,
new address space. For the router to support the new ad- A and B. Determine, if possible, what A and B are if they
dress space it is necessary that the latest software release address you in the ways described. If you cannot determine
be installed. The router can send packets to the edge sys- what these two people are, can you draw any conclusions?
tem if the latest software release is installed, The router 19. A says “At least one of us is a knave” and B says nothing.
does not support the new address space.”
20. A says “The two of us are both knights” and B says “A
12. Are these system specifications consistent? “If the file
is a knave.”
system is not locked, then new messages will be queued.
If the file system is not locked, then the system is func- 21. A says “I am a knave or B is a knight” and B says nothing.
tioning normally, and conversely. If new messages are not 22. Both A and B say “I am a knight.”
queued, then they will be sent to the message buffer. If
the file system is not locked, then new messages will be 23. A says “We are both knaves” and B says nothing.
sent to the message buffer. New messages will not be sent Exercises 24–31 relate to inhabitants of an island on which
to the message buffer.” there are three kinds of people: knights who always tell the
13. What Boolean search would you use to look for Web truth, knaves who always lie, and spies (called normals by
pages about beaches in New Jersey? What if you wanted Smullyan [Sm78]) who can either lie or tell the truth. You
to find Web pages about beaches on the isle of Jersey (in encounter three people, A, B, and C. You know one of these
the English Channel)? people is a knight, one is a knave, and one is a spy. Each of the
three people knows the type of person each of other two is. For
14. What Boolean search would you use to look for Web each of these situations, if possible, determine whether there
pages about hiking in West Virginia? What if you wanted is a unique solution and determine who the knave, knight, and
to find Web pages about hiking in Virginia, but not in West spy are. When there is no unique solution, list all possible
Virginia? solutions or state that there are no solutions.
∗ 15. Each inhabitant of a remote village always tells the truth
or always lies. A villager will give only a “Yes” or a “No” 24. A says “C is the knave,” B says, “A is the knight,” and C
response to a question a tourist asks. Suppose you are a says “I am the spy.”
tourist visiting this area and come to a fork in the road. 25. A says “I am the knight,” B says “I am the knave,” and
One branch leads to the ruins you want to visit; the other C says “B is the knight.”
branch leads deep into the jungle. A villager is standing 26. A says “I am the knave,” B says “I am the knave,” and C
at the fork in the road. What one question can you ask the says “I am the knave.”
villager to determine which branch to take?
27. A says “I am the knight,” B says “A is telling the truth,”
16. An explorer is captured by a group of cannibals. There are
and C says “I am the spy.”
two types of cannibals—those who always tell the truth
and those who always lie. The cannibals will barbecue 28. A says “I am the knight,” B says, “A is not the knave,”
the explorer unless he can determine whether a particu- and C says “B is not the knave.”
lar cannibal always lies or always tells the truth. He is 29. A says “I am the knight,” B says “I am the knight,” and
allowed to ask the cannibal exactly one question. C says “I am the knight.”
a) Explain why the question “Are you a liar?” does not
30. A says “I am not the spy,” B says “I am not the spy,” and
work.
C says “A is the spy.”
b) Find a question that the explorer can use to determine
whether the cannibal always lies or always tells the 31. A says “I am not the spy,” B says “I am not the spy,” and
truth. C says “I am not the spy.”
17. When three professors are seated in a restaurant, the host- Exercises 32–38 are puzzles that can be solved by translating
ess asks them: “Does everyone want coffee?” The first statements into logical expressions and reasoning from these
professor says: “I do not know.” The second professor expressions using truth tables.
then says: “I do not know.” Finally, the third professor 32. The police have three suspects for the murder of Mr.
says: “No, not everyone wants coffee.” The hostess comes Cooper: Mr. Smith, Mr. Jones, and Mr. Williams. Smith,
back and gives coffee to the professors who want it. How Jones, and Williams each declare that they did not kill
did she figure out who wanted coffee? Cooper. Smith also states that Cooper was a friend of
18. When planning a party you want to know whom to in- Jones and that Williams disliked him. Jones also states
vite. Among the people you would like to invite are three that he did not know Cooper and that he was out of town
touchy friends. You know that if Jasmine attends, she will the day Cooper was killed. Williams also states that he
24 1 / The Foundations: Logic and Proofs
saw both Smith and Jones with Cooper the day of the whose favorite drink is mineral water (which is one of the
killing and that either Smith or Jones must have killed favorite drinks) given these clues: The Englishman lives
him. Can you determine who the murderer was if in the red house. The Spaniard owns a dog. The Japanese
a) one of the three men is guilty, the two innocent men man is a painter. The Italian drinks tea. The Norwegian
are telling the truth, but the statements of the guilty lives in the first house on the left. The green house is
man may or may not be true? immediately to the right of the white one. The photogra-
b) innocent men do not lie? pher breeds snails. The diplomat lives in the yellow house.
33. Steve would like to determine the relative salaries of three Milk is drunk in the middle house. The owner of the green
coworkers using two facts. First, he knows that if Fred house drinks coffee. The Norwegian’s house is next to the
is not the highest paid of the three, then Janice is. Sec- blue one. The violinist drinks orange juice. The fox is in
ond, he knows that if Janice is not the lowest paid, then a house next to that of the physician. The horse is in a
Maggie is paid the most. Is it possible to determine the house next to that of the diplomat. [Hint: Make a table
relative salaries of Fred, Maggie, and Janice from what where the rows represent the men and columns represent
Steve knows? If so, who is paid the most and who the the color of their houses, their jobs, their pets, and their
least? Explain your reasoning. favorite drinks and use logical reasoning to determine the
34. Five friends have access to a chat room. Is it possible to correct entries in the table.]
determine who is chatting if the following information is 39. Freedonia has fifty senators. Each senator is either honest
known? Either Kevin or Heather, or both, are chatting. or corrupt. Suppose you know that at least one of the Free-
Either Randy or Vijay, but not both, are chatting. If Abby donian senators is honest and that, given any two Free-
is chatting, so is Randy. Vijay and Kevin are either both donian senators, at least one is corrupt. Based on these
chatting or neither is. If Heather is chatting, then so are facts, can you determine how many Freedonian senators
Abby and Kevin. Explain your reasoning. are honest and how many are corrupt? If so, what is the
35. A detective has interviewed four witnesses to a crime. answer?
From the stories of the witnesses the detective has con- 40. Find the output of each of these combinatorial circuits.
cluded that if the butler is telling the truth then so is the
cook; the cook and the gardener cannot both be telling the a) p
truth; the gardener and the handyman are not both lying;
and if the handyman is telling the truth then the cook is
lying. For each of the four witnesses, can the detective de- q
termine whether that person is telling the truth or lying?
Explain your reasoning. b) p
36. Four friends have been identified as suspects for an unau- p
thorized access into a computer system. They have made q
statements to the investigating authorities. Alice said
“Carlos did it.” John said “I did not do it.” Carlos said 41. Find the output of each of these combinatorial circuits.
“Diana did it.” Diana said “Carlos lied when he said that
I did it.” a) p
a) If the authorities also know that exactly one of the q
four suspects is telling the truth, who did it? Explain r
your reasoning.
b) If the authorities also know that exactly one is lying,
who did it? Explain your reasoning. b) p
37. Suppose there are signs on the doors to two rooms. The
sign on the first door reads “In this room there is a lady, q
and in the other one there is a tiger”; and the sign on the
second door reads “In one of these rooms, there is a lady, p
and in one of them there is a tiger.” Suppose that you r
know that one of these signs is true and the other is false.
Behind which door is the lady? 42. Construct a combinatorial circuit using inverters,
∗ 38. Solve this famous logic puzzle, attributed to Albert Ein- OR gates, and AND gates that produces the output
stein, and known as the zebra puzzle. Five men with (p ∧ ¬r) ∨ (¬q ∧ r) from input bits p, q, and r.
different nationalities and with different jobs live in con- 43. Construct a combinatorial circuit using inverters,
secutive houses on a street. These houses are painted dif- OR gates, and AND gates that produces the output
ferent colors. The men have different pets and have dif- ((¬p ∨ ¬r) ∧ ¬q) ∨ (¬p ∧ (q ∨ r)) from input bits p,
ferent favorite drinks. Determine who owns a zebra and q, and r.