Supriya Ghosh (Editor)

Gödel numbering for sequences

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

In mathematics, a Gödel numbering for sequences provides us an effective way to represent each finite sequence of natural numbers as a single natural number. Of course, the embedding is surely possible set theoretically, but 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.

Contents

It is usually used to build sequential “data types” in the realm of 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 if we regard it as a programming language, we can mimic lists by encoding a sequence of natural numbers in a single natural number. To achieve this, we can use various number theoretic ideas; using the fundamental theorem of arithmetic is a straightforward way, but there are also more economic approaches, such as using the pairing function combined with the Chinese remainder theorem in a sophisticated way.

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, or Turing machines 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.

Accessing members

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 that for all n and for any n-length sequence of natural numbers a 0 , a n 1 , there exists an appropriate natural number a, called the Gödel number of the sequence, such that for all i where 0 i n 1 , f ( a , i ) = a i .

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.

Gödel's β-function lemma

By an ingenious use of the Chinese remainder theorem, we can constructively define such a recursive function β (using simple number-theoretical functions, all of which can be defined in a total recursive way) fulfilling the specifications given above. Gödel defined the β function using the Chinese remainder theorem in his article written in 1931. This is a primitive recursive function.

Thus, for all n and for any n-length sequence of natural numbers a 0 , a n 1 , there exists an appropriate natural number a, called the Gödel number of the sequence such that β ( a , i ) = a i .

Using a 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 π , K, and L denote the pairing function and its two projection functions, respectively, satisying specification

K ( π ( x , y ) ) = x L ( π ( x , y ) ) = y

We shall not discuss and formalize the axiom for excluding alien objects here, as it is not required to understand the method.

Remainder for natural numbers

We shall use another auxiliary function that will compute the remainder for natural numbers. Examples:

  • r e m ( 5 , 3 ) = 2
  • r e m ( 7 , 2 ) = 1
  • It can be proven that this function can be implemented as a recursive function.

    Using the Chinese remainder theorem

    Implementation of the β function

    Using the Chinese remainder theorem, we can prove that implementing β as

    β ( s , i ) = r e m ( K ( s ) , ( i + 1 ) L ( s ) + 1 )

    will work, according to the specification we expect β to satisfy. We can use a more concise form by an abuse of notation (constituting a sort of pattern matching):

    β ( π ( x 0 , m ) , i ) = r e m ( x 0 , ( i + 1 ) m + 1 )

    Let us achieve even more readability by more modularity and reuse (as these notions are used in computer science): by defining i < n the sequence m i = ( i + 1 ) m + 1 , we can write

    β ( π ( x 0 , m ) , i ) = r e m ( x 0 , m i ) .

    We shall use this m i notation in the proof.

    Hand-tuned assumptions

    For proving the correctness of the above definition of the β function, we shall use several lemmas. These have their own assumptions. Now we try to find out these assumptions, calibrating and tuning their strength carefully: they should not be said in an either superfluously sharp, or unsatisfactorily weak form.

    Let a 0 , a n 1 be a sequence of natural numbers. Let m be chosen to satisfy

    i n ¯ { 0 } ( i m ) i < n ( a i < m i )

    The first assumption is meant as

    1 m n 1 m

    It is needed to meet an assumption of the Chinese remainder theorem (that of being pairwise coprime). In the literature, sometimes this requirement is replaced with a stronger one, e.g. constructively built with the factorial function, but the stronger premise is not required for this proof.

    The second assumption does not concern the Chinese remainder theorem in any way. It will have importance in proving that the specification for β is met eventually. It ensures that an x ~ solution of the simultaneous congruence system

    x a i ( mod m i ) for each i where 0 i n 1

    also satisfies

    a i = r e m ( x ~ , m i ) .

    A stronger assumption for m requiring i < n ( a i < m ) automatically satisfies the second assumption (if we define the notation m i as above).

    Proof that (coprimality) assumption for Chinese remainder theorem is met

    In the section Hand-tuned assumptions, we required that

    i n ¯ { 0 } ( i m ) . What we want to prove is that we can produce a sequence of pairwise coprime numbers in a way that will turn out to correspond to the Implementation of the β function.

    In detail:

    i < n , j < n ( i j c o p r i m e ( m i , m j ) )

    remembering that i < n we defined m i = ( i + 1 ) m + 1 .

    The proof is by contradiction; assume the negation of the original statement:

    i < n , j < n ( i j ¬ c o p r i m e ( m i , m j ) )

    First steps

    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:

    i < n , j < n ( i j p P r i m e ( p m i p m j ) )

    Using a “more” prenex normal form (but note allowing a constraint-like notation in quantifiers):

    i < n , j < n , p P r i m e ( i j p m i p m j )

    Because of a theorem on divisibility, p m i p m j allows us to also say

    p m i m j .

    Substituting the definitions of m k -sequence notation, we get m i m j = ( i j ) m , thus (as equality axioms postulate identity to be a congruence relation ) we get

    p ( i j ) m .

    Since p is a prime element (note that the irreducible element property is used), we get

    p i j p m .

    Resorting to the first hand-tuned assumption

    Now we must resort to our assumption

    i n ¯ { 0 } ( i m ) .

    The assumption was chosen carefully to be as weak as possible, but strong enough to enable us to use it now.

    The assumed negation of the original statement contains an appropriate existential statement using indices i < n j < n i j ; this entails i j n ¯ { 0 } , thus the mentioned assumption can be applied, so i j m holds.

    Using an (object) theorem of the propositional calculus as a lemma

    We can prove by several means known in propositional calculus that

    ( A ( A B ) ) B

    holds.

    Since i j m , by the transitivity property of the divisibility relation, p i j p m . Thus (as equality axioms postulate identity to be a congruence relation )

    p m

    can be proven.

    Reaching the contradiction

    The negation of original statement contained

    p m i

    and we have just proved

    p m .

    Thus,

    p m i ( i + 1 ) m

    should also hold. But after substituting the definition of m i ,

    m i ( i + 1 ) m = 1

    Thus, summarizing the above three statements, by transitivity of the equality,

    p 1

    should also hold.

    However, in the negation of the original statement p is existentially quantified and restricted to primes p P r i m e . This establishes the contradiction we wanted to reach.

    End of reductio ad absurdum

    By reaching contradiction with its negation, we have just proven the original statement:

    i < n , j < n ( i j c o p r i m e ( m i , m j ) )

    The system of simultaneous congruences

    We build a system of simultaneous congruences

    x a 0 ( mod m 0 ) x a n 1 ( mod m n 1 )

    We can write it in a more concise way:

    i < n ( x a i ( mod m i ) )

    Many statements will be said below, all beginning with " i < n ( ) ". To achieve a more ergonomic treatment, from now on all statements should be read as being in the scope of an i < n ( ) quantification. Thus, i < n ( begins here.

    Let us chose a solution x 0 for the system of simultaneous congruences. At least one solution must exist, because m 0 , m n 1 are pairwise comprime as proven in the previous sections, so we can refer to the solution ensured by the Chinese remainder theorem. Thus, from now on we can regard x 0 as satisfying

    x 0 a i ( mod m i ) ,

    which means (by definition of modular arithmetic) that

    r e m ( x 0 , m i ) = r e m ( a i , m i )

    Resorting to the second hand-tuned assumption

    Recall the second assumption, “ i < n ( a i < m i ) ”, and remember that we are now in the scope of an implicit quantification for i, so we don't repeat its quantification for each statement.

    The second assumption a i < m i implies that

    r e m ( a i , m i ) = a i .

    Now by transitivity of equality we get

    r e m ( x 0 , m i ) = a i .

    QED

    Our original goal was to prove that the definition

    β ( π ( x 0 , m ) , i ) = r e m ( x 0 , m i )

    is good for achieving what we declared in the specification of β : we want β ( π ( x 0 , m ) , i ) = a i to hold.

    This can be seen now by transitivity of equality, looking at the above three equations.

    (The large scope of i ends here.)

    Existence and uniqueness

    We have just proven the correctness of the definition of β : its specification requiring

    a 0 , , a n 1 s i < n β ( s , i ) = a i

    is met. Although proving this was most important for establishing an encoding scheme for sequences, we have to fill in some gaps yet. These are related notions similar to existence and uniqueness (although on uniqueness, “at most one” should be meant here, and the conjunction of both is delayed as a final result).

    Uniqueness of encoding, achieved by minimalization

    Our ultimate question is: what number should stand for the encoding of sequence a 0 , , a n 1 ? The specification declares only an existential quantification, not yet a functional connection. We want a constructive and algorithmic connection: a (total) recursive function that performs the encoding.

    Totality, because minimalization is restricted to special functions

    This gap can be filled in 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 β by meeting its specification). In fact, the specification

    a 0 , , a n 1 s i < n β ( s , i ) = a i

    plays a role here of a more general notion (“special function”). The importance of this notion is that it enables us to split off the (sub)class of (total) recursive functions from the (super)class of partial recursive functions. In brief, the specification says that a function f satisfying the specification

    f ( a 0 , , a n 1 , s ) = 0 i < n ( β ( s , i ) = a i )

    is a special function; that is, for each fixed combination of all-but-last arguments, the function f has root in its last argument:

    a 0 , , a n 1 s ( f ( a 0 , , a n 1 , s ) = 0 )

    The Gödel numbering function g can be chosen to be total recursive

    Thus, let us choose the minimal possible number that fits well in the specification of the β function:

    g : N n N a 0 , , a n 1 μ a . [ i < n ( β ( a , i ) = a i ) ] .

    It can be proven (using the notions of the previous section ) that g is (total) recursive.

    Access of length

    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. 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.

    Length can be stored simply as a surplus member:

    g : N N a 0 , , a n 1 , a n μ a . [ a 0 = n i < n ( β ( a , i + 1 ) = a i ) ] .

    The corresponding modification of the proof is straightforward, by adding a surplus

    x n ( mod m 0 )

    to the system of simultaneous congruences (provided that the surplus member index is chosen to be 0). Also, the assumptions have to be modified accordingly.

    References

    Gödel numbering for sequences Wikipedia