36
Arithmetic, Logic and Numbers With and Introduction to Cryptography Unit Lo: Logic Edward A. Bender S. Gill Williamson c Edward A. Bender & S. Gill Williamson 2010. All rights reserved.

Arithmetic, Logic and Numbers

Embed Size (px)

Citation preview

Page 1: Arithmetic, Logic and Numbers

Arithmetic, Logic and Numbers

With and Introduction to Cryptography

Unit Lo: Logic

Edward A. Bender

S. Gill Williamson

c©Edward A. Bender & S. Gill Williamson 2010. All rights reserved.

Page 2: Arithmetic, Logic and Numbers
Page 3: Arithmetic, Logic and Numbers

Preface

The material in this unit of study was, over several years, presented by the authors to lowerdivision undergraduates in the Department of Mathematics and the Department of ComputerScience and Engineering at the University of California, San Diego (UCSD). All material hasbeen classroom tested by the authors and other faculty members at UCSD.

The first course of a two quarter sequence was chosen from six units of study: Boolean Func-tions (Unit BF), Logic (Unit Lo), Number Theory and Cryptography (Unit NT), Setsand Functions (Unit SF), and Equivalence and Order (Unit EO), and Induction, Se-quences and Series (Unit IS).

The second course of the sequence was chosen from four units of study: Counting and Listing(Unit CL), Functions (Unit Fn), Decision Trees and Recursion (Unit DT), and BasicConcepts in Graph Theory (Unit GT).

The order of presentation of units within the first six, as well as those within the second four,can be varied for students with a good high school background in mathematics.

Discrete mathematics has become an essential tool in computer science, economics, biology,mathematics, chemistry, and engineering. Each area introduces its own special terms for sharedconcepts in discrete mathematics. The only way to keep from reinventing the wheel from areato area is to know the precise mathematical ideas behind the concepts being applied by thesevarious fields. Our course material is dedicated to this task.

At the end of each unit is a section of multiple choice questions: Multiple Choice Questionsfor Review. These questions should be read before reading the corresponding unit, and theyshould be referred to frequently as the units are read. We encouraged our students to be able towork these multiple choice questions and variations on them with ease and understanding. Atthe end of each section of the units are exercises that are suitable for written homework, exams,or class discussion.

iii

Page 4: Arithmetic, Logic and Numbers

iv

Page 5: Arithmetic, Logic and Numbers

Table of Contents

Unit Lo: Logic

Section 1: Propositional Logic.......................................................................Lo-1truth table, statement forms, tautology, contradiction, implication, conditional, contrapos-itive, double implication, biconditional, converse, inverse, if, only if, sufficient, necessary,unless

Section 2: Predicate Logic........................................................................... Lo-12predicate, truth set, prime, composite, Fermat number, Mersenne number, perfect numbers,Goldbach conjecture, Fermat’s Last Theorem, Marin Mersenne (1588–1648), Pierre de Fermat(1601–1665), Christian Goldbach (1690–1764), Leonhard Euler (1707–1783), Karl FriedrichGauss (1777–1855)

Multiple Choice Questions for Review ........................................................ Lo-23

Notation Index ....................................................................................Lo-Index 1

Subject Index ......................................................................................Lo-Index 3

A star in the text (*) indicates more difficult and/or specialized material.

v

Page 6: Arithmetic, Logic and Numbers

vi

Page 7: Arithmetic, Logic and Numbers

Unit Lo

Logic

Logic is the tool for reasoning about the truth and falsity of statements. There are twomain directions in which logic develops.

• The first is the depth to which we explore the structure of statements. The study ofthe basic level of structure is called propositional logic. First order predicate logic,which is often called just predicate logic, studies structure on a deeper level.

• The second direction is the nature of truth. For example, one may talk about state-ments that are usually true or true at certain times. We study only the simplestsituation: a statement is either always true or it is considered false.

“True” and “false” could be replaced by 1 and 0 (or any other two symbols) in our discus-sions. Using 1 and 0 relates logic to Boolean functions. In fact, propositional logic is thestudy of Boolean functions, where 1 plays the role of “true” and 0 the role of “false.” As wesaw in Unit BF, Boolean functions can be thought of as computer circuits. Thus, proposi-tional logic, Boolean functions, and computer circuits are different ways of interpreting thesame thing.

Propositional logic is not sufficient for all our logic needs. Mathematics requires pred-icate logic. This and other logics are employed in the design of expert systems, robots andartificial intelligence.

Section 1: Propositional Logic

If it is not fresh in your mind, you should review the material in the first section of UnitBF (Boolean Functions). In that section we were wearing our “arithmetic hat.” Now weare wearing our “logic hat” and so refer to things differently:

Arithmetic Hat Logic Hat

0 and 1, respectively false and true, respectivelyBoolean variable statement variableform of function statement formvalue of function truth value of statement (form)

equality of function (forms) equivalence of statement forms

We should explain some of these terms a bit more.

• In English, statement variables have structure— verbs, subjects, prepositional phrases,and so on. In propositional logic, we don’t see the structure. You’re used to thatbecause variables in high school algebra don’t have any structure; they just stand for(unknown) numbers.

Lo-1

Page 8: Arithmetic, Logic and Numbers

Logic

• A function can be written in many ways. For example, xy + x, x + yx, x(y + 1) and(x + z)y + x − yz are all ways of writing the same function. Logicians refer to theparticular way a function is written as a statement form.

You may wonder why we’re concerned with statement forms since we’re not concernedwith function forms in other areas of mathematics but just their values. That is a miscon-ception. We are concerned with function forms in algebra. It’s just that you’re so usedto the equality of different forms that you’ve forgotten that. Knowing that certain formsrepresent the same function allow us to manipulate formulas. For example, the commu-tative (ab = ba and a + b = b + a) and distributive (a(b + c) = ab + ac) laws allow us tomanipulate the function forms xy + x, x+ yx and x(y + 1) to show that they all have thesame value; that is, they all represent the same function. As soon as the equality of thefunction forms is less familiar, you’re aware of their importance. For example (au)v = auv,sin(2x) = 2 sinx cosx and d(ex)/dx = ex.

Since some of you may still be confused, let’s restate this. For our purposes, we shallsay that two statement forms are different as statement forms, or simply different if they“look different.” They are the same if they “look the same.” This is not very precise, but isgood enough. Thus, for example, p∨q and q∨p look different and so are different statementforms. We say that two statement forms are logically equivalent (or simply equivalent) ifthey have the same truth table. The statement forms p ∨ q and q ∨ p are equivalent (havesame truth table). Likewise, (p ∧ q) ∨ r and (p ∨ r) ∧ (q ∨ r) are different statement formsthat are equivalent, as may be seen by doing a truth table for each form and comparingthem. We are familiar with these ideas from high school algebra. For example, x(y + z)and xy + xz look different but are equivalent functions.

Sometimes we’ll let our logic hat slip and use Boolean function terminology. In par-ticular, we’ll often use 0 instead of “false” and 1 instead of “true.”

The constant functions are particularly important and are given special names.

Definition 1 (Tautology, contradiction) A statement form that represents the con-stant 1 function is called a tautology. In other words, the statement form is true for alltruth values of the statement variables. A statement form that represents the constant 0function is called a contradiction. In other words, the statement form is false for all truthvalues of the statement variables.

Recall that some of the basic functions studied in Unit BF: not, and and or, denotedby ∼, ∧ and ∨, respectively. We defined these three functions by giving their values intabular form, which is called a truth table just as it is for Boolean functions in Unit BF.In that unit, definitions were as follows, where we have replaced 0 and 1 by F and T toemphasize “false” and “true;” however, we’ll usually use 0 and 1.

p ∼p

F TT F

p q p ∧ q

F F FF T FT F FT T T

p q p ∨ q

F F FF T TT F TT T T

p q p “equals” q

F F TF T FT F FT T T

We said there were three functions, but there is a fourth table. Besides, p “equals” q isn’t afunction—is it? What happened? The statement p “equals” q is either true or false. Thus,

Lo-2

Page 9: Arithmetic, Logic and Numbers

Section 1: Propositional Logic

we can think of “equals” as a function with domain {F, T}2 and range {F, T}. In symbols,“equals” : {F, T}2 → {F, T}. In what follows, we’ll replace “equals” with the symbol “⇔”(equivalence) which is usually used in logic. We use the more familiar “=” for assigningmeaning and values. Thus

• q = “the sky is blue” assigns an English meaning to q.

• q = p∨ r says that q “means” p∨ r; that is, we should replace q by the statement formp ∨ r.

• p = 1 means we are assigning the value 1 (true) to p.

Since propositional logic can be viewed as the study of Boolean functions, the tech-niques we developed for proving results about Boolean functions (Venn diagrams, truthtables and algebraic) can also be used in propositional logic. For convenience, we recall thetheorem for manipulating Boolean statements:

Theorem 1 (Algebraic rules for statement forms) Each rule states that two differentstatement forms are equivalent. That is, they look different but have the same truth table.

Associative Rules: (p ∧ q) ∧ r ⇔ p ∧ (q ∧ r) (p ∨ q) ∨ r ⇔ p ∨ (q ∨ r)

Distributive Rules: p ∧ (q ∨ r) ⇔ (p ∧ q) ∨ (p ∧ r) p ∨ (q ∧ r) ⇔ (p ∨ q) ∧ (p ∨ r)

Idempotent Rules: p ∧ p ⇔ p p ∨ p ⇔ p

Double Negation: ∼∼p ⇔ p

DeMorgan’s Rules: ∼(p ∧ q) ⇔ ∼p ∨ ∼q ∼(p ∨ q) ⇔ ∼p ∧ ∼q

Commutative Rules: p ∧ q ⇔ q ∧ p p ∨ q ⇔ q ∨ p

Absorption Rules: p ∨ (p ∧ q) ⇔ p p ∧ (p ∨ q) ⇔ p

Bound Rules: p ∧ 0 ⇔ 0 p ∧ 1 ⇔ p p ∨ 1 ⇔ 1 p ∨ 0 ⇔ p

Negation Rules: p ∧ (∼p) ⇔ 0 p ∨ (∼p) ⇔ 1

Truth tables and algebraic rules are practically the same as the tabular method andalgebraic rules for sets discussed in Section 1 of Unit SF. The next example explains whythis is so. You may want to read the first four pages of Unit SF now.

Example 1 (Logic and Sets) We’ve already pointed out that propositional logic andBoolean arithmetic can be viewed as different aspects of the same thing. In this example,we show that basic manipulation of sets are also related.

Suppose we are studying some sets, say P , Q and R. Let the corresponding lower caseletters p, q and r stand for the statement that x belongs to the set. For example p is thestatement “x ∈ P”.

Consider the distributive rule for sets:

P ∩ (Q ∪R) = (P ∩Q) ∪ (P ∩R).

It is equivalent to saying that

x ∈ P ∩ (Q ∪R) if and only if x ∈ (P ∩Q) ∪ (P ∩R)

Lo-3

Page 10: Arithmetic, Logic and Numbers

Logic

for all x in the universal set. What does x ∈ P ∩ (Q ∪ R) mean? It means x ∈ P andx ∈ (Q ∪ R). What does x ∈ (Q ∪ R) mean? It means x ∈ Q or x ∈ R. Putting thisall together and using our logic notation, x ∈ P ∩ (Q ∪ R) means p ∧ (q ∨ r). Similarlyx ∈ (P ∩Q) ∪ (P ∩R) means (p∧ q) ∨ (p∧ r). Thus the set form of the distributive rule isthe same as

p ∧ (q ∨ r) ⇔ (p ∧ q) ∨ (p ∧ r),

the distributive rule for logic.

It should be obvious how things are translated between set notation and logic notationand why we get the same algebraic rules. A practical consequence of this is that we canuse Venn diagrams to prove logic statements just as we used them in Unit SF.

Why is the tabular method for proving set identities like a truth table? The answer issimple, consider P , Q and R again. There are exactly eight possibilities for the location ofx, corresponding to the eight regions of the Venn diagram. For example, if x ∈ P , x 6∈ Qand x ∈ R, then the corresponding row in the tabular method for sets begins “Yes No Yes”and the truth table for p, q and r begins T F T . Thus the way to translate between thetwo methods is Yes↔ T and No↔ F .

Implication

“If it is raining, then the sidewalk is wet.” This is a simple example of an implication

statement. Some other forms are “The sidewalk is wet whenever it is raining” and “If thesidewalk isn’t wet, then it isn’t raining.” We want to include implication in propositionallogic since statements of the form “IfX, then Y ” play an important part in logical reasoning.To do so, we must face two problems:

• It is not clear how we should view “If X, then Y ” when X is false. For example, whatshould we think if it isn’t raining?

• Due to the variety and ambiguity of English, translation into Boolean statements maynot be clear.

In the remainder of this section, we investigate carefully the relationship between Englishlanguage assertions and Boolean functions (Boolean statement forms) associated with im-plication.

Let r = “it is raining” and let w = “the sidewalk is wet.” In symbolic notation, weuse r ⇒ w to stand for the statement “If it is raining, then the sidewalk is wet.” Usually,when such a statement is made we are primarily concerned with the situation when r istrue. For the study of logic, we must be concerned with all situations, so we need to knowhow to think about r ⇒ w when r is false. If it is not raining, the sidewalk may be wet (itrained earlier, the sprinklers are on, etc.) or the sidewalk may not be wet. Thus when r isfalse, we have no reason to disbelieve the statement r ⇒ w. Of course, we have no reasonto believe it either, so we are free to choose whatever we want for the truth value in thiscase. We take the generous approach and call r ⇒ w true when r is false. (Actually we’renot being generous—this is the standard interpretation.)

Lo-4

Page 11: Arithmetic, Logic and Numbers

Section 1: Propositional Logic

Let’s put all this into a definition.

Definition 2 (Implication) We define p ⇒ q to be the Boolean function, called impli-

cation or p implies q or the “conditional of q by p.” As a Boolean function, p ⇒ q has thefollowing truth table:

p q p ⇒ q

0 0 10 1 11 0 01 1 1

The expression p ⇒ q is a Boolean statement form. It is equivalent to the statementform ∼p ∨ q, as can be seen by comparing truth tables:

p q ∼p ∨ q

0 0 10 1 11 0 01 1 1

Note that the Boolean function f(p, q) defined by p ⇒ q has value 1 when p = 0, indepen-dent of the value of q.

We’ve been a bit sloppy: we’ve said r = “It is raining” and also, by the definition,r = 1. Clearly “It is raining” is not the same as “1.” What’s going on? Since we arestudying the truth values of statements, we should have said

r = the truth value of “It is raining.”

We’ll continue with the common practice of abusing the terminology by omitting the words“the truth value of.”

Example 2 (Implication, rain and Venn diagrams) Let R be the set of all timeswhen it is raining and let W be the set of all times when the sidewalk is wet. What doesour earlier example r ⇒ w say about the sets R and W? Suppose t is a time; that is, anelement of our universal set of all times.

• If t ∈ R, then it is raining at time t and so, by r ⇒ w, t ∈ W . Thus R ⊆ W .

• If t 6∈ R, then it is not raining at time t. In this case, r ⇒ w gives us no informationabout whether or not t is in W . Why is that? When r is false, r ⇒ w is true regardlessof whether or not w is true; that is, whether or not t is in W .

What happened to the 0 case of r ⇒ w in the definition of implication? That is the caset ∈ R (because r is true) and t 6∈ W (because w is false). Since the definition of implicationsays this is false, it says that this cannot happen. This is a consequence of R ⊆ W .

This is the way we represent p ⇒ q with Venn diagrams: There is a set P where p istrue and another set Q where q is true and we insist that P ⊆ Q.

Lo-5

Page 12: Arithmetic, Logic and Numbers

Logic

How can we show that p ⇒ q is not true for specific p and q? (For example, “If it israining, then my car won’t start.”) We must find an instance where p is true and q is falsebecause this is the only time p ⇒ q is false. (It’s raining, but my car starts.) You’ll seemore of this later.

Example 3 (Statement forms associated with implication) Here is a table thatdefines the basic statement forms associated with the conversational use of implication.

p q p ⇒ q ∼q ⇒ ∼p q ⇒ p ∼p ⇒ ∼q p ⇔ q

0 0 1 1 1 1 10 1 1 1 0 0 01 0 0 0 1 1 01 1 1 1 1 1 1

Starting with the statement form p ⇒ q, the statement form ∼q ⇒ ∼p is called thecontrapositive of p ⇒ q, the statement form q ⇒ p is called the converse of p ⇒ q, and thestatement form ∼p ⇒ ∼q is called the inverse of p ⇒ q. Note that, although the statementand its contrapositive are different statement forms (they look different) they are equivalent(i.e., the same as Boolean functions). Likewise, the converse and the inverse are equivalent.But, and this is important, the statement and its converse are not equivalent. The finalstatement form p ⇔ q is called double implication or “biconditional” and is equivalent to(p ⇒ q) ∧ (q ⇒ p).

Here, in tabular form, are some additional facts related to implication.

p q p ⇒ q ∼p ∨ q ∼(p ⇒ q) p ∧ ∼q

0 0 1 1 0 00 1 1 1 0 01 0 0 0 1 11 1 1 1 0 0

The statement forms p ⇒ q and ∼p ∨ q are equivalent as are ∼(p ⇒ q) and p ∧ ∼q.

Example 4 (Right triangles and the Pythagorean theorem) Throughout this ex-ample, suppose 0 < a ≤ b ≤ c are some fixed numbers. Take R = “The triangle with sidelengths a, b, c is a right triangle” and P = “a2 + b2 = c2.” We know from high school that“If R then P.” As a Boolean statement form we may write R ⇒ P . If you proved this factby starting with a right triangle and using a geometric argument to show that a2+ b2 = c2,then the statement form R ⇒ P represented the state of your knowledge at that point intime. You then probably went on to learn the law of cosines: a2 + b2 − 2 ab cos(θ) = c2.Using that, you can easily see that the converse P ⇒ R is true. Now you can represent thestate of your knowledge by R ⇔ P .

The statement form R ⇒ P is equivalent to ∼R ∨ P . Either a triangle is not a righttriangle or it satisfies a2 + b2 = c2.

Start with the statement, “If the triangle with side lengths a, b, c is a right triangle,then a2 + b2 = c2.”

Lo-6

Page 13: Arithmetic, Logic and Numbers

Section 1: Propositional Logic

• The contrapositive of that statement is “If a2 + b2 6= c2, then the triangle with sidelengths a, b, c is not a right triangle.”

• The converse is, if a2 + b2 = c2, then the triangle with side lengths a, b, c is a righttriangle.”

• The inverse is, “If the triangle with side lengths a, b, c is a not right triangle, thena2 + b2 6= c2.”

Example 5 (The many English forms for p ⇒ q) In this example we’ll discuss mostof the ways implication is written in English. Pay careful attention to when we use thephrase “statement form” and when we use the phrase “Boolean function.” Be sure to readthe last part of the example where we discuss the distinction between statement form andBoolean function further.

• if . . . then: The basic English form, “If p then q,” is understood to stand for thestatement form p ⇒ q. Note that the “if” is associated with p. Alternatively tothis, one sees “q if p.” Again, the “if” is associated with p, so this stands for thestatement form p ⇒ q. Thus, “If it’s raining, then it’s cloudy” is interpreted as thesame statement form as “It’s cloudy if it’s raining.” Both stand for the statement form“raining” ⇒ “cloudy.”

• only if: Sometimes we say “p only if q,” as in “I’ll go to the party only if I finishstudying.” Some people would paraphrase this as, “If I don’t finish studying, then Iwon’t go to the party.” In other words “p only if q” is translated into the statementform ∼q ⇒ ∼p. This statement form is equivalent, as a Boolean function, to thestatement form p ⇒ q, because an implication form is equivalent to its contrapositiveform. In other words, “p only if q”, however it is interpreted as a statement form, isequivalent as a Boolean function to “If I go to the party, then I finished studying.”Thus the phrase “p only if q” can be translated as a Boolean function into either oneof the equivalent statement forms ∼q ⇒ ∼p or p ⇒ q, whichever is most convenientfor the discussion at hand.

• if and only if: The biconditional, p ⇔ q is sometimes stated as “p if and only if q”and written “p iff q”.

• sufficient: The expression, “p is sufficient for q”(or “p is a sufficient condition for q”)is usually translated into the statement form p ⇒ q. Some students find it helpful to(silently to themselves) expand this phrase to “p is sufficient to force q to happen.”Then it is easier to remember that this means p ⇒ q. Instead of saying “p is sufficientfor q”, one sometimes says “a sufficient condition for q is p.”

• necessary: The statement “p is necessary for q” usually stands for the statement form∼p ⇒ ∼q. Some students (again silently to themselves) expand this to “p is a necessaryconsequence of q.” They find this easier to associate with the equivalent (as a Booleanfunction) form q ⇒ p. Instead of saying “p is necessary for q”, one says “a necessarycondition for q is p.”

• necessary and sufficient: Combining the two previous bulleted items, we see that “pis necessary and sufficient for q” is equivalent to p ⇔ q, the biconditional. Notice thatwe simply combined “necessary” and “sufficient”, just as we combined “if” and “onlyif” earlier to get the biconditional.

Lo-7

Page 14: Arithmetic, Logic and Numbers

Logic

• unless: Another possible source of confusion is the term “unless.” To say “p unlessq” is, formally, to specify the statement form ∼q ⇒ p. The most common usage of“unless” in English is something like, “The building is safe, unless the fire alarm isringing.” Formally, this means, “If the fire alarm is not ringing, then the building issafe.” Think of a night watchman sitting in his office with the fire alarm on the wall.Since the alarm isn’t ringing he relaxes, maybe even takes a nap. His assumption isthat “If the fire alarm is not ringing then all is well, the building is safe, I can relax.”If you asked him, “Why are you sleeping?” he might reply, “The building is safe unlessthe fire alarm is ringing.”

An equivalent Boolean function is ∼p ⇒ q, the contrapositive of ∼q ⇒ p. Thuswe have “If the building is not safe, then the fire alarm is ringing.” Note the symmetryin translating “p unless q” into either of the equivalent forms ∼p ⇒ q or ∼q ⇒ p. Intranslating “p unless q” into a Boolean function, simply apply “∼” to one of p or qand have that imply the other without applying “∼”.

Let’s review the role of the concepts of a “statement form” and a “Boolean function” inthe above discussion.

(a) Generally, when we are translating an English description of an implication into sym-bolic form, we are concerned most of all with obtaining the correct Boolean function.With a little practice you will find this easy to do.

(b) In the rare case when we are being pedantic and want to know if some statementform is the contrapositive, converse, or inverse, of an implication described in English,then we need to associate a precise statement form with the English sentence. Ourpolicy will be to always give you that statement form when you need to know it forthe discussion or question. The one exception to this policy is the case of “if p thenq” (or “q if p”) which we always associate with the statement form p ⇒ q.

Thus, in most cases, as with other English usages, all you will need to be able to do istranslate “if p then q” into an equivalent form as a Boolean function: p ⇒ q, ∼q ⇒ ∼p,∼p ∨ q, etc.

Example 6 (A way of translating English implications) Of course, you can mem-orize the rules from the previous example (and that may be a good idea), but what if youforget or if you run into something new? Suppose we see a sentence that relates two phrasesA and B; for example, “If A then B” or “A requires B.” Suppose we also realize that animplication is involved. How can we determine whether to write A ⇒ B or B ⇒ A or someother implication?

Here’s a trick: The truth table for p ⇒ q has only one row which is false and thatoccurs when p is true and q is false. Take your sentence and figure out how to make it falseand set things up so that it corresponds to (True)⇒(False).

Let’s do some examples.

What about “A requires B?” Consider “Fishes require water.” This is false if some-thing is a fish and does not require water. In general “A requires B” is false when A is trueand B is false. Thus, we have A ⇒ B.

What about “A is necessary for B?” Consider “Enrollment is necessary for credit.”This is false if I receive credit even though I am not enrolled. In other words “A is necessaryfor B” is false when B is true and A is false. Thus we can write it as B ⇒ A.

Lo-8

Page 15: Arithmetic, Logic and Numbers

Section 1: Propositional Logic

What about “A unless B?” Consider “I will flunk unless I study.” This is false when Idon’t flunk and I don’t study. Thus, it is false when A and B are both false. Since we need(True)⇒(False), we need to negate something. One possibility is ∼A ⇒ B and anotheris ∼B ⇒ A. Which is correct? They both are — one is the contrapositive of the other.However, they sound different in English. Compare “If I passed, then I studied” and “If Idon’t study, then I won’t pass.” The first is celebration after the fact and the second is awarning about what I should do.

What about “A or B?” Wait! There’s no implication here. In logic all that mattersis the truth table. Any statement form involving two variables that is false in only one ofthe four cases can be written as an implication. “A or B” is false only when both A andB are false. Thus ∼A ⇒ B. You’ve actually seen this before: we learned that p ⇒ q and∼p ∨ q are equivalent, so set p = ∼A and q = B.

Exercises for Section 1

1.1. In Example 1 we noted that algebraic operations in propositional logic, set the-ory and Boolean functions can be viewed as different aspects of the same thing.What logic and set operations correspond to the exclusive or operation for Booleanfunctions?

1.2. Let h = “he is happily married,” and w = “he is wealthy,” and s = “he is smart.”Write the following statements in symbolic form:

(a) He is happily married and wealthy but not smart.

(b) He is not wealthy, but he is happily married and smart.

(c) He is neither happily married, nor wealthy, nor smart.

1.3. Let n = “Nancy will major in computer science” and k = “Karen will major incomputer science.” Write the following statement in symbolic form: Either Nancywill major in computer science or Karen will major in computer science, but notboth.

1.4. We have three flags:

COM which indicates that the computer is out of memory,

DEO which indicates that a disk error has occurred,

ZIP which indicates that the ZIP disk does not have enough memory.

We use p to mean “the COM flag is off”, that is, the flag is zero. Wed use q and r tomean the DEO and ZIP flags, respectively, are off. Write the following statementsin symbolic form:

(a) COM is off and DEO is off and ZIP is off.

Lo-9

Page 16: Arithmetic, Logic and Numbers

Logic

(b) COM is off but DEO is on.

(c) There is enough memory in the computer; however, either a disk error hasoccurred or the ZIP disk is out of memory.

(d) The computer is out of memory and no disk error has occurred, but the ZIPdisk is out of memory.

(e) Either the computer is out of memory or both COM == 0 and DEO == 0.

1.5. Is the statement form (p ∧ q) ∨(

∼p ∨ (p ∧ ∼q))

∨ r a tautology, contradiction, orneither?

1.6. Is the statement form (p∧∼q)∧ (∼p∨ q)∧ r a tautology, contradiction, or neither?

1.7. Is the statement form(

(∼p ∧ q) ∧ (q ∨ r))

∧ ∼q ∧ r a tautology, contradiction, orneither?

1.8. Construct a truth table for p ∨ (∼p ∧ q) ⇒ q.

1.9. Construct a truth table for p ∨ (∼p ∧ q) ⇒ ∼q.

1.10. Construct a truth table for (p ⇒ q) ⇒ (q ⇒ p).

1.11. Write negations of the following statements in English. Make them as easilyunderstood as possible.

(a) If P is a pentagon then P is a polygon.

(b) If Tom is Ann’s father, then Jim is Ann’s uncle and Sue is her aunt and Maryis her cousin.

1.12. Write the converses and inverses for the statements in the previous exercise.

1.13. Why is the assertion, “There is some statement p ⇒ q that is not equivalent toits contrapositive,” equivalent to the statement, “There is some statement p ⇒ qwhose converse is not equivalent to its inverse?” (Note: both statements are false.)

1.14. Write the contrapositives for the statements in Exercise 1.11.

1.15. Write the contrapositive of the statement “Dennis won’t enter the America’s Cupunless he is sure of victory.” Use the interpretation of “p unless q” as the statementform ∼p ⇒ q.

1.16. You were told by your high school principal that you will “graduate with honor”(call that H) only if you either “make the honor roll each semester” (M) or “com-plete all language requirements” (C), and if, in addition, you “get straight A’s in

Lo-10

Page 17: Arithmetic, Logic and Numbers

Section 2: Predicate Logic

biology” (B) and “letter in at least one athletic activity” (A). You lettered in track,got straight A’s in all your science classes (including biology), and completed alllanguage requirements, but at graduation you were not given any honors. Did yourhigh school principal lie to you?

1.17. Write two different statement forms using “if” and “then” that are equivalent tothe following: “Learning to program in C is a necessary condition for learning toprogram in C++. ”

1.18. Given (∼p ∨ q) ⇒ (r ∨ ∼q), rewrite it as a statement form using only ∼ and ∧.

1.19. Given(

(

p ⇒ (q ⇒ r))

⇔(

(p ∧ q) ⇒ r)

)

∧ ∼p ∧ ∼q ∧ ∼r, rewrite it using only ∼

and ∨.

1.20. Start with the statement form “Getting up when the alarm rings is a sufficientcondition for me to get to work on time.” Rewrite it in an equivalent if- then form.

1.21. Start with the statement form, “Having sides of length 3, 4, and 5 is a sufficientcondition for this triangle to be a right triangle.” Rewrite it in an equivalent if-then form.

1.22. Start with the statement form, “Doing all of the programming assignments is anecessary condition for Jane to pass her Java course.” Rewrite this statement inan equivalent if-then form.

1.23. “If the program is running then there is at least 250K of RAM.” Which of thefollowing are equivalent to this statement?

(a) If there is at least 250K of RAM then the program is running.

(b) If there is less than 250K of RAM then the program is not running.

(c) The program will run only if there is at least 250K of RAM.

(d) If the program is not running then there is less than 250K of RAM.

(e) A necessary condition for the program to run is that there are at least 250Kof RAM.

(f) A sufficient condition for the program to run is that there is at least 250K ofRAM.

Lo-11

Page 18: Arithmetic, Logic and Numbers

Logic

Section 2: Predicate Logic

We have been studying statements that are either true or false. But, consider the statement“x2 > 1.” In order to decide if this statement is true or false, we need to know the numericalvalue of x. If x = 1.1, then “x2 > 1” is true. If x = 0.9, then “x2 > 1” is false. The bestway to think of this is to regard the statement “x2 > 1” as a function S(x) = “x2 > 1.” Ifwe take this point of view, we need to specify the domain of S. First suppose the domainof S is R, the set of all real numbers. The codomain (or range) of S, by our descriptionjust given, is a set of statements that are either true or false (e.g., S(0.9) = “0.92 > 1”,S(2.3) = “2.32 > 1”). The function S is an example of a predicate.

Definition 3 (Predicate and truth set) A predicate is any function whose codomainis statements that are either true or false. There are two things to be careful about:

• The codomain is statements not the truth value of the statements.

• The domain is arbitrary — different predicates can have different domains.

The truth set of a predicate S with domain D is the set of those x ∈ D for which S(x) istrue. It is written

{x ∈ D | S(x) is true} or simply {x | S(x)}.

Note that S(0.9) = “0.92 > 1” is a correct statement consistent with the way wecommonly use functional notation. But S(0.9) = FALSE or S(0.9) = 0 is not a correctstatement even though “0.92 > 1” is false. This is because the codomain of S is a set ofstatements, not the set {0, 1}. Instead of “S(0.9) = 0” we should say “S(0.9) is false.” Like-wise, we say “S(1.1) is true.” These are sometimes shortened to “∼S(0.9)” and “S(1.1).”

The expression {x | S(x)} may look strange, but it is consistent with the usual use ofthe notation. If the domain is known, there is no need to mention it and {x | . . .} meansthe set of those x for which . . . is true. The truth set of the predicate S(x) = “x2 > 1”with domain R is the set {x | x > 1} ∪ {x | x < −1}.

With some domains, it is more natural to think of a predicate as a function of morethan one variable. For example, the domain may be R × R and the predicate may be

“P (x, y) =(

(x > y > 0) ⇒ (x2 > y2))

.” Notice that P (x, y) is true for all x, y ∈ R.

In other words “For all x, y ∈ R, S(x, y)” is true. This sort of statement is the essence ofpredicate logic, so we introduce some terminology.

Definition 4 (Quantifiers) The phrase “for all” is called a universal quantifier andis written ∀ (“A” rotated 180◦). If S(x) is a predicate and the set D is contained in thedomain of x, the statement “ ∀x ∈ D, S(x)” is read “for all x ∈ D, S(x) is true,” or just“for all x ∈ D, S(x).” The statement “ ∀x ∈ D, S(x)” is true if and only if S(x) is true forevery x ∈ D; otherwise the statement “ ∀x ∈ D, S(x)” is false. If the value of D is clear,we may write simply ∀x S(x).

The phrase “for some” is called an existential quantifier and is written ∃ (“E” rotated

Lo-12

Page 19: Arithmetic, Logic and Numbers

Section 2: Predicate Logic

180◦). If S(x) is a predicate and the set D is contained in the domain of x, the statement“ ∃x ∈ D, S(x)” is read “for some x ∈ D, S(x) is true,” or just “for some x ∈ D, S(x).” Itis also read “there exists x ∈ D such that S(x).” The statement “ ∃x ∈ D, S(x)” is true ifand only if S(x) is true for at least one x ∈ D; otherwise the statement “ ∃x ∈ D, S(x)” isfalse. If the value of D is clear, we may write simply ∃x S(x).

In terms of truth sets:

• “ ∀x ∈ D, S(x)” is equivalent to saying that the truth set of S(x) contains the set D.

• “ ∃x ∈ D, S(x)” is equivalent to saying that the truth set of S(x) contains at least oneelement of the set D

One can view much of mathematics as an attempt to understand the truth sets of certainpredicates. For example, can you describe the truth set of the predicate S(b, c) = “x2+bx+chas no real roots”? You can answer this if you know that “the roots of x2 + bx + c are(−b±

√b2 − 4c)/2” is true for all (b, c) ∈ R×R and that “(

√d ∈ R) ⇔ (d ≥ 0)” is true for

all d ∈ R. The answer is {(b, c) | b2 < 4c}.

To work with the notation and also introduce ideas we will need later, we’ll look atsome examples from elementary number theory. The word “elementary” here means easyto state, not, necessarily, easy to solve. To make it easier to specify domains, we need somenotation.

Definition 5 (Notation for sets of numbers) Recall thatR denotes the real numbers, Zdenotes the integers, and Q denotes the rational numbers (ratios of integers). In addition, Ndenotes the nonnegative integers (the “natural numbers”), N+ denotes the nonzero naturalnumbers (positive integers), and P denotes the primes. A natural number n is prime ifn ≥ 2 and the only divisors of n are n and 1. An integer n ≥ 2 that is not prime iscomposite.

The number 2 is the smallest prime and the only even prime. The other primes lessthan 20 are 3, 5, 7, 11, 13, 17, 19.

Example 7 (Goldbach’s conjecture) A mathematician named Christian Goldbach(1690–1764), noticed that 4 = 2+2, 6 = 3+3, 8 = 3+5, 10 = 5+5, 12 = 5+7, 14 = 7+7,16 = 5+11, etc., making him think that every even number greater than or equal to 4 canbe written as the sum of two primes. We can state this in our notation:

∀ n ∈ N,(

(n ≥ 4) ∧ (n even))

⇒(

∃ p, q ∈ P, n = p+ q)

.

Goldbach made this conjecture in 1742 in a letter to Euler (1701-1783). Of course, it canbe written in various other ways; for example,

∀ n ≥ 2, ∃ p, q ∈ P, 2n = p+ q,

where it is understood from the context that n must be an integer and not something like√5 or π.

Lo-13

Page 20: Arithmetic, Logic and Numbers

Logic

Sadly (for mathematicians, since few others are interested) it is unknown whether ornot Goldbach’s conjecture is true. At least we have learned how to make the assertion,if not how to prove or disprove it. However, something is known for odd numbers: It isknown that

∃ K ∈ N, ∀ n ≥ K,(

(n odd) ⇒ ∃ p, q, r ∈ P, n = p+ q + r)

is true. This can be stated as “every sufficiently large odd number is the sum of threeprimes.” (The “sufficiently large” is due to “n ≥ K.”) This was proved by Ivan Vinogradov(1891–1983) in 1937.

Example 8 (Sets and logic again) In Example 1 we saw how set identities could bethought of in terms of propositional logic. We can also phrase this in predicate logic terms.

Let U be the universal set. For every set A,B,C and so on that is being considered,introduce the predicates A(x), B(x), C(x) and so on. Define A(x) to be true if and only ifx ∈ A and do likewise for the other predicates.1 A statement about sets is now equivalentto the corresponding statement about predicates with a universal quantifier. For example,∼(A ∪ B) = (∼A ∩ ∼B) is true if and only if

∀ x ∈ U,(

∼(A(x) ∨B(x)) ⇔ (∼A(x) ∧ ∼B(x)))

.

Why is that? The logic statement asserts that x ∈ ∼(A∪B) if and only if x ∈ (∼A∩∼B).This is essentially the element method of proof.

Example 9 (Quantifiers and negation) Let R(x) = “x+ 2 is prime” be a predicate.The statement “ ∀ n ∈ P, R(n)” is an example of the universal quantifier “for all” appliedto this predicate. Another way to say the same thing is “ ∀(n ∈ P), (n+ 2 ∈ P).” We haveused parentheses to make it easier to see that the predicate is n + 2 ∈ P and that n ∈ P

belongs with the quantifier. You should practice inserting parentheses in what follows tomake it easier to read.

Using the normal English meanings of the statements, you should be able to see thatthe negation of these statements is “ ∃ n ∈ P, ∼R(n),” which can be written“ ∃ n ∈ P, n+ 2 /∈ P.” Both negation statement forms mean the same thing. The symbol“/∈” is the negation of ∈. Since ∈ stands for “is in” or “is an element of,” /∈ stands for “isnot in” or “is not an element of.”

In this case, “ ∀ n ∈ P, R(n)” is false and “ ∃ n ∈ P, ∼R(n)” is true since 7 ∈ P and9 /∈ P. When ∃ is read “there exists,” the symbol ∋ is sometimes used for “such that.”Thus we can write either “ ∃ n ∈ P, n+ 2 /∈ P” or “ ∃ n ∈ P ∋ n+ 2 /∈ P.”

The negation of a “for all” to get a “for some” in the previous example is an applicationof the following theorem for moving negation through quantifiers. You should be able to

1 If you remember the definition of “characteristic function,” you should be able to seethat A(x) is simply the characteristic function for the set A.

Lo-14

Page 21: Arithmetic, Logic and Numbers

Section 2: Predicate Logic

see that the theorem is true by translating the notation into ordinary English. We omitthe formal proof

Theorem 2 (Negating quantifiers) Let D be a set and let P (x) be a predicate thatis defined for x ∈ D. Then

∼(

∀(x ∈ D), P (x))

⇔(

∃(x ∈ D), ∼P (x))

and∼(

∃(x ∈ D), P (x))

⇔(

∀(x ∈ D), ∼P (x))

Example 10 (You can’t buy it here) A grocery store chain has the disclaimer

ALL ITEMS NOT AVAILABLE AT ALL STORES.

in its weekly flyer of specials. What did they say and how could they have said what theymeant?

Let I be the set of items referred to and S the set of stores. Let A(i, s) be the predicateindicating that item i is available at store s. To translate the statement, we need to knowhow NOT should be applied. If the interpretation is

ALL ITEMS NOT (AVAILABLE AT ALL STORES),

then we can rewrite the statement as ∀ i ∈ I, ∼(

∀ s ∈ S, A(i, s))

, which our theorem tells

us is equivalent to ∀ i ∈ I, ∃ s ∈ S, ∼A(i, s). In English this says that, for every item inthe flyer, the company has at least one store where you won’t be able to get it. That’s nota good way to run a business, so our choice of parentheses must be wrong.

The other possibility is

ALL ITEMS (NOT AVAILABLE) AT ALL STORES,

which translates as ∀ i ∈ I,∀ s ∈ S, ∼A(i, s). This is even worse! In English it says nomatter what item you look for and no matter what store you look in, the item won’t beavailable.

It seems fairly obvious that what they want to say is ∼∀ i ∈ I, ∀ s ∈ S, A(i, s). In otherwords, it is not the case that all items are available at all stores. This is rather awkward.Moving the negation through the quantifiers, we obtain ∃ i ∈ I, ∃ s ∈ S, ∼ A(i, s), whichcan be written as

SOME ITEMS ARE UNAVAILABLE AT SOME STORES.

Notice that we have written “UNAVAILABLE” instead of “NOT AVAILABLE” to avoid the prob-lem of where to put parentheses that we considered in the two previous paragraphs.

Lo-15

Page 22: Arithmetic, Logic and Numbers

Logic

Example 11 (Twin primes) Let S(x) =“x and x+2 are prime” be a predicate.2 If S(x)is true, we call x and x+2 twin primes. We could rewrite S(x) as “(x ∈ P)∧ (x+2 ∈ P).”

The Twin Prime conjecture asserts that there are infinitely many twin primes. Howcan we express this in our notation since we do not have the phrase “infinitely many?”Here is a precise way of stating the Twin Prime conjecture:

“For all m ∈ N, there exists n ∈ N such that n ≥ m and S(n).”

Using the symbols we’ve just learned, we can rewrite it as

“ ∀ m ∈ N,(

∃ n ∈ N ∋(

(n ≥ m) ∧ S(n))

)

.”

We often combine ∃ n ∈ N and n ≥ m and often omit the ∋:

“ ∀ m ∈ N, ∃ n ≥ m, S(n).”

If you are puzzled why this states that there are infinitely many primes n such that n+ 2is also a prime, it helps to look at the negation. The negation of the statement is

∼(

∀ m ∈ N, ∃ n ≥ m, S(n))

⇔ ∃ m ∈ N, ∼(

∃ n ≥ m, S(n))

⇔ ∃ m ∈ N, ∀ n ≥ m, ∼S(n).

Note that we applied Theorem 2 twice: the first time to move ∼ inside “ ∀ m ∈ N” and thesecond time to move ∼ inside “ ∃ n ≥ m.”

Let’s look at our negative statement ∃ m ∈ N, ∀ n ≥ m, ∼S(n). If there were onlyfinitely many primes p such that p + 2 is also prime, we could take m to be bigger thanthe largest such p, and the negative would be proved. On the other hand, if there wereinfinitely many twin primes, no matter how we chose m, there would be larger twin primes(i.e., larger n so that S(n) is true) and so the negative would not be true.

Example 12 (Fermat numbers) A Fermat number (Pierre de Fermat, 1601–1665)is an integer of the form Fn = 22

n

+ 1 for n ∈ N. The first six Fermat numbers areF0 = 3, F1 = 5, F2 = 17, F3 = 257, F4 = 65537, and F5 = 4294967297. In 1640Fermat conjectured that Fn is a prime for every n. Let S(n) = “Fn ∈ P.” If we want toassert that all Fn are primes, we would say, “ ∀ n ∈ N, S(n),” or “ ∀ n ∈ N, Fn ∈ P.”The negation of this statement is, “ ∃ n ∈ N, Fn /∈ P.” The negation is true, sinceF5 = 4294967297 = 641 × 6700417. F5 is the first composite (i.e. non-prime) Fermatnumber. It is easy to factor F5 with modern computers, but it was hard when peoplecomputed by hand. Thus Fermat was led to the false conjecture “ ∀n ∈ N, S(n).” Arethere infinitely many Fermat primes (i.e., Fermat numbers that are prime)? If we thoughtso, we would conjecture “ ∀ m ∈ N, ∃ n ≥ m, S(n).” If we thought not, we wouldconjecture “ ∃ m ∈ N, ∀ n ≥ m, ∼S(n).” No one knows which assertion is correct. It isknown that F6 through F20 are, like F5, composite.

2 This is not the same as the predicate R in Example 9. Explain why. Express S(x) interms of R.

Lo-16

Page 23: Arithmetic, Logic and Numbers

Section 2: Predicate Logic

High school math students who take geometry often suffer through “straight edge andcompass” constructions of various geometric figures. The ancient Greeks figured out thatany regular polygon with 3 ·2k sides, k ∈ N, or with 5 ·2k sides, k ∈ N could be constructedwith straight edge and compass. This led them to wonder (in Greek, of course) “For whichn can a regular polygon with n sides be constructed with straight edge and compass?” LetP (n) be the predicate “a regular n-sided polygon can be constructed with straight edgeand compass.” We have just said that the Greeks proved ∀ k ∈ N,

(

P (3 · 2k) ∧ P (5 · 2k))

and they wondered what the truth set of P (n) is. In 1796, Karl Friedrich Gauss (1777–1855), then 18 years old, proved that it is possible to construct a polygon with m · 2k sides(k ∈ N and m odd) using ruler and compass whenever m is a product of distinct Fermatprimes, including m = 1, the empty product. Pierre Wantzel (1814–1848) proved that noothers can be constructed. (In other words, they found the truth set for P (n).) Thus, suchconstructions are known to be possible for m = 1, 3, 5, 17, 257, 65535, 3 × 5, 5 × 17, andso on up to 3 × 5× 17× 257× 65535 = 4294967295. If more Fermat primes are found, wecan add to this list. It should be noted that, although only 18, Gauss worked very hard atmath.

Example 13 (Mersenne primes and perfect numbers) A number of the formMp = 2p−1, where p ∈ P, is called a Mersenne number after Marin Marsenne (1588–1648).IfMp is prime, then it is called aMersenne prime. M2 = 3, M3 = 7, M5 = 31 andM7 = 127are Mersenne primes. But, M11 = 23×89 is not a prime. The first thirty-one values of p forwhich Mp is prime are 2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281,3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049,216091. (The 25th and 26th Mersenne primes, corresponding to p = 21701 and p = 23209,were discovered in 1978 by two high school students, Laura Nickel and Curt Noll.) It is not

known whether or not the statement “ ∀ k ∈ N, ∃ p ∈ P,(

(p ≥ k) ∧ (Mp ∈ P))

” is true or

false. (What does this statement assert about the number of Mersenne primes?)

A mathematician named Leonhard Euler (1701–1783) studied numbers called per-

fect numbers and found a remarkable connection between them and Mersenne primes in1770. A perfect number n ∈ N+ is a number that is equal to the sum of all of its factors(other than itself). The smallest perfect number is 6 = 3 + 2 + 1. The next smallest is28 = 14 + 7 + 4 + 2 + 1. It is known that

∀ n ∈ N+,

(

(

∃ p ∈ P,(

(n = 2p−1Mp) ∧ (Mp ∈ P))

)

⇔(

n is even and perfect)

)

.

Euclid knew the “if-then” part (the left side implies the right). Euler proved the reverse im-plication — a gap of about two millennia! Thus 22−1M2 = 6, 23−1M3 = 28, 25−1M5 = 496and 27−1M7 = 8128 are the first four even perfect numbers.

One could make the statement, “ ∀ k ∈ N, ∃ n > k, (n is even and perfect).” Is thatstatement known to be true or false? What do you think and why?

One could also make the statement, “ ∃ n ∈ N+, (n is odd and perfect).” No one knowswhether this statement is true or false. It is known that there are no odd perfect numbersless than 10160, in other words “∼∃ n < 10160, (n is odd and perfect)” is true.

Lo-17

Page 24: Arithmetic, Logic and Numbers

Logic

Example 14 (Fermat’s Last Theorem) In 1637, Pierre de Fermat wrote, in French,“I have discovered a truly remarkable proof which this margin is too small to contain.”Proof of what? He wrote it in his private shorthand notation which we have learned todecode. In our notation his claim was

∀ n ∈ N+{(

∃ (x, y, z) ∈ N+ × N

+ × N+, (xn + yn = zn)

)

⇔ (n ≤ 2)}

.

This is known as Fermat’s Last Theorem. If you have been watching TV in the last fewyears you will know that this “marginal statement” has finally been proven true by AndrewWiles, after more than 350 years of attempts by many mathematicians.

You may wonder why Fermat never wrote up his proof and why it took so long torediscover his proof. Fermat claimed to have proved many things without writing downthe proofs. (Don’t try this on a test!) He also made many conjectures. All his claims,except the “last theorem” were proven some time ago. All his conjectures are false. Whatwas Fermat’s proof of his “last theorem?” Most mathematicians believe that his proof wasincorrect. One of the techniques that Fermat used is known as “infinite descent.” It canbe used for the cases n = 3 and n = 4, but cannot be used in general. Some people believeFermat assumed it would work in general because it worked in these two cases.

This concludes our “number theory” examples. They were chosen to show you how towork with the notation of predicate logic. They were also chosen to introduce you to somefamous problems in number theory. There are important applications of number theory tocomputer science, but not, so far as we know, applications of these particular examples.They are just hard problems and, as such, intellectual challenges.

At this moment the two Voyager spacecraft (Voyager I and Voyager II) are speedingaway from the solar system at the rate of a million miles per day. They were launchedin 1977. Shortly after 2010 they will pass through the heliopause and enter interstellarspace. Aboard each is a recording containing greetings in 59 languages, a whale noise, 12minutes of sound — including the smack of a kiss, a baby’s cry, an EEG of a young womanin love, 116 pictures of this and that, 90 minutes of music including a Navajo chant, aJapanese shakuhachi piece, a Pygmy girl’s initiation song, a Peruvian wedding song, Bach,Beethoven, Mozart, Stravinsky, Louis Armstrong, Blind Willie Johnson, and, last but notleast, Chuck Berry singing “Johnny B. Goode.” If any aliens find that stuff, they maythink we are nuts sending such material and keep right on going. Much better would havebeen short crisp questions, easily translated,3 asking questions such as, “Are there any oddperfect numbers?” “Is Goldbach’s conjecture true?” The ability to answer such questionsshould be a matter of intellectual pride to any culture. At the time Voyager was launched,Fermat’s Last Theorem was the “obvious” candidate question. Ironically, we now know theanswer without any help from aliens.

3 Questions in physics would also be of interest, but more background concepts may beneeded than are needed for simple number theory problems.

Lo-18

Page 25: Arithmetic, Logic and Numbers

Section 2: Predicate Logic

Example 15 (Algebraic rules for predicate logic) In propositional logic we have The-orem 1 to help us manipulate statement forms. What about analogous rules for predicatelogic?

As long as we are not trying to pull things through quantifiers, the same rules apply.For example

P (x) ∨ (Q(y) ∧R(x, y)) ⇔ (P (x) ∨Q(y)) ∧ (P (x) ∨R(x, y)).

Why is this? For each particular choice of x and y, the predicates become statementvariables and so we are back in propositional logic.

What happens when quantifiers are involved? Theorem 2 tells us how to move ∼

through quantifiers. Sometimes we can move quantifiers through ∨ and ∧, and sometimesnot:

True: ∀ x ∈ D, (P (x) ∧Q(x)) ⇔ (∀ x ∈ D, P (x)) ∧ (∀ x ∈ D, Q(x))False: ∃ x ∈ D, (P (x) ∧Q(x)) ⇔ (∃ x ∈ D, P (x)) ∧ (∃ x ∈ D, Q(x))False: ∀ x ∈ D, (P (x) ∨Q(x)) ⇔ (∀ x ∈ D, P (x)) ∨ (∀ x ∈ D, Q(x))True: ∃ x ∈ D, (P (x) ∨Q(x)) ⇔ (∃ x ∈ D, P (x)) ∨ (∃ x ∈ D, Q(x))

In the exercises, you will be asked to explain this.

It should be clear from this that manipulating quantifiers is trickier than the manip-ulations of propositional logic. Given the problems with algebraic manipulation, how doesone go about proving statements in predicate logic? Since the variables often have infinitedomains (as in our number theory examples), we can’t construct truth tables because thewould have to have an infinite number of rows. Proving things in predicate logic can bedifficult.

Now you know why this section has less manipulation and proofs than the section onBoolean functions in Unit BF.

Exercises for Section 2

The following exercises will give you basic practice in predicate logic.

2.1. Each statement below should be rewritten in the form “ ∀ · · · x, · · · .”

(a) Every real number is negative, zero, or positive.

(b) No computer scientists are unemployed.

2.2. Start with the statement, “ ∀n ∈ Z, if n2 is even then n is even.” Which of thefollowing statements say the same thing? Which are true and which are false?

(a) Every integer has an even square and is even.

(b) If a given integer has an even square then that integer is even.

Lo-19

Page 26: Arithmetic, Logic and Numbers

Logic

(c) For all integers, some will have an even square.

(d) Any integer that has an even square will be even.

(e) If the square of some integer is even then it is even.

(f) All integers that are even have an even square.

2.3. For each of the following statements, construct a statement of the form, “∀ · · · , if· · · then · · ·.” that says the same thing.

(a) Any correct algorithm, correctly coded, runs correctly.

(b) Given any two odd integers, their product is odd.

(c) Given any two integers whose product is odd, the integers themselves are odd.

2.4. Consider the statement, “Every computer science student needs to take Java Pro-gramming.” Rewrite this in two ways, corresponding to the statement forms

(a) “ ∀x, if · · · then · · ·.”

(b) “ ∀x, · · ·.”

2.5. Consider the statement, “Some questions are easy.” Rewrite this statement in twoways, corresponding to the statement forms

(a) “ ∃ · · · x such that · · ·.”

(b) “ ∃x such that · · · and · · ·.”

2.6. A number in R − Q is called irrational. Consider the statement, “The productof any irrational number and any rational number is irrational.” Is the followingproposed negation of this statement the correct negation? If not, what is thecorrect negation? “There exists an irrational number x and an irrational number ysuch that the product xy is rational.” Which is true, the original statement or itsnegation?

2.7. Consider the statement, “For all computer programs P , if P is correctly pro-grammed then P compiles without warning messages.” What is the negation ofthis statement? Which is true, the original statement or its negation?

2.8. Consider the statement, “For all real numbers x and y, if x2 = y2 then x = y.”Is the following proposed negation of this statement the correct negation? If not,what is the correct negation? “If x 6= y then x2 6= y2.” Which is true, the originalstatement or its negation?

2.9. Consider the statement,“For all primes p ∈ P, either p is odd or p is 2.” What is thenegation of this statement? Which is true, the original statement or its negation?

Lo-20

Page 27: Arithmetic, Logic and Numbers

Section 2: Predicate Logic

2.10. Consider the statement, “For all animals x, if x is a tiger then x has stripes andx has claws.” What is the negation of this statement? Which is true, the originalstatement or its negation?

2.11. Start with the statement, “ ∃x ∈ R, ∀ negative y ∈ R, x > y.”

(a) Form a statement by reversing the existential and universal quantifiers. Whichstatement is true?

(b) Form the negation of the original statement. Is it true?

2.12. Start with the statement, “For all computer programs P , if P is correct then Pcompiles without error messages.” Form the contrapositive, converse, and inverseof this statement.

2.13. Start with the statement, “ ∀n ∈ N, if n2 is even then n is even.” Form thecontrapositive, converse, and inverse of this statement. Which statements are true?

2.14. Start with the statement, “ ∀n ∈ N, if n is prime then n is odd or n = 2.” Formthe contrapositive, converse, and inverse of this statement. Which statements aretrue?

2.15. Consider the statement “A large income is a necessary condition for happiness.”

(a) Let P be the set of people. For x ∈ P , let L(x) indicate that x has a largeincome and H(x) that x is happy. Rewrite the given statement using thenotation of logic rather than the English language.

(b) Write the statement in ordinary English, without using “necessary” or “suffi-cient.”

(c) Write the negation of the statement in logic notation. Move the negation insidethe statement as far as possible.

(d) Write this negation in ordinary English, without using “necessary” or “suffi-cient.”

2.16. Which of the following statements are true, which are false (∃! means “there existsexactly one”).

(a) ∃!x ∈ Z ∋ 1/x ∈ Z.

(b) ∀x ∈ R ∃! y ∈ R ∋ x+ y = 0.

2.17. Let S be a predicate with domain D. Write the statement, “ ∃! x ∈ D ∋ S(x)”using ∀ and ∃ instead of ∃!.

2.18. In each case, is the given statement true or false? Explain.

(a) ∀m ∈ N, ∃ n ≥ m, n even, ∃ p, q ∈ P, n = p+ q.

Lo-21

Page 28: Arithmetic, Logic and Numbers

Logic

(b) ∀m ∈ N, ∃ n ≥ m, n odd, ∃ p, q ∈ P, n = p+ q.

2.19. Let P (x) and Q(x) be predicates with domain D. For each pair of statement forms,state which are equivalent and explain your answer.

(a) ∀x ∈ D, (P (x) ∧Q(x)) compared with (∀x ∈ D,P (x)) ∧ (∀x ∈ D,Q(x))

(b) ∃x ∈ D, (P (x) ∧Q(x)) compared with (∃x ∈ D,P (x)) ∧ (∃x ∈ D,Q(x))

(c) ∀x ∈ D, (P (x) ∨Q(x)) compared with (∀x ∈ D,P (x)) ∨ (∀x ∈ D,Q(x))

(d) ∃x ∈ D, (P (x) ∨Q(x)) compared with (∃x ∈ D,P (x)) ∨ (∃x ∈ D,Q(x))

2.20. Suppose n > 1 is an integer. Prove:

If n is composite then 2n − 1 is composite.

Thus, if you are going to search for primes of the form 2n − 1, you can limit yoursearch to n a prime.

2.21. Suppose 2n − 1 is a prime number (that is, a Mersenne prime). Prove that N =2n−1(2n−1) is an even perfect number. (The converse is true but harder to prove.)

Lo-22

Page 29: Arithmetic, Logic and Numbers

Review Questions

Multiple Choice Questions for Review

In each case there is one correct answer (given at the end of the problem set). Tryto work the problem first without looking at the answer. Understand both why thecorrect answer is correct and why the other answers are wrong.

1. Consider the statement form p ⇒ q where p =“If Tom is Jane’s father then Jane isBill’s niece” and q =“Bill is Tom’s brother.” Which of the following statements isequivalent to this statement?

(a) If Bill is Tom’s Brother, then Tom is Jane’s father and Jane is not Bill’s niece.

(b) If Bill is not Tom’s Brother, then Tom is Jane’s father and Jane is not Bill’s niece.

(c) If Bill is not Tom’s Brother, then Tom is Jane’s father or Jane is Bill’s niece.

(d) If Bill is Tom’s Brother, then Tom is Jane’s father and Jane is Bill’s niece.

(e) If Bill is not Tom’s Brother, then Tom is not Jane’s father and Jane is Bill’s niece.

2. Consider the statement, “If n is divisible by 30 then n is divisible by 2 and by 3 andby 5.” Which of the following statements is equivalent to this statement?

(a) If n is not divisible by 30 then n is divisible by 2 or divisible by 3 or divisible by5.

(b) If n is not divisible by 30 then n is not divisible by 2 or not divisible by 3 or notdivisible by 5.

(c) If n is divisible by 2 and divisible by 3 and divisible by 5 then n is divisible by 30.

(d) If n is not divisible by 2 or not divisible by 3 or not divisible by 5 then n is notdivisible by 30.

(e) If n is divisible by 2 or divisible by 3 or divisible by 5 then n is divisible by 30.

3. Which of the following statements is the contrapositive of the statement, “You win thegame if you know the rules but are not overconfident.”

(a) If you lose the game then you don’t know the rules or you are overconfident.

(b) A sufficient condition that you win the game is that you know the rules or youare not overconfident.

(c) If you don’t know the rules or are overconfident you lose the game.

(d) If you know the rules and are overconfident then you win the game.

(e) A necessary condition that you know the rules or you are not overconfident is thatyou win the game.

4. The statement form (p ⇔ r) ⇒ (q ⇔ r) is equivalent to

(a) [(∼p ∨ r) ∧ (p ∨ ∼r)] ∨ ∼[(∼q ∨ r) ∧ (q ∨ ∼r)]

(b) ∼[(∼p ∨ r) ∧ (p ∨ ∼r)] ∧ [(∼q ∨ r) ∧ (q ∨ ∼r)]

(c) [(∼p ∨ r) ∧ (p ∨ ∼r)] ∧ [(∼q ∨ r) ∧ (q ∨ ∼r)]

(d) [(∼p ∨ r) ∧ (p ∨ ∼r)] ∨ [(∼q ∨ r) ∧ (q ∨ ∼r)]

Lo-23

Page 30: Arithmetic, Logic and Numbers

Logic

(e) ∼[(∼p ∨ r) ∧ (p ∨ ∼r)] ∨ [(∼q ∨ r) ∧ (q ∨ ∼r)]

5. Consider the statement, “Given that people who are in need of refuge and consolationare apt to do odd things, it is clear that people who are apt to do odd things are inneed of refuge and consolation.” This statement, of the form (P ⇒ Q) ⇒ (Q ⇒ P ), islogically equivalent to

(a) People who are in need of refuge and consolation are not apt to do odd things.

(b) People are apt to do odd things if and only if they are in need of refuge andconsolation.

(c) People who are apt to do odd things are in need of refuge and consolation.

(d) People who are in need of refuge and consolation are apt to do odd things.

(e) People who aren’t apt to do odd things are not in need of refuge and consolation.

6. A sufficient condition that a triangle T be a right triangle is that a2 + b2 = c2. Anequivalent statement is

(a) If T is a right triangle then a2 + b2 = c2.

(b) If a2 + b2 = c2 then T is a right triangle.

(c) If a2 + b2 6= c2 then T is not a right triangle.

(d) T is a right triangle only if a2 + b2 = c2.

(e) T is a right triangle unless a2 + b2 = c2.

7. Which of the following statements is NOT equivalent to the statement, “There existseither a computer scientist or a mathematician who knows both discrete math andJava.”

(a) There exists a person who is a computer scientist and who knows both discretemath and Java or there exists a person who is a mathematician and who knowsboth discrete math and Java.

(b) There exists a person who is a computer scientist or there exists a person who isa mathematician who knows discrete math or who knows Java.

(c) There exists a person who is a computer scientist and who knows both discretemath and Java or there exists a mathematician who knows both discrete mathand Java.

(d) There exists a computer scientist who knows both discrete math and Java or thereexists a person who is a mathematician who knows both discrete math and Java.

(e) There exists a person who is a computer scientist or a mathematician who knowsboth discrete math and Java.

8. Which of the following is the negation of the statement, “For all odd primes p < qthere exists positive non-primes r < s such that p2 + q2 = r2 + s2.”

(a) For all odd primes p < q there exists positive non-primes r < s such that p2+q2 6=r2 + s2.

(b) There exists odd primes p < q such that for all positive non-primes r < s, p2+q2 =r2 + s2.

Lo-24

Page 31: Arithmetic, Logic and Numbers

Review Questions

(c) There exists odd primes p < q such that for all positive non-primes r < s, p2+q2 6=r2 + s2.

(d) For all odd primes p < q and for all positive non-primes r < s, p2 + q2 6= r2 + s2.

(e) There exists odd primes p < q and there exists positive non-primes r < s suchthat p2 + q2 6= r2 + s2

9. Consider the following assertion: “The two statements(1) ∃x ∈ D, (P (x) ∧Q(x)) and(2) (∃x ∈ D,P (x)) ∧ (∃x ∈ D,Q(x)) have the same

truth value.” Which of the following is correct?

(a) This assertion is false. A counterexample is D = N, P (x) = “x is divisible by 6,”Q(x) = “x is divisible by 3.”

(b) This assertion is true. The proof follows from the distributive law for ∧.

(c) This assertion is false. A counterexample is D = Z, P (x) = “x < 0,” Q(x) =“x ≥ 0.”

(d) This assertion is true. To see why, let D = N, P (x) = “x is divisible by 6,”Q(x) = “x is divisible by 3.” If x = 6, then x is divisible by both 3 and 6 so bothstatements in the assertion have the same truth value for this x.

(e) This assertion is false. A counterexample is D = N, P (x) = “x is a square,”Q(x) = “x is odd.”

10. Which of the following is an unsolved conjecture?

(a) ∃n ∈ N, 22n

+ 1 /∈ P

(b) ∃K ∈ N, ∀n ≥ K, n odd, ∃ p, q, r ∈ P, n = p+ q + r

(c) (∃ x, y, z, n ∈ N+, xn + yn = zn) ⇔ (n = 1, 2)

(d) ∀m ∈ N , ∃ n ≥ m, n even, ∃ p, q ∈ P, n = p+ q

(e) ∀m ∈ N , ∃ n ≥ m, n ∈ P and n+ 2 ∈ P

11. Which of the following is a solved conjecture?

(a) ∀m ∈ N , ∃ n ≥ m, n odd, ∃ p, q ∈ P, n = p+ q

(b) ∀m ∈ N , ∃ n ≥ m, n ∈ P and n+ 2 ∈ P

(c) ∀m ∈ N , ∃ n ≥ m, 22n

+ 1 ∈ P

(d) ∀k ∈ N ,∃ p ∈ P, p ≥ k , 2p − 1 ∈ P

(e) ∀n ≥ 4, n even , ∃ p, q ∈ P, n = p+ q

Answers: 1 (b), 2 (d), 3 (a), 4 (e), 5 (c), 6 (b), 7 (b), 8 (c), 9 (c), 10 (e), 11 (a).

Lo-25

Page 32: Arithmetic, Logic and Numbers
Page 33: Arithmetic, Logic and Numbers

Notation Index

Logic notation∃ (for some) Lo-13∀ (for all) Lo-12∼ (not) Lo-2∧ (and) Lo-2⇔ (if and only if) Lo-6∨ (or) Lo-2⇒ (if . . . then) Lo-5

N (Natural numbers) Lo-13

P (Prime numbers) Lo-13

R (Real numbers) Lo-13

Sets of numbersN (Natural numbers) Lo-13P (Prime numbers) Lo-13R (Real numbers) Lo-13Z (Integers) Lo-13

Z (Integers) Lo-13

Index-1

Page 34: Arithmetic, Logic and Numbers
Page 35: Arithmetic, Logic and Numbers

Index

Subject Index

Absorption rule Lo-3

Algebraic rules forpredicate logic Lo-19statement forms Lo-3

Associative rule Lo-3

Biconditional (= if and onlyif) Lo-6

Bound rule Lo-3

Commutative rule Lo-3

Composite number Lo-13

Conditional (= if . . . then) Lo-5

ConjectureGoldbach’s Lo-13Twin Prime Lo-16

Contradiction Lo-2

Contrapositive Lo-6

Converse Lo-6

DeMorgan’s rule Lo-3

Distributive rule Lo-3

Double implication (= if and onlyif) Lo-6

Double negation rule Lo-3

English to logic“for all” Lo-12“for some” Lo-13“if and only if” Lo-7method for implication Lo-8“necessary” Lo-7“only if” Lo-7“requires” Lo-8“sufficient” Lo-7“there exists” Lo-13“unless” Lo-8

Existential quantifier (∃) Lo-13

Fermat number Lo-16

Fermat’s Last Theorem Lo-18

For all (logic: ∀) Lo-12

For some (logic: ∃) Lo-13

Goldbach’s conjecture Lo-13

Idempotent rule Lo-3

If . . . then Lo-5

If and only if (logic) Lo-7

Implication Lo-5

Inverse Lo-6

Logicpredicate Lo-12propositional Lo-1

Mersenne number Lo-17

Necessary (logic) Lo-7

Negation rule Lo-3

Numbercomposite Lo-13Fermat: Fn Lo-16integer: Z Lo-13Mersenne: Mp Lo-17natural: N Lo-13perfect Lo-17prime Lo-13prime: P Lo-13real: R Lo-13

Index-3

Page 36: Arithmetic, Logic and Numbers

Index

Number theoryelementary Lo-13

Only if (logic) Lo-7

Perfectnumber Lo-17

Predicate logicalgebraic rules Lo-19predicate Lo-12quantifier Lo-12truth set Lo-12

Prime number Lo-13

Propositional logic Lo-1algebraic rules Lo-3

Quantifierexistential (∃) Lo-13negation of Lo-15universal (∀) Lo-12

Ruleabsorption Lo-3associative Lo-3bound Lo-3commutative Lo-3DeMorgan’s Lo-3distributive Lo-3double negation Lo-3idempotent Lo-3negation Lo-3

Setas a predicate Lo-14

Statement form Lo-1Boolean function and Lo-8

Statement variable Lo-1

Sufficient (logic) Lo-7

Tautology Lo-2

There exists (logic: ∃) Lo-13

Truth set (predicate logic) Lo-12

Truth table Lo-2

Twin Prime conjecture Lo-16

Universal quantifier (∀) Lo-12

Unless (logic) Lo-8

Index-4