Docsity

discrete-mathematics, Summaries of Computer science

Toggle sidebar
bg1
60 1 / The Foundations: Logic and Proofs
55. What are the truth values of these statements?
a) +!xP(x)→+xP(x)
b) ∀xP(x)→+!xP(x)
c) +!x¬P(x)→¬∀xP(x)
56. Write out +!xP(x), where the domain consists of the inte-
gers 1, 2, and 3, in terms of negations, conjunctions, and
disjunctions.
57. Given the Prolog facts in Example 28, what wouldProlog
return given these queries?
a) ?instructor(chan,math273)
b) ?instructor(patel,cs301)
c) ?enrolled(X,cs301)
d) ?enrolled(kiko,Y)
e) ?teaches(grossman,Y)
58. Given the Prolog facts in Example 28, what wouldProlog
return when given these queries?
a) ?enrolled(kevin,ee222)
b) ?enrolled(kiko,math273)
c) ?instructor(grossman,X)
d) ?instructor(X,cs301)
e) ?teaches(X,kevin)
59. Suppose that Prolog facts are used to define the predicates
mother(M, Y)andfather(F, X ), which represent that Mis
the mother of Yand Fis the father of X, respectively.
Give a Prolog rule to define the predicate sibling(X, Y),
which represents that Xand Yare siblings (that is, have
the same mother and the same father).
60. Suppose that Prolog facts are used to define the pred-
icates mother(M, Y)andfather(F, X ), which represent
that Mis the mother of Yand Fis the father of X,re-
spectively. Give a Prolog rule to define the predicate
grandfath er(X, Y ), which represents that Xis the grand-
father of Y.[Hint: You ca n wr i te a d isj un cti on i n P ro lo g
either by using a semicolon to separate predicates or by
putting these predicates on separate lines.]
Exercises 61–64 are based on questions found in the book
Symbolic Logic by Lewis Car roll.
61. Let P(x), Q(x), and R(x) be the statements “xis a profes-
sor,”“xis ignorant,” and “xis vain,” respectively. Express
each of these statements using quantifiers; logical con-
nectives; and P(x), Q(x), and R(x), where the domain
consists of all people.
a) No professors are ignorant.
b) All ignorant people are vain.
c) No professors are vain.
d) Does (c) follow from (a) and (b)?
62. Let P(x), Q(x), and R(x) be the statements “xis a clear
explanation,” “xis satisfactory,” and “xis an excuse,”
respectively. Suppose that the domain for xconsists of
all English text. Express each of these statements us-
ing quantifiers, logical connectives, and P(x), Q(x), and
R(x).
a) All clear explanations are satisfactory.
b) Some excuses are unsatisfactory.
c) Some excuses are not clear explanations.
∗d) Does (c) follow from (a) and (b)?
63. Let P(x), Q(x), R(x), and S(x) be the statements “xis a
baby,” “xis logical,” “xis able to manage a crocodile,”
and “xis despised,” respectively. Suppose that the domain
consists of all people. Express each of these statements
using quantifiers; logical connectives; and P(x), Q(x),
R(x), and S(x).
a) Babies are illogical.
b) Nobody is despised who can manage a crocodile.
c) Illogical persons are despised.
d) Babies cannot manage crocodiles.
∗e) Does (d) follow from (a), (b), and (c)? If not, is there
a correct conclusion?
64. Let P(x), Q(x), R(x), and S(x) be the statements “xis a
duck,” “xis one of my poultry,” “xis an officer,” and “x
is willing to waltz,” respectively. Express each of these
statements using quantifiers; logical connectives; and
P(x), Q(x), R(x), and S(x).
a) No ducks are willing to waltz.
b) No officers ever decline to waltz.
c) All my poultry are ducks.
d) My poultry are not officers.
∗e) Does (d) follow from (a), (b), and (c)? If not, is there
a correct conclusion?
1.5 Nested Quantifiers
1.5.1 Introduction
In Section 1.4 we defined the existential and universal quantifiers and showed how they can be
used to represent mathematical statements. We also explained how they can be used to translate
English sentences into logical expressions. However, in Section 1.4 we avoided nested quanti-
fiers,whereonequantifieriswithinthescopeofanother,suchas
∀x+y(x+y=0).
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25

Partial preview of the text

Download discrete-mathematics and more Summaries Computer science in PDF only on Docsity!

60 1 / The Foundations: Logic and Proofs

55. What are the truth values of these statements? a) +! xP ( x ) → + xP ( x ) b) ∀ xP ( x ) → +! xP ( x ) c) +! x ¬ P ( x ) → ¬∀ xP ( x ) 56. Write out +! xP ( x ), where the domain consists of the inte- gers 1, 2, and 3, in terms of negations, conjunctions, and disjunctions. 57. Given the Prolog facts in Example 28, what would Prolog return given these queries? a) ?instructor(chan,math273) b) ?instructor(patel,cs301) c) ?enrolled(X,cs301) d) ?enrolled(kiko,Y) e) ?teaches(grossman,Y) 58. Given the Prolog facts in Example 28, what would Prolog return when given these queries? a) ?enrolled(kevin,ee222) b) ?enrolled(kiko,math273) c) ?instructor(grossman,X) d) ?instructor(X,cs301) e) ?teaches(X,kevin) 59. Suppose that Prolog facts are used to define the predicates mother ( M, Y ) and father ( F, X ), which represent that M is the mother of Y and F is the father of X , respectively. Give a Prolog rule to define the predicate sibling ( X, Y ), which represents that X and Y are siblings (that is, have the same mother and the same father). 60. Suppose that Prolog facts are used to define the pred- icates mother ( M, Y ) and father ( F, X ), which represent that M is the mother of Y and F is the father of X , re- spectively. Give a Prolog rule to define the predicate grandfather ( X, Y ), which represents that X is the grand- father of Y. [ Hint: You can write a disjunction in Prolog either by using a semicolon to separate predicates or by putting these predicates on separate lines.]

Exercises 61–64 are based on questions found in the book Symbolic Logic by Lewis Carroll.

61. Let P ( x ), Q ( x ), and R ( x ) be the statements “ x is a profes- sor,” “ x is ignorant,” and “ x is vain,” respectively. Express each of these statements using quantifiers; logical con- nectives; and P ( x ), Q ( x ), and R ( x ), where the domain consists of all people.

a) No professors are ignorant. b) All ignorant people are vain. c) No professors are vain. d) Does (c) follow from (a) and (b)?

62. Let P ( x ), Q ( x ), and R ( x ) be the statements “ x is a clear explanation,” “ x is satisfactory,” and “ x is an excuse,” respectively. Suppose that the domain for x consists of all English text. Express each of these statements us- ing quantifiers, logical connectives, and P ( x ), Q ( x ), and R ( x ). a) All clear explanations are satisfactory. b) Some excuses are unsatisfactory. c) Some excuses are not clear explanations. ∗ (^) d) Does (c) follow from (a) and (b)? 63. Let P ( x ), Q ( x ), R ( x ), and S ( x ) be the statements “ x is a baby,” “ x is logical,” “ x is able to manage a crocodile,” and “ x is despised,” respectively. Suppose that the domain consists of all people. Express each of these statements using quantifiers; logical connectives; and P ( x ), Q ( x ), R ( x ), and S ( x ). a) Babies are illogical. b) Nobody is despised who can manage a crocodile. c) Illogical persons are despised. d) Babies cannot manage crocodiles. ∗ (^) e) Does (d) follow from (a), (b), and (c)? If not, is there a correct conclusion? 64. Let P ( x ), Q ( x ), R ( x ), and S ( x ) be the statements “ x is a duck,” “ x is one of my poultry,” “ x is an officer,” and “ x is willing to waltz,” respectively. Express each of these statements using quantifiers; logical connectives; and P ( x ), Q ( x ), R ( x ), and S ( x ). a) No ducks are willing to waltz. b) No officers ever decline to waltz. c) All my poultry are ducks. d) My poultry are not officers. ∗ (^) e) Does (d) follow from (a), (b), and (c)? If not, is there a correct conclusion?

1.5 Nested Quantifiers

1.5.1 Introduction

In Section 1.4 we defined the existential and universal quantifiers and showed how they can be used to represent mathematical statements. We also explained how they can be used to translate English sentences into logical expressions. However, in Section 1.4 we avoided nested quanti- fiers , where one quantifier is within the scope of another, such as

∀ x + y ( x + y = 0).

1.5 Nested Quantifiers 61

Note that everything within the scope of a quantifier can be thought of as a propositional func- tion. For example,

∀ x + y ( x + y = 0)

is the same thing as ∀ xQ ( x ), where Q ( x ) is + yP ( x, y ), where P ( x, y ) is x + y = 0. Nested quantifiers commonly occur in mathematics and computer science. Although nested quantifiers can sometimes be difficult to understand, the rules we have already studied in Section 1.4 can help us use them. In this section we will gain experience working with nested quantifiers. We will see how to use nested quantifiers to express mathematical statements such as “The sum of two positive integers is always positive.” We will show how nested quantifiers can be used to translate English sentences such as “Everyone has exactly one best friend” into logical statements. Moreover, we will gain experience working with the negations of statements involving nested quantifiers.

1.5.2 Understanding Statements Involving Nested Quantifiers

To understand statements involving nested quantifiers, we need to unravel what the quantifiers and predicates that appear mean. This is illustrated in Examples 1 and 2.

EXAMPLE! Assume that the domain for the variables x and y consists of all real numbers. The statement

∀ x ∀ y ( x + y = y + x )

Extra^ says that^ x^ +^ y^ =^ y^ +^ x^ for all real numbers^ x^ and^ y. This is the commutative law for addition of Examples real numbers. Likewise, the statement

∀ x + y ( x + y = 0)

says that for every real number x there is a real number y such that x + y = 0. This states that every real number has an additive inverse. Similarly, the statement

∀ x ∀ y ∀ z ( x + ( y + z ) = ( x + y ) + z )

is the associative law for addition of real numbers. ◂

EXAMPLE " Translate into English the statement

∀ x ∀ y (( x > 0) ∧ ( y < 0) → ( xy < 0)) ,

where the domain for both variables consists of all real numbers.

Solution: This statement says that for every real number x and for every real number y , if x > 0 and y < 0, then xy < 0. That is, this statement says that for real numbers x and y , if x is positive and y is negative, then xy is negative. This can be stated more succinctly as “The product of a positive real number and a negative real number is always a negative real number.” ◂

THINKING OF QUANTIFICATION AS LOOPS In working with quantifications of more than one variable, it is sometimes helpful to think in terms of nested loops. (If there are infinitely many elements in the domain of some variable, we cannot actually loop through all values. Nevertheless, this way of thinking is helpful in understanding nested quantifiers.) For example, to see whether ∀ x ∀ yP ( x, y ) is true, we loop through the values for x , and for each x we loop through the values for y. If we find that for all values of x that P ( x, y ) is true for all values of y ,

1.5 Nested Quantifiers 63

The quantification

∀ x + yQ ( x, y )

denotes the proposition

“For every real number x there is a real number y such that Q ( x, y ).”

Given a real number x , there is a real number y such that x + y = 0; namely, y = − x. Hence, the statement ∀ x + yQ ( x, y ) is true. Be careful with the order of existential and universal quantifiers!

◂

Example 4 illustrates that the order in which quantifiers appear makes a di!erence. The statements + y ∀ xP ( x, y ) and ∀ x + yP ( x, y ) are not logically equivalent. The statement + y ∀ xP ( x, y ) is true if and only if there is a y that makes P ( x, y ) true for every x. So, for this statement to be true, there must be a particular value of y for which P ( x, y ) is true regardless of the choice of x. On the other hand, ∀ x + yP ( x, y ) is true if and only if for every value of x there is a value of y for which P ( x, y ) is true. So, for this statement to be true, no matter which x you choose, there must be a value of y (possibly depending on the x you choose) for which P ( x, y ) is true. In other words, in the second case, y can depend on x , whereas in the first case, y is a constant independent of x. From these observations, it follows that if + y ∀ xP ( x, y ) is true, then ∀ x + yP ( x, y ) must also be true. However, if ∀ x + yP ( x, y ) is true, it is not necessary for + y ∀ xP ( x, y ) to be true. (See Supplementary Exercises 30 and 31.) Table 1 summarizes the meanings of the di!erent possible quantifications involving two variables. Quantifications of more than two variables are also common, as Example 5 illustrates.

EXAMPLE % Let Q ( x, y, z ) be the statement “ x + y = z .” What are the truth values of the statements

∀ x ∀ y + zQ ( x, y, z ) and + z ∀ x ∀ yQ ( x, y, z ), where the domain of all variables consists of all real numbers?

Solution: Suppose that x and y are assigned values. Then, there exists a real number z such that x + y = z. Consequently, the quantification

∀ x ∀ y + zQ ( x, y, z ) ,

which is the statement

“For all real numbers x and for all real numbers y there is a real number z such that x + y = z ,”

TABLE! Quantifications of Two Variables.

Statement When True? When False?

∀ x ∀ yP ( x, y ) P ( x, y ) is true for every pair x, y. There is a pair x, y for ∀ y ∀ xP ( x, y ) which P ( x, y ) is false.

∀ x + yP ( x, y ) For every x there is a y for There is an x such that which P ( x, y ) is true. P ( x, y ) is false for every y.

  • x ∀ yP ( x, y ) There is an x for which P ( x, y ) For every x there is a y for is true for every y. which P ( x, y ) is false.

  • x + yP ( x, y ) There is a pair x, y for which P ( x, y ) is false for every

  • y + xP ( x, y ) P ( x, y ) is true. pair x, y.

64 1 / The Foundations: Logic and Proofs

is true. The order of the quantification here is important, because the quantification

  • z ∀ x ∀ yQ ( x, y, z ) ,

which is the statement

“There is a real number z such that for all real numbers x and for all real numbers y it is true that x + y = z ,”

is false, because there is no value of z that satisfies the equation x + y = z for all values of x and y. ◂

1.5.4 Translating Mathematical Statements into Statements

Involving Nested Quantifiers

Mathematical statements expressed in English can be translated into logical expressions, as Examples 6–8 show.

EXAMPLE & Translate the statement “The sum of two positive integers is always positive” into a logical

expression.

Solution: To translate this statement into a logical expression, we first rewrite it so that the implied quantifiers and a domain are shown: “For every two integers, if these integers are both positive, then the sum of these integers is positive.” Next, we introduce the variables x and y to obtain “For all positive integers x and y , x + y is positive.” Consequently, we can express this

Extra Examples

statement as

∀ x ∀ y (( x > 0) ∧ ( y > 0) → ( x + y > 0)) ,

where the domain for both variables consists of all integers. Note that we could also translate this using the positive integers as the domain. Then the statement “The sum of two positive integers is always positive” becomes “For every two positive integers, the sum of these integers is positive.” We can express this as

∀ x ∀ y ( x + y > 0) ,

where the domain for both variables consists of all positive integers. ◂

EXAMPLE ' Translate the statement “Every real number except zero has a multiplicative inverse.” (A mul-

tiplicative inverse of a real number x is a real number y such that xy = 1.)

Solution: We first rewrite this as “For every real number x except zero, x has a multiplicative inverse.” We can rewrite this as “For every real number x , if x ≠ 0, then there exists a real number y such that xy = 1.” This can be rewritten as

∀ x (( x ≠ 0) → + y ( xy = 1)). (^) ◂

One example that you may be familiar with is the concept of limit, which is important in calculus.

66 1 / The Foundations: Logic and Proofs

1.5.6 Translating English Sentences into Logical Expressions

In Section 1.4 we showed how quantifiers can be used to translate sentences into logical expres- sions. However, we avoided sentences whose translation into logical expressions required the use of nested quantifiers. We now address the translation of such sentences.

EXAMPLE !! Express the statement “If a person is female and is a parent, then this person is someone’s

mother” as a logical expression involving predicates, quantifiers with a domain consisting of all people, and logical connectives.

Solution: The statement “If a person is female and is a parent, then this person is someone’s mother” can be expressed as “For every person x , if person x is female and person x is a parent, then there exists a person y such that person x is the mother of person y .” We introduce the propositional functions F ( x ) to represent “ x is female,” P ( x ) to represent “ x is a parent,” and M ( x, y ) to represent “ x is the mother of y .” The original statement can be represented as

∀ x (( F ( x ) ∧ P ( x )) → + yM ( x, y )).

Using the null quantification rule in part (b) of Exercise 49 in Section 1.4, we can move + y to the left so that it appears just after ∀ x , because y does not appear in F ( x ) ∧ P ( x ). We obtain the logically equivalent expression

∀ x + y (( F ( x ) ∧ P ( x )) → M ( x, y )). ◂

EXAMPLE !" Express the statement “Everyone has exactly one best friend” as a logical expression involving

predicates, quantifiers with a domain consisting of all people, and logical connectives.

Solution: The statement “Everyone has exactly one best friend” can be expressed as “For every person x , person x has exactly one best friend.” Introducing the universal quantifier, we see that this statement is the same as “∀ x (person x has exactly one best friend),” where the domain consists of all people. To say that x has exactly one best friend means that there is a person y who is the best friend of x , and furthermore, that for every person z , if person z is not person y , then z is not the best friend of x. When we introduce the predicate B ( x, y ) to be the statement “ y is the best friend of x ,” the statement that x has exactly one best friend can be represented as

  • y ( B ( x, y ) ∧ ∀ z (( z ≠ y ) → ¬ B ( x, z ))).

Consequently, our original statement can be expressed as

∀ x + y ( B ( x, y ) ∧ ∀ z (( z ≠ y ) → ¬ B ( x, z ))).

[Note that we can write this statement as ∀ x +! yB ( x, y ), where +! is the “uniqueness quantifier” defined in Section 1.4.] ◂

EXAMPLE !# Use quantifiers to express the statement “There is a woman who has taken a flight on every

airline in the world.”

Solution: Let P ( w, f ) be “ w has taken f ” and Q ( f, a ) be “ f is a flight on a .” We can express the statement as

  • w ∀ a + f ( P ( w, f ) ∧ Q ( f, a )) ,

1.5 Nested Quantifiers 67

where the domains of discourse for w, f , and a consist of all the women in the world, all airplane flights, and all airlines, respectively. The statement could also be expressed as

  • w ∀ a + fR ( w, f, a ) ,

where R ( w, f, a ) is “ w has taken f on a .” Although this is more compact, it somewhat obscures the relationships among the variables. Consequently, the first solution is usually preferable. ◂

1.5.7 Negating Nested Quantifiers

Statements involving nested quantifiers can be negated by successively applying the rules for Assessment negating statements involving a single quantifier. This is illustrated in Examples 14–16.

EXAMPLE !$ Express the negation of the statement ∀ x + y ( xy = 1) so that no negation precedes a quantifier.

Solution: By successively applying De Morgan’s laws for quantifiers in Table 2 of Section 1.4, we can move the negation in ¬∀ x + y ( xy = 1) inside all the quantifiers. We find that

Extra Examples

¬∀ x + y ( xy = 1) is equivalent to + x ¬+ y ( xy = 1), which is equivalent to + x ∀ y ¬( xy = 1). Because ¬( xy = 1) can be expressed more simply as xy ≠ 1, we conclude that our negated statement can be expressed as + x ∀ y ( xy ≠ 1). ◂

EXAMPLE !% Use quantifiers to express the statement that “There does not exist a woman who has taken a

flight on every airline in the world.”

Solution: This statement is the negation of the statement “There is a woman who has taken a flight on every airline in the world” from Example 13. By Example 13, our statement can be expressed as ¬+ w ∀ a + f ( P ( w, f ) ∧ Q ( f, a )), where P ( w, f ) is “ w has taken f ” and Q ( f, a ) is “ f is a flight on a .” By successively applying De Morgan’s laws for quantifiers in Table 2 of Section 1.4 to move the negation inside successive quantifiers and by applying De Morgan’s law for negating a conjunction in the last step, we find that our statement is equivalent to each of this sequence of statements:

∀ w ¬∀ a + f ( P ( w, f ) ∧ Q ( f, a )) ≡ ∀ w + a ¬+ f ( P ( w, f ) ∧ Q ( f, a ))

≡ ∀ w + a ∀ f ¬( P ( w, f ) ∧ Q ( f, a ))

≡ ∀ w + a ∀ f (¬ P ( w, f ) ∨ ¬ Q ( f, a )).

This last statement states “For every woman there is an airline such that for all flights, this woman has not taken that flight or that flight is not on this airline.” ◂

EXAMPLE !& ( Requires calculus ) Use quantifiers and predicates to express the fact that lim x → a f ( x ) does not

exist where f ( x ) is a real-valued function of a real variable x and a belongs to the domain of f.

Solution: To say that lim x → a f ( x ) does not exist means that for all real numbers L , lim x → a f ( x ) ≠ L. By using Example 8, the statement lim x → a f ( x ) ≠ L can be expressed as

¬∀ 𝜖 > 0 + 𝛿 > 0 ∀ x (0 < ' x − a ' < 𝛿 → ' f ( x ) − L ' < 𝜖 ).

1.5 Nested Quantifiers 69

b) + xT ( x , Korean) ∧ ∀ xT ( x, Mexican) c) + y ( T (Monique Arsenault, y ) ∨ T (Jay Johnson, y )) d) ∀ x ∀ z + y (( x ≠ z ) → ¬( T ( x, y ) ∧ T ( z, y ))) e) + x + z ∀ y ( T ( x, y ) ↔ T ( z, y )) f ) ∀ x ∀ z + y ( T ( x, y ) ↔ T ( z, y ))

8. Let Q ( x, y ) be the statement “Student x has been a con- testant on quiz show y .” Express each of these sentences in terms of Q ( x, y ), quantifiers, and logical connectives, where the domain for x consists of all students at your school and for y consists of all quiz shows on televi- sion. a) There is a student at your school who has been a con- testant on a television quiz show. b) No student at your school has ever been a contestant on a television quiz show. c) There is a student at your school who has been a con- testant on Jeopardy! and on Wheel of Fortune. d) Every television quiz show has had a student from your school as a contestant. e) At least two students from your school have been con- testants on Jeopardy!. 9. Let L ( x, y ) be the statement “ x loves y ,” where the domain for both x and y consists of all people in the world. Use quantifiers to express each of these statements. a) Everybody loves Jerry. b) Everybody loves somebody. c) There is somebody whom everybody loves. d) Nobody loves everybody. e) There is somebody whom Lydia does not love. f ) There is somebody whom no one loves. g) There is exactly one person whom everybody loves. h) There are exactly two people whom Lynn loves. i) Everyone loves himself or herself. j) There is someone who loves no one besides himself or herself. 10. Let F ( x, y ) be the statement “ x can fool y ,” where the do- main consists of all people in the world. Use quantifiers to express each of these statements. a) Everybody can fool Fred. b) Evelyn can fool everybody. c) Everybody can fool somebody. d) There is no one who can fool everybody. e) Everyone can be fooled by somebody. f ) No one can fool both Fred and Jerry. g) Nancy can fool exactly two people. h) There is exactly one person whom everybody can fool. i) No one can fool himself or herself. j) There is someone who can fool exactly one person besides himself or herself. 11. Let S ( x ) be the predicate “ x is a student,” F ( x ) the pred- icate “ x is a faculty member,” and A ( x, y ) the predicate “ x has asked y a question,” where the domain consists of all people associated with your school. Use quantifiers to express each of these statements. a) Lois has asked Professor Michaels a question. b) Every student has asked Professor Gross a question.

c) Every faculty member has either asked Professor Miller a question or been asked a question by Pro- fessor Miller. d) Some student has not asked any faculty member a question. e) There is a faculty member who has never been asked a question by a student. f ) Some student has asked every faculty member a ques- tion. g) There is a faculty member who has asked every other faculty member a question. h) Some student has never been asked a question by a faculty member.

12. Let I ( x ) be the statement “ x has an Internet connection” and C ( x, y ) be the statement “ x and y have chatted over the Internet,” where the domain for the variables x and y consists of all students in your class. Use quantifiers to express each of these statements. a) Jerry does not have an Internet connection. b) Rachel has not chatted over the Internet with Chelsea. c) Jan and Sharon have never chatted over the Internet. d) No one in the class has chatted with Bob. e) Sanjay has chatted with everyone except Joseph. f ) Someone in your class does not have an Internet con- nection. g) Not everyone in your class has an Internet connec- tion. h) Exactly one student in your class has an Internet con- nection. i) Everyone except one student in your class has an In- ternet connection. j) Everyone in your class with an Internet connection has chatted over the Internet with at least one other student in your class. k) Someone in your class has an Internet connection but has not chatted with anyone else in your class. l) There are two students in your class who have not chatted with each other over the Internet. m) There is a student in your class who has chatted with everyone in your class over the Internet. n) There are at least two students in your class who have not chatted with the same person in your class. o) There are two students in the class who between them have chatted with everyone else in the class. 13. Let M ( x, y ) be “ x has sent y an e-mail message” and T ( x, y ) be “ x has telephoned y ,” where the domain con- sists of all students in your class. Use quantifiers to ex- press each of these statements. (Assume that all e-mail messages that were sent are received, which is not the way things often work.) a) Chou has never sent an e-mail message to Koko. b) Arlene has never sent an e-mail message to or tele- phoned Sarah. c) Jose has never received an e-mail message from Deb-´ orah. d) Every student in your class has sent an e-mail mes- sage to Ken. e) No one in your class has telephoned Nina.

70 1 / The Foundations: Logic and Proofs

f ) Everyone in your class has either telephoned Avi or sent him an e-mail message. g) There is a student in your class who has sent every- one else in your class an e-mail message. h) There is someone in your class who has either sent an e-mail message or telephoned everyone else in your class. i) There are two di!erent students in your class who have sent each other e-mail messages. j) There is a student who has sent himself or herself an e-mail message. k) There is a student in your class who has not received an e-mail message from anyone else in the class and who has not been called by any other student in the class. l) Every student in the class has either received an e- mail message or received a telephone call from an- other student in the class. m) There are at least two students in your class such that one student has sent the other e-mail and the second student has telephoned the first student. n) There are two di!erent students in your class who between them have sent an e-mail message to or tele- phoned everyone else in the class.

14. Use quantifiers and predicates with more than one vari- able to express these statements. a) There is a student in this class who can speak Hindi. b) Every student in this class plays some sport. c) Some student in this class has visited Alaska but has not visited Hawaii. d) All students in this class have learned at least one pro- gramming language. e) There is a student in this class who has taken ev- ery course o!ered by one of the departments in this school. f ) Some student in this class grew up in the same town as exactly one other student in this class. g) Every student in this class has chatted with at least one other student in at least one chat group. 15. Use quantifiers and predicates with more than one vari- able to express these statements. a) Every computer science student needs a course in dis- crete mathematics. b) There is a student in this class who owns a personal computer. c) Every student in this class has taken at least one com- puter science course. d) There is a student in this class who has taken at least one course in computer science. e) Every student in this class has been in every building on campus. f ) There is a student in this class who has been in every room of at least one building on campus. g) Every student in this class has been in at least one room of every building on campus. 16. A discrete mathematics class contains 1 mathematics major who is a freshman, 12 mathematics majors who are sophomores, 15 computer science majors who are sophomores, 2 mathematics majors who are juniors, 2 computer science majors who are juniors, and 1 computer science major who is a senior. Express each of these state- ments in terms of quantifiers and then determine its truth value. a) There is a student in the class who is a junior. b) Every student in the class is a computer science ma- jor. c) There is a student in the class who is neither a math- ematics major nor a junior. d) Every student in the class is either a sophomore or a computer science major. e) There is a major such that there is a student in the class in every year of study with that major. 17. Express each of these system specifications using pred- icates, quantifiers, and logical connectives, if neces- sary. a) Every user has access to exactly one mailbox. b) There is a process that continues to run during all er- ror conditions only if the kernel is working correctly. c) All users on the campus network can access all web- sites whose url has a .edu extension. ∗ (^) d) There are exactly two systems that monitor every re- mote server. 18. Express each of these system specifications using pred- icates, quantifiers, and logical connectives, if neces- sary. a) At least one console must be accessible during every fault condition. b) The e-mail address of every user can be retrieved whenever the archive contains at least one message sent by every user on the system. c) For every security breach there is at least one mecha- nism that can detect that breach if and only if there is a process that has not been compromised. d) There are at least two paths connecting every two dis- tinct endpoints on the network. e) No one knows the password of every user on the sys- tem except for the system administrator, who knows all passwords. 19. Express each of these statements using mathematical and logical operators, predicates, and quantifiers, where the domain consists of all integers. a) The sum of two negative integers is negative. b) The di!erence of two positive integers is not neces- sarily positive. c) The sum of the squares of two integers is greater than or equal to the square of their sum. d) The absolute value of the product of two integers is the product of their absolute values. 20. Express each of these statements using predicates, quan- tifiers, logical connectives, and mathematical operators where the domain consists of all integers. a) The product of two negative integers is positive. b) The average of two positive integers is positive.

72 1 / The Foundations: Logic and Proofs

c) No student in this class has sent e-mail to exactly two other students in this class. d) Some student has solved every exercise in this book. e) No student has solved at least one exercise in every section of this book.

37. Express each of these statements using quantifiers. Then form the negation of the statement so that no negation is to the left of a quantifier. Next, express the negation in simple English. (Do not simply use the phrase “It is not the case that.”) a) Every student in this class has taken exactly two math- ematics classes at this school. b) Someone has visited every country in the world ex- cept Libya. c) No one has climbed every mountain in the Himalayas. d) Every movie actor has either been in a movie with Kevin Bacon or has been in a movie with someone who has been in a movie with Kevin Bacon. 38. Express the negations of these propositions using quan- tifiers, and in English. a) Every student in this class likes mathematics. b) There is a student in this class who has never seen a computer. c) There is a student in this class who has taken every mathematics course o!ered at this school. d) There is a student in this class who has been in at least one room of every building on campus. 39. Find a counterexample, if possible, to these universally quantified statements, where the domain for all variables consists of all integers. a) ∀ x ∀ y ( x^2 = y^2 → x = y ) b) ∀ x + y ( y^2 = x ) c) ∀ x ∀ y ( xy ≥ x ) 40. Find a counterexample, if possible, to these universally quantified statements, where the domain for all variables consists of all integers. a) ∀ x + y ( x = 1! y ) b) ∀ x + y ( y^2 − x < 100) c) ∀ x ∀ y ( x^2 ≠ y^3 ) 41. Use quantifiers to express the associative law for multi- plication of real numbers. 42. Use quantifiers to express the distributive laws of multi- plication over addition for real numbers. 43. Use quantifiers and logical connectives to express the fact that every linear polynomial (that is, polynomial of de- gree 1) with real coefficients and where the coefficient of x is nonzero, has exactly one real root. 44. Use quantifiers and logical connectives to express the fact that a quadratic polynomial with real number coefficients has at most two real roots. 45. Determine the truth value of the statement ∀ x + y ( xy = 1) if the domain for the variables consists of

a) the nonzero real numbers. b) the nonzero integers. c) the positive real numbers.

46. Determine the truth value of the statement + x ∀ y ( x ≤ y^2 ) if the domain for the variables consists of a) the positive real numbers. b) the integers. c) the nonzero real numbers. 47. Show that the two statements ¬+ x ∀ yP ( x, y ) and ∀ x + y ¬ P ( x, y ), where both quantifiers over the first vari- able in P ( x, y ) have the same domain, and both quantifiers over the second variable in P ( x, y ) have the same domain, are logically equivalent. ∗ (^) 48. Show that ∀ xP ( x ) ∨ ∀ xQ ( x ) and ∀ x ∀ y ( P ( x ) ∨ Q ( y )), where all quantifiers have the same nonempty domain, are logically equivalent. (The new variable y is used to combine the quantifications correctly.) ∗ (^) 49. a) Show that ∀ xP ( x ) ∧ + xQ ( x ) is logically equivalent to ∀ x + y ( P ( x ) ∧ Q ( y )), where all quantifiers have the same nonempty domain. b) Show that ∀ xP ( x ) ∨ + xQ ( x ) is equivalent to ∀ x + y ( P ( x ) ∨ Q ( y )), where all quantifiers have the same nonempty domain. A statement is in prenex normal form (PNF) if and only if it is of the form

Q 1 x 1 Q 2 x 2 ⋯ QkxkP ( x 1 , x 2 , … , xk ) ,

where each Qi, i = 1 , 2 , … , k , is either the existential quanti- fier or the universal quantifier, and P ( x 1 , … , xk ) is a predicate involving no quantifiers. For example, + x ∀ y ( P ( x, y ) ∧ Q ( y )) is in prenex normal form, whereas + xP ( x ) ∨ ∀ xQ ( x ) is not (be- cause the quantifiers do not all occur first). Every statement formed from propositional variables, predicates, T , and F using logical connectives and quanti- fiers is equivalent to a statement in prenex normal form. Exercise 51 asks for a proof of this fact. ∗ (^) 50. Put these statements in prenex normal form. [ Hint: Use logical equivalence from Tables 6 and 7 in Section 1.3, Table 2 in Section 1.4, Example 19 in Section 1.4, Exercises 47 and 48 in Section 1.4, and Exercises 48 and 49.] a) + xP ( x ) ∨ + xQ ( x ) ∨ A , where A is a proposition not in- volving any quantifiers b) ¬(∀ xP ( x ) ∨ ∀ xQ ( x )) c) + xP ( x ) → + xQ ( x ) ∗∗ (^) 51. Show how to transform an arbitrary statement to a state- ment in prenex normal form that is equivalent to the given statement. (Note: A formal solution of this exercise re- quires use of structural induction, covered in Section 5.3.) ∗ (^) 52. Express the quantification +! xP ( x ), introduced in Sec- tion 1.4, using universal quantifications, existential quan- tifications, and logical operators.

1.6 Rules of Inference 73

1.6 Rules of Inference

1.6.1 Introduction

Later in this chapter we will study proofs. Proofs in mathematics are valid arguments that estab- lish the truth of mathematical statements. By an argument , we mean a sequence of statements that end with a conclusion. By valid , we mean that the conclusion, or final statement of the ar- gument, must follow from the truth of the preceding statements, or premises , of the argument. That is, an argument is valid if and only if it is impossible for all the premises to be true and the conclusion to be false. To deduce new statements from statements we already have, we use rules of inference which are templates for constructing valid arguments. Rules of inference are our basic tools for establishing the truth of statements. Before we study mathematical proofs, we will look at arguments that involve only com- pound propositions. We will define what it means for an argument involving compound propo- sitions to be valid. Then we will introduce a collection of rules of inference in propositional logic. These rules of inference are among the most important ingredients in producing valid arguments. After we illustrate how rules of inference are used to produce valid arguments, we will describe some common forms of incorrect reasoning, called fallacies , which lead to invalid arguments. After studying rules of inference in propositional logic, we will introduce rules of infer- ence for quantified statements. We will describe how these rules of inference can be used to produce valid arguments. These rules of inference for statements involving existential and universal quantifiers play an important role in proofs in computer science and mathematics, although they are often used without being explicitly mentioned. Finally, we will show how rules of inference for propositions and for quantified statements can be combined. These combinations of rule of inference are often used together in complicated arguments.

1.6.2 Valid Arguments in Propositional Logic

Consider the following argument involving propositions (which, by definition, is a sequence of propositions):

“If you have a current password, then you can log onto the network.”

“You have a current password.”

Therefore,

“You can log onto the network.”

We would like to determine whether this is a valid argument. That is, we would like to de- termine whether the conclusion “You can log onto the network” must be true when the premises “If you have a current password, then you can log onto the network” and “You have a current password” are both true. Before we discuss the validity of this particular argument, we will look at its form. Use p to represent “You have a current password” and q to represent “You can log onto the network.” Then, the argument has the form

p → q p ∴ q

where ∴ is the symbol that denotes “therefore.”

1.6 Rules of Inference 75

validity of some relatively simple argument forms, called rules of inference. These rules of inference can be used as building blocks to construct more complicated valid argument forms. We will now introduce the most important rules of inference in propositional logic. The tautology ( p ∧ ( p → q )) → q is the basis of the rule of inference called modus ponens , or the law of detachment. (Modus ponens is Latin for mode that a!rms .) This tautology leads to the following valid argument form, which we have already seen in our initial discussion about arguments (where, as before, the symbol ∴ denotes “therefore”):

p p → q ∴ q

Using this notation, the hypotheses are written in a column, followed by a horizontal bar, fol- lowed by a line that begins with the therefore symbol and ends with the conclusion. In particular, modus ponens tells us that if a conditional statement and the hypothesis of this conditional state- ment are both true, then the conclusion must also be true. Example 1 illustrates the use of modus ponens.

EXAMPLE! Suppose that the conditional statement “If it snows today, then we will go skiing” and its hy-

pothesis, “It is snowing today,” are true. Then, by modus ponens, it follows that the conclusion of the conditional statement, “We will go skiing,” is true. ◂

As we mentioned earlier, a valid argument can lead to an incorrect conclusion if one or more of its premises is false. We illustrate this again in Example 2.

EXAMPLE " Determine whether the argument given here is valid and determine whether its conclusion must

be true because of the validity of the argument.

“If

3 2 , then

3 2

. We know that

3 2

. Consequently, $√ 2

3 2

9 4

Solution: Let p be the proposition “

3 2 ” and q the proposition “2 > ( 3 2 )^2 .” The premises of the argument are p → q and p , and q is its conclusion. This argument is valid because it is constructed by using modus ponens, a valid argument form. However, one of its premises, √ 2 > 3 2 , is false. Consequently, we cannot conclude that the conclusion is true. Furthermore,

note that the conclusion of this argument is false, because 2 < 9 4

. (^) ◂

There are many useful rules of inference for propositional logic. Perhaps the most widely used of these are listed in Table 1. Exercises 13–16, 25, 33, and 34 in Section 1.3 ask for the verifications that these rules of inference are valid argument forms. We now give examples of arguments that use these rules of inference. In each argument, we first use propositional variables to express the propositions in the argument. We then show that the resulting argument form is a rule of inference from Table 1.

EXAMPLE # State which rule of inference is the basis of the following argument: “It is below freezing now.

Therefore, it is below freezing or raining now.”

Solution: Let p be the proposition “It is below freezing now,” and let q be the proposition “It is raining now.” Then this argument is of the form

p ∴ p ∨ q

76 1 / The Foundations: Logic and Proofs

TABLE! Rules of Inference.

Rule of Inference Tautology Name

p p → q ∴ q

( p ∧ ( p → q )) → q Modus ponens

¬ q p → q ∴ ¬ p

(¬ q ∧ ( p → q )) → ¬ p Modus tollens

p → q q → r ∴ p → r

(( p → q ) ∧ ( q → r )) → ( p → r ) Hypothetical syllogism

p ∨ q ¬ p ∴ q

(( p ∨ q ) ∧ ¬ p ) → q Disjunctive syllogism

p ∴ p ∨ q

p → ( p ∨ q ) Addition

p ∧ q ∴ p

( p ∧ q ) → p Simplification

p q ∴ p ∧ q

(( p ) ∧ ( q )) → ( p ∧ q ) Conjunction

p ∨ q ¬ p ∨ r ∴ q ∨ r

(( p ∨ q ) ∧ (¬ p ∨ r )) → ( q ∨ r ) Resolution

This is an argument that uses the addition rule. ◂

EXAMPLE $ State which rule of inference is the basis of the following argument: “It is below freezing and

raining now. Therefore, it is below freezing now.”

Solution: Let p be the proposition “It is below freezing now,” and let q be the proposition “It is raining now.” This argument is of the form

p ∧ q ∴ p

This argument uses the simplification rule. ◂

EXAMPLE % State which rule of inference is used in the argument:

If it rains today, then we will not have a barbecue today. If we do not have a barbecue today, then we will have a barbecue tomorrow. Therefore, if it rains today, then we will have a barbecue tomorrow.

78 1 / The Foundations: Logic and Proofs

will wake up feeling refreshed.” Then the premises are p → q , ¬ p → r , and r → s. The desired conclusion is ¬ q → s. We need to give a valid argument with premises p → q , ¬ p → r , and r → s and conclusion ¬ q → s. This argument form shows that the premises lead to the desired conclusion.

Step Reason

  1. p → q Premise
  2. ¬ q → ¬ p Contrapositive of (1)
  3. ¬ p → r Premise
  4. ¬ q → r Hypothetical syllogism using (2) and (3)
  5. r → s Premise
  6. ¬ q → s Hypothetical syllogism using (4) and (5) ◂

1.6.5 Resolution

Computer programs have been developed to automate the task of reasoning and proving theo- rems. Many of these programs make use of a rule of inference known as resolution. This rule of inference is based on the tautology Links

(( p! q ) ∧ (¬ p! r )) → ( q! r ).

(Exercise 34 in Section 1.3 asks for the verification that this is a tautology.) The final disjunction in the resolution rule, q! r , is called the resolvent. When we let q = r in this tautology, we obtain ( p! q ) ∧ (¬ p! q ) → q. Furthermore, when we let r = F , we obtain ( p! q ) ∧ (¬ p ) → q (because q! F ≡ q ), which is the tautology on which the rule of disjunctive syllogism is based.

EXAMPLE! Use resolution to show that the hypotheses “Jasmine is skiing or it is not snowing” and “It is

snowing or Bart is playing hockey” imply that “Jasmine is skiing or Bart is playing hockey.”

Solution: Let p be the proposition “It is snowing,” q the proposition “Jasmine is skiing,” and r the proposition “Bart is playing hockey.” We can represent the hypotheses as ¬ p! q and p!

Extra Examples

r , respectively. Using resolution, the proposition q! r , “Jasmine is skiing or Bart is playing hockey,” follows. ◂

Resolution plays an important role in programming languages based on the rules of logic, such as Prolog (where resolution rules for quantified statements are applied). Furthermore, it can be used to build automatic theorem proving systems. To construct proofs in propositional logic using resolution as the only rule of inference, the hypotheses and the conclusion must be expressed as clauses , where a clause is a disjunction of variables or negations of these variables. We can replace a statement in propositional logic that is not a clause by one or more equivalent statements that are clauses. For example, suppose we have a statement of the form p! ( q ∧ r ). Because p! ( q ∧ r ) ≡ ( p! q ) ∧ ( p! r ), we can replace the single statement p! ( q ∧ r ) by two statements p! q and p! r , each of which is a clause. We can replace a statement of the form ¬( p! q ) by the two statements ¬ p and ¬ q because De Morgan’s law tells us that ¬( p! q ) ≡ ¬ p ∧ ¬ q. We can also replace a conditional statement p → q with the equivalent disjunction ¬ p! q.

EXAMPLE " Show that the premises ( p ∧ q )! r and r → s imply the conclusion p! s.

Solution: We can rewrite the premises ( p ∧ q )! r as two clauses, p! r and q! r. We can also replace r → s by the equivalent clause ¬ r! s. Using the two clauses p! r and ¬ r! s , we can use resolution to conclude p! s. ◂

1.6 Rules of Inference 79

1.6.6 Fallacies

Several common fallacies arise in incorrect arguments. These fallacies resemble rules of infer- ence, but are based on contingencies rather than tautologies. These are discussed here to show the distinction between correct and incorrect reasoning. The proposition (( p → q ) ∧ q ) → p is not a tautology, because it is false when p is false and q is true. However, there are many incorrect arguments that treat this as a tautology. In other Links words, they treat the argument with premises p → q and q and conclusion p as a valid argument form, which it is not. This type of incorrect reasoning is called the fallacy of affirming the conclusion.

EXAMPLE #$ Is the following argument valid?

If you do every problem in this book, then you will learn discrete mathematics. You learned discrete mathematics.

Therefore, you did every problem in this book.

Solution: Let p be the proposition “You did every problem in this book.” Let q be the proposition “You learned discrete mathematics.” Then this argument is of the form: if p → q and q , then p. This is an example of an incorrect argument using the fallacy of a!rming the conclusion. Indeed, it is possible for you to learn discrete mathematics in some way other than by doing every problem in this book. (You may learn discrete mathematics by reading, listening to lectures, doing some, but not all, the problems in this book, and so on.) ◂

The proposition (( p → q ) ∧ ¬ p ) → ¬ q is not a tautology, because it is false when p is false and q is true. Many incorrect arguments use this incorrectly as a rule of inference. This type of incorrect reasoning is called the fallacy of denying the hypothesis.

EXAMPLE ## Let p and q be as in Example 10. If the conditional statement p → q is true, and ¬ p is true, is it

correct to conclude that ¬ q is true? In other words, is it correct to assume that you did not learn discrete mathematics if you did not do every problem in the book, assuming that if you do every problem in this book, then you will learn discrete mathematics?

Solution: It is possible that you learned discrete mathematics even if you did not do every prob- lem in this book. This incorrect argument is of the form p → q and ¬ p imply ¬ q , which is an example of the fallacy of denying the hypothesis. ◂

1.6.7 Rules of Inference for Quantified Statements

We have discussed rules of inference for propositions. We will now describe some important rules of inference for statements involving quantifiers. These rules of inference are used exten- sively in mathematical arguments, often without being explicitly mentioned. Universal instantiation is the rule of inference used to conclude that P ( c ) is true, where c is a particular member of the domain, given the premise ∀ xP ( x ). Universal instantiation is used when we conclude from the statement “All women are wise” that “Lisa is wise,” where Lisa is a member of the domain of all women. Universal generalization is the rule of inference that states that ∀ xP ( x ) is true, given the premise that P ( c ) is true for all elements c in the domain. Universal generalization is used when we show that ∀ xP ( x ) is true by taking an arbitrary element c from the domain and showing that P ( c ) is true. The element c that we select must be an arbitrary, and not a specific, element of the domain. That is, when we assert from ∀ xP ( x ) the existence of an element c in the domain,