and Structural Induction

Slides:



Advertisements
Similar presentations
Chapter Three: Closure Properties for Regular Languages
Advertisements

22C:19 Discrete Structures Induction and Recursion Spring 2014 Sukumar Ghosh.
22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
Chapter 11 Proof by Induction. Induction and Recursion Two sides of the same coin.  Induction usually starts with small things, and then generalizes.
Recursive Definitions and Structural Induction
CPSC 668Set 10: Consensus with Byzantine Failures1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
CSE115/ENGR160 Discrete Mathematics 04/03/12 Ming-Hsuan Yang UC Merced 1.
Self-Reference - Induction Cmput Lecture 7 Department of Computing Science University of Alberta ©Duane Szafron 1999 Some code in this lecture is.
CPSC 668Set 10: Consensus with Byzantine Failures1 CPSC 668 Distributed Algorithms and Systems Fall 2006 Prof. Jennifer Welch.
1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.
Lecture Recursive Definitions. Fractals fractals are examples of images where the same elements is being recursively.
Chapter 10 Sequences, Induction, and Probability Copyright © 2014, 2010, 2007 Pearson Education, Inc Mathematical Induction.
Prof. Busch - LSU1 More Applications of the Pumping Lemma.
Copyright © 2007 Pearson Education, Inc. Slide 8-1.
22C:19 Discrete Math Induction and Recursion Fall 2011 Sukumar Ghosh.
Induction and recursion
Fundamental Structures of Computer Science March 02, 2006 Ananda Guna Binomial Heaps.
Sequences and Series (T) Students will know the form of an Arithmetic sequence.  Arithmetic Sequence: There exists a common difference (d) between each.
Mathematical Induction. F(1) = 1; F(n+1) = F(n) + (2n+1) for n≥ F(n) n F(n) =n 2 for all n ≥ 1 Prove it!
CSE 311 Foundations of Computing I Lecture 15 Recursive Definitions and Structural Induction Autumn 2011 CSE 3111.
CSE 311 Foundations of Computing I Lecture 16 Recursively Defined Sets and Structural Induction Spring
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
Module #14: Recursion Rosen 5 th ed., §§ In this class, we will study recursion, one of the most important topics in computer science. In the last.
Mathematical Induction II Lecture 21 Section 4.3 Mon, Feb 27, 2006.
4.3 Recursive Definitions and Structural Induction Sometimes it is difficult to define an object explicitly. However, it may be easy to define this object.
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.
Theory of Computation, Feodor F. Dragan, Kent State University 1 TheoryofComputation Spring, 2015 (Feodor F. Dragan) Department of Computer Science Kent.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
1 Recursive Definitions and Structural Induction CS 202 Epp section ??? Aaron Bloomfield.
October 3, 2001CSE 373, Autumn Mathematical Background Exponents X A X B = X A+B X A / X B = X A-B (X A ) B = X AB X N +X N = 2X N 2 N +2 N = 2 N+1.
Classifications LanguageGrammarAutomaton Regular, right- linear Right-linear, left-linear DFA, NFA Context-free PDA Context- sensitive LBA Recursively.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
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.
1 Recursive Definitions and Structural Induction CS/APMA 202 Rosen section 3.4 Aaron Bloomfield.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
CSE 311 Foundations of Computing I Lecture 15 Strong Induction and Recursive Definitions Spring
Mathematical Induction And Recursion Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Mathematical Induction. The Principle of Mathematical Induction Let S n be a statement involving the positive integer n. If 1.S 1 is true, and 2.the truth.
Recursive Definitions & Structural Induction: Selected Exercises
1 Mathematical Induction An inductive proof has three parts: –Basis case –Inductive hypothesis –Inductive step Related to recursive programming.
CS2210:0001Discrete Structures Induction and Recursion
Discrete Structures for Computer Science
Mathematics for Computer Science MIT 6.042J/18.062J
CSE 311: Foundations of Computing
Computational Processes
CS 154, Lecture 4: Limitations on DFAs (I),
Asymptotics & Stirling’s Approximation
Asymptotics & Stirling’s Approximation
Mathematics for Computer Science MIT 6.042J/18.062J
Mathematics for Computer Science MIT 6.042J/18.062J
and Structural Induction II
Fundamental Structures of Computer Science
Mathematics for Computer Science MIT 6.042J/18.062J
and Structural Induction II
and Structural Induction
and Structural Induction II
Mathematics for Computer Science MIT 6.042J/18.062J
and Structural Induction
and Structural Induction
Computational Processes
Asymptotics & Stirling’s Approximation
Mathematics for Computer Science MIT 6.042J/18.062J
Asymptotics & Stirling’s Approximation
Truth and Proof Math vs. Reality Propositions & Predicates
Asymptotics & Stirling’s Approximation
Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011
CSE 311 Foundations of Computing I
Mathematical Induction II
Presentation transcript:

and Structural Induction Mathematics for Computer Science MIT 6.042J/18.062J Recursive Definitions and Structural Induction Copyright © Albert Meyer, 2002. Prof. Albert Meyer & Dr. Radhika Nagpal

Build something from a simpler version of the same thing: Recursive Definitions Build something from a simpler version of the same thing: Base case(s) that don’t depend on anything else Induction (Construction) case(s) that depend on simpler cases

Example Definition: set E Define set E  Z, recursively: 0  E Base Case If n  E, then n + 2  E Induction case If n  E, then -n  E E : 0 , 0+2

Example Definition: set E Define set E  Z, recursively: 0  E Base Case If n  E, then n + 2  E Induction case If n  E, then -n  E E : 0, 2, 2+2 , (2+2)+2

Example Definition: set E Define set E  Z, recursively: 0  E If n  E, then n + 2  E If n  E, then -n  E E : 0, 2, 4, 6, … All even numbers Also, -2, -4, -6, …

Recursive Definition: Extremal Clause So, E contains the even integers Anything Else? No! 0  E If n  E, then n + 2  E If n  E, then -n  E That’s All! Implicit part of recursive definition

Example Definition: set E So E is exactly: The Even Integers

l  S, (the empty string) axb bxa xy Another Example Define set of strings, S  {a, b}* l  S, (the empty string) If x, y  S, then the following are in S: axb bxa xy

Proof by Structural Induction on S Lemma: Every x in S has an equal number of a’s and b’s.

Structural Induction on S Proof: Let EQ ::= {strings with equal # of a’s and b’s} P(x) ::= x  S  x  EQ Base Case: x = l. 0 a’s and 0 b’s. OK

Structural Induction on S Inductive Step Assume: P(x) and P(y) To Prove: P(axb), P(bxa), and P(xy) Case 1: axb has k + 1 a’s and b’s if x has k of each. OK

Structural Induction on S Inductive Step Assume: P(x) and P(y) To Prove: P(axb), P(bxa), and P(xy) Case 2: bxa SAME Case 3: xy has kx + ky of each. OK So S  EQ

Structural Induction on S Rest of Story: Theorem: S = EQ Show by strong induction on length of string in EQ. Proof in Notes 5.

In-Class Problem Problem 1

Recursive Data Types Rooted Binary Trees

Defined recursively as follows: A single node r is an RBT: Rooted Binary Trees Defined recursively as follows: A single node r is an RBT:

If t, t’ are RBTs, then so are : Rooted Binary Trees If t, t’ are RBTs, then so are : makeleft(t) t makeright(t) t makeboth(t,t’) t t’

A Rooted Binary Tree Example

Recursive Functions on RBT Recursive def of set of nodes nodes( )::= { }, nodes(makeleft(t))::= nodes(t) { } nodes(makeright(t))::= nodes(t){ } nodes(makeboth(t1, t2))::= nodes(t1)  nodes(t2){ } Remember, is not supposed to be in nodes(t)

Example = {{ }, { }, { }, { }, { }, { }, { }, { }, { } } nodes( )

Recursive Functions on RBT depth( )::= 0 depth(makeleft(t))::= 1 + depth(t) depth(makeright(t))::= 1 + depth(t) depth(makeboth(t1, t2))::= 1 + max(depth(t1),depth(t2))

Example = 4 depth( )

Number of nodes vs Depth Lemma: |nodes(t)| + 1  2depth(t)+1 Proof by Structural Induction Base Case: t = |nodes(t)| + 1 = 2 = 20+1 = 2depth(t)+1 OK!

Number of nodes vs Depth Induction Case: makeleft(t) Assume: |nodes(t)| + 1  2depth(t) +1 To Prove: |nodes(makeleft(t))| + 1  2depth(makeleft(t)) + 1 |nodes(makeleft(t))| + 1 = (|nodes(t)|+1) + 1 by def. of nodes  (2depth(t)+1 + 1) + 1 by induction hyp. = 2depth(t)+1 + 2  2depth(t)+1 + 2depth(t)+1 = 2depth(t)+1+1 = 2depth(makeleft(t))+1 by def. of depth

Number of nodes vs Depth Induction Case: makeright(t) Same

Number of nodes vs Depth Induction Case: makeboth(t1, t2) Assume: |nodes(t1)|+1  2depth(t1)+1 |nodes(t2)|+1  2depth(t2)+1 To Prove: |nodes(makeboth(t1, t2))| +1  2depth(makeboth(t1,t2))+1

|nodes(makeboth(t1,t2))| + 1 Proof of makeboth Case |nodes(makeboth(t1,t2))| + 1 = (|nodes(t1)| + |nodes(t2)| + 1)+1 def. of nodes = |nodes(t1)| +1 + (|nodes(t2)| +1)  2depth(t1)+1 + 2depth(t2)+1 induction hyp.  2max(depth(t1),depth(t2))+1 + 2max(depth(t1),depth(t2))+1 = 2(max(depth(t1),depth(t2))+1)+1 = 2depth(makeboth(t1,t2))+1 def. of depth

In-Class Problem Problems 2 & 3