Download 1.4 Pairing Function and Arithmetization Cantor Pairing Function

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

Abuse of notation wikipedia , lookup

Large numbers wikipedia , lookup

Mathematics of radio engineering wikipedia , lookup

Big O notation wikipedia , lookup

Functional decomposition wikipedia , lookup

Series (mathematics) wikipedia , lookup

Continuous function wikipedia , lookup

Elementary mathematics wikipedia , lookup

Dirac delta function wikipedia , lookup

Non-standard calculus wikipedia , lookup

Function (mathematics) wikipedia , lookup

Function of several real variables wikipedia , lookup

History of the function concept wikipedia , lookup

Transcript
1.4 Pairing Function and Arithmetization
15
1.4 Pairing Function and Arithmetization
Cantor Pairing Function
1.4.1 Pairing function. The modi๏ฌed Cantor pairing function is a p.r.
function by the following explicit de๏ฌnition:
๐‘ฅ+๐‘ฆ
โŸจ๐‘ฅ, ๐‘ฆโŸฉ = โˆ‘ ๐‘– + ๐‘ฅ + 1,
๐‘–=0
Figure 1.1 shows the initial segment of values of this modi๏ฌed pairing function
of Cantor in tabular form.
โŸจ๐‘ฅ, ๐‘ฆ โŸฉ
0
1
2
3
4
5
6
โ‹ฎ
0 1 2 3 4 5 6โ‹ฏ
1
3
6
10
15
21
28
โ‹ฎ
2
5
9
14
20
27
35
โ‹ฎ
4
8
13
19
26
34
43
โ‹ฎ
7
12
18
25
33
42
52
โ‹ฎ
11
17
24
32
41
51
62
โ‹ฎ
16
23
31
40
50
61
73
โ‹ฎ
22
30
39
49
60
72
85
โ‹ฎ
โ‹ฏ
โ‹ฏ
โ‹ฏ
โ‹ฏ
โ‹ฏ
โ‹ฏ
โ‹ฏ
Fig. 1.1 The modi๏ฌed Cantor pairing function
1.4.2 Basic properties of the pairing function. We have
โŸจ๐‘ฅ1 , ๐‘ฅ2 โŸฉ = โŸจ๐‘ฆ1 , ๐‘ฆ2 โŸฉ โ†’ ๐‘ฅ1 = ๐‘ฆ1 โˆง ๐‘ฅ2 = ๐‘ฆ2
๐‘ฅ < โŸจ๐‘ฅ, ๐‘ฆโŸฉ โˆง ๐‘ฆ < โŸจ๐‘ฅ, ๐‘ฆโŸฉ
(1)
(2)
๐‘ฅ = 0 โˆจ โˆƒ๐‘ฆโˆƒ๐‘ง ๐‘ฅ = โŸจ๐‘ฆ, ๐‘งโŸฉ.
(3)
Property (1) is called the pairing property and it says that the function is an
injection. Property (2) is needed for induction and/or recursion. From (2) we
get that 0 โ‰  โŸจ๐‘ฅ, ๐‘ฆโŸฉ for every ๐‘ฅ and ๐‘ฆ. This means that 0 is not in the range
of the pairing function and plays the role of the atom nil of Lisp. From this
and (3) we can see that the pairing function is onto the set N โˆ– {0}, i.e. that
0 is the only atom.
1.4.3 Ordering properties of the pairing function. We have
โŸจ๐‘ฅ1 , ๐‘ฅ2 โŸฉ โ‰ค โŸจ๐‘ฆ1 , ๐‘ฆ2 โŸฉ โ†” ๐‘ฅ1 + ๐‘ฅ2 < ๐‘ฆ1 + ๐‘ฆ2 โˆจ ๐‘ฅ1 + ๐‘ฅ2 = ๐‘ฆ1 + ๐‘ฆ2 โˆง ๐‘ฅ1 โ‰ค ๐‘ฆ1
โŸจ๐‘ฅ1 , ๐‘ฅ2 โŸฉ < โŸจ๐‘ฆ1 , ๐‘ฆ2 โŸฉ โ†” ๐‘ฅ1 + ๐‘ฅ2 < ๐‘ฆ1 + ๐‘ฆ2 โˆจ ๐‘ฅ1 + ๐‘ฅ2 = ๐‘ฆ1 + ๐‘ฆ2 โˆง ๐‘ฅ1 < ๐‘ฆ1 .
16
1 Primitive Recursive Functions
1.4.4 Pair representation of natural numbers. The class of pair numerals consists of terms obtained from 0 by ๏ฌnitely many pairing operations.
It can be easily proved by complete induction that every natural number ๐‘ฅ
can be uniquely presented as a pair numeral. We call this the pair representation of natural numbers. Pair numerals can be visualized as ๏ฌnite binary
trees.
Zeroes are leaves and a pair numeral โŸจ๐œ1 , ๐œ2 โŸฉ is a tree with two sons ๐œ1 and
๐œ2 . Figure 1.2 enumerates the ๏ฌnite binary trees corresponding to the pair
numerals. We will denote by โˆฃ๐‘ฅโˆฃp the number of nodes of the tree corresponding to the pair numeral ๐œ = ๐‘ฅ. In other words, โˆฃ๐‘ฅโˆฃp is the number of pairing
operations needed to construct the pair numeral ๐œ = ๐‘ฅ.
In order to obtain a simple recursive characterization of subelementary
complexity classes (such as PTIME) one should use a pairing function such
that โˆฃ๐‘ฅโˆฃp = ๐›บ(lg(๐‘ฅ)). The system CL uses such a function but for the purposes
of this text this requirement is not important and we use a much simpler
pairing function which does not satisfy the requirement.
1.4.5 Projection functions. From the basic properties of the pairing function we can see that every non-zero number ๐‘ฅ can be uniquely written in the
form ๐‘ฅ = โŸจ๐‘ฆ, ๐‘งโŸฉ for some ๐‘ฆ, ๐‘ง. The numbers ๐‘ฆ and ๐‘ง are called the ๏ฌrst and
the second projection of ๐‘ฅ, respectively.
The ๏ฌrst projection function ฯ€1 and second projection ฯ€2 are unary functions satisfying
ฯ€1 (0) = 0
ฯ€2 (0) = 0
ฯ€1 โŸจ๐‘ฅ, ๐‘ฆโŸฉ = ๐‘ฅ
ฯ€2 โŸจ๐‘ฅ, ๐‘ฆโŸฉ = ๐‘ฆ.
The projection functions are p.r. functions by bounded minimalization:
ฯ€1 (๐‘ฅ) = µ๐‘ฆ < ๐‘ฅ[โˆƒ๐‘ง < ๐‘ฅ ๐‘ฅ = โŸจ๐‘ฆ, ๐‘งโŸฉ]
ฯ€2 (๐‘ฅ) = µ๐‘ง < ๐‘ฅ[โˆƒ๐‘ฆ < ๐‘ฅ ๐‘ฅ = โŸจ๐‘ฆ, ๐‘งโŸฉ].
Arithmetization of Tuples
1.4.6 Tuples. In this section we introduce a particular encoding of ordered
๐‘›-tuples of natural numbers based on our pairing function โŸจ๐‘ฅ, ๐‘ฆโŸฉ. Our aim is
to assign to each element (๐‘ฅ1 , . . . , ๐‘ฅ๐‘› ) of the Cartesian product ๐‘ ๐‘› a number
โŒœ(๐‘ฅ1 , . . . , ๐‘ฅ๐‘› )โŒ๐‘› , called the code of (๐‘ฅ1 , . . . , ๐‘ฅ๐‘› ), so that di๏ฌ€erent codes are
assigned to di๏ฌ€erent ๐‘›-tuples. Moreover we would like to have decoding effective. This means we can e๏ฌ€ectively decide whether a number is the code of
an ๐‘›-tuple and if it is, ๏ฌnd that tuple. We will use this encoding throughout
the rest of this text.
1.4.7 Arithmetization. Encoding of Cartesian products ๐‘ ๐‘› , where ๐‘› โ‰ฅ 0,
is de๏ฌned inductively on ๐‘› as follows:
1.4 Pairing Function and Arithmetization
1 = โŸจ0, 0โŸฉ
0
r
@
@
@
@
r
@
@
8 = โŸจ1, 2โŸฉ
r
r
@
@
@
@
@
@
r
r
@
@
@
@
@
@ @
@
@
@
@
@
r
r
r
r
r
15 = โŸจ4, 0โŸฉ
r
r
@
@
@
@
@
@
@
@
@
@
@
@
r
r
r
@
@
r
@
@
@
@
@
@
r
r
21 = โŸจ5, 0โŸฉ
r
r
r
r
r
r
r
22 = โŸจ0, 6โŸฉ
r
r
r
r
Fig. 1.2 Pair representation of natural numbers
@
@
@
@
@
@
@
@
@
@
@
@
@
@
@
@
@
@ @
@
@
@
@
r
@
@
@
@
@
@
@
@
r
19 = โŸจ3, 2โŸฉ
18 = โŸจ2, 3โŸฉ
r
20 = โŸจ4, 1โŸฉ
r
r
r
r
r
@
@
@
@
@
@
r
r
@
@
r
14 = โŸจ3, 1โŸฉ
17 = โŸจ1, 4โŸฉ
r
@
@
r
r
16 = โŸจ0, 5โŸฉ
r
@
@
@
@
@
@
r
@
@
@
@ @
@
@
@
r
r
r
@
@
r
11 = โŸจ0, 4โŸฉ
r
r
@
@
@
@
@
@
@
@
r
r
10 = โŸจ3, 0โŸฉ
13 = โŸจ2, 2โŸฉ
r
r
r
r
12 = โŸจ1, 3โŸฉ
@
@
@
@
@
@
r
@
@
r
r
@
@
@
@
@
@
r
@
@
@
@ @
@
@
@
r
7 = โŸจ0, 3โŸฉ
r
r
@
@
@
@
@
@
@
@
r
@
@
r
6 = โŸจ0, 3โŸฉ
9 = โŸจ2, 1โŸฉ
r
@
@
@
@
r
r
r
r
@
@
@
@
5 = โŸจ1, 1โŸฉ
r
3 = โŸจ1, 0โŸฉ
r
@
@
r
@
@
2 = โŸจ0, 1โŸฉ
r
4 = โŸจ0, 2โŸฉ
17
@
@
@
@
@
@
@
@
r
r
r
r
r
18
1 Primitive Recursive Functions
โŒœโˆ…โŒ0 = 0
โŒœ๐‘ฅโŒ1 = ๐‘ฅ
โŒœ(๐‘ฅ1 , ๐‘ฅ2 , . . . , ๐‘ฅ๐‘› )โŒ๐‘› = โŸจ๐‘ฅ1 , โŒœ(๐‘ฅ2 , . . . , ๐‘ฅ๐‘› )โŒ๐‘›โˆ’1 โŸฉ
if ๐‘› โ‰ฅ 2.
The reader will note that the code of an 1-tuple ๐‘ฅ is the number itself and the
code of the empty tuple โˆ… is the number 0. Note also that โŒœ(๐‘ฅ, ๐‘ฆ)โŒ2 = โŸจ๐‘ฅ, ๐‘ฆโŸฉ.
The reader will also note that these encodings may overlap. Consider, for
instance, the number 2. We have 2 = โŸจ0, 1โŸฉ and 1 = โŸจ0, 0โŸฉ. Therefore
2 = โŸจ0, 1โŸฉ = โŒœ(0, 1)โŒ2
2 = โŸจ0, 1โŸฉ = โŸจ0, โŸจ0, 0โŸฉโŸฉ = โŸจ0, โŒœ(0, 0)โŒ2 โŸฉ = โŒœ(0, 0, 0)โŒ3 .
Hence, the number 2 is the code both of the ordered pair (0, 1) โˆˆ N2 and the
ordered triple (0, 0, 0) โˆˆ N3 .
1.4.8 Notational conventions. We will adopt the following conventions
for the pairing function โŸจ๐‘ฅ, ๐‘ฆโŸฉ. We postulate that the pairing operator groups
to the right, i.e. โŸจ๐‘ฅ, ๐‘ฆ, ๐‘งโŸฉ abbreviates โŸจ๐‘ฅ, โŸจ๐‘ฆ, ๐‘งโŸฉโŸฉ. If ๐œโƒ— โ‰ก (๐œ1 , . . . , ๐œ๐‘› ) is an ๐‘›-tuple
of terms then the term โŸจโƒ—
๐œ โŸฉ stands for โŸจ๐œ1 , . . . , ๐œ๐‘› โŸฉ when ๐‘› โ‰ฅ 2, for ๐œ1 when
๐‘› = 1, and for 0 when ๐‘› = 0. Note that we then have
โŒœ(๐‘ฅ1 , . . . , ๐‘ฅ๐‘› )โŒ๐‘› = โŸจ๐‘ฅ1 , . . . , ๐‘ฅ๐‘› โŸฉ
for every ๐‘› and every element (๐‘ฅ1 , . . . , ๐‘ฅ๐‘› ) of ๐‘ ๐‘› .
1.4.9 Predicate holding of the codes of tuples. For ๐‘› โ‰ฅ 2, we have
โˆƒ๐‘ฅ1 . . . โˆƒ๐‘ฅ๐‘› ๐‘ฅ = โŸจ๐‘ฅ1 , . . . , ๐‘ฅ๐‘› โŸฉ โ†” ฯ€๐‘›โˆ’2
2 (๐‘ฅ) โ‰  0.
Consequently, the binary predicate Tuple(๐‘›, ๐‘ฅ), which holds when ๐‘ฅ is the
code of an ๐‘›-tuple, is primitive recursive by the following explicit de๏ฌnition
Tuple(๐‘›, ๐‘ฅ) โ†” ๐‘› = 0 โˆง ๐‘ฅ = 0 โˆจ ๐‘› = 1 โˆจ ๐‘› โ‰ฅ 2 โˆง ฯ€๐‘›โˆ’2
2 (๐‘ฅ) โ‰  0.
1.4.10 Projection function for tuples. The ternary projection function
๐‘›
[๐‘ฅ]๐‘– selects the ๐‘–-th element of the ๐‘›-tuple coded by ๐‘ฅ, i.e.
๐‘›
[โŸจ๐‘ฅ1 , . . . , ๐‘ฅ๐‘› โŸฉ]๐‘– = ๐‘ฅ๐‘–
for every ๐‘– = 1, . . . , ๐‘›. We clearly have
๐‘›โˆ’1
๐‘›โˆ’1
๐‘ฅ = โŸจ๐‘ฅ1 , . . . , ๐‘ฅ๐‘› โŸฉ โ†’ โ‹€ ๐‘ฅ๐‘– = ฯ€1 ฯ€๐‘–โˆ’1
2 (๐‘ฅ) โˆง ๐‘ฅ๐‘› = ฯ€2 (๐‘ฅ)
๐‘–=1
๐‘›
for ๐‘› โ‰ฅ 2. Thus we can de๏ฌne [๐‘ฅ]๐‘– explicitly as a p.r. function by
1.4 Pairing Function and Arithmetization
19
๐‘›
๐‘›1
[๐‘ฅ]๐‘– = ๐ท(๐‘– โ‰ โˆ— ๐‘›, ฯ€1 ฯ€๐‘–1
2 (๐‘ฅ), ฯ€2 (๐‘ฅ)).
The projection function satis๏ฌes
1
[๐‘ฅ1 ]1 = ๐‘ฅ1
๐‘›+2
[โŸจ๐‘ฅ1 , ๐‘ฅโŸฉ]1
= ๐‘ฅ1
๐‘›+2
[โŸจ๐‘ฅ1 , ๐‘ฅโŸฉ]๐‘–+2
= [๐‘ฅ]๐‘–+1 .
๐‘›+1
1.4.11 Contraction to unary functions. As a simple application of the
arithmetization of ๐‘›-tuples we obtain the following natural correspondence
between ๐‘›-ary and unary functions. If ๐‘“ is an ๐‘›-ary function then its contraction is the unary function โŸจ๐‘“ โŸฉ such that
โŽง
โŽช
โŽช๐‘“ (๐‘ฅ1 , . . . , ๐‘ฅ๐‘› )
โŸจ๐‘“ โŸฉ(๐‘ฅ) = โŽจ
โŽช
0
โŽช
โŽฉ
if ๐‘ฅ = โŸจ๐‘ฅ1 , . . . , ๐‘ฅ๐‘› โŸฉ for some numbers ๐‘ฅ1 , . . . , ๐‘ฅ๐‘› ,
if there are no such numbers.
Note that the contraction of an unary function is the function itself.
We can de๏ฌne the contraction of ๐‘“ explicitly by
๐‘›
๐‘›
โŸจ๐‘“ โŸฉ(๐‘ฅ) = ๐ท(Tuple โˆ— (๐‘›, ๐‘ฅ), ๐‘“ ([๐‘ฅ]1 , . . . , [๐‘ฅ]๐‘› ), 0).
Vice versa, we can recover ๐‘“ from its contraction by
๐‘“ (๐‘ฅ1 , . . . , ๐‘ฅ๐‘› ) = โŸจ๐‘“ โŸฉ(โŸจ๐‘ฅ1 , . . . , ๐‘ฅ๐‘› โŸฉ).
Thus a function is primitive recursive if and only if its contraction is.
Arithmetization of Finite Sequences
1.4.12 Finite sequences. Now we consider the problem of the arithmetization of ๏ฌnite sequences of natural numbers. Mathematically speaking, ๏ฌnite
sequences are just tuples of variable length and so the set of all such sequences
is the in๏ฌnite union โ‹ƒ๐‘›โˆˆN N๐‘› . We cannot use the method of codings of tuples
of ๏ฌxed length since such encodings overlap. Our uniform encoding of ๏ฌnite
sequences is based on the fact that the number 0 is the atom, i.e. it is not in
the range of the pairing function โŸจ๐‘ฅ, ๐‘ฆโŸฉ.
1.4.13 Arithmetization. A uniform method for coding of ๏ฌnite sequences
of numbers into N is obtained as follows. We assign the code 0 to the
empty sequence โˆ…. A non-empty sequence ๐‘ฅ1 , . . . , ๐‘ฅ๐‘› is coded by the number
โŸจ๐‘ฅ1 , ๐‘ฅ2 , . . . , ๐‘ฅ๐‘› , 0โŸฉ as shown in Fig. 1.3. The number โŸจ๐‘ฅ1 , ๐‘ฅ2 , . . . , ๐‘ฅ๐‘› , 0โŸฉ is often
called the sequence number of the sequence ๐‘ฅ1 , . . . , ๐‘ฅ๐‘› .
20
1 Primitive Recursive Functions
The reader will note that the assignment of codes is one to one: i.e. every
๏ฌnite sequence of natural numbers is coded by exactly one natural number,
and vice versa, every natural number is the code of exactly one ๏ฌnite sequence
of natural numbers.
r
๐‘ฅ
@
@
0
r
@
@
@
@
r
r
๐‘ฅ
๐‘ฆ
@
@
@
@
๐‘ฆ
@
@
r
๐‘ฅ
0
r
๐‘ฅ1
r
๐‘ง
@
@
@
@
r
๐‘ฅ2
p
p
p
r
0
๐‘ฅ๐‘›
โŸจ๐‘ฅ, 0โŸฉ
โŸจ๐‘ฅ, ๐‘ฆ, 0โŸฉ
โŸจ๐‘ฅ, ๐‘ฆ, ๐‘ง, 0โŸฉ
@
@
0
โŸจ๐‘ฅ1 , ๐‘ฅ2 , . . . , ๐‘ฅ๐‘› , 0โŸฉ
Fig. 1.3 Arithmetization of ๏ฌnite sequences
1.4.14 Length of sequences. The code ๐‘ฅ = โŸจ๐‘ฅ1 , ๐‘ฅ2 , . . . , ๐‘ฅ๐‘› , 0โŸฉ of the sequence ๐‘ฅ1 , . . . , ๐‘ฅ๐‘› has the length ๐‘›. The function ๐ฟ(๐‘ฅ) yielding the length of
๐‘ฅ is introduced by the bounded minimalization as a p.r. function:
๐ฟ(๐‘ฅ) = µ๐‘› โ‰ค ๐‘ฅ[ฯ€๐‘›2 (๐‘ฅ) = 0].
The function satis๏ฌes
๐ฟ(0) = 0
๐ฟ โŸจ๐‘ฃ, ๐‘คโŸฉ = ๐ฟ(๐‘ค) + 1.
1.4.15 Indexing function. The indexing function (๐‘ฅ)๐‘– yields the (๐‘– + 1)-st
element of the sequence ๐‘ฅ, i.e.
(โŸจ๐‘ฅ0 , . . . , ๐‘ฅ๐‘– , . . . , ๐‘ฅ๐‘›โˆ’1 , 0โŸฉ)๐‘– = ๐‘ฅ๐‘– .
The function is de๏ฌned explicitly by
(๐‘ฅ)๐‘– = ฯ€1 ฯ€๐‘–2 (๐‘ฅ)
as a primitive recursive function.
The recurrent properties of the indexing function are:
(โŸจ๐‘ฃ, ๐‘คโŸฉ)0 = ๐‘ฃ
(โŸจ๐‘ฃ, ๐‘คโŸฉ)๐‘–+1 = (๐‘ค)๐‘– .