Download Pairing Functions and Gödel Numbers Pairing Functions and Gödel

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

A New Kind of Science wikipedia , lookup

Theorem wikipedia , lookup

Infinitesimal wikipedia , lookup

Large numbers wikipedia , lookup

Topological quantum field theory wikipedia , lookup

Set theory wikipedia , lookup

Elementary mathematics wikipedia , lookup

Addition wikipedia , lookup

Mathematical logic wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Foundations of mathematics wikipedia , lookup

Mathematics of radio engineering wikipedia , lookup

List of first-order theories wikipedia , lookup

Gödel's incompleteness theorems wikipedia , lookup

Naive set theory wikipedia , lookup

List of important publications in mathematics wikipedia , lookup

Transcript
10/6/2016
Pairing Functions and Gödel Numbers
Pairing Functions and Gödel Numbers
x, y + 1 = 2x(2y + 1).
How can we code pairs of numbers by single
numbers?
Let us define the following primitive recursive
function:
If z is any given number, there is a unique solution
x, y to the equation
x, y = z.
x is the largest number such that 2x | (z + 1),
and y is the solution of the equation
x, y = 2x(2y + 1) -° 1.
Obviously, 2x(2y + 1) can never be 0, so we have:
2y + 1 = (z + 1)/2x.
x, y + 1 = 2x(2y + 1).
This equation has a unique solution because
(z + 1)/2x must be odd
(if it were even, we could have chosen a greater x).
October 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
1
Pairing Functions and Gödel Numbers
x, y + 1 = 2x(2y + 1).
x, y = 36
x=0
y = 18
x, y = 31
x=5
y=0
x, y = 0
x=0
y=0
October 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
3
Theorem 8.1 (Pairing Function Theorem):
The functions x, y, l(z) and r(z) have the following
properties:
they are primitive recursive;
l(x, y) = x; r(x, y) = y;
l(z), r(z) = z;
l(z), r(z) ≤ z.
October 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
2
Pairing Functions and Gödel Numbers
showing that l(z) and r(z) are primitive recursive
functions.
It is also true that x, y = z ⇔ x = l(z) & y = r(z).
Pairing Functions and Gödel Numbers
1.
2.
3.
4.
Theory of Computation
Lecture 10: A Universal Program II
This way the equation x, y = z defines functions
x = l(z) and y = r(z).
x, y = z also implies that x, y < z + 1, and therefore
l(z) ≤ z, r(z) ≤ z.
Then we can write:
l(z) = minx≤z[(∃y)≤z(z = x, y)],
r(z) = miny≤z[(∃x)≤z(z = x, y)],
Examples:
x, y = 41
x=1
y = 10
October 6, 2016
5
October 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
4
Pairing Functions and Gödel Numbers
We now want to develop primitive recursive functions
that encode and decode arbitrary finite sequences of
numbers.
Our method (actually invented by Gödel) will be
based on the prime power decomposition of integers.
We define the Gödel number of the sequence
(a1, …, an) to be the number
For example, the Gödel number of the sequence
(7, 6, 4, 4, 3) is
27 ⋅ 36 ⋅ 54 ⋅ 74 ⋅ 113.
October 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
6
1
10/6/2016
Pairing Functions and Gödel Numbers
For each n, the function [a1, …, an] is clearly primitive
recursive.
Gödel numbering satisfies the following uniqueness
property:
Theorem 8.2:
If [a1, …, an] = [b1, …, bn] then ai = bi for i = 1, …, n.
This follows immediately from the fundamental
theorem of arithmetic, i.e., the uniqueness of the
factorization of integers into primes.
October 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
7
Pairing Functions and Gödel Numbers
However, it is important to note that
[a1, …, an] = [a1, …, an, 0],
because for any n+1, p0n+1 = 1.
Actually, we could add any number of 0s to the right
end of a sequence without changing its Gödel
number.
Since we have 1 = 20 = 2030 = 203050 = … ,
it is useful to define 1 as the Gödel number of the
empty sequence of length 0.
October 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
8
Pairing Functions and Gödel Numbers
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:
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).
[1, 4] = 21 ⋅ 34 = 162
[1, 4, 0] = 21 ⋅ 34 ⋅ 50 = 162
[0, 1, 4] = 20 ⋅ 31 ⋅ 54 = 1875
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 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
9
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):
a. ([a1, …, an])i = ai
b. ([(x)1, …, (x)n]) = x
October 6, 2016
if
if
1≤i≤n
n ≥ Lt(x)
Theory of Computation
Lecture 10: A Universal Program II
11
October 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
10
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 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
12
2
10/6/2016
Coding Programs by Numbers
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 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
13
Coding Programs by Numbers
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.
Theory of Computation
Lecture 10: A Universal Program II
October 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
14
Coding Programs by Numbers
Examples:
October 6, 2016
Then we write
#(I) = a, b, c ,
where
1. if I is unlabeled, then a = 0; if I is labeled L, then
a = #(L);
2. if the variable V is mentioned in I, then c = #(V) – 1;
3. if the statement in I is V ← V, V ← V+1, or
V ← V-1, then b = 0, 1, or 2, respectively;
4. if the statement in I is IF V≠0 GOTO L’
then b = #(L’) + 2.
15
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 6, 2016
Theory of Computation
Lecture 10: A Universal Program II
16
3