Theory of Computation Lecture 6: Primitive Recursive Functions I

Slides:



Advertisements
Similar presentations
November 19, 2009Theory of Computation Lecture 19: Calculations on Strings IV 1 Numerical Representation of Strings Correspondingly, we define the following:
Advertisements

1 Turing Machines and Equivalent Models Section 13.2 The Church-Turing Thesis.
Primitive Recursive Functions (Chapter 3)
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.
Mu-Recursive Functions
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Computability (Chapter 2) ICS 535 Design and Implementation.
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 24, 2009Theory of Computation Lecture 6: Primitive Recursive Functions II 1 Homework Questions Question 1: Write a program P that computes 
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, …,
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
November 3, 2009Theory of Computation Lecture 14: A Universal Program VI 1 Recursively Enumerable Sets Definition: We write: W n = {x  N |  (x, n) 
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.
Algorithms: Selected Exercises Goals Introduce the concept & basic properties of an algorithm.
 Simplify the following. Section Sum: 2. Difference: 3. Product: 4. Quotient: 5. Composition:
December 1, 2009Theory of Computation Lecture 21: Turing Machines II 1 Simulation of L n in T We will now construct a Post-Turing program Q that simulates.
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.
Activity 2.5 Inflated Balloons. Read page 224 and do problems 1 through 3 Do problem 4 in your groups Do problem 5 in your groups Do problem 6 in your.
5.1 Composite Functions Goals 1.Form f(g(x)) = (f  g) (x) 2.Show that 2 Composites are Equal.
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
Aim: What is the composition of functions? Do Now: Given: Express z in terms of x HW: Work sheet.
Review of 1.4 (Graphing) Compare the graph with.
Chapter 2 The z-transform and Fourier Transforms The Z Transform The Inverse of Z Transform The Prosperity of Z Transform System Function System Function.
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
A. The parent graph is translated up 0.5 units.
Theory of Computation Lecture 10: A Universal Program I
Theory of Computation Lecture 4: Programs and Computable Functions II
Theory of Computation Lecture 12: A Universal Program III
Add and subtract complex numbers
Theory Of Computer Science
Functions and Their Graphs RAFIZAH KECHIL, UiTM PULAU PINANG
Diagonalization and Reducibility
Theory of Computation Lecture 14: A Universal Program V
Recursively Enumerable Sets
Numerical Representation of Strings
Theory of Computation Lecture 22: Turing Machines III
Theory of Computation Lecture 16: A Universal Program VII
Theory of Computation Lecture 5: Programs and Computable Functions III
Copyright 2013, 2009, 2005, 2001, Pearson Education, Inc.
5.1 Combining Functions Perform arithmetic operations on functions
Theory Of Computer Science
Combinations of Functions:
The Programming Language L
Activity 2.8 Study Time.
Functions and their Combinations
Pairing Functions and Gödel Numbers
Theory of Computation Lecture 21: Turing Machines II
Diagonalization and Reducibility
Recursively Enumerable Sets
Primitive Recursive Predicates
Theory of Computation Lecture 5: Programs and Computable Functions III
The Programming Language L
Numerical Representation of Strings
Theory of Computation Lecture 4: Programs and Computable Functions II
Theory of Computation Lecture 9: A Universal Program I
Replace inside with “x” of other function
Pairing Functions and Gödel Numbers
Theory of Computation Lecture 6: Primitive Recursive Functions I
Some Primitive Recursive Functions
Theory of Computation Lecture 22: Turing Machines II
Theory of Computation Lecture 13: A Universal Program V
Recursively Enumerable Sets
Theory of Computation Lecture 17: Calculations on Strings II
Theory of Computation Lecture 11: A Universal Program III
Theory of Computation Lecture 23: Turing Machines III
Do Now: Given: Express z in terms of x HW: p.159 # 4,6,8,
ADDITIONAL ANALYSIS TECHNIQUES
12 Chapter Chapter 2 Exponential and Logarithmic Functions.
Presentation transcript:

Theory of Computation Lecture 6: Primitive Recursive Functions I Sample 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: X  X-1 IF X0 GOTO A2 [A1] Z  Z+1 IF Z0 GOTO A1 [A2] X  X-1 Y  Y+1 IF X  0 GOTO A2 Y  Y-1 September 21, 2017 Theory of Computation Lecture 6: Primitive Recursive Functions I

Theory of Computation Lecture 6: Primitive Recursive Functions I Sample 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 21, 2017 Theory of Computation Lecture 6: Primitive Recursive Functions I

Theory of Computation Lecture 6: Primitive Recursive Functions I Sample Questions b) Now comes the best part: Expand all macros in S using the method we discussed in the lecture. Z2  0 // expansion of Y  p(X) with m = 2 Z3  X Z4  0 Z3  Z3-1 IF Z30 GOTO A4 [A3] Z4  Z4-1 IF Z40 GOTO A3 [A4] Z3  Z3-1 Z2  Z2+1 Z2  Z2-1 Y  Z2 Z5  0 // exp. of Y  p(Y) with m = 5 Z6  Y Z7  0 Z6  Z6-1 IF Z60 GOTO A7 [A6] Z7  Z7+1 IF Z70 GOTO A6 [A7] Z6  Z6-1 Z5  Z5+1 Z5  Z5-1 Y  Z5 September 21, 2017 Theory of Computation Lecture 6: Primitive Recursive Functions I

(Partially) Computable Functions By introducing macros, we have seen that it is possible to compute complex functions with our very simple programming language L . Notice that macros do not change the specification of the language, but they just simplify writing down programs. As you know, we can always replace macros with actual code. So what are the limitations of the language L ? In order to find out, we need to do some mathematics. September 21, 2017 Theory of Computation Lecture 6: Primitive Recursive Functions I

Theory of Computation Lecture 6: Primitive Recursive Functions I Composition Let us combine computable functions in such a way that the output of one becomes an input to another. For example, we could combine the functions f and g to obtain a new function h: h(x) = f(g(x)) Let us now take a more general view: Definition: Let f be a function of k variables and let g1, …, gk be functions of n variables. Let h(x1, …, xn) = f(g1(x1, …, xn), …, gk(x1, …, xn)). Then h is said to be obtained from f and g1, …, gk by composition. September 21, 2017 Theory of Computation Lecture 6: Primitive Recursive Functions I

Theory of Computation Lecture 6: Primitive Recursive Functions I Composition Theorem 1.1: If h is obtained from the (partially) computable functions f, g1, …, gk by composition, then h is (partially) computable. Proof: The following program obviously computes h: Z1 ← g1(X1, …, Xn) : Zk ← gk(X1, …, Xn) Y ← f(Z1, …, Zk) If f, g1, …, gk are not only partially computable but are also total, then so is h. ■ September 21, 2017 Theory of Computation Lecture 6: Primitive Recursive Functions I

Theory of Computation Lecture 6: Primitive Recursive Functions I Composition Let us combine computable functions in such a way that the output of one becomes an input to another. For example, we could combine the functions f and g to obtain a new function h: h(x) = f(g(x)) Let us now take a more general view: Definition: Let f be a function of k variables and let g1, …, gk be functions of n variables. Let h(x1, …, xn) = f(g1(x1, …, xn), …, gk(x1, …, xn)). Then h is said to be obtained from f and g1, …, gk by composition. September 21, 2017 Theory of Computation Lecture 6: Primitive Recursive Functions I

Theory of Computation Lecture 6: Primitive Recursive Functions I Composition Theorem 1.1: If h is obtained from the (partially) computable functions f, g1, …, gk by composition, then h is (partially) computable. Proof: The following program obviously computes h: Z1 ← g1(X1, …, Xn) : Zk ← gk(X1, …, Xn) Y ← f(Z1, …, Zk) If f, g1, …, gk are not only partially computable but are also total, then so is h. ■ September 21, 2017 Theory of Computation Lecture 6: Primitive Recursive Functions I