220 likes | 519 Views
Primitive Recursive Predicates. Theorem 6.1: Let C be a PRC class. If f(t, x 1 , …, x n ) belongs to C , then so do the functions. To prove this theorem, we will show that g and h can be obtained from f by primitive recursion. Primitive Recursive Predicates. Proof I:.
E N D
Primitive Recursive Predicates • Theorem 6.1:Let C be a PRC class. • If f(t, x1, …, xn) belongs to C , then so do the functions To prove this theorem, we will show that g and h can be obtained from f by primitive recursion. Theory of Computation Lecture 8: Primitive Recursive Functions IV
Primitive Recursive Predicates • Proof I: can be obtained by recursion in the following way: g(0, x1, …, xn) = f(0, x1, …, xn) g(t + 1, x1, …, xn) = g(t, x1, …, xn) + f(t + 1, x1, …, xn) Since + is primitive recursive, g belongs to C . Theory of Computation Lecture 8: Primitive Recursive Functions IV
Primitive Recursive Predicates • Proof II: can be obtained by recursion in the following way: h(0, x1, …, xn) = f(0, x1, …, xn) h(t + 1, x1, …, xn) = h(t, x1, …, xn) f(t + 1, x1, …, xn) Since is primitive recursive, h belongs to C . Theory of Computation Lecture 8: Primitive Recursive Functions IV
Primitive Recursive Predicates In some cases we might want to begin the iteration at 1 instead of 0: Then we just need to replace the initial recursion equations: g(0, x1, …, xn) = 0 h(0, x1, …, xn) = 1 Theory of Computation Lecture 8: Primitive Recursive Functions IV
Primitive Recursive Predicates As a “by-product” of the preceding idea we obtained the following corollary: Corollary 6.2: If f(t, x1, …, xn) belongs to the PRC class C , then so do the following two functions: Theory of Computation Lecture 8: Primitive Recursive Functions IV
Primitive Recursive Predicates Theorem 6.3: If the predicate P(t, x1, …, xn) belongs to some PRC class C, then so do the following two predicates: (t)y P(t, x1, …, xn) and (t)y P(t, x1, …, xn) Proof: Theory of Computation Lecture 8: Primitive Recursive Functions IV
Primitive Recursive Predicates Sometimes we may want to use the quantifiers (t)<y P(t, x1, …, xn) and (t)<y P(t, x1, …, xn). Then Theorem 6.3 is still valid, which is obvious from the following two relations: (t)<y P(t, x1, …, xn) (t)y [t = y P(t, x1, …, xn)] (t)<y P(t, x1, …, xn) (t)y [t y & P(t, x1, …, xn)] Theory of Computation Lecture 8: Primitive Recursive Functions IV
Primitive Recursive Predicates Example 12: y | x y | x means “y is a divisor of x.” For example, 4 | 15 is false. 3 | 9 is true. This predicate is primitive recursive because y | x (t)x (y t = x). Theory of Computation Lecture 8: Primitive Recursive Functions IV
Primitive Recursive Predicates Example 13: Prime(x) Prime(x) is the predicate “x is a prime.” It is primitive recursive since Prime(x) x > 1 & (t)x [t = 1 t = x (t | x)]. Theory of Computation Lecture 8: Primitive Recursive Functions IV
Minimalization Let the predicate P(t, x1, …, xn) belong to some PRC class C . Then by Theorem 6.1 the function also belongs to C . (Remember the primitive recursive “negation” function we defined earlier.) Theory of Computation Lecture 8: Primitive Recursive Functions IV
Minimalization Let us take a closer look at the function Let us assume that there is a value t0 that is the smallest value of t y for which P(t, x1, …, xn) is true: P(t, x1, …, xn) = 0 for t < t0 P(t0, x1, …, xn) = 1. Then Hence, so that g(y, x1, …, xn) is the least value of t for which P(t, x1, …, xn) is true. Theory of Computation Lecture 8: Primitive Recursive Functions IV
Minimalization Then we define: Thus, minty P(t, x1, …, xn) is the smallest value of tyfor which P(t, x1, …, xn) is true, if such ty exists, otherwise it is 0. Using Theorems 5.4 and 6.3, we have: Theorem 7.1: IfP(t, x1, …, xn) belongs to some PRC Class C and f(y, x1, …, xn) = minty P(t, x1, …, xn), then f also belongs to C . We will call the operation “minty” bounded minimalization. Theory of Computation Lecture 8: Primitive Recursive Functions IV
Minimalization • Example 14: x/y • is the floor function. For example, 8/3 = 2. So x/y is the integer part of the quotient x/y. x/y is primitive recursive as shown by the equation x/y = minty [(t + 1) y > x] Note that this equation gives us x/0 = 0. Theory of Computation Lecture 8: Primitive Recursive Functions IV
Minimalization Example 15: R(x, y) R(x, y) is the remainder when x is divided by y. We can also write R(x, y) = x mod y (“modulo”). Obviously, it is true that x/y = x/y + R(x, y)/y Therefore, we can write: R(x, y) = x - (y x/y) This shows that R(x, y) is primitive recursive. Note that R(x, 0) = x. Theory of Computation Lecture 8: Primitive Recursive Functions IV
Minimalization Example 16: pn Here, for n > 0, pn is the n-th prime number(in order of size). In order to make pn a total function, we set p0 = 0. Then we have: p0 = 0 p1 = 2 p2 = 3 p3 = 5 p4 = 7 Theory of Computation Lecture 8: Primitive Recursive Functions IV
Minimalization Now consider the following recursion equations: p0 = 0 pn+1 = mintpn!+1[Prime(t) & t > pn]. To see that these equations are correct, we must verify the following inequality: pn+1 pn! + 1. Theory of Computation Lecture 8: Primitive Recursive Functions IV
Minimalization pn+1 pn! + 1. Note that for 0 < i n we have: (pn! + 1)/pi = pn!/pi + 1/pi = K + 1/pi , where K is an integer. Why is pn! always divisible by pi ? Example: n = 4, i = 2 Then pn! = 1234567, and pi = 3, so pn!/pi = 124567 = K. In other words, pi is always one of the factors in pn!. According to the equation (pn! + 1)/pi = K + 1/pi ,pn! + 1 is not divisible by any of the primes p1, …, pn. Theory of Computation Lecture 8: Primitive Recursive Functions IV
Minimalization So either pn! + 1 is itself a prime or it is divisible by a prime > pn. In either case there is a prime q such that pn < q pn! + 1, which gives us the inequality that we wanted to verify: pn+1 pn! + 1. Theory of Computation Lecture 8: Primitive Recursive Functions IV