Presentation is loading. Please wait.

Presentation is loading. Please wait.

Methods of Proof.

Similar presentations


Presentation on theme: "Methods of Proof."— Presentation transcript:

1 Methods of Proof

2 Deductive proof: Inductive proof:
Used extensively in geometry & trigonometry Not very important in this class Inductive proof: Basis of most automata theory Proficiency in induction is a learning objective of this class

3 Deductive proof Step-by-step argument from given information to a conclusion “from the information that you gave me, I deduce that ….” No internal assumptions are allowed Example: proving that sets are equivalent

4 Proving equivalences about sets
In automata theory frequently ask “Are sets constructed in different ways actually the same set?” Elements of sets are usually strings; hence sets are called “languages” Statement “set E = set F” means every element in E is in F and every element in F is in E

5 Equivalent sets set E = set F is example of “if and only if”
Element x is in E if and only if x is in F To prove E = F must prove two if…then statements If x is in E then x is in F If x is in F then x is in E

6 Background on sets If x  A implies x  B, then A is a subset of B (written A  B) If, in addition, A  B then A is a proper subset of B (written A  B)  A  B = intersection of sets A and B defined by {x: x  A and x  B } A  B = union of sets A and B defined by {x: x  A or x  B }

7 More background on sets
A - B = difference of sets A and B defined by {x: x  A and x  B } Let T be complement of S with respect to U then SU, TU, ST = U, and ST = null Sets obey laws similar to numbers (commutative, associative, distributive, etc)

8 Proof of distributive law of sets
R(ST) = (RS)(RT) Let E = R(ST) Let F = (RS)(RT) Must prove if x is in E then x is in F if x is in F then x is in E

9 Proof of distributive law of sets: part 1
if x  R(ST) then x  R or x  (ST) (def. of union) x  R or x  S and x  T (def. of intersection) x  RS (def. of union) x  RT (def. of union) x  (RS)(RT) (def. of intersection) Therefore if x is in E then x is in F

10 Proof of distributive law of sets: part 2
if x  (RS)(RT) then x  RS (def. of intersection) x  RT (def. of intersection) x  R or x  S and x  T (logic?) x  R or x  (ST) (def. of intersection) x  R(ST) (def. of union) Therefore if x is in F then x is in E

11 Logic of “If H then C” Given 2 statements, hypothesis H and conclusion C, exactly one of following is the case: 1. H and C are both true 2. H is true and C is false 3. H is false and C is true 4. H and C are both false Only (2) makes “if H then C” false (3) does not apply to “if H then C” In both (1) and (4) “if H then C” is true

12 Contrapositives The contrapositive of “if H then C” is
“if not C then not H” New hypothesis is “not C” New conclusion is “not H” 4 cases of previous slide still apply

13 Logic of “If not C then not H”
Given statements not C and not H, exactly one of following is the case: 1. not C and not H are both true 2. not C is true and not H is false 3. not C is false and not H is true 4. not C and not H are both false Only (2) makes “if not C then not H” false (3) does not apply to “if not C then not H ” In both (1) and (4) “if not C then not H” is true hence “if not C then not H” is equivalent to “if H then C” and may be easier to prove

14 Contrapositive question
What is the contrapositive of “if x > 4 then 2x > x2”

15 Proof by contradiction
Proving that “if H then not C” is false is equivalent to proving “if H then C” Example using complement of a set

16 Proof by contradiction
Given: T is the complement of S with respect to U Prove: If S is finite and U is infinite, then T is infinite Hypothesis has 3 parts T is complement of S S is finite U is infinite Conclusion is “T is infinite” not C is “T is finite”

17 Proof by contradiction
assume T is finite (i.e. not C) then ||T||=some integer m Given S is finite; therefore ||S||=some integer n T is complement of S with respect to U; therefore; ST = U and ST = null Hence, ||U||=m+n, which -> U is finite Therefore “if H then not C” contradicts the part of H that U is infinite This proves “if H then C”

18 Inductive proof Many types of induction
Induction on integers is probably the most familiar

19 Induction on integers S(n) is statement about integers we want to prove Base case establishes truth of the statement for n=is typically the smallest integer where statement is true Inductive step proves statement for n>is typically by “if S(n) then S(n+1)” “if S(n)” is called the “inductive hypothesis”

20 Setup to use inductive hypothesis Statement of inductive hypothesis
I require a “structured” proof. The follow elements must be present and identified. Proof of base case Setup to use inductive hypothesis Statement of inductive hypothesis Application of inductive hypothesis Algebra that completes the proof All algebraic operations must be on the right-hand-side of equals sign

21 Assignment #1 Due 8-25-17 k=1 to n k = n(n+1)/2
Using the approach if S(n) then S(n+1), give a structured proof that k=1 to n k = n(n+1)/2

22 “if S(n-1) then S(n)” is equivalent to
apply “if S(n-1) then S(n)” to assignment 1

23 Structured Proof of j=1 to n j = n(n+1)/2 by if S(n-1) then S(n)
Base case n=1 j=1 to 1 j =? 1(1+1)/2 Setup equation

24 Induction in recursive definitions
Example: definition of tree Base case: a single node is a tree Induction: the structure obtained by adding a node to the root of a tree is a tree Note: this definition is not general What is the structure of tree it defines? Prove: in a tree the #of nodes = #of edges+1 Hint: use if S(n-1) then S(n).

25 Structural Induction Prove: in every tree #of nodes = #of edges+1
Basis: true for single-node tree (no edges) IH: assume #of nodes = #of edges+1 is true for a tree with n-1 nodes Induction: As defined in the previous slide, a tree with n nodes can be obtained from a tree with n-1 nodes by attaching a node to the root. Adding a node requires adding an edge; hence, the n-node tree has both one more node and one more edge than the n-1 node tree. Therefore #of nodes = #of edges+1 applies to the n-node tree.

26 Mutual induction on integers
An inductive hypothesis may have several facets If all facets depend on a common value of an integer, then we have “mutual induction on integers”

27 Example of mutual induction on integers
Given that the start state of the switch automaton is “off” prove the following: off push on Start S1(n): automaton is in the off state after n pushes iff n is even S2(n): automaton is in the on state after n pushes iff n is odd

28 Both S1(n) and S2(n) are iff
off push on Start Given that switch starts in “off” we must prove that after n pushes … If switch is off, then n is even If n is even, then switch is off If switch is on, then n is odd If n is odd, then switch is on

29 Prove: if switch is off then n is even
push on Start Basis: in start state switch is off and n=0, which is even. IH: if switch is on then k is odd Let k=n-1 One more push tunes switch off If n-1 is odd then n is even Similar proofs for S2(n)

30 Prove: if n is even then switch is off
push on Start Basis: n=0 is true. Zero is even by definition and switch starts in off. IH: if k is odd then switch is on If n is even then n-1 is odd By IH, switch is on after n-1 pushes One more push tunes switch off

31

32 Structural Induction Automata theory involves recursive definitions that become the subject of inductive proofs. Example: recursive definition of a tree Basis: single node is a tree IH: assume that T1, … Tk are trees Induction: connect then to the node that is root of a recursively defined tree

33 Structural induction 2 Prove: in every tree n = e +1, where n is the number of nodes and e is the number of edges Basis: true for single-node tree IH: assume ni=ei+1 true for trees T1, …, Tk Induction: n=1+n1+n2+…+nk = 1+(e1+1)+…+(ek+1) n=1+k+e1+…+ek = 1+e

34 Switch automaton Nodes are states; Arcs are transitions
off push on Start Nodes are states; Arcs are transitions Arcs labeled by strings that induce the indicated transitions Arrow indicates the start state

35 Data transfer automaton
Ready Sending data in done timeout Start Data induces transition to sending Loop keeps automaton in sending state until transmission is done “Ready” and “Sending” are complex states Many conditions must be met for automaton to be in these states

36 Mutual Induction 3 off push on Start “switch” automata is always in exactly one state. Not generally true one-state character of switch makes this example of mutual induction artificial Proof of S1(n) implies the truth of S2(n) Text treats as mutual induction

37 Loop invariant and induction
Loop invariant is statement about iterative algorithm Prove the statement is true by induction Show true before 1st iteration (base case or initialization) If true on ith iteration (inductive hypothesis) remains true before i+1 iteration (maintenance)

38 Loop invariant Termination
Aspect of loop invariant analysis that goes beyond general inductive proof Having establish that the loop invariant is true, statement of the loop invariant when looping terminates proves the correctness of the iterative algorithm

39 Example: Sort by insertion

40 Validation is usual approach in code development
Test code for some simple cases were hand calculation is practical If a “validated” code fails, usually learn something important In CS 317 get some practice with formal proofs


Download ppt "Methods of Proof."

Similar presentations


Ads by Google