CPSC 121: Mode els of Computation Unit 7: Proof Te Unit 7: Proof - - PDF document

cpsc 121 mode els of computation
SMART_READER_LITE
LIVE PREVIEW

CPSC 121: Mode els of Computation Unit 7: Proof Te Unit 7: Proof - - PDF document

CPSC 121: Mode els of Computation Unit 7: Proof Te Unit 7: Proof Te chniques (part 1) chniques (part 1) Based on slides by Patrice Be Based on slides by Patrice Be lleville and Steve Wolfman lleville and Steve Wolfman Pre-Class Learning


slide-1
SLIDE 1

CPSC 121: Mode

Unit 7: Proof Te Unit 7: Proof Te

Based on slides by Patrice Be Based on slides by Patrice Be

els of Computation

chniques (part 1) chniques (part 1)

lleville and Steve Wolfman lleville and Steve Wolfman

Pre-Class Learning Pre-Class Learning

By the start of class for ea By the start of class, for ea

you should be able to:

Identify the form of stateme Identify the form of stateme Sketch the structure of a pro

Strategies: Strategies:

constructive/non-constructiv generalizing from the gener g g g direct proof (antecedent ass indirect proofs by contrapos proof by cases.

Unit 7- Proof Techniques

Goals Goals

ach proof strategy below ach proof strategy below,

nt the strategy can prove nt the strategy can prove.

  • of that uses the strategy.

ve proofs of existence ric particular p sumption) sitive and contradiction

2

slide-2
SLIDE 2

Quiz 7 Feedback: Quiz 7 Feedback:

In general : In general : Issues: We will do more proof exam

Unit 7- Proof Techniques

mples in class.

3

Quiz 7 Feedback Quiz 7 Feedback

Open-ended question: whe Open-ended question: whe

strategies?

When you are stuck When you are stuck. When the proof is going aro When the proof is getting to p g g When it is taking too long. Through experience (how d

Unit 7- Proof Techniques

en should you switch en should you switch

  • und in circles.
  • o messy.

y

  • you get that?)

4

slide-3
SLIDE 3

In-Class Learning G In-Class Learning G

By the end of this unit you By the end of this unit, you

Devise and attempt multiple strategies for a given theore g g

  • all those listed in the "pre
  • logical equivalences,
  • propositional rules of infe
  • rules of inference on qua

For theorems requiring only choices or for which the insi prove the theorem prove the theorem.

Unit 7- Proof Techniques

  • als
  • als

u should be able to: u should be able to:

e different, appropriate proof em, including , g e-class" learning goals erence antifiers y simple insights beyond strategic ight is given/hinted, additionally

5

Where We Are in Th

?Where We Are in Th

How can we convince ours

?

How can we convince ours

does what it's supposed to

We need to prove its correc

? ?

We need to prove its correc

How do we determine whe

better than another one?

? ?

better than another one?

Sometimes, we need a proo number of steps of our algo

? ? ? ? ?

Unit 7- Proof Techniques

?

he BIG Questions ? he BIG Questions

selves that an algorithm

?

selves that an algorithm

  • do?

ctness

? ?

ctness.

ether or not one algorithm is

? ?

  • f to convince someone that the

rithm is what we claim it is.

? ? ? ? ? ?

6?

slide-4
SLIDE 4

Unit Outline Unit Outline

T h i f di t

Techniques for direct pro

Existential quantifiers. Universal quantifiers.

Dealing with multiple quan Indirect proofs: contraposit Indirect proofs: contraposit Additional Examples

Unit 7- Proof Techniques

f

  • ofs.

More general term than in Epp. g pp

tifiers. tive and contradiction tive and contradiction

7

Direct Proofs Direct Proofs

General strategy: General strategy:

Start with what it is known to Move one step at a time tow Move one step at a time tow

If the statement is an impl

p1 ^ pn → c p1 … pn → c Assume the premises p1, … Move one step at a time tow p

There are two general form

  • Those that start with an
  • Those that start with a u

We use different techniques

Unit 7- Proof Techniques

  • hold.

wards the conclusion wards the conclusion.

ication

…, pn hold. wards c.

ms of statements:

existential quantifier. q niversal quantifier. s for them.

8

slide-5
SLIDE 5

Direct Proofs :Existe Direct Proofs :Existe

Suppose the statement has t Suppose the statement has t

To prove this statement is

Find a value of x (a “witness Find a value of x (a witness

So the proof will look like th

Let x = <some value in D> Let x = <some value in D> Verify that the x we chose s

Example:There is a prime Example:There is a prime

not prime.

Unit 7- Proof Techniques

ential Statements ential Statements

the form : x D P(x) the form : x D, P(x) true, we must

s”) for which P(x) holds s ) for which P(x) holds.

his:

satisfies the predicate.

number x such that 3x+2 is number x such that 3x+2 is

9

Direct Proofs :Existe Direct Proofs :Existe

How do we translate There How do we translate There

that 3x+2 is not prime into

A x Z+ Prime(x) Prim A. x Z+, Prime(x) ~Prim B. x Z+, Prime(x) ~Prim

  • C. x Z+, Prime(x) → ~Prim

D x Z+ Prime(x) → ~Prim

  • D. x Z+, Prime(x) → ~Prim
  • E. None of the above.

Unit 7- Proof Techniques

ential Statements ential Statements

e is a prime number x such e is a prime number x such predicate logic?

me(3x+2) me(3x+2) me(3x+2) me(3x+2) me(3x+2) me(3x+2)

10

slide-6
SLIDE 6

Direct Proofs :Existe Direct Proofs :Existe

So the proof goes as follow So the proof goes as follow

Proof:

  • Let x =
  • Let x
  • It is prime because its on
  • Now 3x+2 =

and

  • Hence 3x+2 is not prime
  • QED.

Unit 7- Proof Techniques

ential Statements ential Statements

ws: ws:

nly factors are 1 and e.

11

Unit Outline Unit Outline

T h i f di t

Techniques for direct proo

Existential quantifiers. Universal quantifiers.

Dealing with multiple quan Indirect proofs: contraposit Indirect proofs: contraposit Additional Examples

Unit 7- Proof Techniques

f fs. tifiers. tive and contradiction tive and contradiction

12

slide-7
SLIDE 7

Direct Proofs: Unive Direct Proofs: Unive

Suppose our statement has t Suppose our statement has t

To prove this statement is

Show that P(x) holds no ma Show that P(x) holds no ma

So the proof will look like th

Let x be an nonspecific (arb Let x be an nonspecific (arb Verify that the predicate P h

  • Note: the only assumptio
  • Note: the only assumptio

fact that it belongs to D. common to all elements

Unit 7- Proof Techniques

ersal Statements ersal Statements

the form : x D P(x) the form : x D, P(x) true, we must

atter how we choose x atter how we choose x.

his:

bitrary) element of D bitrary) element of D holds for this x.

  • n we can make about x is the
  • n we can make about x is the

So we can only use properties

  • f D.

13

Direct Proofs: Unive Direct Proofs: Unive

Example: Every Racket fun Example: Every Racket fun

characters long.

The proof goes as follows: The proof goes as follows:

Proof:

  • Consider an unspecified
  • Consider an unspecified
  • This function
  • Therefore f is at least 12

Unit 7- Proof Techniques

ersal Statements ersal Statements

nction is at least 12 nction is at least 12

Racket function f Racket function f 2 characters long.

14

slide-8
SLIDE 8

Direct Proofs: Unive Direct Proofs: Unive

Terminology: the following Terminology: the following

same thing:

Consider an unspecified ele Consider an unspecified ele Without loss of generality co Suppose x is a particular bu pp p

Unit 7- Proof Techniques

ersal Statements ersal Statements

statements all mean the statements all mean the

ement x of D ement x of D

  • nsider a valid element x of D.

ut arbitrarily chosen element of D. y

15

Direct Proofs: Unive Direct Proofs: Unive

Another example: Another example:

The sum of two odd numbe Proof: Proof:

Unit 7- Proof Techniques

ersal Statements ersal Statements

ers is even.

16

slide-9
SLIDE 9

Direct Proofs: Speci Direct Proofs: Speci

Suppose the statement has t Suppose the statement has t x D, P(x) → Q(x)

This is a special case of th This is a special case of th The textbook calls this (an The proof looks like this:

Proof: C id ifi d

  • Consider an unspecified
  • Assume that P(x) is true
  • Use this and properties o
  • Use this and properties o

the predicate Q holds for

Unit 7- Proof Techniques

al Case al Case

the form: the form: he previous formula he previous formula d only this) a direct proof.

l t f D element x of D. .

  • f the element of D to verify that
  • f the element of D to verify that

r this x.

17

Direct Proofs: Speci Direct Proofs: Speci

Why is the line Assume tha Why is the line Assume tha

  • A. Because these are the only

matters. B. Because P(x) is preceded ( ) p

  • C. Because we know that P(x
  • D. Both (a) and (c)

E. Both (b) and (c)

Unit 7- Proof Techniques

al Case al Case

at P(x) is true valid? at P(x) is true valid?

y cases where Q(x) by a universal quantifier. y q x) is true.

18

slide-10
SLIDE 10

Direct Proofs: Speci Direct Proofs: Speci

Example: prove that Example: prove that

n N, n ≥ 1024 → 10n ≤

Proof: Proof:

Consider an unspecified na Assume that n ≥ 1024 Assume that n ≥ 1024. Then ...

Unit 7- Proof Techniques

al Case al Case

nlog2 n tural number n.

19

and for fun … and for fun …

Other interesting technique Other interesting technique

Proof by intimidation Proof by lack of space (Ferm Proof by lack of space (Ferm Proof by authority Proof by never-ending revis y g

For the full list, see:

,

http://school.maths.uwa.edu fs.html

Unit 7- Proof Techniques

es for direct proofs ☺ es for direct proofs ☺

mat's favorite!) mat s favorite!) sion u.au/~berwin/humour/invalid.proo

20

slide-11
SLIDE 11

Unit Outline Unit Outline

T h i f di t

Techniques for direct proo

Existential quantifiers. Universal quantifiers.

Dealing with multiple qua Indirect proofs: contraposit Indirect proofs: contraposit Additional Examples

Unit 7- Proof Techniques

f fs. antifiers. tive and contradiction tive and contradiction

21

Multiple Quantifiers Multiple Quantifiers

How do we deal with theor How do we deal with theor

quantifiers?

Start the proof from the oute Start the proof from the oute Work our way inwards.

Example: Example:

For every positive integer n, than n. Written using predicate logic

Unit 7- Proof Techniques

rems that involve multiple rems that involve multiple

ermost quantifier ermost quantifier. , there is a prime p that is larger c:

22

slide-12
SLIDE 12

Multiple Quantifiers: Multiple Quantifiers:

The proof goes as follow The proof goes as follow

Proof: Consider an unspecifie Consider an unspecifie Choose p a Now prove

n Z+ p Z+

Unit 7- Proof Techniques

Example Example

ws: ws:

ed positive integer n ed positive integer n as follows: e that p > n and that p is prime.

23

Multiple Quantifiers: Multiple Quantifiers:

How do we choose p? How do we choose p?

First we compute x = n! + 1 By the fundamental theorem By the fundamental theorem as a product of primes: x = p1·p2· ··· pt We use any one of these as

The integer p is a prime by

Unit 7- Proof Techniques

Example Example

(where n! = 1·2·3· ··· ·(n-1)·n). m of arithmetic x can be written m of arithmetic, x can be written s p (say p1).

y definition.

24

slide-13
SLIDE 13

Multiple Quantifiers: Multiple Quantifiers:

Now we need to prove tha Now we need to prove tha Which of the following sho

A. i Z+, i ≤ n → i divides n B. i Z+, i ≤ n i does not

  • C. i Z+, i ≤ p → i does not

D i Z i i d t

  • D. i Z+, i ≤ n → i does not

E. None of the above.

Unit 7- Proof Techniques

Example Example

t p > n t p > n. uld we prove?

n! divide x t divide x t di id t divide x

25

Multiple Quantifiers: Multiple Quantifiers:

Now the proof: Now the proof:

Pick an unspecified integer 2 ≤ Observe that Observe that x/i = (n! + 1) / i = n! / i + 1 Since 1· 2 ··· (i-1)·(i+1)··· n is integer, this means that x/i i Hence i does not divide x. Therefore every factor of x is g A d And p > n

Unit 7- Proof Techniques

Example Example

≤ i ≤ n. /i = 1· 2 ··· (i-1)·(i+1)··· n + 1/i an integer, but 1/i is not an s not an integer. greater than n

26

slide-14
SLIDE 14

Multiple Quantifiers: Multiple Quantifiers:

Another example: Another example:

Every even square can be consecutive odd integers consecutive odd integers.

x Z+, Even(x) Square(

How do we define: How do we define:

Square(x): SumOfTwoConsOdd(x): ( )

Unit 7- Proof Techniques

Example 2 Example 2

written as the sum of two

(x) → SumOfTwoConsOdd(x)

27

Multiple Quantifiers: Multiple Quantifiers:

Proof: Proof:

Consider an unspecified integ Assume that x is an even squa Assume that x is an even squa Hint: for every positive inte even. Th f b itt Therefore x can be written as integers.

Unit 7- Proof Techniques

Example 2 Example 2

er x are are. eger n, if n2 is even, then n is th f t ti dd the sum of two consecutive odd

28

slide-15
SLIDE 15

Unit Outline Unit Outline

T h i f di t

Techniques for direct proo

Existential quantifiers. Universal quantifiers.

Dealing with multiple quan Indirect proofs: contrapo Indirect proofs: contrapo Additional Examples

Unit 7- Proof Techniques

f fs. tifiers.

  • sitive and contradiction
  • sitive and contradiction

29

Indirect Proofs: Con Indirect Proofs: Con

Consider the following theo Consider the following theo

If the square of a positive integ

How can we prove this? How can we prove this? Let's try a direct proof.

Consider an unspecified integ Consider an unspecified integ Assume that n2 is even. So n2 = 2k for some (positive) So n 2k for some (positive) Hence . k

n 2 =

Then what?

Unit 7- Proof Techniques

trapositive trapositive

  • rem:
  • rem:

ger n is even, then n is even. er n er n. integer k integer k.

30

slide-16
SLIDE 16

Indirect Proofs: Con Indirect Proofs: Con

Consider instead the follow Consider instead the follow

If a positive integer n is odd, th

We can prove this easily: We can prove this easily:

Consider an unspecified posit Assume that n is odd Assume that n is odd. Hence n = 2k+1 for some integ Then n2 = (2k+1)2 = 4k2 + 4k + ( ) Therefore n2 is odd.

Unit 7- Proof Techniques

trapositive trapositive

wing theorem: wing theorem:

hen its square is odd. ive integer n. ger k. + 1 = 2(2k2+2k)+1 ( )

31

Indirect Proofs: Con Indirect Proofs: Con

What is the relationship be What is the relationship be

If the square of a positive integ

and and

If a positive integer n is odd, th

?

They are and hence

Unit 7- Proof Techniques

trapositive trapositive

etween etween

ger n is even, then n is even. hen its square is odd.

32

slide-17
SLIDE 17

Indirect Proofs: Proo Indirect Proofs: Proo

To prove: To prove:

Premise 1 ... Premise n Conclusion

We assume Premise 1, ...,

and then derive a contradic (p ^ ~p, x is odd ^ x is even

We then conclude that Con

Unit 7- Proof Techniques

  • f by Contradiction
  • f by Contradiction

, Premise n, ~Conclusion ction n, x < 5 ^ x > 10, etc). nclusion is true.

33

Indirect Proofs: Proo Indirect Proofs: Proo

Why are proofs by contrad Why are proofs by contrad

technique?

We proved We proved Premise 1 ^ ... ^ Premise n This is only true if y Premise 1 ^ ... ^ Premise n If Premise 1 ^ ... ^ Premise n then Premise 1 ^ ... ^ Premise n is true.

Unit 7- Proof Techniques

  • f by Contradiction
  • f by Contradiction

diction a valid proof diction a valid proof

n ^ ~Conclusion → F n ^ ~Conclusion ≡ F n ≡ F n → Conclusion

34

slide-18
SLIDE 18

Indirect Proofs: Proo Indirect Proofs: Proo

Otherwise Otherwise Premise 1 ^ ... ^ Premise n but Premise 1 ^ ... ^ Premise n Therefore ~Conclusion ≡ F which mea and so Premise 1 ^ ... ^ Premise n is true.

Unit 7- Proof Techniques

  • f by Contradiction
  • f by Contradiction

n ≡ T n ^ ~Conclusion ≡ F ans that Conclusion ≡ T n → Conclusion

35

Indirect Proofs: Proo Indirect Proofs: Proo

Example: Example:

Not every CPSC 121 student g midterm 1.

What are:

The premise(s)? p ( ) The negated conclusion?

Let us prove this theorem t

Unit 7- Proof Techniques

  • f by Contradiction
  • f by Contradiction

got an above average grade on

together.

36

slide-19
SLIDE 19

Indirect Proofs: Proo Indirect Proofs: Proo

Example: Example:

A group of CPSC 121 stude

  • tutorial. The TA is late, and

, each other. If every student student, then two of the stud number of people number of people.

What are

the premise(s)? the premise(s)? the negated conclusion? the negated conclusion?

Prove the theorem! Prove the theorem!

Unit 7- Proof Techniques

  • f by Contradiction
  • f by Contradiction

ents show up in a room for a so the students start talking to g t has talked to at least one other dents talked to exactly the same

37

Indirect Proofs: Proo Indirect Proofs: Proo

Another example: Another example:

Prove that for all real numb number, and y is an irration , y

What are

the premise(s)? p ( ) the negated conclusion?

Prove the theorem!

Unit 7- Proof Techniques

  • f by Contradiction
  • f by Contradiction

bers x and y, if x is a rational al number, then x+y is irrational. , y

38

slide-20
SLIDE 20

How should you tack How should you tack

Try the simpler methods fir Try the simpler methods fir

Witness proofs (if applicable Generalizing from the gener Generalizing from the gener Indirect proof using the cont Proof by contradiction. y

If you don't know if the theo

Alternate between trying to y g Use a failed attempt at one

Unit 7- Proof Techniques

kle a proof? kle a proof?

rst: rst:

e). ric particular ric particular. trapositive.

  • rem is true:

prove and disprove it. p p to help with the other.

39

How should you tack How should you tack

If you get stuck try looking If you get stuck, try looking

conclusion you want.

But don't forget the argume But don t forget the argume from the premises to the co around).

Try to derive all new facts y

premises without worrying ill h l will help.

If you are really stuck, ask

Unit 7- Proof Techniques

kle a proof? (cont') kle a proof? (cont )

g backwards from the g backwards from the

nt must eventually be written nt must eventually be written nclusion (not the other way

you can derive from the about whether or not they for help!

40

slide-21
SLIDE 21

Unit Outline Unit Outline

T h i f di t

Techniques for direct proo

Existential quantifiers. Universal quantifiers.

Dealing with multiple quan Indirect proofs: contraposit Indirect proofs: contraposit Additional Examples

Unit 7- Proof Techniques

f fs. tifiers. tive and contradiction tive and contradiction

41

Additional Examples Additional Examples

Prove that for every positiv Prove that for every positiv

integer, or it is irrational.

Prove that any circuit cons Prove that any circuit cons

XOR gates can be implem gates. gates.

Prove that if a, b and c ar

then at least one of a and b t e at east o e o a a d b by contradiction, and show c2-2.

Prove that there is a positiv

x + y ≤ c · max{ x, y } for e x and y.

Unit 7- Proof Techniques

s s

ve integer x either is an

x

ve integer x, either is an sisting of NOT OR AND and

x

sisting of NOT, OR, AND and ented using only NOR re integers, and a2+b2=c2, b is even. Hint: use a proof b s e e t use a p oo w that 4 divides both c2 and ve integer c such that every pair of positive integers

42

slide-22
SLIDE 22

Quiz 8 Quiz 8

Due Day and Time: Check Reading for Quiz 8:

E 4th diti 12 2 Epp, 4th edition: 12.2, page Epp, 3rd edition: 12.2, page Rosen 6th edition: 12 2 pag Rosen, 6th edition: 12.2 pag Rosen, 7th edition: 13.2 pag

Unit 7- Proof Techniques

k the announcements

791 t 795 es 791 to 795. es 745 to 747, 752 to 754 ges 796 to 798 12 3 ges 796 to 798, 12.3 ges 858 to 861, 13.3

43