1.6 - UCSB Computer Science

advertisement
Introduction to Proofs
Goals
1. Introduce notion of proof & basic proof methods.
2. Distinguish between correct & incorrect arguments
3. Understand & construct basic types of proofs.
Introduction
• Proof: A valid argument establishing the truth of a
mathematical statement.
• In CS, we want to prove
– the correctness of an algorithm or program
– more generally, a property of an algorithm/data
structure, program, or system
(e.g., Java can be parsed efficiently?)
–
–
–
–
AI strategies, automated theorem proving
the consistency/feasibility of a specification
consequences of a mathematical model of computing
...
Copyright © Peter Cappello
2
Methods for Proving Theorems
•
A theorem typically is of the form
x ( P( x )  Q( x ) ).
•
The proof method typically is of the form
1. Let c be an arbitrary element in the domain.
2. Show that P( c )  Q( c ) is true. (The essence.)
3. Therefore, x ( P( x )  Q( x ) ).
Copyright © Peter Cappello
3
Direct Proof of p  q
1.
Assume that p is true.
2.
Show that q is true.
Example
–
Let the domain be the integers.
–
Prove: x ( ( 3 | x – 2 )  ( 3 | x2 – 1 ) )
Proof: WHAT
WHY
1.
Let x be an arbitrary integer such that 3 | x – 2.
2.
Let integer q = ( x – 2 ) / 3.
(from step 1 & definition of “|”)
3.
x = 3q + 2.
(algebraic manipulation of step 2)
(premise)
4. x2 = ( 3q + 2 )2 = 9q2 + 12q + 4 = 3( 3q2 + 4q + 1 ) + 1.
5. x2 – 1 = 3( 3q2 + 4q + 1 ).
6. 3 | x2 – 1.
(subtract 1 from both sides of step 4)
(from step 5 & definition of the meaning of “|”)
7. Therefore, x ( ( 3 | x – 2 )  ( 3 | x2 – 1 ) )
Copyright © Peter Cappello
(Universal Generalization)
4
Proof by Contraposition of p  q
Direct proof of the contrapositive: ~q  ~p
1. Assume q is false.
2. Show that p is false.
Copyright © Peter Cappello
5
Proof by Contraposition of p  q
Example
The domain is the set of integers.
Prove: a b ( (ab is even)  (a is even  b is even) )
Proof WHAT
WHY
1. Let a, b be arbitrary integers.
2. Assume (a is even  b is even).
3. a is odd  b is odd.
(De Morgan’s law)
4. m ( a = 2m + 1 )  n ( b = 2n + 1 ).
(Defn. of odd.)
5. ab = (2m + 1)(2n + 1)
= 4mn + 2m + 2n + 1
= 2(2mn + m + n) + 1 which is odd.
6. a b ( (ab is even)  (a is even  b is even) ) (U.G.)
Copyright © Peter Cappello
6
Proof by Contradiction of p  q
Show p  q is true by showing that
(p  q) ≡ ( p  q) ≡ (p  q) is false:
1. Assume p  q.
2. Show that this leads to a contradiction.
If you need to show  x P( x )
You may assume x P( x ), then show that this leads to a contradiction.
Copyright © Peter Cappello
7
Example
If
1, 2, …, 10 are placed randomly in a circle
then the sum of some 3 adjacent numbers  17.
Proof:
1. Place 1, 2, …, 10 randomly in a circle.
(Premise)
2. Assume that the sum of no 3 adjacent numbers  17.
3. Then, x1 + x2 + x3  16
(explain with diagram)
x2 + x3 + x4  16
x3 + x4 + x5  16
…
x10 + x1 + x2  16.
4. Sum the 10 inequalities:
3( x1 + x2 + . . .+ x10 )  16  10 = 160 
3(1 + 2 + … + 10)  160 
3*55 = 165  160, a contradiction.
5. Our assumption is false:
If 1, 2, …, 10 are placed randomly in a circle then the sum of some 3 adjacent numbers  17.
Copyright © Peter Cappello
8
Proving p  q
p  q ≡ (p  q)  (q  p)
≡ (p  q)  (p   q)
To prove p  q it is necessary &
sufficient to show either:
(p  q)  (q  p), or equivalently
(p  q)  (p   q)
Copyright © Peter Cappello
9
Presentation
Perhaps the clearest proof presentation:
– Give a numbered list of statements, where the last
statement is the statement to be proved
– For each statement, explain why its truth follows from:
• previous statements
• premises
• previously established mathematical facts or definitions.
Copyright © Peter Cappello
10
Download