Theor of Computation (Fall 2014): Godel Numbers
-
Upload
vladimir-kulyukin -
Category
Science
-
view
121 -
download
0
Transcript of Theor of Computation (Fall 2014): Godel Numbers
![Page 1: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/1.jpg)
Theory of Computation
Gödel Numbers
Vladimir Kulyukin
www.vkedco.blogspot.comwww.vkedco.blogspot.com
![Page 2: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/2.jpg)
Outline
● Pairing Functions● Gödel Numbers● Gödel Coding & Decoding
![Page 3: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/3.jpg)
Just a Thought on Why Natural Numbers are Natural
Every natural number in the universe is a program awaiting its computer. The program runs if and when its computer appears.
![Page 4: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/4.jpg)
Theory of Program Compilation & Execution
● Programming languages are symbolic formalisms● If we can convert statements of symbolic formalisms into numbers (i.e., any
program P is associated with a unique number), we have the foundations of a mathematical theory of program compilation and program execution (interpretation)
● The gist of the theory is three-fold: ● Given a program P, there is a computable function C (Compiler) such that C(P) =
#(P); this is the compiler● Given #(P), there is a computable function RC (Reverse Compiler) such that
RC(#(P))= P; this function is the reverse compiler● Given a program P, there is a partially computable function VM that can execute
C(P); this is the operating system or the virtual machine
![Page 5: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/5.jpg)
The Big Picture
GÖDEL Coder
GÖDEL Decoder
L Program Number Universal Program
Number
???
GÖDEL Coder = CompilerGÖDEL Decoder = Reverse CompilerUniversal Program = Operating System/VM/Interpreter
![Page 6: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/6.jpg)
Pairing Functions
![Page 7: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/7.jpg)
Pairing Functions
1221,
01122
1122,
yyx
y
yyx
x
x
x
![Page 8: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/8.jpg)
Equation 8.1 (Ch. 3)
., tofor solution
unique a is therenumber, natural a a is If
zyxx, y
z
![Page 9: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/9.jpg)
Equation 8.1 (Ch. 3)
2
12
1
2
112 .5
.1|2such that number largest theis s,other wordIn
.1z| 2max .4
).12(21z .3
).12(21, .2
, .1
x
x
x
d
d
x
x
z
yz
y
zx
x
y
yyx
zyx
![Page 10: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/10.jpg)
Equation 8.1 (Ch. 3): Upper Bound for x & y
., Hence,
.1,1 Therefore,
.12211,
,1122, Since
zyzx
zyzx
yzyx
yzyxx
x
![Page 11: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/11.jpg)
Example 1
.10111115225,0 :Check
.51112
011|2max
11122
10112210,
.10, Solve
0
yy
xx
y
yyx
yx
d
d
x
x
![Page 12: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/12.jpg)
Example 2
.19120112222,2:Check
.251220122
220|2max
20122
191122,
.19, Solve
2
2
yyy
x
y
yyx
yx
d
d
x
x
![Page 13: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/13.jpg)
Splitting Natural Numbers into
Left & Right Constituents
![Page 14: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/14.jpg)
Equation 8.1 (Ch. 03)
.22,219;22,219
.55,010;05,010
:Examples
.,
.,
. , and :functions twodefines 8.1Equation
rrll
rrll
yyxrzr
xyxlzl
Nzzrzl
![Page 15: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/15.jpg)
Lemma
recursive. primitive are and zrzl
![Page 16: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/16.jpg)
Proof
. ,min)(
; ,min)(
Thus, .,,, then , If
yxzxzr
yxzyzl
zyzxyxzNz
zzy
zzx
![Page 17: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/17.jpg)
Theorem 8.1 (Ch. 03)
zzrzzl
zzrzl
yyxrxyxl
zrzlx,y
, 4.
, 3.
,,, 2.
recursive primitive areThey 1.
:properties following thehave ,, functions The
![Page 18: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/18.jpg)
Gödel Numbers
![Page 19: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/19.jpg)
Background
● Kurt Gödel used of logic and set theory to formulate and understand the foundations of mathematics
● Gödel developed a technique to convert formal symbolic statements into natural numbers
● The technique was later called Gödel numbering
![Page 20: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/20.jpg)
Kurt Gödel, 1906 - 1978
![Page 21: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/21.jpg)
Gödel Numbers
n
ii
ain
n
ippaa
aa
i
1
th1
1
prime. theis where,,...,
as defined is sequence thisof number)-(Gnumber
Gödel The numbers. of sequence a be ,...,Let
![Page 22: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/22.jpg)
Example
.5321,3,2
is sequence thisofnumber -G The
.2,3,1 sequence following thehave weSuppose
23123
32
11 ppp
![Page 23: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/23.jpg)
Lemma
recursive. primitive is ,..., ,each For 1 naan
![Page 24: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/24.jpg)
Proof
3. Ch. 6.2,Corollary
by recursive, primitive isfunction recursive primitive a of
product bounded thebecause recursive, primitive is
recursive. primitive is so recursive primitive is
recursive. primitive is
1
n
i
ai
ai
y
i
i
i
p
px
p
![Page 25: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/25.jpg)
Note 1 on Theorem 8.2 (Ch. 3)
....11......
,..., because,0,0,,...,,...,
example,For number.-G its changing without sequence the
ofright the toszero' ofnumber any addcan wegeneral,In
02
01111
111
111
nnan
aan
aan
a
nnn
pppppppp
aaaaaannn
![Page 26: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/26.jpg)
Note 2 on Theorem 8.2 (Ch. 3)
...75325323221
because 1, be to
defined is () sequenceempty theofnumber -G The
0000000000
![Page 27: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/27.jpg)
Note 2 on Theorem 8.2 (Ch. 3)
.755322,1,018322,1
because,2,1,02,1
example,For
.......
because ,,...,,0,...,
general,In number.-G its changingwithout
sequence theofleft the toszero' addcannot We
21021
12011
11
11
nn a
naa
na
nn
ppppp
aaaa
![Page 28: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/28.jpg)
Accessing Individual Elements of
Gödel Numbers
![Page 29: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/29.jpg)
Motivation● We can map every natural number n into its Gödel number g ● Every n has a unique prime factorization, thus its g can be
construed as a sequence of powers of the prime factors of n● We can think of n as an array of numbers and, as with arrays
in other programming languages, we need access to their individual elements
● In our context, we would like to access those individual prime powers
![Page 30: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/30.jpg)
Example
101
20
3
1000
11
100
2
10
1`
532]1,0,1[10
32]2,0[9
.238
7532[0,0,0,1]7
32[1,1]6
532[0,0,1]5
2[2]4
32[0,1] 3
2[1]2
![Page 31: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/31.jpg)
Access Function for Gödel Numbers
.3;4;2
then,3,4,2 if example,For .1 ,function
recursive primitive a define want to We.,...,Let
321
1
xxx
xniax
aax
ii
n
![Page 32: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/32.jpg)
Access Function for Gödel Numbers
. allfor ,00; allfor ,0 that Note
|min
0
1
ixx
xpx
i
ti
xti
![Page 33: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/33.jpg)
Example 01
.2 so ,18|3 but 18;|3 ;18|3 ;18|3
and ;3 because ,218| min18
.1 so,18|2 but ;18|2 ;18|2
and 2; because ,118| min18
Then .322,118Let
3210
21
218
2
210
11
118
1
2122
11
t
pp
t
pp
pp
tttt
t
t
ttt
t
t
![Page 34: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/34.jpg)
Example 02
3108
2108
Then .274323,2108Let
2
1
3222
11
pp
![Page 35: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/35.jpg)
Access Function for G-Numbers: Implementation
// x is a natural number, compute (x)i
long GAccess(long x, long i) {
long p = computePrime(i); // compute i-th prime pi
for t from 0 upto x {
if ( pt does not divide x )
return t – 1;
}
}
![Page 36: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/36.jpg)
Access Function for G-Numbers: Implementation
● The previous slide assumes that we represent G-Numbers as integers● This is a sensible choice, but only for small numbers● If we want to be generic, we can represent G-numbers as sequences of prime
powers, e.g. arrays, lists, etc. ● In this case, we can represent much larger values without actually having to
compute them● Access function becomes much easier, because we do not have to compute
primes or their powers
![Page 37: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/37.jpg)
Lengths of Natural Numbers
![Page 38: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/38.jpg)
Length of a Natural Number
● Since Gödel numbering and access functions give us techniques to split any natural number into its constituents
● Next question: how many constituents does a given natural number have if looked at as a G-number? In other words, how long is the number?
● How long is 20? How long is 7?
![Page 39: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/39.jpg)
Length of a Natural Number: Definition
.010 ,definitionBy
number.-G ain power prime
zero-nonlast theofindex theis s,other wordIn
.0&0min
LtLt
i
xijjxxLt jxixi
![Page 40: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/40.jpg)
How Long is Natural Number 20?
.320
.0...
.1
.1,0,253220
.?20
2054
3
102
Lt
xxx
x
x
Lt
![Page 41: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/41.jpg)
How Long is Natural Number 7?
.47
.0
.1
.1,0,0,075327
.?20
765
4
1000
Lt
xxx
x
x
Lt
![Page 42: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/42.jpg)
Just In Case You Are Not Confused Yet
20 > 7? Sure, but 7 is longer!
![Page 43: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/43.jpg)
Gödel Coding & Decoding
![Page 44: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/44.jpg)
Gödel Coder & Decoder● We will demonstrate that compilation (coding) and reverse
compilation (decoding) are both primitive recursive ● In other words:
Given an L program P, there is a primitive recursive function that maps P to its number #(P)
Given #(P), there is a primitive recursive function that maps #(P) to its source code P
![Page 45: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/45.jpg)
Gödel Coder
● We need to solve three problems:● Problem 1: Mapping variables and labels to numbers● Problem 2: Mapping instructions to numbers● Problem 3: Mapping programs to numbers
![Page 46: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/46.jpg)
Problem 1: Mapping Variables & Labels● We order the variables as follows: Y, X1, Z1, X2, Z2, X3, Z3, … ● We order the labels as follows: A1, B1, C1, D1, E1, A2, B2, C2,
D2, E2, A3, …● Let #(V) be the position of a variable in the variable ordering ● Let #(L) be the position of a label in the label ordering ● Note that the chosen orderings are arbitrary in the sense that
other orderings are possible
![Page 47: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/47.jpg)
Examples of #(V) & #(L)
● We order the variables as follows: Y, X1, Z1, X2, Z2, X3, Z3, …
● We order the labels as follows: A1, B1, C1, D1, E1, A2, B2, C2, D2, E2, A3, …
● #(Y)=1, #(X1)=2, #(X3)=6, #(Z2)=5● #(B1)=2, #(A2)=6, #(C2)=8
![Page 48: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/48.jpg)
Problem 2: Mapping Instructions to Numbers● There are four primitive instruction types in L: addition, subtraction,
self-assignment (no-op), conditional dispatch● There are three pieces of information we have to known in order to
map an instruction to a number: label or no label variable used in the instruction instruction type
![Page 49: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/49.jpg)
Sub-Task 2: Assigning Numbers to Instruction Types
2# n typeinstructio be willThis // 0
2 n typeinstructio be willThis // 1
1 n typeinstructio be willThis // 1
0 n typeinstructio be willThis //
L GOTO LIF V
-VV
VV
VV
![Page 50: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/50.jpg)
Problem 2: Mapping Instructions to Numbers
ninstructio in the used variable theofnumber theis .3
number n typeinstructio theis 2.
number label theis 1.
where,,,#Then n.instructio primitive a be Let
c
b
a
cbaILI
![Page 51: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/51.jpg)
Problem 2: Mapping Instructions to Numbers
.22
case in this that Note .2then ,0! is if 7.
;2 then ,1 is if 6.
;1 then ,1 is if 5.
;0 then , is if .4
;1 then ,in used is variablea if .3
; then , label some with labeled is if 2.
;0 then unlabeled, is if 1.
where,,,#Then n.instructio primitive a beLet
L#b
L#b GOTO LIF VI
b-VVI
bVVI
bVV I
V#cIV
L#aLI
aI
cbaILI
![Page 52: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/52.jpg)
Instruction Coding Example 01
Let I be X1 ← X1 + 1. What is #(I)?
![Page 53: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/53.jpg)
Instruction Coding Example 01
.101111113221
111112222
111,1221,1,0#
Thus, 4.
;21 because ,111 3.
addition; is because ,1 .2
unlabeled; is because ,0 .1
where,,,# so ;111 is
10
0
I
X#X#c
Ib
Ia
cbaIXXI
![Page 54: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/54.jpg)
Instruction Coding Example 02
Let I be [A1] X1 ← X1+1. What is #(I)?
![Page 55: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/55.jpg)
Instruction Coding Example 02
.211112111112222
111,1221,1,1
11#,1,1##
,111 1 is Since
111
1
XAI
XXAI
![Page 56: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/56.jpg)
Problem 3: Definition of #(P)
.1#,...,#,##
thenns,instructio primitive are ,...,, and
0 where,,...,, of consists that program a be Let
21
21
21
k
k
k
IIIP
LIII
kIIIP
![Page 57: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/57.jpg)
Example of #(P)
1 GOTO 0 1 IF
111 1
program? thisofnumber theisWhat
AX
XXA
![Page 58: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/58.jpg)
Example of #(P)
1#,##
Thus,
1 GOTO 0 1 IF is
111 1 is
21
2
1
IIP
AXI
XXAI
![Page 59: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/59.jpg)
Example of #(P)
21111,1221,1,1 So,
11211# .3
1 2.
11# .1
where
,,,111 1## example, previous aBy
1
1
Xc
b
Aa
cbaXXAI
![Page 60: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/60.jpg)
Example of #(P)
.46147112321
111112222
111,3221,3,0# Thus,
.111# .3
;32121# .2
;0 .1
where,,,1 GOTO 0! 1 IF##
30
02
2
I
Xc
Ab
a
cbaAXI
![Page 61: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/61.jpg)
Example of #(P)
.1321]46,21[#
1 GOTO 0 1 IF
111 1
? program thisofnumber theisWhat
4621
P
AX
XXA
P
![Page 62: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/62.jpg)
Back to The Big Picture
GÖDEL Coder
GÖDEL Decoder
L Program Number Universal Program
Number
???
The red arrows show the implemented tasks (program compilation): we now know how to map L programs to numbers.
![Page 63: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/63.jpg)
Gödel Decoder
![Page 64: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/64.jpg)
Gödel Decoder
● Problem 1: Obtain the source code number● Problem 2: Extract from the source code number the
numbers for individual instructions● Problem 3: Extract the source from each individual
instruction number
![Page 65: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/65.jpg)
GÖDEL Decoder: Problem 1
.1##,...,#,#
isnumber code source theThus,
.1#,...,#,##
21
21
PIII
IIIP
k
k
![Page 66: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/66.jpg)
Side Note: A Prime Factorization Algorithm// n is a natural number > 0, i is the prime counter, initially// set to 1. We need this algorithm to solve problem 2 of // Gödel DecodingFactors(n, i)
If n is prime then n is the factorization;If n is composite thenIf pi divides n then
add pi to the list of factors;Factors((n / pi), i);
If pi does not divide n ThenFactors(n, i+1)
![Page 67: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/67.jpg)
Prime Factorization Algorithm: Example
2] 2, [2,return
2] [2,return
[2]return so prime a is 2
1) factors(2, to2 add so
4|2
1) factors(4, to2 add so
8|2
1)factors(8,
1
1
p
p
![Page 68: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/68.jpg)
GÖDEL Decoder: Problem 2
number-G the
i.e., powers, prime oflist obtain the factors, prime oflist theFrom .3
factors prime oflist obtain the to,1,1nfactorsRun 2.
#,...,#,#1 isnumber code source theSo,
1#,...,#,# be Let 1.
21
21
k
k
IIIn
IIIP#n
![Page 69: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/69.jpg)
Examples of Source Code Extraction
lyrespective 1, and 1,0,0, into compile that nsinstructiofour of consists P .3
1475321] 0, 0, [1,number -G the toconverted is [2,7] 2.
[2,7] returns ,1)factors(14 then 13, into compiles P If .1
3number into compilesn that instructio one of consists code source sP' .5
82[3]number -G the toconverted is ]2,2,2[ 4.
2] 2, [2, returns 1)factors(8, 3.
8 is Pfor number code source The 2.
7number into compiled is P program some Suppose 1.
1001
3
![Page 70: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/70.jpg)
GÖDEL Decoder: Problem 3
ordering. variablein the 1 isposition
whose variableis in used variable theThus, . 3.
ordering. label in the 2 isposition
whoselabel is L whereL GOTO 0 ! V IF typeof is 2.4.
;2 if 1 - V V typeof is 2.3.
;1 if 1 V V typeof is 2.2.
;0 if V V typeof is 2.1.
Then . 2.
ordering. label in the
number label has Otherwise, unlabeled. is ,0 If . 1.
.,,#Let
number.-G in then instructioeach of code
source eextract th toneed wenumber,-G thehave that weNow
c
Iqrrc
b-
I
b I
b I
b I
qrlb
ql
IIaqla
cbaqI
![Page 71: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/71.jpg)
#(P) P: GÖDEL Decoding Algorithm
recursive primitive are steps all that Note
3 stepin obtained
number-G theofelement each from code source eExtract th 4.
powers prime of sequence the
get i.e. factors, prime oflist thefromnumber -G Obtain the .3
1,1nFactorsRun 2.
#,...,#,#1 isnumber code source theSo,
;1#,...,#,# be Let 1.
21
21
k
k
IIIn
IIIP#n
![Page 72: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/72.jpg)
GÖDEL Decoding Algorithm: Example1. Let #(P) = 199.2. The source code number = 199+1=200.3. The prime factorization of 200 is 233052. Thus, the G-number = [3,0,2].4. 3 = <2, <0, 0>>. So the label is B1, the instruction variable is Y and the type of instruction is self-assignment. Thus, first instruction is [B1] Y ← Y.5. 0 = <0, <0, 0>>. Thus, second instruction is Y ← Y.6. 2 = <0, <1, 0>>. Thus, third instruction is Y ← Y + 1.
![Page 73: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/73.jpg)
GÖDEL Decoding Algorithm: Example
Let #(P) = 199. The source code number = 199+1=200. So, the source code of P is
[B1] Y ← Y
Y ← Y
Y ← Y + 1
![Page 74: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/74.jpg)
Back To The Big Picture
GÖDEL Coder
GÖDEL Decoder
L Program Number Universal Program
Number
???
GÖDEL Coder = CompilerGÖDEL Decoder = Reverse CompilerUniversal Program = Operating System/VM/Interpreter
![Page 75: Theor of Computation (Fall 2014): Godel Numbers](https://reader034.fdocuments.us/reader034/viewer/2022052311/55871d8fd8b42a9b058b4720/html5/thumbnails/75.jpg)
Reading Suggestions
● Ch. 03, Computability, Complexity, and Languages, 2nd Edition, by Davis, Sigal, Weyuker, Academic Press
● http://en.wikipedia.org/wiki/Kurt_Gödel