<<

Chapter 1 - Foundations

Introduction

Suppose that:

1. Babies are illogical. 2. Nobody is despised who can manage a crocodile. 3. Illogical persons are despised.

What conclusion may be reached using all of these premises?1

Which is better, eternal happiness or a ham sandwich? It would appear that eternal happiness is better, but this is really not so! After all, nothing is better than eternal happiness, and a ham sandwich is certainly better than nothing. Therefore a ham sandwich is better than eternal happiness.2

And one of my favorite Lewis Carroll quotes:

. . . “Seven years and six months!” Humpty Dumpty repeated thoughtfully. “An uncomfortable sort of age. Now if you’d asked my advice, I’d have said ‘Leave off at seven’ but it’s too late now.” “I never ask advice about growing,” Alice said indignantly. “Too proud?” the other enquired. Alice felt even more indignant at this suggestion. “I mean,” she said, “that one can’t help growing older.” “One can’t, perhaps,” said Humpty Dumpty; “but two can. With proper assistance, you might have left off at seven.”

1.1 - Propositional Logic

Definitions and Notation

• Logic

• Proposition

• Notation

• Negation

1Taken from Lewis Carroll 2Raymond Smullyan

1 Truth Tables

p q ¬p ¬q

Conjunction and Disjunction

Conjunction of p and q:

p q p ∧ q T T T F F T F F

Disjunction of p and q:

p q p ∨ q T T T F F T F F

Other Definitions

• Exclusive Or (notation: ⊕)

• Implication / Conditional (notation: → or =⇒ )

• Biconditional (notation: ↔ or ⇐⇒ )

p q p ⊕ q p → q p ↔ q T T T F F T F F

2 Other Operations on Implications

• Converse

• Contrapositive

• Inverse

Precedence

Operator Precedence () 0 ¬ 1 ∧ 2 ∨ 3 → 4 ↔ 5

We will follow the book’s convention and [almost] always use parentheses to group operators in order to avoid confusion. One exception to this is when negating a proposition, e.g., ¬p ∧ q is equivalent to (¬p) ∧ q, as opposed to ¬(p ∧ q)

Compound Propositions in Truth Tables

Example 1.

p q ¬p p → q ¬p ∧ q (p → q) ∨ (¬p ∧ q) T T T F F T F F

3 Logic and Bit Operators

1.2 - Applications of Propositional Logic

Example 2. Suppose that:

1. Babies are illogical. 2. Nobody is despised who can manage a crocodile.

3. Illogical persons are despised.

What conclusion may be reached using all of these premises?

1.3 - Propositional Equivalences

Definitions

• Compound Proposition

• Contradiction

• Contingency

4 Logical Equivalence

Definition 1.

Notation: ≡

Truth tables can be used to show that compound propositions are logically equivalent.

Example 3. Show that p ≡ p ∨ (p ∧ q):

p q p ∧ q p ∨ (p ∧ q) T T T F F T F F

A Larger Example. . .

Show that (p → q) ∧ (p → r) ≡ p → (q ∧ r):

p q r p → q p → r (p → q) ∧ (p → r) q ∧ r p → (q ∧ r) T T T T T F T F T T F F F T T F T F F F T F F F

5 Table of Logical Equivalences

(The abbreviations are not universal, but you may use them in your homework or on tests if you wish.)

Equivalence Name Abbr. p ∧ T ≡ p Identity / Idempotent IdC (Conjunction) p ∨ F ≡ p Identity / Idempotent IdD (Disjunction) p ∧ F ≡ F Domination (Conjunction) DomC p ∨ T ≡ T Domination (Disjunction) DomD ¬(¬p) ≡ p DN p ∧ q ≡ q ∧ p Commutative (Conjunction) CC p ∨ q ≡ q ∨ p Commutative (Disjunction) CD (p ∧ q) ∧ r ≡ p ∧ (q ∧ r) Associative (Conjunction) AC (p ∨ q) ∨ r ≡ p ∨ (q ∨ r) Associative (Disjunction) AD p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) Distributive (Conjunction) DC p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) Distributive (Disjunction) DD ¬(p ∧ q) ≡ ¬p ∨ ¬q DeMorgan’s Law DMC (Conjunction) ¬(p ∨ q) ≡ ¬p ∧ ¬q DeMorgan’s Law DMD (Disjunction) p ∧ (p ∨ q) ≡ p Absorption (Conjunction) AbC p ∨ (p ∧ q) ≡ p Absorption (Disjunction) AbD p ∧ ¬p ≡ F Negation (Conjunction) p ∨ ¬p ≡ T Negation (Disjunction)

Table 1: Table of Logical Equivalences

6 Equivalence Name Abbr ¬(p → q) ≡ p ∧ ¬q Negation of Implication NI p → q ≡ ¬p ∨ q Implication to Disjunction ID p → q ≡ ¬q → ¬p Contrapositive C p ∨ q ≡ ¬p → q p ∧ q ≡ ¬(p → ¬q) (p → q) ∧ (p → r) ≡ p → (q ∧ r) (p → r) ∧ (q → r) ≡ (p ∨ q) → r (p → q) ∨ (p → r) ≡ p → (q ∨ r) (p → r) ∨ (q → r) ≡ (p ∧ q) → r

Table 2: Logical Equivalences Involving Implications

Equivalence Name Abbr. ¬(p ↔ q) ≡ ¬p ↔ q Negation of Biconditional NB ¬(p ↔ q) ≡ p ↔ ¬q Negation of Biconditional NB (alternative) p ↔ q ≡ (p → q) ∧ (q → p) Biconditional B p ↔ q ≡ ¬p ↔ ¬q p ↔ q ≡ (p ∧ q) ∨ (¬p ∧ ¬q)

Table 3: Logical Equivalences Involving Biconditionals

Additional Tautologies

(Remember, ‘tautology’ these will always be true for any values of p, q, r, and s.)

Tautology Name Abbr. p ∨ ¬p Excluded Middle EM (p ∧ q) → p Simplification S p → (p ∨ q) Addition A [p ∧ (p → q)] → q MP [(p → q) ∧ (q → r)] → (p → r) Hypothetical Syllogism HS [(p ∨ q) ∧ ¬q] → p DS [¬q ∧ (p → q)] → ¬p MT [(p ∨ r) ∧ [(p → q) ∧ (r → s)]] CDL → (q ∨ s) [(¬q ∨ ¬s) ∧ [(p → q) ∧ (r → s)]] Destructive Dilemma DDL → (¬p ∨ ¬r) (p ∨ p) → p Idempotent IM

Table 4: Additional Tautologies

7 De Morgan’s Laws

Example 4. Suppose there is an island populated solely by knights and knaves, and that knights always tell the truth but knaves always lie. While on this island, we encounter two people, A and B. A says “I am a knave or B is a knight”, while B says nothing. Determine, if possible, what A and B are.

Arguments Using Logical Equivalence

Example 5. Prove that ¬(p → q) → ¬q is a tautology.

Example 6. Use equivalences from the tables to prove that (p → q) ∧ (p → r) and p → (q ∧ r) are logically equivalent.

8 Practicality of Using Tables

How many rows does a need for a compound proposition containing 2 variables? 3 variables? 5 variable? 100 variables? in general?

Propositional Satisfiability

Definition 2.

1.4 - Predicates and Quantifiers

Introduciton

Is “x > 3” a proposition?

Definition 3 (Predicates (or ‘Propositional Functions’)).

9 Note that if x has no meaning, then P (x) is just a form.

Definition 4 (Domain of Discourse). The domain of discourse (or the universe of discourse or simply domain) of x is. . .

There are two ways to give meaning to a predicate P (x):

1.

2.

The Universal Quantifier

Definition 5. The universal quantification of the predicate P (x) is the statement . . .

In symbols,

Note:

Example 7. (Let the domain of discourse be all real numbers.)

10 The Existential Quantifier

Definition 6. The existential quantification of the predicate P (x) is the statement . . .

In symbols,

Note:

Example 8. (Let the domain of discourse be all Grove City students and faculty.)

Definition 7 (Free and Bound variables).

Definition 8 (Scope).

11 Quantifiers with Conjunction and Disjunction

Negating Quantified Expressions

Translating Into English

Example 9. Let P (x) be the statement “x likes to fly kites”, Q(x, y) be the statement “x knows y”, and L(x, y) the statement “x likes y”. Translate the following logical expressions into conversational English statements:

1. ∀x (Q(Amy, x) → P (x))

2. ∀x (L(Alice, x) → ¬L(x, Bob))

Translating From English

Example 10. Translate the following statements into logical expressions. Be sure to state the domain of discourse.

1. “All cats are gray.”

2. “There are pigs which can fly.”

12 1.5 - Nested Quantifiers

Example 11.

1. ∀x (x 6= 0 → ∃y(xy = 1)) 2. ∀x∀y(x + y = y)

Note: The order of quantification matters!

Example 12. Let M(x, y) = “x is y’s mother”. Translate the following into English:

• ∀y∃xM(x, y)

• ∃x∀yM(x, y)

Example 13. Translated each of the following in to English, where M is as in the previous example and S(x) = “x is a student”.

1. ∀y (S(y) → ∃xM(x, y))

2. ∀y∃x (S(y) ∧ M(x, y))

13 Example 14. Let L(x, y) = “x loves3 y” and S as in the previous example. Translate the following into logical expressions:

1. Everybody loves somebody.

2. There are people who love everybody.

3. All students love each other.

Negating Nested Quantifiers

Example 15. ¬(∀x∃y xy = 1) We move the negation through each level of quantification, using De Morgan’s rules for quantifiers at each step:

Example 16. Let I(x) = “x has an internet connection”, F (x, y) = “x and y have Facebook messaged”, and the domain be students in this class. Translate the following into logical expressions:

1. Someone in your class has an internet connection but has not Facebook messaged anyone else in the class.

2. There are two students in the class who, between them, have messaged everyone else in the class.

3In a 1 John 4 sort of way.

14 Example 17. Let C(x, y) = “student x is enrolled in class y” and the domain of x be GCC students. Translate the following into English sentences:

1. ¬ (∃x∀y C(x, y))

2. ∃x∃y∀z ((x 6= y) ∧ (C(x, z) ↔ C(y, z)))

1.6 - Rules of

Definitions

• Argument

• Conclusion

• Premises

• Valid [Argument]

• Fallacy

15 Standard Rules of Inference

Each of the following is based on a tautology.

p • Modus Ponens p → q ∴ q

¬q • Modus Tollens p → q ∴ ¬p

p → q • Hypothetical Syllogism q → r ∴ p → r

p ∨ q • Disjunctive Syllogism ¬p ∴ q

p • Addition ∴ p ∨ q

p ∧ q • Simplification ∴ p

p • Conjunction q ∴ p ∧ q

p ∨ q • Resolution ¬p ∨ r ∴ q ∨ r

Example 18. Identify the rules of inference used in each of the following arguments.

1. Alice is a math major. Therefore, Alice is either a math major or a c.s. major.

2. If it snows today, the college will close. The college is not closed today. Therefore it did not snow today.

3. If I go swimming, then I will stay in the sun too long. If I stay in the sun too long, then I will sunburn. Therefore, if I go swimming, then I will get sunburn.

16 Example 19. Use to show that the premises “Henry works hard”, “If Henry works hard then he is a dull boy”, and “If Henry is a dull boy then he will not get the job” imply the conclusion “Henry will not get the job.”

Standard Rules of Inference

Each of the following is based on a tautology.

∀x P (x) • ∴ P (c) for any fixed c

P (c) for an arbitrary c • ∴ ∀x P (x)

∃x P (x) • Existential Instantiation ∴ P (c) for some c

P (c) for some c • Existential Generalization ∴ ∃x P (x)

∀x (P (x) → Q(x)) • Universal Modus Ponens P (c) ∴ Q(c)

∀x (P (x) → Q(x)) • Universal Modus Tollens ¬Q(c) ∴ ¬P (c)

Example 20. What can you conclude about Henry, Jack, and Jill, given the following premises?

1. Every c.s. major has an iPad.

2. Henry does not have an iPad.

3. Jill has an iPad.

4. Jack is a c.s. major.

17 Fallacies p → q • Affirming the Conclusion q ∴ p

p → q • Denying the Hypothesis ¬p ∴ ¬q

p • Begging the Question ∴ p

Valid or Fallacy?

Do the following represent valid arguments, or fallacies?

1. All students in this class understand logic. Pascal is a student in this class. Therefore, Pascal understands logic. (Let P (x) = “x is in this class” and Q(x) = “x understands logic”.)

2. Every c.s. major takes discrete mathematics. Esther is taking discrete mathematics. Therefore, Esther is a c.s. major. (Let P (x) = “x is a c.s. major” and Q(x) = “x takes discrete”.)

3. All parrots like fruit. My pet bird is not a parrot. Therefore, my pet bird does not like fruit. (Let P (x) = “x is a parrot” and Q(x) = “x like fruit”.)

4. Everyone who eats granola every day is healthy. John is not healthy. Therefore John does not eat granola every day. (Let P (x) = “x eats granola every day” and Q(x) = “x is healthy”.)

18 1.7 - Introduction to Proofs

Terms that arise in Formal Proofs

• Proof

• Undefined Term

• Proposition

• Lemma

• Corollary

• Conjecture

• Axiom / Postulate

Quantifiers

When no quantifier is given, then a universal quantification is assumed.

Example 21. If xy > 0, then either x and y are both positive or x and y are both negative.

19 Basic Facts/Definitions/Postulates

• An integer n is even iff there exists an integer k such that n = 2k.

• An integer n is odd iff there exists an integer k such that n = 2k + 1.

• An integer a is a perfect square iff there exists an integer b such that a = b2.

• For a and b are integers such that a 6= 0, we say that a divides b iff there exists an integer c such that b = ac.

p • A real number r is rational iff there exists integers p and q with q 6= 0 such that r = q . A real number is irrational if it is not rational.

Methods of Proving

Definition 9 (Direct Proof). To prove a statement of the form p → q using a direct proof, we assume that p (the “if”) is true and then show by a direct argument (which may take many steps) that q (the “then”) must also be true. This is the most common form of proof, and we’ll almost always start by trying this approach.

Example 22. Prove the statement: “If a person likes math, then he is cool.”

Example 23.

Proposition 1. If n is a perfect square then n is either odd or divisible by 4.

Proof.

Q.E.D.

20 Methods of Proving Theorems

Definition 10 (Proof by Contraposition). A proof by contraposition is an indirect proof in which we prove the contrapositive of the original statement, i.e., we prove that ¬q → ¬p (recall that the contrapositive has the same truth values as the original implication).

Example 24. Prove the statement: “If a person likes math, then he is cool.”

Example 25.

Proposition 2. If n and m are integers and mn is even, then either m or n must be even.

Proof.

Q.E.D.

21 Proving a Biconditional Statement

To prove a statement of the form p ↔ q we prove both

• p → q and • q → p

Example 26. Prove the statement: “A person likes math if and only if he is cool.”

Proving Multiple Equivalences

To prove that three or more statements are equivalent (all connected with “if and only if”s), it is enough to show that a chain of “if. . . then. . . ” statements are true, as long as we can get from any statement to any other statement through the chain.

Example 27. Prove that the following are equivalent [shorthand abbr. “TFAE”; might also see “TAE” for “these are equivalent”] for any a, b ∈ R:

1. a < b a + b 2. > a 2 a + b 3. < b 2

22 Other Methods of Proof

Proof by Contradiction Assume the opposite of what you want to show and then show that this leads to a contra- diction. Can be useful, but usually does not yield a very ‘enlightening’ proof. As far as it is practical, try to avoid proof by contradiction.

Vacuous Proof Show that p → q is true by showing that p is false.

Trivial Proof Show that p → q is true by showing that q is true (without using p).

Example 28.

Proposition 3. The product of a non-zero rational number and an irrational number is irrational.

Proof.

Q.E.D.

23 Finding Mistakes in Proofs

1. a = b Given. 2. a2 = ab Multiply both sides by a. 3. a2 − b2 = ab − b2 Subtract b2 from both sides. 4. (a − b)(a + b) = b(a − b) Factor. 5. a + b = b Cancel a − b on both sides. 6. 2b = b Substitute a for b since a = b. 7. 2 = 1 Divide both sides by b. Where is the mistake in this proof?

Other Errors in Proofs

Begging the Question This occurs when the part of the proof is based on the truth of the statement being proved (we saw this in the previous section).

Circular Reasoning Occurs when you use a statement to prove itself.

1.8 - Proof Methods and Strategy

Proof Methods p ∨ q ∨ r p → s Proof by Cases Logically, it has a form similar to: q → s r → s ∴ s We can use this method when there are finitely many possibilities and show that each possible case leads to the desired result.

Exhaustive Proof Similar to a proof by cases. Generally used when looking at a relatively small number of examples will exhaust all possibilities.

24 Something so important it gets its own subsubsection.

Note Neither a Proof by Cases nor an Exhaustive Proof will constitute a valid proof unless all cases or possibilities have been examined! “Proof by M&Ms” (a.k.a., “Proof by doing a couple of examples”) is not a valid form of proof!

Example 29.

Theorem 1 (Triangle Inequality). For any two real numbers x and y, |x + y| ≤ |x| + |y|.

Proof.

Q.E.D.

Existence Proofs

A proof of a proposition of the form ∃x P (x) is called an existence proof. There are two types of existence proofs:

1. Constructive:

2. Nonconstructive:

Example 30 (Constructive Example). Show that there is a positive integer that can be written as the sum of cubes in two different ways.

Example 31 (Nonconstructive Example). Show that there exists two irrational numbers x and y such that xy is rational.

25 Uniqueness

Definition 11 (The Uniqueness Quantifier). ∃!x P (x) means

Example 32. ∀y ∈ R (y 6= 0 → ∃!x(xy = 1))

Counterexamples

To show that ∀x P (x) is false it is sufficient to find one value of x for which P (x) is false.

Example 33. Every positive integer is the sum of three squares.

26 Open Problems

Example 34 (The 3x + 1 Conjecture). Starting with any positive integer and repeatedly applying the transformation whereby an even integer gets divided by 2, and an odd integer gets multiplied by 3 and incremented by 1, we will ultimately generate the integer 1.

Example 35 (Goldbach’s Conjecture). Every positive even integer n ≥ 4 can be written as the sum of two prime numbers.

27 Additional Logic Puzzles

1. Use all of the following premises to reach a conclusion:

• The only books in this library, that I do not recommend for reading, are unhealthy in tone. • The bound books are all well written. • All the romances are healthy in tone. • I do not recommend you to read any of the unbound books.

2. 4Use all of the following premises to reach a conclusion:

• All my sons are slim. • No child of mine is healthy who takes no exercise. • All gluttons, who are children of mine, are fat. • No daughter of mine takes any exercise.

3. Let us assume that there are five houses of different colors next to each other on the same road. In each house lives a man of a different nationality. Every man has his favorite drink, his favorite brand of cigarettes, and keeps pets of a particular kind.

• The Englishman lives in the red house. • The Swede keeps dogs. • The Dane drinks tea. • The green house is just to the left of the white one. • The owner of the green house drinks coffee. • The Pall Mall smoker keeps birds. • The owner of the yellow house smokes Dunhills. • The man in the center house drinks milk. • The Norwegian lives in the first house. • The Blend smoker has a neighbor who keeps cats. • The man who smokes Blue Masters drinks bier. • The man who keeps horses lives next to the Dunhill smoker. • The German smokes Prince. • The Norwegian lives next to the blue house. • The Blend smoker has a neighbor who drinks water. Who keeps fish as his pet?5

4Puzzles 1 and 2 are attributed to Lewis Carroll 5Commonly attributed to Albert Einstein.

28 4. The Lady or the Tiger.6 A certain king likes to entertain himself by making his prisoners play a game to decide their fate. The prisoners are presented with two doors. In a room behind each door is either a lady whom the prisoner may marry, or a tiger whom may eat the prisoner. A clue is written on each door and the prisoner decides which door to open based on these clues. The clues provided to three prisoners brought before the king are below. Try to figure out which door each prisoner should open. Prisoner 1 is told that exactly one of the following clues is true and exactly one is false. Door 1: There is a lady behind this door and a tiger behind the other. Door 2: There is a lady behind one of the doors and a tiger behind the other.

Prisoner 2 is told that either both clues are true or both are false. Door 1: Either there is a tiger behind this door or a lady behind the second door. Door 2: There is a lady behind this door. Prisoner 3 receives directions which are a bit tricker since the first two escaped. This prisoner is told that if a lady is behind door 1 then the clue on door 1 is true, but if a tiger is behind door 1 then the clue on that door is false. Door 2 follows the opposite rule: if a lady is behind door 2 the clue on door 2 is false, but if a tiger is behind door 2 the clue on that door is true. Door 1: A lady is waiting behind at least one of the doors. Door 2: A lady is waiting behind the other door.

6Commonly attributed to Raymond Smullyan.

29