HOME

TheInfoList



OR:

In
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, a pairing function is a process to uniquely encode two natural numbers into a single natural number. Any pairing function can be used in set theory to prove that integers and rational numbers have the same
cardinality In mathematics, the cardinality of a set is a measure of the number of elements of the set. For example, the set A = \ contains 3 elements, and therefore A has a cardinality of 3. Beginning in the late 19th century, this concept was generalized ...
as natural numbers.


Definition

A pairing function is a
bijection In mathematics, a bijection, also known as a bijective function, one-to-one correspondence, or invertible function, is a function between the elements of two sets, where each element of one set is paired with exactly one element of the other s ...
:\pi:\mathbb \times \mathbb \to \mathbb. More generally, a pairing function on a set ''A'' is a function that maps each pair of elements from ''A'' into an element of ''A'', such that any two pairs of elements of ''A'' are associated with different elements of ''A,'' or a bijection from A^2 to ''A''.


Hopcroft and Ullman pairing function

Hopcroft and Ullman (1979) define the following pairing function: \langle i, j\rangle := \frac(i+j-2)(i+j-1) + i, where i, j\in\. This is the same as the Cantor pairing function below, shifted to exclude 0 (i.e., i=k_2+1, j=k_1+1, and \langle i, j\rangle - 1 = \pi(k_2,k_1)).


Cantor pairing function

The Cantor pairing function is a primitive recursive pairing function :\pi:\mathbb \times \mathbb \to \mathbb defined by :\pi(k_1,k_2) := \frac(k_1 + k_2)(k_1 + k_2 + 1)+k_2 where k_1, k_2\in\. It can also be expressed as Pair
, y The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
:= \frac. It is also strictly monotonic w.r.t. each argument, that is, for all k_1, k_1', k_2, k_2' \in \mathbb, if k_1 < k_', then \pi(k_1, k_2) < \pi(k_1', k_2); similarly, if k_2 < k_', then \pi(k_1, k_2) < \pi(k_1, k_2'). The statement that this is the only quadratic pairing function is known as the
Fueter–Pólya theorem The Fueter–Pólya theorem, first proved by Rudolf Fueter and George Pólya, states that the only quadratic polynomial pairing functions are the Cantor polynomials. Introduction In 1873, Georg Cantor showed that the so-called Cantor pol ...
. Whether this is the only polynomial pairing function is still an open question. When we apply the pairing function to and we often denote the resulting number as . This definition can be inductively generalized to the :\pi^:\mathbb^n \to \mathbb for n > 2 as :\pi^(k_1, \ldots, k_, k_n) := \pi ( \pi^(k_1, \ldots, k_) , k_n) with the base case defined above for a pair: \pi^(k_1,k_2) := \pi(k_1,k_2).


Inverting the Cantor pairing function

Let z \in \mathbb be an arbitrary natural number. We will show that there exist unique values x, y \in \mathbb such that : z = \pi(x, y) = \frac + y and hence that the function is invertible. It is helpful to define some intermediate values in the calculation: : w = x + y \! : t = \fracw(w + 1) = \frac : z = t + y \! where is the triangle number of . If we solve the quadratic equation : w^2 + w - 2t = 0 \! for as a function of , we get : w = \frac which is a strictly increasing and continuous function when is non-negative real. Since : t \leq z = t + y < t + (w + 1) = \frac we get that : w \leq \frac < w + 1 and thus : w = \left\lfloor \frac \right\rfloor. where is the floor function. So to calculate and from , we do: : w = \left\lfloor \frac \right\rfloor : t = \frac : y = z - t \! : x = w - y. \! Since the Cantor pairing function is invertible, it must be
one-to-one One-to-one or one to one may refer to: Mathematics and communication *One-to-one function, also called an injective function *One-to-one correspondence, also called a bijective function *One-to-one (communication), the act of an individual comm ...
and onto.


Examples

To calculate : :, :, :, :, :, so . To find and such that : :, :, :, :, :, :, so ; :, :, :, so ; :, so ; :, so ; thus .


Derivation

The graphical shape of Cantor's pairing function, a diagonal progression, is a standard trick in working with infinite sequences and countability. The algebraic rules of this diagonal-shaped function can verify its validity for a range of polynomials, of which a quadratic will turn out to be the simplest, using the
method of induction Mathematical induction is a method for proving that a statement ''P''(''n'') is true for every natural number ''n'', that is, that the infinitely many cases ''P''(0), ''P''(1), ''P''(2), ''P''(3), ...  all hold. Informal metaphors help ...
. Indeed, this same technique can also be followed to try and derive any number of other functions for any variety of schemes for enumerating the plane. A pairing function can usually be defined inductively – that is, given the th pair, what is the th pair? The way Cantor's function progresses diagonally across the plane can be expressed as :\pi(x,y)+1 = \pi(x-1,y+1). The function must also define what to do when it hits the boundaries of the 1st quadrant – Cantor's pairing function resets back to the x-axis to resume its diagonal progression one step further out, or algebraically: :\pi(0,k)+1 = \pi(k+1,0). Also we need to define the starting point, what will be the initial step in our induction method: . Assume that there is a quadratic 2-dimensional polynomial that can fit these conditions (if there were not, one could just repeat by trying a higher-degree polynomial). The general form is then :\pi(x,y) = ax^2+by^2+cxy+dx+ey+f. Plug in our initial and boundary conditions to get and: :bk^2+ek+1 = a(k+1)^2+d(k+1), so we can match our terms to get : : :. So every parameter can be written in terms of except for , and we have a final equation, our diagonal step, that will relate them: :\begin \pi(x,y)+1 &= a(x^2+y^2) + cxy + (1-a)x + (1+a)y + 1 \\ &= a((x-1)^2+(y+1)^2) + c(x-1)(y+1) + (1-a)(x-1) + (1+a)(y+1). \end Expand and match terms again to get fixed values for and , and thus all parameters: : : : :. Therefore :\begin \pi(x,y) &= \frac(x^2+y^2) + xy + \fracx + \fracy \\ &= \frac(x+y)(x+y+1) + y, \end is the Cantor pairing function, and we also demonstrated through the derivation that this satisfies all the conditions of induction.


Other pairing functions

The function P_2(x, y):= 2^x(2y + 1) - 1 is a pairing function. In 1990, Regan proposed the first known pairing function that is computable in
linear time In computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by ...
and with constant space (as the previously known examples can only be computed in linear time iff multiplication can be too, which is doubtful). In fact, both this pairing function and its inverse can be computed with finite-state transducers that run in real time. In the same paper, the author proposed two more monotone pairing functions that can be computed online in linear time and with logarithmic space; the first can also be computed offline with zero space. In 2001, Pigeon proposed a pairing function based on bit-interleaving, defined recursively as: :\langle i,j\rangle_=\begin T & \text\ i=j=0;\\ \langle\lfloor i/2\rfloor,\lfloor j/2\rfloor\rangle_:i_0:j_0&\text \end where i_0 and j_0 are the
least significant bits In computing, bit numbering is the convention used to identify the bit positions in a binary number. Bit significance and indexing In computing, the least significant bit (LSB) is the bit position in a binary integer representing the bi ...
of ''i'' and ''j'' respectively. In 2006, Szudzik proposed a "more elegant" pairing function defined by the expression: :\operatorname
, y The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
:= \begin y^2 + x&\text\ x\neq\max\,\\ x^2 + x + y&\text\ x = \max\.\\ \end Which can be unpaired using the expression: :\operatorname := \begin \left\ & \textz - \lfloor\sqrt\rfloor^2 < \lfloor\sqrt\rfloor, \\ \left\ & \textz - \lfloor\sqrt\rfloor^2\geq\lfloor\sqrt\rfloor. \end (Qualitatively, it assigns consecutive numbers to pairs along the edges of squares.) This pairing function orders SK combinator calculus expressions by depth. This method is the mere application to \N of the idea, found in most textbooks on Set Theory,See for instance used to establish \kappa^2=\kappa for any infinite cardinal \kappa in ZFC. Define on \kappa\times\kappa the binary relation :(\alpha,\beta)\preccurlyeq(\gamma,\delta) \text \begin (\alpha,\beta) = (\gamma,\delta),\\ pt\max(\alpha,\beta) < \max(\gamma,\delta),\\ pt\max(\alpha,\beta) = \max(\gamma,\delta)\ \text\ \alpha<\gamma,\text\\ pt\max(\alpha,\beta) = \max(\gamma,\delta)\ \text\ \alpha=\gamma\ \text\ \beta<\delta. \end \preccurlyeq is then shown to be a well-ordering such that every element has <\kappa predecessors, which implies that \kappa^2=\kappa. It follows that (\N\times\N,\preccurlyeq) is isomorphic to (\N,\leqslant) and the pairing function above is nothing more than the enumeration of integer couples in increasing order. (See also Talk:Tarski's theorem about choice#Proof of the converse.)


Notes


References

{{reflist Set theory Georg Cantor Functions and mappings