In mathematics, a Gödel numbering for sequences provides an effective way to represent each finite sequence of natural numbers as a single natural number. While a set theoretical embedding is surely possible, the emphasis is on the effectiveness of the functions manipulating such representations of sequences: the operations on sequences (accessing individual members, concatenation) can be "implemented" using total recursive functions, and in fact by primitive recursive functions.
It is usually used to build sequential “data types” in arithmetic-based formalizations of some fundamental notions of mathematics. It is a specific case of the more general idea of Gödel numbering. For example, recursive function theory can be regarded as a formalization of the notion of an algorithm, and can be regarded as a programming language to mimic lists by encoding a sequence of natural numbers in a single natural number.[1] [2]
See main article: Gödel numbering.
Besides using Gödel numbering to encode unique sequences of symbols into unique natural numbers (i.e. place numbers into mutually exclusive or one-to-one correspondence with the sequences), we can use it to encode whole “architectures” of sophisticated “machines”. For example, we can encode Markov algorithms,[3] or Turing machines[4] into natural numbers and thereby prove that the expressive power of recursive function theory is no less than that of the former machine-like formalizations of algorithms.
Any such representation of sequences should contain all the information as in the original sequence—most importantly, each individual member must be retrievable. However, the length does not have to match directly; even if we want to handle sequences of different length, we can store length data as a surplus member, or as the other member of an ordered pair by using a pairing function.
We expect that there is an effective way for this information retrieval process in form of an appropriate total recursive function. We want to find a totally recursive function f with the property thatfor all n and for any n-length sequence of natural numbers
\langlea0,...an-1\rangle
0\lei\len-1
f(a,i)=ai
There are effective functions which can retrieve each member of the original sequence from a Gödel number of the sequence. Moreover, we can define some of them in a constructive way, so we can go well beyond mere proofs of existence.
See also: Gödel's β function.
By an ingenious use of the Chinese remainder theorem, we can constructively define such a recursive function
\beta
\beta
Thus, for all n and for any n-length sequence of natural numbers
\langlea0,...an-1\rangle
\beta(a,i)=ai
See main article: Pairing function.
Our specific solution will depend on a pairing function—there are several ways to implement the pairing function, so one method must be selected. Now, we can abstract from the details of the implementation of the pairing function. We need only to know its “interface”: let
\pi
K\left(\pi\left(x,y\right)\right)=x
L\left(\pi\left(x,y\right)\right)=y
We shall use another auxiliary function that will compute the remainder for natural numbers. Examples:
rem(5,3)=2
rem(7,2)=1
It can be proven that this function can be implemented as a recursive function.
Using the Chinese remainder theorem, we can prove that implementing
\beta
\beta(s,i)=rem\left(K\left(s\right),\left(i+1\right) ⋅ L\left(s\right)+1\right)
\beta
\beta\left(\pi\left(x0,m\right),i\right)=rem\left(x0,\left(i+1\right) ⋅ m+1\right)
\foralli<n
mi=(i+1) ⋅ m+1
\beta\left(\pi\left(x0,m\right),i\right)=rem\left(x0,mi\right)
mi
For proving the correctness of the above definition of the
\beta
Let
a0,...an-1
\foralli\in\overlinen\setminus\left\{0\right\}\left(i\midm\right)
\foralli<n\left(ai<mi\right)
1\midm\land...\landn-1\midm
The second assumption does not concern the Chinese remainder theorem in any way. It will have importance in proving that the specification for
\beta
\tildex
x\equivai\pmod{mi}
0\lei\len-1
ai=rem(\tildex,mi)
\foralli<n (ai<m)
mi
In the section Hand-tuned assumptions, we required that
\foralli\in\overlinen\setminus\left\{0\right\}\left(i\midm\right)
In detail:
\foralli<n,j<n \left(i ≠ j → coprime\left(mi,mj\right)\right)
\foralli<n
mi=(i+1) ⋅ m+1
The proof is by contradiction; assume the negation of the original statement:
\existsi<n,j<n \left(i ≠ j\landlnotcoprime\left(mi,mj\right)\right)
We know what “coprime” relation means (in a lucky way, its negation can be formulated in a concise form); thus, let us substitute in the appropriate way:
\existsi<n,j<n \left(i ≠ j\land\existsp\inPrime \left(p\midmi\landp\midmj\right)\right)
\existsi<n,j<n,p\inPrime \left(i ≠ j\landp\midmi\landp\midmj\right)
Because of a theorem on divisibility,
p\midmi\landp\midmj
p\midmi-mj
Substituting the definitions of
mk
mi-mj=(i-j) ⋅ m
p\mid(i-j) ⋅ m
p\midi-j\lorp\midm
Now we must resort to our assumption
\foralli\in\overlinen\setminus\left\{0\right\}\left(i\midm\right)
The assumed negation of the original statement contains an appropriate existential statement using indices
i<n\landj<n\landi ≠ j
i-j\in\overlinen\setminus\left\{0\right\}
i-j\midm
We can prove by several means [11] known in propositional calculus that
\left(A\land\left(A → B\right)\right) → B
Since
i-j\midm
p\midi-j → p\midm
p\midm
The negation of original statement contained
p\midmi
p\midm
p\midmi-\left(i+1\right) ⋅ m
mi
mi-\left(i+1\right) ⋅ m=1
p\mid1
However, in the negation of the original statement p is existentially quantified and restricted to primes
\existsp\inPrime
By reaching contradiction with its negation, we have just proven the original statement:
\foralli<n,j<n \left(i ≠ j → coprime\left(mi,mj\right)\right)
We build a system of simultaneous congruences
x\equiva0\pmod{m0}
\vdots
x\equivan-1\pmod{mn-1
We can write it in a more concise way:
\foralli<n \left(x\equivai\pmod{mi}\right)
Many statements will be said below, all beginning with "
\foralli<n \left(...\right)
\foralli<n \left(...\right)
\foralli<n(
Let us chose a solution
x0
m0,...mn-1
x0
x0\equivai\pmod{mi}
rem\left(x0,mi\right)=rem\left(ai,mi\right)
Recall the second assumption, “
\foralli<n \left(ai<mi\right)
The second assumption
ai<mi
rem\left(ai,mi\right)=ai
rem\left(x0,mi\right)=ai
Our original goal was to prove that the definition
\beta\left(\pi\left(x0,m\right),i\right)=rem\left(x0,mi\right)
\beta
\beta\left(\pi\left(x0,m\right),i\right)=ai
This can be seen now by transitivity of equality, looking at the above three equations.
(The large scope of i ends here.)
We have just proven the correctness of the definition of
\beta
\foralla0,...,an-1 \existss \foralli<n \beta(s,i)=ai
Our ultimate question is: what number should stand for the encoding of sequence
\left\langlea0,...,an-1\right\rangle
This gap can be filled in a straightforward way: we shall use minimalization, and the totality of the resulting function is ensured by everything we have proven till now (i.e. the correctness of the definition of
\beta
\foralla0,...,an-1 \existss \foralli<n \beta(s,i)=ai
f\left(a0,...,an-1,s\right)=0\leftrightarrow\foralli<n \left(\beta(s,i)=ai\right)
\foralla0,...,an-1 \existss \left(f\left(a0,...,an-1,s\right)=0\right)
Thus, let us choose the minimal possible number that fits well in the specification of the
\beta
g:Nn\toN
\left\langlea0,...,an-1\right\rangle\longmapsto\mua.\left[\foralli<n \left(\beta\left(a,i\right)=ai\right)\right]
If we use the above scheme for encoding sequences only in contexts where the length of the sequences is fixed, then no problem arises. In other words, we can use them in an analogous way as arrays are used in programming.
But sometimes we need dynamically stretching sequences, or we need to deal with sequences whose length cannot be typed in a static way. In other words, we may encode sequences in an analogous way to lists in programming.
To illustrate both cases: if we form the Gödel numbering of a Turing machine, then the each row in the matrix of the “program” can be represented with tuples, sequences of fixed length (thus, without storing the length), because the number of the columns is fixed.[14] But if we want to reason about configuration-like things (of Turing-machines), and specifically if we want to encode the significant part of the tape of a running Turing machine, then we have to represent sequences together with their length. We can mimic dynamically stretching sequences by representing sequence concatenation (or at least, augmenting a sequence with one more element) with a totally recursive function.[15]
Length can be stored simply as a surplus member:
g:N*\toN
\left\langlea0,...,an-1,an\right\rangle\longmapsto\mua.\left[a0=n\land\foralli<n \left(\beta\left(a,i+1\right)=ai\right)\right]
The corresponding modification of the proof is straightforward, by adding a surplus
x\equivn\pmod{m0}
f:Nn+1\toN
f\left(a0,...,an-1,s\right)=\begin{cases}0&if \foralli<n \left(\beta(s,i)=ai\right)\ 1&if \existsi<n \left(\beta(s,i) ≠ ai\right)\end{cases}