Recursive Definitions and Structural Induction ICS 6D Sandy Irani.

Slides:



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

22C:19 Discrete Structures Induction and Recursion Spring 2014 Sukumar Ghosh.
22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
De Bruijn sequences Rotating drum problem:
Discrete Mathematics Math 6A Homework 9 Solution.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
Recursive Definitions and Structural Induction
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.
Recursive Definitions Rosen, 3.4. Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
CSE 321 Discrete Structures Winter 2008 Lecture 12 Induction.
Recursion.
CS5371 Theory of Computation Lecture 1: Mathematics Review I (Basic Terminology)
CSE115/ENGR160 Discrete Mathematics 03/31/11
Costas Busch - RPI1 Mathematical Preliminaries. Costas Busch - RPI2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Lecture Recursive Definitions. Fractals fractals are examples of images where the same elements is being recursively.
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
Lecture Recursive Definitions. Fractals fractals are examples of images where the same elements is being recursively.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
22C:19 Discrete Math Induction and Recursion Fall 2011 Sukumar Ghosh.
Induction and recursion
Recursive Definitions and Structural Induction
Mathematical Maxims and Minims, 1988
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
Induction and recursion
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 4 Induction and Recursion 歐亞書局.
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.
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
Fall 2005Costas Busch - RPI1 Mathematical Preliminaries.
Prof. Busch - LSU1 Mathematical Preliminaries. Prof. Busch - LSU2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
Chapter 5 With Question/Answer Animations. Section 5.1.
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.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
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.
Mathematical Preliminaries
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Recursive Data Structures and Grammars Themes –Recursive Description of Data Structures –Grammars and Parsing –Recursive Definitions of Properties of Data.
1 Recursive Definitions and Structural Induction CS 202 Epp section ??? Aaron Bloomfield.
 Quotient graph  Definition 13: Suppose G(V,E) is a graph and R is a equivalence relation on the set V. We construct the quotient graph G R in the follow.
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.
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.
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.
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
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
1 Mathematical Induction An inductive proof has three parts: –Basis case –Inductive hypothesis –Inductive step Related to recursive programming.
(Proof By) Induction Recursion
Chapter 4: Induction and Recursion
CS2210:0001Discrete Structures Induction and Recursion
Induction and Recursion
Discrete Structures for Computer Science
CSE 311: Foundations of Computing
CSE 321 Discrete Structures
Mathematical Preliminaries
Chapter 4 Induction and Recursion
Theorem 5.13: For vT‘, l’(v)= min{l(v), l(vk)+w(vk, v)}
N(S) ={vV|uS,{u,v}E(G)}
Induction and recursion
CSE 321 Discrete Structures
Chapter 4 (Part 2): Mathematical Reasoning, Induction & Recursion
CSE 311 Foundations of Computing I
Presentation transcript:

Recursive Definitions and Structural Induction ICS 6D Sandy Irani

Recursive Definitions A recursive definition defines a sequence or set in terms of smaller instances. – A recursively defined sequence (recurrence relations) defines each term as a function of earlier terms in the sequence Example: f n = f n-1 + f n-2 – A recursively defined set defines elements in the set by building them up from smaller elements in the set

Recursively Defined Set Example: properly nested parens Consider a string of left and right parens – When is it properly nested? ( ( ) ) ( ) ( ) ) ( ( ) ( ( ( ) ) ( ) ( ) )

Recursively Defined Set Example: properly nested parens Consider a string of left and right parens – When is it properly nested? Basis: () is properly nested. Recursive Rules: if x and y are properly nested strings then: – Rule 1: (x) is properly nested – Rule 2: xy is properly nested Exclusion statement: a string of parens is properly nested only if it can be created by applying the recursive rules to the string in the basis.

Recursively Defined Set Example: properly nested parens

( ( ( ) ) ( ) ( ) ) ( ) ) ( ( ( ) ( ) )

Ingredients for a recursive definition of a set A basis explicitly states that one or more specific elements are in the set. A recursive rule shows how to construct larger elements in the set from smaller elements. – (There is often more than one recursive rule). An exclusion statement states that an element is in the set only if it is given in the basis or can be constructed by applying the recursive rules repeatedly to elements given in the basis. – (Often omitted)

Binary Strings An alternate recursive definition for the set of all binary strings: – {0, 1} * = {, 0, 1, 00, 01, 10, 11, 000, 001,…} Recursive definition: – Basis:  S – Recursive rules: If x  S, then x0  S x1  S

Another recursively defined set of binary strings Basis: λ  S and 0  S Recursive rule: if x  S, then – x1  S – x10  S

Trees Collection of – Vertices (denoted by circles) – Edges (lines connecting vertices) Here are some examples of trees:

Perfect Binary Trees Each perfect binary tree has a designated vertex called the root. A single vertex is a perfect binary tree. If T is a perfect binary tree, then construct a new perfect binary tree T’ by taking two copies of T a new vertex v with connecting v to the roots of the copes of T. v is the root of T’.

Structural Induction Structural induction is a type of induction used to prove facts about recursively defined sets. Definition: if T is a tree, then v(T) is the number of vertices in T. Theorem: If T is a perfect binary tree, then v(T) = 2 n -1 for some positive integer n.

Structural Induction Base case: T is a single vertex. – v(T) = 1 = Induction step: – Suppose that T’ is made from T using the recursive rule for perfect binary trees. – Will show that if v(T) = 2 n -1 for some integer n, then v(T’) = 2 m -1 for some integer m.

Structural Induction Will show that if v(T) = 2 n -1 for some integer n, then v(T’) = 2 m -1 for some integer m.

Structural Induction: Properly Nested Partheses Definition: if x is a string of parentheses, – Right[x] = the number of right parens in x. – Left[x] = the number of left parens in x. Theorem: if x is a properly nested string of parentheses, then Right[x] = Left[x]

Recursively Defined Set Example: properly nested parens Consider a string of left and right parens – When is it properly nested? Basis: () is properly nested. Recursive Rules: if x and y are properly nested strings then: – Rule 1: (x) is properly nested – Rule 2: xy is properly nested Exclusion statement: a string is properly nested only if it can be created by applying the recursive rules to the string in the basis.

Structural Induction: Properly Nested Partheses Base case: x = ( ) Left[x] = 1 = Right[x] = 1 Inductive step: – If x is properly nested, it was constructed by applying a sequence of recursive rules, starting with (). – We consider two cases, depending on whether rule 1 or rule 2 was the last rule used to construct x.

Structural Induction: Properly Nested Partheses Inductive step: case 1. – x = (u), where u is properly nested. – By the inductive hypothesis: Left[u] = Right[u] Left[ x ] = Left[ (u) ] = 1 + Left[ u ] = 1 + Right[ u ] (by the inductive hypothesis) = Right[ (u) ] = Right[ x ]

Structural Induction: Properly Nested Partheses Inductive step: case 2. – x = uv, where u and v are properly nested. – By the inductive hypothesis: Left[u] = Right[u] Left[v] = Right[v] Left[ x ] = Left[ uv ] = Left[ u ] + Left[ v ] = Right[ u ] + Right[ v ] (by the inductive hypothesis) = Right[uv ] = Right[ x ]

Another recursively defined set of binary strings Basis: λ  S and 0  S Recursive rule: if x  S, then – x1  S – x10  S Theorem: S is the set of all all binary strings that do not have any consecutive 0’s.

Basis: λ  S and 0  S Recursive rule: if x  S, then – x1  S – x10  S Theorem: S is the set of all all binary strings that do not have any consecutive 0’s. If x  S, then x does not have 2 consecutive 0’s anywhere in the string If x does not have any 2 consecutive 0’s, then x  S

Basis: λ  S and 0  S Recursive rule: if x  S, then – x1  S – x10  S If x  S, then x does not have any 2 consecutive 0’s

Basis: λ  S and 0  S Recursive rule: if x  S, then – x1  S – x10  S If x does not have any 2 consecutive 0’s, then x  S