cs100 : discrete structures

24
06/15/22 . Prepared by Dr Saad Alabbad 1 CS100 : Discrete Structures Proof Techniques(1) Dr.Saad Alabbad Department of Computer Science E-mail: [email protected] Office # SR 068 Tel # 2581888

Upload: juanita-ocampo

Post on 01-Jan-2016

91 views

Category:

Documents


2 download

DESCRIPTION

CS100 : Discrete Structures. Proof Techniques(1) Dr.Saad Alabbad Department of Computer Science E-mail: [email protected] Office # SR 068 Tel # 2581888. Rules of Inference – Valid Arguments in Propositional Logic. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 1

CS100 : Discrete Structures

Proof Techniques(1)

Dr.Saad AlabbadDepartment of Computer Science

E-mail: [email protected] # SR 068Tel # 2581888

Page 2: CS100 : Discrete Structures

04/20/23 2

Rules of Inference – Valid Arguments in Propositional Logic

Argument: An argument is a sequence of statements that end

with a conclusion.

Valid: An argument is valid if and only if it is impossible for all

premises (preceding statements) to be true and the conclusion

to be false. By valid, we mean that the conclusion of the

argument must follow from the truth of the premises of the

argument.

Consider the arguments:

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

network.”

“You have a current password.”

Therefore,

“You can log onto the network.”

Page 3: CS100 : Discrete Structures

04/20/23 3

Rules of Inference – Valid Arguments in Propositional Logic

The conclusion “You can log onto the network” must be true

when the premises “If you have a current password, then you

can log onto the network” and “You have a current password”

are true.

Let p= “You have a current password.”

and q=“You can log onto the network.” Then the argument has

the form

where is the symbol that denotes “therefore.”

The statement ((p → q) ⌃p) → q is a tautology.

p → q

p

q

Page 4: CS100 : Discrete Structures

04/20/23 4

Rules of Inference – Rule for Propositional Logic

The argument form with premises p1, p2, …., pn and

conclusion q is valid, when (p1⌃p2⌃….⌃pn) → q is a

tautology.

To show that an argument is valid, instead of showing by

truth table, we can establish the validity of some

relatively simple argument forms, called rules of

inference, which can be used as building blocks to

construct more complicated valid argument forms.

The tautology ((p → q) ⌃p) → q is the basis of the rule of

inference called modus ponens or law of detachment.

Page 5: CS100 : Discrete Structures

04/20/23 5

Rules of Inference – Rules for Propositional Logic

Example: Suppose that the conditional statement “If it snows

today, then we will go skiing” and its hypothesis “It is snowing

today”, are true. Then by modus ponens, it follows that the

conclusion of the conditional statement, “We will go skiing” is

true.

Q1: Determine whether the argument given here is valid and

determine whether its conclusion must be true because of the

validity of the argument.."

4

9

2

32)2(,

.2

32.

2

3)2(,

2

32"

22

22

lyConsequent

thatknowWethenIf

Page 6: CS100 : Discrete Structures

04/20/23 6

Rules of Inference – Rules for

Propositional Logic

Page 7: CS100 : Discrete Structures

04/20/23 7

Rules of Inference – Rule for Propositional Logic

Example: State which rule of inference is the basis of the

following argument: “It is below freezing now. Therefore, it is

either below freezing or raining now”.

Sol: Let p= “It is below freezing now.” and q = “It is raining

now.” Then this argument is of the form:

p

p v q

This is an argument that uses the addition rule.

Q2: State which rule of inference is the basis of the following

argument: “It is below freezing and raining now. Therefore, it is

below freezing”.

Page 8: CS100 : Discrete Structures

04/20/23 8

Introduction to Proofs

A theorem is a statement that can be shown to be true (usually important statement)

Less important theorem sometimes are called propositions

A proof is a sequence of statements (valid argument) to show that a theorem is true

The statements to be used in proofs include: Axioms (statement assumed to be true

without proof) Ex: If x is positive integer then x+1 is positive

integer. Hypothesis (premises) of the theorem Previously proven theorems Rules of inference used to draw conclusions

and to move from one step to another

Page 9: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 9

Introduction to Proofs

A theorem is a statement that can be shown to be true (usually important statement)

Less important theorem sometimes are called propositions A proof is a sequence of statements (valid argument) to

show that a theorem is true The statements to be used in proofs include:

Axioms (statement assumed to be true without proof) Ex:If x is positive integer then x+1 is positive integer.

Hypothesis (premises) of the theorem Previously proven theorems Rules of inference used to draw conclusions and to move

from one step to another

Rules of inference

Axioms

Hypothesis

proven theorems

New theorem

Page 10: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 10

Introduction to Proofs

Example: If I have a car (C) I will drive to Makkah(M). My boss gave

me 40,000 (G) or Fired me(F). If I have SR40,000 (H) then I have a car(C). My boss did not fire me. Therefore I will drive to Makkah(M).

1. GF Hypothesis 2. F Hypothesis3. G Disjunctive syllogism rule using 1 and 24. GH Axiom 5. H C Hypothesis6. G C Hypo. syllogism using 4,57. C Modus ponens using 3 and 68. C M Hypothesis9. M Modus ponens using 7 and 8

Page 11: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 11

Methods of proving theorems:Direct proofs

A direct proof of a conditional statement H1 H2 … Hn C is established by assuming the truth of all hypothesis and using rules of inference, axioms and proven theorems to assert the truth of the conclusion

Example: prove that “if n is even then n2 is even”1. Assume that n is even (hypothesis)2. Therefore n=2k where k is integer (definition of even

number)3. By squaring n=2k we get n2=(2k)2=4k2=2(2k2)4. Since 2K2 is integer (Axiom. See p.A-5) 5. Therefore n2=2r is even

Page 12: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 12

Methods of proving theorems:Proof by contraposition

An indirect proof of a conditional statement p q is a direct proof of its contraposition qp.

Example 1: prove that “if n2 is even then n is even”

The contraposition is “if n is not even then n2 is not even”

1. Assume that n is not even i.e n is odd (hypothesis)2. Therefore n=2k+1 where k is integer (definition of odd

number)3. By squaring n=2k+1 we get

n2=(2k+1)2 =4k2+4k+1 =2(2k2+2k)+1= 2r+1

4. Since 2k2+2k is integer (Axiom. See p.A-5) 5. Therefore n2=2r+1 is not even (odd)

Page 13: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 13

Methods of proving theorems:Proof by contraposition

Example 2: prove that if n=ab then an or bn where a and b are positive integers

1. Let p be an , q be bn and r be n=ab2. We want to prove that r pq

3. The contraposition is (pq ) r (By definition)

4. Which is equivalent to p q r (De Morgan’s law)

5. Now assume that an and bn (p q)

6. Then a.bn.n=n (by multiplying the two inequalities)7. Therefore abn

8. Which is the same as r

Page 14: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 14

Methods of proving theorems:Vacuous and Trivial Proofs

Vacuous ProofVacuous ProofIf we know that p is false then pq is

vacuously true. Example 1: prove that if x20 then 1=2

where x is a real number Since x20 for every real number then

the implication is vacuously true Example 2: prove that if he is alive

and he is dead then the sun is ice cold. Since the hypothesis is always false

the implication is vacuously true. Trivial ProofTrivial ProofIf we know q is true then pq is trivially true.

Example 1: prove that if x=2 then x2 0 for all real numbers

Since x2 0 is true then the implication is trivially true.(we didn’t use the fact x=2)

pqp q

F

F

T

T

F

T

F

T

T

T

F

T

pqp q

F

F

T

T

F

T

F

T

T

T

F

T

Page 15: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 15

Methods of proving theorems:Proofs by Contradiction(1)

In proof by contradiction it is shown that if some statement were false, a logical contradiction occurs, hence the statement must be true

Show that 2 is irrational1. Let p be 2 is irrational

1. Assume p is true “2 is rational”1. Then 2=a/b where gcd(a,b)=1 , b0 and a0 (Definition of rational

numbers)2. Squaring both sides we get 2=a2/b2

3. It follows that 2a2=b2

4. Hence b2 is even (Definition of even numbers)5. Which means that b is even (Proved theorem. see slide 5)6. But a2=b2/2=(2k)2/2=2k2 so a is even also (Definition of even

numbers and proved thoeorm)7. But this is a contradiction since 7 and 8 contradict the fact that

gcd(a,b)=1 since if a and b are even then 2 is a common divisor.

Page 16: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 16

Methods of proving theorems:Proofs by Contradiction(2)

Why is this method valid ? The contradiction forces us to reject our assumption because our

other steps based on that assumption are logical and justified. The only “mistake” that we could have made was the assumption itself.

Be careful! Sometimes the contradiction comes from a mistake in the steps

of the proof and not from the assumption. This makes the proof invalid.

Example: prove that 1=2Example: prove that 1=21. Suppose that 21 and a=b for some a.2. Then 2b b [multiply by b]3. a+b b [2b=b+b=a+b by hypothesis]4. (a-b)(a+b) b(a-b) [multiply by a-b]5. a2-b2 ab-b2

6. a2 ab [subtract b2 from both sides]7. a b which contradicts our assumption that a=b8. Hence it follows that 1=2 Can you find the error Can you find the error

Page 17: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 17

Methods of proving theorems:Proofs by Contradiction(3)

To prove a conditional statement p q by contradiction we prove that p q F is true which is equivalent to p q .

Example: If 3n+2 is odd then n is odd Suppose that 3n+2 is odd and n is even [p q] Then

1. n=2r [hypothesis q and definition of even numbers]

2. 3n=6r [multiply 1 by 3]3. 3n+2=2+6r [add 2 to both sides] 4. 3n+2=2(1+3r)5. 3n+2=2k [let k=1+3r]6. Thus 3n+2 is even which is false (a contradiction !) 7. Therefore the implication is true.

Page 18: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 18

Methods of proving theorems: Proofs of Equivalence and Disproof by

counter example Proofs of EquivalenceProofs of Equivalence

To prove pq we have to prove p q and q p Example: prove “n is even if and only if n2 is even”

“if n is even then n2 is even” proved in slide 4 “n2 is even then n is even” proved in slide 5 Therefore, n is even if and only if n2 is even

Proving equivalence of several propositionsProving equivalence of several propositions If we want to prove that p1 p2 p3 … pn

Then it is sufficient to prove p1 p2,, p2 p3 … pn p1

Disproof by CounterexampleDisproof by Counterexample Prove that “For all real numbers x2>x” is false X=0.5 is a counterexample since 0.52>0.5 is not true

Page 19: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 19

Methods of proving theorems: Exhaustive Proof and Proof by

Cases(1) Sometimes there is no single argument that works for all

possible cases appearing in the statement. So we have to consider all different cases and/or instances .

(1) Exhaustive Proof(1) Exhaustive ProofIn this type of proofs. All possible instances are relatively small.

So we prove each instance separately.Example: Prove that (n+1)3 >= 3n if n is a positive integer

with n 4. We only have 4 instances to consider, n = 1, 2, 3, and 4.

Proof of case n = 1: (1+1)3 >= 31 i.e 4 >= 3 which is true.Check n = 2, 3, and 4 similarly. NotesNotes Human can perform exhaustive proofs with limited number

of possibilities. Computers can consider much larger number of instances/cases. However

Instances/cases must be finite and enumerable

Page 20: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 20

Methods of proving theorems: Exhaustive Proof and Proof by

Cases(2) (2) Proof by Cases(2) Proof by CasesIn this type of proofs. The proof covers each possible case. Each

case may cover an infinite number of instancesExample: Prove "if n is an integer then n2 >= n". Case 1: n = 0. Since 02 = 0, 02 >= 0. Case 2Case 2: n >= 1. n >= 1 implies n2 >= n. Case 3: n <= -1. Since n is negative, n2 is positive, so n2 > n. . Question: prove that |xy|=|x||y|Question: prove that |xy|=|x||y|

Hint: Hint: Consider all 4 cases depending on whether x is positive Consider all 4 cases depending on whether x is positive

or x is negative and whether or not y is negative.or x is negative and whether or not y is negative. Common errors in with exhaustive proof and proof by

cases: Draw conclusion from non-exhaustive examples Not covering all possible cases

Page 21: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 21

Methods of proving theorems: Existence Proofs

Many theorems state that an object with certain properties exists. I.e., xP(x) where P is a predicate. A proof of such a theorem is called an EXISTENCE

PROOF. There are two kinds: (1) Constructive Existence Proof(1) Constructive Existence ProofThe proof is established be giving example a such that P(a)

is true

Example: Prove "there is a positive integer that can be written as the sum of cubes in two different ways."

Proof: consider 1729=103+93=123+13. Finding such examples may require computer assistance.

Check n = 2, 3, and 4 similarly.

Page 22: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 22

Methods of proving theorems: Existence Proofs

(2) Non-constructive Existence Proof(2) Non-constructive Existence Proof The proof is established by showing that an object a

with P(a) is true must exist without explicitly demonstrating one. Proofs by contradiction are usually used in such cases.

Example: Let x1,x2,..,xn be positive integers such that their average is m. prove that there exists xi such that xi≥m

Proof: suppose that there is no such number.i,ex1m , x2m … xnmBy adding these inequalities we get: x1+ x2+…+ xn nmDividing by n : (x1+ x2+…+ xn)/n mBut since the average is defined as (x1+ x2+…+ xn)/n Then we have mm which is a contradiction.Therefore there must be a number xi such that xi≥m. But we

can not specify which number is that.

Page 23: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 23

Methods of proving theorems: Uniqueness Proofs

Some theorems state that there is exactly one element Some theorems state that there is exactly one element with a certain property.with a certain property.

A proof of such a theorem is called a A proof of such a theorem is called a UNIQUENESS PROOFUNIQUENESS PROOF. . Strategy here is (1) show that an element x with the Strategy here is (1) show that an element x with the

desired property exists (2) show that any other y (y != x) desired property exists (2) show that any other y (y != x) does not have the property. I.e., if x and y both have the does not have the property. I.e., if x and y both have the property, then x must equal y.property, then x must equal y.

Example:Example: prove that the equation 3x+5=9 has a unique prove that the equation 3x+5=9 has a unique solution.solution.

(1) There exists a solution namely x=4/3 (2) suppose that y and z are solutions then3y+5=9=3z+5So 3y=3zDividing by 3 we get y=zThis proves that the solution is unique

Page 24: CS100 : Discrete Structures

04/20/23 Prepared by Dr.Saad Alabbad 24

ENDEND