Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2007-2014 Curt Hill Proofs An Introduction.

Similar presentations


Presentation on theme: "Copyright © 2007-2014 Curt Hill Proofs An Introduction."— Presentation transcript:

1 Copyright © 2007-2014 Curt Hill Proofs An Introduction

2 What is a Proof? A valid argument Shows the correctness of a statement Uses axioms, theorems and any hypotheses of the problem May be informal or formal Informal uses some shortcuts –Multiple transformations per step Formal tend to be publication quality –Long and difficult Copyright © 2007-2014 Curt Hill

3 Terminology Axioms –An unproven or unprovable given statement –These are self obvious or definitional Theorems –Statements of importance that have been proven Lemmas –Theorem of lesser importance –Often only used in the course of a proof Corollary –Theorem easy to prove from this one Conjectures or Suppositions –Statements we wish to prove –Today’s conjectures proven are tomorrow’s theorems

4 Types of Proofs Two basic forms, direct and indirect Direct –Start with hypotheses and argue towards the result Indirect –Any other direction –Two examples are proof by contraposition and proof by contradiction Copyright © 2007-2014 Curt Hill

5 What constitutes a proof? The usual proof is a series of steps Each step consists of three pieces: –An original statement –A transformed statement –The justification of the transformation The transformed statement is the original for the next step The justification must cite axioms or theorems The first two may be on one line or two

6 Copyright © 2007-2014 Curt Hill Proofs of Equivalence Conjectures are very often stated in terms of one thing equivalent to another In this case we can argue from one side to the other in either direction –Usually easier to go from more complicated to simpler –It reduces the combinatorics We may also consider the entire expression as the supposition –Then show that it is a tautology by reducing it to another tautology, that is an axiom or theorem

7 Implication Proofs Here the conjecture is an implication –Most common in Rosen We usually assert the antecedent Then use a series of steps to prove the consequent What happens if the antecedent is false? Copyright © 2007-2014 Curt Hill

8 Direct Example Prove that the sum of two odd integers is even We will need the definition of odd and even: –An integer n is even if there exists an integer k such that 2k = n –An integer n is odd if there exists an integer k such that 2k + 1 = n –Odd and even are opposites Assume that the propositions E(n) is true if n is even and O(n) is true if n is odd Copyright © 2007-2014 Curt Hill

9 Example Continues The statement of the conjecture is: –(O(n)  O(m))  E(n+m) More formally: –  n,m (n  I  m  I  O(n)  O(m))  E(n+m) Copyright © 2007-2014 Curt Hill

10 Sum of odds is even Let n be 2i+1 and m be 2j+1 –The definition of odd Let p = n+m p = 2i+1 + 2j+1 p= 2i+2j+1 + 1 –Algebraic commutativity p=2(i+j+1) –Algebraic distributivity p is even from definition of even Copyright © 2007-2014 Curt Hill

11 Contrapositive Proofs Recall that if p  q then  q   p –This is the contrapositive A proof by contraposition uses this as the starting point Instead of starting with p  q, instead start with  q   p Sometimes this easier However, it is an indirect proof since we did not start with the hypothesis Copyright © 2007-2014 Curt Hill

12 Commentary The distinction between direct and indirect gets a little fuzzy here Start with the hypothesis –That would be a direct proof As a first step apply the contrapositive Is it now direct or indirect? Lets do #17 or #18 on the board Copyright © 2007-2014 Curt Hill

13 Positive and Negative Proofs usually assume the theorem is true and argue it from there Recall sum of odds is even theorem –  n,m (n  I  m  I  O(n)  O(m))  E(n+m) I could disprove this by showing only one pair of n and m that made the antecedent true and the consequent false Thus if I prove –  n,m (n  I  m  I  O(n)  O(m))  O(n+m) then I have disproved original

14 Proof by Contradiction Can also be quite effective but often easier State the theorem as false and show that there is a contradiction by reasoning to a known fallacy This fallacy is usually the opposite of a theorem or axiom This form is almost always backwards Copyright © 2007-2014 Curt Hill

15 Halting Problem It is impossible to code a procedure that will input an arbitrary procedure and its input and determine if it halts Its output will be true if the program will halt with this data It will output false if the program has an infinite loop with this data This is a specific case of static analysis Copyright © 2007-2014 Curt Hill

16 Proof 1 of 2 Suppose that a procedure exists that flawlessly solves the halting problem –Call this procedure Q(P,I) where P is the input procedure and I is the input We construct a procedure R as follows: –if(Q(R,R)) – while(true) – println(“oops”) –else println(“It will halt”); Copyright © 2007-2014 Curt Hill

17 Proof 2 of 2 What is the result when R is fed into Q? If Q says R halts, then R infinitely loops If Q says R loops, then R halts Since Q cannot give the right answer for this example, there is a contradiction Thus no procedure that can solve the halting problem Copyright © 2007-2014 Curt Hill

18 Proof Commentary This proof was done in 1936 by Alan Turing –The proof by contradiction is simple –What would a direct proof look like? What does this theorem not say? –It does not say that static analysis is completely impossible –It says that static analysis is impossible to complete Most compiler writers use this as an excuse to do little static analysis Copyright © 2007-2014 Curt Hill

19 How many primes? Can we prove that there are an infinite number of primes? –Yes, by contradiction Assume that there are a finite number of primes Take these primes and multiply all of them together Add 1 The resulting number is not divisible by any of the primes –Thus there are an infinite number of primes Copyright © 2007-2014 Curt Hill

20 Almost Finally The only thing easier to mess up than a program is a proof –The text lists several –You will likely find others This presentation is not the end all on proofs –Rather it is just the beginning –We enlarge our tool set in the next one Copyright © 2007-2014 Curt Hill

21 Exercises 3, 9, 27, 39 Copyright © 2007-2014 Curt Hill


Download ppt "Copyright © 2007-2014 Curt Hill Proofs An Introduction."

Similar presentations


Ads by Google