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.

Slides:



Advertisements
Similar presentations
Cognitive Computing 2013 Consciousness and Computations 7. THE SELF APPLICABILITY PROBLEM (SAP); PENROSE ON UNDERSTANDING UNDERSTANDING Mark Bishop.
Advertisements

Completeness and Expressiveness
Lecture 3 Universal TM. Code of a DTM Consider a one-tape DTM M = (Q, Σ, Γ, δ, s). It can be encoded as follows: First, encode each state, each direction,
1 Turing Machines and Equivalent Models Section 13.2 The Church-Turing Thesis.
Primitive Recursive Functions (Chapter 3)
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Copyright © Cengage Learning. All rights reserved.
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.
Induction and recursion
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
CS 454 Theory of Computation Sonoma State University, Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall Original slides by Vahid and.
Discrete Mathematics Lecture 4 Harper Langston New York University.
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.
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.
CS 454 Theory of Computation Sonoma State University, Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall Original slides by Vahid and.
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.
1 Reducibility. 2 Problem is reduced to problem If we can solve problem then we can solve problem.
November 3, 2009Theory of Computation Lecture 14: A Universal Program VI 1 Recursively Enumerable Sets Definition: We write: W n = {x  N |  (x, n) 
Introduction to Proofs
1 Introduction to Abstract Mathematics Chapter 4: Sequences and Mathematical Induction Instructor: Hayk Melikya 4.1- Sequences. 4.2,
1 The Halting Problem and Decidability How powerful is a TM? Any program in a high level language can be simulated by a TM. Any algorithmic procedure carried.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Copyright © Cengage Learning. All rights reserved.
Naïve Set Theory. Basic Definitions Naïve set theory is the non-axiomatic treatment of set theory. In the axiomatic treatment, which we will only allude.
Mathematical Preliminaries
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
CS 3813: Introduction to Formal Languages and Automata Chapter 13 Other Models of Computation These class notes are based on material from our textbook,
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
Lecture 21 Reducibility. Many-one reducibility For two sets A c Σ* and B c Γ*, A ≤ m B if there exists a Turing-computable function f: Σ* → Γ* such that.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
Recursively Enumerable and Recursive Languages
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
Chapters 11 and 12 Decision Problems and Undecidability.
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 14: A Universal Program V
Recursively Enumerable Sets
LIMITS OF ALGORITHMIC COMPUTATION
Theory of Computation Lecture 16: A Universal Program VII
Homework: Friday Read Section 4.1. In particular, you must understand the proofs of Theorems 4.1, 4.2, 4.3, and 4.4, so you can do this homework. Exercises.
Theory of Computation Lecture 6: Primitive Recursive Functions I
CSCE 411 Design and Analysis of Algorithms
Theory Of Computer Science
Computability and Complexity
Proposed in Turing’s 1936 paper
Pairing Functions and Gödel Numbers
Diagonalization and Reducibility
Recursively Enumerable Sets
Theory of Computation Lecture 9: A Universal Program I
Automata, Grammars and Languages
Pairing Functions and Gödel Numbers
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 17: Calculations on Strings II
Theory of Computation Lecture 11: A Universal Program III
Presentation transcript:

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 Z 2 X 3 Z 3 … Similarly labels are ordered: A 1 B 1 C 1 D 1 E 1 A 1 B 1 C 1 D 1 … Definition : #(V) is the position of a variable or label in the given ordering, where V is the label or variable. Example: #(X 3 ) = 6 #(C) = 3 #(X 1 ) = #(X) = 2 2

Coding programs Definition : Let I be (labeled or unlabeled) instruction of the language L. Thus:, where the following points are satisfied: If I is unlabeled, then a = 0; if I is labeled with L, then a = #(L). If the variable V is mentioned in I, then c = #(V) – 1. If the statement in I is either:  V ← V, then b = 0  V ← V + 1, b = 1  V ← V – 1, b = 2 If the statement in I is IF V ≠ 0 GOTO L', then b = #(L') + 2 3

Coding programs Reminder from Chapter 3: Given the following variable ordering: Y X 1, Z 1, X 2, Z 2 … Provided the following label ordering: A 1 B 1 C 1 D 1 E We have a program as follows: [A] X ← X + 1 IF X ≠ 0 GOTO A The instruction numbers for this program are thus: #(I 1 ) = > = > = = 21 #(I 2 ) = > = > = = 46 Definition: The program P number is then calculated as: #(P) = [ #(I 1 ), #(I 2 ), #(I 3 ),... ] - 1 In the program above: #(P) = 2^21 * 3^46 – 1; 4

Coding programs In order to avoid ambiguity of unlabeled Y ← Y instruction, which is > an additional rule is imposed: The final instruction in a program is not permitted to be the unlabeled statement Y ← Y. N.B: The program number thus determines a unique program, which can reconstructed. Example: Given #(P) = 576 = = 5^2 + 23^1 = [ 0, 0, 2, 0, 0, 0, 0, 0, 1 ] – 9 instructions For 2 = = > so unlabeled: Y ← Y + 1 For 1 = = > so labeled: [A] Y ← Y For 0 = >, this will be unlabeled: Y ← Y Empty program has the number 0. 5

The Halting Problem Definition: For a given y, let P be the program such that #(P) = y. Then HALT(x, y) is true if is defined and false if is undefined, so: HALT( x, y ) program number y eventually halts on input x Theorem: HALT( x, x ) is not a computable predicate. Proof: Construct a program P: [A] IF HALT( X, X ) GOTO A Let #(P) = y 0, then HALT( x, y 0 ) ~HALT( x, x ) So we can set x=y 0, thus HALT (y 0,y 0 ) ~HALT(y 0,y 0 ) Contradiction! 6

Insolvability of Halting Problem “There is no algorithm that, given a program of P and an input to that program, can determine whether or not the given program will eventually halt on the given input” (Chapter 4, page 68) Church’s Thesis: Any algorithm for computing on numbers can be carried out by a program of P. See Golbach’s conjecture (every even number greater or equal to 4 is the sum of two prime numbers) for an example of computable program for which it is hard to determine whether it will ever halt. 7

Universality Universality Theorem: For each n > 0, where For each n >0, the function is partially computable. Step-Counter Theorem: For each n > 0, the predicate is primitive recursive, where:, where #(P)=y Program number y halts after t or fewer Steps on inputs x 1, …, x n. 8

Normal Form Theorem 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: Theorem: A function is computable iff can be obtained from the initial functions by a finite number of applications of composition, recursion and (proper ) minimalization 9

Normal Form Theorem Normal Form Theorem Proof: Let y 0 be the program number for f(x 1,…,x n ). when the right-hand side of the equation is defined, then there exists a number z: For any z, the program with number y 0 has reached a terminal snapshot in r(z) or fewer steps and l(z) is in output variable Y. If the right side is undefined, then is false for all t i.e. 10

Recursively Enumerable Sets Theorem: Let the sets B, C belong to some PRC class C. Then so do the sets (prove using predicate union and intersection) Theorem: Let C be a PRC class, and let B be a subset of. Then B belongs to C iff: Definition: The set is called recursively enumerable if there is a partially computable function g(x) such that: belongs to C 11

Recursively Enumerable Sets If B is a recursive set, then B is recursively enumerable. The set B is recursive iff B and are both recursively enumerable. If B and C are recursively enumerable sets so are Enumeration Theorem: A set B is recursively enumerable iff there is an n for which B = W n 12

Recursively Enumerable Sets Definition: K is a set of all numbers n such that program number n eventually halts on input n. K is recursively enumerable but not recursive. Theorem: Let B be a recursively enumerable set. Then there is a primitive recursive predicate R(x,t) such that 13

Recursively Enumerable Sets Theorem: Let S be a nonempty recursively enumerable set. Then there is a primitive recursive function f(u) such that S = { f(n) | n N} = { f(0), f(1), … }, where S is the range of f. Theorem: Let f(x) be a partially computable function and let S = { f(x) | f(x) ↓}, where S is the range. Then S is recursively enumerable. 14

Recursively Enumerable Sets Theorem: Suppose that, then the following statements are all equivalent: –S is recursively enumerable –S is the range of a primitive recursive function –S is the range of a recursive function –S is the range of a partial recursive function 15

The Parameter Theorem s-m-n Theorem: For each n, m > 0 there is a primitive recursive function such that: 16

The Parameter Theorem s-m-n proof: using induction on n. Base case: For program P take n = 1, then the following must be shown to be true: should be the number of the program with m inputs, which must be the same as program number y having m + 1 inputs. #(P) = y So will be the number of the program, that will provide the variable before proceeding with P. 17

The Parameter Theorem s-m-n proof: continued… The instruction will have a number associated with it as follows: > = 16m + 10 Thus may be defined as a primitive recursive function: Induction step: let n = k, then: 18

Diagonalization and Reducibility Definition: Let TOT be the set of all numbers p such that p is the number of a program that computes a total function f(x) of one variable. That is,, where Theorem: TOT is not recursively enumerable.,s 19

Diagonalization and Reducibility Theorem: TOT is not recursively enumerable. Proof: Assume that TOT is recursively enumerable. Then given that, then there is a computable function g(x): and let: Since g(x) is the number of a program that computes a total function, thus h is a computable function. Let P be the program that computes h and p=#(P). Then Contradiction! 20

Diagonalization and Reducibility Theorem: Suppose A ≤ m B, then: –If B is recursive, then A is recursive. –If B is recursively enumerable, then A is as well. Definition: A set A is m-complete if: –A is recursively enumerable and –For every recursively enumerable set B, B ≤ m A 21

Diagonalization and Reducibility If A ≤ m B and B ≤ m C, then A ≤ m C (transitivity) If A is m-complete, B is recursively enumerable and A ≤ m B then B is m-complete. Definition: A B means that A ≤ m B and B ≤ m A Theorem: K and K 0 are m-complete K K 0 Theorem: EMPTY is not recursively enumerable, where 22

Rice's Theorem Examples: Г is the set of computable functions Г is the set of primitive recursive functions Г is the set of partially computable functions that are defined for all but a finite number of values of x Rice’s Theorem: Let Г be a collection of partially computable functions of one variable, such that there are functions f(x), g(x) with f(x) in Г, g(x) not in Г. Then R Г is not recursive. Corollary: There are no algorithms for testing a given program P of the language L to determine whether belongs to any of the classes described in the above examples. What does it mean? If Г is a non-trivial property of functions, then Г is undecidable. 23

Rice's Theorem Proof (using recursion theorem): Let f(x) and g(x) be partially computable functions such that: f(x) Г g(x) Г Suppose is computable. Let and Then, since - is partially computable. Iis not recursive

Rice's Theorem Proof (cont’d): Since is partially computable, by recursion theorem there is a number e s.t.: As and : Contradiction!

26 The Recursion Theorem Recursion Theorem: Let g(z, x 1, …, x m ) be a partially computable function of m + 1 variables. Then, there is a number e such that: Discussion: Given a partially computable function g, we must produce a “program” e that is supplied m arguments and one of the implicit arguments is its own encoding e. We may attempt to prove the theorem by first incrementing a variable e times. But then the problem is that the encoding of such a program will be larger than e! The program P with #(P) = e must contain a “partial description” of itself built-in so that that it can computer its own encoding e from that description.

27 Let Q be the program: Z = Y = g(Z, X 1, X 2, …, X m ) Now, the program P will consist of #(Q) copies of the instruction X m+1 = X m+1 + 1, followed by the program Q. After executing the first #(Q) increments as well as the instruction Z = …, Z holds the number of the program consisting of the #(Q) copies of the instruction followed by the program Q (Remember that as defined in the proof of the parameter theorem computes the # of the program consisting of #(Q) copies of the increment instruction X m+1 = X m followed by program Q). But this is exactly the program P.

The Recursion Theorem Proof: Let g be a partially computable function such as: is the function in the parameter theorem. Then for some z 0 and using s-m-n theorem: Set v = z 0 and, then: Contradiction! 28

The Recursion Theorem Corollary: There is a number e such that for all x: Proof: Let g be a computable function: Using the recursion theorem: Fixed Point Theorem: Let f(z) be a computable function. Then there is a number e such that: Take g(z, x) = 29

Computable functions that are not primitive recursive The primitive recursive functions are precisely the functions from the initial functions (see Chapter 3) Theorem: The unary primitive recursive functions are precisely those obtained from the initial functions s(x) = x + 1, n(x) = 0, l(x), r(x) by applying the following three operations on unary functions: –To go from f(x) and g(x) to f(g(x)) –To go from f(x) and g(x) to –To go from f(x) and g(x) to the function defined by the recursion Theorem: The function f( x, x ) + 1 is a computable function that is not primitive recursive. 30