Recursive Definitions & Structural Induction: Selected Exercises

Slides:



Advertisements
Similar presentations
The Pigeonhole Principle: Selected Exercises
Advertisements

The Basics of Counting: Selected Exercises. Copyright © Peter Cappello2 Sum Rule Example There are 3 sizes of pink shirts & 7 sizes of blue shirts. How.
Recurrence Relations: Selected Exercises
Generalized Permutations & Combinations: Selected Exercises.
Mathematical Induction
Lesson 10.4: Mathematical Induction
Review for CS1050. Review Questions Without using truth tables, prove that  (p  q)   q is a tautology. Prove that the sum of an even integer and an.
The Growth of Functions: Selected Exercises
22C:19 Discrete Structures Induction and Recursion Spring 2014 Sukumar Ghosh.
22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
Discrete Mathematics Math 6A Homework 9 Solution.
More Set Definitions and Proofs 1.6, 1.7. Ordered n-tuple The ordered n-tuple (a1,a2,…an) is the ordered collection that has a1 as its first element,
Recursive Definitions and Structural Induction
Recursively Defined Functions
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.
CSE115/ENGR160 Discrete Mathematics 04/03/12 Ming-Hsuan Yang UC Merced 1.
1 Lecture 31 EQUAL language –Designing a CFG –Proving the CFG is correct.
Recursive Definitions Rosen, 3.4. Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
CSE115/ENGR160 Discrete Mathematics 03/31/11
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
Proof Methods & Strategy
1 Section 3.4 Recursive Definitions. 2 Recursion Recursion is the process of defining an object in terms of itself Technique can be used to define sequences,
Mathematical Maxims and Minims, 1988
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
Induction and recursion
Chapter 6 Mathematical Induction
Copyright © Peter Cappello Mathematical Induction Goals Explain & illustrate construction of proofs of a variety of theorems using mathematical induction.
Chapter 4: Induction and Recursion
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.
Recurrence Relations: Selected Exercises
Inclusion-Exclusion Selected Exercises Powerpoint Presentation taken from Peter Cappello’s webpage
9.4 Mathematical Induction
Module #13: Inductive Proofs Rosen 5 th ed., § inference of a generalized conclusion from particular instances 2. mathematical demonstration of the.
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.
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.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
1 Recursive Definitions and Structural Induction CS 202 Epp section ??? Aaron Bloomfield.
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.
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.
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
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.
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.
Fall 2002CMSC Discrete Structures1 Chapter 3 Sequences Mathematical Induction Recursion Recursion.
3.3 Mathematical Induction 1 Follow me for a walk through...
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
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.
Recurrence Relations: Selected Exercises. Copyright © Peter Cappello2 Exercise 10 (a) A person deposits $1,000 in an account that yields 9% interest compounded.
Recursive Definitions & Structural Induction: Selected Exercises
Strong Induction: Selected Exercises Goal Explain & illustrate proof construction of a variety of theorems using strong induction.
Chapter 4: Induction and Recursion
Partial Orderings: Selected Exercises
Advanced Algorithms Analysis and Design
Induction and Recursion
Recursively Defined Functions
Mathematical Induction Recursion
CSE 311: Foundations of Computing
Follow me for a walk through...
Applied Discrete Mathematics Week 9: Integer Properties
Mathematical Induction
Applied Discrete Mathematics Week 7: Computation
Follow me for a walk through...
Mathematical Induction
Follow me for a walk through...
Chapter 4 (Part 2): Mathematical Reasoning, Induction & Recursion
Presentation transcript:

Recursive Definitions & Structural Induction: Selected Exercises

Copyright © Peter Cappello Exercise 10 Give a recursive definition of Sm( n ), the sum of integer m + nonnegative integer n. Copyright © Peter Cappello

Exercise 10 Solution Give a recursive definition of Sm( n ), the sum of integer m + nonnegative integer n. Sm( n ) = ( n == 0 ) ? m : 1 + Sm( n – 1 ); Copyright © Peter Cappello

Copyright © Peter Cappello Exercise 20 Give a recursive definition of the functions max & min so that max( a1, a2, …, an ) & min( a1, a2, …, an ) are the maximum & minimum of a1, a2, …, an, respectively. Copyright © Peter Cappello

Copyright © Peter Cappello Exercise 20 Solution Give a recursive definition of the functions max & min so that max( a1, a2, …, an ) & min( a1, a2, …, an ) are the maximum & minimum of a1, a2, …, an, respectively. max( a1 ) = a1; max( a1, a2 ) = (a1  a2 ) ? a2 : a1; (Why is this needed?) max( a1, a2, …, an ) = max (max( a1, a2, …, an-1 ) , an ) The min function is defined similarly. Copyright © Peter Cappello

Copyright © Peter Cappello Exercise 30 Prove that in any bit string, the string 01 occurs at most 1 more time than the string 10. Copyright © Peter Cappello

Copyright © Peter Cappello Exercise 30 Prove that in any bit string “01” occurs at most 1 more time than the “10”. Can we prove it by induction? Can we base the induction on the length of the bit string? If we Show it’s true for | s | = 1 Assume it’s true for | s | < n We try to show it’s true for | s | = n. We break the string into bit string r = the 1st n – 1 bits, followed by the last bit. Apply the induction hypothesis to r. Induction step: 4 cases, depending on the last bit of r &the last bit of s. The case fails when the last bit of r is 1 & the last bit of s is 0. What to do? Copyright © Peter Cappello

Copyright © Peter Cappello Exercise 30 Proof Basis: |s| = 1: #01(s) = 0  1 = #10(s) + 1 Assume: |s| < n  #01(s)  #10(s) + 1 Show: |s| = n  #01(s)  #10(s) + 1 (Decomposing s arbitrarily into 2 smaller strings, fails. Try it.) Case: s does not contain substring “10”: It is of the form 0*1*. #01(s)  1 = #10(s) + 1. Copyright © Peter Cappello

Copyright © Peter Cappello Case: s does contain substring “10”: Break s into 2 strings, t and u, between a “10” E.g., 100111011000 is broken into (100111)(011000 ) t ends in “1”; u begins with “0”. #01(t)  #10(t) + 1 (S.I.H.) #01(u)  #10(u) + 1 (S.I.H.) #01(s) = #01(t) + #01(u)  #10(t) + #10(u) + 2 = #10(s) + 1. Copyright © Peter Cappello

Copyright © Peter Cappello Exercise 40 To recursively define a set: Define it to have some “initial” elements; Give rules that compose new elements from pre-existing elements. Recursively define the set S of bit strings with more 0s than 1s. Copyright © Peter Cappello

Copyright © Peter Cappello Exercise 40 Solution Recursively define the set S of bit strings that have more 0s than 1s. 0  S. x, y  S  xy, 1xy, x1y, xy1  S. This recursive definition of set S is like a context free grammar. S is a context-free language. These grammars & languages are studied in CMPSC 138. We use them to define the syntax of programming languages, like Java, C, & C++. Copyright © Peter Cappello

Copyright © Peter Cappello 0  S. x,y  S  xy, 1xy, x1y, xy1  S. Elements of S have more 0s than 1s. Proof by structural induction that x  S  x has more 0s than 1s. Basis: 0  S has more 0s than 1s. Assume: x,y  S have more 0s than 1s. Show: xy, 1xy, x1y, xy1  S have more 0s than 1s. #0(xy1) = #0(x) + #0(y) ≥ ( #1(x) + 1 ) + ( #1(y) + 1 ) = #1(xy1) + 1 > #1(xy1). Copyright © Peter Cappello

Copyright © Peter Cappello Exercise 50 Ackermann’s function is defined as follows: A( m, n ) = 2n, if m = 0; = 0, if m ≥ 1  n = 0 = 2, if m ≥ 1  n = 1 = A( m – 1, A( m, n – 1 ) ), if m ≥ 1  n ≥ 2. Show that A( 1, k ) = 2k, for k ≥ 1. (We use structural induction.) Copyright © Peter Cappello

Copyright © Peter Cappello Exercise 50 Solution Ackermann’s function is defined as follows: A( m, n ) = 2n, if m = 0; = 0, if m ≥ 1  n = 0 = 2, if m ≥ 1  n = 1 = A( m – 1, A( m, n – 1 ) ), if m ≥ 1  n ≥ 2. Show that, for k ≥ 1, A( 1, k ) = 2k. Basis k = 1: A( 1, 1 ) = 2 = 21. Show A( 1, k ) = 2k  A( 1, k + 1 ) = 2k+1, for arbitrary k. Assume A( 1, k ) = 2k. Prove A( 1, k + 1 ) = 2k+1: A( 1, k + 1) = A( 0, A(1, k ) ) = A( 0, 2k ) = 2 . 2k = 2k+1. Copyright © Peter Cappello

A Bijection between Z+ & Rooted Trees The discussion below is based on Peter Cappello. A New Bijection between Natural Numbers and Rooted Trees. 4th SIAM Conf. on Discrete Mathematics, San Francisco, June 1988. Let P denote the set of primes numbers. Let T denote the set of rooted trees. Let p: Z+,  P, where p(n) is the nth prime (e.g., p(4) = 7 and p-1(7) = 4 ). p-1(n)  n. Copyright © Peter Cappello