Recursive Definitions 3 4 Recursion In induction we

  • Slides: 11
Download presentation

Recursive Definitions (재귀의 정의) 3. 4 Recursion In induction, we prove all members of

Recursive Definitions (재귀의 정의) 3. 4 Recursion In induction, we prove all members of an infinite set have some property P by proving the truth for larger members in terms of that of smaller members. (귀납적 정의에서는, “무한 집합의 모든 멤버가 어떠한 성질 P를 가짐”을 보이기 위하여, “작은 멤버들을 사용하여 큰 멤버들이 참(P의 성질을 가짐)임”을 증명하 는 방법을 사용하였다. ) In recursive definitions, we similarly define a function, a predicate or a set over an infinite number of elements by defining the function or predicate value or set-membership of larger elements in terms of that of smaller ones. (재귀적 정의에서는, “작은 멤버들에 함수/술어/집합을 적용(정의)하여 모든 멤 버들을 정의”하는 방법을 사용한다. ) 2 Discrete Mathematics by Yang-Sae Moon

Recursion (재귀) 3. 4 Recursion is a general term for the practice of defining

Recursion (재귀) 3. 4 Recursion is a general term for the practice of defining an object in terms of itself (or of part of itself). (재귀란 객체를 정의하는데 있어서 해당 객체 자신을 사용하는 것을 의미한다. ) An inductive proof establishes the truth of P(n+1) recursively in terms of P(n). (귀납적 증명은 P(n+1)이 참임을 증명하기 위하여 재귀적으로 P(n)을 사용하는 것으로 해석할 수 있다. ) There also recursive algorithms, definitions, functions, sequences, and sets. 3 Discrete Mathematics by Yang-Sae Moon

Recursively Defined Functions 3. 4 Recursion Simplest case: One way to define a function

Recursively Defined Functions 3. 4 Recursion Simplest case: One way to define a function f: N S (for any set S) or series an=f(n) is to: • Define f(0). • For n>0, define f(n) in terms of f(0), …, f(n− 1). E. g. : Define the series an : ≡ 2 n recursively: • Let a 0 : ≡ 1. • For n>0, let an : ≡ 2 an-1. 4 Discrete Mathematics by Yang-Sae Moon

Another Example 3. 4 Recursion Suppose we define f(n) for all n N recursively

Another Example 3. 4 Recursion Suppose we define f(n) for all n N recursively by: • Let f(0)=3 • For all n N, let f(n+1)=2 f(n)+3 What are the values of the following? • f(1)= 9 f(2)= 21 f(3)= 45 f(4)= 93 5 Discrete Mathematics by Yang-Sae Moon

Recursive Definition of Factorial 3. 4 Recursion Given an inductive definition of the factorial

Recursive Definition of Factorial 3. 4 Recursion Given an inductive definition of the factorial function F(n) : ≡ n! : ≡ 2 3 … n. • Base case: F(0) : ≡ 1 • Recursive part: F(n) : ≡ n F(n-1). − F(1)=1 − F(2)=2 − F(3)=6 6 Discrete Mathematics by Yang-Sae Moon

The Fibonacci Series 3. 4 Recursion The Fibonacci series fn≥ 0 is a famous

The Fibonacci Series 3. 4 Recursion The Fibonacci series fn≥ 0 is a famous series defined by: f 0 : ≡ 0, f 1 : ≡ 1, fn≥ 2 : ≡ fn− 1 + fn− 2 0 1 1 2 3 5 8 13 7 Discrete Mathematics by Yang-Sae Moon

Inductive Proof about Fibonacci Series 3. 4 Recursion Theorem: fn < 2 n. Proof:

Inductive Proof about Fibonacci Series 3. 4 Recursion Theorem: fn < 2 n. Proof: By induction. • Base cases: f 0 = 0 < 20 = 1 f 1 = 1 < 2 1 = 2 • Inductive step: Use 2 nd principle of induction (strong induction). Assume k<n, fk < 2 k. Then fn = fn− 1 + fn− 2 is < 2 n− 1 + 2 n− 2 < 2 n− 1 + 2 n− 1 = 2 n. 8 Discrete Mathematics by Yang-Sae Moon

Recursively Defined Sets 3. 4 Recursion An infinite set S may be defined recursively,

Recursively Defined Sets 3. 4 Recursion An infinite set S may be defined recursively, by giving: • A small finite set of base elements of S. (유한 개수의 기본 원소를 제시) • A rule for constructing new elements of S from previouslyestablished elements. (새로운 원소를 만드는 방법을 제시) Example: Let 3 S, and let x+y S if x, y S. What is S? (= {3, 6, 9, 12, 15, …}) 9 Discrete Mathematics by Yang-Sae Moon

The Set of All Strings – skip 3. 4 Recursion Given an alphabet ,

The Set of All Strings – skip 3. 4 Recursion Given an alphabet , the set * of all strings over can be recursively defined as: * ( : ≡ “”, the empty string) w * x → wx * 10 Discrete Mathematics by Yang-Sae Moon

Useful Information 3. 4 Recursion I will not handle “structural induction, ” and thus,

Useful Information 3. 4 Recursion I will not handle “structural induction, ” and thus, you may skip pp. 258 -268 in the text book. 11 Discrete Mathematics by Yang-Sae Moon