October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 1Universality Then we append the following instruction: [C]IF K = Lt(Z) + 1 

Slides:



Advertisements
Similar presentations
1 Turing Machines and Equivalent Models Section 13.2 The Church-Turing Thesis.
Advertisements

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.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
3.3 Divisibility Definition If n and d are integers, then n is divisible by d if, and only if, n = dk for some integer k. d | n  There exists an integer.
Mu-Recursive Functions
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
November 10, 2009Theory of Computation Lecture 16: Computation on Strings I 1Diagonalization Another example: Let TOT be the set of all numbers p such.
CHAPTER 4 Decidability Contents Decidable Languages
CS 5000: Lecture 37 Vladimir Kulyukin Department of Computer Science Utah State University.
December 8, 2009Theory of Computation Lecture 22: Turing Machines IV 1 Turing Machines Theorem 1.1: Any partial function that can be computed by a Post-
October 8, 2009Theory of Computation Lecture 10: A Universal Program II 1 Pairing Functions and Gödel Numbers This way the equation  x, y  = z defines.
Computability and Complexity 10-1 Computability and Complexity Andrei Bulatov Gödel’s Incompleteness Theorem.
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.
Lecture 18 Various TMs. Allow the head not move Theorem. If the head is allowed to stay at the cell in each move, then every function computed by the.
Introduction to AEP In information theory, the asymptotic equipartition property (AEP) is the analog of the law of large numbers. This law states that.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
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.
Specifying Languages Our aim is to be able to specify languages for use in the computer. The sketch of an FSA is easy for us to understand, but difficult.
Chapter 10 Computable Functions Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
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
Computability Go over homework problems. Godel numbering. Homework: prepare for midterm.
Lecture 3: Count Programs, While Programs and Recursively Defined Functions 虞台文 大同大學資工所 智慧型多媒體研究室.
November 12, 2009Theory of Computation Lecture 17: Calculations on Strings II 1 Numerical Representation of Strings First, we define two primitive recursive.
Recursively Enumerable and Recursive Languages
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
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
Theory of Computation Lecture 10: A Universal Program I
Theory of Computation Lecture 12: A Universal Program III
Theory Of Computer Science
Diagonalization and Reducibility
Theory of Computation Lecture 23: Turing Machines IV
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
Theory of Computation Lecture 6: Primitive Recursive Functions I
Theory Of Computer Science
The Programming Language L
Pairing Functions and Gödel Numbers
Theory of Computation Lecture 21: Turing Machines II
Numerical Representation of Strings
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
Numerical Representation of Strings
Theory of Computation Lecture 9: A Universal Program I
Pairing Functions and Gödel Numbers
Theory of Computation Lecture 6: Primitive Recursive Functions I
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 12: A Universal Program IV
Theory of Computation Lecture 11: A Universal Program III
Theory of Computation Lecture 23: Turing Machines III
Presentation transcript:

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 1Universality Then we append the following instruction: [C]IF K = Lt(Z) + 1  K = 0 GOTO F So if the computation has ended, GOTO F, where the proper value will be output. Otherwise, the current instruction is decoded and executed: U  r((Z) K ) P  p r(U)+1 Remember that (Z) K =  a,  b, c  is the number of the K-th instruction. So U =  b, c  is the code of the statement to be executed. The variable mentioned in this statement is the (c + 1)-th, i.e., the (r(U) + 1)-th.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 2Universality Then l(U) contains the type of the instruction to be executed. IF l(U) = 0 GOTO N IF l(U) = 1 GOTO A IF  (P | S) GOTO N IF l(U) = 2 GOTO M If either the instruction is V  V, or the instruction is V  V-1 and V = 0 (as indicated by the absence of P in S), or the instruction is IF V  0 GOTO L and V = 0, then nothing is done to S (“nothing” - GOTO N). If the instruction is V  V+1, then the exponent of P in S needs to be incremented (“add” – GOTO A). If the instruction is V  V-1 with V > 0, then the exponent of P in S needs to be decremented (“minus” – GOTO M).

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 3Universality If none of the four previous predicates were true, a GOTO command has to be executed: K  min i  Lt(Z) [l((Z) i ) + 2 = l(U)] GOTO C So if the label l(U) – 2 exists in the program, the number K of the next instruction to be executed will be set to the first instruction with that label. Otherwise, K will be set to 0. As you remember, if K = 0 or K = Lt(Z) + 1, then the computation stops. In any case, our interpreter program executes a GOTO C to execute the next instruction.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 4Universality The program continues as follows: [M]S   S/P  GOTO N [A]S  S  P [N]K  K+1 GOTO C The value of the variable in the current instruction is decremented or incremented by 1 by dividing or multiplying S by P, respectively. Then K is incremented and the next instruction executed.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 5Universality The program concludes with the following line: [F]Y  (S) 1 This way, after termination of the interpreted program, its output value becomes the output value of the interpreter. On the next slide, we will list the entire interpreter program.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 6Universality Z  X n S   n i=1 (p 2i ) X i K  1 [C]IF K = Lt(Z) + 1  K = 0 GOTO F U  r((Z) K ) P  p r(U)+1 IF l(U) = 0 GOTO N IF l(U) = 1 GOTO A IF  (P | S) GOTO N IF l(U) = 2 GOTO M K  min i  Lt(Z) [l((Z) i ) + 2 = l(U)] GOTO C [M]S   S/P  GOTO N [A]S  S  P [N]K  K+1 GOTO C [F]Y  (S) 1

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 7Universality For each n > 0, the sequence  (n) (x 1, …, x n, 0),  (n) (x 1, …, x n, 1), … enumerates all partially computable functions of n variables. We can also write:  y (n) (x 1, …, x n ) =  (n) (x 1, …, x n, y). We can omit the superscript (n) when n = 1:  y (x) =  (x, y) =  (1) (x, y).

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 8Universality Consider the following predicates: STP (n) (x 1, …, x n, y, t)  Program number y halts after t or fewer steps on inputs x 1, …, x n  There is a computation of program y of length  t + 1, beginning with inputs x 1, …, x n These predicates are computable, which we can easily prove: We can simply add a counter to our universal programs to determine when we have simulated t steps.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 9Universality Consider the following predicates: STP (n) (x 1, …, x n, y, t)  Program number y halts after t or fewer steps on inputs x 1, …, x n  There is a computation of program y of length  t + 1, beginning with inputs x 1, …, x n These predicates are computable, which we can easily prove: We can simply add a counter to our universal programs to determine when we have simulated t steps.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 10Universality We can prove an even stronger theorem: Theorem 3.2 (Step-Counter Theorem): For each n > 0, the predicate STP (n) (x 1, …, x n, y, t) is primitive recursive. Proof: We will provide numerical descriptions of the notions of snapshot and successor snapshot. This will show that the necessary functions are primitive recursive. See pages 74 and 75 in the textbook for the proof.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 11Universality Now that we know the Step-Counter Theorem, we are ready for yet another theorem. Proving this theorem will be similar to the last one. Theorem 3.3 (Normal Form Theorem): Let f(x 1, …, x n ) be a partially computable function. Then there is a primitive recursive predicate R(x 1, …, x n, y) such that f(x 1, …, x n ) = l(min z R(x 1, …, x n, z))

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 12UniversalityProof: Let y 0 be the number of a program that computes f(x 1, …, x n ). Then consider the equation f(x 1, …, x n ) = l(min z R(x 1, …, x n, z)), where R(x 1, …, x n, z) is the predicate STP (n) (x 1, …, x n, y 0, r(z)) & (r(SNAP (n) (x 1, …, x n, y 0, r(z)))) 1 = l(z) If the right side of the first equation is defined, then there exists a number z such that STP (n) (x 1, …, x n, y 0, r(z)) and (r(SNAP (n) (x 1, …, x n, y 0, r(z)))) 1 = l(z)

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 13Universality For any such z, the computation by the program with number y 0 has reached a terminal snapshot in r(z) or fewer steps, the computation by the program with number y 0 has reached a terminal snapshot in r(z) or fewer steps, l(z) is the value of the output variable Y, that is, l(z) = f(x 1, …, x n ). l(z) is the value of the output variable Y, that is, l(z) = f(x 1, …, x n ). If the right side of the equation is undefined, it must be true that STP (n) (x 1, …, x n, y 0, t) is false for all values of t, that is, f(x 1, …, x n ) is undefined.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 14Universality Theorem 3.4: A function is partially computable if and only if it can be obtained from the initial functions by a finite number of applications of composition, recursion, and minimalization. Proof: It follows from Theorems 1.1, 2.1, 2.2, 3.1, and 7.2 in Chapter 3 that every function that can be so obtained is partially computable.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 15Universality Now let us consider the “opposite direction” of the Normal Form Theorem (Theorem 3.3): We can use the normal form theorem to write any given partially computable function in the form l(min y R(x 1, …, x n, y)), where R is a primitive recursive predicate and therefore is obtained from the initial functions by a finite number of applications of composition and recursion. Finally, our given function is obtained from R by one use of minimalization and then by composition with the primitive recursive function l.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 16Universality When min y R(x 1, …, x n, y)) is a total function (that is, when for each x 1, …, x n there is at least one y for which R(x 1, …, x n, y) is true), we say that we are applying the operation of proper minimalization to R. Now, if l(min y R(x 1, …, x n, y)) is total, then min y R(x 1, …, x n, y) must be total. This gives us the following theorem: Theorem 3.5: A function is computable if and only if it can be obtained from the initial functions by a finite number of applications of composition, recursion, and proper minimalization.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 17 Recursively Enumerable Sets From previous classes, such as CS 320, you may remember the correspondence between predicates and sets. We now want to use the set notation in our discussion of solvable and unsolvable problems. For example, the predicate HALT(x, y) is the characteristic function of the set {(x, y)  N 2 | HALT(x, y)}. We say that a set B  N m belongs to some class of functions if and only if the characteristic function P(x 1, …, x n ) of B belongs to the class in question.

October 27, 2009Theory of Computation Lecture 12: A Universal Program IV 18 Recursively Enumerable Sets Thus, saying that a set B is computable or recursive is the same as saying that P(x 1, …, x n ) is a computable function. Likewise, B is a primitive recursive set if P(x 1, …, x n ) is a primitive recursive predicate. It follows that: Theorem 4.1: Let the sets B, C belong to some PRC class C. Then so do the sets B  C, B  C,  B. Proof: This is an immediate consequence of Theorem 5.1, Chapter 3.