Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Quiz Friday 8-29 Lectures: introduction and methods of proof Text: pp 1-26.

Similar presentations


Presentation on theme: "1 Quiz Friday 8-29 Lectures: introduction and methods of proof Text: pp 1-26."— Presentation transcript:

1 1 Quiz Friday 8-29 Lectures: introduction and methods of proof Text: pp 1-26

2 2 Methods of Proof

3 u Deductive proof: wUsed extensively in geometry & trigonometry wNot very important in this class u Inductive proof: wBasis of most automata theory wProficiency in induction is a primary objective of this class 3

4 Deductive proof uStep-by-step argument from given information to a conclusion u“from the information that you gave me, I deduce that ….” uNo internal assumptions are allowed uExample: proving that sets are equivalent 4

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

6 Equivalent sets 2 u set E = set F is example of “if and only if” uElement x is in E if and only if x is in F uTo prove E = F must prove 2 if…then statements wIf x is in E then x is in F wIf x is in F then x is in E 6

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

8 Background on sets 2 uA - B = difference of sets A and B defined by {x: x  A and x  B } uLet T be complement of S with respect to U then S  U, T  U, S  T = U, and S  T = null uSets obey laws similar to numbers (commutative, associative, distributive, etc) 8

9 Proof of distributive law of sets uR  (S  T) = (R  S)  (R  T) uLet E = R  (S  T) uLet F = (R  S)  (R  T) uMust prove wif x is in E then x is in F wif x is in F then x is in E 9

10 Proof of distributive law of sets 2 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) 10

11 Proof of distributive law of sets 3 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 (why?) x  R or x  (S  T) (def. of intersection) x  R  (S  T) (def. of union) 11

12 Contrapositives uGiven hypothesis H and conclusion C, one of following cases is true w1. H and C are both true w2. H is true and C is false w3. H is false and C is true w4. H and C are both false 12 uOnly (2) makes “if H then C” false u(3) does not apply to “if H then C” uIn both (1) and (4) “if H then C” is true

13 Contrapositives 2 uContrapositive of “if H then C” is “if not C then not H” wHypothesis is “not C” wConclusion is “not H” w4 cases of previous slide still apply 13 uOnly (2) makes “if not C then not H” false u(3) does not apply to “if not C then not H” uIn (1) and (4) “if not C then not H” is true uhence “if not C then not H” is equivalent to “if H then C” and may be easier to prove

14 Contrapositive 3 uContrapositive of “if x > 4 then 2 x > x 2” is “if 2 x < x 2 then x < 4” uSometimes contrapositive is easier to prove. uCan this contrapositive be proved by algebra? 14

15 Proof by contradiction Proving “if H and not C -> falsehood” is equivalent to proving “if H then C” Example using complement of a set 15

16 Proof by contradiction 2 uT is the complement of S with respect to U then S  U, T  U, S  T = U, and S  T = null uIf S is finite and U is infinite, then T is infinite uHypothesis has 3 parts wT is complement of S wS is finite wU is infinite uConclusion is “T is infinite” unot C is “T is finite” 16

17 Proof by contradiction 3 uIf T is finite, then ||T||=some integer m uS is finite; therefore ||S||=some integer n uT is complement of S with respect to U; therefore; S  T = U and S  T = null uHence, ||U||=m+n uBy definition, this means U is finite uH and not C contradicts part of H uThis proves “if H then C” 17

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

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

20 How I grade inductive proofs u Proof of base case u Statement of inductive hypothesis u How inductive hypothesis is used wBasis for algebra that completes the proof wAll algebraic operations are on the rhs of equals sign 20

21 Assignment #1 Due 9-3-14 21 Prove by induction on integers that  k=1 to n k = n(n+1)/2 Your proof must include the following: (1) truth of base case (2) statement of inductive hypothesis (3) correct application of inductive hypothesis

22 22 uBasis can consist of a range of i values, all of which must be used in the inductive step. u“if S(n-1) then S(n)” is equivalent to “if S(n) then S(n+1)” uExample: if S(n-1) then S(n) applied to assignment 1 Exceptions to typical approach

23 23 Prove  j=1 to n j = n(n+1)/2 Base case n=1  j=1 to 1 j = 1(1+1)/2

24 24 Review Induction used 2 ways in the class recursive definitions proofs Both have 3 parts base case assumption (IH) induction Example: definition of tree and proof that n=e+1

25 Structural Induction uAutomata theory involves recursive definitions that become the subject of inductive proofs. uExample: recursive definition of a tree wBasis: single node is a tree wIH: assume that T 1, … T k are trees wInduction: connect then to the node that is root of a recursively defined tree 25

26 Structural induction 2 uProve: in every tree n = e +1, where n is the number of nodes and e is the number of edges uBasis: true for single-node tree uIH: assume n i =e i +1 true for trees T 1, …, T k uInduction: wn=1+n 1 +n 2 +…+n k = 1+(e 1 +1)+…+(e k +1) wn=1+k+e 1 +…+e k = 1+e 26

27 Switch automaton uNodes are states; Arcs are transitions uArcs labeled by strings that induce the indicated transitions uArrow indicates the start state 27 off push on Start push

28 Data transfer automaton uData induces transition to sending uLoop keeps automaton in sending state until transmission is done u“Ready” and “Sending” are complex states uMany conditions must be met for automaton to be in these states 28 ReadySending data in done timeout Start

29 Mutual Induction uAn inductive hypothesis may have several facets uExample: all the conditions necessary to put an automaton in a certain state uIf all facets depend on a common value of an integer, then we have “mutual induction” 29

30 Example of Mutual Induction uS1(n): automaton in the off state after n pushes iff n is even uS2(n): automaton is in the on state after n pushes iff n is odd 30 off push on Start push Prove the following about the “switch” automaton

31 Both S 1 (n) and S 2 (n) are iff uIf n is even, then switch is off uIf switch is off, then n is even uIf n is odd, then switch is on uIf switch is on, then n is odd 31 off push on Start push Given that switch starts in “off” we must prove that after n pushes …

32 Prove : if n is even then switch is off uIH: if k is odd then switch is on uIf n is even then n-1 is odd uBy IH, switch is on after n-1 pushes uOne more push tunes switch off uSimilar proof for other 3 statements 32 off push on Start push Basis: n=0 true zero even by definition and switch starts in off

33 33

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

35 Loop invariant and induction uLoop invariant is statement about iterative algorithm uProve the statement is true by induction uShow true before 1 st iteration (base case or initialization) uIf true on i th iteration (inductive hypothesis) remains true before i+1 iteration (maintenance) 35

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

37 Example: Sort by insertion 37

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


Download ppt "1 Quiz Friday 8-29 Lectures: introduction and methods of proof Text: pp 1-26."

Similar presentations


Ads by Google