Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pairing Functions and Gödel Numbers

Similar presentations


Presentation on theme: "Pairing Functions and Gödel Numbers"— Presentation transcript:

1 Pairing Functions and Gödel Numbers
Obviously, adding a zero to the left of the sequence will lead to a Gödel number different from the initial one. Examples: [1, 4] = 21  34 = 162 [1, 4, 0] = 21  34  50 = 162 [0, 1, 4] = 20  31  54 = 1875 October 10, 2017 Theory of Computation Lecture 11: A Universal Program II

2 Pairing Functions and Gödel Numbers
We will now define a primitive recursive function (x)i so that if x = [a1, …, an], then (x)i = ai. We set (x)i = mintx(pit+1 | x). Then we define the length Lt(x) of the sequence for the Gödel number x: Lt(x) = minix((x)i  0 & (j)x(j  i  (x)j = 0)). Example: If x = 20 = 22  51 = [2, 0, 1], then (x)1 = 2, (x)2 = 0, (x)3 = 1, (x)4 = (x)5 = … 0, Lt(x) = 3. October 10, 2017 Theory of Computation Lecture 11: A Universal Program II

3 Pairing Functions and Gödel Numbers
If x > 1 and Lt(x) = n, then pn divides x but no prime greater than pn divides x. Note that Lt([a1, …, an]) = n if and only if an  0. Theorem 8.3 (Sequence Number Theorem): ([a1, …, an])i = ai if 1  i  n ([(x)1, …, (x)n]) = x if n  Lt(x) October 10, 2017 Theory of Computation Lecture 11: A Universal Program II

4 Coding Programs by Numbers
After having developed appropriate coding techniques, it will be our goal to enumerate all programs of the language L . In other words, each program P of L will receive a number #(P ) so that the program can be retrieved from its number. Let us first arrange the variables in the following order: Y X1 Z1 X2 Z2 X3 Z3 … And also the labels: A1 B1 C1 D1 E1 A2 B2 C2 D2 E2 A3 … October 10, 2017 Theory of Computation Lecture 11: A Universal Program II

5 Coding Programs by Numbers
We write #(V), #(L) for the position of a given variable or label in the appropriate ordering. For example, #(X2) = 4, #(Z) = 3, #(C2) = 8. Now let I be an instruction (labeled or unlabeled) of the language L . October 10, 2017 Theory of Computation Lecture 11: A Universal Program II

6 Coding Programs by Numbers
Then we write #(I) = a, b, c , where if I is unlabeled, then a = 0; if I is labeled L, then a = #(L); if the variable V is mentioned in I, then c = #(V) – 1; if the statement in I is V  V, V  V+1, or V  V-1, then b = 0, 1, or 2, respectively; if the statement in I is IF V0 GOTO L’ then b = #(L’) + 2. October 10, 2017 Theory of Computation Lecture 11: A Universal Program II

7 Coding Programs by Numbers
Examples: The number of the unlabeled instruction X  X-1 is 0, 2, 1 = 0, 11 = 22. The number of the instruction [A] X  X-1 is 1, 2, 1 = 1, 11 = 45. October 10, 2017 Theory of Computation Lecture 11: A Universal Program II

8 Coding Programs by Numbers
Note that for any given number q there is a unique instruction I with #(I) = q. We first calculate l(q). If l(q) = 0, I is unlabeled; otherwise I has the l(q)-th label in our list. To find the variable mentioned in I, we compute i = r(r(q)) + 1 and locate the i-th variable V in our list. Then the statement will be V  V, V  V+1, or V  V-1, if l(r(q)) = 0, 1, or 2, respectively; otherwise, it will be the statement IF V0 GOTO L, where L is the j-th label in our list and j = l(r(q)) –2. October 10, 2017 Theory of Computation Lecture 11: A Universal Program II

9 Coding Programs by Numbers
Finally, for a program P that consists of the instructions I1, I2, …, Ik, we set #(P ) = [#(I1), #(I2), …, #(Ik)] – 1. This way we associated every possible program in L with a unique number. October 10, 2017 Theory of Computation Lecture 11: A Universal Program II

10 Coding Programs by Numbers
Gödel numbers are usually very large, even for small programs. Let us look at the following example: [A] X  X+1 IF X0 GOTO A #(I1) = 1, 1, 1 = 1, 5 = 21 #(I2) = 0, 3, 1 = 0, 23 = 46 So the number of our small program is 221  346 – 1. October 10, 2017 Theory of Computation Lecture 11: A Universal Program II

11 Coding Programs by Numbers
Note that the number of the unlabeled instruction Y  Y is 0, 0, 0 = 0, 0 = 0. Thus, the number of a program will be unchanged if an unlabeled instruction Y  Y is appended to it. Although this ambiguity is harmless, we avoid it by adding a sentence to our definition of programs of L : The final instruction in a program is not permitted to be the unlabeled statement Y  Y. October 10, 2017 Theory of Computation Lecture 11: A Universal Program II

12 Coding Programs by Numbers
Then each number determines a unique program. As an example, let us determine the program whose number is 199: = 200 = 23  30  52 = [3, 0, 2]. So if #(P ) = 199, P consists of 3 instructions, the second of which is the unlabeled statement Y  Y. 3 = 2, 0 = 2, 0, 0 2 = 0, 1 = 0, 1, 0 Thus, the program is: [B] Y  Y Y  Y Y  Y+1 October 10, 2017 Theory of Computation Lecture 11: A Universal Program II


Download ppt "Pairing Functions and Gödel Numbers"

Similar presentations


Ads by Google