See section 1.2-1.3 of course notes Colin Morris colin@cs...
Transcript of See section 1.2-1.3 of course notes Colin Morris colin@cs...
![Page 1: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/1.jpg)
CSC236 winter 2020, week 3: structural induction, well-orderingSee section 1.2-1.3 of course notes
Colin [email protected]
http://www.cs.toronto.edu/~colin/236/W20/
January 20, 2020
![Page 2: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/2.jpg)
Outline
Well-orderingPrinciple of well-orderingExample: prime factorizations, revisitedExample: round-robin tournament cycles
Structural inductionIntroductionExample: complete binary treesComparison with simple inductionExample: strings of matching parentheses
![Page 3: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/3.jpg)
Principle of well-ordering
Every non-empty subset of N has a smallest element.
Surprisingly, turns out to be equivalent to principle of mathematical induction /complete induction. (Theorem 1.1 in Vassos course notes)
![Page 4: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/4.jpg)
Every n > 1 has a prime factorization
For sake of contradiction, assume this is false. i.e.
S = {n ∈ N | n > 1 ∧ n is not the product of primes}
is non-empty. By PWO, S has a smallest element, call it j .
Case 1: j is prime. Contradiction!Case 2: j is composite. Let a, b ∈ N such that j = a× b ∧ 1 < a < j ∧ 1 < b < j (bydefinition of composite).a, b /∈ S , since j was chosen to be the smallest element. So a and b each have a primefactorization. We can concatenate them to form a prime factorization of j .Contradiction!In each case, we derived a contradiction, so our premise is false. S must be empty.∀n ∈ N− {0, 1}, n has a prime factorization.
![Page 5: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/5.jpg)
Every n > 1 has a prime factorization
For sake of contradiction, assume this is false. i.e.
S = {n ∈ N | n > 1 ∧ n is not the product of primes}
is non-empty. By PWO, S has a smallest element, call it j .Case 1: j is prime. Contradiction!Case 2: j is composite. Let a, b ∈ N such that j = a× b ∧ 1 < a < j ∧ 1 < b < j (bydefinition of composite).a, b /∈ S , since j was chosen to be the smallest element. So a and b each have a primefactorization. We can concatenate them to form a prime factorization of j .Contradiction!In each case, we derived a contradiction, so our premise is false. S must be empty.∀n ∈ N− {0, 1}, n has a prime factorization.
![Page 6: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/6.jpg)
Round-robin tournament cycles
Round-robin tournament ≡ every player faces every other player once.Consider “cycles” of matchups such as...
I Naomi beats Kim
I Kim beats Monica
I Monica beats Serena
I Serena beats Naomi
Claim: Any round-robin tournament having at least one cycle has a 3-cycle.
![Page 7: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/7.jpg)
Proof: if a RR tournament has a cycle, it has a 3-cycle
![Page 8: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/8.jpg)
Recursively defined sets
Sets defined in terms of one or more ‘simple’ examples, plus rules for generatingelements from other elements.
Example:
I A single node is a complete binary tree
I If t1 and t2 are complete binary trees, then a new node joined to t1 and t2 as itschildren form a complete binary tree
We can use structural induction to prove properties of such sets.
![Page 9: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/9.jpg)
Structural induction proof outline
For some recursively defined set S ...
1. Define predicate with domain S
2. Basis: verify P(x) for ‘basic’ element(s) x ∈ S
3. Inductive step: show that each rule that generates other elements of S preservesP-ness. i.e. for each rule...
3.1 Choose arbitrary elements of S3.2 Assume predicate holds for those elements3.3 Use assumption to show that P(z) holds, where z is an element generated from our
previously chosen elements.
![Page 10: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/10.jpg)
Prove: all complete binary trees have an odd number of nodes1. Predicate
![Page 11: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/11.jpg)
Prove: all complete binary trees have an odd number of nodes2. Basis
![Page 12: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/12.jpg)
Prove: all complete binary trees have an odd number of nodes3. Inductive step
![Page 13: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/13.jpg)
Compare with simple induction
Define N as the smallest1 set such that:
1. 0 ∈ N2. n ∈ N =⇒ n + 1 ∈ N
1Why is this necessary?
![Page 14: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/14.jpg)
Strings with matching parentheses
Define B as the smallest set such that...
1. ε ∈ B # where ε denotes the empty string
2. If b ∈ B, then (b) ∈ B3. If b1, b2 ∈ B, then b1b2 ∈ B # closed under concatenation
Examples of elements?
![Page 15: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/15.jpg)
A claim about B
Define...
I L(s) = # of occurrences of ( in s
I R(s) = # of occurrences of ) in s
Claim: ∀s ∈ B, if s ′ is a prefix of s, then L(s ′) ≥ R(s ′).
![Page 16: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/16.jpg)
Prove: prefixes of strings of balanced parens are left-heavy
P(s) :
Basis:
![Page 17: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/17.jpg)
Prove: prefixes of strings of balanced parens are left-heavyInductive step
![Page 18: See section 1.2-1.3 of course notes Colin Morris colin@cs ...colin/236/W20/lecture_slides/w3_lec2_annotated.pdfCase 2: j is composite. Let a;b 2N such that j = a b ^1](https://reader035.fdocuments.in/reader035/viewer/2022071408/61000c9d0a45bb43692a9983/html5/thumbnails/18.jpg)
Prove: prefixes of strings of balanced parens are left-heavyInductive step