Induction II: Inductive Pictures Great Theoretical Ideas In Computer Science Steven RudichCS 15-251 Spring 2005 Lecture 2Jan 13, 2005Carnegie Mellon University.

Slides:



Advertisements
Similar presentations
Chapter 2 Revision of Mathematical Notations and Techniques
Advertisements

Trees Chapter 11.
Induction and Recursion. Odd Powers Are Odd Fact: If m is odd and n is odd, then nm is odd. Proposition: for an odd number m, m k is odd for all non-negative.
Discrete Structures & Algorithms Counting Counting I: One-To-One Correspondence and Choice Trees.
Induction: One Step At A Time Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 4Jan 22, 2004Carnegie Mellon University.
Counting I: One To One Correspondence and Choice Trees Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 9Feb 10,
Costas Busch - RPI1 Mathematical Preliminaries. Costas Busch - RPI2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Grade School Revisited: How To Multiply Two Numbers Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 16March 4,
1 Recitation 10. Induction Introduction. Induction is useful in proving properties of recursive algorithms, like their execution times. It is also the.
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
Theoretical Computer Science COMP 335 Fall 2004
Induction and recursion
Graph Algorithms Using Depth First Search Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
Great Theoretical Ideas in Computer Science for Some.
Applied Discrete Mathematics Week 9: Relations
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
Induction and recursion
 We noticed in Section 2.3 that the limit of a function as x approaches a can often be found simply by calculating the value of the function at a.  Functions.
Analysis of Algorithms
Multiway Trees. Trees with possibly more than two branches at each node are know as Multiway trees. 1. Orchards, Trees, and Binary Trees 2. Lexicographic.
Tree A connected graph that contains no simple circuits is called a tree. Because a tree cannot have a simple circuit, a tree cannot contain multiple.
Counting III: Pascal’s Triangle, Polynomials, and Vector Programs Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2003 Lecture.
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
Fall 2005Costas Busch - RPI1 Mathematical Preliminaries.
Prof. Busch - LSU1 Mathematical Preliminaries. Prof. Busch - LSU2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Induction Proof. Well-ordering A set S is well ordered if every subset has a least element. [0, 1] is not well ordered since (0,1] has no least element.
Great Theoretical Ideas in Computer Science.
Discrete Structures & Algorithms More on Methods of Proof / Mathematical Induction EECE 320 — UBC.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
COMPSCI 102 Discrete Mathematics for Computer Science.
Inductive Reasoning Great Theoretical Ideas In Computer Science Victor AdamchikCS Spring 2010 Lecture 2Jan 14, 2010Carnegie Mellon University.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Great Theoretical Ideas in Computer Science.
Foundations of Discrete Mathematics Chapters 5 By Dr. Dalia M. Gil, Ph.D.
CompSci 102 Discrete Math for Computer Science March 20, 2012 Prof. Rodger Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily.
Counting I: One To One Correspondence and Choice Trees Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 9Feb 10,
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
1 Mathematical Preliminaries. 2 Sets Functions Relations Graphs Proof Techniques.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Great Theoretical Ideas in Computer Science for Some.
Counting I: One To One Correspondence and Choice Trees Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2005 Lecture 6Sept 15,
COMPSCI 102 Introduction to Discrete Mathematics.
Induction II: Inductive Pictures Great Theoretical Ideas In Computer Science Anupam GuptaCS Fall 2005 Lecture 3Sept 6, 2005Carnegie Mellon University.
Great Theoretical Ideas in Computer Science.
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar Dr Nazir A. Zafar Advanced Algorithms Analysis and Design.
Induction: One Step At A Time
Great Theoretical Ideas In Computer Science
Great Theoretical Ideas in Computer Science
Great Theoretical Ideas in Computer Science
Great Theoretical Ideas in Computer Science
Advanced Algorithms Analysis and Design
Grade School Revisited: How To Multiply Two Numbers
Graph Algorithms Using Depth First Search
Great Theoretical Ideas in Computer Science
Counting I: Bijection and Choice Trees
Induction II: Inductive Pictures
Induction II: Inductive Pictures
Counting I: One-To-One Correspondence and Choice Trees
Induction: One Step At A Time
Induction: One Step At A Time
Grade School Revisited: How To Multiply Two Numbers
Mathematical Preliminaries
Induction II: Inductive Pictures
Induction: One Step At A Time
Counting I: Choice Trees and Correspondences
Presentation transcript:

Induction II: Inductive Pictures Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2005 Lecture 2Jan 13, 2005Carnegie Mellon University

Inductive Proof: “Standard” Induction “Least Counter-example” “All Previous” Induction Inductive Definition: Recurrences Recursive Programming

Theorem ? (k ¸ 0) …+2 k = 2 k Try it out on small examples: 2 0 = = =

S k ´ “ …+2 k = 2 k+1 -1” Use induction to prove  k ¸ 0, S k Establish “Base Case”: S 0. We have already check it. Establish “Domino Property”:  k ¸ 0, S k ) S k+1 “Inductive Hypothesis” S k : …+2 k = 2 k+1 -1 Add 2 k+1 to both sides: …+2 k + 2 k+1 = 2 k+1 +2 k …+2 k + 2 k+1 = 2 k+2 -1

FUNDAMENTAL LEMMA OF THE POWERS OF TWO: The sum of the first n powers of 2, is one less than the next power of 2.

Yet another way of packaging inductive reasoning is to define an “invariant”. Invariant (adj.) 1.Not varying; constant. 2.(mathematics) Unaffected by a designated operation, as a transformation of coordinates.

Yet another way of packaging inductive reasoning is to define an “invariant”. Invariant (adj.) 3. (programming) A rule, such as the ordering an ordered list or heap, that applies throughout the life of a data structure or procedure. Each change to the data structure must maintain the correctness of the invariant.

Invariant Induction Suppose we have a time varying world state: W 0, W 1, W 2, … Each state change is assumed to come from a list of permissible operations. We seek to prove that statement S is true of all future worlds. Argue that S is true of the initial world. Show that if S is true of some world – then S remains true after one permissible operation is performed.

Odd/Even Handshaking Theorem: At any party, at any point in time, define a person’s parity as ODD/EVEN according to the number of hands they have shaken. Statement: The number of people of odd parity must be even. Initial case: Zero hands have been shaken at the start of a party, so zero people have odd parity. If 2 people of different parities shake, then they both swap parities and the odd parity count is unchanged. If 2 people of the same parity shake, they both change. But then the odd parity count changes by 2, and remains even.

Inductive Definition of n! [said n “factorial”] 0! = 1; n! = n*(n-1)!

F:=1; For x = 1 to n do F:=F*x; Return F Program for n! ?

0! = 1; n! = n*(n-1)! F:=1; For x = 1 to n do F:=F*x; Return F Program for n! ? n=0 returns 1 n=1 returns 1 n=2 returns 2

0! = 1; n! = n*(n-1)! F:=1; For x = 1 to n do F:=F*x; Return F Loop Invariant: F=x! True for x=0. If true after k times through – true after k+1 times through.

Inductive Definition of T(n) T(1) = 1 T(n) = 4T(n/2) + n Notice that T(n) is inductively defined for positive powers of 2, and undefined on other values.

Inductive Definition of T(n) T(1) = 1 T(n) = 4T(n/2) + n Notice that T(n) is inductively defined for positive powers of 2, and undefined on other values. T(1)=1T(2)=6T(4)=28T(8)=120

Guess a closed form formula for T(n). Guess G(n) G(n) = 2n 2 - n Let the domain of G be the powers of two.

Two equivalent functions? G(n) = 2n 2 - n Let the domain of G be the powers of two. T(1) = 1 T(n) = 4 T(n/2) + n Domain of T are the powers of two.

Inductive Proof of Equivalence Base: G(1) = 1 and T(1) = 1 Induction Hypothesis: T(x) = G(x) for x < n Hence: T(n/2) = G(n/2) = 2(n/2) 2 – n/2 T(n) = 4 T(n/2) + n = 4 G(n/2) + n = 4 [2(n/2) 2 – n/2] + n = 2n 2 – 2n + n = 2n 2 – n = G(n) G(n) = 2n 2 - n T(1) = 1 T(n) = 4 T(n/2) + n

We inductively proved the assertion that G(n) =T(n). Giving a formula for T with no sums or recurrences is called solving the recurrence T.

Solving Recurrences Guess and Verify Guess: G(n) = 2n 2 – n Verify: G(1) = 1 and G(n) = 4 G(n/2) + n Similarly: T(1) = 1 and T(n) = 4 T(n/2) + n So T(n) = G(n)

Technique 2 Guess Form and Calculate Coefficients Guess: T(n) = an 2 + bn + c for some a,b,c Calculate: T(1) = 1  a + b + c = 1 T(n) = 4 T(n/2) + n  an 2 + bn + c = 4 [a(n/2) 2 + b(n/2) + c] + n = an 2 + 2bn + 4c + n  (b+1)n + 3c = 0 Therefore: b=-1 c=0 a=2

A computer scientist not only deals with numbers, but also with Finite Strings of symbols Very visual objects called graphs And especially, especially the special graphs called trees

GRAPHS b root a

Definition: Graphs A graph G = (V,E) consists of a finite set V of vertices (nodes) and a finite set E of edges. Each edge is a set {a, b} of two different vertices. A graph may not have self loops or multiple edges.

Definition: Directed Graphs A graph G = (V,E) consists of a finite set V of vertices (nodes) and a finite set E of edges. Each edge is an ordered pair of two different vertices. Unless we say otherwise, our directed graphs will not have multi-edges, or self loops.

Definition: Tree A tree is a directed graph with one special node called the root and the property that each node must a unique path from the root to itself. Child: If 2 E, we sav is a child of u Parent: If 2 E, we say u is the parent of u Leaf: If u has no children, we say u is leaf. Siblings: If u and v have the same parent, they are siblings. Descendants of u: The set of nodes reachable from u (including u). Sub-tree rooted at u: Descendants of u and all the edges between them where u has been designated as a root.

Classic Visualization: Tree Inductive rule: If G is a single node Viz(G) = If G consists of root r with sub-trees T 1, T 2, …, T k Viz(G) = Vuz(T 1 )Viz(T 2 )Viz(T k ) …..

I own 3 beanies and 2 ties. How many beanie/tie combos might I wear to the ball tonight?

A choice tree is a tree with an object called a “choice” associated with each edge and a label on each leaf. Choice Tree

Definition: Labeled Tree A tree node labeled by S is a tree T = with an associated function Label 1 : V to S A tree edge labeled by S is a tree T = with an associated function Label 2 : E to S

was very illuminating. Let’s do something similar to illuminate the nature of T(1)=1; T(n)= 4T(n/2) + n

T(1)=1; T(n)= 4T(n/2) + n For each n (power of 2), we will define a tree W(n) node labeled by Natural numbers. W(n) will give us an incisive picture of T(n).

Inductive Definition Of Labeled Tree W(n) T(n) = n + 4 T(n/2) n W(n/2) W(n) = W(1) T(1) = 1 1 =

Inductive Definition Of Labeled Tree W(n) T(2) = 6 2 W(2) = W(1) T(1) = 1 1 = 1111

Inductive Definition Of Labeled Tree W(n) T(4) = 28 4 W(4) =

Inductive Definition Of Labeled Tree W(n) T(4) = 28 4 W(4) = NOTE: When we sum all the node labels on W(n), we get T(n)

Invariant: LabelSum W(n) = T(n) T(n) = n + 4 T(n/2) n W(n/2) W(n) = W(1) T(1) = 1 1 =

n W(n/2) W(n) =

n W(n/2) W(n) = n/2 W(n/4)

n W(n) = n/2 W(n/4) n/2 W(n/4) n/2 W(n/4) n/2 W(n/4)

n W(n) = n/ n/4

n n/2 + n/2 + n/2 + n/2 Level i is the sum of 4 i copies of n/2 i n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/4 + n/ i

= 1n = 2n = 4n = 2 i n = (n)n n( n) = n(2n-1) = 2n 2 -n

Instead of T(1)=1; T(n)= 4T(n/2) + n We could illuminate T(1)=1; T(n) = 2T(n/2) + n

T(n) = n + 2 T(n/2) n W(n/2) W(n) = W(1) T(1) = 1 1 =

n n/2 + n/2 Level i is the sum of 2 i copies of n/2 i i

n n n n i

T(1)=1; T(n) = 2T(n/2) + n Has closed form: nlog 2 (n) where n is a power of 2

Representing a recurrence relation as a labeled tree is one of the basics tools you will have to put recurrence relations in closed form.

The Lindenmayer Game  = {a,b} Start word: a SUB(a) = abSUB(b) = a For each w = w 1 w 2 … w n NEXT(w) = SUB(w 1 )SUB(w 2 )..SUB(w n )

The Lindenmayer Game SUB(a) = abSUB(b) = a For each w = w 1 w 2 … w n NEXT(w) = SUB(w 1 )SUB(w 2 )..SUB(w n ) Time 1: a Time 2: ab Time 3: aba Time 4: abaab Time 5: abaababa

The Lindenmayer Game SUB(a) = abSUB(b) = a For each w = w 1 w 2 … w n NEXT(w) = SUB(w 1 )SUB(w 2 )..SUB(w n ) Time 1: a Time 2: ab Time 3: aba Time 4: abaab Time 5: abaababa How long are the strings as a function of time?

Aristid Lindenmayer ( ) 1968 Invents L-systems in Theoretical Botany Time 1: a Time 2: ab Time 3: aba Time 4: abaab Time 5: abaababa FIBONACCI(n) cells at time n

The Koch Game  = {F,+,-} Start word: F SUB(F) = F+F--F+F SUB(+)=+ SUB(-)=- For each w = w 1 w 2 … w n NEXT(w) = SUB(w 1 )SUB(w 2 )..SUB(w n )

The Koch Game Gen 0:F Gen 1: F+F--F+F Gen 2: F+F--F+F+F+F--F+F--F+F--F+F+F+F--F+F

The Koch Game Picture representation: F draw forward one unit + turn 60 degree left - turn 60 degrees right. Gen 0: F Gen 1: F+F--F+F Gen 2: F+F--F+F+F+F--F+F--F+F--F+F+F+F--F+F

The Koch Game F+F--F+F

The Koch Game F+F--F+F+F+F--F+F--F+F--F+F+F+F--F+F

Koch Curve

Dragon Game SUB(X) =X+YF+ SUB(Y) = -FX-Y Dragon Curve:

Hilbert Game SUB(L)= +RF-LFL-FR+ SUB(R)= -LF+RFR+FL- Hilbert Curve: Note: Make 90 degree turns instead of 60 degrees.

Hilbert’s Space Filling Curve

Peano-Gossamer Curve

Sierpinski Triangle

Lindenmayer 1968 SUB(F) = F[-F]F[+F][F] Interpret the stuff inside brackets as a branch.

Lindenmayer 1968

Inductive Leaf