Gödel numbering for sequences

From HandWiki

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]

Gödel numbering

Main page: 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.

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,[5] 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 [math]\displaystyle{ \langle a_0,\dots a_{n-1} \rangle }[/math], there exists an appropriate natural number a, called the Gödel number of the sequence, such that for all i where [math]\displaystyle{ 0\le i \le n-1 }[/math], [math]\displaystyle{ f(a,i) = a_i }[/math].

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 [math]\displaystyle{ \beta }[/math] (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 [math]\displaystyle{ \beta }[/math] function using the Chinese remainder theorem in his article written in 1931. This is a primitive recursive function.[6]

Thus, for all n and for any n-length sequence of natural numbers [math]\displaystyle{ \langle a_0,\dots a_{n-1} \rangle }[/math], there exists an appropriate natural number a, called the Gödel number of the sequence such that [math]\displaystyle{ \beta(a,i) = a_i }[/math].[7]

Using a pairing function

Main page: 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 [math]\displaystyle{ \pi }[/math], K, and L denote the pairing function and its two projection functions, respectively, satisfying specification

[math]\displaystyle{ K\left(\pi\left(x,y\right)\right) = x }[/math]
[math]\displaystyle{ L\left(\pi\left(x,y\right)\right) = y }[/math]

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:

  • [math]\displaystyle{ \mathrm{rem}(5, 3) = 2 }[/math]
  • [math]\displaystyle{ \mathrm{rem}(7, 2) = 1 }[/math]

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 [math]\displaystyle{ \beta }[/math] as

[math]\displaystyle{ \beta(s,i) = \mathrm{rem}\left(K\left(s\right),\left(i+1\right)\cdot L\left(s\right)+1\right) }[/math]

will work, according to the specification we expect [math]\displaystyle{ \beta }[/math] to satisfy. We can use a more concise form by an abuse of notation (constituting a sort of pattern matching):

[math]\displaystyle{ \beta\left(\pi\left(x_0,m\right),i\right) = \mathrm{rem}\left(x_0, \left(i+1\right)\cdot m+1\right) }[/math]

Let us achieve even more readability by more modularity and reuse (as these notions are used in computer science[8]): by defining [math]\displaystyle{ \forall i\lt n }[/math] the sequence [math]\displaystyle{ m_i = (i+1)\cdot m+1 }[/math], we can write

[math]\displaystyle{ \beta\left(\pi\left(x_0,m\right),i\right) = \mathrm{rem}\left(x_0, m_i\right) }[/math].

We shall use this [math]\displaystyle{ m_i }[/math] notation in the proof.

Hand-tuned assumptions

For proving the correctness of the above definition of the [math]\displaystyle{ \beta }[/math] 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 [math]\displaystyle{ a_0,\dots a_{n-1} }[/math] be a sequence of natural numbers. Let m be chosen to satisfy

[math]\displaystyle{ \forall i \in \overline n \setminus \left\{0\right\} \left(i \mid m\right) }[/math]
[math]\displaystyle{ \forall i \lt n \left( a_i \lt m_i \right) }[/math]

The first assumption is meant as

[math]\displaystyle{ 1 \mid m \land \dots \land n-1 \mid m }[/math]

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,[1] but the stronger premise is not required for this proof.[2]

The second assumption does not concern the Chinese remainder theorem in any way. It will have importance in proving that the specification for [math]\displaystyle{ \beta }[/math] is met eventually. It ensures that an [math]\displaystyle{ \tilde x }[/math] solution of the simultaneous congruence system

[math]\displaystyle{ x \equiv a_i \pmod{m_i} }[/math] for each i where [math]\displaystyle{ 0\le i \le n-1 }[/math]

also satisfies

[math]\displaystyle{ a_i = \mathrm{rem}(\tilde x, m_i) }[/math].[5][9]

A stronger assumption for m requiring [math]\displaystyle{ \forall i \lt n \; (a_i \lt m) }[/math] automatically satisfies the second assumption (if we define the notation [math]\displaystyle{ m_i }[/math] as above).

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

In the section Hand-tuned assumptions, we required that

[math]\displaystyle{ \forall i \in \overline n \setminus \left\{0\right\} \left(i \mid m\right) }[/math]. 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:

[math]\displaystyle{ \forall i\lt n,j \lt n \; \left( i \neq j \rightarrow \mathrm{coprime}\left(m_i,m_j\right) \right) }[/math]

remembering that [math]\displaystyle{ \forall i\lt n }[/math] we defined [math]\displaystyle{ m_i = (i+1)\cdot m+1 }[/math].

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

[math]\displaystyle{ \exists i\lt n,j \lt n \; \left( i \neq j \land \lnot \mathrm{coprime}\left(m_i,m_j\right) \right) }[/math]

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:

[math]\displaystyle{ \exists i\lt n,j \lt n \; \left( i \neq j \land \exists p \in \mathrm{Prime} \; \left( p \mid m_i \land p \mid m_j \right) \right) }[/math]

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

[math]\displaystyle{ \exists i\lt n,j \lt n,p \in \mathrm{Prime} \; \left( i \neq j \land p \mid m_i \land p \mid m_j \right) }[/math]

Because of a theorem on divisibility, [math]\displaystyle{ p \mid m_i \land p \mid m_j }[/math] allows us to also say

[math]\displaystyle{ p \mid m_i - m_j }[/math].

Substituting the definitions of [math]\displaystyle{ m_k }[/math]-sequence notation, we get [math]\displaystyle{ m_i - m_j = (i-j) \cdot m }[/math], thus (as equality axioms postulate identity to be a congruence relation[10]) we get

[math]\displaystyle{ p \mid (i-j) \cdot m }[/math].

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

[math]\displaystyle{ p \mid i-j \lor p \mid m }[/math].

Resorting to the first hand-tuned assumption

Now we must resort to our assumption

[math]\displaystyle{ \forall i \in \overline n \setminus \left\{0\right\} \left(i \mid m\right) }[/math].

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 [math]\displaystyle{ i\lt n\land j\lt n \land i\neq j }[/math]; this entails [math]\displaystyle{ i-j \in \overline n \setminus \left\{0\right\} }[/math], thus the mentioned assumption can be applied, so [math]\displaystyle{ i-j \mid m }[/math] holds.

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

We can prove by several means [11] known in propositional calculus that

[math]\displaystyle{ \left(A \land \left( A \rightarrow B\right)\right) \rightarrow B }[/math]

holds.

Since [math]\displaystyle{ i-j \mid m }[/math], by the transitivity property of the divisibility relation, [math]\displaystyle{ p \mid i-j \rightarrow p \mid m }[/math]. Thus (as equality axioms postulate identity to be a congruence relation [10])

[math]\displaystyle{ p \mid m }[/math]

can be proven.

Reaching the contradiction

The negation of original statement contained

[math]\displaystyle{ p \mid m_i }[/math]

and we have just proved

[math]\displaystyle{ p \mid m }[/math].

Thus,

[math]\displaystyle{ p \mid m_i - \left(i+1\right)\cdot m }[/math]

should also hold. But after substituting the definition of [math]\displaystyle{ m_i }[/math],

[math]\displaystyle{ m_i - \left(i+1\right)\cdot m = 1 }[/math]

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

[math]\displaystyle{ p \mid 1 }[/math]

should also hold.

However, in the negation of the original statement p is existentially quantified and restricted to primes [math]\displaystyle{ \exists p \in \mathrm{Prime} }[/math]. 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:

[math]\displaystyle{ \forall i\lt n,j\lt n \; \left( i \neq j \rightarrow \mathrm{coprime}\left(m_i,m_j\right)\right) }[/math]

The system of simultaneous congruences

We build a system of simultaneous congruences

[math]\displaystyle{ x \equiv a_0 \pmod{m_0} }[/math]
[math]\displaystyle{ \vdots }[/math]
[math]\displaystyle{ x \equiv a_{n-1} \pmod{m_{n-1}} }[/math]

We can write it in a more concise way:

[math]\displaystyle{ \forall i \lt n \; \left(x \equiv a_i \pmod{m_i}\right) }[/math]

Many statements will be said below, all beginning with "[math]\displaystyle{ \forall i \lt n \; \left(\dots\right) }[/math]". To achieve a more ergonomic treatment, from now on all statements should be read as being in the scope of an [math]\displaystyle{ \forall i \lt n \; \left(\dots\right) }[/math] quantification. Thus, [math]\displaystyle{ \forall i \lt n ( }[/math] begins here.

Let us chose a solution [math]\displaystyle{ x_0 }[/math] for the system of simultaneous congruences. At least one solution must exist, because [math]\displaystyle{ m_0,\dots m_{n-1} }[/math] 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 [math]\displaystyle{ x_0 }[/math] as satisfying

[math]\displaystyle{ x_0 \equiv a_i \pmod{m_i} }[/math],

which means (by definition of modular arithmetic) that

[math]\displaystyle{ \mathrm{rem}\left(x_0,m_i\right) = \mathrm{rem}\left(a_i,m_i\right) }[/math]

Resorting to the second hand-tuned assumption

Recall the second assumption, “[math]\displaystyle{ \forall i \lt n \; \left(a_i \lt m_i \right) }[/math]”, 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 [math]\displaystyle{ a_i \lt m_i }[/math] implies that

[math]\displaystyle{ \mathrm{rem}\left(a_i,m_i\right) = a_i }[/math].

Now by transitivity of equality we get

[math]\displaystyle{ \mathrm{rem}\left(x_0,m_i\right) = a_i }[/math].

QED

Our original goal was to prove that the definition

[math]\displaystyle{ \beta\left(\pi\left(x_0,m\right),i\right) = \mathrm{rem}\left(x_0,m_i\right) }[/math]

is good for achieving what we declared in the specification of [math]\displaystyle{ \beta }[/math]: we want [math]\displaystyle{ \beta\left(\pi\left(x_0,m\right),i\right) = a_i }[/math] 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 [math]\displaystyle{ \beta }[/math]: its specification requiring

[math]\displaystyle{ \forall a_0,\dots, a_{n-1}\;\exists s\;\forall i \lt n \; \beta(s,i) = a_i }[/math]

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 [math]\displaystyle{ \left\langle a_0,\dots,a_{n-1}\right\rangle }[/math]? 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 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 [math]\displaystyle{ \beta }[/math] by meeting its specification). In fact, the specification

[math]\displaystyle{ \forall a_0,\dots, a_{n-1}\;\exists s\;\forall i \lt n \; \beta(s,i) = a_i }[/math]

plays a role here of a more general notion (“special function”[12]). 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 [13] satisfying the specification

[math]\displaystyle{ f\left(a_0,\dots, a_{n-1}, s\right) = 0 \leftrightarrow \forall i \lt n \; \left(\beta(s,i) = a_i\right) }[/math]

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

[math]\displaystyle{ \forall a_0,\dots,a_{n-1}\;\exists s\; \left(f\left(a_0,\dots,a_{n-1},s\right)=0\right) }[/math]

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 [math]\displaystyle{ \beta }[/math] function:[5]

[math]\displaystyle{ g : \mathbb N^n \to \mathbb N }[/math]
[math]\displaystyle{ \left\langle a_0,\dots,a_{n-1}\right\rangle \longmapsto \mu a . \left[ \forall i \lt n \; \left(\beta\left(a,i\right) = a_i\right)\right] }[/math].

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.[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:[5]

[math]\displaystyle{ g : \mathbb N^* \to \mathbb N }[/math]
[math]\displaystyle{ \left\langle a_0,\dots,a_{n-1}, a_n\right\rangle \longmapsto \mu a . \left[ a_0 = n \land \forall i \lt n \; \left(\beta\left(a,i+1\right) = a_i\right)\right] }[/math].

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

[math]\displaystyle{ x \equiv n \pmod{m_0} }[/math]

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.

Notes

  1. 1.0 1.1 Monk 1976: 56–58
  2. 2.0 2.1 Csirmaz 1994: 99–100 (see online)
  3. Monk 1976: 72–74
  4. Monk 1976: 52–55
  5. 5.0 5.1 5.2 5.3 Csirmaz 1994: 100 (see online)
  6. Smullyan 2003: 56 (= Chpt IV, § 5, note 1)
  7. Monk 1976: 58 (= Thm 3.46)
  8. Hughes 1989 (see online )
  9. Burris 1998: Supplementary Text, Arithmetic I, Lemma 4
  10. 10.0 10.1 see also related notions, e.g. “equals for equals” (referential transparency), and another related notion Leibniz's law / identity of indiscernibles
  11. either proof theoretic (algebraic steps); or semantic (truth table, method of analytic tableaux, Venn diagram, Veitch diagram / Karnaugh map)
  12. Monk 1976: 45 (= Def 3.1.)
  13. E.g. defined by
    [math]\displaystyle{ f : \mathbb N^{n+1} \to \mathbb N }[/math]
    [math]\displaystyle{ f\left(a_0,\dots, a_{n-1}, s\right) = \begin{cases}0 & \mathrm{if}\;\forall i \lt n \; \left(\beta(s,i) = a_i\right) \\ 1 & \mathrm{if}\;\exists i \lt n \; \left( \beta(s,i) \neq a_i \right)\end{cases} }[/math]
  14. Monk 1976: 53 (= Def 3.20, Lem 3.21)
  15. Csirmaz 1994: 101 (=Thm 10.7, Conseq 10.8), see online

References

External links