September 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 1 Homework Questions Question 1: Write a program P that computes 

Slides:



Advertisements
Similar presentations
Primitive Recursive Functions (Chapter 3)
Advertisements

Example: Obtain the Maclaurin’s expansion for
October 13, 2009Theory of Computation Lecture 11: A Universal Program III 1 Coding Programs by Numbers Gödel numbers are usually very large, even for small.
The Derivative. Definition Example (1) Find the derivative of f(x) = 4 at any point x.
October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 1Universality Then we append the following instruction: [C]IF K = Lt(Z) + 1 
November 10, 2009Theory of Computation Lecture 16: Computation on Strings I 1Diagonalization Another example: Let TOT be the set of all numbers p such.
September 17, 2009Theory of Computation Lecture 4: Programs and Computable Functions III 1 Macros Now we want to use macros of the form: W  f(V 1, …,
October 1, 2009Theory of Computation Lecture 8: Primitive Recursive Functions IV 1 Primitive Recursive Predicates Theorem 6.1: Let C be a PRC class. If.
November 3, 2009Theory of Computation Lecture 14: A Universal Program VI 1 Recursively Enumerable Sets Definition: We write: W n = {x  N |  (x, n) 
Fall 2002CMSC Discrete Structures1 Yes, No, Maybe... Boolean Algebra.
Key Concept 1. Example 1 Operations with Functions A. Given f (x) = x 2 – 2x, g (x) = 3x – 4, and h (x) = –2x 2 + 1, find the function and domain for.
Chapter 4: A Universal Program 1. Coding programs Example : For our programs P we have variables that are arranged in a certain order: Y 1 X 1 Z 1 X 2.
Computability Turing machines for functions. Recursive functions. Homework: Modify class example for addition to produce contiguous 1s. Construct TM for.
2.4 The Chain Rule Remember the composition of two functions? The chain rule is used when you have the composition of two functions.
Chapter 7 7.6: Function Operations. Function Operations.
1 Section 13.2 The Church-Turing Thesis The Church-Turing Thesis: Anything that is intuitively computable can be be computed by a Turing machine. It is.
1.3 New functions from old functions: Transformations.
5.1 Composite Functions Goals 1.Form f(g(x)) = (f  g) (x) 2.Show that 2 Composites are Equal.
Copyright © 2009 Pearson Education, Inc. CHAPTER 2: More on Functions 2.1 Increasing, Decreasing, and Piecewise Functions; Applications 2.2 The Algebra.
3 DERIVATIVES.  Remember, they are valid only when x is measured in radians.  For more details see Chapter 3, Section 4 or the PowerPoint file Chapter3_Sec4.ppt.
September 29, 2009Theory of Computation Lecture 7: Primitive Recursive Functions III 1 Some Primitive Recursive Functions Example 3: h(x) = x! Here are.
Theory of Computation Lecture 5: Primitive Recursive Functions I
2.4: THE CHAIN RULE. Review: Think About it!!  What is a derivative???
Aim: What is the composition of functions? Do Now: Given: Express z in terms of x HW: Work sheet.
Function Notation Assignment. 1.Given f(x) = 6x+2, what is f(3)? Write down the following problem and use your calculator in order to answer the question.
Boolean Algebra.
Last Answer LETTER I h(x) = 3x 4 – 8x Last Answer LETTER R Without graphing, solve this polynomial: y = x 3 – 12x x.
October 4, 2016Theory of Computation Lecture 9: A Universal Program I 1Minimalization Example 15: R(x, y) R(x, y) is the remainder when x is divided by.
Another Word on PRC Classes
Sec. 4-3: Matrix Multiplication 8/24/17
Operations on Functions Day 1 – Add, Subtract, Multiply and Divide
Theory of Computation Lecture 10: A Universal Program I
Section 2-3b The Product Rule
Theory of Computation Lecture 12: A Universal Program III
Theory Of Computer Science
Derivative of an Exponential
… and now for the Final Topic:
Theory of Computation Lecture 14: A Universal Program V
Recursively Enumerable Sets
Copyright © Cengage Learning. All rights reserved.
Theory of Computation Lecture 5: Programs and Computable Functions III
Product and Quotient Rules
Theory of Computation Lecture 6: Primitive Recursive Functions I
5.1 Combining Functions Perform arithmetic operations on functions
CMSC Discrete Structures
Perform Function Operations and Composition
Yes, No, Maybe... BooleanAlgebra 12/10/2018.
Theory Of Computer Science
Applied Discrete Mathematics Week 4: Functions
Combinations of Functions:
Theory of Computation Lecture 21: Turing Machines II
Copyright © Cengage Learning. All rights reserved.
Recursively Enumerable Sets
Algebra 1 Section 12.9.
Perform the indicated operation.
Primitive Recursive Predicates
Theory of Computation Lecture 5: Programs and Computable Functions III
Name:__________ warm-up 9-3
Theory of Computation Lecture 9: A Universal Program I
Chapter 3 Chain Rule.
Theory of Computation Lecture 6: Primitive Recursive Functions I
Some Primitive Recursive Functions
Theory of Computation Lecture 13: A Universal Program V
Recursively Enumerable Sets
Theory of Computation Lecture 11: A Universal Program III
CMSC Discrete Structures
Operations on Functions
Do Now: Given: Express z in terms of x HW: p.159 # 4,6,8,
Composition of Functions
New function graphs from old ones: Using Transformations
Presentation transcript:

September 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 1 Homework Questions Question 1: Write a program P that computes  P (1) (r) = r-2 using no macros. Notice that we only consider natural numbers! This means that, for example, the expression 1-2 is undefined. Any program computing such an expression must never halt. Sample solution: IF X  0 GOTO B [A]Z  Z+1 IF Z  0 GOTO A [B]X  X-1 IF X  0 GOTO D [C]Z  Z+1 IF Z  0 GOTO C [D]X  X-1 Y  Y+1 IF X  0 GOTO D Y  Y-1

September 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 2 Homework Questions Question 2: a) Write a program S that computes  S (1) (r) = r-4. Use a macro based on program P of the form W  p(V) (which has the effect W  V-2). Sample solution: Y  p(X) Y  p(Y)

September 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 3 Homework Questions b) Now comes the best part: Expand all macros in S using the method we discussed in the lecture. Z 2  0 // expansion of Y  p(X) with m = 2 Z3  XZ3  XZ3  XZ3  X Z4  0Z4  0Z4  0Z4  0 IF Z 3  0 GOTO A 4 [A 3 ]Z 4  Z 4 +1 IF Z 4  0 GOTO A 3 [A 4 ]Z 3  Z 3 -1 IF Z 3  0 GOTO A 6 [A 5 ]Z 4  Z 4 +1 IF Z 4  0 GOTO A 5 [A 6 ]Z 3  Z 3 -1 Z 2  Z 2 +1 IF Z 3  0 GOTO A 6 Z 2  Z 2 -1 Y  Z 2 Z 7  0 // exp. of Y  p(Y) with m = 7 Z8  YZ8  YZ8  YZ8  Y Z9  0Z9  0Z9  0Z9  0 IF Z 8  0 GOTO A 9 [A 8 ]Z 9  Z 9 +1 IF Z 9  0 GOTO A 8 [A 9 ]Z 8  Z 8 -1 IF Z 8  0 GOTO A 11 [A 10 ]Z 9  Z 9 +1 IF Z 9  0 GOTO A 10 [A 11 ]Z 8  Z 8 -1 Z 7  Z 7 +1 IF Z 8  0 GOTO A 11 Z 7  Z 7 -1 Y  Z 7

September 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 4 Some Primitive Recursive Functions So we have learned that every primitive recursive function is computable. We will now look at some examples of primitive recursive functions. In order to prove that a function is primitive recursive, we have to show how that function can be derived from the initial functions by using composition and recursion.

September 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 5 Some Primitive Recursive Functions Remember? The recursive definition of a function looks like this: h(x 1, …, x n, 0) = f(x 1, …, x n ) h(x 1, …, x n, t + 1) = g(t, h(x 1, …, x n, t), x 1, …, x n ). If f is a function of k variables, g 1, …, g k are functions of n variables, and h(x 1, …, x n ) = f(g 1 (x 1, …, x n ), …, g k (x 1, …, x n )). Then h is said to be obtained from f and g 1, …, g k by composition.

September 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 6 Some Primitive Recursive Functions We defined the following initial functions: s(x) = x + 1 n(x) = 0 u i n (x 1, …, x n ) = x i, 1 ≤ i ≤ n.

September 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 7 Some Primitive Recursive Functions Example 1: f(x, y) = x + y We can transform this into a recursive definition: f(x, 0) = x f(x, y + 1) = f(x, y) + 1 This can be rewritten as: f(x, 0) = u 1 1 (x) f(x, y + 1) = g(y, f(x, y), x) where g(x 1, x 2, x 3 ) = s(u 2 3 (x 1, x 2, x 3 )). Obviously, u 1 1 (x), u 2 3 (x 1, x 2, x 3 ), and s(x) are primitive recursive functions – they are initial functions. g(x 1, x 2, x 3 ) is obtained by composition of primitive recursive functions, so it is primitive recursive itself. Therefore, f(x, y) = x + y is primitive recursive.

September 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 8 Some Primitive Recursive Functions Example 2: h(x, y) = x  y We can obtain the following recursive definition: h(x, 0) = 0 h(x, y + 1) = h(x, y) + x This can be rewritten as: h(x, 0) = n(x) h(x, y + 1) = g(y, h(x, y), x) where f(x 1, x 2 ) = x 1 + x 2 and g(x 1, x 2, x 3 ) = f(u 2 3 (x 1, x 2, x 3 ), u 3 3 (x 1, x 2, x 3 )). Obviously, these are all primitive recursive functions. Therefore, h(x, y) = x  y is primitive recursive.