* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download 1.4 Pairing Function and Arithmetization Cantor Pairing Function
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
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 = (๐ค)๐ .