1.1 Propositional Logic 15 Irgi n ach of thes nts in the form "if n then press conditional statements provided in this section.] 30 Hov in a truth table for each of these a)I will remember o send you the address only if you compound propositions? b)To be actizf hs country.i issufficient that you b)(p v-t)A (p v-s) .it will be a useful reference C(p→r)V(s→=I)V(u→0 d)(pArAs)v(gAt)v(rA-1) d)The Redwthe Stanley Cup if their goalie Cdataakeahoicoawapo apA-P b)PV-P e)( )(pvq)→(pAg) log on to 9 h)You will reach thesummitunless you begin yourclimb each of thes sitions. compound propo 0 bl cp⊕(pVa) d(pAq→(pVa b7aneCeoseme,amdf a)If it is hot outside you buy an ic c(g→一p)w(peq) )(p→a)由(n→-g) est it is ne aCmanthkrahoiecaroapmopo apVg)→(p⊕q) you get promoted c(pVq)⊕(pAq) d(p+q)®(p+q e)The trains run lateon exactly those days when I take for each of thes e compound propo 26.W sitions a pe a)For t an a in this co it is n c)n t you learn how to solve discrete mathe. e(p⊕q)v(p⊕y) fD(p⊕g)A(p⊕-q) every day.you will be in- 35.Constructa truth table foreach of these compound propo sitions. c)It rains if it isa weekend day.and it is a weekend day ap→g b)-pq c9(p→q)V(p→q)d(p→q)A(-p→q) d)You can see the wizard ony if the wizard is not in. (P行q)V-pq) and the wizard is not in only if you can see him. )p4 (p q) 36 If it cas day.I will ski a)(pvq)vr b)(pvq)Ar c)Apositive integer is 37.C sitions. ap→(qVr) ight then I will sta b)p(ar) CD→a)V(D→r) c)When I stay up late,it is necessary that I sleep until dp→d)A(p→r】 CD→g)Vq→r) (p 副p明Agv- 39.Construct a truth table for (p)+(r+s)
1.1 Propositional Logic 15 24. Write each of these statements in the form “if p, then q” in English. [Hint: Refer to the list of common ways to express conditional statements provided in this section.] a) I will remember to send you the address only if you send me an e-mail message. b) To be a citizen of this country, it is sufficient that you were born in the United States. c) If you keep your textbook, it will be a useful reference in your future courses. d) The Red Wings will win the Stanley Cup if their goalie plays well. e) That you get the job implies that you had the best credentials. f ) The beach erodes whenever there is a storm. g) It is necessary to have a valid password to log on to the server. h) You will reach the summit unless you begin your climb too late. 25. Write each of these propositions in the form “p if and only if q” in English. a) If it is hot outside you buy an ice cream cone, and if you buy an ice cream cone it is hot outside. b) For you to win the contest it is necessary and sufficient that you have the only winning ticket. c) You get promoted only if you have connections, and you have connections only if you get promoted. d) If you watch television your mind will decay, and conversely. e) The trains run late on exactly those days when I take it. 26. Write each of these propositions in the form “p if and only if q” in English. a) For you to get an A in this course, it is necessary and sufficient that you learn how to solve discrete mathematics problems. b) If you read the newspaper every day, you will be informed, and conversely. c) It rains if it is a weekend day, and it is a weekend day if it rains. d) You can see the wizard only if the wizard is not in, and the wizard is not in only if you can see him. 27. State the converse, contrapositive, and inverse of each of these conditional statements. a) If it snows today, I will ski tomorrow. b) I come to class whenever there is going to be a quiz. c) A positive integer is a prime only if it has no divisors other than 1 and itself. 28. State the converse, contrapositive, and inverse of each of these conditional statements. a) If it snows tonight, then I will stay at home. b) I go to the beach whenever it is a sunny summer day. c) When I stay up late, it is necessary that I sleep until noon. 29. How many rows appear in a truth table for each of these compound propositions? a) p → ¬p b) (p ∨ ¬r) ∧ (q ∨ ¬s) c) q ∨ p ∨ ¬s ∨ ¬r ∨ ¬t ∨ u d) (p ∧ r ∧ t) ↔ (q ∧ t) 30. How many rows appear in a truth table for each of these compound propositions? a) (q → ¬p) ∨ (¬p → ¬q) b) (p ∨ ¬t) ∧ (p ∨ ¬s) c) (p → r) ∨ (¬s → ¬t) ∨ (¬u → v) d) (p ∧ r ∧ s) ∨ (q ∧ t) ∨ (r ∧ ¬t) 31. Construct a truth table for each of these compound propositions. a) p ∧ ¬p b) p ∨ ¬p c) (p ∨ ¬q) → q d) (p ∨ q) → (p ∧ q) e) (p → q) ↔ (¬q → ¬p) f ) (p → q) → (q → p) 32. Construct a truth table for each of these compound propositions. a) p → ¬p b) p ↔ ¬p c) p ⊕ (p ∨ q) d) (p ∧ q) → (p ∨ q) e) (q → ¬p) ↔ (p ↔ q) f ) (p ↔ q) ⊕ (p ↔ ¬q) 33. Construct a truth table for each of these compound propositions. a) (p ∨ q) → (p ⊕ q) b) (p ⊕ q) → (p ∧ q) c) (p ∨ q) ⊕ (p ∧ q) d) (p ↔ q) ⊕ (¬p ↔ q) e) (p ↔ q) ⊕ (¬p ↔ ¬r) f ) (p ⊕ q) → (p ⊕ ¬q) 34. Construct a truth table for each of these compound propositions. a) p ⊕ p b) p ⊕ ¬p c) p ⊕ ¬q d) ¬p ⊕ ¬q e) (p ⊕ q) ∨ (p ⊕ ¬q) f ) (p ⊕ q) ∧ (p ⊕ ¬q) 35. Construct a truth table for each of these compound propositions. a) p → ¬q b) ¬p ↔ q c) (p → q) ∨ (¬p → q) d) (p → q) ∧ (¬p → q) e) (p ↔ q) ∨ (¬p ↔ q) f ) (¬p ↔ ¬q) ↔ (p ↔ q) 36. Construct a truth table for each of these compound propositions. a) (p ∨ q) ∨ r b) (p ∨ q) ∧ r c) (p ∧ q) ∨ r d) (p ∧ q) ∧ r e) (p ∨ q) ∧ ¬r f ) (p ∧ q) ∨ ¬r 37. Construct a truth table for each of these compound propositions. a) p → (¬q ∨ r) b) ¬p → (q → r) c) (p → q) ∨ (¬p → r) d) (p → q) ∧ (¬p → r) e) (p ↔ q) ∨ (¬q ↔ r) f ) (¬p ↔ ¬q) ↔ (q ↔ r) 38. Construct a truth table for ((p → q) → r) → s. 39. Construct a truth table for (p ↔ q) ↔ (r ↔ s)
16 1/The Foundations:Logic and Proofs 40.Explain.without usinguth table.why (p because Fred is happy most of the time.and the truth value 4 can be assigne htly ese tru 【g4L.Explai ises 45-47 45.The truth value of the negation of a proposition in fuzzy he statements 2PtonWM is not happy 42.What is the x afte d in program. 46 The of the fuzzy logic is the minimum of the truth va es of the two 动+3h 2+1 43 + appy 2a4 AND 3 4 happy? 47.Theuth value of thediscinfwo propositions n fuzzy logic is the maximum of the truth va es of the two 13 PEred is ha and "Fred is not har or John is not happy? *48 Is the assertion"This statement is false"a proposition? 44.Evaluat n of the 11000A0101i101 a)What conclusions can you draw from these state 10mA1010y010o b)Answer part (a)if the nt statement is"At leastof the list contains99 50.An ancient Sicilian legend says that the barber in a remote town who can be reached only by y traveling a dangerous se peop h Fo at are be barber?do no the se pen value 0.8 can be assigned to the statement"Fred is happy. 1.2 Applications of Propositional Logic Introduction Logic has many important applications to mathematics.computer science,and numerous other disciplines.Statements in mathematics and the sciences and in natural language often are im- precise or ambiguous.To make such statements precise,they can be translated into the language of logic. For example.logic is used in the specification of software and hardware,because these cations ne efore development begins.Furthermore,propositional logi can b e used be ems.Logiccom solve many familiar puzzles.Software systems based on the rules of logic have been developed for constructing some,but not all.types of proofs automatically.We will discuss some of these applications of propositional logic in this section and in later chapters. Translating English Sentences The
16 1 / The Foundations: Logic and Proofs 40. Explain, without using a truth table, why (p ∨ ¬q) ∧ (q ∨ ¬r) ∧ (r ∨ ¬p) is true when p, q, and r have the same truth value and it is false otherwise. 41. Explain, without using a truth table, why (p ∨ q ∨ r) ∧ (¬p ∨ ¬q ∨ ¬r) is true when at least one of p, q, and r is true and at least one is false, but is false when all three variables have the same truth value. 42. What is the value of x after each of these statements is encountered in a computer program, if x = 1 before the statement is reached? a) if x + 2 = 3 then x := x + 1 b) if (x + 1 = 3) OR (2x + 2 = 3) then x := x + 1 c) if (2x + 3 = 5) AND (3x + 4 = 7) then x := x + 1 d) if (x + 1 = 2) XOR (x + 2 = 3) then x := x + 1 e) if x < 2 then x := x + 1 43. Find the bitwise OR, bitwise AND, and bitwise XOR of each of these pairs of bit strings. a) 101 1110, 010 0001 b) 1111 0000, 1010 1010 c) 00 0111 0001, 10 0100 1000 d) 11 1111 1111, 00 0000 0000 44. Evaluate each of these expressions. a) 1 1000 ∧ (0 1011 ∨ 1 1011) b) (0 1111 ∧ 1 0101) ∨ 0 1000 c) (0 1010 ⊕ 1 1011) ⊕ 0 1000 d) (1 1011 ∨ 0 1010) ∧ (1 0001 ∨ 1 1011) Fuzzy logic is used in artificial intelligence. In fuzzy logic, a proposition has a truth value that is a number between 0 and 1, inclusive.A proposition with a truth value of 0 is false and one with a truth value of 1 is true. Truth values that are between 0 and 1 indicate varying degrees of truth. For instance, the truth value 0.8 can be assigned to the statement “Fred is happy,” because Fred is happy most of the time, and the truth value 0.4 can be assigned to the statement “John is happy,” because John is happy slightly less than half the time. Use these truth values to solve Exercises 45–47. 45. The truth value of the negation of a proposition in fuzzy logic is 1 minus the truth value of the proposition. What are the truth values of the statements “Fred is not happy” and “John is not happy?” 46. The truth value of the conjunction of two propositions in fuzzy logic is the minimum of the truth values of the two propositions. What are the truth values of the statements “Fred and John are happy” and “Neither Fred nor John is happy?” 47. The truth value of the disjunction of two propositions in fuzzy logic is the maximum of the truth values of the two propositions. What are the truth values of the statements “Fred is happy, or John is happy” and “Fred is not happy, or John is not happy?” ∗48. Is the assertion “This statement is false” a proposition? ∗49. The nth statement in a list of 100 statements is “Exactly n of the statements in this list are false.” a) What conclusions can you draw from these statements? b) Answer part (a) if the nth statement is “At least n of the statements in this list are false.” c) Answer part (b) assuming that the list contains 99 statements. 50. An ancient Sicilian legend says that the barber in a remote town who can be reached only by traveling a dangerous mountain road shaves those people, and only those people, who do not shave themselves. Can there be such a barber? 1.2 Applications of Propositional Logic Introduction Logic has many important applications to mathematics, computer science, and numerous other disciplines. Statements in mathematics and the sciences and in natural language often are imprecise or ambiguous. To make such statements precise, they can be translated into the language of logic. For example, logic is used in the specification of software and hardware, because these specifications need to be precise before development begins. Furthermore, propositional logic and its rules can be used to design computer circuits, to construct computer programs, to verify the correctness of programs, and to build expert systems. Logic can be used to analyze and solve many familiar puzzles. Software systems based on the rules of logic have been developed for constructing some, but not all, types of proofs automatically. We will discuss some of these applications of propositional logic in this section and in later chapters. Translating English Sentences There are many reasons to translate English sentences into expressions involving propositional variables and logical connectives. In particular, English (and every other human language) is
1.2Applications of Propositional Logic 17 nd statements (and othe hihntodie late nhapetheNote 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 ressions t determine their truth values e can manipulat them Toillustrate 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 ess the Internet from campus only if you are a computer science major or you are not a freshman. Sotion:There are many ways to translate this sentence into a logical expression.Although it is possible to represent the sentence by a single propositional varia ole,such as p.this would not b eful when analyzing its meaning or rea soning with it.Instead d,we wil 0 a le ifis one way a conditional statement can be expressed,this sentence can be represented as a→(cVf). EXAMPLE 2 How can this English sentence be translated into a logical expression? onde the roller coaster if you are under 4 feet tall unless you are older th You can ride the olle "“You are under4 feet tall, 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 Translatin mers 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 EXAMPLE3 Express the specification"The automated reply cannot be sent when the file system is full" using logical connectives a邮
1.2 Applications of Propositional Logic 17 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 variables 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 Crpbeed b the cmlna System specifications should be consistent.that is they should not contain conflicting at could e no way to develop a system th n specincations are not consistent. speci EXAMPLE4 Determine whether these system specifications are consistent: "The diagnostic message is stored in the buffer or it is retransmitted. agnosnc message is stored in the Solution To determine whether the logical exr essions.Let p denote"The diagnostic message is stored in the buffer"and let denote"The diagnostic message is retransmitted."The specifications can then be written as p.and q.An assignment of truth values that makes all three specificat ons true e p fal to make -p true.Be se we nt p to be true but e fal pust be rue.Becaus c p e,we co to the sam to of truth values to p andg. EXAMPLE5 Do the system sp esae ot retedsremain consistent if the specifcation The diagnostid Salution:By the 4 the th only in the case whenifalse and is te However thisee 7.which is false when g is true.Consequently.these four specifications are inconsistent. Boolean Searches Lovical conn ed extensively in searcheso Iinte he searches employ te onal isuch 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 metimes written as AND NOT)is use ed to exclude a particula rsearch term nning of how logical conne es are us n sea of potential nterest.Example6 strates how Boolean searches EXAMPLE 6 Web Page Se Most Web suppor Boolean searching techniques which an help finc pages about parncu ance,using Boole sear we can 1o paes matching NEV tain the thre ds NEW MEYICO will include o ag res 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 may be more
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. EXAMPLE 4 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.” 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 CREWADMENICO8R品AND UNIVERSITESN rc for D theANDoperator 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 se arch will include words NEW and MEXICO gamn,pages in Me g MEXICO AND UNIVI ges 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 v "In Google,the terms used for this Logic Puzzles Puzzles that can be solved using logical reasoning are known as logic puzzles.Solving logic way to practice working with the rules of logic.Also computer progra ing on use wer the Web. g logic puzzles.pu 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. EXAMPLE7 In [Sm78]Smullyan posed many puzzles about an island that has two kinds of inhabitants. a 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 nd be the sta nts that and B is a knight nd We first consider the a knight,then he is telling the truth when he says that B is a knight,so that g 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 state ment (pA-q)v(p A q),would h ave to be true,which it is not,because A nghts.Consequently,we can conclude that A is not a knight.t .the is fals t that B is Furthermore,if B is a knave,then B's statement that A and B are op posite 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 e of smully zzles about knights and knaves in Exercises 19-23 Ir ople,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
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