131
Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers 1.5 Rules of Inference 1.6 Introduction to Proofs 1.7 Proof Methods and Strategy 1

Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Embed Size (px)

Citation preview

Page 1: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

1

Chapter 1: The Foundations: Logic and Proofs

1.1 Propositional Logic1.2 Propositional Equivalences1.3 Predicates and Quantifiers1.4 Nested Quantifiers1.5 Rules of Inference1.6 Introduction to Proofs1.7 Proof Methods and Strategy

Page 2: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

2

1.1: Propositional Logic

Propositions: A proposition is a declarative sentence (that is, a sentence that declares a fact) that is either true or false, but not both.

Page 3: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

3

Example 1: All the following declarative sentences are propositions: 1. Washington D.C., is the capital of

the USA.2. Toronto is the capital of Canada3. 1+1=2.4. 2+2=3.

Page 4: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

4

Example 2: Consider the following sentences. Are they propositions? 1. What time is it?2. Read this carefully.3. x+1=2.4. x+y=z

Page 5: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

5

• We use letters to denote propositional variables (or statement variables).

• T: the value of a proposition is true.• F: the value of a proposition is false.• The area of logic that deals with

propositions is called the propositional calculus or propositional logic.

Page 6: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

6

Let p and q are propositions:

Definition 1: Negation (Not)• Symbol: ¬ • Statement: “it is not the case that p”.

• Example:P: I am going to town

¬P:It is not the case that I am going to town;I am not going to town;I ain’t goin’.

Page 7: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

7

Page 8: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

8

Definition 2: Conjunction (And)• Symbol:• The conjunction pq is true when both p and q are

true and is false otherwise.

• Example:

P - ‘I am going to town’Q - ‘It is going to rain’PQ: ‘I am going to town and it is going to rain.’

Page 9: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

9

t01_1_002.jpg

Page 10: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

10

Definition 3: Disjunction (Or)• Symbol:• The disjunction pq is false when both p and q are

false and is true otherwise.

• Example:

P - ‘I am going to town’Q - ‘It is going to rain’P Q: ‘I am going to town or it is going to rain.’

Page 11: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

11

Page 12: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

12

Definition 4: Exclusive OR• Symbol:• The exclusive or of p and q, denote pq, is true

when exactly one of p and q is true and is false otherwise.

• Example:

P - ‘I am going to town’Q - ‘It is going to rain’P Q: ‘Either I am going to town or it is going to rain.’

Page 13: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

13

Page 14: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

14

Definition 5: Implication • If…. Then….• Symbol:• The conditional statement pq is false when p is true

and q is false, and true• P is called the hypothesis and q is called the

conclusion.• Example:

P - ‘I am going to town’Q - ‘It is going to rain’P Q: ‘If I am going to town then it is going to rain.’

Page 15: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

15

Page 16: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

16

Equivalent Forms

If P, then QP implies Q

If P, QP only if Q

P is a sufficient condition for QQ if P

Q whenever PQ is a necessary condition for P

Page 17: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

17

Note: The implication is false only when P is true and Q is false!• ‘If the moon is made of green cheese then I have

more money than Bill Gates’ (?)• ‘If the moon is made of green cheese then I’m on

welfare’ (?)• ‘If 1+1=3 then your grandma wears combat boots’ (?) • ‘If I’m wealthy then the moon is not made of green cheese.’ (?)• ‘If I’m not wealthy then the moon is not made of

green cheese.’ (?)

Page 18: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

18

More terminology

•QP is the CONVERSE of P Q•¬ Q ¬ P is the CONTRAPOSITIVE of P Q•¬ P ¬ Q is the inverse of P Q•Example:Find the converse of the following statement:R: ‘Raining tomorrow is a sufficient condition for my not going to town.’

Page 19: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

19

ProcedureStep 1: Assign propositional variables to component propositions P: It will rain tomorrow Q: I will not go to townStep 2: Symbolize the assertion R: P QStep 3: Symbolize the converse Q PStep 4: Convert the symbols back into words ‘If I don’t go to town then it will rain tomorrow’

• Homework: Find inverse and contrapositive of statements above.

Page 20: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

20

Definition 6: Biconditional• ‘if and only if’, ‘iff’ • Symbol:• The biconditional statement pq is true when p and q

have the same truth value, and is false otherwise. • Biconditional statements are also called bi-implications.• Example:

P - ‘I am going to town’Q - ‘It is going to rain’P Q: ‘I am going to town if and only if it is going to rain.’

Page 21: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

21

Page 22: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

22

Translating English•Breaking assertions into component propositions - look for the logical operators!•Example:‘If I go to Harry’s or go to the country I will not goshopping.’P: I go to Harry’sQ: I go to the countryR: I will go shoppingIf......P......or.....Q.....then....not.....R(P Q) ¬ R

Page 23: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

23

Constructing a truth table1. one column for each propositional variable2. one for the compound proposition3. count in binary4. n propositional variables = 2n rows

• Construct the truth table for (P ¬ Q) (PQ)• HW: Construct the truth table for (P Q) ¬ R

Page 24: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

24

Page 25: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

25

t01_1_008.jpg

Page 26: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

26

• What is the real meaning of ¬ PQ ? a) (¬ P) Q b) ¬ (PQ)• What is the real meaning of PQR ? a) (PQ)R b) P(QR) • What is the real meaning of P QR ? a) (P Q)R b) P (QR)

Page 27: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

27

Page 28: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

28

• Example 20Find the bitwise OR, bitwise AND, and

bitwise XOR of the bit strings 01 1011 0110 and 11 0001 1101.

Logic and Bit Operations

Page 29: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

29

• Example 18: There are two kind of inhabitants, knights,

who always tell the truth, and their opposites, knaves, who always lie. You encounter two people A and B. What are A and B if A says “B is a knight” and B says “The two of us are opposite type”?

Logic Puzzles

Page 30: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

30

• Proposition• Negation• Conjection• Disjunction• Exclusive OR• Implication

Terms• Inverse• Converse• Contrapositive

Page 31: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Chapter 1: The Foundations: Logic and Proofs

1.1 Propositional Logic1.2 Propositional Equivalences1.3 Predicates and Quantifiers1.4 Nested Quantifiers1.5 Rules of Inference1.6 Introduction to Proofs1.7 Proof Methods and Strategy

31

Page 32: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

1.2: Propositional EquivalencesDefinition:Tautology: A compound proposition that

is always true.Contradiction: A compound proposition

that is always false.Contingency: A compound proposition

that is neither a tautology nor a contradiction.

32

Page 33: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

33

Page 34: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Logical Equivalences• Compound propositions that have the

same truth values in all possible cases are called logically equivalent.

• Definition:The compound propositions p and q are

called logically equivalent if pq is a tautology. Denote pq.

34

Page 35: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Logical Equivalences• One way to determine whether

two compound propositions are equivalent is to use a truth table.

• Symbol: PQ

35

Page 36: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

36

Logical Equivalences• Prove the De Morgan’s Laws.

Page 37: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

37

• HW: Prove the other one (De Morgan’s Laws).

Logical Equivalences

Page 38: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

•Example: Show that pq and ¬pq are logically equivalent. •HW: example 4 of page 23

38

Logical Equivalences

Page 39: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

t01_2_006.jpg

39

Logical Equivalences

Page 40: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

40

Logical Equivalences

Page 41: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

41

Logical Equivalences

Page 42: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Example 5: Use De Morgan’s laws to express the negations of “Miguel has a cellphone and he has a laptop computer”.

Example 5: Use De Morgan’s laws to express the negations of “Heather will go to the concert or Steve will go to the concert”.

42

Logical Equivalences

Page 43: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example 6: Show that ¬(pq) and p ¬q are logically equivalent.

• Example 7: Show that ¬(p(¬p q)) and ¬p ¬q are logically equivalent by developing a series of logical equivalences.

• Example 8: Show that (p q) ( pq) is a tautology.

43

Logical Equivalences

Page 44: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Tautology• Contradiction• Contingency• Logical Equivalence• De Morgan’s Laws• Commutative Law• Associative Law• Distributive Law

44

Terms

Page 45: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Chapter 1: The Foundations: Logic and Proofs

1.1 Propositional Logic1.2 Propositional Equivalences1.3 Predicates and Quantifiers1.4 Nested Quantifiers1.5 Rules of Inference1.6 Introduction to Proofs1.7 Proof Methods and Strategy

Page 46: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Predicate: A generalization of propositions ; A propositions which contain variables

• Predicates become propositions once every variable is bound- by– assigning it a value from the Universe of

Discourse U or–quantifying it

P. 1

Predicates

Page 47: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Examples:Let U = Z, the integers = {. . . -2, -1, 0 , 1, 2, . . .}– P(x): x > 0 is the predicate. It has no truth value until

the variable x is bound.• Examples of propositions where x is assigned a

value:(a) P(-3) (?, true or false); (b) P(0)(?); (c) (c) P(3)(?).

• The collection of integers for which P(x) is true are the positive integers.

• P(y) ν ¬ P(0) is not a proposition. The variable y has not been bound. However, P(3) ν ¬ P(0) is a proposition which is true. P. 1

Predicates

Page 48: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Example: Let R be the three-variable predicate R(x, y, z): x + y = z

• Find the truth value of R(2, -1, 5), R(3, 4, 7), R(x, 3, z)

P. 1

Predicates

Page 49: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers: Universal

• P(x) is true for every x in the universe of discourse.

• Notation: universal quantifier ∀xP(x)• ‘For all x, P(x)’, ‘For every x, P(x)’• The variable x is bound by the universal

quantifier producing a proposition.• An element for which P(x) is false is

called a counterexample of ∀xP(x).• Example: U={1,2,3}

∀ xP(x) P(1) Λ P(2) Λ P(3)P. 1

Page 50: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers: Universal

• Example 8: Let P(x) be the statement “x+1>x.” What is the

truth value of the quantification xP(x) where ∀the domain consists of all real number.

• HW: P36, example 13

P. 1

Page 51: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers: Existential

• P(x) is true for some x in the universe of discourse.

• Notation: existential quantifier ∃xP(x)– ‘There is an x such that P(x),’ – ‘For some x, P(x)’, – ‘For at least one x, P(x)’, – ‘I can find an x such that P(x).’

• Example: U={1,2,3}–∃xP(x) P(1) ν P(2) ν P(3)

P. 1

Page 52: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers: Existential

• Example 14: Let P(x) denote the statement “x>3.” What is the

truth value of the quantification xP(x), ∃where the domain consists of all real numbers.

• HW: Page 37, Example 16.

P. 1

Page 53: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers

P. 1

Page 54: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers: Unique Existential

• P(x) is true for one and only one x in the universe of discourse.

• Notation: unique existential !∃ xP(x)– ‘There is a unique x such that P(x),’– ‘There is one and only one x such that P(x),’– ‘One can find only one x such that P(x).’

P. 1

Page 55: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers

• Example: U={1,2,3}• Truth Table:

P(1) P(2) P(3) !∃ xP(x) 0 0 0 00 0 1 10 1 0 10 1 1 01 0 0 11 0 1 01 1 0 01 1 1 0

P. 1

Page 56: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers

• Note: A predicate is not a proposition until all variables have been bound either by quantification or assignment of a value!

P. 1

Page 57: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Precedence of Quantifiers

The quantifiers and have higher precedence than all logical operators from propositional calculus.

Example: xP(x)Q(x) means(a) ( xP(x))Q(x) (b) x(P(x)Q(x))

P. 1

Page 58: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Binding Variables

• Example:x(x+y=1)Bound variable:Free variable:

• Example:x(P(x)Q(x)) xR(x)The scope of :The scope of :The same meaning of x(P(x)Q(x)) yR(y)

P. 1

Page 59: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Logical Equivalences Involving Quantifiers

Example 19: Show that x(P(x)Q(x)) and xP(x) xQ(x) are

logically equivalent.

P. 1

Page 60: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Logical Equivalences Involving Quantifiers

• Statement involving predicates and quantifiers are logically equivalent if and only if they have the same truth value no matter which predicates are substituted into these statements and which domain of discourse is used for the variables in these propositional functions.

• Symbol: S T

P. 1

Page 61: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Equivalences Involving the Negation Operator

• Equivalences involving the negation operator¬∀xP(x) ∃x ¬ P(x)¬∃xP(x) ∀ x ¬ P(x)

• Distributing a negation operator across a quantifier changes a universal to an existential and vice versa.

P. 1

Page 62: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Equivalences Involving the Negation Operator

• Example 20:What are the negations of the statements: “There is an honest politician”

• Example 20:What are the negations of the statements: “All Americans eat cheeseburgers”.

HW: Example 21 in P41.

P. 1

Page 63: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Translating from English into Logical Expressions (single quantifier)

• Example 23:Express the statement “Every student in this class has

studied calculus” using predicates and quantifiers.

P. 1

Page 64: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Using Quantifiers in System Specifications

• Example 26:Consider these statements. “All lions are fierce.”“Some lions do not drink coffee.”“Some fierce creatures do not drink coffee.”Let P(x): x is a lion. Q(x): x is fierce. R(x): x drinks coffee.Assuming that the domain consists of all creatures,

express the statements in the argument using quantifiers and P(x), Q(x), and R(x).

P. 1

Page 65: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Logic Programming

• Prolog(Programming in Logic, developed in the 1970s.

• Working in AI.• Prolog programs including a set of declarations

consisting of two types of statements:– Facts : define predicates by specifying the elements that

satisfy these predicates.– Rules: define new predicates using those already defined

by facts.

P. 1

Page 66: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Logic Programming• Example 28:Facts:instructor(chan, math273)instructor(patel, ee222)instructor(grossman, cs301)enrolled(kevin, math273)enrolled(juana, ee222)enrolled(juana, cs301)enrolled(kiko, math273)enrolled(kiko, cs301)

P. 1

Rules:teacher(P,S) :-

instructor(P,C), enrolled(S,C)

Queries:?enrolled(kevin, math273)?enrolled(X,math273)?teacher(X,juana)

Uppercase letters are variables. The “” represents by “,” and the “” represents by “;” in Prolog.

Page 67: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers

• Multiple Quantifiers: read left to right . . .• Example: Let U = R, the real numbers, P(x,y): xy= 0

∀x∀yP(x, y)∀x∃yP(x, y)∃x∀yP(x, y)∃x∃yP(x, y)

The only one that is false is the first one.• Suppose P(x,y) is the predicate x/y=1? Assume U=R-

{0}.

P. 1

Page 68: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers

• Example: Let U = {1,2,3}. Find an expression equivalent to ∀x∃yP(x, y) where the variables are bound by substitution instead:

• Expand from inside out or outside in.• Outside in:

∃yP(1, y) Λ ∃ yP(2, y) Λ ∃ yP(3, y)[P(1,1) ν P(1,2) ν P(1,3)] Λ[P(2,1) ν P(2,2) ν P(2,3)] Λ[P(3,1) ν P(3,2) ν P(3,3)]

• HW: Inside Out: P. 1

Page 69: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers

• De Morgan’s Laws for Quantifiers

P. 1

Page 70: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers: Converting from English

• Examples:F(x): x is a fleegleS(x): x is a snurdT(x): x is a thingamabob

U={fleegles, snurds, thingamabobs}• Note: the equivalent form using the existential

quantifier is also given

P. 1

Page 71: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers: Converting from English

• Everything is a fleegle∀xF( x) ¬∃x¬F(x)

• Nothing is a snurd.∀x¬S(x) ¬∃xS( x)

• All fleegles are snurds.∀x[F(x) → S(x)]

Û ∀ x[¬ F(x) ν S(x)] ∀ x ¬[F(x) Λ ¬ S(x)] ¬∃x[F(x) Λ ¬ S( x)]

P. 1

Page 72: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers: Converting from English

• Some fleegles are thingamabobs.∃x[F(x) Λ T(x)]

¬ ∀ x[¬ F(x) ν ¬ T(x)]• No snurd is a thingamabob.

∀ x[S(x) → ¬ T(x)] ¬ ∃ x[S(x ) Λ T(x)]

• If any fleegle is a snurd then it's also a thingamabob ∀ x[(F(x) Λ S(x)) → T(x)]

¬ ∃ x[F(x) Λ S(x) Λ ¬ T( x)]

P. 1

Page 73: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers:Dangerous situations

• Commutativity of quantifiers∀x∀yP(x, y) ∀y∀xP(x, y)? YES!∀x∃yP(x, y) ∃y∀xP(x, y)? NO!

DIFFERENT MEANING!• Example: P(x,y): x+y=0, U: Integers∀x∃yP(x, y) is Ture∃y∀xP(x, y) is False

P. 1

Page 74: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Quantifiers:Dangerous situations

• Distributivity of quantifiers over operators∀x[P(x)ΛQ(x)] ∀xP( x)Λ∀xQ(x)? YES!

∀x[P(x)→Q(x)] [∀xP(x)→∀xQ(x)]? NO!• Let P(x) sometimes true, sometimes false, and

Q(x) is always false, then ∀x[P(x)→Q(x)] is False

[∀xP(x)→∀xQ(x)] is True

P. 1

Page 75: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Terms

• Proposition• Predicate• Universal Quantifier• Existential Quantifier• Unique Existential Quantifier• De Morgan’s Laws for Quantifiers• Binding Variables• Logic Programming

P. 1

Page 76: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Chapter 1: The Foundations: Logic and Proofs

1.1 Propositional Logic1.2 Propositional Equivalences1.3 Predicates and Quantifiers1.4 Nested Quantifiers1.5 Rules of Inference1.6 Introduction to Proofs1.7 Proof Methods and Strategy

Page 77: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Introduction: Nested Quantifiers

• Nested quantifiers: Two quantifiers are nested if one is within the scope of the other.

• Example: xy(x+y=0)

Page 78: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Introduction: Nested Quantifiers• Example:Domain: real number.Addition inverse: xy(x+y=0)Commutative law for addition: xy(x+y=y+x)Associative law for addition: xyz (x+(y+z)=(x+y)

+z)

Page 79: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

The Order of Quantifiers• Example:Let Q(x,y) denote “x+y=0.” What are the truth

values of the quantifications yxQ(x,y) and xyQ(x,y), where the domain for all variables consists of all real numbers?

Page 80: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers
Page 81: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Translating Mathematical Statements into Statements Involving Nested Quantifiers• Example 7:Translate the statement “Every real umber except

zero has a multiplicative inverse.” (A multiplicative inverse of a real number x is a real number y such that xy=1)

• HW: Example 8, p54

Page 82: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Translating from Nested Quantifiers into English

• Example 9:Translate the statement x(C(x)y(C(y)F(x,y)))

into English, where C(x) is “x has a computer,” F(x,y) is “x and y are friends,” and the domain for both x and y consists of all students in your school.

• HW: Example 10, p55.

Page 83: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Negating Nested Quantifiers• Example 14:Express the statement xy(xy=1) negation of the

statement so that no negation precedes a quantifier.

• HW: Example 15, p57

Page 84: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Chapter 1: The Foundations: Logic and Proofs

1.1 Propositional Logic1.2 Propositional Equivalences1.3 Predicates and Quantifiers1.4 Nested Quantifiers1.5 Rules of Inference1.6 Introduction to Proofs1.7 Proof Methods and Strategy

Page 85: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Definition:An argument in propositional logic is a sequence of

propositions. All but the final proposition in the argument are called premises and the final proposition is called the conclusion. An argument is valid if the truth of all its premises implies that the conclusion is true.

Rules of Inference

Page 86: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Definition: A theorem is a valid logical assertion which can be proved using– other theorems– axioms (statements which are given to be true) and– rules of inference (logical rules which allow the deduction

of conclusions from premises).

• A lemma (not a “lemon”) is a 'pre-theorem' or a result which is needed to prove a theorem.

• A corollary is a 'post-theorem' or a result which follows directly from a theorem.

Rules of Inference

Page 87: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Many of the tautologies in Chapter 1 are rules of inference. They have the form

H1 Λ H2 Λ..... Λ Hn →C• Where Hi are called the hypotheses and C is the conclusion.• As a rule of inference they take the symbolic form:

H1

H2

.

.Hn

Cwhere means 'therefore' or 'it follows that.'

Rules of Inference

Page 88: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Examples:The tautology P Λ(P → Q) → Q becomesP

P → Q Q

• This means that whenever P is true and P → Q is true we can conclude logically that Q is true.

• This rule of inference is the most famous and has the name– modus ponens or– the law of detachment.

Rules of Inference

Page 89: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Rules of Inference

Page 90: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Rules of Inference for Quantifiers

• Note:– In Universal Generalization, x must be arbitrary.– In Universal Instantiation, c need not be arbitrary but often is assumed to be.– In Existential Instantiation, c must be an element of the universe which makes P(x)

true.

Page 91: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example: Every man has two legs. John Smith is a man. Therefore, John Smith has two legs.

• Define the predicates:M(x): x is a man

L(x): x has two legsJ: John Smith, a member of the universe

Rules of Inference

Page 92: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example: • The argument becomes

1.x[M(x) → L(x)]2.M( J )\ L( J)

• The proof is1. x[M(x) → L(x)] Hypothesis 12.M( J ) → L(J ) step 1 and UI3.M( J ) Hypothesis 24.L( J) steps 2 and 3 and modus ponensQ. E. D. Note: Using the rules of inference requires lots of practice.

Rules of Inference

Page 93: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example 12: Show that the premises “Everyone in this

discrete mathematics class has taken a course in computer science” and “Marla is a student in this class” imply the conclusion “Marla has taken a course in computer science.”

• HW: Example 13, p71.

Rule of Inference for Quantified Statement

Page 94: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Fallacies are incorrect inferences.• Some common fallacies:–The Fallacy of Affirming the

Consequent–The Fallacy of Denying the Antecedent

(or the hypothesis)–Begging the question or circular

reasoning

Fallacies

Page 95: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example:If the butler did it he has blood on his hands.The butler had blood on his hands.Therefore, the butler did it.

• This argument has the formP → Q

QPor

[(P → Q)ΛQ] → P• which is not a tautology and therefore not a rule of

inference!

Fallacies:The Fallacy of Affirming the Consequent

Page 96: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example:if the butler is nervous, he did it.The butler is really mellow.Therefore, the butler didn't do it.

• This argument has the formP → Q

¬ P ¬ Q

or[(P → Q)Λ ¬ P] → ¬ Q

• which is also not a tautology and hence not a rule of inference.

Fallacies:The Fallacy of Denying the Antecedent (or the hypothesis)

Page 97: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Fallacies: Begging the question or circular reasoning

• This occurs when we use the truth of statement being proved (or something equivalent) in the proof itself.

• Example: Conjecture: if x2 is even then x is even.Proof: If x2 is even then x2 = 2k for some k. Then

x = 2l for some l. Hence, x must be even.

Page 98: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example: P (x): x注射疫苗 Q(x): x死亡某報刊登:『某人於下午過世,上午有注射疫苗』,請問其論點及目的為何?

Example:上題中加入一個描述:”所有注射疫苗的人都會死亡”。某人不幸過世,請問他是否有打疫苗?

Example:要如何確認 (加入 rules)某人是因注射疫苗過世。

HW: Example 10, p69

Fallacies

Page 99: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Argument• Premises• Conslusion• Valid

Terms

• Theorem• Axioms• Lemma• Corollary

• Rule of inference• Modus ponens• Modus tollensva• fallacies

Page 100: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Chapter 1: The Foundations: Logic and Proofs

1.1 Propositional Logic1.2 Propositional Equivalences1.3 Predicates and Quantifiers1.4 Nested Quantifiers1.5 Rules of Inference1.6 Introduction to Proofs1.7 Proof Methods and Strategy

Page 101: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• To prove an argument is valid or the conclusion follows logically from the hypotheses:– Assume the hypotheses are true– Use the rules of inference and logical

equivalences to determine that the conclusion is true.

P. 1

Formal ProofsFormal Proofs

Page 102: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Example:• Consider the following logical argument:

If horses fly or cows eat artichokes, then the mosquito is the national bird. If the mosquito is the national bird then peanut butter takes good on hot dogs. But peanut butter tastes terrible on hot dogs. Therefore, cows don't eat artichokes.

1. Assign propositional variables to the component propositions in the argument:

F Horses flyA Cows eat artichokesM The mosquito is the national birdP Peanut butter tastes good on hot dogs

P. 1

Formal ProofsFormal Proofs

Page 103: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

2. Represent the formal argument using the variables

1.(F ν A) → M2.M →P3. ¬ P ¬ A

P. 1

Formal ProofsFormal Proofs

Page 104: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

3. Use the hypotheses 1., 2., and 3. and the above rules of inference and any logical equivalences to construct the proof.

Assertion Reasons1.(F ν A) → M Hypothesis 1.2.M → P Hypothesis 2.3.(F ν A) → P` steps 1 and 2 and hypothetical

syll.4. ¬ P Hypothesis 3.5. ¬(F ν A) steps 3 and 4 and modus tollens6. ¬F Λ¬A step 5 and DeMorgan7. ¬A Λ¬F step 6 and commutativity of

'and'8. ¬A step 7 and simplification

Q. E. D.P. 1

Formal ProofsFormal Proofs

Page 105: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• We wish to establish the truth of the 'theorem‘

P→Q.• P may be a conjunction of other

hypotheses.• P → Q is a conjecture until a proof is

produced.

P. 1

Methods of Proof

Page 106: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Trivial Proof• Vacuous Proof• Direct Proof• Indirect Proof• Proof by Contradiction• Proof by Cases

P. 1

Methods of Proof

Page 107: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Trivial proof – If we know Q is true then P → Q is true.

• Example:– If it's raining today then the void set is a subset

of every set.– The assertion is trivially true independent of

the truth of P.

P. 1

Methods of Proof: Trivial Proof

Page 108: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Vacuous proof– If we know one of the hypotheses in P is false then P →

Q is vacuously true.

• Example:– If I am both rich and poor then hurricane Fran was a

mild breeze.

• This is of the form(P Λ ¬ P) → Q

– and the hypotheses form a contradiction.– Hence Q follows from the hypotheses vacuously.

P. 1歐亞書局

Methods of Proof: Vacuous Proof

Page 109: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Direct proof– assumes the hypotheses are true– uses the rules of inference, axioms and any

logical equivalences to establish the truth of the conclusion.

• Example:– Theorem: If 6x + 9y = 101, then x or y is not an integer.– Proof: Assume 6x + 9y = 101 is true.

Then from the rules of algebra 3(2x + 3y) = 101.But 101/3 is not an integer so it must be the case that one of 2x or 3y is not an integer (maybe both).Therefore, one of x or y must not be an integer.Q.E.D.

P. 1歐亞書局

Methods of Proof: Direct Proof

Page 110: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Indirect proof– A direct proof of the contrapositive:– assumes the conclusion of P → Q is false (¬ Q is true)– uses the rules of inference, axioms and any logical

equivalences to establish the premise P is false.• Note, in order to show that a conjunction of

hypotheses is false is suffices to show just one of the hypotheses is false.

P. 1

Methods of Proof: Indirect Proof

Page 111: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

P. 1

Methods of Proof: Indirect Proof

• Example:– A perfect number is one which is the sum of all

its divisors except itself. For example, 6 is perfect since 1 + 2 + 3 = 6. So is 28.

– Theorem: A perfect number is not a prime.– Proof: (Indirect). We assume the number p is a

prime and show it is not perfect.But the only divisors of a prime are 1 and itself.Hence the sum of the divisors less than p is 1 which is not equal to p.Hence p cannot be perfect.Q. E. D.

Page 112: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Proof by contradiction– assumes the conclusion Q is false– derives a contradiction..

P. 1

Methods of Proof:Proof by contradiction

Page 113: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example:– Theorem: There is no largest prime number.

(Note that there are no formal hypotheses here.)We assume the conclusion 'there is no largest prime

number' is false. There is a largest prime number. Call it p. Hence, the set of all primes lie between 1 and p.

Form the product of these primes:r = 2•3•5•7•11•....•p.But r + 1 is a prime larger than p. (Why?).This contradicts the assumption that there is a largest

prime. Q.E.D.

P. 1

Methods of Proof:Proof by contradiction

Page 114: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• The formal structure of the above proof is as follows:– Let P be the assertion that there is no largest prime.– Let Q be the assertion that p is the largest prime.– Assume ¬ P is true.– Then (for some p) Q is true so ¬ P→Q is true.– We then construct a prime greater than p so Q → ¬ Q.– Applying hypothetical syllogism we get ¬ P → ¬ Q.– From two applications of modus ponens we conclude

that Q is true and ¬ Q is true so by conjunction ¬ QΛQ or a contradiction is true.

– Hence the assumption must be false and the theorem is true.

P. 1歐亞書局

Methods of Proof:Proof by contradiction

Page 115: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

1. Break the premise of P→Q into an equivalent disjunction of the form

P1 ν P2 ν... ν Pn .2. Then use the tautology [(P1 → Q) Λ (P2 → Q) Λ... Λ(Pn → Q)]↔[(P1 ν P2 ν... ν Pn )

→ Q] Each of the implications Pi → Q is a case.• You must

a) Convince the reader that the cases are inclusive, i.e., they exhaust all possibilities

b) Establish all implications

P. 1

Methods of Proof: Proof by Cases

Page 116: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example:– Let be the operation 'max' on the set of

integers:

if a b then a b = max {a, b} = a = b a.– Theorem: The operation is associative.– For all a, b, c

(a b) c = a (b c).

P. 1歐亞書局

Methods of Proof: Proof by Cases

Page 117: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example:Proof:– Let a, b, c be arbitrary integers.– Then one of the following 6 cases must hold (are

exhaustive):1. a b c 2. a c b3. b a c 4. b c a5. c a b 6. c b a

– Case 1: a b = a, a c = a, and b c = b.– Hence (a b) c = a = a (b c).– Therefore the equality holds for the first case.– The proofs of the remaining cases are similar (and are

left for the student).Q. E. D.

P. 1歐亞書局

Methods of Proof: Proof by Cases

Page 118: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example 15:What is wrong with the “proof” that 1=2?“Proof:” We use these steps where a and b are two

equal positive integers.1. a=b (Given)2. a2=ab3. a2-b2=ab-b2

4. (a-b)(a+b)=b(a-b)5. a+b=b6. 2b=b7. 2=1

• HW: Example 15, p83 P. 1

Mistakes in Proofs

Page 119: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Conjunction• Disjunction• Conjecture

P. 1

Terms

Page 120: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

Chapter 1: The Foundations: Logic and Proofs

1.1 Propositional Logic1.2 Propositional Equivalences1.3 Predicates and Quantifiers1.4 Nested Quantifiers1.5 Rules of Inference1.6 Introduction to Proofs1.7 Proof Methods and Strategy

Page 121: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• We wish to establish the truth ofxP( x).

• Constructive existence proof:– Establish P(c) is true for some c in the universe.– Then xP( x) is true by Existential Generalization (EG).

• Example:Theorem: There exists an integer solution to the

equation x2+y2=z2.Proof: Choose x = 3, y = 4, z = 5.

P. 1

Existence Proofs

Page 122: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example:–Theorem: There exists a bijection

from A= [0,1] to B= [0, 2].–Proof:–we could have chosen g(x) = x/2 and

obtained a bijection directly.

• HW: Prove that g(x) above is a bijection function.

P. 1歐亞書局

Existence Proofs

Page 123: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Nonconstructive existence proof.– Assume no c exists which makes P(c) true and derive a

contradiction.• Example:

– Theorem: There exists an irrational number.– Proof:Assume there doesn’t exist an irrational number.Then all numbers must be rational.Then the set of all numbers must be countable.Then the real numbers in the interval [0, 1] is a countable set.But we have already known this set is not countable.Hence, we have a contradiction (The set [0,1] is countable and not countable).Therefore, there must exist an irrational number.

Q. E. D.– Note: we have not produced such a number!

HW: Prove that [0,1] is not countable.

P. 1

Nonconstructive Existence Proof

Page 124: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Recall that x ¬ P(x)↔¬ xP(x ).• To establish that ¬xP(x ) is true (or xP(x) is

false) construct a c such that ¬ P(c) is true or P(c) is false.

• In this case c is called a counterexample to the assertion xP(x)

P. 1

Disproof by Counterexample

Page 125: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example:Prove or disprove that “every positive integer

is the sum of the squares of two integers.Example: 5=12+22; 34=32+52.Counterexample:

P. 1

Disproof by Counterexample

Page 126: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Nonexistence Proofs– We wish to establish the truth of ¬ xP( x)

(which is equivalent to x ¬ P(x)).– Use a proof by contradiction by assuming there

is a c which makes P(c) true.

P. 1

Nonexistence Proofs

Page 127: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• We wish to establish the truth of xP(x) • We assume that x is an arbitrary member of

the universe and show P(x) must be true. Using UG it follows that xP(x) .

P. 1

Universally Quantified Assertions

Page 128: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example:– Theorem: For the universe of integers, x is even iff

x2 is even.Proof: The quantified assertion is x[x is even ↔ x2

is even]We assume x is arbitrary.Recall that P ↔ Q is equivalent to (P→Q) Λ (Q → P).

P. 1

Universally Quantified Assertions

Page 129: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example:– Case 1 . We show if x is even then x2 is even using a

direct proofIf x is even then x = 2k for some integer k. Hence, x2 = 4k2 which is even since it is an integer

which is divisible by 2.This completes the proof of case 1.

P. 1

Universally Quantified Assertions

Page 130: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Example:– Case 2 . We show that if x2 is even then x must be even .We use an indirect proof:Assume x is not even and show x2 is not even.If x is not even then it must be odd.So, x = 2k + 1 for some k.Then x2 = (2k+1) 2 = 2(2k 2+2k)+1 which is odd and hence not

even.This completes the proof of the second case.Therefore we have shown x is even iff x2 is even.Since x was arbitrary, the result follows by UG.

Q.E.D.

P. 1

Universally Quantified Assertions

Page 131: Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers

• Dear students: Learning how to construct proofs is probably one of the most difficult things you will face in life. Few of us are gifted enough to do it with ease. One only learns how to do it by practicing .

P. 1

Rosen to his student