![On Two Infinite Families of Pairing Bijections](https://data.docslib.org/img/3a60ab92a6e30910dab9bd827208bcff-1.webp)
1 On Two Infinite Families of Pairing Bijections Paul Tarau Department of Computer Science and Engineering University of North Texas Denton, Texas Email: [email protected] Abstract—We describe two general mechanisms for producing pair- The characteristic-function mechanism, while intuitively obvious, 2 ing bijections (bijective functions defined from N ! N). The first opens the doors, in combination with a framework providing bijec- mechanism, using n-adic valuations results in parameterized algorithms tions between them and arbitrary data-types [18], to custom-build generating a countable family of distinct pairing bijections. The second arbitrarily intricate pairing functions associated to for instance to mechanism, using characteristic functions of subsets of N provides 2N distinct pairing bijections. Mechanisms to combine such pairing “interesting” sequences of natural numbers or binary expansions of functions and their application to generate families of permutations of [15] real numbers. N are also described. The paper uses a small subset of the functional We will use a subset of the non-strict functional language Haskell language Haskell to provide type checked executable specifications of all the functions defined in a literate programming style. The self- (seen as an equational notation for typed λ-calculus) to provide contained Haskell code extracted from the paper is available at http: executable definitions of mathematical functions on N, pairs in N×N, //logic.cse.unt.edu/tarau/research/2012/infpair.hs . subsets of N, and sequences of natural numbers. We mention, for the Keywords: pairing / unpairing functions, data type isomorphisms, infinite benefit of the reader unfamiliar with the language, that a notation data objects, lazy evaluation, functional programming. like f x y stands for f(x; y), [t] represents sequences of type t and a type declaration like f :: s -> t -> u stands for a function f : s × t ! u (modulo Haskell’s “currying” operation, I. INTRODUCTION given the isomorphism between the function spaces s × t ! u and s ! t ! u). Our Haskell functions are always represented as sets Definition 1: A pairing bijection is a bijection f : × ! . N N N of recursive equations guided by pattern matching, conditional to Its inverse f −1 is called an unpairing bijection. constraints (simple arithmetic relations following | and before the We are emphasizing here the fact that these functions are bijections = symbol). Locally scoped helper functions are defined in Haskell as the name pairing function is sometime used in the literature to after the where keyword, using the same equational style. The indicate injective functions from × to . N N N composition of functions f and g is denoted f . g. It is also Pairing bijections have been used in the first half of 19-th century customary in Haskell, when defining functions in an equational style by Cauchy as a mechanism to express duble summations as simple (using =) to write f = g instead of f x = g x (“point-free” notation). summations in series. They have been made famous by their uses in The use of Haskell’s “call-by-need” evaluation allows us to work with the second half of the 19-th century by Cantor’s work on foundations infinite sequences, like the [0..] infinite list notation, corresponding of set theory. Their most well known application is to show that to the set N itself. infinite sets like N and N×N have the same cardinality. A classic use in the theory of recursive functions is to reduce functions on multiple II. DERIVING PAIRING BIJECTIONS FROM n-ADIC VALUATIONS arguments to single argument functions. Reasons on why they are an interesting object of study in terms of practical applications ranging We first overview a mechanism for deriving pairing bijections from from multi-dimensional dynamic arrays to proximity search using one-solution Diophantine equations. Let us observe that + space filling curves are described in [4], [6], [7], [14]. Proposition 1: 8z 2 N = N − f0g the Diophantine equation 1 x Like in the case of Cantor’s original function f(x; y) = 2 (x + 2 (2y + 1) = z (1) y)(x + y + 1) + y, pairing bijections have been usually hand-crafted arXiv:1301.0129v1 [cs.MS] 1 Jan 2013 by putting to work geometric or arithmetic intuitions. has exactly one solution x; y 2 N. While it is easy to prove (non-constructively) that there is an This follows immediately from the unicity of the decomposition of uncountable family of distinct pairing bijections, we have not seen a natural number as a multiset of prime factors. Note that a slight in the literature general mechanisms for building families of pairing modification of equation 1 results in the pairing bijection originally introduced in [3], [8], seen as a mapping between the pair (x; y) and bijections indexed by N or 2N. It is even easier to generate (construc- z. tively) a countable family of pairing functions simply by modifying x its result of a fixed pairing function with a reversible operation (e.g 2 (2y + 1) − 1 = z (2) XOR with a natural number, seen as the index of the family). We will generalize this mechanism to obtain a family of bijections + This paper introduces two general mechanisms for generating between N × N and N (and the corresponding pairing bijections such families, using n-adic valuations (section II) and characteristic between N × N and N) by choosing an arbitrary base b instead of 2. functions of subsets of N (section III), followed by a discussion of Definition 2: Given a number n 2 N; n > 1, the n-adic valuation related work (section IV) and our conclusions (section V). of a natural number m is the largest exponent k of n, such that nk We will give here a glimpse of why our arguably more complex divides m. It is denoted νn(m). pairing bijections are interesting. Note that the solution x of the equation (1) is actually ν2(z). This The n-adic valuation based pairing functions will provide a general suggest deriving similar Diophantine equations for an arbitrary n-adic mechanism for designing strongly asymmetric pairing functions, valuation. We start by observing that the following holds: where changes in one of the arguments have an exponential impact Proposition 2: 8b 2 N; b > 1; 8y 2 N if 9q; m such that b > on the result. m > 0; y = bq + m, then there’s exactly one pair (y0; m0), b − 1 > 2 m0 ≥ 0 such that y0 = (b − 1)q + m0 and the function associating nAdicUnPair :: N!N!(N,N) (y0; m0) to (y; m) is a bijection. nAdicUnPair b n = nAdicDeCons b (n+1) Proof: y = bq + m; b > m > 0 can be rewritten as y − q − 1 = bq − q + m − 1; b > m > 0, or equivalently y − q − 1 = (b − 1)q + nAdicPair :: N!(N,N)!N (m−1); b > m > 0 from where it follows that setting y0 = y−q−1 nAdicPair b xy = (nAdicCons b xy)-1 0 and m = m − 1 ensures the existence and unicity of y’ and m’ such One can see that we obtain a countable family of bijections fb : 0 0 0 that y = (b−1)q +m and b−1 > m > 0. We can therefore define N × N ! N indexed by b 2 N, b > 1. a function f that transforms a pair (y; m), such that y = bq + m The following examples illustrate the work of these bijections for with b > m > 0, into a pair (y0; m0), such that y0 = q(b − 1) + m0 b = 3. Note the use of Haskell’s higher-order function “map”, that with b − 1 > m0 ≥ 0. Note that the transformation works also in the applies the function nAdicUnPair 3 to a list of elements and opposite direction with y0 = y − q − 1 giving y = y0 + q + 1, and collects the results to a list, and the special value “it”, standing with m0 = m − 1 giving m = m0 + 1. Therefore f is a bijection. for the previously computed result. Proposition 3: 8b 2 N; b > 1; 8z 2 N; z > 0 the system of *InfPair> map (nAdicUnPair 3) [0..7] Diophantine equations and inequations [(0,0),(0,1),(1,0),(0,2),(0,3),(1,1),(0,4),(0,5)] x 0 *InfPair> map (nAdicPair 3) it b ∗ (y + q + 1) = z (3) [0,1,2,3,4,5,6,7] y0 = (b − 1)q + m0 (4) 1) Deriving bijections between N and [N]: For each base b>1, b − 1 > m0 ≥ 0 (5) we can also obtain a pair of bijections between natural numbers and lists of natural numbers in terms of nAdicHead, nAdicTail and has exactly one solution x; y0 2 . N nAdicCons: Proof: Let f −1 be the inverse of the bijection f defined in Proposition 2. Then f −1 provides the desired unique mapping, that nat2nats :: N!N![N] gives y = y0 +q+1 and m = m0 −1 such that b > m > 0. Therefore nat2nats _ 0 = [] y ≡ m (mod b) with m > 0. And as y is not divisible with b, we can nat2nats b n j n>0 = nAdicHead b n : nat2nats b (nAdicTail b n) determine uniquely x as the largest power of b dividing z, x = νb(z). nats2nat :: N [N] N We implement, for and arbitrary b 2 , the Haskell code cor- ! ! N nats2nat _ [] = 0 responding to these bijections as the functions nAdicCons b and + nats2nat b (x:xs) = nAdicCons b (x,nats2nat b xs) nAdicDeCons b, defined between N × N and N . The following example illustrate how they work: nAdicCons :: N!(N,N)!N nAdicCons b (x,y’) j b>1 = (bˆx)∗y where *InfPair> nat2nats 3 2012 q = y’ ‘div‘ (b-1) [0,2,2,0,0,0,0] y = y’+q+1 *InfPair> nats2nat 3 it 2012 nAdicDeCons :: N!N!(N,N) nAdicDeCons b z j b>1 && z>0 = (x,y’) where Using the framework introduced in [16], [18] and summarized in hd n = if n ‘mod‘ b > 0 then 0 else 1+hd (n ‘div‘ b) the Appendix, we can “reify” these bijections as Encoders between x = hd z natural numbers and sequences of natural numbers (parameterized by y = z ‘div‘ (bˆx) the first argument of nAdicHead and nAdicTail).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages7 Page
-
File Size-