ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.

Slides:



Advertisements
Similar presentations
Mathematical Induction
Advertisements

22C:19 Discrete Structures Induction and Recursion Spring 2014 Sukumar Ghosh.
22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
Recursive Definitions and Structural Induction
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
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.
UCI ICS/Math 6A, Summer Recursion -1 after Strong Induction “Normal” Induction “Normal” Induction: If we prove.
Induction and recursion
UCI ICS/Math 6D5-Recursion -1 Strong Induction “Normal” Induction “Normal” Induction: If we prove that 1) P(n 0 ) 2) For any k≥n 0, if P(k) then P(k+1)
CSE115/ENGR160 Discrete Mathematics 04/03/12 Ming-Hsuan Yang UC Merced 1.
CSE 321 Discrete Structures Winter 2008 Lecture 12 Induction.
CSE115/ENGR160 Discrete Mathematics 03/22/12 Ming-Hsuan Yang UC Merced 1.
CSE115/ENGR160 Discrete Mathematics 03/31/11
Lecture Recursive Definitions. Fractals fractals are examples of images where the same elements is being recursively.
Chapter Mathematical Induction
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,
1 Section 3.3 Mathematical Induction. 2 Technique used extensively to prove results about large variety of discrete objects Can only be used to prove.
CSE115/ENGR160 Discrete Mathematics 03/29/11 Ming-Hsuan Yang UC Merced 1.
Induction and recursion
Induction and recursion
Recursive Definitions and Structural Induction
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 歐亞書局.
1 Introduction to Abstract Mathematics Chapter 4: Sequences and Mathematical Induction Instructor: Hayk Melikya 4.1- Sequences. 4.2,
Chapter 4: Induction and Recursion
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
Induction and recursion
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.
Chapter Mathematical Induction 4.2 Strong Induction and Well-Ordering 4.3 Recursive Definitions and Structural Induction 4.4 Recursive Algorithms.
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.
Section 3.3: Mathematical Induction Mathematical induction is a proof technique that can be used to prove theorems of the form:  n  Z +,P(n) We have.
CompSci 102 Discrete Math for Computer Science March 1, 2012 Prof. Rodger Slides modified from Rosen.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Foundations of Discrete Mathematics Chapters 5 By Dr. Dalia M. Gil, Ph.D.
1 INFO 2950 Prof. Carla Gomes Module Induction Rosen, Chapter 4.
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.
Mathematical Induction
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Chapter 5. 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 we can reach.
Chapter 5 Kenneth Rosen, Discrete Mathematics and its Applications, 7th edition, McGraw Hill Instructor: Longin Jan Latecki, Copyright.
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.
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.
Chapter 4: Induction and Recursion
Induction and recursion
Induction and Recursion Chapter 5
CSE15 Discrete Mathematics 03/22/17
Advanced Algorithms Analysis and Design
CS2210:0001Discrete Structures Induction and Recursion
Induction and recursion
Induction and Recursion
Mathematical Induction Recursion
Discrete Structures for Computer Science
Chapter 5 Induction and Recursion
Induction and recursion
Applied Discrete Mathematics Week 9: Integer Properties
CSE 321 Discrete Structures
Chapter 4 Induction and Recursion
Advanced Analysis of Algorithms
Mathematical Induction
Induction and recursion
Induction and recursion
Chapter 4 (Part 2): Mathematical Reasoning, Induction & Recursion
Presentation transcript:

ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department

Induction and Recursion ICS 253: Discrete Structures I Reading Assignment K. H. Rosen, Discrete Mathematics and Its Applications, 6 th Ed., McGraw-Hill, 2006.Discrete Mathematics and Its Applications Chapter 4 Sections 4.1, 4.2 and 4.3 2

Induction and Recursion ICS 253: Discrete Structures I Introduction Many mathematical statements assert that a property is true for all positive integers. e.g. n!  n n Many functions are defined based on certain “rules” i.e. recursively. 3

Induction and Recursion ICS 253: Discrete Structures I Section 4.1: Mathematical Induction 4

Induction and Recursion ICS 253: Discrete Structures I Mathematical Induction Mathematical induction is an extremely important proof technique that is used extensively to prove results about a large variety of discrete objects. Complexity of algorithms Correctness of certain types of computer programs Theorems about graphs and trees, A wide range of identities and inequalities…etc. 5

Induction and Recursion ICS 253: Discrete Structures I Mathematical Induction Mathematical induction is used to prove propositions of the form:  n P(n), where the universe of discourse is the set of positive integers 6

Induction and Recursion ICS 253: Discrete Structures I First Form of Mathematical Induction Basis Step: P(1) is shown to be true Inductive Step: The implication P(n)  P(n+1) is shown to be true for every positive integer n Question: Is this the same as circular reasoning??? As a rule of inference: [P(1)   n (P(n)  P(n+1))]   n P(n) Inductive Hypothesis 7

Induction and Recursion ICS 253: Discrete Structures I Examples Prove that Proof: 8

Induction and Recursion ICS 253: Discrete Structures I Examples Prove that the sum of the first n odd positive integers is n 2 9

Induction and Recursion ICS 253: Discrete Structures I Examples Prove that n < 2 n  n 10

Induction and Recursion ICS 253: Discrete Structures I Examples Prove that 2 n < n! for n  4 11

Induction and Recursion ICS 253: Discrete Structures I Examples Prove that n 3 – n is divisible by 3  n  Z + 12

Induction and Recursion ICS 253: Discrete Structures I Examples Use mathematical induction to show that n=0,1,2,… where 13

Induction and Recursion ICS 253: Discrete Structures I Examples Use mathematical induction to show that if S is a finite set with n elements where n is a nonnegative integer, then S has 2 n subsets. 14

Induction and Recursion ICS 253: Discrete Structures I Examples Use mathematical induction to prove the following generalization of one of De Morgan's laws: whenever A 1, A 2,..., A n are subsets of a universal set U and n  2. 15

Induction and Recursion ICS 253: Discrete Structures I Examples Let n be a +ve integer. Show that any 2 n  2 n chessboard with one square removed can be tiled using L-shaped pieces, where these pieces cover three squares at a time as shown below 16

Induction and Recursion ICS 253: Discrete Structures I Sketch of The Solution Basis Step: Induction Step: Inductive Hypothesis Subsquare having the real hole Subsquare with ‘artificial’ hole at lower right corner Subsquare with ‘artificial’ hole at lower left corner Subsquare with ‘artificial’ hole at upper left corner 17

Induction and Recursion ICS 253: Discrete Structures I Section 4.2: Strong Induction and Well Ordering Strong induction is similar to the mathematical induction in both requiring a basis step. Strong induction differs in the inductive step, where we assume that the statement P(j) is true for all j  k, and then prove that P holds for j=k+1. The validity of both mathematical induction and strong induction follow from the well-ordering property. In fact, mathematical induction, strong induction, and well-ordering are all equivalent principles. 18

Induction and Recursion ICS 253: Discrete Structures I Strong Induction Basis Step: P(1) is shown to be true Inductive Step: [P(1)  P(2)  …  P(n)]  P(n+1) is shown to be true for every positive integer n 19

Induction and Recursion ICS 253: Discrete Structures I Examples Suppose we can reach the first and second rungs of an infinite ladder, and we know that if we can reach a rung, then we can reach two rungs higher. Can we prove that we can reach every rung using the principle of mathematical induction? Can we prove that we can reach every rung using strong induction? 20

Induction and Recursion ICS 253: Discrete Structures I Examples Show that if n is an integer greater than 1, then n can be written as the product of primes. 21

Induction and Recursion ICS 253: Discrete Structures I Examples Prove that every amount of postage of 12 cents or more can be formed using just 4-cent and 5-cent stamps. 22

Induction and Recursion ICS 253: Discrete Structures I Well Ordering Property Mathematical induction follows from the following fundamental axiom The Well Ordering Property: Every non- empty set of nonnegative integers has a least element The well ordering property can often be used directly in proofs. 23

Induction and Recursion ICS 253: Discrete Structures I Section 4.3: Recursive Definitions and Structural Induction 24 Sometimes it is difficult to define an object explicitly. However, it may be easy to define this object in terms of itself. This process is called recursion.

Induction and Recursion ICS 253: Discrete Structures I Recursive Definitions and Structural Induction Recursion can be used to define sequences, functions and sets Sequences: can also be defined as Functions: Similar to sequences After all, sequences are, themselves, functions! Sets 25

Induction and Recursion ICS 253: Discrete Structures I Recursively Defined Functions Q3 pp 308: Find f(2), f(3), f(4), and f(5) if f is defined recursively by f(0) = –1, f(l) = 2 and for n = 1,2,... a) f(n + 1) = f(n) + 3f(n – 1). b) f(n + 1) = f(n) 2 f(n – 1). c) f(n + 1) = 3f(n) 2 – 4f(n – 1) 2. d) f(n + 1) = f(n – l)/f(n). 26

Induction and Recursion ICS 253: Discrete Structures I Recursively Defined Functions Give an inductive definition of the factorial function F(n) = n!. Give a recursive definition of 27

Induction and Recursion ICS 253: Discrete Structures I Fibonacci Numbers Definition: The Fibonacci numbers, f 0, f 1, f 2,..., are defined by the equations f 0 = 0, f 1 = 1, and f n = f n – l + f n – 2 for n = 2, 3, 4,.... Show that whenever n  3, f n >  n – 2, where 28

Induction and Recursion ICS 253: Discrete Structures I Recursively Defined Sets and Structures In recursively defined sets, the basis step defines some initial elements and the recursive step defines a rule for constructing new elements from those already in the set. Recursive definitions may also include an exclusion rule, which specifies that a recursively defined set contains nothing other than those elements specified in the basis step or generated by applications of the recursive step. We will assume that it always holds. To prove results about recursively defined sets we use a method called structural induction. 29

Induction and Recursion ICS 253: Discrete Structures I Example Consider the subset S of the set of integers defined by Basis step: 3  S. Recursive step: If x  S and y  S, then x + y  S. Show that S is the set of all positive integers that are multiples of 3. 30

Induction and Recursion ICS 253: Discrete Structures I Strings Over Alphabet  Definition: The set  * of strings over the alphabet  can be defined recursively by Basis step:  * (where is the empty string containing no symbols). Recursive step: If w  * and x , then wx  *. Example: What are the strings formed over  ={0,1}? 31

Induction and Recursion ICS 253: Discrete Structures I Concatenation of Strings Definition: Two strings can be combined via the operation of concatenation. Let  be a set of symbols and  * the set of strings formed from symbols in . We can define the concatenation of two strings, denoted by., recursively as follows. Basis step: If w   *, then w · = w, where is the empty string. Recursive step: If w 1  * and w 2  * and x , then w 1 · (w 2 x ) = (w 1. w 2 )x. Usually, w 1. w 2 is denoted by w 1 w 2 32

Induction and Recursion ICS 253: Discrete Structures I Length of a String Give a recursive definition of l(w), the length of the string w. Solution: The length of a string can be defined by l( ) = 0; l(wx) = l(w) + 1 if w   * and x  . Use structural induction to prove that l(xy) = I(x) + l(y). 33

Induction and Recursion ICS 253: Discrete Structures I Well-Formed Formulae Well-Formed Formulae for Compound Statement Forms We can define the set of well-formed formulae for compound statement forms involving T, F, propositional variables, and operators from the set { , , , ,  } as follows Basis step: T, F, and s, where s is a propositional variable, are well- formed formulae. Recursive step: If E and F are well-formed formulae, then (  E), (E  F), (E  F), (E  F), and (E  F) are well-formed formulae. Is (p  q)  (q  F) a well-formed formula? Is p   q a well-formed formula? Can you similarly define well-formed formulae for operators and operands? Show that every well-formed formulae for compound propositions contains an equal number of left and right parentheses. 34

Induction and Recursion ICS 253: Discrete Structures I Rooted Trees Definition: The set of rooted trees, where a rooted tree consists of a set of vertices containing a distinguished vertex called the root, and edges connecting these vertices, can be defined recursively by these steps: Basis step: A single vertex r is a rooted tree. Recursive step: Suppose that T 1, T 2,..., T n are disjoint rooted trees with roots r l, r 2,..., r n, respectively. Then the graph formed by starting with a root r, which is not in any of the rooted trees T 1, T 2,..., T n, and adding an edge from r to each of the vertices r 1, r 2,..., r n, is also a rooted tree.. 35

Induction and Recursion ICS 253: Discrete Structures I Building Up Rooted Trees 36

Induction and Recursion ICS 253: Discrete Structures I Extended Binary Trees Definition: The set of extended binary trees can be defined recursively by these steps: Basis step: The empty set is an extended binary tree. Recursive step: If T 1 and T 2 are disjoint extended binary trees, there is an extended binary tree, denoted by T l · T 2, consisting of a root r together with edges connecting the root to each of the roots of the left subtree T l and the right subtree T 2 when these trees are nonempty. 37

Induction and Recursion ICS 253: Discrete Structures I Building Extended Binary Trees 38

Induction and Recursion ICS 253: Discrete Structures I Full Binary Trees Definition: The set of full binary trees can be defined recursively by these steps: Basis step: There is a full binary tree consisting only of a single vertex r. Recursive step: If T l and T 2 are disjoint full binary trees, there is a full binary tree, denoted by T l · T 2, consisting of a root r together with edges connecting the root to each of the roots of the left subtree T l and the right subtree T 2. 39

Induction and Recursion ICS 253: Discrete Structures I Examples of Full Binary Trees 40

Induction and Recursion ICS 253: Discrete Structures I Full Binary Trees Denote the number of nodes in full binary tree T as n(T). Can you provide a recursive definition of n(T)? Definition: The height h(T) of a full binary tree T recursively as follows Basis step: The height of the full binary tree T consisting of only a root r is h(T) = 0. Recursive step: If T 1 and T 2 are full binary trees, then the full binary tree T = T 1 · T 2 has height h(T) = 1 + max(h(T 1 ), h(T 2 )) 41

Induction and Recursion ICS 253: Discrete Structures I Full Binary Trees Theorem: If T is a full binary tree, then Proof (By Structural Induction): 42

Induction and Recursion ICS 253: Discrete Structures I Full Binary Trees Definition: A leaf node is a node that has no children. Definition: An internal node is a node that has one or more children. Prove that in any full binary tree, the number of leaf nodes is one more than the number of internal nodes. 43

Induction and Recursion ICS 253: Discrete Structures I Generalized Induction Instead of using induction on Z + or N, we can extend it to any set having the well-ordering property For example, consider N  N with the following property (called lexicographic ordering) (x 1, y 1 ) is less than or equal to (x 2, y 2 ) if either x 1 <x 2, or x 1 =x 2 and y 1 <y 2 ; 44

Induction and Recursion ICS 253: Discrete Structures I Example Suppose that a m,n is defined recursively for (m, n)  N  N Show that a m,n = m + n(n + 1)/2 for all (m,n)  N  N 45