Some Primitive Recursive Functions

Slides:



Advertisements
Similar presentations
Primitive Recursive Functions (Chapter 3)
Advertisements

Joint and marginal distribution functions For any two random variables X and Y defined on the same sample space, the joint c.d.f. is For an example, see.
3.3 Differentiation Formulas
1 The RSA Algorithm Supplementary Notes Prepared by Raymond Wong Presented by Raymond Wong.
Mu-Recursive Functions
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, …,
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) 
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.
5.5 The Substitution Rule In this section, we will learn: To substitute a new variable in place of an existing expression in a function, making integration.
Composition of Functions. Definition of Composition of Functions The composition of the functions f and g are given by (f o g)(x) = f(g(x))
DERIVATIVES 3. If it were always necessary to compute derivatives directly from the definition, as we did in the Section 3.2, then  Such computations.
DERIVATIVES 3. If it were always necessary to compute derivatives directly from the definition, as we did in the Section 3.2, then  Such computations.
First-Order Differential Equations Part 1
Universidad Nacional de ColombiaUniversidad Nacional de Colombia Facultad de IngenieríaFacultad de Ingeniería Departamento de Sistemas- 2002Departamento.
INTEGRALS The Substitution Rule In this section, we will learn: To substitute a new variable in place of an existing expression in a function,
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.
Chapter 3 DeGroot & Schervish. Functions of a Random Variable the distribution of some function of X suppose X is the rate at which customers are served.
6.4 Inverse Functions Part 1 Goal: Find inverses of linear functions.
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
November 12, 2009Theory of Computation Lecture 17: Calculations on Strings II 1 Numerical Representation of Strings First, we define two primitive recursive.
Direct Proof and Counterexample I Lecture 11 Section 3.1 Fri, Jan 28, 2005.
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.
The Foundations: Logic and Proofs
3 DERIVATIVES.
First-Order Differential Equations
Another Word on PRC Classes
Theory of Computation Lecture 10: A Universal Program I
Theory of Computation Lecture 12: A Universal Program III
Theory Of Computer Science
Chapter 7 Integration.
… and now for the Final Topic:
Diagonalization and Reducibility
Copyright © Cengage Learning. All rights reserved.
Theory of Computation Lecture 14: A Universal Program V
Recursively Enumerable Sets
Copyright © Cengage Learning. All rights reserved.
Theory of Computation Lecture 16: A Universal Program VII
Theory of Computation Lecture 5: Programs and Computable Functions III
Theory of Computation Lecture 6: Primitive Recursive Functions I
Copyright © Cengage Learning. All rights reserved.
CMSC Discrete Structures
Integral Rules; Integration by Substitution
Yes, No, Maybe... BooleanAlgebra 12/10/2018.
Follow me for a walk through...
Theory Of Computer Science
Copyright © Cengage Learning. All rights reserved.
Applied Discrete Mathematics Week 4: Functions
5.1 Power Series Method Section 5.1 p1.
The Chain Rule Theorem Chain Rule
Applied Discrete Mathematics Week 9: Integer Properties
Continuity Alex Karassev.
Applied Discrete Mathematics Week 7: Computation
Copyright © Cengage Learning. All rights reserved.
Diagonalization and Reducibility
Recursively Enumerable Sets
Primitive Recursive Predicates
Numerical Representation of Strings
Theory of Computation Lecture 9: A Universal Program I
Theory of Computation Lecture 6: Primitive Recursive Functions I
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
CMSC Discrete Structures
Presentation transcript:

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. February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Some Primitive Recursive Functions Remember? The recursive definition of a function looks like this: h(x1, …, xn, 0) = f(x1, …, xn) h(x1, …, xn, t + 1) = g(t, h(x1, …, xn, t), x1, …, xn) . If f is a function of k variables, g1, …, gk are functions of n variables, and h(x1, …, xn) = f(g1(x1, …, xn), …, gk(x1, …, xn)). Then h is said to be obtained from f and g1, …, gk by composition. February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Some Primitive Recursive Functions We defined the following initial functions: s(x) = x + 1 n(x) = 0 uin(x1, …, xn) = xi , 1 ≤ i ≤ n. February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

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) = u11(x) f(x, y + 1) = g(y, f(x, y), x) where g(x1, x2, x3) = s(u23(x1, x2, x3)). Obviously, u11(x), u23(x1, x2, x3), and s(x) are primitive recursive functions – they are initial functions. g(x1, x2, x3) is obtained by composition of primitive recursive functions, so it is primitive recursive itself. Therefore, f(x, y) = x + y is primitive recursive. February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

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(x1, x2) = x1 + x2 and g(x1, x2, x3) = f(u23(x1, x2, x3), u33(x1, x2, x3)). Obviously, these are all primitive recursive functions. Therefore, h(x, y) = x  y is primitive recursive. February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Some Primitive Recursive Functions Example 3: h(x) = x! Here are the recursion equations: h(0) = 1 h(t + 1) = h(t)  s(t) This can be rewritten as: h(0) = s(n(t)) h(t + 1) = g(t, h(t)) where g(x1, x2) = s(x1)  x2 , which can be written as: g(x1, x2) = s(u12(x1, x2))  u22(x1, x2). Multiplication is already known to be primitive recursive. Therefore, h(x) = x! is primitive recursive. February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Some Primitive Recursive Functions In the following examples, we just show the recursive mechanism without developing the precise form of the recursion equations. Example 4: xy The recursion equations are: x0 = 1 xy+1 = xy  x February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Some Primitive Recursive Functions Example 5: The predecessor function p(x) It is defined as follows: p(x) = x – 1 if x  0 = 0 if x = 0 The recursion equations are: p(0) = 0 p(t + 1) = t February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Some Primitive Recursive Functions Example 6: x - y (monus) It is defined as follows: x - y = x – y if x  y = 0 if x < y The recursion equations are: x - 0 = x x - (t + 1) = p(x - t) February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Some Primitive Recursive Functions Example 7: | x – y | The function | x – y | is defined as the absolute value of the difference between x and y. It can be written as follows: | x – y | = (x - y) + (y - x) Therefore, | x – y | is primitive recursive. February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Some Primitive Recursive Functions Example 8: (x) (“negation”) The function (x) is defined as follows: (x) = 1 if x = 0 = 0 if x  0 (x) is primitive recursive, because: (x) = 1 - x If we prefer, we can just write down the recursion equations: (0) = 1 (t + 1) = 0 February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Primitive Recursive Predicates Example 9: x = y We can describe this predicate by the function d(x, y): d(x, y) = 1 if x = y = 0 if x  y d(x, y) is primitive recursive because of the following equation: d(x, y) = (|x – y|) February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Primitive Recursive Predicates Example 10: x  y Again, we can describe this predicate by the function d(x, y): d(x, y) = 1 if x  y = 0 if x > y d(x, y) is primitive recursive because of the following equation: d(x, y) = (x – y) February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Primitive Recursive Predicates Theorem 5.1: Let C be a PRC class. If P, Q are predicates that belong to C , then so are P, PQ, and P&Q. Proof: Since P = (P), it follows that P belongs to C . Since P&Q = PQ, it follows that P&Q belongs to C . Since PQ = (P & Q), it follows that PQ belongs to C . February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Primitive Recursive Predicates We already know two different PRC classes, namely the class of all primitive recursive functions, and the class of all computable functions. Correspondingly, we have the following corollaries: Corollary 5.2: If P, Q are primitive recursive predicates, then so are P, PQ, and P&Q. Corollary 5.3: If P, Q are computable predicates, then so are P, PQ, and P&Q. February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Primitive Recursive Predicates Example 11: x < y So far, we only know that x  y and x = y are primitive recursive predicates (Examples 9 and 10). Since we have the tautology x < y  x  y & (x = y) or even simpler: x < y  (y  x) , according to Corollary 5.2, x < y is also a primitive recursive predicate. February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Primitive Recursive Predicates Theorem 5.4: Let C be a PRC class. Let the functions g, h and the predicate P belong to C . Let f(x1, …, xn) = g(x1, …, xn) if P(x1, …, xn) = h(x1, …, xn) otherwise. Then f belongs to C . Proof: f obviously belongs to C , because it can be written as: f(x1, …, xn) = g(x1, …, xn)P(x1, …, xn) + h(x1, …, xn)(P(x1, …, xn)) February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Primitive Recursive Predicates Corollary 5.5: Let C be a PRC class. Let n-ary functions g1, …, gm, h and predicates P1, …, Pm belong to C , and let Pi(x1, …, xn) & Pj(x1, …, xn) = 0 for all 1  i < j  m and all x1, …, xn. If f(x1, …, xn) = g1(x1, …, xn) if P1(x1, …, xn) = g2(x1, …, xn) if P2(x1, …, xn) : : = gm(x1, …, xn) if Pm(x1, …, xn) = h(x1, …, xn) otherwise. Then f belongs to C . February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Primitive Recursive Predicates Proof: The idea is to use induction on the variable m. Theorem 5.4 provides the case for m = 1, so we just have to do the inductive step. Let f(x1, …, xn) = g1(x1, …, xn) if P1(x1, …, xn) : : = gm+1(x1, …, xn) if Pm+1(x1, …, xn) = h(x1, …, xn) otherwise, and let h’(x1, …, xn) = gm+1(x1, …, xn) if Pm+1(x1, …, xn) = h(x1, …, xn) otherwise. Then = gm(x1, …, xn) if Pm(x1, …, xn) = h’(x1, …, xn) otherwise. February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II

Primitive Recursive Predicates The previous steps showed that f belongs to C for m = 1 whenever f belongs to C for a particular m, then f also belongs to C for m + 1. Conclusion: f belongs to C for any natural number m. February 26, 2019 Theory of Computation Lecture 7: Primitive Recursive Functions II