CSE 311: Foundations of Computing

Slides:



Advertisements
Similar presentations
22C:19 Discrete Structures Induction and Recursion Spring 2014 Sukumar Ghosh.
Advertisements

22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
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.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
CSE115/ENGR160 Discrete Mathematics 04/03/12 Ming-Hsuan Yang UC Merced 1.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
CSE 321 Discrete Structures Winter 2008 Lecture 12 Induction.
1 Languages and Finite Automata or how to talk to machines...
CSE115/ENGR160 Discrete Mathematics 03/31/11
Costas Busch - RPI1 Mathematical Preliminaries. Costas Busch - RPI2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
22C:19 Discrete Math Induction and Recursion Fall 2011 Sukumar Ghosh.
Induction and recursion
Recursive Definitions and Structural Induction
Induction and recursion
Chapter 4: Induction and Recursion
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.
CSE 311 Foundations of Computing I Lecture 17 Structural Induction: Regular Expressions, Regular Languages Autumn 2011 CSE 3111.
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
Chapter 5 With Question/Answer Animations. Section 5.1.
CSE 311 Foundations of Computing I Lecture 17 Structural Induction Spring
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.
CSE 311 Foundations of Computing I Lecture 9 Proofs and Set Theory Autumn 2012 CSE
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.
CSE 311: Foundations of Computing Fall 2013 Lecture 8: Proofs and Set theory.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
CSE 311: Foundations of Computing Fall 2013 Lecture 18: Structural induction, regular expressions.
CSE 311 Foundations of Computing I Lecture 19 Recursive Definitions: Context-Free Grammars and Languages Spring
CSE 311 Foundations of Computing I Lecture 19 Recursive Definitions: Context-Free Grammars and Languages Autumn 2012 CSE
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
P Symbol Q E(Q) a b a b a b Convert to a DFA: Start state: Final States:
CSE 311 Foundations of Computing I Lecture 18 Recursive Definitions: Context-Free Grammars and Languages Autumn 2011 CSE 3111.
CSE 311 Foundations of Computing I Lecture 20 Context-Free Grammars and Languages Autumn 2012 CSE
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
Chapter 4: Induction and Recursion
Languages.
CSE 311 Foundations of Computing I
CS2210:0001Discrete Structures Induction and Recursion
CSE 311 Foundations of Computing I
Induction and Recursion
CSE 311 Foundations of Computing I
Discrete Structures for Computer Science
Single Final State for NFA
Discrete Structures for Computer Science
CSE 311: Foundations of Computing
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
CSE 311: Foundations of Computing
CSE 311: Foundations of Computing
CSE 311: Foundations of Computing
CSE 321 Discrete Structures
CSE 321 Discrete Structures
CSE 321 Discrete Structures
CSE 311 Foundations of Computing I
Convert to a DFA: Start state: Final States: P Symbol Q E(Q) a b.
CSE 321 Discrete Structures
Chapter 4 (Part 2): Mathematical Reasoning, Induction & Recursion
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
Presentation transcript:

CSE 311: Foundations of Computing Fall 2013 Lecture 17: Recursive definitions and structural induction

announcements Reading assignment Induction 5.3, 7th edition 4.3, 6th edition Homework 5 solutions out today Midterm Monday, November 4th, IN CLASS Topics: Everything up to ordinary induction and recursive definition of functions Sample questions from old midterms now posted. Solutions posted later today. Review sessions: Today 3:30, Sunday 4:00 in EEB 125

review: recursive definition of sets Basis step: 0  𝑆 Recursive step: if 𝑥  𝑆, then 𝑥+2  𝑆 Exclusion rule: Every element in 𝑆 follows from basis steps and a finite number of recursive steps

review: recursive definitions of sets Basis: 6∈𝑆; 15∈𝑆; Recursive: if 𝑥, 𝑦  𝑆, then 𝑥 + 𝑦  𝑆; Basis: 1, 1, 0  𝑆, 0, 1, 1 𝑆; Recursive: if 𝑥, 𝑦, 𝑧  𝑆, 𝛼∈ ℝ, then 𝑥, 𝛼𝑦, 𝛼𝑧 ∈𝑆 if [𝑥1, 𝑦1, 𝑧1], [𝑥2, 𝑦2, 𝑧2]  𝑆 then [𝑥1 + 𝑥2, 𝑦1 + 𝑦2, 𝑧1 + 𝑧2]  𝑆 Powers of 3: 1∈𝑆 and 𝑥∈𝑆 3𝑥∈𝑆

recursive definitions of sets: general form Basis step: Some specific elements are in 𝑆 Recursive step: Given some existing named elements in 𝑆 some new objects constructed from these named elements are also in 𝑆. Exclusion rule: Every element in 𝑆 follows from basis steps and a finite number of recursive steps

review: strings An alphabet  is any finite set of characters The set * of strings over the alphabet  is defined by Basis:   * ( is the empty string) Recursive: if 𝑤  *, 𝑎  , then 𝑤𝑎  *

review: palindromes Palindromes are strings that are the same backwards and forwards Basis:  is a palindrome and any 𝑎 ∈  is a palindrome Recursive step: If 𝑝∈ Σ ∗ is a palindrome then 𝑎𝑝𝑎 is a palindrome for every 𝑎∈ 

review: all binary strings with no 1’s before 0’s

function definitions on recursively defined sets len () = 0; len (𝑤𝑎) = 1 + len(𝑤); for 𝑤∈ Σ ∗ , 𝑎∈Σ Reversal: 𝜆 𝑅 =𝜆 𝑤𝑎 𝑅 = 𝑎𝑤 𝑅 for 𝑤  *, 𝑎   Concatenation: 𝑥 •  = 𝑥 for 𝑥  * 𝑥 • 𝑤𝑎 = (𝑥 • 𝑤)𝑎 for 𝑥, 𝑤  *, 𝑎  

rooted binary trees Basis: • is a rooted binary tree Recursive step: If and are rooted binary trees then so is: T2 T1 T2 T1

functions defined on rooted binary trees size(•)=1 size( ) = 1+size(T1)+size(T2) height(•)=0 height( )=1+max{height(T1),height(T2)} T1 T2 T1 T2

structural induction How to prove 𝑥∈𝑆, 𝑃(𝑥) is true: Base Case: Show that 𝑃 is true for all specific elements of 𝑆 mentioned in the Basis step Inductive Hypothesis: Assume that 𝑃 is true for some arbitrary values of each of the existing named elements mentioned in the Recursive step Inductive Step: Prove that 𝑃 holds for each of the new elements constructed in the Recursive step using the named elements mentioned in the Inductive Hypothesis Conclude that 𝑥∈𝑆, 𝑃(𝑥)

structural induction vs. ordinary induction Ordinary induction is a special case of structural induction: Recursive definition of ℕ Basis: 0 ∈ ℕ Recursive Step: If k ∈ ℕ then k+1 ∈ ℕ Structural induction follows from ordinary induction: Let 𝑄(𝑛) be true iff for all 𝑥∈𝑆 that take 𝑛 recursive steps to be constructed, 𝑃(𝑥) is true.

using structural induction Let 𝑆 be given by Basis: 6  𝑆; 15∈ 𝑆; Recursive: if 𝑥, 𝑦∈𝑆, then 𝑥 + 𝑦∈𝑆. Claim: Every element of 𝑆 is divisible by 3.

Claim: Every element of 𝑆 is divisible by 3.

structural induction for strings Let 𝑆 be a set of strings over {𝑎,𝑏} defined as follows Basis: 𝑎∈𝑆 Recursive: If 𝑤∈𝑆 then 𝑎𝑤∈𝑆 and 𝑏𝑎𝑤∈𝑆 If 𝑢∈𝑆 and 𝑣∈𝑆 then 𝑢𝑣∈𝑆 Claim: If 𝑤∈𝑆 then 𝑤 has more 𝑎’s than 𝑏’s

Claim: If 𝑤∈𝑆 then 𝑤 has more 𝑎’s than 𝑏’s Basis: 𝑎∈𝑆 Recursive: If 𝑤∈𝑆 then 𝑎𝑤∈𝑆 and 𝑏𝑎𝑤∈𝑆 If 𝑢∈𝑆 and 𝑣∈𝑆 then 𝑢𝑣∈𝑆

function definitions on recursively defined sets len () = 0; len (𝑤𝑎) = 1 + len(𝑤); for 𝑤∈ Σ ∗ , 𝑎∈Σ Reversal: 𝜆 𝑅 =𝜆 𝑤𝑎 𝑅 = 𝑎𝑤 𝑅 for 𝑤  *, 𝑎   Concatenation: 𝑥 •  = 𝑥 for 𝑥  * 𝑥 • 𝑤𝑎 = (𝑥 • 𝑤)𝑎 for 𝑥, 𝑤  *, 𝑎  

len(𝑥•𝑦)=len(𝑥)+len(𝑦) for all strings 𝑥 and 𝑦 Let 𝑃(𝑦) be “len(𝑥•𝑦)=len(𝑥)+len(𝑦) for all strings 𝑥”

len(𝑥•𝑦)=len(𝑥)+len(𝑦) for all strings 𝑥 and 𝑦 Let 𝑃(𝑦) be “len(𝑥•𝑦)=len(𝑥)+len(𝑦) for all strings 𝑥”

functions defined on rooted binary trees size(•)=1 size( ) = 1+size(T1)+size(T2) height(•)=0 height( )=1+max{height(T1),height(T2)} T1 T2 T1 T2

For every rooted binary tree 𝑇, 𝑠𝑖𝑧𝑒(𝑇)≤ 2 ℎ𝑒𝑖𝑔ℎ𝑡(𝑇)+1 −1

For every rooted binary tree 𝑇, 𝑠𝑖𝑧𝑒(𝑇)≤ 2 ℎ𝑒𝑖𝑔ℎ𝑡(𝑇)+1 −1